Rather than tracking the visibility manually, we now make sure that the window state is saved
before the window is hidden, i.e. not in aboutToQuit() which is already too late for that.
Instead of calling QApplication::quit(), we use our new slot MainWin::quit() which saves the window
layout first.
For KDEified Quassel, we now use KMainWindow's autosave feature rather than using QMainWindow::restoreState().
This might fix some issues with multiple desktops etc, though I haven't tested that. In any case it's cleaner
as it saves additional properties (e.g. toolbar state).
bool Quassel::_initialized = false;
bool Quassel::DEBUG = false;
QString Quassel::_coreDumpFileName;
bool Quassel::_initialized = false;
bool Quassel::DEBUG = false;
QString Quassel::_coreDumpFileName;
+Quassel *Quassel::_instance = 0;
+ Q_ASSERT(!_instance);
+ _instance = this;
+
// We catch SIGTERM and SIGINT (caused by Ctrl+C) to graceful shutdown Quassel.
signal(SIGTERM, handleSignal);
signal(SIGINT, handleSignal);
// We catch SIGTERM and SIGINT (caused by Ctrl+C) to graceful shutdown Quassel.
signal(SIGTERM, handleSignal);
signal(SIGINT, handleSignal);
+void Quassel::quit() {
+ QCoreApplication::quit();
+}
+
//! Register our custom types with Qt's Meta Object System.
/** This makes them available for QVariant and in signals/slots, among other things.
*
//! Register our custom types with Qt's Meta Object System.
/** This makes them available for QVariant and in signals/slots, among other things.
*
case SIGTERM:
case SIGINT:
qWarning("%s", qPrintable(QString("Caught signal %1 - exiting.").arg(sig)));
case SIGTERM:
case SIGINT:
qWarning("%s", qPrintable(QString("Caught signal %1 - exiting.").arg(sig)));
- QCoreApplication::quit();
+ if(_instance)
+ _instance->quit();
+ else
+ QCoreApplication::quit();
break;
case SIGABRT:
case SIGSEGV:
break;
case SIGABRT:
case SIGSEGV:
protected:
Quassel();
virtual bool init();
protected:
Quassel();
virtual bool init();
inline void setRunMode(RunMode mode);
inline void setDataDirPaths(const QStringList &paths);
inline void setRunMode(RunMode mode);
inline void setDataDirPaths(const QStringList &paths);
static void handleSignal(int signal);
static void logBacktrace(const QString &filename);
static void handleSignal(int signal);
static void logBacktrace(const QString &filename);
+ static Quassel *_instance;
static BuildInfo _buildInfo;
static AbstractCliParser *_cliParser;
static RunMode _runMode;
static BuildInfo _buildInfo;
static AbstractCliParser *_cliParser;
static RunMode _runMode;
updateIcon();
installEventFilter(new JumpKeyHandler(this));
updateIcon();
installEventFilter(new JumpKeyHandler(this));
-
- QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
- connect(app, SIGNAL(aboutToQuit()), SLOT(aboutToQuit()));
- connect(QApplication::instance(), SIGNAL(aboutToQuit()), SLOT(saveLayout()));
connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId)));
connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId)));
connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId)));
connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId)));
connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
setDisconnectedState(); // Disable menus and stuff
setDisconnectedState(); // Disable menus and stuff
+#ifdef HAVE_KDE
+ setAutoSaveSettings();
+#endif
+
// restore mainwin state
QtUiSettings s;
restoreStateFromSettings(s);
// restore mainwin state
QtUiSettings s;
restoreStateFromSettings(s);
-void MainWin::aboutToQuit() {
QtUiSettings s;
saveStateToSettings(s);
QtUiSettings s;
saveStateToSettings(s);
+ saveLayout();
+ QApplication::quit();
}
void MainWin::saveStateToSettings(UiSettings &s) {
}
void MainWin::saveStateToSettings(UiSettings &s) {
s.setValue("MainWinGeometry", saveGeometry());
s.setValue("MainWinMinimized", isMinimized());
s.setValue("MainWinMaximized", isMaximized());
s.setValue("MainWinGeometry", saveGeometry());
s.setValue("MainWinMinimized", isMinimized());
s.setValue("MainWinMaximized", isMaximized());
- s.setValue("MainWinHidden", _isHidden);
+ s.setValue("MainWinHidden", !isVisible());
+
+#ifdef HAVE_KDE
+ saveAutoSaveSettings();
+#endif
}
void MainWin::restoreStateFromSettings(UiSettings &s) {
}
void MainWin::restoreStateFromSettings(UiSettings &s) {
_normalPos = s.value("MainWinPos", pos()).toPoint();
bool maximized = s.value("MainWinMaximized", false).toBool();
_normalPos = s.value("MainWinPos", pos()).toPoint();
bool maximized = s.value("MainWinMaximized", false).toBool();
restoreGeometry(s.value("MainWinGeometry").toByteArray());
if(maximized) {
restoreGeometry(s.value("MainWinGeometry").toByteArray());
if(maximized) {
restoreState(s.value("MainWinState").toByteArray());
restoreState(s.value("MainWinState").toByteArray());
+#else
+ move(_normalPos);
+#endif
+
if(s.value("MainWinHidden").toBool())
hideToTray();
else if(s.value("MainWinMinimized").toBool())
if(s.value("MainWinHidden").toBool())
hideToTray();
else if(s.value("MainWinMinimized").toBool())
coll->addAction("ConfigureNetworks", new Action(SmallIcon("configure"), tr("Configure &Networks..."), coll,
this, SLOT(on_actionConfigureNetworks_triggered())));
coll->addAction("Quit", new Action(SmallIcon("application-exit"), tr("&Quit"), coll,
coll->addAction("ConfigureNetworks", new Action(SmallIcon("configure"), tr("Configure &Networks..."), coll,
this, SLOT(on_actionConfigureNetworks_triggered())));
coll->addAction("Quit", new Action(SmallIcon("application-exit"), tr("&Quit"), coll,
- qApp, SLOT(quit()), tr("Ctrl+Q")));
+ this, SLOT(quit()), tr("Ctrl+Q")));
// View
coll->addAction("ConfigureBufferViews", new Action(tr("&Configure Buffer Views..."), coll,
// View
coll->addAction("ConfigureBufferViews", new Action(tr("&Configure Buffer Views..."), coll,
event->ignore();
} else {
event->accept();
event->ignore();
} else {
event->accept();
}
hide();
systemTray()->setIconVisible();
}
hide();
systemTray()->setIconVisible();
}
void MainWin::toggleMinimizedToTray() {
}
void MainWin::toggleMinimizedToTray() {
show();
raise();
activateWindow();
show();
raise();
activateWindow();
}
void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
}
void MainWin::messagesInserted(const QModelIndex &parent, int start, int end) {
//! Bring window to front and focus it
void forceActivated();
//! Bring window to front and focus it
void forceActivated();
+ //! Quit application
+ void quit();
+
protected:
void closeEvent(QCloseEvent *event);
void changeEvent(QEvent *event);
protected:
void closeEvent(QCloseEvent *event);
void changeEvent(QEvent *event);
void connectOrDisconnectFromNet();
void saveStatusBarStatus(bool enabled);
void connectOrDisconnectFromNet();
void saveStatusBarStatus(bool enabled);
void loadLayout();
void saveLayout();
void loadLayout();
void saveLayout();
QSize _normalSize; //!< Size of the non-maximized window
QPoint _normalPos; //!< Position of the non-maximized window
QSize _normalSize; //!< Size of the non-maximized window
QPoint _normalPos; //!< Position of the non-maximized window
#ifdef Q_WS_WIN
DWORD dwTickCount;
#ifdef Q_WS_WIN
DWORD dwTickCount;
+void QtUiApplication::quit() {
+ QtUi::mainWindow()->quit();
+}
+
void QtUiApplication::commitData(QSessionManager &manager) {
Q_UNUSED(manager)
_aboutToQuit = true;
void QtUiApplication::commitData(QSessionManager &manager) {
Q_UNUSED(manager)
_aboutToQuit = true;
inline bool isAboutToQuit() const { return _aboutToQuit; }
inline bool isAboutToQuit() const { return _aboutToQuit; }
+protected:
+ virtual void quit();
+
private:
bool _aboutToQuit;
};
private:
bool _aboutToQuit;
};