Skip to content

Commit

Permalink
refactor(!): rename ColorTheme to EditorColorTheme
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The `ColorTheme` setting has been changed to `EditorColorTheme`.
  • Loading branch information
ChungZH committed Jun 20, 2020
1 parent 8fadf5e commit 7cd8b62
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ All notable changes to this project will be documented in this file.

### ! BREAKING CHANGE !

- The `Style` setting has been changed to `StyleTheme`
- The `Style` setting has been renamed to `StyleTheme`
- The `ColorTheme` setting has been renamed to `EditorColorTheme`

## 0.1.3-alpha2

Expand Down
22 changes: 12 additions & 10 deletions src/core/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,28 @@ bool ConfigManager::writeJsonFile(QIODevice &device,
*/
void ConfigManager::save()
{
settings->setValue("EditorFontFamily", QVariant(editorFontFamily));
settings->beginGroup("Editor");
settings->setValue("FontFamily", QVariant(editorFontFamily));
settings->setValue("FontSize", QVariant(editorFontSize));
settings->setValue("ColorTheme", QVariant(editorColorTheme));
settings->endGroup();
settings->setValue("StyleTheme", QVariant(styleTheme));
settings->setValue("EditorFontSize", QVariant(editorFontSize));
settings->setValue("ColorTheme", QVariant(colorTheme));
}

/**
* @brief Read general settings from `settings`.
*/
void ConfigManager::readGeneralSettings()
{
if (settings->contains("EditorFontFamily")) {
editorFontFamily = settings->value("EditorFontFamily").toString();
if (settings->contains("Editor/FontFamily")) {
editorFontFamily = settings->value("Editor/FontFamily").toString();
} else {
editorFontFamily =
QFontDatabase::systemFont(QFontDatabase::FixedFont).toString();
}
styleTheme = settings->value("StyleTheme", "Fusion").toString();
editorFontSize = settings->value("EditorFontSize", 16).toInt();
colorTheme = settings->value("ColorTheme", "Default").toString();
editorFontSize = settings->value("Editor/FontSize", 16).toInt();
editorColorTheme = settings->value("Editor/ColorTheme", "Default").toString();
}

QString ConfigManager::getEditorFontFamily() const { return editorFontFamily; }
Expand All @@ -86,8 +88,8 @@ void ConfigManager::setEditorFontSize(const int &fontsize)
editorFontSize = fontsize;
}

QString ConfigManager::getColorTheme() const { return colorTheme; }
void ConfigManager::setColorTheme(const QString &ctname)
QString ConfigManager::getEditorColorTheme() const { return editorColorTheme; }
void ConfigManager::setEditorColorTheme(const QString &ctname)
{
colorTheme = ctname;
editorColorTheme = ctname;
};
6 changes: 3 additions & 3 deletions src/core/configmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ class ConfigManager : public QObject
void setStyleTheme(const QString &stylename);
int getEditorFontSize() const;
void setEditorFontSize(const int &fontsize);
QString getColorTheme() const;
void setColorTheme(const QString &ctname);
QString getEditorColorTheme() const;
void setEditorColorTheme(const QString &ctname);

private:
QSettings *settings;
QString configFile;
QString editorFontFamily;
QString styleTheme;
int editorFontSize;
QString colorTheme;
QString editorColorTheme;
};

#endif // CONFIGMANAGER_H
2 changes: 1 addition & 1 deletion src/core/texteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ TextEditor::TextEditor(ConfigManager *cfManager, QWidget *parent)
m_highlighter(new KSyntaxHighlighting::SyntaxHighlighter(document()))

{
const auto theme = m_repository.theme(configManager->getColorTheme());
const auto theme = m_repository.theme(configManager->getEditorColorTheme());
setTheme(theme);

// Line number area
Expand Down
4 changes: 2 additions & 2 deletions src/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ MainWindow::MainWindow(ConfigManager *cfManager, QWidget *parent)
connect(pfWindow->ui->highlightThemeCombo, &QComboBox::currentTextChanged,
[&](const QString &ctname) {
plainTextEdit->setEditorColorTheme(ctname);
configManager->setColorTheme(ctname);
configManager->setEditorColorTheme(ctname);
});

// User accepted, so change the `settings`.
Expand All @@ -120,7 +120,7 @@ MainWindow::MainWindow(ConfigManager *cfManager, QWidget *parent)
// Restore TextEditor
plainTextEdit->setEditorFont(configManager->getEditorFontFamily());
plainTextEdit->setEditorFontSize(configManager->getEditorFontSize());
plainTextEdit->setEditorColorTheme(configManager->getColorTheme());
plainTextEdit->setEditorColorTheme(configManager->getEditorColorTheme());

// Restore MainWindow
QApplication::setStyle(
Expand Down
2 changes: 1 addition & 1 deletion src/ui/preferenceswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ void PreferencesWindow::resetAllValues(const bool isFirst)
ui->themeCombo->setCurrentText(configManager->getStyleTheme());
ui->fontComboBox->setCurrentFont(QFont(configManager->getEditorFontFamily()));
ui->spinBox->setValue(configManager->getEditorFontSize());
ui->highlightThemeCombo->setCurrentText(configManager->getColorTheme());
ui->highlightThemeCombo->setCurrentText(configManager->getEditorColorTheme());
}

0 comments on commit 7cd8b62

Please sign in to comment.