2023-05-01 22:36:11 +02:00
|
|
|
#include "runeaspektbutton.h"
|
|
|
|
#include "ui_runeaspektbutton.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
2023-06-13 22:40:55 +02:00
|
|
|
#include "runeaspektbuttongroup.h"
|
|
|
|
|
2023-05-01 22:36:11 +02:00
|
|
|
RuneAspektButton::RuneAspektButton(QWidget* parent) : QPushButton(parent), ui(new Ui::RuneAspektButton) {
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
QObject::connect(this, &QPushButton::pressed, this, &RuneAspektButton::buttonPressed);
|
|
|
|
}
|
|
|
|
|
|
|
|
RuneAspektButton::~RuneAspektButton() {
|
|
|
|
delete this->ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuneAspektButton::setAspektId(uint32_t id) {
|
|
|
|
aspektId = id;
|
|
|
|
|
|
|
|
dataChanged();
|
|
|
|
}
|
|
|
|
|
2023-06-13 22:40:55 +02:00
|
|
|
void RuneAspektButton::setButtonGroup(RuneAspektButtonGroup* group) {
|
|
|
|
this->group = group;
|
|
|
|
}
|
|
|
|
|
2023-05-01 22:36:11 +02:00
|
|
|
bool RuneAspektButton::isSelected() const {
|
2023-06-13 22:40:55 +02:00
|
|
|
return group && group->getSelectedRunes().contains(aspektId);
|
2023-05-01 22:36:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RuneAspektButton::buttonPressed() {
|
2023-06-13 22:40:55 +02:00
|
|
|
emit aspektToggled(aspektId);
|
2023-05-01 22:36:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void RuneAspektButton::dataChanged() {
|
|
|
|
bool selection = isSelected();
|
|
|
|
|
|
|
|
qDebug() << text() << " datachanged - isSelected: " << selection;
|
|
|
|
|
|
|
|
setShowSelection(selection);
|
|
|
|
}
|
|
|
|
|
2023-06-13 23:02:38 +02:00
|
|
|
void RuneAspektButton::checkSelection(uint32_t aspekt) {
|
|
|
|
qDebug() << "checkSelection: " << text() << aspekt << aspektId;
|
|
|
|
setShowSelection(aspekt == this->aspektId);
|
|
|
|
}
|
|
|
|
|
2023-05-01 22:36:11 +02:00
|
|
|
void RuneAspektButton::setShowSelection(bool selected) {
|
|
|
|
if(selected) {
|
|
|
|
setStyleSheet("border: 1px solid red;");
|
|
|
|
} else {
|
|
|
|
setStyleSheet("");
|
|
|
|
}
|
2023-06-13 23:02:38 +02:00
|
|
|
}
|