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(); Clean();
if (mainWindows.isEmpty()) if (mainWindows.isEmpty())
{ {
VPCommandLinePtr cmd; NewMainWindow();
VPCommandLine::ProcessInstance(cmd, QStringList());
NewMainWindow(VPCommandLinePtr());
} }
return mainWindows[0]; 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 * auto VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow *
{ {
VPMainWindow *puzzle = new VPMainWindow(cmd); auto *puzzle = new VPMainWindow(cmd);
mainWindows.prepend(puzzle); mainWindows.prepend(puzzle);
if (not cmd->IsTestModeEnabled()) if (not cmd->IsTestModeEnabled())
{ {

View File

@ -260,7 +260,14 @@ void VPMainWindow::SetupMenu()
// Add dock properties action // Add dock properties action
QAction* actionDockWidgetToolOptions = ui->dockWidgetProperties->toggleViewAction(); 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() void VPMainWindow::on_actionNew_triggered()
{ {
// just for test purpuses, to be removed: VPApplication::VApp()->NewMainWindow();
QMessageBox msgBox;
msgBox.setText("TODO VPMainWindow::New");
int ret = msgBox.exec();
Q_UNUSED(ret);
// TODO
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -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() void VPMainWindow::on_actionAboutQt_triggered()
{ {

View File

@ -124,13 +124,6 @@ private slots:
*/ */
void on_actionImportRawLayout_triggered(); 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 * @brief on_actionAboutQt_triggered When the menu action Help > About Qt
* is triggered. * is triggered.

View File

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