- fix: left and right gutter offset settings not correctly saved

- enhancement: use svg icons for editor gutter, and they can zoom with font now
This commit is contained in:
Roy Qu 2021-12-20 09:36:18 +08:00
parent ba538c9b13
commit 74fdf1ebef
8 changed files with 92 additions and 13 deletions

View File

@ -2,6 +2,8 @@ Version 0.11.4 For Dev-C++ 7 Beta
- fix: compiler set's custom link parameters not used when compiling - fix: compiler set's custom link parameters not used when compiling
- fix: code completion doesn't work when input inside () or [] - fix: code completion doesn't work when input inside () or []
- fix: auto indent processing error when input '{' in the middle of if statement - fix: auto indent processing error when input '{' in the middle of if statement
- fix: left and right gutter offset settings not correctly saved
- enhancement: use svg icons for editor gutter, and they can zoom with font now
Version 0.11.3 For Dev-C++ 7 Beta Version 0.11.3 For Dev-C++ 7 Beta
- fix: use pixel size for fonts, to fit different dpi in multiple displays - fix: use pixel size for fonts, to fit different dpi in multiple displays

View File

@ -787,13 +787,12 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y)
{ {
// Get point where to draw marks // Get point where to draw marks
//X := (fText.Gutter.RealGutterWidth(fText.CharWidth) - fText.Gutter.RightOffset) div 2 - 3; //X := (fText.Gutter.RealGutterWidth(fText.CharWidth) - fText.Gutter.RightOffset) div 2 - 3;
X = 5; PIcon icon;
Y += (this->textHeight() - 16) / 2;
if (mActiveBreakpointLine == aLine) { if (mActiveBreakpointLine == aLine) {
painter.drawPixmap(X,Y,*(pIconsManager->activeBreakpoint())); icon = pIconsManager->activeBreakpoint();
} else if (hasBreakpoint(aLine)) { } else if (hasBreakpoint(aLine)) {
painter.drawPixmap(X,Y,*(pIconsManager->breakpoint())); icon = pIconsManager->breakpoint();
} else { } else {
PSyntaxIssueList lst = getSyntaxIssuesAtLine(aLine); PSyntaxIssueList lst = getSyntaxIssuesAtLine(aLine);
if (lst) { if (lst) {
@ -805,16 +804,19 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y)
} }
} }
if (hasError) { if (hasError) {
painter.drawPixmap(X,Y,*(pIconsManager->syntaxError())); icon = pIconsManager->syntaxError();
} else { } else {
painter.drawPixmap(X,Y,*(pIconsManager->syntaxWarning())); icon = pIconsManager->syntaxWarning();
} }
return; } else if (hasBookmark(aLine)) {
} icon = pIconsManager->bookmark();
if (hasBookmark(aLine)) {
painter.drawPixmap(X,Y,*(pIconsManager->bookmark()));
} }
} }
if (icon) {
X = 5;
Y += (this->textHeight() - icon->height()) / 2;
painter.drawPixmap(X,Y,*icon);
}
} }
void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList) void Editor::onGetEditingAreas(int Line, SynEditingAreaList &areaList)
@ -4049,7 +4051,7 @@ void Editor::applySettings()
setFont(f); setFont(f);
// Set gutter properties // Set gutter properties
gutter().setLeftOffset(pSettings->editor().gutterLeftOffset()); gutter().setLeftOffset(pointToPixel(pSettings->editor().fontSize()) + pSettings->editor().gutterLeftOffset());
gutter().setRightOffset(pSettings->editor().gutterRightOffset()); gutter().setRightOffset(pSettings->editor().gutterRightOffset());
gutter().setBorderStyle(SynGutterBorderStyle::None); gutter().setBorderStyle(SynGutterBorderStyle::None);
gutter().setUseFontStyle(pSettings->editor().gutterUseCustomFont()); gutter().setUseFontStyle(pSettings->editor().gutterUseCustomFont());

View File

