annotate libgui/graphics/annotation-dialog.cc @ 22399:f0836b5ec628

Allow translation of all the annotation dialog strings (bug #48940) * annotation-dialog.cc (annotation_dialog::get_gui_props): return the actual english version of the combo box text. * annotation-dialog.cc (annotation_dialog::get_gui_props): wrap code to 80 col. * fr_FR.ts: translate combo box strings
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Mon, 29 Aug 2016 11:25:12 +0200
parents bac0d6f07a3e
children c69805d1fa64
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
1 /*
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
3 Copyright (C) 2016 John Donoghue
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
4
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
5 This file is part of Octave.
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
6
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
10 option) any later version.
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
11
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
15 for more details.
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
16
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
20
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
21 */
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
22
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21568
diff changeset
23 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
24 # include "config.h"
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
25 #endif
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
26
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
27 #include "annotation-dialog.h"
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
28 #include "ui-annotation-dialog.h"
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 "QtHandlesUtils.h"
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
31
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
32 #include "resource-manager.h"
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
33
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
34 #include <QColorDialog>
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
35 #include <QPushButton>
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
36 #include <QPalette>
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
37
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
38 using namespace QtHandles;
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
39
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
40 annotation_dialog::annotation_dialog (QWidget *p, const octave_value_list &pr):
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
41 QDialog (p), ui (new Ui::annotation_dialog)
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
42 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
43 props = pr;
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
44
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
45 init ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
46 }
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 void
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
49 annotation_dialog::init ()
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
50 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
51 ui->setupUi (this);
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 QSettings *settings = resource_manager::get_settings ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
54
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
55 // restore last geometry
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
56 if (settings)
6fe746def1aa Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
57 restoreGeometry (settings->value("annotation/geometry").toByteArray ());
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
58
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
59 // connect signals
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
60 connect (ui->button_box, SIGNAL (clicked (QAbstractButton *)),
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
61 this, SLOT (button_clicked (QAbstractButton *)));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
62
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20109
diff changeset
63 connect (ui->edit_string, SIGNAL (textChanged (const QString&)),
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
64 this, SLOT (edit_string_changed (const QString&)));
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 (ui->btn_color, SIGNAL (clicked ()),
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
67 this, SLOT (prompt_for_color ()));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
68
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
69 connect (ui->btn_background_color, SIGNAL (clicked ()),
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
70 this, SLOT (prompt_for_color ()));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
71
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
72 connect (ui->btn_edge_color, SIGNAL (clicked ()),
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
73 this, SLOT (prompt_for_color ()));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
74
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
75 // set gui element to default values
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
76 ui->cb_fit_box_to_text->setChecked (true);
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
77 ui->cb_horz_align->setCurrentIndex ( ui->cb_horz_align->findText("left") );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
78 ui->cb_vert_align->setCurrentIndex ( ui->cb_vert_align->findText("middle") );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
79
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
80 // set gui elements to any values from input properties
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
81 set_gui_props ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
82 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
83
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
84 annotation_dialog::~annotation_dialog ()
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
85 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
86 delete ui;
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
87 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
88
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
89 // internal slots
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 void
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
92 annotation_dialog::button_clicked (QAbstractButton *button)
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
93 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
94 QDialogButtonBox::ButtonRole button_role = ui->button_box->buttonRole (button);
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 QSettings *settings = resource_manager::get_settings ();
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 // 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
99 if (settings)
6fe746def1aa Also load settings and translations in --no-gui mode (bugs #44222 and #45199)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20181
diff changeset
100 settings->setValue ("annotation/geometry",saveGeometry ());
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
101
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
102 if (button_role == QDialogButtonBox::ApplyRole ||
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
103 button_role == QDialogButtonBox::AcceptRole)
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
104 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
105 get_gui_props ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
106 }
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 if (button_role == QDialogButtonBox::RejectRole ||
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
109 button_role == QDialogButtonBox::AcceptRole)
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
110 close ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
111 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
112
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
113 octave_value_list
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
114 annotation_dialog::get_properties () const
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
115 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
116 return props;
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
117 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
118
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
119 void
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
120 annotation_dialog::get_gui_props ()
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 // set props to the values of the gui
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
123 props = octave_value_list ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
124
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
125 Matrix position(1,4);
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
126 position(0) = ui->sb_x->value ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
127 position(1) = ui->sb_y->value ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
128 position(2) = ui->sb_width->value ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
129 position(3) = ui->sb_height->value ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
130 props.append (ovl ("textbox", position));
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20109
diff changeset
131
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
132 props.append (ovl ("string", ui->edit_string->text ().toStdString ()));
22399
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
133 props.append (ovl ("fitboxtotext", ui->cb_fit_box_to_text->isChecked() ?
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
134 "on" : "off" ));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
135
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
136 // FIXME: only "normalized" units 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
137 // once more units 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
138 std::string tmpval;
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
139 props.append (ovl ("units", "normalized"));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
140
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
141 tmpval = (ui->cb_horz_align->currentIndex () == 0 ? "left" :
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
142 (ui->cb_horz_align->currentIndex () == 1 ? "center" : "right"));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
143 props.append (ovl ("horizontalalignment", tmpval));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
144
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
145 tmpval = (ui->cb_vert_align->currentIndex () == 0 ? "top" :
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
146 (ui->cb_horz_align->currentIndex () == 1 ? "middle" : "bottom"));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
147 props.append (ovl ("verticalalignment", tmpval));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
148
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
149 tmpval = ui->cb_font_name->currentText ().toStdString();
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
150 props.append (ovl ("fontname", tmpval));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
151
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
152 props.append (ovl ("fontsize", ui->sb_font_size->value ()));
22399
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
153 props.append (ovl ("fontweight", ui->cb_font_bold->isChecked() ?
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
154 "bold" : "normal" ));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
155 props.append (ovl ("fontangle", ui->cb_font_italic->isChecked() ?
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
156 "italic" : "normal" ));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
157 props.append (ovl ("color", Utils::toRgb (ui->btn_color->palette ().
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
158 color (QPalette::Button))));
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
159
f0836b5ec628 Allow translation of all the annotation dialog strings (bug #48940)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 22323
diff changeset
160 // 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
161 // 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
162 props.append (ovl ("linestyle", "none"));
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
163 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
164
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
165 void
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
166 annotation_dialog::set_gui_props ()
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
167 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
168 // set the gui to the values from the props
21568
3d60ed163b70 maint: Eliminate bad spacing around '='.
Rik <rik@octave.org>
parents: 21301
diff changeset
169 octave_idx_type len = props.length ();
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
170
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
171 for (int i=0; i<len/2; i++)
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
172 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
173 std::string name = props(i*2).string_value ();
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 if (name == "textbox")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
176 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
177 Matrix position = props(2*i +1).matrix_value ();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
178 int nels = position.numel();
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
179 if (nels >= 2)
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 ui->sb_x->setValue (position(0));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
182 ui->sb_y->setValue (position(1));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
183 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
184 else
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
185 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
186 ui->sb_x->setValue (0);
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
187 ui->sb_y->setValue (0);
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
188 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
189 if (nels >= 4)
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_width->setValue (position(2));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
192 ui->sb_height->setValue (position(3));
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_width->setValue (position(2));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
197 ui->sb_height->setValue (position(3));
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 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
200 else if (name == "string")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
201 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
202 // 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
203 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
204 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
205 else if (name == "fitboxtotext")
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 ui->cb_fit_box_to_text->setChecked ( props(1*i +1).string_value () == "on" );
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 else if (name == "units")
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20109
diff changeset
210 {
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
211 ui->cb_units->setCurrentIndex ( ui->cb_units->findText(props(1*i +1).string_value ().c_str ()) );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
212 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
213 else if (name == "horizontalalignment")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
214 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
215 ui->cb_horz_align->setCurrentIndex ( ui->cb_horz_align->findText(props(1*i +1).string_value ().c_str ()) );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
216 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
217 else if (name == "verticalalignment")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
218 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
219 ui->cb_vert_align->setCurrentIndex ( ui->cb_vert_align->findText(props(1*i +1).string_value ().c_str ()) );
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 == "fontname")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
222 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
223 ui->cb_vert_align->setCurrentIndex ( ui->cb_font_name->findText(props(1*i +1).string_value ().c_str ()) );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
224 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
225 else if (name == "fontsize")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
226 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
227 ui->sb_font_size->setValue ( props(1*i +1).float_value () );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
228 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
229 else if (name == "fontweight")
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 ui->cb_font_bold->setChecked ( props(1*i +1).string_value () == "bold" );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
232 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
233 else if (name == "fontangle")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
234 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
235 ui->cb_font_italic->setChecked ( props(1*i +1).string_value () == "italic" );
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
236 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
237 else if (name == "color")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
238 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
239 QColor color;
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
240 if (props(1*i +1).is_matrix_type ())
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
241 color = Utils::fromRgb (props(2*i +1).matrix_value ());
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
242 else
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
243 color.setNamedColor (props(2*i +1).string_value ().c_str ());
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
244
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
245 if (color.isValid ())
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
246 ui->btn_color->setPalette (QPalette (color));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
247 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
248
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
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
251 edit_string_changed (ui->edit_string->text ());
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
252 }
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20109
diff changeset
253
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
254 void
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
255 annotation_dialog::edit_string_changed (const QString &str)
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
256 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
257 ui->button_box->button (QDialogButtonBox::Ok)->setEnabled (str.length () > 0);
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 void
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
261 annotation_dialog::prompt_for_color ()
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
262 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
263 QWidget *widg = dynamic_cast<QWidget*> (sender ());
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
264 if (widg)
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
265 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
266 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
267
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
268 color = QColorDialog::getColor(color, this);
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 if (color.isValid ())
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
271 {
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
272 widg->setPalette (QPalette (color));
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
273
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
274 QString css = QString ("background-color: %1; border: 1px solid %2;")
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
275 .arg (color.name ())
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
276 .arg ("#000000");
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20109
diff changeset
277
20095
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
278 widg->setStyleSheet (css);
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
279 widg->update ();
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 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
282 }
c164cfc24bdd QtHandles: add annotations dialog
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
283