2017-01-01 18:43:52 +01:00
|
|
|
#include "settingsdialogtab.h"
|
|
|
|
#include "QPainter"
|
2017-01-02 03:02:32 +01:00
|
|
|
#include "QStyleOption"
|
|
|
|
#include "settingsdialog.h"
|
2017-01-01 18:43:52 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
SettingsDialogTab::SettingsDialogTab(SettingsDialog *dialog, QString label,
|
|
|
|
QString imageRes)
|
2017-01-02 03:02:32 +01:00
|
|
|
: image(QImage(imageRes))
|
2017-01-01 18:43:52 +01:00
|
|
|
{
|
2017-01-02 03:02:32 +01:00
|
|
|
this->dialog = dialog;
|
|
|
|
|
2017-01-01 18:43:52 +01:00
|
|
|
this->label = label;
|
2017-01-02 03:02:32 +01:00
|
|
|
setFixedHeight(32);
|
|
|
|
|
|
|
|
setCursor(QCursor(Qt::PointingHandCursor));
|
2017-01-01 18:43:52 +01:00
|
|
|
}
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void
|
|
|
|
SettingsDialogTab::paintEvent(QPaintEvent *)
|
2017-01-01 18:43:52 +01:00
|
|
|
{
|
|
|
|
QPainter painter(this);
|
|
|
|
|
2017-01-02 03:02:32 +01:00
|
|
|
QStyleOption opt;
|
|
|
|
opt.init(this);
|
|
|
|
|
|
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
|
|
|
|
|
2017-01-01 18:43:52 +01:00
|
|
|
int a = (height() - image.width()) / 2;
|
|
|
|
|
|
|
|
painter.drawImage(a, a, image);
|
|
|
|
|
|
|
|
a = a + a + image.width();
|
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
painter.drawText(QRect(a, 0, width() - a, height()), label,
|
|
|
|
QTextOption(Qt::AlignLeft | Qt::AlignVCenter));
|
2017-01-01 18:43:52 +01:00
|
|
|
}
|
2017-01-02 03:02:32 +01:00
|
|
|
|
2017-01-11 18:52:09 +01:00
|
|
|
void
|
|
|
|
SettingsDialogTab::mouseReleaseEvent(QMouseEvent *event)
|
2017-01-02 03:02:32 +01:00
|
|
|
{
|
2017-01-11 18:52:09 +01:00
|
|
|
if (event->button() != Qt::LeftButton)
|
|
|
|
return;
|
2017-01-02 03:02:32 +01:00
|
|
|
|
|
|
|
dialog->select(this);
|
|
|
|
}
|