mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 19:11:39 -06:00
Support for dark themes in default settings and restore defaults button
All the colour configurations have been reviewed under an operating-system theme dark theme. Some hard-coded colours in QScintilla editors and Data Browser have been replaced by queries of the system palette or reuse of our settings. New settings for foreground and background colours for QScintilla editors defaulting to system colours. This is mainly needed because if the user saves colour settings for a dark theme and then he changes the system theme back to a light theme, then the foreground colours are preserved while the background would fall back to the system theme leading to an incompatible combination. This also gives more freedom to the user in defining his own colour combinations. Since only the default colour settings adapt to the system theme, and once settings are saved this can no longer happen, a 'Restore Defaults' button is added so the default adapted colour settings can be restored. This is also useful for restoring default behaviour when wanted. Other fixes and improvements: waiting cursor while saving; check boxes in SQL tab for bold, italic and underline when applicable; avoid translation of hidden colour setting names used in code. See related issue #1324.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <QShortcut>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QPalette>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
@@ -99,6 +100,17 @@ void ExtendedScintilla::setupSyntaxHighlightingFormat(QsciLexer *lexer, const QS
|
||||
lexer->setFont(font, style);
|
||||
}
|
||||
|
||||
void ExtendedScintilla::setLexer(QsciLexer *lexer)
|
||||
{
|
||||
QsciScintilla::setLexer(lexer);
|
||||
|
||||
// Set margins to system window theme. setLexer seems to reset these colours.
|
||||
setMarginsBackgroundColor(QPalette().color(QPalette::Active, QPalette::Window));
|
||||
setMarginsForegroundColor(QPalette().color(QPalette::Active, QPalette::WindowText));
|
||||
setIndentationGuidesBackgroundColor(QPalette().color(QPalette::Active, QPalette::Window));
|
||||
setIndentationGuidesForegroundColor(QPalette().color(QPalette::Active, QPalette::WindowText));
|
||||
}
|
||||
|
||||
void ExtendedScintilla::reloadKeywords()
|
||||
{
|
||||
// Set lexer again to reload the updated keywords list
|
||||
@@ -115,9 +127,11 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
|
||||
QFont defaultfont(Settings::getValue("editor", "font").toString());
|
||||
defaultfont.setStyleHint(QFont::TypeWriter);
|
||||
defaultfont.setPointSize(Settings::getValue("editor", "fontsize").toInt());
|
||||
lexer->setDefaultColor(Qt::black);
|
||||
lexer->setFont(defaultfont);
|
||||
|
||||
lexer->setDefaultColor(QColor(Settings::getValue("syntaxhighlighter", "foreground_colour").toString()));
|
||||
lexer->setPaper(QColor(Settings::getValue("syntaxhighlighter", "background_colour").toString()));
|
||||
|
||||
// Set font
|
||||
QFont font(Settings::getValue("editor", "font").toString());
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
@@ -129,12 +143,13 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
|
||||
marginsfont.setPointSize(font.pointSize());
|
||||
setMarginsFont(marginsfont);
|
||||
setMarginLineNumbers(0, true);
|
||||
setMarginsBackgroundColor(Qt::lightGray);
|
||||
|
||||
updateLineNumberAreaWidth();
|
||||
|
||||
// Highlight current line
|
||||
setCaretLineVisible(true);
|
||||
setCaretLineBackgroundColor(QColor(Settings::getValue("syntaxhighlighter", "currentline_colour").toString()));
|
||||
setCaretForegroundColor(QColor(Settings::getValue("syntaxhighlighter", "foreground_colour").toString()));
|
||||
|
||||
// Set tab width
|
||||
setTabWidth(Settings::getValue("editor", "tabsize").toInt());
|
||||
|
||||
Reference in New Issue
Block a user