c3fd8ae5286970f53e3cfff387e9fd513deb0af8
[quassel.git] / src / qtui / settingspages / chatviewsettingspage.cpp
1 /***************************************************************************
2  *   Copyright (C) 2005-2018 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #include "chatviewsettingspage.h"
22 #include "chatviewsettings.h"
23 #include "client.h"
24 #include "qtui.h"
25 #include "qtuistyle.h"
26 #include "uistyle.h"
27
28 ChatViewSettingsPage::ChatViewSettingsPage(QWidget *parent)
29     : SettingsPage(tr("Interface"), tr("Chat View"), parent)
30 {
31     ui.setupUi(this);
32
33 #if !defined HAVE_WEBKIT && !defined HAVE_WEBENGINE
34     ui.showWebPreview->hide();
35     ui.showWebPreview->setEnabled(false);
36 #endif
37
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"));
44     }
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.")));
57     }
58     initAutoWidgets();
59     initSenderPrefixComboBox();
60 }
61
62
63 void ChatViewSettingsPage::initSenderPrefixComboBox()
64 {
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));
74 }
75
76
77 void ChatViewSettingsPage::save()
78 {
79     // Save the general settings
80     SettingsPage::save();
81     // Update the stylesheet in case fonts are changed
82     QtUi::style()->generateSettingsQss();
83     QtUi::style()->reload();
84 }