One application, many windows.

This commit is contained in:
Roman Telezhynskyi 2021-05-21 11:25:43 +03:00
parent 5f607008ac
commit e1b9fbaccd
4 changed files with 18 additions and 49 deletions

View file

@ -334,9 +334,7 @@ auto VPApplication::MainWindow()-> VPMainWindow *
Clean();
if (mainWindows.isEmpty())
{
VPCommandLinePtr cmd;
VPCommandLine::ProcessInstance(cmd, QStringList());
NewMainWindow(VPCommandLinePtr());
NewMainWindow();
}
return mainWindows[0];
}
@ -354,15 +352,17 @@ auto VPApplication::MainWindows() -> QList<VPMainWindow *>
}
//---------------------------------------------------------------------------------------------------------------------
VPMainWindow *VPApplication::NewMainWindow()
auto VPApplication::NewMainWindow() -> VPMainWindow *
{
return NewMainWindow(VPCommandLinePtr());
VPCommandLinePtr cmd;
VPCommandLine::ProcessInstance(cmd, {ConstFirst<QString>(VPApplication::arguments())});
return NewMainWindow(cmd);
}
//---------------------------------------------------------------------------------------------------------------------
auto VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow *
{
VPMainWindow *puzzle = new VPMainWindow(cmd);
auto *puzzle = new VPMainWindow(cmd);
mainWindows.prepend(puzzle);
if (not cmd->IsTestModeEnabled())
{

View file

@ -260,7 +260,14 @@ void VPMainWindow::SetupMenu()
// Add dock properties action
QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction();
ui->menuWindows->addAction(actionDockWidgetToolOptions);
ui->menuEdit->addAction(actionDockWidgetToolOptions);
// Window
connect(ui->menuWindow, &QMenu::aboutToShow, this, [this]()
{
ui->menuWindow->clear();
CreateWindowMenu(ui->menuWindow);
});
}
//---------------------------------------------------------------------------------------------------------------------
@ -935,16 +942,7 @@ void VPMainWindow::CreateWindowMenu(QMenu *menu)
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_actionNew_triggered()
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::New");
int ret = msgBox.exec();
Q_UNUSED(ret);
// TODO
VPApplication::VApp()->NewMainWindow();
}
//---------------------------------------------------------------------------------------------------------------------
@ -1119,19 +1117,6 @@ void VPMainWindow::on_actionImportRawLayout_triggered()
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_actionCloseLayout_triggered()
{
// just for test purpuses, to be removed:
QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::CloseLayout");
int ret = msgBox.exec();
Q_UNUSED(ret);
// TODO
}
//---------------------------------------------------------------------------------------------------------------------
void VPMainWindow::on_actionAboutQt_triggered()
{

View file

@ -124,13 +124,6 @@ private slots:
*/
void on_actionImportRawLayout_triggered();
/**
* @brief on_actionCloseLayout_triggered When the menu action
* File > Close Layout is triggered.
* The slot is automatically connected through name convention.
*/
void on_actionCloseLayout_triggered();
/**
* @brief on_actionAboutQt_triggered When the menu action Help > About Qt
* is triggered.

View file

@ -61,11 +61,10 @@
</property>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuWindows">
<widget class="QMenu" name="menuWindow">
<property name="title">
<string>&amp;Windows</string>
<string>&amp;Window</string>
</property>
<addaction name="actionCloseLayout"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuHelp">
@ -77,7 +76,7 @@
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuWindows"/>
<addaction name="menuWindow"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
@ -1607,14 +1606,6 @@
<string>Ctrl+Shift+S</string>
</property>
</action>
<action name="actionCloseLayout">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Close Layout</string>
</property>
</action>
<action name="actionImportRawLayout">
<property name="enabled">
<bool>true</bool>