Save Main ToolBar state when not built against KDE. Fixes #1116
[quassel.git] / src / qtui / mainwin.cpp
index 01389c5..39199d3 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  *
@@ -1015,7 +1015,23 @@ void MainWin::setupToolBars()
 
     QtUi::toolBarActionProvider()->addActions(_mainToolBar, ToolBarActionProvider::MainToolBar);
     _toolbarMenu->addAction(_mainToolBar->toggleViewAction());
+
+#ifndef HAVE_KDE
+    QtUiSettings uiSettings;
+
+    bool visible = uiSettings.value("ShowMainToolBar", QVariant(true)).toBool();
+    _mainToolBar->setVisible(visible);
+    connect(_mainToolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(saveMainToolBarStatus(bool)));
+#endif
+}
+
+#ifndef HAVE_KDE
+void MainWin::saveMainToolBarStatus(bool enabled)
+{
+    QtUiSettings uiSettings;
+    uiSettings.setValue("ShowMainToolBar", enabled);
 }
+#endif
 
 
 void MainWin::connectedToCore()
@@ -1395,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);
 }