#include <QSettings>
#include <QSpinBox>
#include <QStandardItemModel>
+#include <QStyleFactory>
#include <QTableView>
#include <QTimer>
#include <QUrl>
m->addAction(tr("&Language..."),this,SLOT(changeLang()));
m->addAction(tr("&OpenOffice.org Settings..."),this,SLOT(openOfficeCfg()));
m->addAction(tr("Set &Default Label Font..."),this,SLOT(setDefaultFont()));
+ m->addAction(tr("Set &Application Style..."),this,SLOT(setAppStyle()));
mb->addMenu(MApplication::helpMenu());
//create list view
QSettings().setValue("defaultfont",df);
}
+void MConfigDialog::setAppStyle()
+{
+ MAppStyleDialog d(this);
+ d.exec();
+}
+
void MConfigDialog::serverProbe()
{
//sanity check
sslmodel->setData(sslmodel->index(i,2),QSslError((QSslError::SslError)lst[i].second).errorString());
}
}
+
+MAppStyleDialog::MAppStyleDialog(QWidget*par)
+ :QDialog(par)
+{
+ setWindowTitle(tr("Application Style"));
+ QGridLayout *gl;
+ setLayout(gl=new QGridLayout);
+ gl->addWidget(new QLabel(tr("GUI Style:")),0,0);
+ gl->addWidget(style=new QComboBox,0,1,1,2);
+ style->addItem(tr("System Default"));
+ style->setEditable(false);
+ QStringList k=QStyleFactory::keys();
+ QString cs=QSettings().value("appstyle").toString();
+ style->addItems(k);
+ if(k.contains(cs))
+ style->setCurrentIndex(k.indexOf(cs)+1);
+
+ gl->addWidget(new QLabel(tr("Stylesheet:")),1,0);
+ gl->addWidget(css=new QLineEdit,1,1);
+ css->setText(QSettings().value("appstylesheet").toString());
+ QPushButton*p;
+ gl->addWidget(p=new QPushButton("..."),1,2);
+ connect(p,SIGNAL(clicked()),this,SLOT(selectCSS()));
+
+ gl->setRowMinimumHeight(2,15);
+ QHBoxLayout*hl;
+ gl->addLayout(hl=new QHBoxLayout,3,0,1,3);
+ hl->addStretch(10);
+ hl->addWidget(p=new QPushButton(tr("Ok")));
+ connect(p,SIGNAL(clicked()),this,SLOT(accept()),Qt::QueuedConnection);
+ connect(p,SIGNAL(clicked()),this,SLOT(save()));
+ hl->addWidget(p=new QPushButton(tr("Cancel")));
+ connect(p,SIGNAL(clicked()),this,SLOT(reject()));
+}
+
+void MAppStyleDialog::selectCSS()
+{
+ QString s=QFileDialog::getOpenFileName(this,tr("Select Stylesheet"));
+ if(s!="")css->setText(s);
+}
+
+void MAppStyleDialog::save()
+{
+ if(style->currentIndex()==0)
+ QSettings().remove("appstyle");
+ else
+ QSettings().setValue("appstyle",style->currentText());
+ QSettings().setValue("appstylesheet",css->text());
+}
+
QDesktopServices::openUrl(QUrl(d));
}
+MApplication::MApplication(int ac,char**av)
+:QApplication(ac,av)
+{}
+
+void MApplication::setMyStyle()
+{
+ QSettings set;
+ if(set.contains("appstyle"))
+ setStyle(set.value("appstyle").toString());
+ if(set.contains("appstylesheet")){
+ QFile fd(set.value("appstylesheet").toString());
+ if(fd.open(QIODevice::ReadOnly)){
+ setStyleSheet(QString::fromLocal8Bit(fd.readAll()));
+ fd.close();
+ }
+ }
+}
int main(int argc,char**argv)
{
//set icon
app.setWindowIcon(QIcon(":/icon.png"));
+ //set styling
+ app.setMyStyle();
+
//install event filter for random generator
EFilter ef;
app.installEventFilter(&ef);