From: Manuel Nickschas Date: Tue, 8 Sep 2009 21:54:27 +0000 (+0200) Subject: Make topicwidget font and resize behavior configurable X-Git-Tag: 0.5-rc2~81 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=26f4a767b58ebf412d3c7ceb8005abc1ec9ad2bd Make topicwidget font and resize behavior configurable 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. --- diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index d14ebec7..04314688 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -108,6 +108,7 @@ #include "settingspages/itemviewsettingspage.h" #include "settingspages/networkssettingspage.h" #include "settingspages/notificationssettingspage.h" +#include "settingspages/topicwidgetsettingspage.h" MainWin::MainWin(QWidget *parent) #ifdef HAVE_KDE @@ -836,6 +837,7 @@ void MainWin::showSettingsDlg() { 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)); diff --git a/src/qtui/settingspages/settingspages.inc b/src/qtui/settingspages/settingspages.inc index 2f1df1c0..d96bddce 100644 --- a/src/qtui/settingspages/settingspages.inc +++ b/src/qtui/settingspages/settingspages.inc @@ -1,9 +1,11 @@ # 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) diff --git a/src/qtui/settingspages/topicwidgetsettingspage.cpp b/src/qtui/settingspages/topicwidgetsettingspage.cpp new file mode 100644 index 00000000..46f40cb9 --- /dev/null +++ b/src/qtui/settingspages/topicwidgetsettingspage.cpp @@ -0,0 +1,28 @@ +/*************************************************************************** + * 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(); +} diff --git a/src/qtui/settingspages/topicwidgetsettingspage.h b/src/qtui/settingspages/topicwidgetsettingspage.h new file mode 100644 index 00000000..adc3ed49 --- /dev/null +++ b/src/qtui/settingspages/topicwidgetsettingspage.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * 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 diff --git a/src/qtui/settingspages/topicwidgetsettingspage.ui b/src/qtui/settingspages/topicwidgetsettingspage.ui new file mode 100644 index 00000000..2328fe27 --- /dev/null +++ b/src/qtui/settingspages/topicwidgetsettingspage.ui @@ -0,0 +1,157 @@ + + + TopicWidgetSettingsPage + + + + 0 + 0 + 470 + 370 + + + + Form + + + + + + + + Custom font: + + + /UiStyle/Fonts/UseCustomTopicWidgetFont + + + false + + + + + + + false + + + /UiStyle/Fonts/TopicWidget + + + + + + + + + + + + Resize dynamically to fit contents + + + true + + + DynamicResize + + + true + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + On hover only + + + true + + + ResizeOnHover + + + true + + + + + + + + + Qt::Vertical + + + + 20 + 274 + + + + + + + + + FontSelector + QWidget +
fontselector.h
+ 1 +
+
+ + + + customFont + toggled(bool) + topicWidgetFont + setEnabled(bool) + + + 105 + 19 + + + 242 + 20 + + + + + dynamicResize + toggled(bool) + resizeOnHover + setEnabled(bool) + + + 56 + 46 + + + 65 + 73 + + + + +
diff --git a/src/qtui/topicwidget.cpp b/src/qtui/topicwidget.cpp index 2f8f5fa4..08546471 100644 --- a/src/qtui/topicwidget.cpp +++ b/src/qtui/topicwidget.cpp @@ -23,6 +23,7 @@ #include "client.h" #include "iconloader.h" #include "networkmodel.h" +#include "uisettings.h" TopicWidget::TopicWidget(QWidget *parent) : AbstractItemView(parent) @@ -33,6 +34,18 @@ TopicWidget::TopicWidget(QWidget *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) { @@ -47,6 +60,31 @@ void TopicWidget::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot setTopic(currentTopicIndex.data().toString()); }; +void TopicWidget::setUseCustomFont(const QVariant &v) { + if(v.toBool()) { + UiStyleSettings fs("Fonts"); + setCustomFont(fs.value("TopicWidget").value()); + } else + setCustomFont(QFont()); +} + +void TopicWidget::setCustomFont(const QVariant &v) { + UiStyleSettings fs("Fonts"); + if(!fs.value("UseCustomTopicWidgetFont", false).toBool()) + return; + + setCustomFont(v.value()); +} + +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; @@ -57,6 +95,19 @@ void TopicWidget::setTopic(const QString &newtopic) { 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(); click.activate(networkId, _topic); diff --git a/src/qtui/topicwidget.h b/src/qtui/topicwidget.h index 18eae860..29e45c63 100644 --- a/src/qtui/topicwidget.h +++ b/src/qtui/topicwidget.h @@ -32,6 +32,7 @@ public: TopicWidget(QWidget *parent = 0); void setTopic(const QString &newtopic); + void setCustomFont(const QFont &); virtual bool eventFilter(QObject *obj, QEvent *event); @@ -45,6 +46,9 @@ private slots: void switchEditable(); void switchPlain(); void clickableActivated(const Clickable &); + void updateResizeMode(); + void setCustomFont(const QVariant &); + void setUseCustomFont(const QVariant &); private: Ui::TopicWidget ui;