refactored the settings dialog

This commit is contained in:
fourtf
2018-01-12 23:09:05 +01:00
parent 4cbc3b8b61
commit e0bb061c81
39 changed files with 953 additions and 894 deletions
-1
View File
@@ -1 +0,0 @@
../.clang-format
+6 -11
View File
@@ -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);
+8 -5
View File
@@ -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;
};