Merge branch 'master' into gdbmi

# Conflicts:
#	RedPandaIDE/qsynedit/SynEdit.cpp
This commit is contained in:
royqh1979@gmail.com 2021-11-13 10:55:10 +08:00
commit c7748bf5b2
11 changed files with 129 additions and 104 deletions

View File

@ -1,6 +1,15 @@
Version 0.8.7 For Dev-C++ 7 Beta
- enhancement: auto indent line to column 1 when enter '#' at beginning of line
- fix: when enter '{' or '}' at beginning of line, auto indent will remove all contents of the line
- fix: auto indent should be turned off when reformat code
- fix: auto indent should be turned off when replace in code
Version 0.8.6 For Dev-C++ 7 Beta Version 0.8.6 For Dev-C++ 7 Beta
- enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 80m+) - enhancement: greatly reduces memory usage for symbol parsing ( memory needed for bits/stdc++.h reduced from 150m+ to 80m+)
- fix: currect compiler set not correctly updated when switch between normal file and project file - fix: currect compiler set not correctly updated when switch between normal file and project file
- fix: editor auto save settings not saved and applied
- fix: only auto save files that has new modifications
- fix: correctly auto save files with it's own name
Version 0.8.5 For Dev-C++ 7 Beta Version 0.8.5 For Dev-C++ 7 Beta
- enhancement: use lighter color to draw menu seperators - enhancement: use lighter color to draw menu seperators

View File

@ -151,10 +151,12 @@ Editor::Editor(QWidget *parent, const QString& filename,
connect(this, &QWidget::customContextMenuRequested, connect(this, &QWidget::customContextMenuRequested,
pMainWindow, &MainWindow::onEditorContextMenu); pMainWindow, &MainWindow::onEditorContextMenu);
mCanAutoSave = false;
if (isNew && parentPageControl!=nullptr) { if (isNew && parentPageControl!=nullptr) {
QString fileTemplate = pMainWindow->codeSnippetManager()->newFileTemplate(); QString fileTemplate = pMainWindow->codeSnippetManager()->newFileTemplate();
if (!fileTemplate.isEmpty()) { if (!fileTemplate.isEmpty()) {
insertCodeSnippet(fileTemplate); insertCodeSnippet(fileTemplate);
mCanAutoSave = true;
} }
} }
if (!isNew && parentPageControl!=nullptr) { if (!isNew && parentPageControl!=nullptr) {
@ -1390,6 +1392,8 @@ void Editor::onStatusChanged(SynStatusChanges changes)
} }
if (changes.testFlag(scModified)) { if (changes.testFlag(scModified)) {
mCurrentLineModified = true; mCurrentLineModified = true;
if (mParentPageControl!=nullptr)
mCanAutoSave = true;
} }
if (changes.testFlag(SynStatusChange::scCaretX) if (changes.testFlag(SynStatusChange::scCaretX)
@ -3120,6 +3124,16 @@ void Editor::onExportedFormatToken(PSynHighlighter syntaxHighlighter, int Line,
} }
} }
bool Editor::canAutoSave() const
{
return mCanAutoSave;
}
void Editor::setCanAutoSave(bool newCanAutoSave)
{
mCanAutoSave = newCanAutoSave;
}
const QDateTime &Editor::hideTime() const const QDateTime &Editor::hideTime() const
{ {
return mHideTime; return mHideTime;
@ -3514,7 +3528,12 @@ void Editor::reformat()
content); content);
selectAll(); selectAll();
SynEditorOptions oldOptions = getOptions();
SynEditorOptions newOptions = oldOptions;
newOptions.setFlag(SynEditorOption::eoAutoIndent,false);
setOptions(newOptions);
setSelText(QString::fromUtf8(newContent)); setSelText(QString::fromUtf8(newContent));
setOptions(oldOptions);
reparse(); reparse();
checkSyntaxInBack(); checkSyntaxInBack();
reparseTodo(); reparseTodo();

View File

