X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=06c9b8999513a472d49df10b3433d60c0d8b2931;hp=df005d578ac1a4a75a43ab1d9af27b3ca1392259;hb=96c9508110f38a19be161652ea888c7d61ba279b;hpb=16b1cf4b46f6f5ee85c2331028a6f40e54f53298 diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index df005d57..06c9b899 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -19,10 +19,20 @@ ***************************************************************************/ #include "mainwin.h" +#ifdef HAVE_KDE +# include +# include +# include +# include +# include +# include +#endif + #include "aboutdlg.h" #include "action.h" #include "actioncollection.h" #include "buffermodel.h" +#include "bufferview.h" #include "bufferviewmanager.h" #include "bufferwidget.h" #include "channellistdlg.h" @@ -34,8 +44,11 @@ #include "clientbacklogmanager.h" #include "coreinfodlg.h" #include "coreconnectdlg.h" +#include "debuglogwidget.h" +#include "debugmessagemodelfilter.h" #include "iconloader.h" #include "inputwidget.h" +#include "inputline.h" #include "irclistmodel.h" #include "jumpkeyhandler.h" #include "msgprocessorstatuswidget.h" @@ -49,15 +62,24 @@ #include "topicwidget.h" #include "verticaldock.h" -#ifdef HAVE_DBUS -# include "desktopnotificationbackend.h" -#endif -#include "systraynotificationbackend.h" -#include "taskbarnotificationbackend.h" +#ifndef HAVE_KDE +# ifdef HAVE_DBUS +# include "desktopnotificationbackend.h" +# endif +# ifdef HAVE_PHONON +# include "phononnotificationbackend.h" +# endif +# include "systraynotificationbackend.h" +# include "taskbarnotificationbackend.h" +#else /* HAVE_KDE */ +# include "knotificationbackend.h" +#endif /* HAVE_KDE */ #include "settingspages/aliasessettingspage.h" #include "settingspages/appearancesettingspage.h" +#include "settingspages/backlogsettingspage.h" #include "settingspages/bufferviewsettingspage.h" +#include "settingspages/chatmonitorsettingspage.h" #include "settingspages/colorsettingspage.h" #include "settingspages/fontssettingspage.h" #include "settingspages/generalsettingspage.h" @@ -67,7 +89,12 @@ #include "settingspages/notificationssettingspage.h" MainWin::MainWin(QWidget *parent) +#ifdef HAVE_KDE + : KMainWindow(parent), + _kHelpMenu(new KHelpMenu(this)), +#else : QMainWindow(parent), +#endif coreLagLabel(new QLabel()), sslLabel(new QLabel()), msgProcessorStatusWidget(new MsgProcessorStatusWidget()), @@ -80,17 +107,27 @@ MainWin::MainWin(QWidget *parent) QApplication::setStyle(style); } + QApplication::setQuitOnLastWindowClosed(false); + setWindowTitle("Quassel IRC"); setWindowIconText("Quassel IRC"); updateIcon(); installEventFilter(new JumpKeyHandler(this)); - QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this)); - QtUi::registerNotificationBackend(new SystrayNotificationBackend(this)); -#ifdef HAVE_DBUS - QtUi::registerNotificationBackend(new DesktopNotificationBackend(this)); -#endif +#ifndef HAVE_KDE + QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this)); + QtUi::registerNotificationBackend(new SystrayNotificationBackend(this)); +# ifdef HAVE_PHONON + QtUi::registerNotificationBackend(new PhononNotificationBackend(this)); +# endif +# ifdef HAVE_DBUS + QtUi::registerNotificationBackend(new DesktopNotificationBackend(this)); +# endif + +#else /* HAVE_KDE */ + QtUi::registerNotificationBackend(new KNotificationBackend(this)); +#endif /* HAVE_KDE */ QtUiApplication* app = qobject_cast qApp; connect(app, SIGNAL(saveStateToSession(const QString&)), SLOT(saveStateToSession(const QString&))); @@ -107,6 +144,7 @@ void MainWin::init() { 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::mainUi()->actionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId))); // Setup Dock Areas setDockNestingEnabled(true); @@ -137,7 +175,6 @@ void MainWin::init() { setDisconnectedState(); // Disable menus and stuff show(); - showCoreConnectionDlg(true); // autoconnect if appropriate } @@ -174,9 +211,9 @@ void MainWin::setupActions() { qApp, SLOT(quit()), tr("Ctrl+Q"))); // View - coll->addAction("ManageBufferViews", new Action(SmallIcon("view-tree"), tr("&Manage Buffer Views..."), coll, + coll->addAction("ManageBufferViews", new Action(tr("&Manage Buffer Views..."), coll, this, SLOT(on_actionManageViews_triggered()))); - Action *lockAct = coll->addAction("LockDockPositions", new Action(tr("&Lock Dock Positions"), coll)); + QAction *lockAct = coll->addAction("LockDockPositions", new Action(tr("&Lock Dock Positions"), coll)); lockAct->setCheckable(true); connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockDockPositions_toggled(bool))); @@ -190,12 +227,16 @@ void MainWin::setupActions() { this, SLOT(showSettingsDlg()), tr("F7"))); // Help - coll->addAction("AboutQuassel", new Action(SmallIcon("quassel"), tr("&About Quassel..."), coll, + coll->addAction("AboutQuassel", new Action(SmallIcon("quassel"), tr("&About Quassel"), coll, this, SLOT(showAboutDlg()))); - coll->addAction("AboutQt", new Action(tr("About &Qt..."), coll, + coll->addAction("AboutQt", new Action(QIcon(":/pics/qt-logo.png"), tr("About &Qt"), coll, qApp, SLOT(aboutQt()))); coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll, this, SLOT(on_actionDebugNetworkModel_triggered()))); + coll->addAction("DebugMessageModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &MessageModel"), coll, + this, SLOT(on_actionDebugMessageModel_triggered()))); + coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll, + this, SLOT(on_actionDebugLog_triggered()))); } void MainWin::setupMenus() { @@ -222,14 +263,24 @@ void MainWin::setupMenus() { _viewMenu->addAction(coll->action("LockDockPositions")); _settingsMenu = menuBar()->addMenu(tr("&Settings")); +#ifdef HAVE_KDE + _settingsMenu->addAction(KStandardAction::keyBindings(this, SLOT(showShortcutsDlg()), this)); + _settingsMenu->addAction(KStandardAction::configureNotifications(this, SLOT(showNotificationsDlg()), this)); +#endif _settingsMenu->addAction(coll->action("ConfigureQuassel")); _helpMenu = menuBar()->addMenu(tr("&Help")); _helpMenu->addAction(coll->action("AboutQuassel")); +#ifndef HAVE_KDE _helpMenu->addAction(coll->action("AboutQt")); +#else + _helpMenu->addAction(KStandardAction::aboutKDE(_kHelpMenu, SLOT(aboutKDE()), this)); +#endif _helpMenu->addSeparator(); _helpDebugMenu = _helpMenu->addMenu(SmallIcon("tools-report-bug"), tr("Debug")); _helpDebugMenu->addAction(coll->action("DebugNetworkModel")); + _helpDebugMenu->addAction(coll->action("DebugMessageModel")); + _helpDebugMenu->addAction(coll->action("DebugLog")); } void MainWin::setupBufferWidget() { @@ -259,8 +310,6 @@ void MainWin::addBufferView(BufferViewConfig *config) { view->setFilteredModel(Client::bufferModel(), config); view->show(); - connect(&view->showChannelList, SIGNAL(triggered()), this, SLOT(showChannelList())); - Client::bufferModel()->synchronizeView(view); dock->setWidget(view); @@ -269,7 +318,7 @@ void MainWin::addBufferView(BufferViewConfig *config) { addDockWidget(Qt::LeftDockWidgetArea, dock); _bufferViewsMenu->addAction(dock->toggleViewAction()); - _netViews.append(dock); + _bufferViews.append(dock); } void MainWin::removeBufferView(int bufferViewConfigId) { @@ -288,6 +337,18 @@ void MainWin::removeBufferView(int bufferViewConfigId) { } } +BufferView *MainWin::allBuffersView() const { + // "All Buffers" is always the first dock created + if(_bufferViews.count() > 0) + return _bufferViews[0]->bufferView(); + return 0; +} + +void MainWin::showNotificationsDlg() { + SettingsPageDlg dlg(new NotificationsSettingsPage(this), this); + dlg.exec(); +} + void MainWin::on_actionEditNetworks_triggered() { SettingsPageDlg dlg(new NetworksSettingsPage(this), this); dlg.exec(); @@ -358,6 +419,8 @@ void MainWin::setupInputWidget() { inputWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel()); _bufferWidget->setFocusProxy(inputWidget); + + inputWidget->inputLine()->installEventFilter(_bufferWidget); } void MainWin::setupTopicWidget() { @@ -407,6 +470,9 @@ void MainWin::setupStatusBar() { connect(showStatusbar, SIGNAL(toggled(bool)), statusBar(), SLOT(setVisible(bool))); connect(showStatusbar, SIGNAL(toggled(bool)), this, SLOT(saveStatusBarStatus(bool))); + + connect(Client::backlogManager(), SIGNAL(messagesRequested(const QString &)), this, SLOT(showStatusBarMessage(const QString &))); + connect(Client::backlogManager(), SIGNAL(messagesProcessed(const QString &)), this, SLOT(showStatusBarMessage(const QString &))); } void MainWin::saveStatusBarStatus(bool enabled) { @@ -459,7 +525,6 @@ void MainWin::connectedToCore() { connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigDeleted(int)), this, SLOT(removeBufferView(int))); connect(Client::bufferViewManager(), SIGNAL(initDone()), this, SLOT(loadLayout())); - Client::backlogManager()->requestInitialBacklog(); setConnectedState(); } @@ -562,9 +627,11 @@ void MainWin::showSettingsDlg() { dlg->registerSettingsPage(new AppearanceSettingsPage(dlg)); //General //Category: Behaviour dlg->registerSettingsPage(new GeneralSettingsPage(dlg)); + dlg->registerSettingsPage(new BacklogSettingsPage(dlg)); dlg->registerSettingsPage(new HighlightSettingsPage(dlg)); dlg->registerSettingsPage(new AliasesSettingsPage(dlg)); dlg->registerSettingsPage(new NotificationsSettingsPage(dlg)); + dlg->registerSettingsPage(new ChatMonitorSettingsPage(dlg)); //Category: General dlg->registerSettingsPage(new IdentitiesSettingsPage(dlg)); dlg->registerSettingsPage(new NetworksSettingsPage(dlg)); @@ -577,6 +644,12 @@ void MainWin::showAboutDlg() { AboutDlg(this).exec(); } +#ifdef HAVE_KDE +void MainWin::showShortcutsDlg() { + KShortcutsDialog::configure(QtUi::actionCollection("General"), KShortcutsEditor::LetterShortcutsDisallowed); +} +#endif + void MainWin::closeEvent(QCloseEvent *event) { QtUiSettings s; if(s.value("UseSystemTrayIcon").toBool() && s.value("MinimizeOnClose").toBool()) { @@ -584,6 +657,7 @@ void MainWin::closeEvent(QCloseEvent *event) { event->ignore(); } else { event->accept(); + QApplication::quit(); } } @@ -727,6 +801,22 @@ void MainWin::on_actionDebugNetworkModel_triggered() { view->show(); } +void MainWin::on_actionDebugMessageModel_triggered() { + QTableView *view = new QTableView(0); + DebugMessageModelFilter *filter = new DebugMessageModelFilter(view); + filter->setSourceModel(Client::messageModel()); + view->setModel(filter); + view->setAttribute(Qt::WA_DeleteOnClose, true); + view->verticalHeader()->hide(); + view->horizontalHeader()->setStretchLastSection(true); + view->show(); +} + +void MainWin::on_actionDebugLog_triggered() { + DebugLogWidget *logWidget = new DebugLogWidget(0); + logWidget->show(); +} + void MainWin::saveStateToSession(const QString &sessionId) { return; SessionSettings s(sessionId); @@ -742,3 +832,7 @@ void MainWin::saveStateToSessionSettings(SessionSettings & s) s.setValue("MainWinPos", pos()); s.setValue("MainWinState", saveState()); } + +void MainWin::showStatusBarMessage(const QString &message) { + statusBar()->showMessage(message, 10000); +}