Mercurial > octave
annotate libgui/graphics/annotation-dialog.cc @ 30398:d4d83344d653 stable
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
* ButtonGroup.cc, Canvas.cc, CheckBoxControl.cc, Container.cc,
ContextMenu.cc, EditControl.cc, Figure.cc, Figure.h, FigureWindow.cc,
GenericEventNotify.h, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Menu.cc,
Object.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc, PushTool.cc,
RadioButtonControl.cc, SliderControl.cc, Table.cc, Table.h, TextControl.cc,
ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, annotation-dialog.cc,
qt-graphics-toolkit.cc, documentation-bookmarks.cc, documentation-bookmarks.h,
documentation-dock-widget.h, documentation.cc, documentation.h,
dw-main-window.h, files-dock-widget.cc, files-dock-widget.h,
find-files-dialog.cc, find-files-model.cc, gui-preferences-dw.h,
gui-preferences-ed.h, gui-preferences-global.h, gui-settings.h,
interpreter-qobject.cc, led-indicator.cc, file-editor-interface.h,
file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h,
find-dialog.cc, find-dialog.h, marker.cc, octave-qscintilla.cc,
octave-qscintilla.h, main-window.cc, main-window.h, octave-dock-widget.cc,
octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, octave-qtutils.h,
qt-interpreter-events.cc, release-notes.cc, resource-manager.cc,
set-path-dialog.cc, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc,
shortcut-manager.h, tab-bar.cc, tab-bar.h, variable-editor-model.cc,
variable-editor-model.h, variable-editor.cc, variable-editor.h,
workspace-model.cc, workspace-view.cc, mkoctfile.in.cc, octave-config.in.cc:
Style check C++ files in src/ and libgui/ ahead of 7.1 release.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 29 Nov 2021 15:58:51 -0800 |
parents | 6ea4a84df9c7 |
children | 796f54d4ddbf |
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 // |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 // Copyright (C) 2016-2021 The Octave Project Developers |
27923
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 //////////////////////////////////////////////////////////////////////// |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21568
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
27 # include "config.h" |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
28 #endif |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
29 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
30 #include <QColorDialog> |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
31 #include <QPushButton> |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
32 #include <QPalette> |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
33 |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27417
diff
changeset
|
34 #include "gui-settings.h" |
27866
b134fc61d89e
use symbolic constants for prefs of graphics utlilities
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27645
diff
changeset
|
35 #include "gui-preferences-gp.h" |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
36 #include "octave-qobject.h" |
27611
0495b64288f7
use new gui_settings class instead of using QSettings directly
John W. Eaton <jwe@octave.org>
parents:
27417
diff
changeset
|
37 |
27417
f844b1f03dcc
update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
38 #include "QtHandlesUtils.h" |
f844b1f03dcc
update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
39 #include "annotation-dialog.h" |
f844b1f03dcc
update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
40 #include "ui-annotation-dialog.h" |
f844b1f03dcc
update some header file lists in libgui sources
John W. Eaton <jwe@octave.org>
parents:
27276
diff
changeset
|
41 |
29992
6ea4a84df9c7
rename QtHandles namespace to octave
John W. Eaton <jwe@octave.org>
parents:
29542
diff
changeset
|
42 using namespace octave; |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
43 |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
44 annotation_dialog::annotation_dialog (octave::base_qobject& oct_qobj, |
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
45 QWidget *p, const octave_value_list& pr): |
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
46 QDialog (p), m_octave_qobj (oct_qobj), ui (new Ui::annotation_dialog) |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
47 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
48 props = pr; |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
49 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
50 init (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
51 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
52 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
53 void |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
54 annotation_dialog::init () |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
55 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
56 ui->setupUi (this); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
57 |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
58 octave::resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
59 |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
60 octave::gui_settings *settings = rmgr.get_settings (); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
61 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
62 // restore last geometry |
27866
b134fc61d89e
use symbolic constants for prefs of graphics utlilities
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27645
diff
changeset
|
63 if (settings && settings->contains (gp_annotation_geometry.key)) |
b134fc61d89e
use symbolic constants for prefs of graphics utlilities
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27645
diff
changeset
|
64 restoreGeometry (settings->value (gp_annotation_geometry).toByteArray ()); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
65 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
66 // connect signals |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
67 connect (ui->button_box, &QDialogButtonBox::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
68 this, &annotation_dialog::button_clicked); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
69 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
70 connect (ui->edit_string, &QLineEdit::textChanged, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
71 this, &annotation_dialog::edit_string_changed); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
72 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
73 connect (ui->btn_color, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
74 this, &annotation_dialog::prompt_for_color); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
75 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
76 connect (ui->btn_background_color, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
77 this, &annotation_dialog::prompt_for_color); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
78 |
29542
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
79 connect (ui->btn_edge_color, &QPushButton::clicked, |
3d34b70b5a49
connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
80 this, &annotation_dialog::prompt_for_color); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
81 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
82 // set gui element to default values |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
83 ui->cb_fit_box_to_text->setChecked (true); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
84 ui->cb_horz_align->setCurrentIndex (ui->cb_horz_align->findText ("left")); |
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
85 ui->cb_vert_align->setCurrentIndex (ui->cb_vert_align->findText ("middle")); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
86 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
87 // set gui elements to any values from input properties |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
88 set_gui_props (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
89 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
90 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
91 annotation_dialog::~annotation_dialog () |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
92 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
93 delete ui; |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
94 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
95 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
96 // internal slots |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
97 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
98 void |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
99 annotation_dialog::button_clicked (QAbstractButton *button) |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
100 { |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
101 QDialogButtonBox::ButtonRole button_role |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
102 = ui->button_box->buttonRole (button); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
103 |
27645
028205a91a07
eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents:
27620
diff
changeset
|
104 octave::resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
27620
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
105 |
45bb5bbaf291
don't use singleton pattern for resource manager in GUI
John W. Eaton <jwe@octave.org>
parents:
27611
diff
changeset
|
106 octave::gui_settings *settings = rmgr.get_settings (); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
107 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
108 // save position |
20246
6fe746def1aa
Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
20181
diff
changeset
|
109 if (settings) |
27866
b134fc61d89e
use symbolic constants for prefs of graphics utlilities
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27645
diff
changeset
|
110 settings->setValue (gp_annotation_geometry.key, saveGeometry ()); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
111 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
112 if (button_role == QDialogButtonBox::ApplyRole |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
113 || button_role == QDialogButtonBox::AcceptRole) |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
114 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
115 get_gui_props (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
116 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
117 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
118 if (button_role == QDialogButtonBox::RejectRole |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
119 || button_role == QDialogButtonBox::AcceptRole) |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
120 close (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
121 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
122 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
123 octave_value_list |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
124 annotation_dialog::get_properties () const |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
125 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
126 return props; |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
127 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
128 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
129 void |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
130 annotation_dialog::get_gui_props () |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
131 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
132 // set props to the values of the gui |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
133 props = octave_value_list (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
134 |
30398
d4d83344d653
maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
29992
diff
changeset
|
135 Matrix position(1, 4); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
136 position(0) = ui->sb_x->value (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
137 position(1) = ui->sb_y->value (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
138 position(2) = ui->sb_width->value (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
139 position(3) = ui->sb_height->value (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
140 props.append (ovl ("textbox", position)); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20109
diff
changeset
|
141 |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
142 props.append (ovl ("string", ui->edit_string->text ().toStdString ())); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
143 props.append (ovl ("fitboxtotext", |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
144 ui->cb_fit_box_to_text->isChecked () ? "on" : "off")); |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
145 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
146 // FIXME: only "normalized" units is selectable, change the code below |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
147 // once more units are added in the UI. |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
148 std::string tmpstr; |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
149 props.append (ovl ("units", "normalized")); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
150 |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
151 tmpstr = (ui->cb_horz_align->currentIndex () == 0 ? "left" : |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
152 (ui->cb_horz_align->currentIndex () == 1 ? "center" : "right")); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
153 props.append (ovl ("horizontalalignment", tmpstr)); |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
154 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
155 tmpstr = (ui->cb_vert_align->currentIndex () == 0 ? "top" : |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
156 (ui->cb_horz_align->currentIndex () == 1 ? "middle" : "bottom")); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
157 props.append (ovl ("verticalalignment", tmpstr)); |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
158 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
159 tmpstr = ui->cb_font_name->currentText ().toStdString (); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
160 props.append (ovl ("fontname", tmpstr)); |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
161 |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
162 props.append (ovl ("fontsize", ui->sb_font_size->value ())); |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
163 props.append (ovl ("fontweight", |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
164 ui->cb_font_bold->isChecked () ? "bold" : "normal")); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
165 props.append (ovl ("fontangle", |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
166 ui->cb_font_italic->isChecked () ? "italic" : "normal")); |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
167 props.append (ovl ("color", Utils::toRgb (ui->btn_color->palette (). |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
168 color (QPalette::Button)))); |
22399
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
169 |
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
170 // FIXME: only "none" linestyle is selectable, change the code bellow |
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
171 // once more linestyles are added in the UI. |
f0836b5ec628
Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
22323
diff
changeset
|
172 props.append (ovl ("linestyle", "none")); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
173 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
174 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
175 void |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
176 annotation_dialog::set_gui_props () |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
177 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
178 // set the gui to the values from the props |
21568
3d60ed163b70
maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents:
21301
diff
changeset
|
179 octave_idx_type len = props.length (); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
180 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
181 for (int i=0; i<len/2; i++) |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
182 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
183 std::string name = props(i*2).string_value (); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
184 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
185 if (name == "textbox") |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
186 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
187 Matrix position = props(2*i +1).matrix_value (); |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
188 int nels = position.numel (); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
189 if (nels >= 2) |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
190 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
191 ui->sb_x->setValue (position(0)); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
192 ui->sb_y->setValue (position(1)); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
193 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
194 else |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
195 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
196 ui->sb_x->setValue (0); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
197 ui->sb_y->setValue (0); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
198 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
199 if (nels >= 4) |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
200 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
201 ui->sb_width->setValue (position(2)); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
202 ui->sb_height->setValue (position(3)); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
203 } |
26390
aabee709c13a
annotation-dialog.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
204 // FIXME: Should there be an else branch here? |
aabee709c13a
annotation-dialog.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
205 // In annotation.m "textbox" is forced to have a 4-elem vector. |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
206 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
207 else if (name == "string") |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
208 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
209 // FIXME: handle if is array of strings ? |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20109
diff
changeset
|
210 ui->edit_string->setText (props(2*i +1).string_value ().c_str ()); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
211 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
212 else if (name == "fitboxtotext") |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
213 { |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
214 ui->cb_fit_box_to_text->setChecked (props(1*i +1).string_value () == "on"); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
215 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
216 else if (name == "units") |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20109
diff
changeset
|
217 { |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
218 ui->cb_units->setCurrentIndex |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
219 (ui->cb_units->findText (props(1*i +1).string_value ().c_str ())); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
220 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
221 else if (name == "horizontalalignment") |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
222 { |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
223 ui->cb_horz_align->setCurrentIndex |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
224 (ui->cb_horz_align->findText (props(1*i +1).string_value ().c_str ())); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
225 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
226 else if (name == "verticalalignment") |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
227 { |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
228 ui->cb_vert_align->setCurrentIndex |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
229 (ui->cb_vert_align->findText (props(1*i +1).string_value ().c_str ())); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
230 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
231 else if (name == "fontname") |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
232 { |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
233 ui->cb_vert_align->setCurrentIndex |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
26390
diff
changeset
|
234 (ui->cb_font_name->findText (props(1*i +1).string_value ().c_str ())); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
235 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
236 else if (name == "fontsize") |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
237 { |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
238 ui->sb_font_size->setValue (props(1*i +1).float_value ()); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
239 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
240 else if (name == "fontweight") |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
241 { |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
242 ui->cb_font_bold->setChecked (props(1*i +1).string_value () == "bold"); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
243 } |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
244 else if (name == "fontangle") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
245 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
246 ui->cb_font_italic->setChecked (props(1*i +1).string_value () == "italic"); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
247 } |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
248 else if (name == "color") |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
249 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
250 QColor color; |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
251 if (props(1*i +1).is_matrix_type ()) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
252 color = Utils::fromRgb (props(2*i +1).matrix_value ()); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
253 else |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
254 color.setNamedColor (props(2*i +1).string_value ().c_str ()); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
255 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
256 if (color.isValid ()) |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
257 ui->btn_color->setPalette (QPalette (color)); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
258 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
259 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
260 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
261 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
262 edit_string_changed (ui->edit_string->text ()); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
263 } |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20109
diff
changeset
|
264 |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
265 void |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
266 annotation_dialog::edit_string_changed (const QString& str) |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
267 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
268 ui->button_box->button (QDialogButtonBox::Ok)->setEnabled (str.length () > 0); |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
269 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
270 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
271 void |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
272 annotation_dialog::prompt_for_color () |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
273 { |
23447
db1fdf4384dd
maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
274 QWidget *widg = dynamic_cast<QWidget *> (sender ()); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
275 if (widg) |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
276 { |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
277 QColor color = widg->palette ().color (QPalette::Button); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20109
diff
changeset
|
278 |
23070
bef714f45999
maint: Use space after function name/before parenthesis in libgui.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
279 color = QColorDialog::getColor (color, this); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
280 |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
281 if (color.isValid ()) |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
282 { |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
283 widg->setPalette (QPalette (color)); |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
284 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
285 QString css = QString ("background-color: %1; border: 1px solid %2;") |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
286 .arg (color.name ()) |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
287 .arg ("#000000"); |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20109
diff
changeset
|
288 |
22411
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
289 widg->setStyleSheet (css); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
290 widg->update (); |
c69805d1fa64
maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents:
22399
diff
changeset
|
291 } |
20095
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
292 } |
c164cfc24bdd
QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff
changeset
|
293 } |