From: Manuel Nickschas Date: Tue, 18 Aug 2009 21:19:20 +0000 (+0200) Subject: Add a settingspage for configuring the input widget X-Git-Tag: 0.5-rc1~57 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=d7832127ff8412b09d9fa4e56570d8a890abcbbe Add a settingspage for configuring the input widget Centralize the now-scattered input-line related settings in their own settingspage; also add some new options. --- diff --git a/src/qtui/inputwidget.cpp b/src/qtui/inputwidget.cpp index dc8b6a6a..7534ab69 100644 --- a/src/qtui/inputwidget.cpp +++ b/src/qtui/inputwidget.cpp @@ -56,9 +56,25 @@ InputWidget::InputWidget(QWidget *parent) new TabCompleter(ui.inputEdit); - QtUiStyleSettings s("Fonts"); - s.notify("InputLine", this, SLOT(setCustomFont(QVariant))); - setCustomFont(s.value("InputLine", QFont())); + UiStyleSettings fs("Fonts"); + fs.notify("InputWidget", this, SLOT(setCustomFont(QVariant))); + setCustomFont(fs.value("InputWidget", QFont())); + + UiSettings s("InputWidget"); + +#ifdef HAVE_KDE + s.notify("EnableSpellCheck", this, SLOT(setEnableSpellCheck(QVariant))); + setEnableSpellCheck(s.value("EnableSpellCheck", false)); +#endif + + s.notify("ShowNickSelector", this, SLOT(setShowNickSelector(QVariant))); + setShowNickSelector(s.value("ShowNickSelector", true)); + + s.notify("MaxNumLines", this, SLOT(setMaxLines(QVariant))); + setMaxLines(s.value("MaxNumLines", 5)); + + s.notify("EnableScrollBars", this, SLOT(setEnableScrollBars(QVariant))); + setEnableScrollBars(s.value("EnableScrollBars", true)); ActionCollection *coll = QtUi::actionCollection(); @@ -78,6 +94,22 @@ void InputWidget::setCustomFont(const QVariant &v) { ui.inputEdit->setCustomFont(font); } +void InputWidget::setEnableSpellCheck(const QVariant &v) { + ui.inputEdit->enableSpellCheck(v.toBool()); +} + +void InputWidget::setShowNickSelector(const QVariant &v) { + ui.ownNick->setVisible(v.toBool()); +} + +void InputWidget::setMaxLines(const QVariant &v) { + ui.inputEdit->setMaxHeight(v.toInt()); +} + +void InputWidget::setEnableScrollBars(const QVariant &v) { + ui.inputEdit->enableScrollBars(v.toBool()); +} + bool InputWidget::eventFilter(QObject *watched, QEvent *event) { if(event->type() != QEvent::KeyPress) return false; diff --git a/src/qtui/inputwidget.h b/src/qtui/inputwidget.h index d60ee340..aeb63f8a 100644 --- a/src/qtui/inputwidget.h +++ b/src/qtui/inputwidget.h @@ -53,6 +53,11 @@ protected slots: private slots: void setCustomFont(const QVariant &font); + void setEnableSpellCheck(const QVariant &); + void setShowNickSelector(const QVariant &); + void setMaxLines(const QVariant &); + void setEnableScrollBars(const QVariant &); + void sendText(const QString &text) const; void changeNick(const QString &newNick) const; diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 07d2baeb..b56c7947 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -102,6 +102,7 @@ #include "settingspages/generalsettingspage.h" #include "settingspages/highlightsettingspage.h" #include "settingspages/identitiessettingspage.h" +#include "settingspages/inputwidgetsettingspage.h" #include "settingspages/itemviewsettingspage.h" #include "settingspages/networkssettingspage.h" #include "settingspages/notificationssettingspage.h" @@ -807,10 +808,11 @@ void MainWin::awayLogDestroyed() { void MainWin::showSettingsDlg() { SettingsDlg *dlg = new SettingsDlg(); - //Category: Appearance + //Category: Interface dlg->registerSettingsPage(new AppearanceSettingsPage(dlg)); dlg->registerSettingsPage(new ChatViewSettingsPage(dlg)); dlg->registerSettingsPage(new ItemViewSettingsPage(dlg)); + dlg->registerSettingsPage(new InputWidgetSettingsPage(dlg)); dlg->registerSettingsPage(new HighlightSettingsPage(dlg)); dlg->registerSettingsPage(new NotificationsSettingsPage(dlg)); dlg->registerSettingsPage(new BacklogSettingsPage(dlg)); diff --git a/src/qtui/settingspages/appearancesettingspage.cpp b/src/qtui/settingspages/appearancesettingspage.cpp index ab39344a..228fe403 100644 --- a/src/qtui/settingspages/appearancesettingspage.cpp +++ b/src/qtui/settingspages/appearancesettingspage.cpp @@ -20,23 +20,16 @@ #include "appearancesettingspage.h" -#include "buffersettings.h" -#include "chatviewsettings.h" #include "qtui.h" #include "qtuisettings.h" #include "qtuistyle.h" -#include "util.h" #include -#include #include -#include -#include #include AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) - : SettingsPage(tr("Interface"), QString(), parent), - _fontsChanged(false) + : SettingsPage(tr("Interface"), QString(), parent) { ui.setupUi(this); initAutoWidgets(); @@ -50,13 +43,6 @@ AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent) connect(checkBox, SIGNAL(clicked()), this, SLOT(widgetHasChanged())); } - mapper = new QSignalMapper(this); - connect(mapper, SIGNAL(mapped(QWidget *)), this, SLOT(chooseFont(QWidget *))); - - connect(ui.chooseInputLine, SIGNAL(clicked()), mapper, SLOT(map())); - - mapper->setMapping(ui.chooseInputLine, ui.demoInputLine); - connect(ui.chooseStyleSheet, SIGNAL(clicked()), SLOT(chooseStyleSheet())); } @@ -83,9 +69,6 @@ void AppearanceSettingsPage::initLanguageComboBox() { void AppearanceSettingsPage::defaults() { ui.styleComboBox->setCurrentIndex(0); - loadFonts(Settings::Default); - _fontsChanged = true; - SettingsPage::defaults(); widgetHasChanged(); } @@ -114,23 +97,10 @@ void AppearanceSettingsPage::load() { ui.languageComboBox->setProperty("storedValue", ui.languageComboBox->currentIndex()); Quassel::loadTranslation(selectedLocale()); - loadFonts(Settings::Custom); - SettingsPage::load(); setChangedState(false); } -void AppearanceSettingsPage::loadFonts(Settings::Mode mode) { - QtUiStyleSettings s("Fonts"); - - QFont inputLineFont; - if(mode == Settings::Custom) - inputLineFont = s.value("InputLine", QFont()).value(); - setFont(ui.demoInputLine, inputLineFont); - - _fontsChanged = false; -} - void AppearanceSettingsPage::save() { QtUiSettings uiSettings; @@ -146,15 +116,6 @@ void AppearanceSettingsPage::save() { uiSettings.setValue("Locale", selectedLocale()); } - // Fonts - QtUiStyleSettings fontSettings("Fonts"); - if(ui.demoInputLine->font() != QApplication::font()) - fontSettings.setValue("InputLine", ui.demoInputLine->font()); - else - fontSettings.setValue("InputLine", ""); - - _fontsChanged = false; - bool needsStyleReload = ui.useCustomStyleSheet->isChecked() != ui.useCustomStyleSheet->property("storedValue").toBool() || (ui.useCustomStyleSheet->isChecked() && ui.customStyleSheetPath->text() != ui.customStyleSheetPath->property("storedValue").toString()); @@ -178,26 +139,6 @@ QLocale AppearanceSettingsPage::selectedLocale() const { return locale; } -void AppearanceSettingsPage::setFont(QLabel *label, const QFont &font_) { - QFont font = font_; - if(font.family().isEmpty()) - font = QApplication::font(); - label->setFont(font); - label->setText(QString("%1 %2").arg(font.family()).arg(font.pointSize())); - widgetHasChanged(); -} - -void AppearanceSettingsPage::chooseFont(QWidget *widget) { - QLabel *label = qobject_cast(widget); - Q_ASSERT(label); - bool ok; - QFont font = QFontDialog::getFont(&ok, label->font()); - if(ok) { - _fontsChanged = true; - setFont(label, font); - } -} - void AppearanceSettingsPage::chooseStyleSheet() { QString name = QFileDialog::getOpenFileName(this, tr("Please choose a stylesheet file"), QString(), "*.qss"); if(!name.isEmpty()) @@ -209,8 +150,6 @@ void AppearanceSettingsPage::widgetHasChanged() { } bool AppearanceSettingsPage::testHasChanged() { - if(_fontsChanged) return true; // comparisons are nasty for now - if(ui.styleComboBox->currentIndex() != ui.styleComboBox->property("storedValue").toInt()) return true; if(selectedLocale() != QLocale()) return true; // QLocale() returns the default locale (manipulated via loadTranslation()) diff --git a/src/qtui/settingspages/appearancesettingspage.h b/src/qtui/settingspages/appearancesettingspage.h index 302d78bd..a6fffa2f 100644 --- a/src/qtui/settingspages/appearancesettingspage.h +++ b/src/qtui/settingspages/appearancesettingspage.h @@ -30,8 +30,6 @@ #include "settingspage.h" #include "ui_appearancesettingspage.h" -class QSignalMapper; - class AppearanceSettingsPage : public SettingsPage { Q_OBJECT @@ -48,10 +46,6 @@ public slots: private slots: void widgetHasChanged(); - void loadFonts(Settings::Mode mode); - void setFont(QLabel *label, const QFont &font); - void chooseFont(QWidget *label); - void chooseStyleSheet(); private: @@ -59,13 +53,10 @@ private: void initStyleComboBox(); void initLanguageComboBox(); QLocale selectedLocale() const; - void clearFontFromFormat(QTextCharFormat &fmt); Ui::AppearanceSettingsPage ui; QHash settings; QList _locales; - QSignalMapper *mapper; - bool _fontsChanged; }; #endif diff --git a/src/qtui/settingspages/appearancesettingspage.ui b/src/qtui/settingspages/appearancesettingspage.ui index 9c484191..2bc0409c 100644 --- a/src/qtui/settingspages/appearancesettingspage.ui +++ b/src/qtui/settingspages/appearancesettingspage.ui @@ -114,66 +114,6 @@ - - - - true - - - Fonts - - - - - - Set font for the input line - - - Input line: - - - - - - - - 0 - 0 - - - - Set font for the input line - - - QFrame::StyledPanel - - - QFrame::Sunken - - - Font - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Choose... - - - - - - diff --git a/src/qtui/settingspages/generalsettingspage.cpp b/src/qtui/settingspages/generalsettingspage.cpp index 9888235d..a16e1b69 100644 --- a/src/qtui/settingspages/generalsettingspage.cpp +++ b/src/qtui/settingspages/generalsettingspage.cpp @@ -49,8 +49,6 @@ GeneralSettingsPage::GeneralSettingsPage(QWidget *parent) connect(ui.errorMsgsInDefaultBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.errorMsgsInStatusBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); connect(ui.errorMsgsInCurrentBuffer, SIGNAL(clicked(bool)), this, SLOT(widgetHasChanged())); - - connect(ui.completionSuffix, SIGNAL(textEdited(const QString&)), this, SLOT(widgetHasChanged())); } bool GeneralSettingsPage::hasDefaults() const { @@ -74,8 +72,6 @@ void GeneralSettingsPage::defaults() { ui.errorMsgsInStatusBuffer->setChecked(false); ui.errorMsgsInCurrentBuffer->setChecked(false); - ui.completionSuffix->setText(": "); - widgetHasChanged(); } @@ -107,11 +103,6 @@ void GeneralSettingsPage::load() { SettingsPage::load(ui.errorMsgsInStatusBuffer, redirectTarget & BufferSettings::StatusBuffer); SettingsPage::load(ui.errorMsgsInCurrentBuffer, redirectTarget & BufferSettings::CurrentBuffer); - // completion settings - TabCompletionSettings completionSettings; - settings["CompletionSuffix"] = completionSettings.completionSuffix(); - ui.completionSuffix->setText(settings["CompletionSuffix"].toString()); - setChangedState(false); } @@ -152,10 +143,6 @@ void GeneralSettingsPage::save() { redirectTarget |= BufferSettings::CurrentBuffer; bufferSettings.setErrorMsgsTarget(redirectTarget); - TabCompletionSettings completionSettings; - completionSettings.setCompletionSuffix(ui.completionSuffix->text()); - - load(); setChangedState(false); } @@ -185,7 +172,5 @@ bool GeneralSettingsPage::testHasChanged() { if(SettingsPage::hasChanged(ui.errorMsgsInDefaultBuffer)) return true; if(SettingsPage::hasChanged(ui.errorMsgsInCurrentBuffer)) return true; - if(settings["CompletionSuffix"].toString() != ui.completionSuffix->text()) return true; - return false; } diff --git a/src/qtui/settingspages/generalsettingspage.ui b/src/qtui/settingspages/generalsettingspage.ui index cca69d40..45103dcd 100644 --- a/src/qtui/settingspages/generalsettingspage.ui +++ b/src/qtui/settingspages/generalsettingspage.ui @@ -187,55 +187,6 @@ - - - - The suffix appended to a nick on completion via TAB. Default is ": " - - - Input Line - - - - - - - - Completion suffix: - - - - - - - - 0 - 0 - - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 157 - 27 - - - - - - - - - diff --git a/src/qtui/settingspages/inputwidgetsettingspage.cpp b/src/qtui/settingspages/inputwidgetsettingspage.cpp new file mode 100644 index 00000000..02f4c250 --- /dev/null +++ b/src/qtui/settingspages/inputwidgetsettingspage.cpp @@ -0,0 +1,32 @@ +/*************************************************************************** + * 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 "inputwidgetsettingspage.h" + +InputWidgetSettingsPage::InputWidgetSettingsPage(QWidget *parent) + : SettingsPage(tr("Interface"), tr("Input Widget"), parent) +{ + ui.setupUi(this); + +#ifndef HAVE_KDE + ui.enableSpellCheck->hide(); +#endif + + initAutoWidgets(); +} diff --git a/src/qtui/settingspages/inputwidgetsettingspage.h b/src/qtui/settingspages/inputwidgetsettingspage.h new file mode 100644 index 00000000..a42a591e --- /dev/null +++ b/src/qtui/settingspages/inputwidgetsettingspage.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 INPUTLINESETTINGSPAGE_H_ +#define INPUTLINESETTINGSPAGE_H_ + +#include "settingspage.h" +#include "ui_inputwidgetsettingspage.h" + +class InputWidgetSettingsPage : public SettingsPage { + Q_OBJECT + +public: + InputWidgetSettingsPage(QWidget *parent = 0); + + inline bool hasDefaults() const { return true; } + +private: + Ui::InputWidgetSettingsPage ui; + + inline QString settingsKey() const { return QString("InputWidget"); } +}; + +#endif diff --git a/src/qtui/settingspages/inputwidgetsettingspage.ui b/src/qtui/settingspages/inputwidgetsettingspage.ui new file mode 100644 index 00000000..92aea269 --- /dev/null +++ b/src/qtui/settingspages/inputwidgetsettingspage.ui @@ -0,0 +1,253 @@ + + + InputWidgetSettingsPage + + + + 0 + 0 + 507 + 514 + + + + Form + + + + + + + + Custom font: + + + /UiStyle/Fonts/UseCustomInputWidgetFont + + + false + + + + + + + false + + + /UiStyle/Fonts/InputWidget + + + + + + + + + + + + Enable spell check + + + EnableSpellCheck + + + false + + + + + + + Show nick selector + + + true + + + ShowNickSelector + + + true + + + + + + + Multi-Line Editing + + + + + + + + Show at most + + + + + + + 1 + + + 19 + + + 5 + + + MaxNumLines + + + 5 + + + + + + + lines + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Enable scrollbars + + + true + + + EnableScrollBars + + + true + + + + + + + + + + Tab Completion + + + + + + + + Completion suffix: + + + + + + + + 0 + 0 + + + + /TabCompletion/CompletionSuffix + + + : + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 157 + 27 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 233 + + + + + + + + + FontSelector + QWidget +
fontselector.h
+ 1 +
+
+ + customFont + enableSpellCheck + showNickSelector + maxNumLines + enableScrollBars + completionSuffix + + + + + customFont + toggled(bool) + inputLineFont + setEnabled(bool) + + + 165 + 18 + + + 305 + 17 + + + + +
diff --git a/src/qtui/settingspages/itemviewsettingspage.h b/src/qtui/settingspages/itemviewsettingspage.h index 4b184c40..0eed0a9e 100644 --- a/src/qtui/settingspages/itemviewsettingspage.h +++ b/src/qtui/settingspages/itemviewsettingspage.h @@ -48,7 +48,7 @@ private: QTreeWidgetItem *_networkItem, *_defaultBufferItem, *_inactiveBufferItem, *_activeBufferItem, *_unreadBufferItem, *_highlightedBufferItem; - inline QString settingsKey() const { return QString("ItemViews"); } + inline QString settingsKey() const { return QString("InputLine"); } }; #endif diff --git a/src/qtui/settingspages/settingspages.inc b/src/qtui/settingspages/settingspages.inc index 3e0fb19c..66ca1f21 100644 --- a/src/qtui/settingspages/settingspages.inc +++ b/src/qtui/settingspages/settingspages.inc @@ -1,7 +1,7 @@ # 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 itemview networks) +set(SETTINGSPAGES aliases appearance backlog bufferview chatview connection chatmonitor general highlight identities inputwidget itemview networks) # Specify additional files (e.g. for subdialogs) here! set(SP_SOURCES aliasesmodel.cpp identityeditwidget.cpp notificationssettingspage.cpp) diff --git a/src/uisupport/multilineedit.cpp b/src/uisupport/multilineedit.cpp index 77e2cc6c..a79ef28d 100644 --- a/src/uisupport/multilineedit.cpp +++ b/src/uisupport/multilineedit.cpp @@ -151,6 +151,14 @@ QSize MultiLineEdit::minimumSizeHint() const { return sizeHint(); } +void MultiLineEdit::enableSpellCheck(bool enable) { +#ifdef HAVE_KDE + setCheckSpellingEnabled(enable); +#else + Q_UNUSED(enable) +#endif +} + void MultiLineEdit::historyMoveBack() { addToHistory(text(), true); diff --git a/src/uisupport/multilineedit.h b/src/uisupport/multilineedit.h index 4a578fa6..67264dda 100644 --- a/src/uisupport/multilineedit.h +++ b/src/uisupport/multilineedit.h @@ -68,6 +68,7 @@ public slots: void setMinHeight(int numLines); void setMaxHeight(int numLines); void enableScrollBars(bool enable = true); + void enableSpellCheck(bool enable = true); signals: void textEntered(const QString &text);