diff options
author | Florian Jung <flo@windfisch.org> | 2011-09-14 13:55:37 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-09-14 13:55:37 +0000 |
commit | 539b0f88b82d7f0f9c625165c815cbbe19599b1c (patch) | |
tree | affc9cf66b206b5dd9eee635c335c839277bfa75 /muse2/muse/app.cpp | |
parent | a8c8fa89d916bded2905e0a5a8c05ac30e159902 (diff) |
fixed window->tile
Diffstat (limited to 'muse2/muse/app.cpp')
-rw-r--r-- | muse2/muse/app.cpp | 60 |
1 files changed, 58 insertions, 2 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index bbe5de22..de35e5bc 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -919,7 +919,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setCentralWidget(mdiArea); - connect(windowsTileAction, SIGNAL(activated()), mdiArea, SLOT(tileSubWindows())); + connect(windowsTileAction, SIGNAL(activated()), this, SLOT(tileSubWindows())); connect(windowsRowsAction, SIGNAL(activated()), this, SLOT(arrangeSubWindowsRows())); connect(windowsColumnsAction, SIGNAL(activated()), this, SLOT(arrangeSubWindowsColumns())); connect(windowsCascadeAction, SIGNAL(activated()), mdiArea, SLOT(cascadeSubWindows())); @@ -3299,9 +3299,17 @@ list<QMdiSubWindow*> get_all_visible_subwins(QMdiArea* mdiarea) QList<QMdiSubWindow*> wins = mdiarea->subWindowList(); list<QMdiSubWindow*> result; + // always put the arranger at the top of the list, if visible + for (QList<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++) if ((*it)->isVisible() && ((*it)->isMinimized()==false)) - result.push_back(*it); + if (dynamic_cast<TopWin*>((*it)->widget())->type()==TopWin::ARRANGER) + result.push_back(*it); + + for (QList<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++) + if ((*it)->isVisible() && ((*it)->isMinimized()==false)) + if (dynamic_cast<TopWin*>((*it)->widget())->type()!=TopWin::ARRANGER) + result.push_back(*it); return result; } @@ -3376,4 +3384,52 @@ void MusE::arrangeSubWindowsRows() } } +void MusE::tileSubWindows() +{ + list<QMdiSubWindow*> wins=get_all_visible_subwins(mdiArea); + int n=wins.size(); + + if (n==0) + return; + else if (n==1) + (*wins.begin())->showMaximized(); + else + { + int nx,ny; + nx=ceil(sqrt(n)); + ny=ceil((double)n/nx); + + int width = mdiArea->width(); + int height = mdiArea->height(); + int x_add = (*wins.begin())->frameGeometry().width() - (*wins.begin())->geometry().width(); + int y_add = (*wins.begin())->frameGeometry().height() - (*wins.begin())->geometry().height(); + int height_per_win = height/ny; + int width_per_win = height/nx; + + if ((x_add >= width_per_win) || (y_add >= height_per_win)) + { + printf("ERROR: tried to tile subwins, but there's too few space.\n"); + return; + } + + int i=0, j=0; + for (list<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++, i++) + { + if (i>=nx) + { + i=0; + j++; + } + + int top = (float) height*j/ny; + int bottom = (float) height*(j+1.0)/ny; + int left = (float) width*i/nx; + int right = (float) width*(i+1.0)/nx; + + (*it)->move(left,top); + (*it)->resize(right-left-x_add, bottom-top-y_add); + } + } +} + } //namespace MusEApp |