display channelname in windowtitle
authorAlexander von Renteln <phon@quassel-irc.org>
Mon, 21 Apr 2008 00:02:06 +0000 (00:02 +0000)
committerAlexander von Renteln <phon@quassel-irc.org>
Mon, 21 Apr 2008 00:02:06 +0000 (00:02 +0000)
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/qtui.pri
src/qtui/titlesetter.cpp [new file with mode: 0644]
src/qtui/titlesetter.h [new file with mode: 0644]
version.inc

index f01640a..829fa98 100644 (file)
 #include "global.h"
 #include "qtuistyle.h"
 
+
 MainWin::MainWin(QtUi *_gui, QWidget *parent)
   : QMainWindow(parent),
     gui(_gui),
     sslLabel(new QLabel()),
+    _titleSetter(this),
     systray(new QSystemTrayIcon(this)),
     activeTrayIcon(":/icons/quassel-icon-active.png"),
     onlineTrayIcon(":/icons/quassel-icon.png"),
@@ -140,6 +142,8 @@ void MainWin::init() {
   ui.bufferWidget->setModel(Client::bufferModel());
   ui.bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
 
+  _titleSetter.setModel(Client::bufferModel());
+  _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel());
 }
 
 MainWin::~MainWin() {
@@ -606,6 +610,7 @@ void MainWin::makeTrayIconBlink() {
 }
 
 
+
 void MainWin::clientNetworkCreated(NetworkId id) {
   const Network *net = Client::network(id);
   QAction *act = new QAction(net->networkName(), this);
index f572e1d..96e0c71 100644 (file)
 #include "ui_mainwin.h"
 
 #include "qtui.h"
+#include "titlesetter.h"
 
 #include <QSystemTrayIcon>
 #include <QTimer>
 
+
 class ServerListDlg;
 class CoreConnectDlg;
 class Buffer;
@@ -107,6 +109,8 @@ class MainWin : public QMainWindow {
     QMenu *systrayMenu;
     QLabel *sslLabel;
 
+    TitleSetter _titleSetter;
+
     void setupMenus();
     void setupViews();
     void setupNickWidget();
index 089c788..ab2774f 100644 (file)
@@ -4,12 +4,12 @@ QT_MOD = core gui network
 SRCS += aboutdlg.cpp bufferwidget.cpp chatline-old.cpp chatwidget.cpp \
         coreconfigwizard.cpp coreconnectdlg.cpp configwizard.cpp debugconsole.cpp inputwidget.cpp \
         mainwin.cpp nicklistwidget.cpp qtui.cpp qtuisettings.cpp qtuistyle.cpp settingsdlg.cpp settingspagedlg.cpp \
-        topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
+        titlesetter.cpp topicbutton.cpp topicwidget.cpp verticaldock.cpp jumpkeyhandler.cpp
 
 HDRS += aboutdlg.h bufferwidget.h chatline-old.h chatwidget.h \
         coreconfigwizard.h configwizard.h debugconsole.h inputwidget.h \
         coreconnectdlg.h mainwin.h nicklistwidget.h qtui.h qtuisettings.h qtuistyle.h settingsdlg.h settingspagedlg.h \
-        topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
+        titlesetter.h topicbutton.h topicwidget.h verticaldock.h jumpkeyhandler.h
 
 FORMNAMES = aboutdlg.ui mainwin.ui coreaccounteditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui nicklistwidget.ui settingsdlg.ui \
             settingspagedlg.ui topicwidget.ui debugconsole.ui inputwidget.ui \
diff --git a/src/qtui/titlesetter.cpp b/src/qtui/titlesetter.cpp
new file mode 100644 (file)
index 0000000..f48f000
--- /dev/null
@@ -0,0 +1,49 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   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.             *
+ ***************************************************************************/
+
+#include "titlesetter.h"
+
+#include "abstractitemview.h"
+#include "mainwin.h"
+
+TitleSetter::TitleSetter(MainWin *parent)
+  : AbstractItemView(parent),
+    _mainWin(parent)
+{
+
+}
+
+void TitleSetter::currentChanged(const QModelIndex &current, const QModelIndex &previous) {
+  Q_UNUSED(previous);
+  changeWindowTitle(current.sibling(current.row(), 0).data().toString());
+}
+
+void TitleSetter::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) {
+  QItemSelectionRange changedArea(topLeft, bottomRight);
+  QModelIndex currentTopicIndex = selectionModel()->currentIndex().sibling(selectionModel()->currentIndex().row(), 0);
+  if(changedArea.contains(currentTopicIndex))
+    changeWindowTitle(currentTopicIndex.data().toString());
+};
+
+void TitleSetter::changeWindowTitle(QString title) {
+  QString newTitle = QString("%1 - %2").arg("Quassel IRC").arg(title);
+  _mainWin->setWindowTitle(newTitle);
+  _mainWin->setWindowIconText(newTitle);
+}
diff --git a/src/qtui/titlesetter.h b/src/qtui/titlesetter.h
new file mode 100644 (file)
index 0000000..5fe1aee
--- /dev/null
@@ -0,0 +1,45 @@
+/***************************************************************************
+ *   Copyright (C) 2005-08 by the Quassel IRC Team                         *
+ *   devel@quassel-irc.org                                                 *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) version 3.                                           *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   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.             *
+ ***************************************************************************/
+
+
+#ifndef TITLESETTER_H
+#define TITLESETTER_H
+
+#include "abstractitemview.h"
+
+class MainWin;
+
+class TitleSetter : public AbstractItemView {
+  Q_OBJECT
+
+  public:
+    TitleSetter(MainWin *parent);
+
+  protected slots:
+    virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+    virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+
+  private:
+    MainWin *_mainWin;
+    void changeWindowTitle(QString title);
+};
+
+
+#endif
index 021ed4a..372684b 100644 (file)
@@ -4,8 +4,8 @@
 { using namespace Global;
 
   quasselVersion = "0.2.0-beta1-pre";
-  quasselDate = "2008-04-18";
-  quasselBuild = 777;
+  quasselDate = "2008-04-21";
+  quasselBuild = 784;
 
   //! Minimum client build number the core needs
   clientBuildNeeded = 731;