/***************************************************************************
- * Copyright (C) 2005-09 by the Quassel Project *
+ * Copyright (C) 2005-2010 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
#include "qtuistyle.h"
#include "settingsdlg.h"
#include "settingspagedlg.h"
+#include "statusnotifieritem.h"
#include "toolbaractionprovider.h"
#include "topicwidget.h"
#include "verticaldock.h"
#ifndef HAVE_KDE
-# ifdef HAVE_DBUS
-# include "desktopnotificationbackend.h"
-# endif
# ifdef HAVE_PHONON
# include "phononnotificationbackend.h"
# endif
_awayLog(0),
_layoutLoaded(false)
{
+ setAttribute(Qt::WA_DeleteOnClose, false); // we delete the mainwin manually
+
QtUiSettings uiSettings;
QString style = uiSettings.value("Style", QString()).toString();
if(!style.isEmpty()) {
setupHotList();
#ifndef HAVE_KDE
- QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
-# ifndef QT_NO_SYSTEMTRAYICON
- QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
-# endif
# ifdef HAVE_PHONON
QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
# endif
-# ifdef HAVE_DBUS
- QtUi::registerNotificationBackend(new DesktopNotificationBackend(this));
+# ifndef QT_NO_SYSTEMTRAYICON
+ QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
# endif
+ QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
+
#else /* HAVE_KDE */
QtUi::registerNotificationBackend(new KNotificationBackend(this));
#endif /* HAVE_KDE */
s.setValue("MainWinMinimized", isMinimized());
s.setValue("MainWinMaximized", isMaximized());
s.setValue("MainWinHidden", !isVisible());
+ BufferId lastBufId = Client::bufferModel()->currentBuffer();
+ if(lastBufId.isValid())
+ s.setValue("LastUsedBufferId", lastBufId.toInt());
#ifdef HAVE_KDE
saveAutoSaveSettings();
move(_normalPos);
#endif
- if(s.value("MainWinHidden").toBool() && systemTray()->isSystemTrayAvailable())
- systemTray()->hideMainWidget();
+ if(s.value("MainWinHidden").toBool() && QtUi::haveSystemTray())
+ QtUi::hideMainWidget();
else if(s.value("MainWinMinimized").toBool())
showMinimized();
else if(maximized)
}
void MainWin::setupSystray() {
-#ifndef QT_NO_SYSTEMTRAYICON
+#ifdef HAVE_DBUS
+ _systemTray = new StatusNotifierItem(this);
+#elif !defined QT_NO_SYSTEMTRAYICON
_systemTray = new LegacySystemTray(this);
#else
_systemTray = new SystemTray(this); // dummy
IrcConnectionWizard *wizard = new IrcConnectionWizard(this, Qt::Sheet);
wizard->show();
}
+ else {
+ QtUiSettings s;
+ BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt());
+ if(lastUsedBufferId.isValid())
+ Client::bufferModel()->switchToBuffer(lastUsedBufferId);
+ }
}
void MainWin::loadLayout() {
int accountId = Client::currentCoreAccount().accountId().toInt();
QByteArray state = s.value(QString("MainWinState-%1").arg(accountId)).toByteArray();
if(state.isEmpty()) {
- // Make sure that the default bufferview is shown
- if(_bufferViews.count())
- _bufferViews.at(0)->show();
+ foreach(BufferViewDock *view, _bufferViews)
+ view->show();
+ _layoutLoaded = true;
return;
}
void MainWin::saveLayout() {
QtUiSettings s;
- int accountId = Client::currentCoreAccount().accountId().toInt();
- if(accountId > 0) s.setValue(QString("MainWinState-%1").arg(accountId) , saveState(accountId));
+ int accountId = _bufferViews.count()? Client::currentCoreAccount().accountId().toInt() : 0; // only save if we still have a layout!
+ if(accountId > 0)
+ s.setValue(QString("MainWinState-%1").arg(accountId) , saveState(accountId));
}
void MainWin::disconnectedFromCore() {
QtUiSettings s;
QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
Q_ASSERT(app);
- if(!app->isAboutToQuit()
- && s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool() && systemTray()->isSystemTrayAvailable()) {
- systemTray()->hideMainWidget();
+ if(!app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) {
+ QtUi::hideMainWidget();
event->ignore();
} else {
event->accept();
void MainWin::showStatusBarMessage(const QString &message) {
statusBar()->showMessage(message, 10000);
}
-