27 #include "QY2StyleEditor.h"
28 #include "QY2Styler.h"
29 #include "ui_QStyleEditor.h"
32 #include <QFileDialog>
33 #include <QMessageBox>
34 #include <QTextObject>
43 ui.textEdit->setPlainText(
"/* enter style sheet here */" );
44 ui.closeButton->setAutoDefault(
false);
45 setWindowTitle( _(
"Stylesheet Editor" ) );
47 connect( ui.applyButton, SIGNAL( clicked() ),
48 this, SLOT( slotApplyStyle() ));
50 connect( ui.closeButton, SIGNAL( clicked() ),
51 this, SLOT( close() ));
53 connect( ui.loadButton, SIGNAL( clicked() ),
54 this, SLOT( slotLoadFile() ));
56 connect( ui.textEdit, SIGNAL( textChanged() ),
57 this, SLOT( slotTextChanged() ));
59 connect( ui.autoApply, SIGNAL( stateChanged(
int) ),
60 this, SLOT( slotTextChanged() ));
68 void QY2StyleEditor::slotTextChanged()
70 if ( ui.autoApply->isChecked() )
74 void QY2StyleEditor::slotApplyStyle()
76 QY2Styler::styler()->setStyleSheet( ui.textEdit->toPlainText() );
80 void QY2StyleEditor::slotLoadFile()
83 QString fileName = QFileDialog::getOpenFileName(
this,
84 QString(
"Load stylesheet ..." ),
85 QY2Styler::styler()->themeDir(),
87 QFileDialog::DontUseNativeDialog );
89 if ( fileName.isEmpty() )
93 QFile file( fileName);
95 if ( file.open( QFile::ReadOnly ) )
96 ui.textEdit->setPlainText( file.readAll() );
99 QMessageBox::warning(
this,
101 QString(
"Couldn't load file\n%1" ).arg( fileName ),
102 QMessageBox::Ok | QMessageBox::Default,
111 #include "QY2StyleEditor.moc"
QY2StyleEditor(QWidget *parent)