Change Q_WS_* to Q_OS_*
[quassel.git] / src / qtui / mainwin.cpp
index d5e9b0c..2a1ce6f 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-2013 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  *
@@ -62,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"
@@ -83,6 +85,7 @@
 #include "qtuimessageprocessor.h"
 #include "qtuisettings.h"
 #include "qtuistyle.h"
+#include "receivefiledlg.h"
 #include "settingsdlg.h"
 #include "settingspagedlg.h"
 #include "statusnotifieritem.h"
@@ -334,7 +337,7 @@ void MainWin::restoreStateFromSettings(UiSettings &s)
 
 void MainWin::updateIcon()
 {
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     const int size = 128;
 #else
     const int size = 48;
@@ -399,7 +402,7 @@ void MainWin::setupActions()
     configureShortcutsAct->setMenuRole(QAction::NoRole);
     coll->addAction("ConfigureShortcuts", configureShortcutsAct);
 
-  #ifdef Q_WS_MAC
+  #ifdef Q_OS_MAC
     QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll,
         this, SLOT(showSettingsDlg()));
     configureQuasselAct->setMenuRole(QAction::PreferencesRole);
@@ -442,7 +445,7 @@ void MainWin::setupActions()
             this, SLOT(on_jumpHotBuffer_triggered()), QKeySequence(Qt::META + Qt::Key_A)));
 
     // Jump keys
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     const int bindModifier = Qt::ControlModifier | Qt::AltModifier;
     const int jumpModifier = Qt::ControlModifier;
 #else
@@ -997,7 +1000,7 @@ void MainWin::setupToolBars()
     connect(_nickListWidget, SIGNAL(nickSelectionChanged(QModelIndexList)),
         QtUi::toolBarActionProvider(), SLOT(nickSelectionChanged(QModelIndexList)));
 
-#ifdef Q_WS_MAC
+#ifdef Q_OS_MAC
     setUnifiedTitleAndToolBarOnMac(true);
 #endif
 
@@ -1012,7 +1015,23 @@ void MainWin::setupToolBars()
 
     QtUi::toolBarActionProvider()->addActions(_mainToolBar, ToolBarActionProvider::MainToolBar);
     _toolbarMenu->addAction(_mainToolBar->toggleViewAction());
+
+#ifdef Q_OS_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_OS_MAC
+void MainWin::saveMainToolBarStatus(bool enabled)
+{
+    QtUiSettings uiSettings;
+    uiSettings.setValue("ShowMainToolBar", enabled);
 }
+#endif
 
 
 void MainWin::connectedToCore()
@@ -1022,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();
 }
 
@@ -1358,6 +1379,13 @@ void MainWin::showShortcutsDlg()
 }
 
 
+void MainWin::showNewTransferDlg(const ClientTransfer *transfer)
+{
+    ReceiveFileDlg *dlg = new ReceiveFileDlg(transfer, this);
+    dlg->show();
+}
+
+
 void MainWin::onFullScreenToggled()
 {
     // Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs
@@ -1383,10 +1411,19 @@ void MainWin::onFullScreenToggled()
 
 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);
 }