Centralize the now-scattered input-line related settings in their own settingspage;
also add some new options.
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();
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;
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;
#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"
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));
#include "appearancesettingspage.h"
-#include "buffersettings.h"
-#include "chatviewsettings.h"
#include "qtui.h"
#include "qtuisettings.h"
#include "qtuistyle.h"
-#include "util.h"
#include <QCheckBox>
-#include <QDir>
#include <QFileDialog>
-#include <QFontDialog>
-#include <QSignalMapper>
#include <QStyleFactory>
AppearanceSettingsPage::AppearanceSettingsPage(QWidget *parent)
- : SettingsPage(tr("Interface"), QString(), parent),
- _fontsChanged(false)
+ : SettingsPage(tr("Interface"), QString(), parent)
{
ui.setupUi(this);
initAutoWidgets();
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()));
}
void AppearanceSettingsPage::defaults() {
ui.styleComboBox->setCurrentIndex(0);
- loadFonts(Settings::Default);
- _fontsChanged = true;
-
SettingsPage::defaults();
widgetHasChanged();
}
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<QFont>();
- setFont(ui.demoInputLine, inputLineFont);
-
- _fontsChanged = false;
-}
-
void AppearanceSettingsPage::save() {
QtUiSettings uiSettings;
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());
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<QLabel *>(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())
}
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())
#include "settingspage.h"
#include "ui_appearancesettingspage.h"
-class QSignalMapper;
-
class AppearanceSettingsPage : public SettingsPage {
Q_OBJECT
private slots:
void widgetHasChanged();
- void loadFonts(Settings::Mode mode);
- void setFont(QLabel *label, const QFont &font);
- void chooseFont(QWidget *label);
-
void chooseStyleSheet();
private:
void initStyleComboBox();
void initLanguageComboBox();
QLocale selectedLocale() const;
- void clearFontFromFormat(QTextCharFormat &fmt);
Ui::AppearanceSettingsPage ui;
QHash<QString, QVariant> settings;
QList<QLocale> _locales;
- QSignalMapper *mapper;
- bool _fontsChanged;
};
#endif
</layout>
</widget>
</item>
- <item>
- <widget class="QGroupBox" name="groupBox_4">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="title">
- <string>Fonts</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="label_3">
- <property name="toolTip">
- <string>Set font for the input line</string>
- </property>
- <property name="text">
- <string>Input line:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="demoInputLine">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip">
- <string>Set font for the input line</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <property name="text">
- <string>Font</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QPushButton" name="chooseInputLine">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Choose...</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
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 {
ui.errorMsgsInStatusBuffer->setChecked(false);
ui.errorMsgsInCurrentBuffer->setChecked(false);
- ui.completionSuffix->setText(": ");
-
widgetHasChanged();
}
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);
}
redirectTarget |= BufferSettings::CurrentBuffer;
bufferSettings.setErrorMsgsTarget(redirectTarget);
- TabCompletionSettings completionSettings;
- completionSettings.setCompletionSuffix(ui.completionSuffix->text());
-
-
load();
setChangedState(false);
}
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;
}
</layout>
</widget>
</item>
- <item>
- <widget class="QGroupBox" name="inputLineGroup">
- <property name="toolTip">
- <string>The suffix appended to a nick on completion via TAB. Default is ": "</string>
- </property>
- <property name="title">
- <string>Input Line</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLabel" name="completionSuffixDesc">
- <property name="text">
- <string>Completion suffix:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="completionSuffix">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>157</width>
- <height>27</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
--- /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 "inputwidgetsettingspage.h"
+
+InputWidgetSettingsPage::InputWidgetSettingsPage(QWidget *parent)
+ : SettingsPage(tr("Interface"), tr("Input Widget"), parent)
+{
+ ui.setupUi(this);
+
+#ifndef HAVE_KDE
+ ui.enableSpellCheck->hide();
+#endif
+
+ 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 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
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>InputWidgetSettingsPage</class>
+ <widget class="QWidget" name="InputWidgetSettingsPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>507</width>
+ <height>514</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <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/UseCustomInputWidgetFont</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="FontSelector" name="inputLineFont" native="true">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>/UiStyle/Fonts/InputWidget</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <font/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="enableSpellCheck">
+ <property name="text">
+ <string>Enable spell check</string>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>EnableSpellCheck</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="showNickSelector">
+ <property name="text">
+ <string>Show nick selector</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>ShowNickSelector</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Multi-Line Editing</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Show at most</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="maxNumLines">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>19</number>
+ </property>
+ <property name="value">
+ <number>5</number>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>MaxNumLines</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>lines</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="enableScrollBars">
+ <property name="text">
+ <string>Enable scrollbars</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>EnableScrollBars</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Tab Completion</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="completionSuffixDesc">
+ <property name="text">
+ <string>Completion suffix:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="completionSuffix">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="settingsKey" stdset="0">
+ <string>/TabCompletion/CompletionSuffix</string>
+ </property>
+ <property name="defaultValue" stdset="0">
+ <string>: </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>157</width>
+ <height>27</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>233</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>FontSelector</class>
+ <extends>QWidget</extends>
+ <header>fontselector.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>customFont</tabstop>
+ <tabstop>enableSpellCheck</tabstop>
+ <tabstop>showNickSelector</tabstop>
+ <tabstop>maxNumLines</tabstop>
+ <tabstop>enableScrollBars</tabstop>
+ <tabstop>completionSuffix</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>customFont</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>inputLineFont</receiver>
+ <slot>setEnabled(bool)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>165</x>
+ <y>18</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>305</x>
+ <y>17</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
QTreeWidgetItem *_networkItem, *_defaultBufferItem, *_inactiveBufferItem,
*_activeBufferItem, *_unreadBufferItem, *_highlightedBufferItem;
- inline QString settingsKey() const { return QString("ItemViews"); }
+ inline QString settingsKey() const { return QString("InputLine"); }
};
#endif
# 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)
return sizeHint();
}
+void MultiLineEdit::enableSpellCheck(bool enable) {
+#ifdef HAVE_KDE
+ setCheckSpellingEnabled(enable);
+#else
+ Q_UNUSED(enable)
+#endif
+}
+
void MultiLineEdit::historyMoveBack() {
addToHistory(text(), true);
void setMinHeight(int numLines);
void setMaxHeight(int numLines);
void enableScrollBars(bool enable = true);
+ void enableSpellCheck(bool enable = true);
signals:
void textEntered(const QString &text);