1 /***************************************************************************
2 * Copyright (C) 2005-2018 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "chatviewsettingspage.h"
22 #include "chatviewsettings.h"
25 #include "qtuistyle.h"
28 ChatViewSettingsPage::ChatViewSettingsPage(QWidget *parent)
29 : SettingsPage(tr("Interface"), tr("Chat View"), parent)
33 #if !defined HAVE_WEBKIT && !defined HAVE_WEBENGINE
34 ui.showWebPreview->hide();
35 ui.showWebPreview->setEnabled(false);
38 // Handle UI dependent on core feature flags here
39 // FIXME remove with protocol v11
40 if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) {
41 ui.autoMarkerLine->setEnabled(false);
42 ui.autoMarkerLine->setChecked(true);
43 ui.autoMarkerLine->setToolTip(tr("You need at least version 0.6 of Quassel Core to use this feature"));
45 if (!Client::isCoreFeatureEnabled(Quassel::Feature::SenderPrefixes)) {
46 // Sender prefixes are not supported, disallow toggling
47 ui.senderPrefixComboBox->setEnabled(false);
48 // Split up the message to allow re-using translations:
49 // [Original tool-tip]
50 // [Bold 'does not support feature' message]
51 // [Specific version needed and feature details]
52 ui.senderPrefixComboBox->setToolTip(
53 QString("<b>%2</b><br/>%3").arg(
54 tr("Your Quassel core does not support this feature"),
55 tr("You need a Quassel core v0.13.0 or newer in order to show sender "
56 "modes before nicknames.")));
59 initSenderPrefixComboBox();
63 void ChatViewSettingsPage::initSenderPrefixComboBox()
65 // Fill combobox with sender prefix modes
66 // Do not change ComboBox ordering without also adjusting chatviewsettingspage.ui "defaultValue"
67 // and UiStyle::SenderPrefixMode
68 ui.senderPrefixComboBox->addItem(tr("No modes"),
69 static_cast<int>(UiStyle::SenderPrefixMode::NoModes));
70 ui.senderPrefixComboBox->addItem(tr("Highest mode"),
71 static_cast<int>(UiStyle::SenderPrefixMode::HighestMode));
72 ui.senderPrefixComboBox->addItem(tr("All modes"),
73 static_cast<int>(UiStyle::SenderPrefixMode::AllModes));
77 void ChatViewSettingsPage::save()
79 bool needsStyleReload = SettingsPage::hasChanged(ui.customChatViewFont)
80 || SettingsPage::hasChanged(ui.chatViewFont);
82 // Save the general settings
85 // Update the stylesheet if fonts are changed
86 if (needsStyleReload) {
87 QtUi::style()->generateSettingsQss();
88 QtUi::style()->reload();