- fix: Custom editor colors shouldn't be tested for high contrast with the default background color

- fix: Custom color settings not correctly displayed in the options widget
 - enhancement: add hit counts in the search result view
 - fix: editor actions' state not correctly updated after close editors.
 - fix: When replace in the editor, "Yes to All" and "No" button doesn't work correctly.
 - fix: crash when editing non-c/c++ files
 - enhancement: set the alpha value of scheme colors
 - enhancement: can use symbols' own scheme color to draw selection
 - enhancement: can use different colors to highlight the current word and the selections
This commit is contained in:
royqh1979@gmail.com 2021-11-03 18:09:12 +08:00
parent d297faf3af
commit 6ad87990c7
13 changed files with 246 additions and 128 deletions

View File

@ -8,6 +8,11 @@ Version 0.7.8
- fix: Custom color settings not correctly displayed in the options widget
- enhancement: add hit counts in the search result view
- fix: editor actions' state not correctly updated after close editors.
- fix: When replace in the editor, "Yes to All" and "No" button doesn't work correctly.
- fix: crash when editing non-c/c++ files
- enhancement: set the alpha value of scheme colors
- enhancement: can use symbols' own scheme color to draw selection
- enhancement: can use different colors to highlight the current word and the selections
Version 0.7.7
- enhancement: Problem Set

View File

