quit action

master
zetaPRIME 2022-03-13 16:34:07 -04:00
parent 46a73bef74
commit c41ffbfcce
4 changed files with 49 additions and 1 deletions

2
notes
View File

@ -34,7 +34,7 @@ TODO {
immediate frontburner {
multi-window accounting {
- keep list of active windows
quit (just trigger close on all sequentially)
- quit (just trigger close on all sequentially)
if opening project already in other window, focus/flash that window
open project from command line
IPC to open/new window in existing instance

View File

@ -70,6 +70,8 @@ namespace {
//
}
std::unordered_set<MainWindow*> MainWindow::openWindows;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow) {
@ -635,6 +637,24 @@ void MainWindow::menuFileNewWindow() {
w->show();
}
void MainWindow::menuQuit() {
auto c = openWindows.size();
if (c > 1) { // prompt if more than just this window
auto r = QMessageBox::warning(this, qs("Quit"), qs("Close %1 open projects?").arg(c),
static_cast<QMessageBox::StandardButtons>(QMessageBox::Yes + QMessageBox::No));
if (r == QMessageBox::No || r == QMessageBox::Escape) return;
}
// assemble list
std::vector<MainWindow*> cl;
cl.push_back(this);
for (auto w : openWindows) if (w != this) cl.push_back(w);
// and close
for (auto w : cl) w->close();
}
void MainWindow::onNewProjectLoaded() {
undoStack->clear();

View File

@ -79,6 +79,7 @@ namespace Xybrid {
void menuFileExportAs();
void menuFileNewWindow();
void menuQuit();
signals:
void projectLoaded();

View File

@ -1082,6 +1082,8 @@
<addaction name="separator"/>
<addaction name="actionNew_Window"/>
<addaction name="actionClose_Window"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
@ -1173,6 +1175,14 @@
<string>Ctrl+Shift+E</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@ -1325,6 +1335,22 @@
</hint>
</hints>
</connection>
<connection>
<sender>actionQuit</sender>
<signal>triggered()</signal>
<receiver>MainWindow</receiver>
<slot>menuQuit()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>459</x>
<y>305</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>menuFileNew()</slot>
@ -1334,5 +1360,6 @@
<slot>menuFileNewWindow()</slot>
<slot>menuFileExport()</slot>
<slot>menuFileExportAs()</slot>
<slot>menuQuit()</slot>
</slots>
</ui>