From b085be5a2a0512c432bc9fd58413a9d8f93d451e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 16 Sep 2019 21:08:43 +0300 Subject: Add two new helper functions - get_design_element and get_static_image_suffix Modify all set_image calls to utilize said suffix helper function Dynamically change betweehn chatblank, chat, chatmed, chatbig based on the showname's length Use char.ini showname if showname is set to whitespace (doesn't yet check if char.ini showname is also whitespace) --- src/aoevidencebutton.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/aoevidencebutton.cpp') diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 15b598fc..616f6367 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -10,14 +10,14 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, i ui_selected = new AOImage(p_parent, ao_app); ui_selected->resize(70, 70); ui_selected->move(p_x, p_y); - ui_selected->set_image("evidence_selected.png"); + ui_selected->set_image("evidence_selected"); ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents); ui_selected->hide(); ui_selector = new AOImage(p_parent, ao_app); ui_selector->resize(71, 71); ui_selector->move(p_x - 1, p_y - 1); - ui_selector->set_image("evidence_selector.png"); + ui_selector->set_image("evidence_selector"); ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); ui_selector->hide(); -- cgit From 0fe94d5d9f0e175ba8355305cdfd6cd35e0a545f Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 18 Sep 2019 17:34:22 +0300 Subject: Evidence and emotes reloading when reload_theme is pressed Update evidence a bit and change the way it sets images to something much better and less confusing Update the hovering logic a bit so there's less weird occurences happening e.g. evidence button is deleted --- src/aoevidencebutton.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/aoevidencebutton.cpp') diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 616f6367..871b4775 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -7,48 +7,49 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, i ao_app = p_ao_app; m_parent = p_parent; - ui_selected = new AOImage(p_parent, ao_app); + //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->move(p_x, p_y); +// 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(p_parent, ao_app); - ui_selector->resize(71, 71); - ui_selector->move(p_x - 1, p_y - 1); + ui_selector = new AOImage(this, ao_app); + ui_selector->resize(70, 70); +// 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->setAcceptDrops(true); +// this->setAcceptDrops(true); connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); } -void AOEvidenceButton::reset() -{ - this->hide(); - ui_selected->hide(); - ui_selector->hide(); -} - void AOEvidenceButton::set_image(QString p_image) { QString image_path = ao_app->get_evidence_path(p_image); - - if (file_exists(image_path)) + qDebug() << image_path << p_image; + if (file_exists(p_image)) + { + this->setText(""); + this->setIcon(QIcon(p_image)); + } + else if (file_exists(image_path)) { this->setText(""); - this->setStyleSheet("border-image:url(\"" + image_path + "\")"); + this->setIcon(QIcon(image_path)); } else { this->setText(p_image); - this->setStyleSheet(""); + this->setIcon(QIcon()); } + this->setIconSize(this->size()); + this->setStyleSheet("border:0px"); } void AOEvidenceButton::set_theme_image(QString p_image) @@ -63,8 +64,7 @@ void AOEvidenceButton::set_theme_image(QString p_image) else final_image_path = default_image_path; - this->setText(""); - this->setStyleSheet("border-image:url(\"" + final_image_path + "\")"); + this->set_image(final_image_path); } void AOEvidenceButton::set_selected(bool p_selected) -- cgit From d3f23708c43bc132c322b778b2aa8d31a68d1c0c Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 20 Sep 2019 15:54:45 +0300 Subject: Revert buttons using setIcon and use a better stylesheet method instead Fix evidence buttons and emote buttons being hardcoded size --- src/aoevidencebutton.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/aoevidencebutton.cpp') diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 871b4775..61847f2d 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -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) -- cgit From c8e12558cdd3fd0769b81679ad09edf1f29b780f Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 22 May 2020 01:18:24 +0300 Subject: Clang-ify the code with this styling using Visual Studio Code: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Stroustrup, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All } (this is the Visual Studio preset with only "BreakBeforeBraces" changed from Allman to Stroustrup) --- src/aoevidencebutton.cpp | 127 +++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 65 deletions(-) (limited to 'src/aoevidencebutton.cpp') diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 61847f2d..596374b2 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -4,85 +4,82 @@ 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); - 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(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, SIGNAL(clicked()), this, SLOT(on_clicked())); + ao_app = p_ao_app; + m_parent = p_parent; + + ui_selected = new AOImage(this, ao_app); + 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(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, SIGNAL(clicked()), this, SLOT(on_clicked())); } void AOEvidenceButton::set_image(QString p_image) { - QString image_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; }"); - } + QString image_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_theme_path(p_image); - QString default_image_path = ao_app->get_default_theme_path(p_image); + QString theme_image_path = ao_app->get_theme_path(p_image); + QString default_image_path = ao_app->get_default_theme_path(p_image); - QString final_image_path; + QString final_image_path; - if (file_exists(theme_image_path)) - final_image_path = theme_image_path; - else - final_image_path = default_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); + this->set_image(final_image_path); } void AOEvidenceButton::set_selected(bool p_selected) { - if (p_selected) - ui_selected->show(); - else - ui_selected->hide(); + if (p_selected) + ui_selected->show(); + else + ui_selected->hide(); } void AOEvidenceButton::on_clicked() { - evidence_clicked(m_id); + evidence_clicked(m_id); } void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) { - QPushButton::mouseDoubleClickEvent(e); - evidence_double_clicked(m_id); + QPushButton::mouseDoubleClickEvent(e); + evidence_double_clicked(m_id); } /* @@ -101,20 +98,20 @@ void AOEvidenceButton::dragEnterEvent(QMouseEvent *e) } */ -void AOEvidenceButton::enterEvent(QEvent * e) +void AOEvidenceButton::enterEvent(QEvent *e) { - ui_selector->show(); + ui_selector->show(); - on_hover(m_id, true); + on_hover(m_id, true); - setFlat(false); - QPushButton::enterEvent(e); + setFlat(false); + QPushButton::enterEvent(e); } -void AOEvidenceButton::leaveEvent(QEvent * e) +void AOEvidenceButton::leaveEvent(QEvent *e) { - ui_selector->hide(); + ui_selector->hide(); - on_hover(m_id, false); - QPushButton::leaveEvent(e); + on_hover(m_id, false); + QPushButton::leaveEvent(e); } -- cgit From 88de4cde0433ef5e606f38a2f1e6041f0d24a87e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 22 May 2020 02:14:54 +0300 Subject: clang 2 electric boogaloo { BasedOnStyle: LLVM, BreakBeforeBraces: Stroustrup} --- src/aoevidencebutton.cpp | 132 ++++++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 64 deletions(-) (limited to 'src/aoevidencebutton.cpp') diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 596374b2..f85a223f 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -2,84 +2,88 @@ #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) +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); - 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(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, SIGNAL(clicked()), this, SLOT(on_clicked())); + ao_app = p_ao_app; + m_parent = p_parent; + + ui_selected = new AOImage(this, ao_app); + 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(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, SIGNAL(clicked()), this, SLOT(on_clicked())); } void AOEvidenceButton::set_image(QString p_image) { - QString image_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; }"); - } + QString image_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_theme_path(p_image); - QString default_image_path = ao_app->get_default_theme_path(p_image); + QString theme_image_path = ao_app->get_theme_path(p_image); + QString default_image_path = ao_app->get_default_theme_path(p_image); - QString final_image_path; + QString final_image_path; - if (file_exists(theme_image_path)) - final_image_path = theme_image_path; - else - final_image_path = default_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); + this->set_image(final_image_path); } void AOEvidenceButton::set_selected(bool p_selected) { - if (p_selected) - ui_selected->show(); - else - ui_selected->hide(); + if (p_selected) + ui_selected->show(); + else + ui_selected->hide(); } -void AOEvidenceButton::on_clicked() -{ - evidence_clicked(m_id); -} +void AOEvidenceButton::on_clicked() { evidence_clicked(m_id); } void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) { - QPushButton::mouseDoubleClickEvent(e); - evidence_double_clicked(m_id); + QPushButton::mouseDoubleClickEvent(e); + evidence_double_clicked(m_id); } /* @@ -100,18 +104,18 @@ void AOEvidenceButton::dragEnterEvent(QMouseEvent *e) void AOEvidenceButton::enterEvent(QEvent *e) { - ui_selector->show(); + ui_selector->show(); - on_hover(m_id, true); + on_hover(m_id, true); - setFlat(false); - QPushButton::enterEvent(e); + setFlat(false); + QPushButton::enterEvent(e); } void AOEvidenceButton::leaveEvent(QEvent *e) { - ui_selector->hide(); + ui_selector->hide(); - on_hover(m_id, false); - QPushButton::leaveEvent(e); + on_hover(m_id, false); + QPushButton::leaveEvent(e); } -- cgit