diff --git a/sources/borderpropertieswidget.cpp b/sources/borderpropertieswidget.cpp index 9aaa70b72..765e67d84 100644 --- a/sources/borderpropertieswidget.cpp +++ b/sources/borderpropertieswidget.cpp @@ -133,7 +133,9 @@ void BorderPropertiesWidget::build() { widget_layout -> addWidget(diagram_size_box); // add background color field QLabel *ds3 = new QLabel(tr("Couleur de fond :")); - pb_background_color = new QPushButton(diagram_size_box); + background_color = new QCheckBox(tr("Gris"), diagram_size_box); + bool isnotChecked = Diagram::background_color == Qt::white; + background_color -> setChecked(!isnotChecked); // layout diagram_size_box_layout -> addWidget(ds1, 0, 0); @@ -146,25 +148,16 @@ void BorderPropertiesWidget::build() { diagram_size_box_layout -> addWidget(display_rows, 1, 3); diagram_size_box_layout -> addWidget(ds3, 2, 0, 1, 2); - diagram_size_box_layout -> addWidget(pb_background_color, 2, 2, 1, 2); - // make color of pushbutton same as the present background color chosen - QPalette palette; - palette.setColor(QPalette::Button, Diagram::background_color); - pb_background_color -> setPalette(palette); + diagram_size_box_layout -> addWidget(background_color, 2, 2, 1, 2); //build button connection - connect(pb_background_color, SIGNAL(clicked()), this, SLOT(chooseColor())); + connect(background_color, SIGNAL(stateChanged(int)), this, SLOT(changeColor())); setLayout(widget_layout); } /** Background color choose QColorDialog. Makes Diagram::background_color equal to new chosen color. */ -void BorderPropertiesWidget::chooseColor() { - QColor user_chosen_color = QColorDialog::getColor(Diagram::background_color); - if (user_chosen_color.isValid()) { - Diagram::background_color = user_chosen_color; - QPalette palette; - palette.setColor(QPalette::Button, Diagram::background_color); - pb_background_color -> setPalette(palette); - } +void BorderPropertiesWidget::changeColor() { + Diagram::background_color = (background_color -> isChecked()) ? Qt::gray : Qt::white; + } diff --git a/sources/borderpropertieswidget.h b/sources/borderpropertieswidget.h index 029d996c2..9780c6931 100644 --- a/sources/borderpropertieswidget.h +++ b/sources/borderpropertieswidget.h @@ -46,7 +46,7 @@ class BorderPropertiesWidget : public QWidget { public slots: // to choose the back_ground color of diagram. - void chooseColor(); + void changeColor(); private: void build(); @@ -60,6 +60,6 @@ class BorderPropertiesWidget : public QWidget { QSpinBox *rows_count; ///< Widget to edit the rows count QSpinBox *rows_height; ///< Widget to edit the rows height QCheckBox *display_rows; ///< Checkbox stating whether to display row headers - QPushButton *pb_background_color; ///< Push button for selecting diagram background color + QCheckBox *background_color; ///< Checkbox for selecting diagram background color grey/white }; #endif diff --git a/sources/diagramprintdialog.cpp b/sources/diagramprintdialog.cpp index a3ce6e3b0..9689249b5 100644 --- a/sources/diagramprintdialog.cpp +++ b/sources/diagramprintdialog.cpp @@ -39,6 +39,8 @@ DiagramPrintDialog::DiagramPrintDialog(QETProject *project, QWidget *parent) : // orientation paysage par defaut printer_ -> setOrientation(QPrinter::Landscape); + backup_diagram_background_color = Diagram::background_color; + Diagram::background_color = Qt::white; } /** @@ -47,6 +49,7 @@ DiagramPrintDialog::DiagramPrintDialog(QETProject *project, QWidget *parent) : DiagramPrintDialog::~DiagramPrintDialog() { delete dialog_; delete printer_; + Diagram::background_color = backup_diagram_background_color; } /** diff --git a/sources/diagramprintdialog.h b/sources/diagramprintdialog.h index d82e5adb8..257cf23d4 100644 --- a/sources/diagramprintdialog.h +++ b/sources/diagramprintdialog.h @@ -83,5 +83,6 @@ class DiagramPrintDialog : public QWidget { QLineEdit *filepath_field_; QPushButton *browse_button_; QDialogButtonBox *buttons_; + QColor backup_diagram_background_color; }; #endif