Revert buttons using setIcon and use a better stylesheet method instead

Fix evidence buttons and emote buttons being hardcoded size
This commit is contained in:
Crystalwarrior 2019-09-20 15:54:45 +03:00
parent 3899dbe0bd
commit d3f23708c4
8 changed files with 30 additions and 29 deletions

View File

@ -11,7 +11,7 @@ class AOEmoteButton : public QPushButton
Q_OBJECT
public:
AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y);
AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h);
void set_image(QString p_image, QString p_emote_comment);
void set_char_image(QString p_char, int p_emote, QString suffix);

View File

@ -13,7 +13,7 @@ class AOEvidenceButton : public QPushButton
Q_OBJECT
public:
AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y);
AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h);
void set_image(QString p_image);
void set_theme_image(QString p_image);

View File

@ -20,17 +20,15 @@ void AOButton::set_image(QString p_image)
if (file_exists(image_path))
{
this->setIcon(QIcon(image_path));
this->setIconSize(this->size());
this->setStyleSheet("border:0px");
this->setText("");
this->setStyleSheet("QPushButton { border-image: url(\"" + image_path + "\") 0 0 0 0 stretch stretch; }"
"QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }");
}
else if (file_exists(default_image_path))
{
this->setIcon(QIcon(default_image_path));
this->setIconSize(this->size());
this->setStyleSheet("border:0px");
this->setText("");
this->setStyleSheet("QPushButton { border-image: url(\"" + default_image_path + "\"); }"
"QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }");
}
else
return;

View File

@ -70,10 +70,14 @@ void AOCharButton::set_image(QString p_character)
this->setText("");
if (file_exists(image_path))
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
{
this->setStyleSheet("QPushButton { border-image: url(\"" + image_path + "\") 0 0 0 0 stretch stretch; }"
"QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }");
}
else
{
this->setStyleSheet("border-image:url()");
this->setStyleSheet("QPushButton { border-image: url(); }"
"QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }");
this->setText(p_character);
}
}

View File

@ -2,13 +2,13 @@
#include "file_functions.h"
AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y) : QPushButton(p_parent)
AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y, int p_w, int p_h) : QPushButton(p_parent)
{
parent = p_parent;
ao_app = p_ao_app;
this->move(p_x, p_y);
this->resize(40, 40);
this->resize(p_w, p_h);
connect(this, SIGNAL(clicked()), this, SLOT(on_clicked()));
}
@ -17,15 +17,15 @@ void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
{
if (file_exists(p_image))
{
this->setIcon(QIcon(p_image));
this->setIconSize(this->size());
this->setStyleSheet("border:0px");
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
{
this->setText(p_emote_comment);
this->setStyleSheet("border-image:url(\"\")");
this->setStyleSheet("QPushButton { border-image: url(); }"
"QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }");
}
}

View File

@ -2,28 +2,27 @@
#include "file_functions.h"
AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y) : QPushButton(p_parent)
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;
//HELLO AND WELCOME TO HARDCODE CENTRAL, MAY I TAKE YOUR FRESH ORDER OF PAIN AND SUFFERING
ui_selected = new AOImage(this, ao_app);
ui_selected->resize(70, 70);
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);
ui_selector->resize(70, 70);
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(70, 70);
this->resize(p_w, p_h);
// this->setAcceptDrops(true);
connect(this, SIGNAL(clicked()), this, SLOT(on_clicked()));
@ -32,24 +31,24 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, i
void AOEvidenceButton::set_image(QString p_image)
{
QString image_path = ao_app->get_evidence_path(p_image);
qDebug() << image_path << p_image;
if (file_exists(p_image))
{
this->setText("");
this->setIcon(QIcon(p_image));
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->setIcon(QIcon(image_path));
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->setIcon(QIcon());
this->setStyleSheet("QPushButton { border-image: url(); }"
"QToolTip { background-image: url(); color: #000000; background-color: #ffffff; border: 0px; }");
}
this->setIconSize(this->size());
this->setStyleSheet("border:0px");
}
void AOEvidenceButton::set_theme_image(QString p_image)

View File

@ -52,7 +52,7 @@ void Courtroom::refresh_emotes()
int x_pos = (button_width + x_spacing) * x_mod_count;
int y_pos = (button_height + y_spacing) * y_mod_count;
AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos);
AOEmoteButton *f_emote = new AOEmoteButton(ui_emotes, ao_app, x_pos, y_pos, button_width, button_height);
ui_emote_list.append(f_emote);

View File

@ -74,7 +74,7 @@ void Courtroom::refresh_evidence()
int x_pos = (button_width + x_spacing) * x_mod_count;
int y_pos = (button_height + y_spacing) * y_mod_count;
AOEvidenceButton *f_evidence = new AOEvidenceButton(ui_evidence_buttons, ao_app, x_pos, y_pos);
AOEvidenceButton *f_evidence = new AOEvidenceButton(ui_evidence_buttons, ao_app, x_pos, y_pos, button_width, button_height);
ui_evidence_list.append(f_evidence);