merged with slight code cleanup

This commit is contained in:
itsmattkc
2019-01-12 13:55:53 +11:00
53 changed files with 659 additions and 484 deletions
+14 -14
View File
@@ -5,18 +5,18 @@
#include <QColorDialog>
ColorButton::ColorButton(QWidget *parent)
: QPushButton(parent), color(Qt::white) {
set_button_color();
connect(this, SIGNAL(clicked(bool)), this, SLOT(open_dialog()));
: QPushButton(parent), color(Qt::white) {
set_button_color();
connect(this, SIGNAL(clicked(bool)), this, SLOT(open_dialog()));
}
QColor ColorButton::get_color() {
return color;
return color;
}
void ColorButton::set_color(QColor c) {
previousColor = color;
color = c;
color = c;
set_button_color();
}
@@ -25,27 +25,27 @@ const QColor &ColorButton::getPreviousValue() {
}
void ColorButton::set_button_color() {
QPalette pal = palette();
pal.setColor(QPalette::Button, color);
setPalette(pal);
QPalette pal = palette();
pal.setColor(QPalette::Button, color);
setPalette(pal);
}
void ColorButton::open_dialog() {
QColor new_color = QColorDialog::getColor(color, nullptr, "Set Color");
QColor new_color = QColorDialog::getColor(color, nullptr, tr("Set Color"));
if (new_color.isValid() && color != new_color) {
set_color(new_color);
set_button_color();
set_button_color();
emit color_changed();
}
}
}
ColorCommand::ColorCommand(ColorButton* s, QColor o, QColor n)
: sender(s), old_color(o), new_color(n) {}
: sender(s), old_color(o), new_color(n) {}
void ColorCommand::undo() {
sender->set_color(old_color);
sender->set_color(old_color);
}
void ColorCommand::redo() {
sender->set_color(new_color);
sender->set_color(new_color);
}