select Rune Style
This commit is contained in:
parent
a9fa26346f
commit
df78570e51
|
@ -27,6 +27,7 @@ signals:
|
|||
public slots:
|
||||
void buttonPressed();
|
||||
void dataChanged(); // triggers a refresh
|
||||
void checkSelection(uint32_t aspekt); // only used for rune styles
|
||||
|
||||
private slots:
|
||||
void setShowSelection(bool selected); // show/hide the red border
|
||||
|
|
|
@ -41,6 +41,9 @@ public:
|
|||
signals:
|
||||
void selectionChanged();
|
||||
|
||||
void selectPrimary(int aspektId);
|
||||
void selectSecondary(int aspektId);
|
||||
|
||||
private:
|
||||
const RuneStyle* getRuneStyle(uint32_t id) const;
|
||||
RuneAspektButton* createStyleButton(const RuneStyle& rs, bool selected);
|
||||
|
|
|
@ -41,6 +41,11 @@ void RuneAspektButton::dataChanged() {
|
|||
setShowSelection(selection);
|
||||
}
|
||||
|
||||
void RuneAspektButton::checkSelection(uint32_t aspekt) {
|
||||
qDebug() << "checkSelection: " << text() << aspekt << aspektId;
|
||||
setShowSelection(aspekt == this->aspektId);
|
||||
}
|
||||
|
||||
void RuneAspektButton::setShowSelection(bool selected) {
|
||||
if(selected) {
|
||||
setStyleSheet("border: 1px solid red;");
|
||||
|
|
|
@ -33,13 +33,14 @@ void RuneEditor::setClient(ClientAPI& client) {
|
|||
styles = client.getAllRuneStyles();
|
||||
|
||||
for(const RuneStyle& rs : styles) {
|
||||
QPushButton* runeStyleBtn = createStyleButton(rs, rs.id == runepage.primaryStyle);
|
||||
RuneAspektButton* runeStyleBtn = createStyleButton(rs, rs.id == runepage.primaryStyle);
|
||||
|
||||
if(!runeStyleBtn) continue;
|
||||
|
||||
QObject::connect(runeStyleBtn, &QPushButton::pressed, [this, id = rs.id](){
|
||||
selectStyle(id);
|
||||
});
|
||||
QObject::connect(this, &RuneEditor::selectPrimary, runeStyleBtn, &RuneAspektButton::checkSelection);
|
||||
|
||||
ui->style->addWidget(runeStyleBtn);
|
||||
}
|
||||
|
@ -85,6 +86,8 @@ void RuneEditor::selectStyle(uint32_t id) {
|
|||
runepage.selectedAspects.clear();
|
||||
runepage.selectedAspects.resize(9, 0);
|
||||
|
||||
emit selectPrimary(id);
|
||||
|
||||
clearLayout(ui->substyle);
|
||||
clearLayout(ui->stylePerks);
|
||||
clearLayout(ui->substylePerks);
|
||||
|
@ -92,7 +95,7 @@ void RuneEditor::selectStyle(uint32_t id) {
|
|||
// populate substyles
|
||||
for(int subStyleId : style->allowedSubStyles) {
|
||||
const RuneStyle* substyle = getRuneStyle(subStyleId);
|
||||
QPushButton* subStyleBtn = createStyleButton(*substyle, false);
|
||||
RuneAspektButton* subStyleBtn = createStyleButton(*substyle, false);
|
||||
|
||||
if(!subStyleBtn) continue;
|
||||
|
||||
|
@ -100,6 +103,8 @@ void RuneEditor::selectStyle(uint32_t id) {
|
|||
selectSubStyle(subStyleId);
|
||||
});
|
||||
|
||||
QObject::connect(this, &RuneEditor::selectSecondary, subStyleBtn, &RuneAspektButton::checkSelection);
|
||||
|
||||
ui->substyle->addWidget(subStyleBtn);
|
||||
}
|
||||
|
||||
|
@ -116,6 +121,8 @@ void RuneEditor::selectSubStyle(uint32_t id) {
|
|||
if(substyle) {
|
||||
runepage.secondaryStyle = id;
|
||||
|
||||
emit selectSecondary(id);
|
||||
|
||||
clearLayout(ui->substylePerks);
|
||||
delete groups.at(4);
|
||||
|
||||
|
@ -189,12 +196,12 @@ RuneAspektButton* RuneEditor::createStyleButton(const RuneStyle& rs, bool select
|
|||
styleBtn->setText(rs.name);
|
||||
styleBtn->setToolTip(rs.tooltip);
|
||||
|
||||
styleBtn->setAspektId(rs.id);
|
||||
|
||||
if(selected) {
|
||||
styleBtn->setStyleSheet("border: 1px solid red;");
|
||||
}
|
||||
|
||||
QObject::connect(this, &RuneEditor::selectionChanged, styleBtn, &RuneAspektButton::dataChanged);
|
||||
|
||||
return styleBtn;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user