/***************************************************************************
- * 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 "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 */
QtUi::registerNotificationBackend(new IndicatorNotificationBackend(this));
#endif
+ // we assume that at this point, all configurable actions are defined!
+ QtUi::loadShortcuts();
+
connect(bufferWidget(), SIGNAL(currentChanged(BufferId)), SLOT(currentBufferChanged(BufferId)));
setDisconnectedState(); // Disable menus and stuff
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();
this, SLOT(showCoreInfoDlg())));
coll->addAction("ConfigureNetworks", new Action(SmallIcon("configure"), tr("Configure &Networks..."), coll,
this, SLOT(on_actionConfigureNetworks_triggered())));
+ // FIXME: use QKeySequence::Quit once we depend on Qt 4.6
coll->addAction("Quit", new Action(SmallIcon("application-exit"), tr("&Quit"), coll,
- this, SLOT(quit()), tr("Ctrl+Q")));
+ this, SLOT(quit()), Qt::CTRL + Qt::Key_Q));
// View
coll->addAction("ConfigureBufferViews", new Action(tr("&Configure Chat Lists..."), coll,
coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
this, SLOT(showAwayLog())));
coll->addAction("ToggleMenuBar", new Action(SmallIcon("show-menu"), tr("Show &Menubar"), coll,
- 0, 0, tr("Ctrl+M")))->setCheckable(true);
+ 0, 0, QKeySequence(Qt::CTRL + Qt::Key_M)))->setCheckable(true);
coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll,
0, 0))->setCheckable(true);
// Settings
coll->addAction("ConfigureQuassel", new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll,
- this, SLOT(showSettingsDlg()), tr("F7")));
+ this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7)));
// Help
coll->addAction("AboutQuassel", new Action(SmallIcon("quassel"), tr("&About Quassel"), coll,
}
void MainWin::bufferViewToggled(bool enabled) {
+ if(!enabled && !isVisible()) {
+ // hiding the mainwindow triggers a toggle of the bufferview (which pretty much sucks big time)
+ // since this isn't our fault and we can't do anything about it, we suppress the resulting calls
+ return;
+ }
QAction *action = qobject_cast<QAction *>(sender());
Q_ASSERT(action);
BufferViewDock *dock = qobject_cast<BufferViewDock *>(action->parent());
if(enabled) {
Client::bufferViewOverlay()->addView(dock->bufferViewId());
- BufferViewConfig *config = dock->config();
- if(config && config->isInitialized()) {
- BufferIdList buffers;
- if(config->networkId().isValid()) {
- foreach(BufferId bufferId, config->bufferList()) {
- if(Client::networkModel()->networkId(bufferId) == config->networkId())
- buffers << bufferId;
- }
- foreach(BufferId bufferId, config->temporarilyRemovedBuffers().toList()) {
- if(Client::networkModel()->networkId(bufferId) == config->networkId())
- buffers << bufferId;
- }
- } else {
- buffers = BufferIdList::fromSet(config->bufferList().toSet() + config->temporarilyRemovedBuffers());
- }
- Client::backlogManager()->checkForBacklog(buffers);
- }
} else {
Client::bufferViewOverlay()->removeView(dock->bufferViewId());
}
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() {
if(dock && actionData.toInt() != -1) {
removeAction(action);
_bufferViews.removeAll(dock);
- Client::bufferViewOverlay()->removeView(dock->bufferViewId());
dock->deleteLater();
}
}
if(event->type() == QEvent::WindowActivate) {
BufferId buffer = Client::bufferModel()->currentBuffer();
if(buffer.isValid())
- QtUi::closeNotifications(buffer);
+ Client::instance()->markBufferAsRead(buffer);
}
return QMainWindow::event(event);
}
else
type = AbstractNotificationBackend::HighlightFocused;
- QtUi::invokeNotification(bufId, type, sender, contents);
+ QtUi::instance()->invokeNotification(bufId, type, sender, contents);
}
}
}
void MainWin::currentBufferChanged(BufferId buffer) {
if(buffer.isValid())
- QtUi::closeNotifications(buffer);
+ Client::instance()->markBufferAsRead(buffer);
}
void MainWin::clientNetworkCreated(NetworkId id) {
void MainWin::showStatusBarMessage(const QString &message) {
statusBar()->showMessage(message, 10000);
}
-