Skip to content

Commit

Permalink
Added switch between image or placeholder text for AOImage
Browse files Browse the repository at this point in the history
  • Loading branch information
TrickyLeifa committed Apr 10, 2022
1 parent fee1c1e commit 7edf28c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
15 changes: 11 additions & 4 deletions src/aobutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ void AOButton::set_image(QString p_image)
l_hover_image = m_image;
}

this->setStyleSheet("QPushButton {border-image:url(\"" + m_image +
"\");}"
"QPushButton:hover {border-image:url(\"" +
l_hover_image + "\");}");
setStyleSheet("QPushButton {border-image:url(\"" + m_image +
"\");}"
"QPushButton:hover {border-image:url(\"" +
l_hover_image + "\");}");
setText(m_image.isEmpty() ? m_text : nullptr);
}

void AOButton::set_image_and_text(QString p_image, QString p_text)
{
m_text = p_text;
set_image(p_image);
}

void AOButton::refresh_image()
Expand Down
2 changes: 2 additions & 0 deletions src/aobutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ class AOButton : public QPushButton
QString get_image();
bool has_image();
void set_image(QString p_image);
void set_image_and_text(QString p_image, QString p_text);
void refresh_image();

private:
AOApplication *ao_app = nullptr;
QString m_image;
QString m_image_stem;
QString m_text;
};

#endif // AOBUTTON_H
3 changes: 1 addition & 2 deletions src/lobby.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ void Lobby::update_widgets()
ui_version->setText("Version: " + get_version_string());

set_size_and_pos(ui_config_panel, "config_panel", LOBBY_DESIGN_INI, ao_app);
ui_config_panel->set_image("lobby_config_panel.png");
ui_config_panel->setText("Config");
ui_config_panel->set_image_and_text("lobby_config_panel.png", "Config");
if (ui_config_panel->isHidden() || ui_config_panel->size().isEmpty())
{
ui_config_panel->resize(64, 64);
Expand Down

0 comments on commit 7edf28c

Please sign in to comment.