1 /***************************************************************************
2 * Copyright (C) 2005-2020 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"
23 #include "chatviewsettings.h"
26 #include "qtuistyle.h"
29 ChatViewSettingsPage::ChatViewSettingsPage(QWidget* parent)
30 : SettingsPage(tr("Interface"), tr("Chat View"), parent)
34 #if !defined HAVE_WEBKIT && !defined HAVE_WEBENGINE
35 ui.showWebPreview->hide();
36 ui.showWebPreview->setEnabled(false);
39 // Handle UI dependent on core feature flags here
40 // FIXME remove with protocol v11
41 if (!Client::isCoreFeatureEnabled(Quassel::Feature::SynchronizedMarkerLine)) {
42 ui.autoMarkerLine->setEnabled(false);
43 ui.autoMarkerLine->setChecked(true);
44 ui.autoMarkerLine->setToolTip(tr("You need at least version 0.6 of Quassel Core to use this feature"));
46 if (!Client::isCoreFeatureEnabled(Quassel::Feature::SenderPrefixes)) {
47 // Sender prefixes are not supported, disallow toggling
48 ui.senderPrefixComboBox->setEnabled(false);
49 // Split up the message to allow re-using translations:
50 // [Original tool-tip]
51 // [Bold 'does not support feature' message]
52 // [Specific version needed and feature details]
53 ui.senderPrefixComboBox->setToolTip(QString("<b>%2</b><br/>%3")
54 .arg(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();
62 void ChatViewSettingsPage::initSenderPrefixComboBox()
64 // Fill combobox with sender prefix modes
65 // Do not change ComboBox ordering without also adjusting chatviewsettingspage.ui "defaultValue"
66 // and UiStyle::SenderPrefixMode
67 ui.senderPrefixComboBox->addItem(tr("No modes"), static_cast<int>(UiStyle::SenderPrefixMode::NoModes));
68 ui.senderPrefixComboBox->addItem(tr("Highest mode"), static_cast<int>(UiStyle::SenderPrefixMode::HighestMode));
69 ui.senderPrefixComboBox->addItem(tr("All modes"), static_cast<int>(UiStyle::SenderPrefixMode::AllModes));
72 void ChatViewSettingsPage::save()
74 bool needsStyleReload = SettingsPage::hasChanged(ui.customChatViewFont) || SettingsPage::hasChanged(ui.chatViewFont);
76 // Save the general settings
79 // Update the stylesheet if fonts are changed
80 if (needsStyleReload) {
81 QtUi::style()->generateSettingsQss();
82 QtUi::style()->reload();