aboutsummaryrefslogtreecommitdiff
path: root/src/aoemotebutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/aoemotebutton.cpp')
-rw-r--r--src/aoemotebutton.cpp56
1 files changed, 34 insertions, 22 deletions
diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp
index c0539844..32e50ff8 100644
--- a/src/aoemotebutton.cpp
+++ b/src/aoemotebutton.cpp
@@ -1,13 +1,10 @@
#include "aoemotebutton.h"
#include "file_functions.h"
-AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app,
- int p_x, int p_y, int p_w, int p_h)
+AOEmoteButton::AOEmoteButton(AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h, QWidget *p_parent)
: QPushButton(p_parent)
+ , ao_app(p_ao_app)
{
- parent = p_parent;
- ao_app = p_ao_app;
-
this->move(p_x, p_y);
this->resize(p_w, p_h);
@@ -21,27 +18,38 @@ AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app,
void AOEmoteButton::set_selected_image(QString p_image)
{
- if (file_exists(p_image)) {
+ if (file_exists(p_image))
+ {
ui_selected->setStyleSheet("border-image: url(\"" + p_image + "\")");
}
- else {
+ else
+ {
ui_selected->setStyleSheet("background-color: rgba(0, 0, 0, 128)");
}
}
-void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
+void AOEmoteButton::set_id(int p_id)
+{
+ m_id = p_id;
+}
+
+int AOEmoteButton::get_id()
{
- QString tmp_p_image = p_image;
+ return m_id;
+}
- if (file_exists(p_image)) {
+void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
+{
+ if (file_exists(p_image))
+ {
this->setText("");
- this->setStyleSheet(
- "QPushButton { border: none; }"
- "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
+ this->setStyleSheet("QPushButton { border: none; }"
+ "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
this->setIcon(QPixmap(p_image).scaled(this->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
this->setIconSize(this->size());
}
- else {
+ else
+ {
this->setText(p_emote_comment);
this->setStyleSheet("QPushButton { border-image: url(); }"
"QToolTip { background-image: url(); color: #000000; "
@@ -54,25 +62,29 @@ void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
void AOEmoteButton::set_char_image(QString p_char, int p_emote, bool on)
{
QString emotion_number = QString::number(p_emote + 1);
- QStringList suffixes { "_off", "_on" };
+ QStringList suffixes{"_off", "_on"};
QStringList suffixedPaths;
- for (const QString &suffix : suffixes) {
- suffixedPaths.append(ao_app->get_image_suffix(ao_app->get_character_path(
- p_char, "emotions/button" + emotion_number + suffix)));
+ for (const QString &suffix : suffixes)
+ {
+ suffixedPaths.append(ao_app->get_image_suffix(ao_app->get_character_path(p_char, "emotions/button" + emotion_number + suffix)));
}
QString image = suffixedPaths[static_cast<int>(on)];
QString emoteComment = ao_app->get_emote_comment(p_char, p_emote);
- if (on && !file_exists(suffixedPaths[1])) {;
+ if (on && !file_exists(suffixedPaths[1]))
+ {
ui_selected->show();
image = suffixedPaths[0];
}
- else {
+ else
+ {
ui_selected->hide();
}
set_image(image, emoteComment);
}
-void AOEmoteButton::on_clicked() { emit emote_clicked(m_id); }
-
+void AOEmoteButton::on_clicked()
+{
+ Q_EMIT emote_clicked(m_id);
+}