Add darker button generator (#201)
When an `_off` emote button exists without an `_on` counterpart, the client will automatically generate the `_on` button and save it to disk. Co-authored-by: Cents02 <Cents02@Cents0.me> Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
This commit is contained in:
parent
6844f72ab5
commit
55fa6d7da0
@ -2,7 +2,7 @@
|
|||||||
#define AOEMOTEBUTTON_H
|
#define AOEMOTEBUTTON_H
|
||||||
|
|
||||||
#include "aoapplication.h"
|
#include "aoapplication.h"
|
||||||
|
#include <QPainter>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
@ -25,6 +25,7 @@ private:
|
|||||||
|
|
||||||
int m_id = 0;
|
int m_id = 0;
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void emote_clicked(int p_id);
|
void emote_clicked(int p_id);
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "aoemotebutton.h"
|
#include "aoemotebutton.h"
|
||||||
|
|
||||||
#include "file_functions.h"
|
#include "file_functions.h"
|
||||||
|
|
||||||
AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app,
|
AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app,
|
||||||
@ -17,6 +16,8 @@ AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app,
|
|||||||
|
|
||||||
void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
|
void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
|
||||||
{
|
{
|
||||||
|
QString tmp_p_image = p_image;
|
||||||
|
|
||||||
if (file_exists(p_image)) {
|
if (file_exists(p_image)) {
|
||||||
this->setText("");
|
this->setText("");
|
||||||
this->setStyleSheet(
|
this->setStyleSheet(
|
||||||
@ -24,6 +25,26 @@ void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
|
|||||||
"\") 0 0 0 0 stretch stretch; }"
|
"\") 0 0 0 0 stretch stretch; }"
|
||||||
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
||||||
}
|
}
|
||||||
|
else if (p_image.contains("_on") && file_exists(tmp_p_image.replace("_on", "_off"))) {
|
||||||
|
QImage tmpImage(tmp_p_image);
|
||||||
|
QPoint p1, p2;
|
||||||
|
p2.setY(tmpImage.height());
|
||||||
|
|
||||||
|
QLinearGradient gradient(p1, p2);
|
||||||
|
gradient.setColorAt(0, Qt::transparent);
|
||||||
|
gradient.setColorAt(1, QColor(0, 0, 0, 159));
|
||||||
|
|
||||||
|
QPainter p(&tmpImage);
|
||||||
|
p.fillRect(0, 0, tmpImage.width(), tmpImage.height(), gradient);
|
||||||
|
|
||||||
|
gradient.setColorAt(0, QColor(0, 0, 0, 159));
|
||||||
|
gradient.setColorAt(1, Qt::transparent);
|
||||||
|
p.fillRect(0, 0, tmpImage.width(), tmpImage.height(), gradient);
|
||||||
|
|
||||||
|
p.end();
|
||||||
|
tmpImage.save(p_image, "png");
|
||||||
|
set_image(p_image, p_emote_comment);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
this->setText(p_emote_comment);
|
this->setText(p_emote_comment);
|
||||||
this->setStyleSheet("QPushButton { border-image: url(); }"
|
this->setStyleSheet("QPushButton { border-image: url(); }"
|
||||||
|
Loading…
Reference in New Issue
Block a user