Updated MainWindwow to center it properly on start

This commit is contained in:
Uwe Kindler 2020-01-11 13:53:58 +01:00
parent 5cf4aa77d8
commit 592193fc91

View File

@ -53,6 +53,8 @@
#include <QRubberBand> #include <QRubberBand>
#include <QPlainTextEdit> #include <QPlainTextEdit>
#include <QTableWidget> #include <QTableWidget>
#include <QScreen>
#include <QStyle>
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
#include <QAxWidget> #include <QAxWidget>
@ -297,14 +299,17 @@ void MainWindowPrivate::createContent()
auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea); auto RighDockArea = DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), TopDockArea);
DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); auto BottomDockArea = DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea);
DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea); DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);
auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle())); auto Action = ui.menuView->addAction(QString("Set %1 floating").arg(DockWidget->windowTitle()));
DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating())); DockWidget->connect(Action, SIGNAL(triggered()), SLOT(setFloating()));
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
DockManager->addDockWidgetFloating(createActiveXWidget(ViewMenu)); if (!DockManager->configFlags().testFlag(ads::CDockManager::OpaqueUndocking))
{
DockManager->addDockWidget(ads::CenterDockWidgetArea, createActiveXWidget(ViewMenu), RighDockArea);
}
#endif #endif
for (auto DockWidget : DockManager->dockWidgetsMap()) for (auto DockWidget : DockManager->dockWidgetsMap())
@ -404,8 +409,8 @@ CMainWindow::CMainWindow(QWidget *parent) :
// not change if the visibility of the close button changes // not change if the visibility of the close button changes
// CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true); // CDockManager::setConfigFlag(CDockManager::RetainTabSizeWhenCloseButtonHidden, true);
// uncomment the following line if you want to use non opaque undocking and splitter // comment the following line if you want to use opaque undocking and
// movements // opaque splitter resizing
CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig); CDockManager::setConfigFlags(CDockManager::DefaultNonOpaqueConfig);
// Now create the dock manager and its content // Now create the dock manager and its content
@ -419,8 +424,12 @@ CMainWindow::CMainWindow(QWidget *parent) :
d->DockManager, SLOT(openPerspective(const QString&))); d->DockManager, SLOT(openPerspective(const QString&)));
d->createContent(); d->createContent();
// Default window geometry // Default window geometry - center on screen
resize(1280, 720); resize(1280, 720);
setGeometry(QStyle::alignedRect(
Qt::LeftToRight, Qt::AlignCenter, frameSize(),
QGuiApplication::primaryScreen()->availableGeometry()
));
//d->restoreState(); //d->restoreState();
d->restorePerspectives(); d->restorePerspectives();