annotate libgui/src/gui-settings.cc @ 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 0495b64288f7
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 (HAVE_CONFIG_H)
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 # include "config.h"
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25 #endif
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26
27724
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
27 #include <QSettings>
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
28
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include "gui-settings.h"
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 namespace octave
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 {
27724
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
33
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
34 QVariant gui_settings::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: 27611
diff changeset
35 {
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
36 QKeySequence key_seq = QKeySequence ();
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
37
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
38 // Check, which of the elements for the default value in the sc_pref
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
39 // structure has a valid value and take this as default. If both
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
40 // elements are not valid, leave the key sequence empty
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
41 if (pref.def)
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
42 key_seq = QKeySequence (pref.def);
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
43 else if (pref.def_std != QKeySequence::UnknownKey)
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
44 key_seq = QKeySequence (pref.def_std);
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
45
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
46 // Get the value from the settings where the key sequences are stored
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
47 // as strings
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
48 return value (pref.key, key_seq.toString ());
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
49 }
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
50
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 // Additional gui_settings functions will be added later.
27724
19e80f22aa47 provide structure and settings value method for shortcut key sequences
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27611
diff changeset
52
27611
0495b64288f7 use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 }