X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fmainwin.cpp;h=1399113c5e5fb9b605d3a953bb9ef13461dae095;hp=cc667caa5416edaf0baf3b18cd0ad55fa3fa2721;hb=d24dd043d52af12e0ad68625ca0c9a9ec16fc8e1;hpb=694f9bfbf7f1af19108461c7e00d133e55082bce diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index cc667caa..1399113c 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2012 by the Quassel Project * + * Copyright (C) 2005-2014 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -15,8 +15,9 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ + #include "mainwin.h" #include @@ -61,6 +62,8 @@ #include "clientbufferviewconfig.h" #include "clientbufferviewmanager.h" #include "clientignorelistmanager.h" +#include "clienttransfer.h" +#include "clienttransfermanager.h" #include "coreconfigwizard.h" #include "coreconnectdlg.h" #include "coreconnection.h" @@ -82,6 +85,7 @@ #include "qtuimessageprocessor.h" #include "qtuisettings.h" #include "qtuistyle.h" +#include "receivefiledlg.h" #include "settingsdlg.h" #include "settingspagedlg.h" #include "statusnotifieritem.h" @@ -93,6 +97,9 @@ # ifdef HAVE_PHONON # include "phononnotificationbackend.h" # endif +# ifdef HAVE_LIBSNORE +# include "snorenotificationbackend.h" +# endif # include "systraynotificationbackend.h" # include "taskbarnotificationbackend.h" #else /* HAVE_KDE */ @@ -107,6 +114,14 @@ #include "indicatornotificationbackend.h" #endif +#ifdef HAVE_NOTIFICATION_CENTER + #include "osxnotificationbackend.h" +#endif + +#ifdef HAVE_DBUS + #include "dockmanagernotificationbackend.h" +#endif + #include "settingspages/aliasessettingspage.h" #include "settingspages/appearancesettingspage.h" #include "settingspages/backlogsettingspage.h" @@ -203,7 +218,9 @@ void MainWin::init() # ifdef HAVE_PHONON QtUi::registerNotificationBackend(new PhononNotificationBackend(this)); # endif -# ifndef QT_NO_SYSTEMTRAYICON +# ifdef HAVE_LIBSNORE + QtUi::registerNotificationBackend(new SnoreNotificationBackend(this)); +# elif !defined(QT_NO_SYSTEMTRAYICON) QtUi::registerNotificationBackend(new SystrayNotificationBackend(this)); # endif @@ -217,6 +234,14 @@ void MainWin::init() QtUi::registerNotificationBackend(new IndicatorNotificationBackend(this)); #endif +#ifdef HAVE_NOTIFICATION_CENTER + QtUi::registerNotificationBackend(new OSXNotificationBackend(this)); +#endif + +#ifdef HAVE_DBUS + QtUi::registerNotificationBackend(new DockManagerNotificationBackend(this)); +#endif + // we assume that at this point, all configurable actions are defined! QtUi::loadShortcuts(); @@ -297,7 +322,9 @@ void MainWin::restoreStateFromSettings(UiSettings &s) move(_normalPos); #endif - if (s.value("MainWinHidden").toBool() && QtUi::haveSystemTray()) + if ((Quassel::isOptionSet("hidewindow") + || s.value("MainWinHidden").toBool()) + && _systemTray->isSystemTrayAvailable()) QtUi::hideMainWidget(); else if (s.value("MainWinMinimized").toBool()) showMinimized(); @@ -361,13 +388,13 @@ void MainWin::setupActions() 0, 0))->setCheckable(true); #ifdef HAVE_KDE - QAction *fullScreenAct = KStandardAction::fullScreen(this, SLOT(toggleFullscreen()), this, coll); + QAction *fullScreenAct = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll); #else QAction *fullScreenAct = new Action(SmallIcon("view-fullscreen"), tr("&Full Screen Mode"), coll, - this, SLOT(toggleFullscreen()), QKeySequence(Qt::Key_F11)); + this, SLOT(onFullScreenToggled()), QKeySequence(Qt::Key_F11)); fullScreenAct->setCheckable(true); #endif - coll->addAction("ToggleFullscreen", fullScreenAct); + coll->addAction("ToggleFullScreen", fullScreenAct); // Settings QAction *configureShortcutsAct = new Action(SmallIcon("configure-shortcuts"), tr("Configure &Shortcuts..."), coll, @@ -633,7 +660,7 @@ void MainWin::removeBufferView(int bufferViewConfigId) void MainWin::bufferViewToggled(bool enabled) { - if (!enabled && !isVisible()) { + if (!enabled && !isMinimized()) { // 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; @@ -896,7 +923,7 @@ void MainWin::setupTopicWidget() void MainWin::setupViewMenuTail() { _viewMenu->addSeparator(); - _viewMenu->addAction(QtUi::actionCollection("General")->action("ToggleFullscreen")); + _viewMenu->addAction(QtUi::actionCollection("General")->action("ToggleFullScreen")); } @@ -988,8 +1015,24 @@ void MainWin::setupToolBars() QtUi::toolBarActionProvider()->addActions(_mainToolBar, ToolBarActionProvider::MainToolBar); _toolbarMenu->addAction(_mainToolBar->toggleViewAction()); + +#ifdef Q_WS_MAC + QtUiSettings uiSettings; + + bool visible = uiSettings.value("ShowMainToolBar", QVariant(true)).toBool(); + _mainToolBar->setVisible(visible); + connect(_mainToolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(saveMainToolBarStatus(bool))); +#endif } +#ifdef Q_WS_MAC +void MainWin::saveMainToolBarStatus(bool enabled) +{ + QtUiSettings uiSettings; + uiSettings.setValue("ShowMainToolBar", enabled); +} +#endif + void MainWin::connectedToCore() { @@ -998,6 +1041,8 @@ void MainWin::connectedToCore() connect(Client::bufferViewManager(), SIGNAL(bufferViewConfigDeleted(int)), this, SLOT(removeBufferView(int))); connect(Client::bufferViewManager(), SIGNAL(initDone()), this, SLOT(loadLayout())); + connect(Client::transferManager(), SIGNAL(transferAdded(const ClientTransfer*)), SLOT(showNewTransferDlg(const ClientTransfer*))); + setConnectedState(); } @@ -1334,12 +1379,31 @@ void MainWin::showShortcutsDlg() } -void MainWin::toggleFullscreen() +void MainWin::showNewTransferDlg(const ClientTransfer *transfer) +{ + ReceiveFileDlg *dlg = new ReceiveFileDlg(transfer, this); + dlg->show(); +} + + +void MainWin::onFullScreenToggled() { - if (isFullScreen()) - showNormal(); + // Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs + // Also, one should not use showFullScreen() or showNormal(), as those reset all other window flags + + QAction *action = QtUi::actionCollection("General")->action("ToggleFullScreen"); + if (!action) + return; + +#ifdef HAVE_KDE + KToggleFullScreenAction *kAct = static_cast(action); + kAct->setFullScreen(this, kAct->isChecked()); +#else + if (action->isChecked()) + setWindowState(windowState() | Qt::WindowFullScreen); else - showFullScreen(); + setWindowState(windowState() & ~Qt::WindowFullScreen); +#endif } @@ -1347,10 +1411,19 @@ void MainWin::toggleFullscreen() bool MainWin::event(QEvent *event) { - if (event->type() == QEvent::WindowActivate) { - BufferId buffer = Client::bufferModel()->currentBuffer(); - if (buffer.isValid()) - Client::instance()->markBufferAsRead(buffer); + switch(event->type()) { + case QEvent::WindowActivate: { + BufferId bufferId = Client::bufferModel()->currentBuffer(); + if (bufferId.isValid()) + Client::instance()->markBufferAsRead(bufferId); + break; + } + case QEvent::WindowDeactivate: + if (bufferWidget()->autoMarkerLineOnLostFocus()) + bufferWidget()->setMarkerLine(); + break; + default: + break; } return QMainWindow::event(event); }