@ -269,6 +269,7 @@ private:
int mTabStopBegin; int mTabStopBegin;
int mTabStopEnd; int mTabStopEnd;
int mTabStopY; int mTabStopY;
bool mCanAutoSave;
QString mLineBeforeTabStop; QString mLineBeforeTabStop;
QString mLineAfterTabStop; QString mLineAfterTabStop;
QList<PTabStop> mUserCodeInTabStops; QList<PTabStop> mUserCodeInTabStops;
@ -312,6 +313,9 @@ public:
const QDateTime &hideTime() const; const QDateTime &hideTime() const;
void setHideTime(const QDateTime &newHideTime); void setHideTime(const QDateTime &newHideTime);
bool canAutoSave() const;
void setCanAutoSave(bool newCanAutoSave);
protected: protected:
void mouseReleaseEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override;

View File

@ -146,7 +146,7 @@ bool GDBMIResultParser::parseArray(char *&p, ParseValue &value)
if (*p!=']') { if (*p!=']') {
while (*p!=0) { while (*p!=0) {
skipSpaces(p); skipSpaces(p);
QObject obj; ParseObject obj;
bool result = parseObject(p,obj); bool result = parseObject(p,obj);
if (result) { if (result) {
array.append(obj); array.append(obj);
@ -202,7 +202,7 @@ const QString &GDBMIResultParser::ParseValue::value() const
return mValue; return mValue;
} }
const QList<GDBMIResultParser::ParseObject> &GDBMIResultParser::ParseValue::array() const const QList<::GDBMIResultParser::ParseObject> &GDBMIResultParser::ParseValue::array() const
{ {
return mArray; return mArray;
} }
@ -228,25 +228,18 @@ GDBMIResultParser::ParseValue::ParseValue(const QString &value):
{ {
} }
GDBMIResultParser::ParseValue::ParseValue(const PParseObject &object): GDBMIResultParser::ParseValue::ParseValue(const ParseObject &object):
mObject(object), mObject(object),
mType(ParseValueType::Object) mType(ParseValueType::Object)
{ {
} }
GDBMIResultParser::ParseValue::ParseValue(const QList<PParseObject> &array): GDBMIResultParser::ParseValue::ParseValue(const QList<ParseObject> &array):
mArray(array), mArray(array),
mType(ParseValueType::Array) mType(ParseValueType::Array)
{ {
} }
void GDBMIResultParser::ParseValue::addObject(const PParseObject &object)
{
Q_ASSERT(mType == ParseValueType::Array || mType == ParseValueType::NotAssigned);
mType = ParseValueType::Array;
mArray.append(object);
}
GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const QString &value) GDBMIResultParser::ParseValue &GDBMIResultParser::ParseValue::operator=(const QString &value)
{ {
Q_ASSERT(mType == ParseValueType::NotAssigned); Q_ASSERT(mType == ParseValueType::NotAssigned);

View File

@ -2,6 +2,7 @@
#define GDBMIRESULTPARSER_H #define GDBMIRESULTPARSER_H
#include <QByteArray> #include <QByteArray>
#include <QList>
#include <QVector> #include <QVector>
@ -38,10 +39,9 @@ class GDBMIResultParser
explicit ParseValue(const ParseObject &object); explicit ParseValue(const ParseObject &object);
explicit ParseValue(const QList<ParseObject>& array); explicit ParseValue(const QList<ParseObject>& array);
ParseValue(const ParseValue&) = delete; ParseValue(const ParseValue&) = delete;
void addObject(const PParseObject& object);
const QString &value() const; const QString &value() const;
QList<ParseObject> &array() const; const QList<ParseObject> &array() const;
const PParseObject &object() const; const ParseObject &object() const;
ParseValueType type() const; ParseValueType type() const;
ParseValue& operator=(const QString& value); ParseValue& operator=(const QString& value);
ParseValue& operator=(const ParseObject& object); ParseValue& operator=(const ParseObject& object);

View File

@ -799,8 +799,10 @@ void MainWindow::updateClassBrowserForEditor(Editor *editor)
void MainWindow::resetAutoSaveTimer() void MainWindow::resetAutoSaveTimer()
{ {
if (pSettings->editor().enableAutoSave()) { if (pSettings->editor().enableAutoSave()) {
mAutoSaveTimer.stop();
//minute to milliseconds //minute to milliseconds
mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000); mAutoSaveTimer.start(pSettings->editor().autoSaveInterval()*60*1000);
onAutoSaveTimeout();
} else { } else {
mAutoSaveTimer.stop(); mAutoSaveTimer.stop();
} }
@ -1544,18 +1546,19 @@ void MainWindow::prepareDebugger()
void MainWindow::doAutoSave(Editor *e) void MainWindow::doAutoSave(Editor *e)
{ {
if (!e)
return; if (!e || !e->canAutoSave())
if (!e->modified())
return; return;
QString filename = e->filename(); QString filename = e->filename();
try {
QFileInfo fileInfo(filename); QFileInfo fileInfo(filename);
QDir parent = fileInfo.absoluteDir(); QDir parent = fileInfo.absoluteDir();
QString baseName = fileInfo.completeBaseName(); QString baseName = fileInfo.completeBaseName();
QString suffix = fileInfo.suffix(); QString suffix = fileInfo.suffix();
switch(pSettings->editor().autoSaveStrategy()) { switch(pSettings->editor().autoSaveStrategy()) {
case assOverwrite: case assOverwrite:
break; e->save();
return;
case assAppendUnixTimestamp: case assAppendUnixTimestamp:
filename = parent.filePath( filename = parent.filePath(
QString("%1.%2.%3") QString("%1.%2.%3")
@ -1572,7 +1575,18 @@ void MainWindow::doAutoSave(Editor *e)
.arg(suffix)); .arg(suffix));
} }
} }
if (e->isNew()) {
e->saveAs();
} else {
e->saveFile(filename); e->saveFile(filename);
e->setCanAutoSave(false);
}
} catch (FileError& error) {
QMessageBox::critical(e,
tr("Auto Save Error"),
tr("Auto save \"%1\" to \"%2\" failed:%3")
.arg(e->filename(), filename, error.reason()));
}
} }
//static void limitActionShortCutScope(QAction* action,QWidget* scopeWidget) { //static void limitActionShortCutScope(QAction* action,QWidget* scopeWidget) {

View File

@ -1,4 +1,5 @@
#include "SynEdit.h" #include "SynEdit.h"
#include "highlighter/cpp.h"
#include <QApplication> #include <QApplication>
#include <QFontMetrics> #include <QFontMetrics>
#include <algorithm> #include <algorithm>
@ -1473,7 +1474,14 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
matchingIndents = rangeAfterFirstToken.matchingIndents; matchingIndents = rangeAfterFirstToken.matchingIndents;
dontAddIndent = true; dontAddIndent = true;
l = startLine; l = startLine;
} else if (mHighlighter->isLastLineCommentNotFinished(rangePreceeding.state) } else if (mHighlighter->getClass() == SynHighlighterClass::CppHighlighter
&& trimmedLineText.startsWith('#')
&& attr == ((SynEditCppHighlighter *)mHighlighter.get())->preprocessorAttribute()) {
dontAddIndent = true;
indentSpaces=0;
l=0;
} else if (mHighlighter->getClass() == SynHighlighterClass::CppHighlighter
&& mHighlighter->isLastLineCommentNotFinished(rangePreceeding.state)
&& (trimmedLineText.startsWith("*")) && (trimmedLineText.startsWith("*"))
) { ) {
// last line is a not finished comment, and this line start with "*" // last line is a not finished comment, and this line start with "*"
@ -1785,7 +1793,7 @@ void SynEdit::doDeleteLastChar()
mLines->deleteAt(mCaretY); mLines->deleteAt(mCaretY);
doLinesDeleted(mCaretY+1, 1); doLinesDeleted(mCaretY+1, 1);
if (mOptions.testFlag(eoTrimTrailingSpaces)) if (mOptions.testFlag(eoTrimTrailingSpaces))
Temp = trimRight(Temp); Temp = TrimRight(Temp);
setLineText(lineText() + Temp); setLineText(lineText() + Temp);
helper = lineBreak(); //"/r/n" helper = lineBreak(); //"/r/n"
} }
@ -2119,7 +2127,7 @@ void SynEdit::insertLine(bool moveCaret)
rightLineText,mOptions.testFlag(eoAutoIndent) rightLineText,mOptions.testFlag(eoAutoIndent)
&& notInComment); && notInComment);
if (mOptions.testFlag(eoAutoIndent)) { if (mOptions.testFlag(eoAutoIndent)) {
rightLineText=trimLeft(rightLineText); rightLineText=TrimLeft(rightLineText);
} }
QString indentSpacesForRightLineText = GetLeftSpacing(indentSpaces,true); QString indentSpacesForRightLineText = GetLeftSpacing(indentSpaces,true);
mLines->insert(mCaretY, indentSpacesForRightLineText+rightLineText); mLines->insert(mCaretY, indentSpacesForRightLineText+rightLineText);
@ -2624,17 +2632,21 @@ void SynEdit::doAddChar(QChar AChar)
} }
mUndoList->BeginBlock(); mUndoList->BeginBlock();
if (mOptions.testFlag(eoAutoIndent) && mHighlighter // auto
if (mOptions.testFlag(eoAutoIndent)
&& mHighlighter
&& mHighlighter->getClass()==SynHighlighterClass::CppHighlighter
&& (oldCaretY<=mLines->count()) ) { && (oldCaretY<=mLines->count()) ) {
//unindent if ':' at end of the line //unindent if ':' at end of the line
if (AChar == ':') { if (AChar == ':') {
QString line = mLines->getString(oldCaretY-1); QString line = mLines->getString(oldCaretY-1);
if (line.length() < oldCaretX) { if (line.length() < oldCaretX) {
int indentSpaces = calcIndentSpaces(oldCaretY,line+":", true); int indentSpaces = calcIndentSpaces(oldCaretY,line+":", true);
if (indentSpaces != leftSpaces(line)) { if (indentSpaces != leftSpaces(line)) {
QString temp = GetLeftSpacing(indentSpaces,true) + trimLeft(line); QString newLine = GetLeftSpacing(indentSpaces,true) + TrimLeft(line);
int i = temp.length(); int i = newLine.length();
mLines->putString(oldCaretY-1,temp); mLines->putString(oldCaretY-1,newLine);
internalSetCaretXY(BufferCoord{i+1,oldCaretY}); internalSetCaretXY(BufferCoord{i+1,oldCaretY});
mUndoList->AddChange( mUndoList->AddChange(
SynChangeReason::crDelete, SynChangeReason::crDelete,
@ -2646,66 +2658,35 @@ void SynEdit::doAddChar(QChar AChar)
mUndoList->AddChange( mUndoList->AddChange(
SynChangeReason::crInsert, SynChangeReason::crInsert,
BufferCoord{1, oldCaretY}, BufferCoord{1, oldCaretY},
BufferCoord{temp.length()+1, oldCaretY}, BufferCoord{newLine.length()+1, oldCaretY},
"", newLine,
SynSelectionMode::smNormal SynSelectionMode::smNormal
); );
} }
} }
} } else if (AChar == '{' || AChar == '}' || AChar == '#') {
//unindent if '{' is after an statement like 'if' 'for' //Reindent line when add '{' '}' and '#' at the beginning
if (AChar == '{') { QString left = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1);
QString temp = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1);
// and the first nonblank char is this new { // and the first nonblank char is this new {
if (temp.trimmed().isEmpty()) { if (left.trimmed().isEmpty()) {
int indentSpaces = calcIndentSpaces(oldCaretY,"{", true); int indentSpaces = calcIndentSpaces(oldCaretY,AChar, true);
QString line = mLines->getString(oldCaretY-1); if (indentSpaces != leftSpaces(left)) {
if (indentSpaces != leftSpaces(line)) { QString right = mLines->getString(oldCaretY-1).mid(oldCaretX);
QString temp = GetLeftSpacing(indentSpaces,true); QString newLeft = GetLeftSpacing(indentSpaces,true);
int i = temp.length(); mLines->putString(oldCaretY-1,newLeft+right);
mLines->putString(oldCaretY-1,temp); internalSetCaretXY(BufferCoord{newLeft.length()+1,oldCaretY});
internalSetCaretXY(BufferCoord{i+1,oldCaretY});
mUndoList->AddChange( mUndoList->AddChange(
SynChangeReason::crDelete, SynChangeReason::crDelete,
BufferCoord{1, oldCaretY}, BufferCoord{1, oldCaretY},
BufferCoord{line.length()+1, oldCaretY}, BufferCoord{left.length()+1, oldCaretY},
line, left,
SynSelectionMode::smNormal SynSelectionMode::smNormal
); );
mUndoList->AddChange( mUndoList->AddChange(
SynChangeReason::crInsert, SynChangeReason::crInsert,
BufferCoord{1, oldCaretY}, BufferCoord{1, oldCaretY},
BufferCoord{temp.length()+1, oldCaretY}, BufferCoord{newLeft.length()+1, oldCaretY},
"", newLeft,
SynSelectionMode::smNormal
);
}
}
}
// Remove TabWidth of indent of the current line when typing a }
if (AChar == '}') {
QString temp = mLines->getString(oldCaretY-1).mid(0,oldCaretX-1);
// and the first nonblank char is this new }
if (temp.trimmed().isEmpty()) {
int indentSpaces = calcIndentSpaces(oldCaretY,"}", true);
QString line = mLines->getString(oldCaretY-1);
if (indentSpaces != leftSpaces(line)) {
QString temp = GetLeftSpacing(indentSpaces,true);
int i = temp.length();
mLines->putString(oldCaretY-1,temp);
internalSetCaretXY(BufferCoord{i+1,oldCaretY});
mUndoList->AddChange(
SynChangeReason::crDelete,
BufferCoord{1, oldCaretY},
BufferCoord{line.length()+1, oldCaretY},
line,
SynSelectionMode::smNormal
);
mUndoList->AddChange(
SynChangeReason::crInsert,
BufferCoord{1, oldCaretY},
BufferCoord{temp.length()+1, oldCaretY},
"",
SynSelectionMode::smNormal SynSelectionMode::smNormal
); );
} }
@ -4881,6 +4862,8 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
mUndoList->BeginBlock(); mUndoList->BeginBlock();
dobatchReplace = true; dobatchReplace = true;
} }
bool oldAutoIndent = mOptions.testFlag(SynEditorOption::eoAutoIndent);
mOptions.setFlag(SynEditorOption::eoAutoIndent,false);
doSetSelText(replaceText); doSetSelText(replaceText);
nReplaceLen = caretX() - nFound; nReplaceLen = caretX() - nFound;
// fix the caret position and the remaining results // fix the caret position and the remaining results
@ -4894,6 +4877,7 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS
} }
} }
} }
mOptions.setFlag(SynEditorOption::eoAutoIndent,oldAutoIndent);
} }
} }
// search next / previous line // search next / previous line
@ -4941,7 +4925,7 @@ void SynEdit::doLinesInserted(int firstLine, int count)
void SynEdit::properSetLine(int ALine, const QString &ALineText) void SynEdit::properSetLine(int ALine, const QString &ALineText)
{ {
if (mOptions.testFlag(eoTrimTrailingSpaces)) if (mOptions.testFlag(eoTrimTrailingSpaces))
mLines->putString(ALine,trimRight(ALineText)); mLines->putString(ALine,TrimRight(ALineText));
else else
mLines->putString(ALine,ALineText); mLines->putString(ALine,ALineText);
} }
@ -5047,7 +5031,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
int Result = 0; int Result = 0;
sLeftSide = lineText().mid(0, mCaretX - 1); sLeftSide = lineText().mid(0, mCaretX - 1);
if (mCaretX - 1 > sLeftSide.length()) { if (mCaretX - 1 > sLeftSide.length()) {
if (stringIsBlank(sLeftSide)) if (StringIsBlank(sLeftSide))
sLeftSide = GetLeftSpacing(displayX() - 1, true); sLeftSide = GetLeftSpacing(displayX() - 1, true);
else else
sLeftSide += QString(mCaretX - 1 - sLeftSide.length(),' '); sLeftSide += QString(mCaretX - 1 - sLeftSide.length(),' ');
@ -5063,7 +5047,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Start = 0; Start = 0;
P = GetEOL(Value,Start); P = GetEOL(Value,Start);
if (P<Value.length()) { if (P<Value.length()) {
QString s = trimLeft(Value.mid(0, P - Start)); QString s = TrimLeft(Value.mid(0, P - Start));
if (sLeftSide.isEmpty()) { if (sLeftSide.isEmpty()) {
sLeftSide = GetLeftSpacing(calcIndentSpaces(caretY,s,true),true); sLeftSide = GetLeftSpacing(calcIndentSpaces(caretY,s,true),true);
} }
@ -5096,7 +5080,7 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
Str += sRightSide; Str += sRightSide;
if (mOptions.testFlag(eoAutoIndent)) { if (mOptions.testFlag(eoAutoIndent)) {
int indentSpaces = calcIndentSpaces(caretY,Str,true); int indentSpaces = calcIndentSpaces(caretY,Str,true);
Str = GetLeftSpacing(indentSpaces,true)+trimLeft(Str); Str = GetLeftSpacing(indentSpaces,true)+TrimLeft(Str);
} }
} }
properSetLine(caretY - 1, Str); properSetLine(caretY - 1, Str);

View File

@ -34,7 +34,7 @@ void EditorAutoSaveWidget::doLoad()
{ {
//pSettings->editor().load(); //pSettings->editor().load();
//font //font
ui->chkEnableAutoSave->setChecked(pSettings->editor().enableAutoSave()); ui->grpEnableAutoSave->setChecked(pSettings->editor().enableAutoSave());
ui->spinInterval->setValue(pSettings->editor().autoSaveInterval()); ui->spinInterval->setValue(pSettings->editor().autoSaveInterval());
switch(pSettings->editor().autoSaveTarget()) { switch(pSettings->editor().autoSaveTarget()) {
case astCurrentFile: case astCurrentFile:
@ -60,7 +60,7 @@ void EditorAutoSaveWidget::doLoad()
void EditorAutoSaveWidget::doSave() void EditorAutoSaveWidget::doSave()
{ {
pSettings->editor().setEnableAutoSave(ui->chkEnableAutoSave->isChecked()); pSettings->editor().setEnableAutoSave(ui->grpEnableAutoSave->isChecked());
pSettings->editor().setAutoSaveInterval(ui->spinInterval->value()); pSettings->editor().setAutoSaveInterval(ui->spinInterval->value());
if (ui->rbCurrentFile->isChecked()) if (ui->rbCurrentFile->isChecked())
pSettings->editor().setAutoSaveTarget(astCurrentFile); pSettings->editor().setAutoSaveTarget(astCurrentFile);
@ -74,6 +74,8 @@ void EditorAutoSaveWidget::doSave()
pSettings->editor().setAutoSaveStrategy(assAppendUnixTimestamp); pSettings->editor().setAutoSaveStrategy(assAppendUnixTimestamp);
else else
pSettings->editor().setAutoSaveStrategy(assAppendFormatedTimeStamp); pSettings->editor().setAutoSaveStrategy(assAppendFormatedTimeStamp);
pSettings->editor().save();
pMainWindow->resetAutoSaveTimer();
} }
void EditorAutoSaveWidget::on_rbOverwrite_toggled(bool) void EditorAutoSaveWidget::on_rbOverwrite_toggled(bool)

View File

@ -15,7 +15,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QGroupBox" name="chkEnableAutoSave"> <widget class="QGroupBox" name="grpEnableAutoSave">
<property name="title"> <property name="title">
<string>Enable auto save</string> <string>Enable auto save</string>
</property> </property>

View File

@ -3,7 +3,7 @@
#include <QStringList> #include <QStringList>
#define DEVCPP_VERSION "beta.0.8.5" #define DEVCPP_VERSION "beta.0.8.6"
#define APP_SETTSINGS_FILENAME "redpandacpp.ini" #define APP_SETTSINGS_FILENAME "redpandacpp.ini"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View File

@ -805,12 +805,12 @@ void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *op
switch (element) { switch (element) {
case CE_MenuItem: case CE_MenuItem:
painter->save();
// Draws one item in a popup menu. // Draws one item in a popup menu.
if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
QColor highlightOutline = highlightedOutline; QColor highlightOutline = highlightedOutline;
QColor highlight = option->palette.highlight().color(); QColor highlight = option->palette.highlight().color();
if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
painter->save();
int w = 0; int w = 0;
const int margin = int(QStyleHelper::dpiScaled(5, option)); const int margin = int(QStyleHelper::dpiScaled(5, option));
if (!menuItem->text.isEmpty()) { if (!menuItem->text.isEmpty()) {