line number, symtax highlight, initial dark theme
This commit is contained in:
@@ -109,7 +109,9 @@ void MainWindow::setupActions()
|
||||
lexerNoneAction->setText("None (Normal Text)");
|
||||
actionCollection()->addAction(u"lexer_none"_s, lexerNoneAction);
|
||||
connect(lexerNoneAction, &QAction::triggered, this, [this](){
|
||||
// m_editor->setLexer(nullptr);
|
||||
if (SciEdit *editor = m_tabWidget->currentEditor()) {
|
||||
editor->setLexer(nullptr);
|
||||
}
|
||||
});
|
||||
|
||||
for (const QChar & group : LexerGroupActionMenu::groups()) {
|
||||
@@ -167,6 +169,17 @@ void MainWindow::setupActions()
|
||||
// m_editor->setIndentationGuides(!m_editor->indentationGuides());
|
||||
});
|
||||
|
||||
QAction *toggleEditorDarkThemeAction = new QAction(this);
|
||||
toggleEditorDarkThemeAction->setText("Editor Dark Theme");
|
||||
toggleEditorDarkThemeAction->setCheckable(true);
|
||||
toggleEditorDarkThemeAction->setChecked(AppSettings::editorDarkTheme());
|
||||
actionCollection()->addAction(u"toggle_editor_dark_theme"_s, toggleEditorDarkThemeAction);
|
||||
connect(toggleEditorDarkThemeAction, &QAction::toggled, this, [this](bool checked){
|
||||
AppSettings::setEditorDarkTheme(checked);
|
||||
AppSettings::self()->save();
|
||||
applySettingsToAllEditors();
|
||||
});
|
||||
|
||||
// Load themes
|
||||
KColorSchemeManager *manager = KColorSchemeManager::instance();
|
||||
auto *colorSelectionMenu = KColorSchemeMenu::createMenu(manager, this);
|
||||
@@ -185,8 +198,12 @@ void MainWindow::showSettings()
|
||||
dialog->setFaceType(KPageDialog::FlatList);
|
||||
dialog->addPage(new SettingsPage<Ui::GeneralSettings>(dialog), "Appearance", "preferences-desktop-theme-global");
|
||||
|
||||
connect(dialog, &KConfigDialog::settingsChanged, this, [](const QString &dialogName){
|
||||
qDebug() << dialogName << "changed";
|
||||
connect(dialog, &KConfigDialog::settingsChanged, this, [this](const QString &dialogName){
|
||||
Q_UNUSED(dialogName)
|
||||
applySettingsToAllEditors();
|
||||
if (QAction *action = actionCollection()->action(QStringLiteral("toggle_editor_dark_theme"))) {
|
||||
action->setChecked(AppSettings::editorDarkTheme());
|
||||
}
|
||||
});
|
||||
|
||||
dialog->show();
|
||||
@@ -248,12 +265,30 @@ void MainWindow::onCurrentEditorChanged(SciEdit *editor)
|
||||
|
||||
// 连接当前编辑器的光标位置变化信号
|
||||
if (editor) {
|
||||
applySettingsToEditor(editor);
|
||||
connect(editor, &SciEdit::cursorPosChanged, this, [this](int line, int column) {
|
||||
m_cursorPosStatusLabel->setText(QString("Ln: %1 Col: %2").arg(line).arg(column));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::applySettingsToEditor(SciEdit *editor)
|
||||
{
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
editor->setTabWidth(AppSettings::tabWidth());
|
||||
editor->setEditorFont(AppSettings::editorFont());
|
||||
editor->applyTheme(AppSettings::editorDarkTheme());
|
||||
}
|
||||
|
||||
void MainWindow::applySettingsToAllEditors()
|
||||
{
|
||||
for (int i = 0; i < m_tabWidget->count(); ++i) {
|
||||
applySettingsToEditor(m_tabWidget->editorAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onDocumentModified(int docIndex, bool modified)
|
||||
{
|
||||
Q_UNUSED(docIndex)
|
||||
|
||||
Reference in New Issue
Block a user