mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#include "widgets/settingsdialogtab.h"
|
|
#include "widgets/settingsdialog.h"
|
|
|
|
#include <QPainter>
|
|
#include <QStyleOption>
|
|
|
|
namespace chatterino {
|
|
namespace widgets {
|
|
|
|
SettingsDialogTab::SettingsDialogTab(SettingsDialog *dialog, QString label,
|
|
QString imageRes)
|
|
: image(QImage(imageRes))
|
|
{
|
|
this->dialog = dialog;
|
|
|
|
this->label = label;
|
|
setFixedHeight(32);
|
|
|
|
setCursor(QCursor(Qt::PointingHandCursor));
|
|
|
|
setStyleSheet("color: #FFF");
|
|
}
|
|
|
|
void
|
|
SettingsDialogTab::paintEvent(QPaintEvent *)
|
|
{
|
|
QPainter painter(this);
|
|
|
|
QStyleOption opt;
|
|
opt.init(this);
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
|
|
|
|
int a = (height() - image.width()) / 2;
|
|
|
|
painter.drawImage(a, a, image);
|
|
|
|
a = a + a + image.width();
|
|
|
|
painter.drawText(QRect(a, 0, width() - a, height()), label,
|
|
QTextOption(Qt::AlignLeft | Qt::AlignVCenter));
|
|
}
|
|
|
|
void
|
|
SettingsDialogTab::mouseReleaseEvent(QMouseEvent *event)
|
|
{
|
|
if (event->button() != Qt::LeftButton)
|
|
return;
|
|
|
|
dialog->select(this);
|
|
}
|
|
}
|
|
}
|