code completion popup window use editor's background clor

This commit is contained in:
royqh1979 2021-11-04 00:54:20 +08:00
parent 731a10a1d6
commit c5105cfa43
2 changed files with 20 additions and 9 deletions

View File

@ -460,7 +460,6 @@ void MainWindow::updateEditorColorSchemes()
QString schemeName = pSettings->editor().colorScheme();
//color for code completion popup
PColorSchemeItem item;
item = pColorManager->getItem(schemeName, SYNS_AttrFunction);
QColor baseColor = palette().color(QPalette::Base);
if (item) {
@ -496,11 +495,12 @@ void MainWindow::updateEditorColorSchemes()
if (item) {
mStatementColors->insert(StatementKind::skPreprocessor,item);
mStatementColors->insert(StatementKind::skEnum,item);
if (haveGoodContrast(item->foreground(), baseColor)) {
mHeaderCompletionPopup->setSuggestionColor(item->foreground());
} else {
mHeaderCompletionPopup->setSuggestionColor(palette().color(QPalette::Text));
}
// if (haveGoodContrast(item->foreground(), baseColor)) {
// mHeaderCompletionPopup->setSuggestionColor(item->foreground());
// } else {
// mHeaderCompletionPopup->setSuggestionColor(palette().color(QPalette::Text));
// }
mHeaderCompletionPopup->setSuggestionColor(item->foreground());
} else {
mHeaderCompletionPopup->setSuggestionColor(palette().color(QPalette::Text));
}
@ -527,6 +527,18 @@ void MainWindow::updateEditorColorSchemes()
} else {
ui->tableIssues->setWarningColor(palette().color(QPalette::Text));
}
item = pColorManager->getItem(schemeName, COLOR_SCHEME_TEXT);
if (item) {
QPalette pal = palette();
pal.setColor(QPalette::Base,item->background());
pal.setColor(QPalette::Text,item->foreground());
mCompletionPopup->setPalette(pal);
mHeaderCompletionPopup->setPalette(pal);
} else {
QPalette pal = palette();
mCompletionPopup->setPalette(pal);
mHeaderCompletionPopup->setPalette(pal);
}
}
void MainWindow::applySettings()

View File

@ -25,7 +25,7 @@ CodeCompletionPopup::CodeCompletionPopup(QWidget *parent) :
kind = statement->kind;
}
PColorSchemeItem item = mColors->value(kind,PColorSchemeItem());
if (item && haveGoodContrast(item->foreground(),palette().color(QPalette::Base))) {
if (item) {
return item->foreground();
}
return palette().color(QPalette::Text);
@ -922,8 +922,7 @@ QVariant CodeCompletionListModel::data(const QModelIndex &index, int role) const
PStatement statement = mStatements->at(index.row());
if (mColorCallback)
return mColorCallback(statement);
QApplication *app = dynamic_cast<QApplication *>(QApplication::instance());
return app->palette().color(QPalette::Text);
return qApp->palette().color(QPalette::Text);
}
}
return QVariant();