mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Extracted resizing of window's width to separate method
This commit is contained in:
parent
2eaf96e3bf
commit
bf9aa2e131
2 changed files with 32 additions and 27 deletions
|
@ -570,32 +570,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
|
|||
//
|
||||
mScrollbarOnly = windows["mainwindow-scrollbar"].toString() == "Scrollbar Only";
|
||||
|
||||
QDesktopWidget *dw = QApplication::desktop();
|
||||
QRect rect;
|
||||
if (windows["grow-limit"].isTrue())
|
||||
rect = dw->screenGeometry(this);
|
||||
else
|
||||
rect = dw->screenGeometry(dw->screen(dw->screenNumber(this)));
|
||||
|
||||
if (!mScrollbarOnly && mScroll && mSubViews.size() > 1)
|
||||
{
|
||||
int newWidth = width()+minWidth;
|
||||
int frameWidth = frameGeometry().width() - width();
|
||||
if (newWidth+frameWidth <= rect.width())
|
||||
{
|
||||
resize(newWidth, height());
|
||||
// WARNING: below code assumes that new subviews are added to the right
|
||||
if (x() > rect.width()-(newWidth+frameWidth))
|
||||
move(rect.width()-(newWidth+frameWidth), y()); // shift left to stay within the screen
|
||||
}
|
||||
else
|
||||
{
|
||||
// full width
|
||||
resize(rect.width()-frameWidth, height());
|
||||
mSubViewWindow.setMinimumWidth(mSubViewWindow.width()+minWidth);
|
||||
move(0, y());
|
||||
}
|
||||
}
|
||||
updateWidth(windows["grow-limit"].isTrue(), minWidth);
|
||||
|
||||
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
|
||||
|
||||
|
@ -959,3 +934,33 @@ void CSVDoc::View::merge()
|
|||
{
|
||||
emit mergeDocument (mDocument);
|
||||
}
|
||||
|
||||
void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth)
|
||||
{
|
||||
QDesktopWidget *dw = QApplication::desktop();
|
||||
QRect rect;
|
||||
if (isGrowLimit)
|
||||
rect = dw->screenGeometry(this);
|
||||
else
|
||||
rect = dw->screenGeometry(dw->screen(dw->screenNumber(this)));
|
||||
|
||||
if (!mScrollbarOnly && mScroll && mSubViews.size() > 1)
|
||||
{
|
||||
int newWidth = width()+minSubViewWidth;
|
||||
int frameWidth = frameGeometry().width() - width();
|
||||
if (newWidth+frameWidth <= rect.width())
|
||||
{
|
||||
resize(newWidth, height());
|
||||
// WARNING: below code assumes that new subviews are added to the right
|
||||
if (x() > rect.width()-(newWidth+frameWidth))
|
||||
move(rect.width()-(newWidth+frameWidth), y()); // shift left to stay within the screen
|
||||
}
|
||||
else
|
||||
{
|
||||
// full width
|
||||
resize(rect.width()-frameWidth, height());
|
||||
mSubViewWindow.setMinimumWidth(mSubViewWindow.width()+minSubViewWidth);
|
||||
move(0, y());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace CSVDoc
|
|||
void resizeViewHeight (int height);
|
||||
|
||||
void updateScrollbar();
|
||||
|
||||
void updateWidth(bool isGrowLimit, int minSubViewWidth);
|
||||
public:
|
||||
|
||||
View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews);
|
||||
|
|
Loading…
Reference in a new issue