annotate libgui/src/gui-preferences-ve.h @ 29250:3ad713d82d18

improve saving a variable in the variable editor (bug #59570) * gui-preferences-ve.h: define lists with possible save formats and with a relation between save format and suggested file extension * variable-editor.cc: include builtin-defun-decls.h and ovl.h (variable_editor_stack::save): format string as new argument, test save_default_options if format is empty, moved the saving into do_save; up in several functions/slots (variable_editor_stack::do_save): select suitable file extension for desired save format, perform the saving with Fsave; (variable_editor::edit_variable): remove connection of obsolete signal variable_editor_stack::command_signal, connect interpreter and signals mapper for saving instead; (construct_tool_bar): add button for saving with pull down menu for different formats, creating a signal mapper for the menu actions * variable-editor.h: inlcude qt-interpreter-events.h, (variable_editor_stack): remove command_signal, add slot do_save, add interpreter_event signals, slot save with format as new argument; (variable_editor): new signal mapper *m_save_mapper
author Torsten Lilge <ttl-octave@mailbox.org>
date Sun, 03 Jan 2021 20:19:04 +0100
parents bd51beb6205e
children 7854d5752dd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 2017-2020 The Octave Project Developers
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if ! defined (octave_gui_preferences_ve_h)
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #define octave_gui_preferences_ve_h 1
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include "gui-preferences.h"
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
27662
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
31 #include <QApplication>
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
32
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 // Variable Editor preferences
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 const gui_pref
27662
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
36 ve_use_terminal_font ("variable_editor/use_terminal_font", QVariant (true));
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
37
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
38 const gui_pref
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
39 ve_font_name ("variable_editor/font_name", QVariant ());
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
40
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
41 const gui_pref
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
42 ve_font_size ("variable_editor/font_size", QVariant (10));
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
43
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
44 const gui_pref
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
45 ve_column_width ("variable_editor/column_width", QVariant (100));
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
46
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
47 const gui_pref
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
48 ve_row_height ("variable_editor/row_height", QVariant (10));
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
49
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
50 const gui_pref
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
51 ve_alternate_rows ("variable_editor/alternate_rows", QVariant (false));
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
52
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
53 const int ve_colors_count = 5;
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
54
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
55 const QString ve_color_chars ("fbsha");
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
56
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
57 const gui_pref ve_colors[ve_colors_count] =
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
58 {
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
59 {"variable_editor/color_f", QVariant (QPalette::WindowText)},
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
60 {"variable_editor/color_b", QVariant (QPalette::Base)},
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
61 {"variable_editor/color_s", QVariant (QPalette::HighlightedText)},
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
62 {"variable_editor/color_h", QVariant (QPalette::Highlight)},
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
63 {"variable_editor/color_a", QVariant (QPalette::AlternateBase)}
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
64 };
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
65
3b078b750181 replace preference literals by symbolic constants for variable editor
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27562
diff changeset
66 const QStringList ve_color_names (QStringList ()
27890
5ca326b3c0d5 fix missing translations due to new symbolic constants for prefs (bug #57490)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27662
diff changeset
67 << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Foreground")
5ca326b3c0d5 fix missing translations due to new symbolic constants for prefs (bug #57490)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27662
diff changeset
68 << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Background")
5ca326b3c0d5 fix missing translations due to new symbolic constants for prefs (bug #57490)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27662
diff changeset
69 << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Selected Foreground")
5ca326b3c0d5 fix missing translations due to new symbolic constants for prefs (bug #57490)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27662
diff changeset
70 << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Selected Background")
5ca326b3c0d5 fix missing translations due to new symbolic constants for prefs (bug #57490)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27662
diff changeset
71 << QT_TRANSLATE_NOOP ("octave::settings_dialog", "Alternate Background"));
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
29250
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
73 const QStringList ve_save_formats (QStringList ()
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
74 << "ascii"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
75 << "binary"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
76 << "float-binary"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
77 << "hdf5"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
78 << "float-hdf5"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
79 << "text"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
80 << "mat7-binary"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
81 << "mat-binary"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
82 << "mat4-binary"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
83 << "zip");
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
84
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
85 // The following list is a relation between save format and fiel extension.
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
86 // The format string are case insensitive.
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
87 const QStringList ve_save_formats_ext (QStringList ()
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
88 << "-ascii" << "dat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
89 << "-hdf5" << "h5"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
90 << "-text" << "txt"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
91 << "-v7.3" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
92 << "-7.3" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
93 << "-v7" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
94 << "-7" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
95 << "-mat7-binary" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
96 << "-v6" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
97 << "-6" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
98 << "-mat-binary" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
99 << "-v4" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
100 << "-4" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
101 << "-mat4-binary" << "mat"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
102 << "-binary" << "bin" // after other fmt incl. "-binary"
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
103 << "-z" << "txt.gz" // gzipped -text
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
104 );
3ad713d82d18 improve saving a variable in the variable editor (bug #59570)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27923
diff changeset
105
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 #endif