aboutsummaryrefslogtreecommitdiff
path: root/src/aoevidencebutton.cpp
diff options
context:
space:
mode:
authorTrickyLeifa <date.epoch@gmail.com>2024-05-15 00:00:17 +0200
committerTrickyLeifa <date.epoch@gmail.com>2024-05-15 00:04:16 +0200
commitc9f52b7223685d2e7fca925594171f94dd8c6e3b (patch)
tree740bb32a40da98a4d52836432f59a16b31333900 /src/aoevidencebutton.cpp
parent951766666621fa77e257e6b5616fe4ab1eb2a52f (diff)
Ported to CMake, ...
* Ported the project to CMake * Android and Mac support dropped for the time being. * Tests, BASS and Discord-RPC are now options * Restructured and reformated the project. * Merged `include` and `src` * Renamed `resource` to `data` * Renamed various files * External libraries headers are no longer included in `src` * Replaced header guards with #pragma once * Multiple refactors (keywords, headers) * Added Qt6 compatibility * Removed various unused functions and headers * Reworked AOPacket * When content is passed to AOPacket, it should be ensured that the content is already decoded. * Encoding/decoding are now static methods. * Fixed various memory leaks * Removed animation code for AOImage * AOImage is always using static images * Simplified ChatLogPiece
Diffstat (limited to 'src/aoevidencebutton.cpp')
-rw-r--r--src/aoevidencebutton.cpp59
1 files changed, 33 insertions, 26 deletions
diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp
index d731682e..b026c13e 100644
--- a/src/aoevidencebutton.cpp
+++ b/src/aoevidencebutton.cpp
@@ -2,21 +2,18 @@
#include "file_functions.h"
-AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app,
- int p_x, int p_y, int p_w, int p_h)
+AOEvidenceButton::AOEvidenceButton(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)
{
- ao_app = p_ao_app;
- m_parent = p_parent;
-
- ui_selected = new AOImage(this, ao_app, true);
+ ui_selected = new AOImage(ao_app, this);
ui_selected->resize(p_w, p_h);
// ui_selected->move(p_x, p_y);
ui_selected->set_image("evidence_selected");
ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_selected->hide();
- ui_selector = new AOImage(this, ao_app, true);
+ ui_selector = new AOImage(ao_app, this);
ui_selector->resize(p_w, p_h);
// ui_selector->move(p_x - 1, p_y - 1);
ui_selector->set_image("evidence_selector");
@@ -33,21 +30,22 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app,
void AOEvidenceButton::set_image(QString p_image)
{
QString image_path = ao_app->get_real_path(ao_app->get_evidence_path(p_image));
- if (file_exists(p_image)) {
+ if (file_exists(p_image))
+ {
this->setText("");
- this->setStyleSheet(
- "QPushButton { border-image: url(\"" + p_image +
- "\") 0 0 0 0 stretch stretch; }"
- "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
+ this->setStyleSheet("QPushButton { border-image: url(\"" + p_image +
+ "\") 0 0 0 0 stretch stretch; }"
+ "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
}
- else if (file_exists(image_path)) {
+ else if (file_exists(image_path))
+ {
this->setText("");
- this->setStyleSheet(
- "QPushButton { border-image: url(\"" + image_path +
- "\") 0 0 0 0 stretch stretch; }"
- "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
+ this->setStyleSheet("QPushButton { border-image: url(\"" + image_path +
+ "\") 0 0 0 0 stretch stretch; }"
+ "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
}
- else {
+ else
+ {
this->setText(p_image);
this->setStyleSheet("QPushButton { border-image: url(); }"
"QToolTip { background-image: url(); color: #000000; "
@@ -57,17 +55,19 @@ void AOEvidenceButton::set_image(QString p_image)
void AOEvidenceButton::set_theme_image(QString p_image)
{
- QString theme_image_path = ao_app->get_real_path(
- ao_app->get_theme_path(p_image));
- QString default_image_path = ao_app->get_real_path(
- ao_app->get_theme_path(p_image, ao_app->default_theme));
+ QString theme_image_path = ao_app->get_real_path(ao_app->get_theme_path(p_image));
+ QString default_image_path = ao_app->get_real_path(ao_app->get_theme_path(p_image, ao_app->default_theme));
QString final_image_path;
if (file_exists(theme_image_path))
+ {
final_image_path = theme_image_path;
+ }
else
+ {
final_image_path = default_image_path;
+ }
this->set_image(final_image_path);
}
@@ -75,17 +75,24 @@ void AOEvidenceButton::set_theme_image(QString p_image)
void AOEvidenceButton::set_selected(bool p_selected)
{
if (p_selected)
+ {
ui_selected->show();
+ }
else
+ {
ui_selected->hide();
+ }
}
-void AOEvidenceButton::on_clicked() { emit evidence_clicked(m_id); }
+void AOEvidenceButton::on_clicked()
+{
+ Q_EMIT evidence_clicked(m_id);
+}
void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e)
{
QPushButton::mouseDoubleClickEvent(e);
- emit evidence_double_clicked(m_id);
+ Q_EMIT evidence_double_clicked(m_id);
}
/*
@@ -112,7 +119,7 @@ void AOEvidenceButton::enterEvent(QEnterEvent *e)
{
ui_selector->show();
- emit on_hover(m_id, true);
+ Q_EMIT on_hover(m_id, true);
setFlat(false);
QPushButton::enterEvent(e);
@@ -122,6 +129,6 @@ void AOEvidenceButton::leaveEvent(QEvent *e)
{
ui_selector->hide();
- emit on_hover(m_id, false);
+ Q_EMIT on_hover(m_id, false);
QPushButton::leaveEvent(e);
}