added settingsdialog
This commit is contained in:
+21
-3
@@ -1,17 +1,28 @@
|
||||
#include "settingsdialogtab.h"
|
||||
#include "QPainter"
|
||||
#include "QStyleOption"
|
||||
#include "settingsdialog.h"
|
||||
|
||||
SettingsDialogTab::SettingsDialogTab(QWidget *parent, QString label, QImage& image)
|
||||
: QWidget(parent),
|
||||
image(image)
|
||||
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);
|
||||
@@ -20,3 +31,10 @@ void SettingsDialogTab::paintEvent(QPaintEvent *)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user