detectTheme

This commit is contained in:
2024-01-18 17:42:57 +03:00
parent ccf17510d8
commit 2739cc53ec
2 changed files with 8 additions and 1 deletions

View File

@@ -548,6 +548,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
void QCodeEdit::showEvent(QShowEvent *) { void QCodeEdit::showEvent(QShowEvent *) {
detectTheme();
if (!_first) return; if (!_first) return;
_first = false; _first = false;
completer->installEventFilter(this); completer->installEventFilter(this);
@@ -584,7 +585,7 @@ void QCodeEdit::changeEvent(QEvent * e) {
ui->retranslateUi(this); ui->retranslateUi(this);
lbl_help[lhF1]->setText(tr("Press F1 for details")); lbl_help[lhF1]->setText(tr("Press F1 for details"));
break; break;
case QEvent::PaletteChange: is_dark_theme = palette().color(QPalette::Window).valueF() < 0.5; break; case QEvent::PaletteChange: detectTheme(); break;
default: break; default: break;
} }
} }
@@ -1716,6 +1717,11 @@ QCodeEdit::ACEntry QCodeEdit::findEntryOnCursor(QTextCursor tc, int arg, ACClass
} }
void QCodeEdit::detectTheme() {
is_dark_theme = palette().color(QPalette::Window).valueF() < 0.5;
}
void QCodeEdit::raiseHelp(QTextCursor tc, int arg) { void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
ACClass acc; ACClass acc;
QPair<QStringList, QString> scope; QPair<QStringList, QString> scope;

View File

@@ -230,6 +230,7 @@ private:
void createBlockSelection(); void createBlockSelection();
void cancelDragCursor(); void cancelDragCursor();
ACEntry findEntryOnCursor(QTextCursor tc, int arg = -1, ACClass * acc = nullptr, QPair<QStringList, QString> * scope = nullptr); ACEntry findEntryOnCursor(QTextCursor tc, int arg = -1, ACClass * acc = nullptr, QPair<QStringList, QString> * scope = nullptr);
void detectTheme();
Ui::QCodeEdit * ui; Ui::QCodeEdit * ui;
QCodeEditCompleter * completer; QCodeEditCompleter * completer;