26 #if defined (HAVE_CONFIG_H)
30 #include <QColorDialog>
31 #include <QPushButton>
40 #include "ui-annotation-dialog.h"
67 connect (
ui->button_box, SIGNAL (clicked (QAbstractButton *)),
70 connect (
ui->edit_string, SIGNAL (textChanged (
const QString&)),
73 connect (
ui->btn_color, SIGNAL (clicked ()),
76 connect (
ui->btn_background_color, SIGNAL (clicked ()),
79 connect (
ui->btn_edge_color, SIGNAL (clicked ()),
83 ui->cb_fit_box_to_text->setChecked (
true);
84 ui->cb_horz_align->setCurrentIndex (
ui->cb_horz_align->findText (
"left"));
85 ui->cb_vert_align->setCurrentIndex (
ui->cb_vert_align->findText (
"middle"));
101 QDialogButtonBox::ButtonRole button_role
102 =
ui->button_box->buttonRole (button);
112 if (button_role == QDialogButtonBox::ApplyRole
113 || button_role == QDialogButtonBox::AcceptRole)
118 if (button_role == QDialogButtonBox::RejectRole
119 || button_role == QDialogButtonBox::AcceptRole)
136 position(0) =
ui->sb_x->value ();
137 position(1) =
ui->sb_y->value ();
138 position(2) =
ui->sb_width->value ();
139 position(3) =
ui->sb_height->value ();
144 ui->cb_fit_box_to_text->isChecked () ?
"on" :
"off"));
151 tmpstr = (
ui->cb_horz_align->currentIndex () == 0 ?
"left" :
152 (
ui->cb_horz_align->currentIndex () == 1 ?
"center" :
"right"));
155 tmpstr = (
ui->cb_vert_align->currentIndex () == 0 ?
"top" :
156 (
ui->cb_horz_align->currentIndex () == 1 ?
"middle" :
"bottom"));
159 tmpstr =
ui->cb_font_name->currentText ().toStdString ();
164 ui->cb_font_bold->isChecked () ?
"bold" :
"normal"));
166 ui->cb_font_italic->isChecked () ?
"italic" :
"normal"));
168 color (QPalette::Button))));
181 for (
int i=0; i<
len/2; i++)
183 std::string
name =
props(i*2).string_value ();
185 if (
name ==
"textbox")
188 int nels = position.
numel ();
191 ui->sb_x->setValue (position(0));
192 ui->sb_y->setValue (position(1));
196 ui->sb_x->setValue (0);
197 ui->sb_y->setValue (0);
201 ui->sb_width->setValue (position(2));
202 ui->sb_height->setValue (position(3));
207 else if (
name ==
"string")
210 ui->edit_string->setText (
props(2*i +1).string_value ().c_str ());
212 else if (
name ==
"fitboxtotext")
214 ui->cb_fit_box_to_text->setChecked (
props(1*i +1).string_value () ==
"on");
216 else if (
name ==
"units")
218 ui->cb_units->setCurrentIndex
219 (
ui->cb_units->findText (
props(1*i +1).string_value ().c_str ()));
221 else if (
name ==
"horizontalalignment")
223 ui->cb_horz_align->setCurrentIndex
224 (
ui->cb_horz_align->findText (
props(1*i +1).string_value ().c_str ()));
226 else if (
name ==
"verticalalignment")
228 ui->cb_vert_align->setCurrentIndex
229 (
ui->cb_vert_align->findText (
props(1*i +1).string_value ().c_str ()));
231 else if (
name ==
"fontname")
233 ui->cb_vert_align->setCurrentIndex
234 (
ui->cb_font_name->findText (
props(1*i +1).string_value ().c_str ()));
236 else if (
name ==
"fontsize")
238 ui->sb_font_size->setValue (
props(1*i +1).float_value ());
240 else if (
name ==
"fontweight")
242 ui->cb_font_bold->setChecked (
props(1*i +1).string_value () ==
"bold");
244 else if (
name ==
"fontangle")
246 ui->cb_font_italic->setChecked (
props(1*i +1).string_value () ==
"italic");
248 else if (
name ==
"color")
251 if (
props(1*i +1).is_matrix_type ())
254 color.setNamedColor (
props(2*i +1).string_value ().c_str ());
256 if (color.isValid ())
257 ui->btn_color->setPalette (QPalette (color));
268 ui->button_box->button (QDialogButtonBox::Ok)->setEnabled (str.length () > 0);
277 QColor color = widg->palette ().color (QPalette::Button);
279 color = QColorDialog::getColor (color,
this);
281 if (color.isValid ())
283 widg->setPalette (QPalette (color));
285 QString css = QString (
"background-color: %1; border: 1px solid %2;")
289 widg->setStyleSheet (css);
octave_idx_type numel(void) const
Number of elements in the array.
void button_clicked(QAbstractButton *button)
void edit_string_changed(const QString &str)
octave_value_list get_properties() const
octave::base_qobject & m_octave_qobj
annotation_dialog(octave::base_qobject &oct_qobj, QWidget *parent, const octave_value_list &pr)
Ui::annotation_dialog * ui
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
QVariant value(const gui_pref &pref) const
gui_settings * get_settings(void) const
octave_value_list & append(const octave_value &val)
octave_idx_type length(void) const
const gui_pref gp_annotation_geometry("annotation/geometry", QVariant())
QColor fromRgb(const Matrix &rgb)
Matrix toRgb(const QColor &c)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.