# # # add_file "src/view/MacStartMenu.cpp" # content [4cf7133a0572dc78749e556696e812b213d1d0c5] # # add_file "src/view/MacStartMenu.h" # content [d98d19bcc23c5c867e4c9a8ecc9c3d850bfa9b8c] # # patch "guitone.pro" # from [699626c565b3bcc3597192c0db6a9dbb8c68c365] # to [a629ca62b46a7321570f4041bca51b48b7977626] # # patch "res/i18n/guitone_de.ts" # from [c990b567b20efbb91e0a9d0dc57b1cc7b97d9ad4] # to [318c95b152805a098fb31efbd44e322dccebc628] # # patch "src/Guitone.cpp" # from [1a9d4af5358b813497cfab222ae2e857df360c95] # to [ec78935be4ecb902da20c35f9e6076a76b505a68] # # patch "src/Guitone.h" # from [7e8655d1197edc661b8d7b5f90b64b957cb04972] # to [9c9143ee93f0633494e48c42e0ee0f64d6af46d6] # # patch "src/main.cpp" # from [c9a04259af7dc123b9b3a9ade1bd3fa977c856f7] # to [b3c466a5103800420aa2b0cab6c9d1be4994f5c5] # # patch "src/util/CocoaUtil.h" # from [8424a0c7f877f0167271bb2386fd00472a32f551] # to [7bab17bbe14218ea6e1dc33bbca110c0cc13a248] # # patch "src/util/CocoaUtil.mm" # from [af7058410a39e0fa1f7fdb9d1ff5019261fd0960] # to [5fe5b302f4e7198a04700856bab989b3b7e2f44c] # # patch "src/view/MainWindow.cpp" # from [8e4b32d0cdc7891375c109d0f3c408d3fcc0245e] # to [c4b6cf1f128df54b18ba2a5b8ca2a2fddc0231aa] # ============================================================ --- src/view/MacStartMenu.cpp 4cf7133a0572dc78749e556696e812b213d1d0c5 +++ src/view/MacStartMenu.cpp 4cf7133a0572dc78749e556696e812b213d1d0c5 @@ -0,0 +1,205 @@ +/*************************************************************************** + * Copyright (C) 2007 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "MacStartMenu.h" +#include "About.h" +#include "Preferences.h" +#include "CocoaUtil.h" +#include "Settings.h" + +#include +#include + +// +// FIXME: This is pretty much a plain copy of ui_main_window.h and +// MainWindow.cpp - if we keep this, then maybe this should be generalized +// i.e. into a "CommonMenuBar" class or something alike +// +MacStartMenu::MacStartMenu() : QMenuBar(0) +{ + actionOpen_Workspace = new QAction(this); + actionOpen_Workspace->setObjectName(QString::fromUtf8("actionOpen_Workspace")); + actionNo_recent_workspaces_found = new QAction(this); + actionNo_recent_workspaces_found->setObjectName(QString::fromUtf8("actionNo_recent_workspaces_found")); + actionPreferences = new QAction(this); + actionPreferences->setObjectName(QString::fromUtf8("actionPreferences")); + actionPreferences->setMenuRole(QAction::PreferencesRole); + actionAbout_Qt = new QAction(this); + actionAbout_Qt->setObjectName(QString::fromUtf8("actionAbout_Qt")); + actionAbout_Qt->setMenuRole(QAction::AboutQtRole); + actionAbout_guitone = new QAction(this); + actionAbout_guitone->setObjectName(QString::fromUtf8("actionAbout_guitone")); + actionAbout_guitone->setMenuRole(QAction::AboutRole); + actionOpen_Database = new QAction(this); + actionOpen_Database->setObjectName(QString::fromUtf8("actionOpen_Database")); + actionNo_previous_databases_available = new QAction(this); + actionNo_previous_databases_available->setObjectName(QString::fromUtf8("actionNo_previous_databases_available")); + actionCheck_for_updates = new QAction(this); + actionCheck_for_updates->setObjectName(QString::fromUtf8("actionCheck_for_updates")); + + menuFile = new QMenu(this); + menuFile->setObjectName(QString::fromUtf8("menuFile")); + menuRecent_Databases = new QMenu(menuFile); + menuRecent_Databases->setObjectName(QString::fromUtf8("menuRecent_Databases")); + menuRecent_Workspaces = new QMenu(menuFile); + menuRecent_Workspaces->setObjectName(QString::fromUtf8("menuRecent_Workspaces")); + + menuFile->addAction(actionOpen_Workspace); + menuFile->addAction(menuRecent_Workspaces->menuAction()); + menuFile->addSeparator(); + menuFile->addAction(actionOpen_Database); + menuFile->addAction(menuRecent_Databases->menuAction()); + menuFile->addSeparator(); + menuFile->addAction(actionPreferences); + menuFile->addAction(actionCheck_for_updates); + menuFile->addAction(actionAbout_Qt); + menuFile->addAction(actionAbout_guitone); + menuRecent_Databases->addAction(actionNo_previous_databases_available); + menuRecent_Workspaces->addAction(actionNo_recent_workspaces_found); + + // add the created menu to this menu bar + addAction(menuFile->menuAction()); + + // translate everything + actionOpen_Workspace->setText(tr("Open Workspace")); + actionOpen_Workspace->setShortcut(tr("Ctrl+O")); + actionNo_recent_workspaces_found->setText(tr("No previous workspaces available.")); + actionNo_recent_workspaces_found->setIconText(tr("No previous workspaces available.")); + actionNo_recent_workspaces_found->setToolTip(tr("No previous workspaces available.")); + actionPreferences->setText(tr("Preferences...")); + actionPreferences->setShortcut(tr("Ctrl+P")); + actionAbout_Qt->setText(tr("About Qt")); + actionAbout_guitone->setText(tr("About guitone")); + actionOpen_Database->setText(tr("Open Database")); + actionOpen_Database->setShortcut(tr("Ctrl+Shift+O")); + actionNo_previous_databases_available->setText(tr("No previous databases available.")); + actionCheck_for_updates->setText(tr("Check for updates")); + menuFile->setTitle(tr("File")); + menuRecent_Databases->setTitle(tr("Recent Databases")); + menuRecent_Workspaces->setTitle(tr("Recent Workspaces")); + + // fill in any recently loaded databases and workspaces + QStringList previousDb = Settings::getItemList("RecentDatabaseList"); + int elemCount = previousDb.size(); + if (elemCount > 0) + { + menuRecent_Databases->clear(); + + QAction *act; + for (int i = 0; i < elemCount; ++i) + { + act = menuRecent_Databases->addAction( + tr("&%1 %2").arg(i + 1).arg(previousDb[i]), + this, + SLOT(openRecentDatabase()) + ); + act->setData(previousDb[i]); + } + } + + QStringList previousWs = Settings::getItemList("RecentWorkspaceList"); + elemCount = previousWs.size(); + if (elemCount > 0) + { + menuRecent_Workspaces->clear(); + + QAction *act; + for (int i = 0; i < elemCount; ++i) + { + act = menuRecent_Workspaces->addAction( + tr("&%1 %2").arg(i + 1).arg(previousWs[i]), + this, + SLOT(openRecentWorkspace()) + ); + act->setData(previousWs[i]); + } + } + + // auto-connect all signals/slots + QMetaObject::connectSlotsByName(this); +} + +MacStartMenu::~MacStartMenu() {} + +void MacStartMenu::on_actionPreferences_triggered() +{ + Preferences dialog(this); + dialog.exec(); +} + +void MacStartMenu::on_actionAbout_guitone_triggered() +{ + About dialog(this); + dialog.exec(); +} + +void MacStartMenu::on_actionAbout_Qt_triggered() +{ + qApp->aboutQt(); +} + +void MacStartMenu::on_actionCheck_for_updates_triggered() +{ + CocoaUtil::checkForUpdates(); +} + +void MacStartMenu::on_actionOpen_Workspace_triggered() +{ + QString fn = QFileDialog::getExistingDirectory(0, tr("Select your workspace...")); + + if (!fn.isEmpty()) + { + emit loadWorkspace(fn); + } +} + +void MacStartMenu::on_actionOpen_Database_triggered() +{ + QString fn = QFileDialog::getOpenFileName( + 0, + tr("Select your database..."), + QString(), + tr("monotone Databases (*.mtn *.db)") + ); + + if (!fn.isEmpty()) + { + emit loadDatabase(fn); + } +} + +void MacStartMenu::openRecentWorkspace() +{ + QAction *action = qobject_cast(sender()); + if (action) + { + emit loadWorkspace(action->data().toString()); + } +} + +void MacStartMenu::openRecentDatabase() +{ + QAction *action = qobject_cast(sender()); + if (action) + { + emit loadDatabase(action->data().toString()); + } +} + ============================================================ --- src/view/MacStartMenu.h d98d19bcc23c5c867e4c9a8ecc9c3d850bfa9b8c +++ src/view/MacStartMenu.h d98d19bcc23c5c867e4c9a8ecc9c3d850bfa9b8c @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (C) 2007 by Thomas Keller * + * address@hidden * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef MAC_START_MENU_H +#define MAC_START_MENU_H + +#include + +class MacStartMenu : public QMenuBar +{ + Q_OBJECT + +public: + MacStartMenu(); + ~MacStartMenu(); + +signals: + void loadWorkspace(const QString &); + void loadDatabase(const QString &); + +public: + QAction * actionOpen_Workspace; + QAction * actionNo_recent_workspaces_found; + QAction * actionPreferences; + QAction * actionAbout_Qt; + QAction * actionAbout_guitone; + QAction * actionOpen_Database; + QAction * actionNo_previous_databases_available; + QMenu * menuFile; + QMenu * menuRecent_Databases; + QMenu * menuRecent_Workspaces; + QAction * actionCheck_for_updates; + +private slots: + void on_actionOpen_Workspace_triggered(); + void on_actionOpen_Database_triggered(); + void on_actionPreferences_triggered(); + void on_actionAbout_guitone_triggered(); + void on_actionAbout_Qt_triggered(); + void on_actionCheck_for_updates_triggered(); + void openRecentDatabase(); + void openRecentWorkspace(); +}; + +#endif + ============================================================ --- guitone.pro 699626c565b3bcc3597192c0db6a9dbb8c68c365 +++ guitone.pro a629ca62b46a7321570f4041bca51b48b7977626 @@ -198,9 +198,11 @@ macx { # macx { - # add sources for Sparkle - HEADERS += src/util/CocoaUtil.h - SOURCES += src/util/CocoaUtil.mm + # add specific Mac sources + HEADERS += src/util/CocoaUtil.h \ + src/view/MacStartMenu.h + SOURCES += src/util/CocoaUtil.mm \ + src/view/MacStartMenu.cpp # add the Sparkle and the Carbon framework QMAKE_LFLAGS += -framework Sparkle -framework Carbon ============================================================ --- res/i18n/guitone_de.ts c990b567b20efbb91e0a9d0dc57b1cc7b97d9ad4 +++ res/i18n/guitone_de.ts 318c95b152805a098fb31efbd44e322dccebc628 @@ -781,17 +781,17 @@ In jedem Fall sollte der derzeitige Arbe Guitone - + Error Fehler - + The path to the monotone binary is either invalid or points to an older version of monotone. Guitone requires monotone version %1 or a monotone with interface version %2 or later. Der Pfad zur ausführbaren Datei von monotone ist entweder ungültig oder zeigt auf eine ältere Version von monotone. Guitone benötigt monotone Version %1 oder ein monotone mit einer Interface-Version %2 oder neuer. - + Select your workspace... Wählen Sie Ihren Arbeitsbereich aus... @@ -1149,6 +1149,34 @@ In jedem Fall sollte der derzeitige Arbe + MacStartMenu + + + No updates available + Keine Aktualisierungen verfügbar + + + + Your version of guitone (%1) is already up-to-date. + Ihre Version von guitone (%1) ist bereits aktuell. + + + + Select your workspace... + Wählen Sie Ihren Arbeitsbereich aus... + + + + Select your database... + Wählen Sie eine Datenbank aus... + + + + monotone Databases (*.mtn *.db) + monotone-Datenbanken (*.mtn *.db) + + + MainWindow @@ -1166,32 +1194,32 @@ In jedem Fall sollte der derzeitige Arbe Arbeitsbereich - + File Datei - + Recent Workspaces Vorherige Arbeitsbereiche - + Open Workspace Arbeitsbereich öffnen - + Ctrl+O Strg+O - + No previous workspaces available. Keine vorherigen Arbeitsbereiche verfügbar. - + Ctrl+P Strg+P @@ -1206,7 +1234,7 @@ In jedem Fall sollte der derzeitige Arbe Strg+Q - + Hide ignored files Ignorierte Dateien verstecken @@ -1261,7 +1289,7 @@ In jedem Fall sollte der derzeitige Arbe Ignorierte Dateien - + Expand tree Baum aufklappen @@ -1286,12 +1314,12 @@ In jedem Fall sollte der derzeitige Arbe Strg+K - + About Qt Über Qt - + About guitone Über guitone @@ -1306,42 +1334,42 @@ In jedem Fall sollte der derzeitige Arbe guitone - ein Frontend für monotone - + Select your workspace... Wählen Sie Ihren Arbeitsbereich aus... - + Loading aborted Laden abgebrochen - + Show ignored files Zeige ignorierte Dateien - + Collapse tree Baum zuklappen - + &%1 %2 &%1 %2 - + Recent Databases Vorherige Datenbanken - + Open Database Datenbank öffnen - + No previous databases available. Keine vorherigen geöffneten Datenbanken verfügbar. @@ -1351,22 +1379,22 @@ In jedem Fall sollte der derzeitige Arbe Datenbank - + Ctrl+Shift+O Strg+Shift+O - + Loaded database: %1 Geladene Datenbank: %1 - + Select your database... Wählen Sie eine Datenbank aus... - + monotone Databases (*.mtn *.db) monotone-Datenbanken (*.mtn *.db) @@ -1461,22 +1489,22 @@ In jedem Fall sollte der derzeitige Arbe Alle nach vorne bringen - + %1 - database mode - guitone %1 - Datenbankmodus - guitone - + %1 - workspace mode - guitone %1 - Arbeitsbereichmodus - guitone - + Unable to load workspace Konnte Arbeitsbereich nicht laden - + The workspace '%1' could not be loaded. monotone returned: @@ -1497,12 +1525,12 @@ monotone gab zurück: Strg+C - + Failed to load workspace Konnte Arbeitsbereich nicht laden - + The workspace could not be loaded. The last output was: @@ -1513,12 +1541,12 @@ Die letzte Ausgabe war: %1 - + Failed to load database Konnte Datenbank nicht laden - + The database could not be loaded. The last output was: @@ -1529,22 +1557,22 @@ Die letzte Ausgabe war: %1 - + Preferences... Einstellungen... - + Check for updates Auf Aktualisierungen prüfen - + No updates available Keine Aktualisierungen verfügbar - + Your version of guitone (%1) is already up-to-date. Ihre Version von guitone (%1) ist bereits aktuell. @@ -1559,12 +1587,12 @@ Die letzte Ausgabe war: Finde nicht verfolgte Umbenennungen - + Nothing found Nichts gefunden - + No unaccounted renames found for this workspace. Keine nicht verfolgten Umbenennungen in diesem Arbeitsbereich gefunden. @@ -1624,32 +1652,32 @@ Die letzte Ausgabe war: Preferences - + Error Fehler - + The path to the monotone binary is either invalid or points to an older version of monotone. Guitone requires monotone version %1 or a monotone with interface version %2 or later. Der Pfad zur ausführbaren Datei von monotone ist entweder ungültig oder zeigt auf eine ältere Version von monotone. Guitone benötigt monotone Version %1 oder ein monotone mit einer Interface-Version %2 oder neuer. - + Notice Hinweis - + You need to reload your current workspace or restart guitone to use the new monotone binary. Sie müssen Ihren derzeitigen Arbeitsbereich oder guitone neu laden, um die neue monotone-Binary zu nutzen. - + Choose the monotone executable Wählen Sie die ausführbare Datei von monotone - + Binaries (mtn mtn.exe) Binärdateien (mtn mtn.exe) @@ -1801,22 +1829,22 @@ Die letzte Ausgabe war: QShortcut - + Ctrl Strg - + Alt Alt - + Shift Umschalt - + Meta Meta ============================================================ --- src/Guitone.cpp 1a9d4af5358b813497cfab222ae2e857df360c95 +++ src/Guitone.cpp ec78935be4ecb902da20c35f9e6076a76b505a68 @@ -26,7 +26,6 @@ #ifdef Q_WS_MACX #include "CocoaUtil.h" -#include #endif #include @@ -34,107 +33,18 @@ #include #include #include +#include -#ifdef Q_WS_MACX -static OSErr OpenDocumentAE(const AppleEvent * evt, AppleEvent *, long) -{ - AEDescList docList; - DescType retType; - AEKeyword keywd; - FSRef fsref; - long count, size; - - AEGetParamDesc(evt, keyDirectObject, typeAEList, &docList); - AECountItems(&docList, &count); - - OSErr err; - - for (int i = 1; i <= count; i++) - { - err = AEGetNthPtr(&docList, i, typeFSRef, &keywd, - &retType, (Ptr)&fsref, sizeof(fsref), &size); - - if (err != noErr) - { - W("Couldn't retrieve FSRef."); - continue; - } - - QString path = CocoaUtil::FSRefToPath(fsref); - if (path.isEmpty()) - { - W("Couldn't convert FSRef to path."); - continue; - } - - D(QString("Acquired new path: %1").arg(path)); - APP->loadFromPath(path); - } - AEDisposeDesc(&docList); - - return 0; -} - -bool Guitone::macEventFilter(EventHandlerCallRef caller, EventRef event) -{ - // - // taken from - // http://developer.apple.com/documentation/AppleScript/Conceptual/ - // AppleEvents/dispatch_aes_aepg/chapter_4_section_3.html - // - Boolean release = false; - EventRecord eventRecord; - OSErr ignoredErr; - - // Events of type kEventAppleEvent must be removed from the queue - // before being passed to AEProcessAppleEvent. - if (IsEventInQueue(GetMainEventQueue(), event)) - { - // RemoveEventFromQueue will release the event, which will - // destroy it if we don't retain it first. - RetainEvent(event); - release = true; - RemoveEventFromQueue(GetMainEventQueue(), event); - } - - // Convert the event ref to the type AEProcessAppleEvent expects. - ConvertEventRefToEventRecord(event, &eventRecord); - ignoredErr = AEProcessAppleEvent(&eventRecord); - - if (release) - ReleaseEvent(event); - - // This Carbon event has been handled, even if no AppleEvent handlers - // were installed for the Apple event. - return noErr; -} -#endif - Guitone::Guitone(int argc, char** argv) - : QApplication(argc, argv), updateDialog(0) + : QApplication(argc, argv), updateDialog(0), somethingLoaded(false) { setQuitOnLastWindowClosed(false); setOrganizationName("Thomas Keller"); setOrganizationDomain("thomaskeller.biz"); setApplicationName("guitone"); - -#ifdef Q_WS_MACX - // install apple event handler to open documents - OSErr err = AEInstallEventHandler( - kCoreEventClass, kAEOpenDocuments, - NewAEEventHandlerUPP(OpenDocumentAE), 0, false - ); - require_noerr(err, error_installing_event_handler); - return; -error_installing_event_handler: - C("Could not install OpenDocumentAE event handler"); -#endif -} - -bool Guitone::init() -{ + // check for updates immediatly on launch if (Settings::getBool("CheckForUpdates", true)) { #ifdef Q_WS_MACX @@ -148,13 +58,77 @@ bool Guitone::init() } #endif } + + // + // Try to load something given on the command line + // or found in one of the recent items lists + // + // FIXME: This is disabled for OSX since it interfers terribly with + // FileOpen events on this platform, i.e. we can't determine + // properly if the program is opened and shortly afterwards gets + // a FileOpen event or if there will no such event and we have to look + // at the command line or in the recent lists for something to load. + // + // What we're doing instead here for Mac OS X (whose users would otherwise + // fail to use guitone by opening it without also opening a workspace or + // database) is to create a global QMenuBar (MacStartMenu), which contains + // the basic file menu entries to open (recent) workspaces and databases + // amongst regular stuff like about dialogs and the update stuff. This is + // certainly not the end for "load recent automatically" on Mac, but a + // workaround. + // +#ifdef Q_WS_MACX + macStartMenu = new MacStartMenu(); + connect( + macStartMenu, SIGNAL(loadWorkspace(const QString &)), + this, SLOT(loadWorkspace(const QString &)) + ); + + connect( + macStartMenu, SIGNAL(loadDatabase(const QString &)), + this, SLOT(loadDatabase(const QString &)) + ); +#else + QTimer::singleShot(0, this, SLOT(loadSomething())); +#endif +} + +Guitone::~Guitone() +{ + I(openWindows.size() == 0); + I(monotoneInstances.size() == 0); + if (updateDialog) delete updateDialog; + +#ifdef Q_WS_MACX + disconnect( + macStartMenu, SIGNAL(loadWorkspace(const QString &)), + this, SLOT(loadWorkspace(const QString &)) + ); + + disconnect( + macStartMenu, SIGNAL(loadDatabase(const QString &)), + this, SLOT(loadDatabase(const QString &)) + ); + + delete macStartMenu; +#endif +} + +#ifndef Q_WS_MACX +void Guitone::loadSomething() +{ QStringList args = arguments(); - bool somethingLoaded = false; - for (int i=1, j=args.size(); i 0 && loadWorkspace(workspaces.at(0)); } if (!somethingLoaded) { + D("trying to load recent database"); QStringList databases = Settings::getItemList("RecentDatabaseList"); somethingLoaded = databases.size() > 0 && loadDatabase(databases.at(0)); } @@ -175,21 +151,67 @@ bool Guitone::init() // if still nothing is loaded, prompt the user to load a workspace if (!somethingLoaded) { + D("prompting for a workspace"); QString workspaceDir = QFileDialog::getExistingDirectory(0, tr("Select your workspace...")); somethingLoaded = !workspaceDir.isEmpty() && loadWorkspace(workspaceDir); } // if nothing could be loaded (= no window could be created), - // let the app close itself - return somethingLoaded; + // quit the application + if (!somethingLoaded) + { + D("nothing could be loaded, quitting"); + quit(); + } } +#endif -Guitone::~Guitone() +// this code is borrowed and adapted from QDesigner - thanks to the Trolls! +bool Guitone::event(QEvent * ev) { - I(openWindows.size() == 0); - I(monotoneInstances.size() == 0); - if (updateDialog) delete updateDialog; + bool eaten; + switch (ev->type()) + { + case QEvent::FileOpen: + { + QApplication::processEvents(); + D("got load event"); + if (loadFromPath(static_cast(ev)->file())) + { + QApplication::processEvents(); + D("loading from path succeeded"); + somethingLoaded = true; + } + 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; + } + return eaten; } bool Guitone::loadFromPath(const QString & path) @@ -385,7 +407,7 @@ const QList Guitone::window return openWindows; } -void Guitone::quit() +bool Guitone::closeAllWindows() { // do we need to close any windows? if (openWindows.size() > 0) @@ -397,11 +419,16 @@ void Guitone::quit() // problems foreach (MainWindow * wnd, openWindows) { - wnd->close(); + // QWidget::close() returns true if the widget could be closed, + // i.e. hasn't ignored the close event + if (!wnd->close()) return false; } - return; } - + return true; +} + +void Guitone::quit() +{ Settings::sync(); QApplication::quit(); } ============================================================ --- src/Guitone.h 7e8655d1197edc661b8d7b5f90b64b957cb04972 +++ src/Guitone.h 9c9143ee93f0633494e48c42e0ee0f64d6af46d6 @@ -26,6 +26,10 @@ #include "ApplicationUpdate.h" #include "DebugLog.h" +#ifdef Q_WS_MACX +#include "MacStartMenu.h" +#endif + #include #include #include @@ -38,7 +42,6 @@ public: public: Guitone(int, char**); ~Guitone(); - bool init(); const QList windowList() const; MainWindow * findMainWindow(QObject *); @@ -55,8 +58,11 @@ private slots: bool loadWorkspace(const QString &); bool loadDatabase(const QString &); void windowClosed(MainWindow *); +#ifndef Q_WS_MACX + void loadSomething(); +#endif void quit(); - + private: MainWindow * addWindow(); void removeWindow(MainWindow *); @@ -64,15 +70,20 @@ private: bool addMonotoneInstance(MainWindow *); bool removeMonotoneInstance(MainWindow *); -#ifdef Q_WS_MACX - bool macEventFilter(EventHandlerCallRef, EventRef); -#endif + bool closeAllWindows(); + + bool event(QEvent *); QList openWindows; QMap monotoneInstances; QMutex mutex; - ApplicationUpdate * updateDialog; + bool somethingLoaded; + +#ifdef Q_WS_MACX + MacStartMenu * macStartMenu; +#endif + }; #endif ============================================================ --- src/main.cpp c9a04259af7dc123b9b3a9ade1bd3fa977c856f7 +++ src/main.cpp b3c466a5103800420aa2b0cab6c9d1be4994f5c5 @@ -73,8 +73,6 @@ int main(int argc, char** argv) app.installTranslator(&appTranslator); app.installTranslator(&qtTranslator); - if (!app.init()) return 1; - return app.exec(); } ============================================================ --- src/util/CocoaUtil.h 8424a0c7f877f0167271bb2386fd00472a32f551 +++ src/util/CocoaUtil.h 7bab17bbe14218ea6e1dc33bbca110c0cc13a248 @@ -5,7 +5,6 @@ #ifndef COCOAUTIL_H #define COCOAUTIL_H -#include #include class SUUpdater; @@ -14,7 +13,6 @@ namespace CocoaUtil { void initialize(); void checkForUpdates(); - QString FSRefToPath(FSRef ref); }; #endif ============================================================ --- src/util/CocoaUtil.mm af7058410a39e0fa1f7fdb9d1ff5019261fd0960 +++ src/util/CocoaUtil.mm 5fe5b302f4e7198a04700856bab989b3b7e2f44c @@ -20,15 +20,3 @@ void CocoaUtil::checkForUpdates() [updater checkForUpdates:nil]; } -QString CocoaUtil::FSRefToPath(FSRef fsref) -{ - CFURLRef url = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsref); - if (!url) - { - return QString(); - } - NSString * pathName = (NSString*)CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); - [pathName autorelease]; - CFRelease(url); - return QString::fromUtf8([pathName UTF8String]); -} ============================================================ --- src/view/MainWindow.cpp 8e4b32d0cdc7891375c109d0f3c408d3fcc0245e +++ src/view/MainWindow.cpp c4b6cf1f128df54b18ba2a5b8ca2a2fddc0231aa @@ -30,7 +30,6 @@ #include "UpdateWorkspace.h" #include "CommitRevision.h" #include "CheckoutRevision.h" -#include "ApplicationUpdate.h" #include "Platform.h" #include "Preferences.h" #include "KeyManagement.h" @@ -43,6 +42,8 @@ #ifdef Q_WS_MAC #include "CocoaUtil.h" +#else +#include "ApplicationUpdate.h" #endif #include