23 #if defined (HAVE_CONFIG_H) 28 #include "ui-annotation-dialog.h" 34 #include <QColorDialog> 35 #include <QPushButton> 53 QSettings *settings = resource_manager::get_settings ();
57 restoreGeometry (settings->value (
"annotation/geometry").toByteArray ());
60 connect (
ui->button_box, SIGNAL (clicked (QAbstractButton *)),
63 connect (
ui->edit_string, SIGNAL (textChanged (
const QString&)),
66 connect (
ui->btn_color, SIGNAL (clicked ()),
69 connect (
ui->btn_background_color, SIGNAL (clicked ()),
72 connect (
ui->btn_edge_color, SIGNAL (clicked ()),
76 ui->cb_fit_box_to_text->setChecked (
true);
77 ui->cb_horz_align->setCurrentIndex (
ui->cb_horz_align->findText (
"left"));
78 ui->cb_vert_align->setCurrentIndex (
ui->cb_vert_align->findText (
"middle"));
94 QDialogButtonBox::ButtonRole button_role
95 =
ui->button_box->buttonRole (button);
97 QSettings *settings = resource_manager::get_settings ();
101 settings->setValue (
"annotation/geometry",saveGeometry ());
103 if (button_role == QDialogButtonBox::ApplyRole
104 || button_role == QDialogButtonBox::AcceptRole)
109 if (button_role == QDialogButtonBox::RejectRole
110 || button_role == QDialogButtonBox::AcceptRole)
127 position(0) =
ui->sb_x->value ();
128 position(1) =
ui->sb_y->value ();
129 position(2) =
ui->sb_width->value ();
130 position(3) =
ui->sb_height->value ();
135 ui->cb_fit_box_to_text->isChecked () ?
"on" :
"off"));
142 tmpstr = (
ui->cb_horz_align->currentIndex () == 0 ?
"left" :
143 (
ui->cb_horz_align->currentIndex () == 1 ?
"center" :
"right"));
146 tmpstr = (
ui->cb_vert_align->currentIndex () == 0 ?
"top" :
147 (
ui->cb_horz_align->currentIndex () == 1 ?
"middle" :
"bottom"));
150 tmpstr =
ui->cb_font_name->currentText ().toStdString ();
155 ui->cb_font_bold->isChecked () ?
"bold" :
"normal"));
157 ui->cb_font_italic->isChecked () ?
"italic" :
"normal"));
159 color (QPalette::Button))));
172 for (
int i=0;
i<len/2;
i++)
176 if (
name ==
"textbox")
179 int nels = position.
numel ();
182 ui->sb_x->setValue (position(0));
183 ui->sb_y->setValue (position(1));
187 ui->sb_x->setValue (0);
188 ui->sb_y->setValue (0);
192 ui->sb_width->setValue (position(2));
193 ui->sb_height->setValue (position(3));
197 ui->sb_width->setValue (position(2));
198 ui->sb_height->setValue (position(3));
201 else if (
name ==
"string")
204 ui->edit_string->setText (
props(2*
i +1).string_value ().c_str ());
206 else if (
name ==
"fitboxtotext")
208 ui->cb_fit_box_to_text->setChecked (
props(1*
i +1).string_value () ==
"on");
210 else if (
name ==
"units")
212 ui->cb_units->setCurrentIndex (
ui->cb_units->findText (
props(
213 1*
i +1).string_value ().c_str ()));
215 else if (
name ==
"horizontalalignment")
217 ui->cb_horz_align->setCurrentIndex (
ui->cb_horz_align->findText (
props(
218 1*
i +1).string_value ().c_str ()));
220 else if (
name ==
"verticalalignment")
222 ui->cb_vert_align->setCurrentIndex (
ui->cb_vert_align->findText (
props(
223 1*
i +1).string_value ().c_str ()));
225 else if (
name ==
"fontname")
227 ui->cb_vert_align->setCurrentIndex (
ui->cb_font_name->findText (
props(
228 1*
i +1).string_value ().c_str ()));
230 else if (
name ==
"fontsize")
232 ui->sb_font_size->setValue (
props(1*
i +1).float_value ());
234 else if (
name ==
"fontweight")
236 ui->cb_font_bold->setChecked (
props(1*
i +1).string_value () ==
"bold");
238 else if (
name ==
"fontangle")
240 ui->cb_font_italic->setChecked (
props(1*
i +1).string_value () ==
"italic");
242 else if (
name ==
"color")
245 if (
props(1*
i +1).is_matrix_type ())
248 color.setNamedColor (
props(2*
i +1).string_value ().c_str ());
250 if (color.isValid ())
251 ui->btn_color->setPalette (QPalette (color));
262 ui->button_box->button (QDialogButtonBox::Ok)->setEnabled (
str.length () > 0);
271 QColor color = widg->palette ().color (QPalette::Button);
273 color = QColorDialog::getColor (color,
this);
275 if (color.isValid ())
277 widg->setPalette (QPalette (color));
279 QString css = QString (
"background-color: %1; border: 1px solid %2;")
283 widg->setStyleSheet (css);
void edit_string_changed(const QString &str)
octave_value_list get_properties() const
octave_value_list & append(const octave_value &val)
void button_clicked(QAbstractButton *button)
QColor fromRgb(const Matrix &rgb)
nd deftypefn *std::string name
Matrix toRgb(const QColor &c)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
octave_idx_type length(void) const
Ui::annotation_dialog * ui
octave_idx_type numel(void) const
Number of elements in the array.
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
annotation_dialog(QWidget *parent, const octave_value_list &pr)