refactored the settings dialog
This commit is contained in:
@@ -1 +0,0 @@
|
||||
../.clang-format
|
||||
@@ -7,11 +7,12 @@
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog, QString _labelText,
|
||||
SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog, settingspages::SettingsPage *_page,
|
||||
QString imageFileName)
|
||||
: dialog(_dialog)
|
||||
, page(_page)
|
||||
{
|
||||
this->ui.labelText = _labelText;
|
||||
this->ui.labelText = page->getName();
|
||||
this->ui.icon.addFile(imageFileName);
|
||||
|
||||
this->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
@@ -31,14 +32,9 @@ void SettingsDialogTab::setSelected(bool _selected)
|
||||
emit selectedChanged(selected);
|
||||
}
|
||||
|
||||
QWidget *SettingsDialogTab::getWidget()
|
||||
settingspages::SettingsPage *SettingsDialogTab::getSettingsPage()
|
||||
{
|
||||
return this->ui.widget;
|
||||
}
|
||||
|
||||
void SettingsDialogTab::setWidget(QWidget *widget)
|
||||
{
|
||||
this->ui.widget = widget;
|
||||
return this->page;
|
||||
}
|
||||
|
||||
void SettingsDialogTab::paintEvent(QPaintEvent *)
|
||||
@@ -51,8 +47,7 @@ void SettingsDialogTab::paintEvent(QPaintEvent *)
|
||||
this->style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
|
||||
|
||||
int a = (this->height() - 20) / 2;
|
||||
QPixmap pixmap = this->ui.icon.pixmap(QSize(20,20));
|
||||
|
||||
QPixmap pixmap = this->ui.icon.pixmap(QSize(20, 20));
|
||||
|
||||
painter.drawPixmap(0, a, pixmap);
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPaintEvent>
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
|
||||
namespace chatterino {
|
||||
namespace widgets {
|
||||
namespace settingspages {
|
||||
class SettingsPage;
|
||||
}
|
||||
|
||||
class SettingsDialog;
|
||||
|
||||
@@ -14,11 +17,11 @@ class SettingsDialogTab : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsDialogTab(SettingsDialog *dialog, QString _label, QString imageFileName);
|
||||
SettingsDialogTab(SettingsDialog *dialog, settingspages::SettingsPage *page,
|
||||
QString imageFileName);
|
||||
|
||||
void setSelected(bool selected);
|
||||
QWidget *getWidget();
|
||||
void setWidget(QWidget *widget);
|
||||
settingspages::SettingsPage *getSettingsPage();
|
||||
|
||||
signals:
|
||||
void selectedChanged(bool);
|
||||
@@ -28,13 +31,13 @@ private:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
struct {
|
||||
QWidget *widget;
|
||||
QString labelText;
|
||||
QIcon icon;
|
||||
} ui;
|
||||
|
||||
// Parent settings dialog
|
||||
SettingsDialog *dialog;
|
||||
settingspages::SettingsPage *page;
|
||||
|
||||
bool selected = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user