X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=2ae203d9aaba1e1ccfc0746c8563917df5f5f21f;hp=bf806b7becd8082ee996d7df7d64467c3481620b;hb=d3f60cb05a682113f75ff21beb1c7fcdf9a85b67;hpb=c3f487c53eb663ba9d06176b093d928351bee78d diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index bf806b7b..2ae203d9 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -28,6 +28,7 @@ #include "channellistdlg.h" #include "client.h" #include "clientbacklogmanager.h" +#include "coreinfodlg.h" #include "coreconnectdlg.h" #include "networkmodel.h" #include "buffermodel.h" @@ -40,6 +41,7 @@ #include "irclistmodel.h" #include "verticaldock.h" #include "uisettings.h" +#include "util.h" #include "qtuisettings.h" #include "jumpkeyhandler.h" @@ -48,6 +50,7 @@ #include "selectionmodelsynchronizer.h" #include "mappedselectionmodel.h" +#include "settingspages/aliasessettingspage.h" #include "settingspages/appearancesettingspage.h" #include "settingspages/bufferviewsettingspage.h" #include "settingspages/colorsettingspage.h" @@ -62,10 +65,10 @@ #include "global.h" #include "qtuistyle.h" - MainWin::MainWin(QtUi *_gui, QWidget *parent) : QMainWindow(parent), gui(_gui), + coreLagLabel(new QLabel()), sslLabel(new QLabel()), _titleSetter(this), systray(new QSystemTrayIcon(this)), @@ -78,6 +81,14 @@ MainWin::MainWin(QtUi *_gui, QWidget *parent) settingsDlg(new SettingsDlg(this)), debugConsole(new DebugConsole(this)) { + UiSettings uiSettings; + loadTranslation(uiSettings.value("Locale", QLocale::system()).value()); + + QString style = uiSettings.value("Style", QString("")).toString(); + if(style != "") { + QApplication::setStyle(style); + } + ui.setupUi(this); setWindowTitle("Quassel IRC"); setWindowIcon(offlineTrayIcon); @@ -94,6 +105,16 @@ MainWin::MainWin(QtUi *_gui, QWidget *parent) if(style != "") { QApplication::setStyle(style); } + +#ifdef HAVE_DBUS + desktopNotifications = new org::freedesktop::Notifications( + "org.freedesktop.Notifications", + "/org/freedesktop/Notifications", + QDBusConnection::sessionBus(), this); + notificationId = 0; + connect(desktopNotifications, SIGNAL(NotificationClosed(uint, uint)), this, SLOT(desktopNotificationClosed(uint, uint))); + connect(desktopNotifications, SIGNAL(ActionInvoked(uint, const QString&)), this, SLOT(desktopNotificationInvoked(uint, const QString&))); +#endif } void MainWin::init() { @@ -162,6 +183,7 @@ MainWin::~MainWin() { void MainWin::setupMenus() { connect(ui.actionConnectCore, SIGNAL(triggered()), this, SLOT(showCoreConnectionDlg())); connect(ui.actionDisconnectCore, SIGNAL(triggered()), Client::instance(), SLOT(disconnectFromCore())); + connect(ui.actionCoreInfo, SIGNAL(triggered()), this, SLOT(showCoreInfoDlg())); connect(ui.actionQuit, SIGNAL(triggered()), QCoreApplication::instance(), SLOT(quit())); connect(ui.actionSettingsDlg, SIGNAL(triggered()), this, SLOT(showSettingsDlg())); // connect(ui.actionDebug_Console, SIGNAL(triggered()), this, SLOT(showDebugConsole())); @@ -226,6 +248,7 @@ void MainWin::setupSettingsDlg() { //Category: Behaviour settingsDlg->registerSettingsPage(new GeneralSettingsPage(settingsDlg)); settingsDlg->registerSettingsPage(new HighlightSettingsPage(settingsDlg)); + settingsDlg->registerSettingsPage(new AliasesSettingsPage(settingsDlg)); //Category: General settingsDlg->registerSettingsPage(new IdentitiesSettingsPage(settingsDlg)); settingsDlg->registerSettingsPage(new NetworksSettingsPage(settingsDlg)); @@ -326,6 +349,12 @@ void MainWin::setupTopicWidget() { } void MainWin::setupStatusBar() { + // Core Lag: + updateLagIndicator(0); + statusBar()->addPermanentWidget(coreLagLabel); + connect(Client::signalProxy(), SIGNAL(lagUpdated(int)), this, SLOT(updateLagIndicator(int))); + + // SSL indicator connect(Client::instance(), SIGNAL(securedConnection()), this, SLOT(securedConnection())); sslLabel->setPixmap(QPixmap()); statusBar()->addPermanentWidget(sslLabel); @@ -400,7 +429,7 @@ void MainWin::connectedToCore() { connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigAdded(int)), this, SLOT(addBufferView(int))); connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigDeleted(int)), this, SLOT(removeBufferView(int))); connect(Client::bufferViewManager(), SIGNAL(initDone()), this, SLOT(loadLayout())); - + foreach(BufferInfo id, Client::allBufferInfos()) { Client::backlogManager()->requestBacklog(id.bufferId(), 500, -1); } @@ -408,10 +437,11 @@ void MainWin::connectedToCore() { } void MainWin::setConnectedState() { - ui.menuViews->setEnabled(true); //ui.menuCore->setEnabled(true); ui.actionConnectCore->setEnabled(false); ui.actionDisconnectCore->setEnabled(true); + ui.actionCoreInfo->setEnabled(true); + ui.menuViews->setEnabled(true); ui.bufferWidget->show(); statusBar()->showMessage(tr("Connected to core.")); setWindowIcon(onlineTrayIcon); @@ -433,6 +463,11 @@ void MainWin::saveLayout() { if(accountId > 0) s.setValue(QString("MainWinState-%1").arg(accountId) , saveState(accountId)); } +void MainWin::updateLagIndicator(int lag) { + coreLagLabel->setText(QString("Core Lag: %1 msec").arg(lag)); +} + + void MainWin::securedConnection() { // todo: make status bar entry sslLabel->setPixmap(QPixmap::fromImage(QImage(":/16x16/status/ssl"))); @@ -460,11 +495,12 @@ void MainWin::disconnectedFromCore() { } void MainWin::setDisconnectedState() { - ui.menuViews->setEnabled(false); //ui.menuCore->setEnabled(false); + ui.actionConnectCore->setEnabled(true); ui.actionDisconnectCore->setEnabled(false); + ui.actionCoreInfo->setEnabled(false); + ui.menuViews->setEnabled(false); ui.bufferWidget->hide(); - ui.actionConnectCore->setEnabled(true); statusBar()->showMessage(tr("Not connected to core.")); setWindowIcon(offlineTrayIcon); qApp->setWindowIcon(offlineTrayIcon); @@ -494,6 +530,11 @@ void MainWin::showChannelList(NetworkId netId) { channelListDlg->show(); } +void MainWin::showCoreInfoDlg() { + CoreInfoDlg dlg(this); + dlg.exec(); +} + void MainWin::showSettingsDlg() { settingsDlg->show(); } @@ -567,10 +608,15 @@ void MainWin::receiveMessage(const Message &msg) { UiSettings uiSettings; #ifndef SPUTDEV - if(uiSettings.value("DisplayPopupMessages", QVariant(true)).toBool()) { + bool displayBubble = uiSettings.value("NotificationBubble", QVariant(true)).toBool(); + bool displayDesktop = uiSettings.value("NotificationDesktop", QVariant(true)).toBool(); + if(displayBubble || displayDesktop) { // FIXME don't invoke style engine for this! QString text = QtUi::style()->styleString(Message::mircToInternal(msg.contents())).plainText; - displayTrayIconMessage(title, text); + if(displayBubble) displayTrayIconMessage(title, text); +# ifdef HAVE_DBUS + if(displayDesktop) sendDesktopNotification(title, text); +# endif } #endif if(uiSettings.value("AnimateTrayIcon", QVariant(true)).toBool()) { @@ -586,6 +632,57 @@ bool MainWin::event(QEvent *event) { return QMainWindow::event(event); } +#ifdef HAVE_DBUS + +/* +Using the notification-daemon from Freedesktop's Galago project +http://www.galago-project.org/specs/notification/0.9/x408.html#command-notify +*/ +void MainWin::sendDesktopNotification(const QString &title, const QString &message) { + QStringList actions; + QMap hints; + UiSettings uiSettings; + + hints["x"] = uiSettings.value("NotificationDesktopHintX", QVariant(0)).toInt(); // Standard hint: x location for the popup to show up + hints["y"] = uiSettings.value("NotificationDesktopHintY", QVariant(0)).toInt(); // Standard hint: y location for the popup to show up + + actions << "click" << "Click Me!"; + + QDBusReply reply = desktopNotifications->Notify( + "Quassel", // Application name + notificationId, // ID of previous notification to replace + "", // Icon to display + title, // Summary / Header of the message to display + QString("%1: %2:\n%3").arg(QTime::currentTime().toString()).arg(title).arg(message), // Body of the message to display + actions, // Actions from which the user may choose + hints, // Hints to the server displaying the message + uiSettings.value("NotificationDesktopTimeout", QVariant(5000)).toInt() // Timeout in milliseconds + ); + + if(!reply.isValid()) { + /* ERROR */ + qDebug() << "Error on sending notification..."; + return; + } + + notificationId = reply.value(); + + qDebug() << "ID: " << notificationId << " Time: " << QTime::currentTime().toString(); +} + + +void MainWin::desktopNotificationClosed(uint id, uint reason) { + qDebug() << "OID: " << notificationId << " ID: " << id << " Reason: " << reason << " Time: " << QTime::currentTime().toString(); + notificationId = 0; +} + + +void MainWin::desktopNotificationInvoked(uint id, const QString & action) { + qDebug() << "OID: " << notificationId << " ID: " << id << " Action: " << action << " Time: " << QTime::currentTime().toString(); +} + +#endif /* HAVE_DBUS */ + void MainWin::displayTrayIconMessage(const QString &title, const QString &message) { systray->showMessage(title, message); }