atrooney-online-2/src/aoevidencebutton.cpp
stonedDiscord a449aa86e9
Qt6 (#824)
* Major cleanup of screenshake code

* Add pre-5.10 support for screenshake math

* more compat, uglier too

* add surprise tool

* we don't need inline functions

* only run qsrand on old versions

* Squash compiler warnings

* >= not > please

* don't set codec in qt6

* switch to new regex

* remove qdesktopwidget (was unused)

* make enter event an enter event

* forgot header file

* rename emote_mod enum as there is an enum of the same name in chat_message

* regexp

* no more codec

* fix warning about emote_mod type

* change to new qtconcurrent

* misc was unused

* fix run

* change qtconcurrent for music

* codecs came back

* make CI run on qt6 too

* seperate artifacts

* qFormatLogMessage is wonky here

* maybe actually use the qt version from matrix

* change qt version here as well

* even lower

* use my own fixed installer

* use my own fixed version of qapng

* get websockets

* minor spelling mistake

* yOu nEeD aDdOnS

* aaaaaaaaaaaaaaaaaaaaaaaaaaaaa

* Revert "maybe actually use the qt version from matrix"

This reverts commit 7ab6b1b4c2f1200318d52f325efd2ef46c3fbd6a.

* Revert "Revert "maybe actually use the qt version from matrix""

This reverts commit a6f7c5bedf214a1992c15b296edd195f96a9196a.

* use jurplels again

* Revert "use jurplels again"

This reverts commit 5795474bca64590f1479af3ccbf7d8cc57f427e7.

* revert CI to master

* main not master

Co-authored-by: in1tiate <woodward.randall02+github@gmail.com>
2022-12-28 21:35:11 +01:00

124 lines
3.2 KiB
C++

#include "aoevidencebutton.h"
#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)
: QPushButton(p_parent)
{
ao_app = p_ao_app;
m_parent = p_parent;
ui_selected = new AOImage(this, ao_app, true);
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->resize(p_w, p_h);
// ui_selector->move(p_x - 1, p_y - 1);
ui_selector->set_image("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)
{
QString image_path = ao_app->get_real_path(ao_app->get_evidence_path(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; }");
}
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; }");
}
else {
this->setText(p_image);
this->setStyleSheet("QPushButton { border-image: url(); }"
"QToolTip { background-image: url(); color: #000000; "
"background-color: #ffffff; border: 0px; }");
}
}
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 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);
}
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::mouseDoubleClickEvent(QMouseEvent *e)
{
QPushButton::mouseDoubleClickEvent(e);
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";
}
*/
void AOEvidenceButton::enterEvent(QEnterEvent *e)
{
ui_selector->show();
emit on_hover(m_id, true);
setFlat(false);
QPushButton::enterEvent(e);
}
void AOEvidenceButton::leaveEvent(QEvent *e)
{
ui_selector->hide();
emit on_hover(m_id, false);
QPushButton::leaveEvent(e);
}