blob: 99439e8dd405a211d1d06fd94ce9c2b59aa220c4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include "cssdebugdialog.h"
#include "ui_cssdebugdialog.h"
#include "mainwindow.h"
#include "themetuner.h"
#include <QApplication>
#include <QPushButton>
CssDebugDialog::CssDebugDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CssDebugDialog)
{
ui->setupUi(this);
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
appliedCss = MAINWINDOW->styleSheet();
ui->cssEdit->setPlainText(appliedCss);
updateState();
connect(ui->cssEdit, SIGNAL(textChanged()), this, SLOT(updateState()));
}
CssDebugDialog::~CssDebugDialog()
{
delete ui;
}
void CssDebugDialog::buttonClicked(QAbstractButton* button)
{
if (ui->buttonBox->standardButton(button) == QDialogButtonBox::RestoreDefaults)
{
ui->cssEdit->setPlainText(THEME_TUNER->getDefaultCss());
}
else if (ui->buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole)
{
appliedCss = ui->cssEdit->toPlainText();
MAINWINDOW->setStyleSheet(appliedCss);
}
updateState();
}
void CssDebugDialog::updateState()
{
ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(ui->cssEdit->toPlainText() != appliedCss);
}
void CssDebugDialog::closeEvent(QCloseEvent*)
{
deleteLater();
}
|