# # # patch "src/Guitone.cpp" # from [c0b4ae2403ec1d7d02411a375eec94d3e4f6c876] # to [126d5563492285e3a1c9d8ae772052cf94265282] # # patch "src/Guitone.h" # from [7880ef62c9a4284cd26464206df642a55b528b20] # to [ac09cea22aae69929e11e302f6551bfacb502ce6] # ============================================================ --- src/Guitone.cpp c0b4ae2403ec1d7d02411a375eec94d3e4f6c876 +++ src/Guitone.cpp 126d5563492285e3a1c9d8ae772052cf94265282 @@ -37,8 +37,8 @@ Guitone::Guitone(int argc, char** argv) #include Guitone::Guitone(int argc, char** argv) - : QApplication(argc, argv), monotoneManager(0), - somethingLoaded(false) + : QApplication(argc, argv), openPrompt(0), + monotoneManager(0), somethingLoaded(false) { #ifndef Q_WS_MACX updateDialog = 0; @@ -66,6 +66,7 @@ Guitone::~Guitone() Guitone::~Guitone() { I(openWindows.size() == 0); + if (openPrompt) delete openPrompt; #ifndef Q_WS_MACX if (updateDialog) delete updateDialog; #endif @@ -138,20 +139,24 @@ void Guitone::loadSomething() // if still nothing is loaded, prompt the user to load a workspace or database if (!somethingLoaded) { - D("prompting for a workspace or database"); - QString fileOrDir = QFileDialog::getOpenFileName( - 0, - tr("Select your workspace or database...") + openPrompt = new OpenPrompt(NULL); + + connect( + openPrompt, SIGNAL(loadDatabase(const QString &)), + this, SLOT(loadDatabase(const QString &)) ); - somethingLoaded = !fileOrDir.isEmpty() && tryLoadSomething(fileOrDir); - } - // if nothing could be loaded (= no window could be created), - // quit the application - if (!somethingLoaded) - { - D("nothing could be loaded, quitting"); - quit(); + connect( + openPrompt, SIGNAL(loadWorkspace(const QString &)), + this, SLOT(loadWorkspace(const QString &)) + ); + + connect( + openPrompt, SIGNAL(quitApp()), + this, SLOT(quit()) + ); + + openPrompt->show(); } } @@ -189,27 +194,6 @@ bool Guitone::event(QEvent * ev) eaten = true; break; } - case QEvent::Close: - { - D("got close event"); - QCloseEvent * closeEvent = static_cast(ev); - - // try to close all windows, if any window refuses to be closed, - // just eat the event and do nothing - if (closeAllWindows()) - { - closeEvent->setAccepted(true); - eaten = QApplication::event(ev); - D("closing all windows succeeded"); - } - else - { - closeEvent->setAccepted(false); - eaten = true; - D("could not close all windows"); - } - break; - } default: eaten = QApplication::event(ev); break; @@ -253,8 +237,8 @@ void Guitone::loadFromPath(const QString throw e; } - ensureCascadedWindowPlacement(wnd); openWindows.append(wnd); + ensureCascadedWindowPlacement(wnd); wnd->show(); triggerUpdateWindowList(); @@ -275,7 +259,16 @@ void Guitone::loadWorkspace(const QStrin tr("The workspace could not be loaded:\n%1").arg(e), QMessageBox::Ok ); + return; } + + // we don't need this anymore + if (openPrompt) + { + openPrompt->hide(); + delete openPrompt; + openPrompt = 0; + } } void Guitone::loadDatabase(const QString & path) @@ -292,7 +285,16 @@ void Guitone::loadDatabase(const QString tr("The database could not be loaded:\n%1").arg(e), QMessageBox::Ok ); + return; } + + // we don't need this anymore + if (openPrompt) + { + openPrompt->hide(); + delete openPrompt; + openPrompt = 0; + } } void Guitone::windowClosed(MainWindow * wnd) @@ -301,7 +303,10 @@ void Guitone::windowClosed(MainWindow * int i = openWindows.indexOf(wnd); I(i != -1); openWindows.removeAt(i); - if (openWindows.size() == 0) quit(); + if (openWindows.size() == 0) + { + quit(); + } triggerUpdateWindowList(); } @@ -337,6 +342,7 @@ void Guitone::quit() void Guitone::quit() { + if (!closeAllWindows()) return; Settings::sync(); QApplication::quit(); } ============================================================ --- src/Guitone.h 7880ef62c9a4284cd26464206df642a55b528b20 +++ src/Guitone.h ac09cea22aae69929e11e302f6551bfacb502ce6 @@ -24,6 +24,7 @@ #include "MainWindow.h" #include "MonotoneManager.h" #include "DebugLog.h" +#include "OpenPrompt.h" #ifndef Q_WS_MACX #include "ApplicationUpdate.h" @@ -72,6 +73,7 @@ private: bool closeAllWindows(); bool event(QEvent *); + OpenPrompt * openPrompt; MonotoneManager * monotoneManager; QList openWindows; QMutex lock;