--- a/utils/confgui.h
+++ b/utils/confgui.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2016 J.F.Dockes
+/* Copyright (C) 2007-2018 J.F.Dockes
* 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
@@ -35,6 +35,15 @@
* is then copied to the actual configuration if the data is accepted, or
* destroyed and recreated as a copy if Cancel is pressed (you have to
* delete/recreate the widgets in this case as the links are no longer valid).
+ *
+ * The set() methods of the link objects are only called if the
+ * current value() differs from the value obtained by get() when the
+ * object was initialized. This can be used to avoid cluttering the
+ * output with values which are unmodified from the defaults.
+ *
+ * The file also defines a multi-tabbed dialog container for the
+ * parameter objects, with simple interface methods to create/add
+ * panels and elements.
*/
#include <string>
@@ -85,11 +94,11 @@
virtual void loadValues() = 0;
};
-/** The top level widget has tabs, each tab/panel has multiple widgets
- * for setting parameter values
- */
class ConfPanelW;
class ConfParamW;
+
+/** The top level widget has tabs, each tab/panel has multiple widgets
+ * for setting parameter values */
class ConfTabsW : public QDialog {
Q_OBJECT;
@@ -98,7 +107,7 @@
enum ParamType {CFPT_BOOL, CFPT_INT, CFPT_STR, CFPT_CSTR, CFPT_FN,
CFPT_STRL, CFPT_DNL, CFPT_CSTRL
- };
+ };
/** Add tab and return its identifier / index */
int addPanel(const QString& title);
@@ -114,8 +123,12 @@
int maxval = 0, const QStringList* sl = 0);
bool enableLink(ConfParamW* boolw, ConfParamW* otherw, bool revert = false);
void endOfList(int tabindex);
+
+ /** Find param widget associated with given variable name */
ConfParamW *findParamW(const QString& varname);
+ void hideButtons();
+
public slots:
void acceptChanges();
void rejectChanges();
@@ -123,21 +136,25 @@
void setCurrentIndex(int);
signals:
+ /** This is emitted when acceptChanges() is called, after the
+ * values have been stored */
void sig_prefsChanged();
private:
- ConfLinkFact *m_makelink;
+ ConfLinkFact *m_makelink{nullptr};
std::vector<ConfPanelW *> m_panels;
// "Foreign" panels
std::vector<ConfPanelWIF *> m_widgets;
// All params
std::vector<ConfParamW *> m_params;
- QTabWidget *tabWidget;
- QDialogButtonBox *buttonBox;
+ QTabWidget *tabWidget{nullptr};
+ QDialogButtonBox *buttonBox{nullptr};
};
/////////////////////////////////////////////////
-// All the rest could be moved to the C++ file ?
+// The rest of the class definitions are only useful if you need to
+// access a specific element for customisation (use findParamW() and a
+// dynamic cast).
/** A panel/tab contains multiple controls for parameters */
class ConfPanelW : public QWidget {
@@ -375,14 +392,17 @@
* <brief>Host MPD runs on.</brief>
* <descr>Defaults to localhost. This can also be specified as -h</descr>
* </var>
+ * mpdhost = default-host
* <var name="mpdport" type="int" values="0 65635 6600">
* <brief>IP port used by MPD</brief>.
* <descr>Can also be specified as -p port. Defaults to the...</descr>
* </var>
+ * mpdport = defport
* <var name="ownqueue" type="bool" values="1">
* <brief>Set if we own the MPD queue.</brief>
* <descr>If this is set (on by default), we own the MPD...</descr>
* </var>
+ * ownqueue =
* </confcomments>
*
* <grouptitle> creates a panel in which the following <var> are set.
@@ -398,7 +418,8 @@
* the documentation and the GUI interface.
*
* @param xml the input xml
- * @param toptxt on output: the top level text. This will be evaluated
+ * @param[output] toptxt the top level XML text (text not inside <var>,
+ * normally commented variable assignments). This will be evaluated
* as a config for default values.
* @lnkf factory to create the objects which link the GUI to the
* storage mechanism.