@ -490,5 +490,6 @@
<file>images/newlook24/091-openproblemanswer.png</file> <file>images/newlook24/091-openproblemanswer.png</file>
<file>images/newlook24/092-runallproblemcases.png</file> <file>images/newlook24/092-runallproblemcases.png</file>
<file>images/newlook24/093-pause.png</file> <file>images/newlook24/093-pause.png</file>
<file>images/editor/breakpoint.svg</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -1,12 +1,26 @@
#include "iconsmanager.h" #include "iconsmanager.h"
#include <QPainter>
#include <QSvgRenderer>
IconsManager* pIconsManager; IconsManager* pIconsManager;
IconsManager::IconsManager(QObject *parent) : QObject(parent) IconsManager::IconsManager(QObject *parent) : QObject(parent)
{ {
updateIcons(24);
}
void IconsManager::updateIcons(int size)
{
QSvgRenderer renderer(QString(":/icons/images/editor/breakpoint.svg"));
mBreakpoint = std::make_shared<QPixmap>(size,size);
mBreakpoint->fill(Qt::transparent);
QPainter painter(mBreakpoint.get());
renderer.render(&painter,mBreakpoint->rect());
mSyntaxError = std::make_shared<QPixmap>(":/icons/images/editor/syntaxerror.png"); mSyntaxError = std::make_shared<QPixmap>(":/icons/images/editor/syntaxerror.png");
mSyntaxWarning = std::make_shared<QPixmap>(":/icons/images/editor/syntaxwarning.png"); mSyntaxWarning = std::make_shared<QPixmap>(":/icons/images/editor/syntaxwarning.png");
mBreakpoint = std::make_shared<QPixmap>(":/icons/images/editor/breakpoint.png");
mActiveBreakpoint = std::make_shared<QPixmap>(":/icons/images/editor/currentline.png"); mActiveBreakpoint = std::make_shared<QPixmap>(":/icons/images/editor/currentline.png");
mBookmark = std::make_shared<QPixmap>(":/icons/images/editor/bookmark.png"); mBookmark = std::make_shared<QPixmap>(":/icons/images/editor/bookmark.png");
mFolder = std::make_shared<QPixmap>(":/icons/images/newlook24/090-explorer.png"); mFolder = std::make_shared<QPixmap>(":/icons/images/newlook24/090-explorer.png");

View File

@ -12,6 +12,8 @@ class IconsManager : public QObject
public: public:
explicit IconsManager(QObject *parent = nullptr); explicit IconsManager(QObject *parent = nullptr);
void updateIcons(int size);
const PIcon &syntaxError() const; const PIcon &syntaxError() const;
const PIcon &syntaxWarning() const; const PIcon &syntaxWarning() const;

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="100"
height="100"
viewBox="0 0 26.458333 26.458334"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="breakpoint.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="px"
showgrid="false"
inkscape:zoom="2.8934904"
inkscape:cx="136.85893"
inkscape:cy="69.293473"
inkscape:window-width="1920"
inkscape:window-height="1001"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
units="px" />
<defs
id="defs2" />
<g
inkscape:label="图层 1"
inkscape:groupmode="layer"
id="layer1">
<ellipse
style="fill:#ff0000;fill-opacity:1;stroke:#000000;stroke-width:0.60914;stroke-miterlimit:4;stroke-dasharray:none"
id="path927"
cx="13.076049"
cy="13.350369"
rx="12.487414"
ry="12.670298" />
<path
style="fill:none;stroke:#33f445;stroke-width:2.64583;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 2.5603448,14.904864 4.0233989,6.766626 3.10899,1.463054 L 12.984606,21.67149 23.77463,6.8580665"
id="path1509" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -21,6 +21,7 @@
#include "problems/problemcasevalidator.h" #include "problems/problemcasevalidator.h"
#include "widgets/ojproblempropertywidget.h" #include "widgets/ojproblempropertywidget.h"
#include "version.h" #include "version.h"
#include "iconsmanager.h"
#include <QCloseEvent> #include <QCloseEvent>
#include <QComboBox> #include <QComboBox>
@ -320,6 +321,7 @@ void MainWindow::updateForEncodingInfo() {
void MainWindow::updateEditorSettings() void MainWindow::updateEditorSettings()
{ {
pIconsManager->updateIcons(pointToPixel(pSettings->editor().fontSize()));
mEditorList->applySettings(); mEditorList->applySettings();
} }

View File

@ -1059,6 +1059,8 @@ void Settings::Editor::doSave()
//gutter //gutter
saveValue("gutter_visible", mGutterVisible); saveValue("gutter_visible", mGutterVisible);
saveValue("gutter_auto_size", mGutterAutoSize); saveValue("gutter_auto_size", mGutterAutoSize);
saveValue("gutter_left_offset",mGutterLeftOffset);
saveValue("gutter_right_offset",mGutterRightOffset);
saveValue("gutter_digits_count", mGutterDigitsCount); saveValue("gutter_digits_count", mGutterDigitsCount);
saveValue("gutter_show_line_numbers",mGutterShowLineNumbers); saveValue("gutter_show_line_numbers",mGutterShowLineNumbers);
saveValue("gutter_add_leading_zero",mGutterAddLeadingZero); saveValue("gutter_add_leading_zero",mGutterAddLeadingZero);
@ -1173,7 +1175,7 @@ void Settings::Editor::doLoad()
//gutter //gutter
mGutterVisible = boolValue("gutter_visible",true); mGutterVisible = boolValue("gutter_visible",true);
mGutterAutoSize = boolValue("gutter_auto_size",true); mGutterAutoSize = boolValue("gutter_auto_size",true);
mGutterLeftOffset = intValue("gutter_left_offset",28); mGutterLeftOffset = intValue("gutter_left_offset",6);
mGutterRightOffset = intValue("gutter_right_offset",24); mGutterRightOffset = intValue("gutter_right_offset",24);
mGutterDigitsCount = intValue("gutter_digits_count",1); mGutterDigitsCount = intValue("gutter_digits_count",1);
mGutterShowLineNumbers = boolValue("gutter_show_line_numbers",true); mGutterShowLineNumbers = boolValue("gutter_show_line_numbers",true);