28 #include "QY2StyleEditor.h"
29 #include "QY2Styler.h"
30 #include "ui_QStyleEditor.h"
33 #include <QFileDialog>
34 #include <QMessageBox>
35 #include <QTextObject>
44 ui.textEdit->setPlainText(
"/* enter style sheet here */" );
45 ui.closeButton->setAutoDefault(
false);
46 setWindowTitle( _(
"Stylesheet Editor" ) );
48 connect( ui.applyButton, &pclass(ui.applyButton)::clicked,
49 this, &pclass(
this)::slotApplyStyle);
51 connect( ui.closeButton, &pclass(ui.closeButton)::clicked,
52 this, &pclass(
this)::close);
54 connect( ui.loadButton, &pclass(ui.loadButton)::clicked,
55 this, &pclass(
this)::slotLoadFile);
57 connect( ui.textEdit, &pclass(ui.textEdit)::textChanged,
58 this, &pclass(
this)::slotTextChanged);
60 connect( ui.autoApply, &pclass(ui.autoApply)::stateChanged,
61 this, &pclass(
this)::slotTextChanged);
69 void QY2StyleEditor::slotTextChanged()
71 if ( ui.autoApply->isChecked() )
75 void QY2StyleEditor::slotApplyStyle()
77 QY2Styler::styler()->setStyleSheet( ui.textEdit->toPlainText() );
81 void QY2StyleEditor::slotLoadFile()
84 QString fileName = QFileDialog::getOpenFileName(
this,
85 QString(
"Load stylesheet ..." ),
86 QY2Styler::styler()->themeDir(),
88 QFileDialog::DontUseNativeDialog );
90 if ( fileName.isEmpty() )
94 QFile file( fileName);
96 if ( file.open( QFile::ReadOnly ) )
97 ui.textEdit->setPlainText( file.readAll() );
100 QMessageBox::warning(
this,
102 QString(
"Couldn't load file\n%1" ).arg( fileName ),
103 QMessageBox::Ok | QMessageBox::Default,
112 #include "QY2StyleEditor.moc"
QY2StyleEditor(QWidget *parent)
Constructor.
~QY2StyleEditor()
Destructor.