aboutsummaryrefslogtreecommitdiff
path: root/aocharbutton.cpp
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-01-27 01:24:58 +0100
committerGitHub <noreply@github.com>2017-01-27 01:24:58 +0100
commitd4ad200b612acb1ed2a74d057efc8c3cbfa07ad2 (patch)
treea2b2dbee3b1a3102499b3cb5c6529e6f01655f74 /aocharbutton.cpp
parentea9ba4526dc313a61682ec41b3b052019051545e (diff)
parent9682087667e2de26e14406efde960b8c7f0c3c98 (diff)
Merge pull request #2 from OmniTroid/master
well
Diffstat (limited to 'aocharbutton.cpp')
-rw-r--r--aocharbutton.cpp59
1 files changed, 57 insertions, 2 deletions
diff --git a/aocharbutton.cpp b/aocharbutton.cpp
index 41a4f402..d6edf804 100644
--- a/aocharbutton.cpp
+++ b/aocharbutton.cpp
@@ -1,17 +1,53 @@
#include "aocharbutton.h"
-#include "path_functions.h"
#include "file_functions.h"
#include <QFile>
-AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent)
+AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos) : QPushButton(parent)
{
m_parent = parent;
ao_app = p_ao_app;
this->resize(60, 60);
+ this->move(x_pos, y_pos);
+
+ ui_taken = new AOImage(this, ao_app);
+ ui_taken->resize(60, 60);
+ ui_taken->set_image("char_taken.png");
+ ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents);
+ ui_taken->hide();
+
+ ui_passworded = new AOImage(this, ao_app);
+ ui_passworded->resize(60, 60);
+ ui_passworded->set_image("char_passworded");
+ ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents);
+ ui_passworded->hide();
+
+ ui_selector = new AOImage(parent, ao_app);
+ ui_selector->resize(62, 62);
+ ui_selector->move(x_pos - 1, y_pos - 1);
+ ui_selector->set_image("char_selector.png");
+ ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
+ ui_selector->hide();
+}
+
+void AOCharButton::reset()
+{
+ ui_taken->hide();
+ ui_passworded->hide();
+ ui_selector->hide();
+}
+
+void AOCharButton::set_taken()
+{
+ ui_taken->show();
+}
+
+void AOCharButton::set_passworded()
+{
+ ui_passworded->show();
}
void AOCharButton::set_image(QString p_character)
@@ -19,6 +55,8 @@ void AOCharButton::set_image(QString p_character)
QString image_path = ao_app->get_character_path(p_character) + "char_icon.png";
QString legacy_path = ao_app->get_demothings_path() + p_character.toLower() + "_char_icon.png";
+ this->setText("");
+
if (file_exists(image_path))
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
else if (file_exists(legacy_path))
@@ -33,3 +71,20 @@ void AOCharButton::set_image(QString p_character)
this->setText(p_character);
}
}
+
+void AOCharButton::enterEvent(QEvent * e)
+{
+ ui_selector->raise();
+ ui_selector->show();
+
+ setFlat(false);
+ QPushButton::enterEvent(e);
+}
+
+void AOCharButton::leaveEvent(QEvent * e)
+{
+ ui_selector->hide();
+ QPushButton::leaveEvent(e);
+}
+
+