annotate libgui/src/gui-settings.h @ 27724:19e80f22aa47

provide structure and settings value method for shortcut key sequences * QTerminal.cc (notice_settings): fix comparison of copy shortcut with the interrupt shortcut ctrl+c for dis-/enabling an extra action for the interrupt, more detailed comments on this * gui-preferences-sc.h: use new structure for defining shortcut preferences * gui-preferences.h: define new structure sc_pref for shortcut preferences with key name and default values as unsigned int (combinations of Qt::Key) and as QKeySequence::StandardKey togehter with three constructors for the different ways to initialize the structure * gui-settings.cc (sc_value): new method for reading the value of a key sequence from the preferences file testing the possible given default values with different type * gui-settings.h: new method sc_value
author Torsten Lilge <ttl-octave@mailbox.org>
date Wed, 20 Nov 2019 07:33:24 +0100
parents a36443e94f8a
children fa0582694fda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
3 Copyright (C) 2019 John W. Eaton
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software: you can redistribute it and/or modify it
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 (at your option) any later version.
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 GNU General Public License for more details.
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <https://www.gnu.org/licenses/>.
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #if ! defined (octave_gui_settings_h)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #define octave_gui_settings_h 1
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #include <QSettings>
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
28 #include "gui-preferences.h"
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
29
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 namespace octave
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 {
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 class gui_settings : public QSettings
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 {
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
34 Q_OBJECT
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
35
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 public:
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 gui_settings (const QString& file_name, QSettings::Format format,
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 QObject *parent = nullptr)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 : QSettings (file_name, format, parent)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 { }
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 gui_settings (QSettings::Format format, QSettings::Scope scope,
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 const QString& organization,
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45 const QString& application = QString (),
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 QObject *parent = nullptr)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 : QSettings (format, scope, organization, application, parent)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 { }
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 // No copying!
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 gui_settings (const gui_settings&) = delete;
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 gui_settings& operator = (const gui_settings&) = delete;
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 ~gui_settings (void) = default;
27672
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
57
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
58 using QSettings::value;
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
59
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
60 QVariant value (const gui_pref& pref) const
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
61 {
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
62 return value (pref.key, pref.def);
a36443e94f8a simplify gui_settings->value (PREF.key, PREF.def) calls
John W. Eaton <jwe@octave.org>
parents: 27611
diff changeset
63 }
27724
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27672
diff changeset
64
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27672
diff changeset
65 QVariant sc_value (const sc_pref& pref) const;
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27672
diff changeset
66
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 };
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 }
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 #endif
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71