mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
41 lines
926 B
C++
41 lines
926 B
C++
#include "settingsdialogtab.h"
|
|
#include "QPainter"
|
|
#include "QStyleOption"
|
|
#include "settingsdialog.h"
|
|
|
|
SettingsDialogTab::SettingsDialogTab(SettingsDialog* dialog, QString label, QString imageRes)
|
|
: image(QImage(imageRes))
|
|
{
|
|
this->dialog = dialog;
|
|
|
|
this->label = label;
|
|
setFixedHeight(32);
|
|
|
|
setCursor(QCursor(Qt::PointingHandCursor));
|
|
}
|
|
|
|
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);
|
|
}
|