2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-06-18 21:02:38 +08:00
|
|
|
#include "environmentappearencewidget.h"
|
|
|
|
#include "ui_environmentappearencewidget.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStyleFactory>
|
|
|
|
#include "../settings.h"
|
|
|
|
#include "../mainwindow.h"
|
2021-11-07 22:34:19 +08:00
|
|
|
#include "../thememanager.h"
|
2021-06-18 21:02:38 +08:00
|
|
|
|
|
|
|
EnvironmentAppearenceWidget::EnvironmentAppearenceWidget(const QString& name, const QString& group, QWidget *parent) :
|
|
|
|
SettingsWidget(name,group,parent),
|
|
|
|
ui(new Ui::EnvironmentAppearenceWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->cbTheme->addItem("default");
|
|
|
|
ui->cbTheme->addItem("dark");
|
2021-10-18 22:06:33 +08:00
|
|
|
// ui->cbTheme->addItem("dracula");
|
|
|
|
// ui->cbTheme->addItem("light");
|
|
|
|
// QStyleFactory factory;
|
|
|
|
// for (QString name:factory.keys()) {
|
|
|
|
// ui->cbTheme->addItem(name);
|
|
|
|
// }
|
2021-12-24 09:17:28 +08:00
|
|
|
ui->cbLanguage->addItem(tr("English"),"en");
|
2021-08-16 23:17:48 +08:00
|
|
|
ui->cbLanguage->addItem(tr("Simplified Chinese"),"zh_CN");
|
2021-12-24 09:17:28 +08:00
|
|
|
ui->cbIconSet->addItem("newlook");
|
2021-06-18 21:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EnvironmentAppearenceWidget::~EnvironmentAppearenceWidget()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnvironmentAppearenceWidget::doLoad()
|
|
|
|
{
|
|
|
|
ui->cbTheme->setCurrentText(pSettings->environment().theme());
|
|
|
|
ui->cbFont->setCurrentFont(QFont(pSettings->environment().interfaceFont()));
|
|
|
|
ui->spinFontSize->setValue(pSettings->environment().interfaceFontSize());
|
2021-12-24 09:17:28 +08:00
|
|
|
ui->cbIconSet->setCurrentText(pSettings->environment().iconSet());
|
2021-06-20 09:27:37 +08:00
|
|
|
|
|
|
|
for (int i=0;i<ui->cbLanguage->count();i++) {
|
|
|
|
if (ui->cbLanguage->itemData(i) == pSettings->environment().language()) {
|
|
|
|
ui->cbLanguage->setCurrentIndex(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-06-18 21:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void EnvironmentAppearenceWidget::doSave()
|
|
|
|
{
|
2021-11-07 22:34:19 +08:00
|
|
|
if (pSettings->environment().theme()!=ui->cbTheme->currentText()) {
|
|
|
|
ThemeManager themeManager;
|
|
|
|
PAppTheme appTheme = themeManager.theme(ui->cbTheme->currentText());
|
|
|
|
if (appTheme && !appTheme->defaultColorScheme().isEmpty()) {
|
|
|
|
pSettings->editor().setColorScheme(appTheme->defaultColorScheme());
|
|
|
|
pMainWindow->updateEditorColorSchemes();
|
|
|
|
}
|
|
|
|
}
|
2021-06-18 21:02:38 +08:00
|
|
|
pSettings->environment().setTheme(ui->cbTheme->currentText());
|
|
|
|
pSettings->environment().setInterfaceFont(ui->cbFont->currentFont().family());
|
|
|
|
pSettings->environment().setInterfaceFontSize(ui->spinFontSize->value());
|
2021-06-20 09:27:37 +08:00
|
|
|
pSettings->environment().setLanguage(ui->cbLanguage->currentData().toString());
|
2021-12-24 09:17:28 +08:00
|
|
|
pSettings->environment().setIconSet(ui->cbIconSet->currentText());
|
2021-11-16 00:03:43 +08:00
|
|
|
pSettings->editor().save();
|
2021-06-18 21:02:38 +08:00
|
|
|
pSettings->environment().save();
|
|
|
|
pMainWindow->applySettings();
|
|
|
|
}
|