aboutsummaryrefslogtreecommitdiff
path: root/src/aoevidencebutton.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/aoevidencebutton.cpp')
-rw-r--r--src/aoevidencebutton.cpp87
1 files changed, 34 insertions, 53 deletions
diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp
index b026c13e..31163ca8 100644
--- a/src/aoevidencebutton.cpp
+++ b/src/aoevidencebutton.cpp
@@ -2,61 +2,58 @@
#include "file_functions.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)
+AOEvidenceButton::AOEvidenceButton(int id, int width, int height, AOApplication *ao_app, QWidget *parent)
+ : QPushButton(parent)
+ , ao_app(ao_app)
+ , m_id(id)
{
+ resize(width, height);
+
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->resize(width, height);
+ ui_selected->setImage("evidence_selected");
ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_selected->hide();
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");
+ ui_selector->resize(width, height);
+ ui_selector->setImage("evidence_selector");
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_selector->hide();
- this->move(p_x, p_y);
- this->resize(p_w, p_h);
- // this->setAcceptDrops(true);
-
connect(this, &AOEvidenceButton::clicked, this, &AOEvidenceButton::on_clicked);
}
-void AOEvidenceButton::set_image(QString p_image)
+void AOEvidenceButton::setImage(QString fileName)
{
- QString image_path = ao_app->get_real_path(ao_app->get_evidence_path(p_image));
- if (file_exists(p_image))
+ QString image_path = ao_app->get_real_path(ao_app->get_evidence_path(fileName));
+ if (file_exists(fileName))
{
- this->setText("");
- this->setStyleSheet("QPushButton { border-image: url(\"" + p_image +
- "\") 0 0 0 0 stretch stretch; }"
- "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
+ setText("");
+ setStyleSheet("QPushButton { border-image: url(\"" + fileName +
+ "\") 0 0 0 0 stretch stretch; }"
+ "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
}
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; }");
+ setText("");
+ setStyleSheet("QPushButton { border-image: url(\"" + image_path +
+ "\") 0 0 0 0 stretch stretch; }"
+ "QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
}
else
{
- this->setText(p_image);
- this->setStyleSheet("QPushButton { border-image: url(); }"
- "QToolTip { background-image: url(); color: #000000; "
- "background-color: #ffffff; border: 0px; }");
+ setText(fileName);
+ setStyleSheet("QPushButton { border-image: url(); }"
+ "QToolTip { background-image: url(); color: #000000; "
+ "background-color: #ffffff; border: 0px; }");
}
}
-void AOEvidenceButton::set_theme_image(QString p_image)
+void AOEvidenceButton::setThemeImage(QString fileName)
{
- 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(fileName));
+ QString default_image_path = ao_app->get_real_path(ao_app->get_theme_path(fileName, ao_app->default_theme));
QString final_image_path;
@@ -69,10 +66,10 @@ void AOEvidenceButton::set_theme_image(QString p_image)
final_image_path = default_image_path;
}
- this->set_image(final_image_path);
+ setImage(final_image_path);
}
-void AOEvidenceButton::set_selected(bool p_selected)
+void AOEvidenceButton::setSelected(bool p_selected)
{
if (p_selected)
{
@@ -86,30 +83,14 @@ void AOEvidenceButton::set_selected(bool p_selected)
void AOEvidenceButton::on_clicked()
{
- Q_EMIT evidence_clicked(m_id);
+ Q_EMIT evidenceClicked(m_id);
}
void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e)
{
QPushButton::mouseDoubleClickEvent(e);
- Q_EMIT evidence_double_clicked(m_id);
-}
-
-/*
-void AOEvidenceButton::dragLeaveEvent(QMouseEvent *e)
-{
- //QWidget::dragLeaveEvent(e);
-
- qDebug() << "drag leave event";
-}
-
-void AOEvidenceButton::dragEnterEvent(QMouseEvent *e)
-{
- //QWidget::dragEnterEvent(e);
-
- qDebug() << "drag enter event";
+ Q_EMIT evidenceDoubleClicked(m_id);
}
-*/
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
void AOEvidenceButton::enterEvent(QEvent *e)
@@ -119,7 +100,7 @@ void AOEvidenceButton::enterEvent(QEnterEvent *e)
{
ui_selector->show();
- Q_EMIT on_hover(m_id, true);
+ Q_EMIT mouseoverUpdated(m_id, true);
setFlat(false);
QPushButton::enterEvent(e);
@@ -129,6 +110,6 @@ void AOEvidenceButton::leaveEvent(QEvent *e)
{
ui_selector->hide();
- Q_EMIT on_hover(m_id, false);
+ Q_EMIT mouseoverUpdated(m_id, false);
QPushButton::leaveEvent(e);
}