From 00da09199bf35237ccc9c6bdec1ad949e7905bbc Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 27 Jan 2022 21:27:51 +0800 Subject: [PATCH] refine code completion ui --- .../iconsets/newlook/classparser/enum.svg | 4 ++-- RedPandaIDE/themes/default.json | 2 ++ RedPandaIDE/widgets/codecompletionpopup.cpp | 15 +++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/RedPandaIDE/resources/iconsets/newlook/classparser/enum.svg b/RedPandaIDE/resources/iconsets/newlook/classparser/enum.svg index 3840594b..5c395342 100644 --- a/RedPandaIDE/resources/iconsets/newlook/classparser/enum.svg +++ b/RedPandaIDE/resources/iconsets/newlook/classparser/enum.svg @@ -51,7 +51,7 @@ ry="7.9375" /> + style="font-style:normal;font-weight:normal;font-size:28.2222px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.241984" + d="m 8.9892087,3.448301 c -1.4690741,6.5274719 -2.9402539,13.05445 -4.4080035,19.582233 4.4021168,0 8.8042328,0 13.2063498,0 0.234096,-1.04466 0.470019,-2.088894 0.706411,-3.133013 -3.252433,0 -6.504867,0 -9.7572991,0 0.4662306,-2.066391 0.9324626,-4.132782 1.3986931,-6.199173 3.251844,0 6.503689,0 9.755534,0 0.236892,-1.039923 0.472135,-2.080239 0.708176,-3.120365 -3.252433,0 -6.504867,0 -9.7573,0 0.325538,-1.4580979 0.651076,-2.9161955 0.976613,-4.3742931 3.252434,0 6.504867,0 9.7573,0 0.23353,-1.0452572 0.471382,-2.0894991 0.704645,-3.1348195 -4.402117,-1e-7 -8.804233,0 -13.20635,0 C 9.045722,3.1953473 9.017465,3.3218242 8.9892087,3.448301 Z" /> diff --git a/RedPandaIDE/themes/default.json b/RedPandaIDE/themes/default.json index ced14f2e..0f6f5dd4 100644 --- a/RedPandaIDE/themes/default.json +++ b/RedPandaIDE/themes/default.json @@ -3,5 +3,7 @@ "isDark":false, "default scheme": "Intellij Classic", "palette": { + "PaletteHighlight":"#ffdddddd", + "PaletteHighlightedText":"#ff000000" } } diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index 9487048e..11843ec5 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -126,7 +126,7 @@ bool CodeCompletionPopup::search(const QString &memberPhrase, bool autoHideOnSin mDelegate->setNormalColor(item->foreground()); else mDelegate->setNormalColor(palette().color(QPalette::Text)); - item = mColors->value(StatementKind::skLocalVariable,PColorSchemeItem()); + item = mColors->value(StatementKind::skKeyword,PColorSchemeItem()); if (item) mDelegate->setMatchedColor(item->foreground()); else @@ -1006,13 +1006,16 @@ void CodeCompletionListItemDelegate::paint(QPainter *painter, const QStyleOption PStatement statement; if (mModel && (statement = mModel->statement(index)) ) { painter->save(); - if (option.state & QStyle::State_Selected) + QColor normalColor = mNormalColor; + if (option.state & QStyle::State_Selected) { painter->fillRect(option.rect, option.palette.highlight()); + normalColor = option.palette.color(QPalette::HighlightedText); + } QPixmap icon = mModel->statementIcon(index); int x=option.rect.left(); if (!icon.isNull()) { - painter->drawPixmap(x,option.rect.top()+(option.rect.height()-icon.height())/2,icon); - x+=icon.width(); + painter->drawPixmap(x+(option.rect.height()-icon.width())/2,option.rect.top()+(option.rect.height()-icon.height())/2,icon); + x+=option.rect.height(); } QString text = statement->command; int pos=0; @@ -1020,7 +1023,7 @@ void CodeCompletionListItemDelegate::paint(QPainter *painter, const QStyleOption foreach (const PStatementMathPosition& matchPosition, statement->matchPositions) { if (posstart) { QString t = text.mid(pos,matchPosition->start-pos); - painter->setPen(mNormalColor); + painter->setPen(normalColor); painter->drawText(x,y,t); x+=painter->fontMetrics().horizontalAdvance(t); } @@ -1032,7 +1035,7 @@ void CodeCompletionListItemDelegate::paint(QPainter *painter, const QStyleOption } if (possetPen(mNormalColor); + painter->setPen(normalColor); painter->drawText(x,y,t); x+=painter->fontMetrics().horizontalAdvance(t); }