@ -60,6 +60,14 @@ PColorScheme ColorScheme::load(const QString &filename)
return ColorScheme::fromJson(doc.object());
}
void ColorScheme::addItem(const QString& name)
{
if (mItems.contains(name))
return;
PColorSchemeItem item = std::make_shared<ColorSchemeItem>();
mItems[name]=item;
}
QMap<QString, PColorSchemeItem> ColorScheme::items()
{
return mItems;
@ -220,12 +228,12 @@ PColorSchemeItem ColorSchemeItem::fromJson(const QJsonObject &json)
void ColorSchemeItem::toJson(QJsonObject &json)
{
if (mForeground.isValid()) {
json["foreground"] = mForeground.name();
json["foreground"] = mForeground.name(QColor::HexArgb);
} else if (json.contains("foreground")){
json.remove("foreground");
}
if (mBackground.isValid()) {
json["background"] = mBackground.name();
json["background"] = mBackground.name(QColor::HexArgb);
} else if (json.contains("background")){
json.remove("background");
}
@ -503,6 +511,10 @@ void ColorManager::initItemDefines()
QObject::tr("Gutter"),
QObject::tr("Editor"),
true,true,true);
addDefine(COLOR_SCHEME_GUTTER_ACTIVE_LINE,
QObject::tr("Gutter Active Line"),
QObject::tr("Editor"),
true,false,false);
//Active Line
addDefine(COLOR_SCHEME_ACTIVE_LINE,
QObject::tr("Active Line"),
@ -528,6 +540,17 @@ void ColorManager::initItemDefines()
QObject::tr("Selection"),
QObject::tr("Editor"),
true,true,false);
addDefine(COLOR_SCHEME_TEXT,
QObject::tr("Editor Text"),
QObject::tr("Editor"),
true,true,false);
addDefine(COLOR_SCHEME_CURRENT_HIGHLIGHTED_WORD,
QObject::tr("Current Highlighted Word"),
QObject::tr("Editor"),
true,true,false);
//Syntax Error
addDefine(COLOR_SCHEME_ERROR,
QObject::tr("Error"),

View File

@ -11,7 +11,10 @@
#define COLOR_SCHEME_ERROR "Error"
#define COLOR_SCHEME_ACTIVE_BREAKPOINT "Active Breakpoint"
#define COLOR_SCHEME_GUTTER "Gutter"
#define COLOR_SCHEME_GUTTER_ACTIVE_LINE "Gutter Active Line"
#define COLOR_SCHEME_SELECTION "Selected text"
#define COLOR_SCHEME_TEXT "Editor Text"
#define COLOR_SCHEME_CURRENT_HIGHLIGHTED_WORD "Current Highlighted Word"
#define COLOR_SCHEME_FOLD_LINE "Fold Line"
#define COLOR_SCHEME_ACTIVE_LINE "Active Line"
#define COLOR_SCHEME_WARNING "Warning"
@ -69,6 +72,8 @@ public:
static PColorScheme load(const QString& filename);
void addItem(const QString& name);
QMap<QString,PColorSchemeItem> items();
static PColorScheme fromJson(const QJsonObject& json);

View File

@ -113,7 +113,6 @@
},
"Space" : {
"foreground" : "#505050",
"background" : "#1E1E1E",
"bold" : false,
"italic" : false,
"underlined" : false,
@ -140,14 +139,23 @@
"underlined" : false,
"strikeout" : false
},
"Editor Text": {
"foreground" : "#ffffff",
"background" : "#1E1E1E"
},
"Current Highlighted Word": {
"background": "#50ffffff"
},
"Selected text" : {
"foreground" : "#000000",
"background" : "#808080"
"background" : "#3c55aaff"
},
"Gutter" : {
"foreground" : "#858585",
"background" : "#1E1E1E"
},
"Gutter Active Line" : {
"foreground" : "#C0C0C0"
},
"Breakpoint" : {
},
"Error" : {

View File

@ -74,8 +74,8 @@ Editor::Editor(QWidget *parent, const QString& filename,
mLastIdCharPressed(0),
mCurrentWord(),
mCurrentTipType(TipType::None),
mOldSelectionWord(),
mSelectionWord(),
mOldHighlightedWord(),
mCurrentHighlightedWord(),
mSaving(false)
{
mUseCppSyntax = pSettings->editor().defaultFileCpp();
@ -855,37 +855,6 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
{
if (token.isEmpty())
return;
//selection
if (selAvail() && highlighter()) {
if ((
(attr == highlighter()->identifierAttribute())
|| (attr == highlighter()->keywordAttribute())
|| (attr->name() == SYNS_AttrPreprocessor)
)
&& (token == mSelectionWord)) {
foreground = selectedForeground();
background = selectedBackground();
return;
}
}
if (!selAvail() && attr->name() == SYNS_AttrSymbol) {
// qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char;
if ( (line == mHighlightCharPos1.Line)
&& (aChar == mHighlightCharPos1.Char)) {
foreground = selectedForeground();
background = selectedBackground();
return;
}
if ((line == mHighlightCharPos2.Line)
&& (aChar == mHighlightCharPos2.Char)) {
foreground = selectedForeground();
background = selectedBackground();
return;
}
}
// qDebug()<<token<<"-"<<attr->name()<<" - "<<line<<" : "<<aChar;
if (mParser && (attr == highlighter()->identifierAttribute())) {
@ -918,7 +887,43 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
} else {
foreground = highlighter()->identifierAttribute()->foreground();
}
return;
}
//selection
if (highlighter()) {
if ((
(attr == highlighter()->identifierAttribute())
|| (attr == highlighter()->keywordAttribute())
|| (attr->name() == SYNS_AttrPreprocessor)
)
&& (token == mCurrentHighlightedWord)) {
if (mCurrentHighlighWordForeground.isValid())
foreground = mCurrentHighlighWordForeground;
if (mCurrentHighlighWordBackground.isValid())
background = mCurrentHighlighWordBackground;
}
} else if (token == mCurrentHighlightedWord) {
if (mCurrentHighlighWordForeground.isValid())
foreground = mCurrentHighlighWordForeground;
if (mCurrentHighlighWordBackground.isValid())
background = mCurrentHighlighWordBackground;
} else if (!selAvail() && attr->name() == SYNS_AttrSymbol) {
// qDebug()<<line<<":"<<aChar<<" - "<<mHighlightCharPos1.Line<<":"<<mHighlightCharPos1.Char<<" - "<<mHighlightCharPos2.Line<<":"<<mHighlightCharPos2.Char;
if ( (line == mHighlightCharPos1.Line)
&& (aChar == mHighlightCharPos1.Char)) {
if (mCurrentHighlighWordForeground.isValid())
foreground = mCurrentHighlighWordForeground;
if (mCurrentHighlighWordBackground.isValid())
background = mCurrentHighlighWordBackground;
}
if ((line == mHighlightCharPos2.Line)
&& (aChar == mHighlightCharPos2.Char)) {
if (mCurrentHighlighWordForeground.isValid())
foreground = mCurrentHighlighWordForeground;
if (mCurrentHighlighWordBackground.isValid())
background = mCurrentHighlighWordBackground;
}
}
}
@ -1436,31 +1441,32 @@ void Editor::onStatusChanged(SynStatusChanges changes)
// scSelection includes anything caret related
if (changes.testFlag(SynStatusChange::scSelection)) {
mSelectionWord="";
if (selAvail()) {
BufferCoord wordBegin,wordEnd,bb,be;
bb = blockBegin();
be = blockEnd();
wordBegin = wordStartEx(bb);
wordEnd = wordEndEx(be);
if (wordBegin.Line == bb.Line
&& wordBegin.Char == bb.Char
&& wordEnd.Line == be.Line
&& wordEnd.Char == be.Char) {
if (wordBegin.Line>=1 && wordBegin.Line<=lines()->count()) {
QString line = lines()->getString(wordBegin.Line-1);
mSelectionWord = line.mid(wordBegin.Char-1,wordEnd.Char-wordBegin.Char);
}
}
// qDebug()<<QString("(%1,%2)").arg(bb.Line).arg(bb.Char)
// <<" - "<<QString("(%1,%2)").arg(be.Line).arg(be.Char)
// <<" - "<<QString("(%1,%2)").arg(wordBegin.Line).arg(wordBegin.Char)
// <<" - "<<QString("(%1,%2)").arg(wordEnd.Line).arg(wordEnd.Char)
// <<" : "<<mSelectionWord;
}
if (mOldSelectionWord != mSelectionWord) {
mCurrentHighlightedWord = wordAtCursor();
// mSelectionWord="";
// if (selAvail()) {
// BufferCoord wordBegin,wordEnd,bb,be;
// bb = blockBegin();
// be = blockEnd();
// wordBegin = wordStartEx(bb);
// wordEnd = wordEndEx(be);
// if (wordBegin.Line == bb.Line
// && wordBegin.Char == bb.Char
// && wordEnd.Line == be.Line
// && wordEnd.Char == be.Char) {
// if (wordBegin.Line>=1 && wordBegin.Line<=lines()->count()) {
// QString line = lines()->getString(wordBegin.Line-1);
// mSelectionWord = line.mid(wordBegin.Char-1,wordEnd.Char-wordBegin.Char);
// }
// }
//// qDebug()<<QString("(%1,%2)").arg(bb.Line).arg(bb.Char)
//// <<" - "<<QString("(%1,%2)").arg(be.Line).arg(be.Char)
//// <<" - "<<QString("(%1,%2)").arg(wordBegin.Line).arg(wordBegin.Char)
//// <<" - "<<QString("(%1,%2)").arg(wordEnd.Line).arg(wordEnd.Char)
//// <<" : "<<mSelectionWord;
// }
if (mOldHighlightedWord != mCurrentHighlightedWord) {
invalidate();
mOldSelectionWord = mSelectionWord;
mOldHighlightedWord = mCurrentHighlightedWord;
}
pMainWindow->updateStatusbarForLineCol();
@ -3742,6 +3748,10 @@ void Editor::applyColorScheme(const QString& schemeName)
gutter().setTextColor(item->foreground());
gutter().setColor(item->background());
}
item = pColorManager->getItem(schemeName,COLOR_SCHEME_GUTTER_ACTIVE_LINE);
if (item) {
gutter().setActiveLineTextColor(item->foreground());
}
item = pColorManager->getItem(schemeName,COLOR_SCHEME_FOLD_LINE);
if (item) {
codeFolding().folderBarLinesColor = item->foreground();
@ -3762,6 +3772,9 @@ void Editor::applyColorScheme(const QString& schemeName)
if (item) {
setSelectedForeground(item->foreground());
setSelectedBackground(item->background());
} else {
this->setForegroundColor(palette().color(QPalette::HighlightedText));
this->setBackgroundColor(palette().color(QPalette::Highlight));
}
item = pColorManager->getItem(schemeName,COLOR_SCHEME_ACTIVE_BREAKPOINT);
if (item) {
@ -3773,6 +3786,23 @@ void Editor::applyColorScheme(const QString& schemeName)
this->mBreakpointForegroundColor = item->foreground();
this->mBreakpointBackgroundColor = item->background();
}
item = pColorManager->getItem(schemeName,COLOR_SCHEME_TEXT);
if (item) {
this->setForegroundColor(item->foreground());
this->setBackgroundColor(item->background());
} else {
this->setForegroundColor(palette().color(QPalette::Text));
this->setBackgroundColor(palette().color(QPalette::Base));
}
item = pColorManager->getItem(schemeName,COLOR_SCHEME_CURRENT_HIGHLIGHTED_WORD);
if (item) {
mCurrentHighlighWordForeground = item->foreground();
mCurrentHighlighWordBackground = item->background();
} else {
mCurrentHighlighWordForeground = selectedForeground();
mCurrentHighlighWordBackground = selectedBackground();
}
this->invalidate();
}

View File

@ -243,6 +243,8 @@ private:
QColor mActiveBreakpointBackgroundColor;
QColor mBreakpointForegroundColor;
QColor mBreakpointBackgroundColor;
QColor mCurrentHighlighWordForeground;
QColor mCurrentHighlighWordBackground;
int mSyntaxErrorLine;
int mLineCount;
int mGutterClickedLine;
@ -257,8 +259,8 @@ private:
QString mCurrentWord;
QString mCurrentDebugTipWord;
TipType mCurrentTipType;
QString mOldSelectionWord;
QString mSelectionWord;
QString mOldHighlightedWord;
QString mCurrentHighlightedWord;
bool mSaving;

View File

@ -56,6 +56,16 @@ void SynGutter::setChanged()
emit changed();
}
const QColor &SynGutter::activeLineTextColor() const
{
return mActiveLineTextColor;
}
void SynGutter::setActiveLineTextColor(const QColor &newActiveLineTextColor)
{
mActiveLineTextColor = newActiveLineTextColor;
}
QColor SynGutter::textColor() const
{
return mTextColor;

View File

@ -76,6 +76,9 @@ public:
QColor textColor() const;
void setTextColor(const QColor &value);
const QColor &activeLineTextColor() const;
void setActiveLineTextColor(const QColor &newActiveLineTextColor);
signals:
void changed();
private:
@ -84,6 +87,7 @@ private:
bool mAutoSize;
QColor mBorderColor;
QColor mTextColor;
QColor mActiveLineTextColor;
QColor mColor;
int mDigitCount;
QFont mFont;

View File

@ -1077,7 +1077,7 @@ void SynEdit::processGutterClick(QMouseEvent *event)
rect.setLeft(mGutterWidth - mGutter.rightOffset());
rect.setRight(rect.left() + mGutter.rightOffset() - 4);
rect.setTop((RowColumn.Row - mTopLine) * mTextHeight);
rect.setBottom(rect.top() + mTextHeight);
rect.setBottom(rect.top() + mTextHeight - 1);
if (rect.contains(QPoint(X, Y))) {
if (FoldRange->collapsed)
uncollapse(FoldRange);
@ -3081,6 +3081,8 @@ int SynEdit::scanFrom(int Index, int canStopIndex)
void SynEdit::rescanRange(int line)
{
if (!mHighlighter)
return;
line--;
line = std::max(0,line);
if (line >= mLines->count())
@ -3507,7 +3509,7 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip)
ct =mOverwriteCaret;
}
if (mCaretUseTextColor) {
painter.setPen(palette().color(QPalette::Text));
painter.setPen(mForegroundColor);
} else {
painter.setPen(mCaretColor);
}
@ -3592,6 +3594,26 @@ void SynEdit::onScrolled(int)
invalidate();
}
const QColor &SynEdit::backgroundColor() const
{
return mBackgroundColor;
}
void SynEdit::setBackgroundColor(const QColor &newBackgroundColor)
{
mBackgroundColor = newBackgroundColor;
}
const QColor &SynEdit::foregroundColor() const
{
return mForegroundColor;
}
void SynEdit::setForegroundColor(const QColor &newForegroundColor)
{
mForegroundColor = newForegroundColor;
}
int SynEdit::mouseWheelScrollSpeed() const
{
return mMouseWheelScrollSpeed;
@ -4698,6 +4720,8 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
doOnPaintTransient(SynTransientType::ttAfter);
});
int i;
// If it's a search only we can leave the procedure now.
SynSearchAction searchAction = SynSearchAction::Exit;
while ((ptCurrent.Line >= ptStart.Line) && (ptCurrent.Line <= ptEnd.Line)) {
int nInLine = searchEngine->findAll(mLines->getString(ptCurrent.Line - 1));
int iResultOffset = 0;
@ -4748,8 +4772,7 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
internalSetCaretXY(blockBegin());
else
internalSetCaretXY(ptCurrent);
// If it's a search only we can leave the procedure now.
SynSearchAction searchAction = SynSearchAction::Exit;
QString replaceText = searchEngine->replace(selText(), sReplace);
if (matchedCallback && !dobatchReplace) {
searchAction = matchedCallback(sSearch,replaceText,ptCurrent.Line,

View File

@ -376,6 +376,12 @@ public:
int mouseWheelScrollSpeed() const;
void setMouseWheelScrollSpeed(int newMouseWheelScrollSpeed);
const QColor &foregroundColor() const;
void setForegroundColor(const QColor &newForegroundColor);
const QColor &backgroundColor() const;
void setBackgroundColor(const QColor &newBackgroundColor);
signals:
void linesDeleted(int FirstLine, int Count);
void linesInserted(int FirstLine, int Count);
@ -610,6 +616,8 @@ private:
PSynHighlighter mHighlighter;
QColor mSelectedForeground;
QColor mSelectedBackground;
QColor mForegroundColor;
QColor mBackgroundColor;
QColor mCaretColor;
PSynHighlighterAttribute mRainbowAttr0;
PSynHighlighterAttribute mRainbowAttr1;

View File

@ -16,6 +16,7 @@ SynEditTextPainter::SynEditTextPainter(SynEdit *edit, QPainter *painter, int Fir
void SynEditTextPainter::paintTextLines(const QRect& clip)
{
painter->fillRect(clip, edit->mBackgroundColor);
AClip = clip;
vFirstLine = edit->rowToLine(aFirstRow);
vLastLine = edit->rowToLine(aLastRow);
@ -81,14 +82,6 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
AClip = clip;
//todo: Does the following comment still apply?
// Changed to use fTextDrawer.BeginDrawing and fTextDrawer.EndDrawing only
// when absolutely necessary. Note: Never change brush / pen / font of the
// canvas inside of this block (only through methods of fTextDrawer)!
// If we have to draw the line numbers then we don't want to erase
// the background first. Do it line by line with TextRect instead
// and fill only the area after the last visible line.
//painter->setClipRect(AClip);
painter->fillRect(AClip,edit->mGutter.color());
rcLine=AClip;
@ -108,16 +101,22 @@ void SynEditTextPainter::paintGutter(const QRect& clip)
newFont.setUnderline(false);
painter->setFont(newFont);
}
QColor textColor;
if (edit->mGutter.textColor().isValid()) {
painter->setPen(edit->mGutter.textColor());
textColor = edit->mGutter.textColor();
} else {
painter->setPen(edit->palette().color(QPalette::Text));
textColor = edit->mForegroundColor;
}
// draw each line if it is not hidden by a fold
for (int cRow = aFirstRow; cRow <= aLastRow; cRow++) {
vLine = edit->rowToLine(cRow);
if ((vLine > edit->mLines->count()) && (edit->mLines->count() > 0 ))
break;
if (edit->mCaretY==vLine && edit->mGutter.activeLineTextColor().isValid()) {
painter->setPen(edit->mGutter.activeLineTextColor());
} else {
painter->setPen(textColor);
}
vLineTop = (cRow - edit->mTopLine) * edit->mTextHeight;
// next line rect
@ -270,14 +269,8 @@ QColor SynEditTextPainter::colEditorBG()
if (edit->mActiveLineColor.isValid() && bCurrentLine) {
return edit->mActiveLineColor;
} else {
if (edit->mHighlighter) {
PSynHighlighterAttribute attr = edit->mHighlighter->whitespaceAttribute();
if (attr && attr->background().isValid()) {
return attr->background();
}
}
return edit->mBackgroundColor;
}
return edit->palette().color(QPalette::Base);
}
void SynEditTextPainter::ComputeSelectionInfo()
@ -351,13 +344,19 @@ void SynEditTextPainter::ComputeSelectionInfo()
void SynEditTextPainter::setDrawingColors(bool Selected)
{
if (Selected) {
painter->setPen(colSelFG);
painter->setBrush(colSelBG);
painter->setBackground(colSelBG);
if (colSelFG.isValid())
painter->setPen(colSelFG);
else
painter->setPen(colFG);
if (colSelBG.isValid())
painter->setBrush(colSelBG);
else
painter->setBrush(colBG);
painter->setBackground(edit->mBackgroundColor);
} else {
painter->setPen(colFG);
painter->setBrush(colBG);
painter->setBackground(colBG);
painter->setBackground(edit->mBackgroundColor);
}
}
@ -376,7 +375,9 @@ void SynEditTextPainter::PaintToken(const QString &Token, int TokenCols, int Col
nX = ColumnToXValue(First);
First -= ColumnsBefore;
Last -= ColumnsBefore;
painter->fillRect(rcToken,painter->brush());
QRect rcTokenBack = rcToken;
rcTokenBack.setWidth(rcTokenBack.width()-1);
painter->fillRect(rcTokenBack,painter->brush());
if (First > TokenCols) {
} else {
int tokenColLen=0;
@ -588,8 +589,6 @@ void SynEditTextPainter::AddHighlightToken(const QString &Token, int ColumnsBefo
SynFontStyles Style;
bool bSpacesTest,bIsSpaces;
// qDebug()<<"Add highlight token"<<Token<<ColumnsBefore<<TokenColumns<<cLine;
if (p_Attri) {
Foreground = p_Attri->foreground();
Background = p_Attri->background();
@ -604,7 +603,7 @@ void SynEditTextPainter::AddHighlightToken(const QString &Token, int ColumnsBefo
Background = colEditorBG();
}
if (!Foreground.isValid()) {
Foreground = edit->palette().color(QPalette::Text);
Foreground = edit->mForegroundColor;
}
edit->onPreparePaintHighlightToken(cLine,edit->mHighlighter->getTokenPos()+1,
@ -618,7 +617,7 @@ void SynEditTextPainter::AddHighlightToken(const QString &Token, int ColumnsBefo
if (TokenAccu.Style == Style || ( (Style & SynFontStyle::fsUnderline) == (TokenAccu.Style & fsUnderline)
&& TokenIsSpaces(bSpacesTest,Token,bIsSpaces)) ) {
// either special colors or same colors
if ((bSpecialLine && !(edit->mOptions.testFlag(SynEditorOption::eoSpecialLineDefaultFg))) || bLineSelected ||
if ((bSpecialLine && !(edit->mOptions.testFlag(SynEditorOption::eoSpecialLineDefaultFg))) ||
// background color must be the same and
((TokenAccu.BG == Background) &&
// foreground color must be the same or token is only spaces
@ -819,14 +818,8 @@ void SynEditTextPainter::PaintLines()
colBG = colEditorBG();
bSpecialLine = edit->onGetSpecialLineColors(vLine, colFG, colBG);
if (bSpecialLine) {
// The selection colors are just swapped, like seen in Delphi.
colSelFG = colBG;
colSelBG = colFG;
} else {
colSelFG = edit->mSelectedForeground;
colSelBG = edit->mSelectedBackground;
}
colSelFG = edit->mSelectedForeground;
colSelBG = edit->mSelectedBackground;
edit->onGetEditingAreas(vLine, areaList);
// Removed word wrap support
vFirstChar = FirstCol;
@ -867,8 +860,10 @@ void SynEditTextPainter::PaintLines()
} //endif bAnySelection
// Update the rcLine rect to this line.
rcLine.setTop(rcLine.bottom());
rcLine.setBottom(rcLine.bottom()+edit->mTextHeight);
// rcLine.setTop(rcLine.bottom());
// rcLine.setBottom(rcLine.bottom()+edit->mTextHeight);
rcLine.setTop((cRow - edit->mTopLine) * edit->mTextHeight);
rcLine.setHeight(edit->mTextHeight);
bLineSelected = (!bComplexLine) && (nLineSelStart > 0);
rcToken = rcLine;

View File

@ -189,29 +189,33 @@ void EditorColorSchemeWidget::onItemSelectionChanged()
ui->colorForeground->setEnabled(define->hasForeground());
ui->grpFontStyles->setEnabled(define->hasFontStyle());
PColorSchemeItem item = pColorManager->getItem(ui->cbScheme->currentText(), name);
if (item) {
if (define->hasBackground()) {
setColorProp(ui->colorBackground, ui->cbBackground,item->background());
} else {
setColorProp(ui->colorBackground, ui->cbBackground,QColor());
}
if (define->hasForeground()) {
setColorProp(ui->colorForeground, ui->cbForeground,item->foreground());
} else {
setColorProp(ui->colorForeground, ui->cbForeground,QColor());
}
if (define->hasFontStyle()) {
ui->cbBold->setChecked(item->bold());
ui->cbItalic->setChecked(item->italic());
ui->cbUnderlined->setChecked(item->underlined());
ui->cbStrikeout->setChecked(item->strikeout());
} else {
ui->cbBold->setChecked(false);
ui->cbItalic->setChecked(false);
ui->cbUnderlined->setChecked(false);
ui->cbStrikeout->setChecked(false);
if (!item) {
PColorScheme scheme = pColorManager->get(ui->cbScheme->currentText());
if (scheme) {
scheme->addItem(name);
}
}
if (define->hasBackground() && item) {
setColorProp(ui->colorBackground, ui->cbBackground,item->background());
} else {
setColorProp(ui->colorBackground, ui->cbBackground,QColor());
}
if (define->hasForeground() && item) {
setColorProp(ui->colorForeground, ui->cbForeground,item->foreground());
} else {
setColorProp(ui->colorForeground, ui->cbForeground,QColor());
}
if (define->hasFontStyle() && item) {
ui->cbBold->setChecked(item->bold());
ui->cbItalic->setChecked(item->italic());
ui->cbUnderlined->setChecked(item->underlined());
ui->cbStrikeout->setChecked(item->strikeout());
} else {
ui->cbBold->setChecked(false);
ui->cbItalic->setChecked(false);
ui->cbUnderlined->setChecked(false);
ui->cbStrikeout->setChecked(false);
}
}
}

View File

@ -73,7 +73,7 @@ void ColorEdit::paintEvent(QPaintEvent *)
painter.setBrush(palette().color(QPalette::Disabled,QPalette::Base));
}
painter.drawRect(rect);
painter.drawText(rect,Qt::AlignCenter, mColor.name());
painter.drawText(rect,Qt::AlignCenter, mColor.name(QColor::HexArgb));
} else {
//painter.fillRect(rect,palette().color(QPalette::Base));
if (isEnabled()) {
@ -92,7 +92,8 @@ void ColorEdit::paintEvent(QPaintEvent *)
void ColorEdit::mouseReleaseEvent(QMouseEvent *)
{
QColor c = QColorDialog::getColor();
QColor c = QColorDialog::getColor(mColor,nullptr,tr("Color"),
QColorDialog::ShowAlphaChannel | QColorDialog::DontUseNativeDialog);
if (c.isValid()) {
setColor(c);
}