modernize: Pass arguments by value and move in constructors
[quassel.git] / src / qtui / settingspages / dccsettingspage.h
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 #pragma once
22
23 #include "dccconfig.h"
24 #include "settingspage.h"
25 #include "ui_dccsettingspage.h"
26
27 /**
28  * A settingspage for configuring DCC.
29  */
30 class DccSettingsPage : public SettingsPage
31 {
32     Q_OBJECT
33
34 public:
35     /**
36      * Constructor.
37      *
38      * @param[in] parent QObject parent
39      */
40     DccSettingsPage(QWidget *parent = nullptr);
41
42     /// See base class docs
43     bool hasDefaults() const override;
44
45 public slots:
46     // See base class docs
47     void save() final override;
48     void load() final override;
49     void defaults() final override;
50
51 private:
52     /**
53      * Whether the client's DccConfig is valid
54      *
55      * @returns true if the client is connected and its DccConfig instance synchronized
56      */
57     bool isClientConfigValid() const;
58
59     /**
60      * Set the client config
61      *
62      * @param[in] config The client's config. Must be be valid or a nullptr.
63      */
64     void setClientConfig(DccConfig *config);
65
66     // See base class docs
67     QVariant loadAutoWidgetValue(const QString &widgetName) override;
68     void saveAutoWidgetValue(const QString &widgetName, const QVariant &value) override;
69
70 private slots:
71     /**
72      * Updates the enabled state according to the current config.
73      */
74     void updateWidgetStates();
75
76     /**
77      * Checks if the current unsaved config differs from the client's and sets state accordingly.
78      */
79     void widgetHasChanged();
80
81     /**
82      * Called if the client's config was changed (e.g. if the connection state changed).
83      */
84     void onClientConfigChanged();
85
86 private:
87     Ui::DccSettingsPage ui;              ///< The UI object
88     DccConfig *_clientConfig {nullptr};  ///< Pointer to the client's config (nullptr if not synchronized/available)
89     DccConfig _localConfig;              ///< Local config reflecting the widget states
90 };