Adds a new settingspage "Interface -> Topic Widget" to configure the topicline.
By default, now the whole topic is shown whilst the mouse hovers over the topic widget.
#include "settingspages/itemviewsettingspage.h"
#include "settingspages/networkssettingspage.h"
#include "settingspages/notificationssettingspage.h"
+#include "settingspages/topicwidgetsettingspage.h"
MainWin::MainWin(QWidget *parent)
#ifdef HAVE_KDE
dlg->registerSettingsPage(new ChatViewSettingsPage(dlg));
dlg->registerSettingsPage(new ItemViewSettingsPage(dlg));
dlg->registerSettingsPage(new InputWidgetSettingsPage(dlg));
+ dlg->registerSettingsPage(new TopicWidgetSettingsPage(dlg));
dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
# Putting $FOO in SETTINGSPAGES automatically includes
# $FOOsettingspage.cpp, $FOOsettingspage.h and $FOOsettingspage.ui
-set(SETTINGSPAGES aliases appearance backlog bufferview chatview connection chatmonitor general highlight identities ignorelist inputwidget itemview networks)
+set(SETTINGSPAGES aliases appearance backlog bufferview chatview connection chatmonitor general
+ highlight identities ignorelist inputwidget itemview networks topicwidget)
# Specify additional files (e.g. for subdialogs) here!
set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp ignorelistmodel.cpp notificationssettingspage.cpp)
set(SP_HEADERS aliasesmodel.h identityeditwidget.h ignorelistmodel.h notificationssettingspage.h previewbufferview.h)
-set(SP_FORMS buffervieweditdlg.ui createidentitydlg.ui identityeditwidget.ui ignorelisteditdlg.ui saveidentitiesdlg.ui networkadddlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui)
+set(SP_FORMS buffervieweditdlg.ui createidentitydlg.ui identityeditwidget.ui ignorelisteditdlg.ui saveidentitiesdlg.ui
+ networkadddlg.ui networkeditdlg.ui nickeditdlg.ui servereditdlg.ui)
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * 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 "topicwidgetsettingspage.h"
+
+TopicWidgetSettingsPage::TopicWidgetSettingsPage(QWidget *parent)
+ : SettingsPage(tr("Interface"), tr("Topic Widget"), parent)
+{
+ ui.setupUi(this);
+
+ initAutoWidgets();
+}
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2005-09 by the Quassel Project *
+ * 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 TOPICWIDGETSETTINGSPAGE_H_
+#define TOPICWIDGETSETTINGSPAGE_H_
+
+#include "settingspage.h"
+#include "ui_topicwidgetsettingspage.h"
+
+class TopicWidgetSettingsPage : public SettingsPage {
+ Q_OBJECT
+
+public:
+ TopicWidgetSettingsPage(QWidget *parent = 0);
+
+ inline bool hasDefaults() const { return true; }
+
+private:
+ Ui::TopicWidgetSettingsPage ui;
+
+ inline QString settingsKey() const { return QString("TopicWidget"); }
+};
+
+#endif
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TopicWidgetSettingsPage</class>
+ <widget class="QWidget" name="TopicWidgetSettingsPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>470</width>
+ <height>370</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QCheckBox" name="customFont">
+ <property name="text">
+ <string>Custom font:</string>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>/UiStyle/Fonts/UseCustomTopicWidgetFont</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="FontSelector" name="topicWidgetFont" native="true">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>/UiStyle/Fonts/TopicWidget</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <font/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="dynamicResize">
+ <property name="text">
+ <string>Resize dynamically to fit contents</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>DynamicResize</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="resizeOnHover">
+ <property name="text">
+ <string>On hover only</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>ResizeOnHover</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>274</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>FontSelector</class>
+ <extends>QWidget</extends>
+ <header>fontselector.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>customFont</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>topicWidgetFont</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>105</x>
+ <y>19</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>242</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>dynamicResize</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>resizeOnHover</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>56</x>
+ <y>46</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>65</x>
+ <y>73</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
#include "client.h"
#include "iconloader.h"
#include "networkmodel.h"
+#include "uisettings.h"
TopicWidget::TopicWidget(QWidget *parent)
: AbstractItemView(parent)
ui.topicLineEdit->installEventFilter(this);
connect(ui.topicLabel, SIGNAL(clickableActivated(Clickable)), SLOT(clickableActivated(Clickable)));
+
+ UiSettings s("TopicWidget");
+ s.notify("DynamicResize", this, SLOT(updateResizeMode()));
+ s.notify("ResizeOnHover", this, SLOT(updateResizeMode()));
+ updateResizeMode();
+
+ UiStyleSettings fs("Fonts");
+ fs.notify("UseCustomTopicWidgetFont", this, SLOT(setUseCustomFont(QVariant)));
+ fs.notify("TopicWidget", this, SLOT(setCustomFont(QVariant)));
+ if(fs.value("UseCustomTopicWidgetFont", false).toBool())
+ setCustomFont(fs.value("TopicWidget", QFont()));
+
}
void TopicWidget::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) {
setTopic(currentTopicIndex.data().toString());
};
+void TopicWidget::setUseCustomFont(const QVariant &v) {
+ if(v.toBool()) {
+ UiStyleSettings fs("Fonts");
+ setCustomFont(fs.value("TopicWidget").value<QFont>());
+ } else
+ setCustomFont(QFont());
+}
+
+void TopicWidget::setCustomFont(const QVariant &v) {
+ UiStyleSettings fs("Fonts");
+ if(!fs.value("UseCustomTopicWidgetFont", false).toBool())
+ return;
+
+ setCustomFont(v.value<QFont>());
+}
+
+void TopicWidget::setCustomFont(const QFont &f) {
+ QFont font = f;
+ if(font.family().isEmpty())
+ font = QApplication::font();
+
+ ui.topicLineEdit->setCustomFont(font);
+ ui.topicLabel->setCustomFont(font);
+}
+
void TopicWidget::setTopic(const QString &newtopic) {
if(_topic == newtopic)
return;
switchPlain();
}
+void TopicWidget::updateResizeMode() {
+ StyledLabel::ResizeMode mode = StyledLabel::NoResize;
+ UiSettings s("TopicWidget");
+ if(s.value("DynamicResize", true).toBool()) {
+ if(s.value("ResizeOnHover", true).toBool())
+ mode = StyledLabel::ResizeOnHover;
+ else
+ mode = StyledLabel::DynamicResize;
+ }
+
+ ui.topicLabel->setResizeMode(mode);
+}
+
void TopicWidget::clickableActivated(const Clickable &click) {
NetworkId networkId = selectionModel()->currentIndex().data(NetworkModel::NetworkIdRole).value<NetworkId>();
click.activate(networkId, _topic);
TopicWidget(QWidget *parent = 0);
void setTopic(const QString &newtopic);
+ void setCustomFont(const QFont &);
virtual bool eventFilter(QObject *obj, QEvent *event);
void switchEditable();
void switchPlain();
void clickableActivated(const Clickable &);
+ void updateResizeMode();
+ void setCustomFont(const QVariant &);
+ void setUseCustomFont(const QVariant &);
private:
Ui::TopicWidget ui;