2 * This file is part of jSpeed.
4 * jSpeed is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * jSpeed is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with jSpeed. If not, see <http://www.gnu.org/licenses/>.
19 #include <QtCore/QDir>
20 #include <QtCore/QDebug>
21 #include <QtCore/QString>
22 #include <QtCore/QStringList>
23 #include <QtGui/QFileDialog>
24 #include <QtGui/QDialogButtonBox>
25 #include <QtGui/QPushButton>
26 #include <QtGui/QHBoxLayout>
27 #include <QtGui/QVBoxLayout>
28 #include <QtGui/QMessageBox>
29 #include "themeselector.h"
30 #include "themepicker.h"
31 #include "themeloader.h"
33 #include "themeschedulersettings.h"
35 ThemeSelector::ThemeSelector(QWidget* parent): QDialog(parent), themeScheduler_(0)
37 setWindowTitle(tr("Select theme"));
39 QHBoxLayout* layout = new QHBoxLayout;
40 QVBoxLayout* left = new QVBoxLayout;
41 QHBoxLayout* first = new QHBoxLayout;
43 QPushButton* saveButton = new QPushButton(tr("Save"));
44 connect(saveButton, SIGNAL(clicked(bool)), this, SLOT(saveTheme()));
45 QDialogButtonBox* buttons = new QDialogButtonBox;
46 buttons->setCenterButtons(false);
47 buttons->setOrientation(Qt::Vertical);
48 buttons->addButton(saveButton, QDialogButtonBox::AcceptRole);
50 selector_ = new ThemePicker(tr("Theme"), this);
51 theme_ = Settings::instance().value("theme", "default").toString();
53 QPushButton* loadButton = new QPushButton(tr("Import"));
54 connect(loadButton, SIGNAL(clicked(bool)), this, SLOT(loadFromFile()));
56 QPushButton* scheduler = new QPushButton(tr("Theme scheduler"));
57 connect(scheduler, SIGNAL(clicked(bool)), this, SLOT(openScheduler()));
59 first->addWidget(selector_, Qt::AlignLeft);
60 first->addWidget(loadButton);
62 left->addLayout(first);
63 left->addWidget(scheduler);
65 layout->addLayout(left, Qt::AlignLeft);
66 layout->addWidget(buttons);
72 void ThemeSelector::saveTheme()
74 QString theme = selector_->value().toString();
82 Settings::instance().setValue("theme", theme);
88 void ThemeSelector::loadFromFile()
92 if(selector_->importFile(ThemeLoader::getThemeDir(),
94 "*" + ThemeLoader::getThemeSuffix(),
98 selector_->loadThemes();
99 selector_->selectTheme(file);
103 void ThemeSelector::openScheduler()
107 themeScheduler_ = new ThemeSchedulerSettings(this);
110 themeScheduler_->show();