- enhancement: "Mouse scroll direction" option in Options / Editor / General

- change: Invert scroll direction in horizontal, like in vertical.
This commit is contained in:
Roy Qu 2024-03-20 15:55:22 +08:00
parent 63db2e5179
commit 5003c412f7
11 changed files with 126 additions and 23 deletions

View File

@ -58,6 +58,8 @@ Red Panda C++ Version 2.27
- enhancement: Folding button scales with editor font. - enhancement: Folding button scales with editor font.
- fix: Should show header completion popup in #include line comments. - fix: Should show header completion popup in #include line comments.
- fix: Custom compile options not correctly parsed. - fix: Custom compile options not correctly parsed.
- enhancement: "Mouse scroll direction" option in Options / Editor / General
- change: Invert scroll direction in horizontal, like in vertical.
Red Panda C++ Version 2.26 Red Panda C++ Version 2.26
- enhancement: Code suggestion for embedded std::vectors. - enhancement: Code suggestion for embedded std::vectors.

View File

@ -5253,6 +5253,8 @@ void Editor::applySettings()
options.setFlag(QSynedit::eoScrollByOneLess,pSettings->editor().scrollByOneLess()); options.setFlag(QSynedit::eoScrollByOneLess,pSettings->editor().scrollByOneLess());
options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll()); options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll());
options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll()); options.setFlag(QSynedit::eoHalfPageScroll,pSettings->editor().halfPageScroll());
options.setFlag(QSynedit::eoInvertMouseScroll, pSettings->editor().invertMouseScroll());
options.setFlag(QSynedit::eoShowRainbowColor, options.setFlag(QSynedit::eoShowRainbowColor,
pSettings->editor().rainbowParenthesis() pSettings->editor().rainbowParenthesis()
&& syntaxer()->supportBraceLevel()); && syntaxer()->supportBraceLevel());

View File

@ -825,6 +825,16 @@ void Settings::Editor::setForceFixedFontWidth(bool newForceFixedWidth)
mForceFixedFontWidth = newForceFixedWidth; mForceFixedFontWidth = newForceFixedWidth;
} }
bool Settings::Editor::invertMouseScroll() const
{
return mInvertMouseScroll;
}
void Settings::Editor::setInvertMouseScroll(bool newInvertMouseScroll)
{
mInvertMouseScroll = newInvertMouseScroll;
}
bool Settings::Editor::showTrailingSpaces() const bool Settings::Editor::showTrailingSpaces() const
{ {
return mShowTrailingSpaces; return mShowTrailingSpaces;
@ -1342,6 +1352,7 @@ void Settings::Editor::doSave()
saveValue("half_page_scroll", mHalfPageScroll); saveValue("half_page_scroll", mHalfPageScroll);
saveValue("mouse_wheel_scroll_speed", mMouseWheelScrollSpeed); saveValue("mouse_wheel_scroll_speed", mMouseWheelScrollSpeed);
saveValue("mouse_selection_scroll_speed",mMouseSelectionScrollSpeed); saveValue("mouse_selection_scroll_speed",mMouseSelectionScrollSpeed);
saveValue("invert_mouse_scroll",mInvertMouseScroll);
//right edge //right edge
saveValue("show_right_edge_line",mShowRightEdgeLine); saveValue("show_right_edge_line",mShowRightEdgeLine);
@ -1474,6 +1485,7 @@ void Settings::Editor::doLoad()
mHalfPageScroll = boolValue("half_page_scroll",false); mHalfPageScroll = boolValue("half_page_scroll",false);
mMouseWheelScrollSpeed = intValue("mouse_wheel_scroll_speed", 3); mMouseWheelScrollSpeed = intValue("mouse_wheel_scroll_speed", 3);
mMouseSelectionScrollSpeed = intValue("mouse_selection_scroll_speed",1); mMouseSelectionScrollSpeed = intValue("mouse_selection_scroll_speed",1);
mInvertMouseScroll = boolValue("invert_mouse_scroll", false);
//right edge //right edge

View File

@ -410,6 +410,9 @@ public:
bool forceFixedFontWidth() const; bool forceFixedFontWidth() const;
void setForceFixedFontWidth(bool newForceFixedWidth); void setForceFixedFontWidth(bool newForceFixedWidth);
bool invertMouseScroll() const;
void setInvertMouseScroll(bool newInvertMouseScroll);
private: private:
//General //General
// indents // indents
@ -441,6 +444,7 @@ public:
bool mHalfPageScroll; bool mHalfPageScroll;
int mMouseWheelScrollSpeed; int mMouseWheelScrollSpeed;
int mMouseSelectionScrollSpeed; int mMouseSelectionScrollSpeed;
bool mInvertMouseScroll;
//right margin //right margin
bool mShowRightEdgeLine; bool mShowRightEdgeLine;

View File

@ -79,6 +79,7 @@ void EditorGeneralWidget::doLoad()
ui->chkScrollByOneLess->setChecked(pSettings->editor().scrollByOneLess()); ui->chkScrollByOneLess->setChecked(pSettings->editor().scrollByOneLess());
ui->spinMouseWheelScrollSpeed->setValue(pSettings->editor().mouseWheelScrollSpeed()); ui->spinMouseWheelScrollSpeed->setValue(pSettings->editor().mouseWheelScrollSpeed());
ui->spinMouseSelectionScrollSpeed->setValue(pSettings->editor().mouseSelectionScrollSpeed()); ui->spinMouseSelectionScrollSpeed->setValue(pSettings->editor().mouseSelectionScrollSpeed());
ui->rbInvertScroll->setChecked(pSettings->editor().invertMouseScroll());
//right margin line; //right margin line;
ui->grpRightEdge->setChecked(pSettings->editor().showRightEdgeLine()); ui->grpRightEdge->setChecked(pSettings->editor().showRightEdgeLine());
@ -116,7 +117,7 @@ void EditorGeneralWidget::doSave()
pSettings->editor().setHalfPageScroll(ui->chkScrollHalfPage->isChecked()); pSettings->editor().setHalfPageScroll(ui->chkScrollHalfPage->isChecked());
pSettings->editor().setMouseWheelScrollSpeed(ui->spinMouseWheelScrollSpeed->value()); pSettings->editor().setMouseWheelScrollSpeed(ui->spinMouseWheelScrollSpeed->value());
pSettings->editor().setMouseSelectionScrollSpeed(ui->spinMouseSelectionScrollSpeed->value()); pSettings->editor().setMouseSelectionScrollSpeed(ui->spinMouseSelectionScrollSpeed->value());
pSettings->editor().setInvertMouseScroll(ui->rbInvertScroll->isChecked());
//right margin line; //right margin line;
pSettings->editor().setShowRightEdgeLine(ui->grpRightEdge->isChecked()); pSettings->editor().setShowRightEdgeLine(ui->grpRightEdge->isChecked());
pSettings->editor().setRightEdgeWidth(ui->spRightEdge->value()); pSettings->editor().setRightEdgeWidth(ui->spRightEdge->value());

View File

@ -367,6 +367,42 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Mouse Scroll Direction</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QRadioButton" name="rbNaturalScroll">
<property name="text">
<string>Natural</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rbInvertScroll">
<property name="text">
<string>Invert</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QWidget" name="widget_6" native="true"> <widget class="QWidget" name="widget_6" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">

View File

@ -1452,12 +1452,12 @@
<translation>Inserir a condição de parada:</translation> <translation>Inserir a condição de parada:</translation>
</message> </message>
<message> <message>
<location line="+260"/> <location line="+262"/>
<source>Readonly</source> <source>Readonly</source>
<translation>Apenas leitura</translation> <translation>Apenas leitura</translation>
</message> </message>
<message> <message>
<location line="-5347"/> <location line="-5349"/>
<location line="+434"/> <location line="+434"/>
<source>Error Load File</source> <source>Error Load File</source>
<translation type="unfinished">Erro ao carregar arquivo</translation> <translation type="unfinished">Erro ao carregar arquivo</translation>
@ -8374,7 +8374,7 @@
<location filename="../autolinkmanager.cpp" line="+54"/> <location filename="../autolinkmanager.cpp" line="+54"/>
<location line="+16"/> <location line="+16"/>
<location line="+19"/> <location line="+19"/>
<location filename="../settings.cpp" line="+4057"/> <location filename="../settings.cpp" line="+4069"/>
<location filename="../widgets/ojproblemsetmodel.cpp" line="-401"/> <location filename="../widgets/ojproblemsetmodel.cpp" line="-401"/>
<location line="+61"/> <location line="+61"/>
<source>Can&apos;t open file &apos;%1&apos; for read.</source> <source>Can&apos;t open file &apos;%1&apos; for read.</source>
@ -8689,7 +8689,7 @@
<translation>Impossível carregar configurações para autolink</translation> <translation>Impossível carregar configurações para autolink</translation>
</message> </message>
<message> <message>
<location filename="../parser/cppparser.cpp" line="+1235"/> <location filename="../parser/cppparser.cpp" line="+1258"/>
<source>constructor</source> <source>constructor</source>
<translation>constructor</translation> <translation>constructor</translation>
</message> </message>
@ -11047,7 +11047,22 @@
<translation>Limitar rolamento de página a apenas uma linha</translation> <translation>Limitar rolamento de página a apenas uma linha</translation>
</message> </message>
<message> <message>
<location line="+22"/> <location line="+7"/>
<source>Mouse Scroll Direction</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>Natural</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+38"/>
<source>Mouse Wheel Scroll Speed</source> <source>Mouse Wheel Scroll Speed</source>
<translation>Velocidade de rolamento pela rodinha do mouse</translation> <translation>Velocidade de rolamento pela rodinha do mouse</translation>
</message> </message>

View File

@ -1714,7 +1714,7 @@ p, li { white-space: pre-wrap; }
<translation>:</translation> <translation>:</translation>
</message> </message>
<message> <message>
<location line="+260"/> <location line="+262"/>
<source>Readonly</source> <source>Readonly</source>
<translation></translation> <translation></translation>
</message> </message>
@ -9234,7 +9234,7 @@ p, li { white-space: pre-wrap; }
<translation>(-g3)</translation> <translation>(-g3)</translation>
</message> </message>
<message> <message>
<location filename="../settings.cpp" line="+3455"/> <location filename="../settings.cpp" line="+3467"/>
<source>Would you like Red Panda C++ to search for compilers in PATH?</source> <source>Would you like Red Panda C++ to search for compilers in PATH?</source>
<translation>C++PATH路径中寻找gcc编译器吗</translation> <translation>C++PATH路径中寻找gcc编译器吗</translation>
</message> </message>
@ -9828,7 +9828,7 @@ p, li { white-space: pre-wrap; }
<translation type="vanished"></translation> <translation type="vanished"></translation>
</message> </message>
<message> <message>
<location filename="../parser/cppparser.cpp" line="+1235"/> <location filename="../parser/cppparser.cpp" line="+1258"/>
<source>constructor</source> <source>constructor</source>
<translation></translation> <translation></translation>
</message> </message>
@ -11950,7 +11950,22 @@ p, li { white-space: pre-wrap; }
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location line="+22"/> <location line="+7"/>
<source>Mouse Scroll Direction</source>
<translation></translation>
</message>
<message>
<location line="+6"/>
<source>Natural</source>
<translation></translation>
</message>
<message>
<location line="+7"/>
<source>Invert</source>
<translation></translation>
</message>
<message>
<location line="+38"/>
<source>Mouse Wheel Scroll Speed</source> <source>Mouse Wheel Scroll Speed</source>
<translation></translation> <translation></translation>
</message> </message>
@ -11976,7 +11991,7 @@ p, li { white-space: pre-wrap; }
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location line="-331"/> <location line="-367"/>
<source>Caret for overwriting mode</source> <source>Caret for overwriting mode</source>
<translation></translation> <translation></translation>
</message> </message>

View File

@ -1297,12 +1297,12 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+260"/> <location line="+262"/>
<source>Readonly</source> <source>Readonly</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="-5347"/> <location line="-5349"/>
<location line="+434"/> <location line="+434"/>
<source>Error Load File</source> <source>Error Load File</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
@ -8002,7 +8002,7 @@
<location filename="../autolinkmanager.cpp" line="+54"/> <location filename="../autolinkmanager.cpp" line="+54"/>
<location line="+16"/> <location line="+16"/>
<location line="+19"/> <location line="+19"/>
<location filename="../settings.cpp" line="+4057"/> <location filename="../settings.cpp" line="+4069"/>
<location filename="../widgets/ojproblemsetmodel.cpp" line="-401"/> <location filename="../widgets/ojproblemsetmodel.cpp" line="-401"/>
<location line="+61"/> <location line="+61"/>
<source>Can&apos;t open file &apos;%1&apos; for read.</source> <source>Can&apos;t open file &apos;%1&apos; for read.</source>
@ -8310,7 +8310,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../parser/cppparser.cpp" line="+1235"/> <location filename="../parser/cppparser.cpp" line="+1258"/>
<source>constructor</source> <source>constructor</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -10275,7 +10275,22 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location line="+22"/> <location line="+7"/>
<source>Mouse Scroll Direction</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>Natural</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<source>Invert</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+38"/>
<source>Mouse Wheel Scroll Speed</source> <source>Mouse Wheel Scroll Speed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -6256,6 +6256,7 @@ void QSynEdit::leaveEvent(QEvent *)
void QSynEdit::wheelEvent(QWheelEvent *event) void QSynEdit::wheelEvent(QWheelEvent *event)
{ {
int sign = mOptions.testFlag(EditorOption::eoInvertMouseScroll)?+1:-1;
if (event->modifiers() == Qt::ShiftModifier) { if (event->modifiers() == Qt::ShiftModifier) {
if ( (mWheelAccumulatedDeltaX>0 &&event->angleDelta().y()<0) if ( (mWheelAccumulatedDeltaX>0 &&event->angleDelta().y()<0)
|| (mWheelAccumulatedDeltaX<0 &&event->angleDelta().y()>0)) || (mWheelAccumulatedDeltaX<0 &&event->angleDelta().y()>0))
@ -6263,11 +6264,11 @@ void QSynEdit::wheelEvent(QWheelEvent *event)
mWheelAccumulatedDeltaX+=event->angleDelta().y(); mWheelAccumulatedDeltaX+=event->angleDelta().y();
while (mWheelAccumulatedDeltaX>=120) { while (mWheelAccumulatedDeltaX>=120) {
mWheelAccumulatedDeltaX-=120; mWheelAccumulatedDeltaX-=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed); horizontalScrollBar()->setValue(horizontalScrollBar()->value()+sign*mMouseWheelScrollSpeed*mCharWidth);
} }
while (mWheelAccumulatedDeltaX<=-120) { while (mWheelAccumulatedDeltaX<=-120) {
mWheelAccumulatedDeltaX+=120; mWheelAccumulatedDeltaX+=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed); horizontalScrollBar()->setValue(horizontalScrollBar()->value()-sign*mMouseWheelScrollSpeed*mCharWidth);
} }
} else { } else {
if ( (mWheelAccumulatedDeltaY>0 &&event->angleDelta().y()<0) if ( (mWheelAccumulatedDeltaY>0 &&event->angleDelta().y()<0)
@ -6276,11 +6277,11 @@ void QSynEdit::wheelEvent(QWheelEvent *event)
mWheelAccumulatedDeltaY+=event->angleDelta().y(); mWheelAccumulatedDeltaY+=event->angleDelta().y();
while (mWheelAccumulatedDeltaY>=120) { while (mWheelAccumulatedDeltaY>=120) {
mWheelAccumulatedDeltaY-=120; mWheelAccumulatedDeltaY-=120;
verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed); verticalScrollBar()->setValue(verticalScrollBar()->value()+sign*mMouseWheelScrollSpeed);
} }
while (mWheelAccumulatedDeltaY<=-120) { while (mWheelAccumulatedDeltaY<=-120) {
mWheelAccumulatedDeltaY+=120; mWheelAccumulatedDeltaY+=120;
verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed); verticalScrollBar()->setValue(verticalScrollBar()->value()-sign*mMouseWheelScrollSpeed);
} }
if ( (mWheelAccumulatedDeltaX>0 &&event->angleDelta().x()<0) if ( (mWheelAccumulatedDeltaX>0 &&event->angleDelta().x()<0)
@ -6289,11 +6290,11 @@ void QSynEdit::wheelEvent(QWheelEvent *event)
mWheelAccumulatedDeltaX+=event->angleDelta().x(); mWheelAccumulatedDeltaX+=event->angleDelta().x();
while (mWheelAccumulatedDeltaX>=120) { while (mWheelAccumulatedDeltaX>=120) {
mWheelAccumulatedDeltaX-=120; mWheelAccumulatedDeltaX-=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed); horizontalScrollBar()->setValue(horizontalScrollBar()->value()+sign*mMouseWheelScrollSpeed*mCharWidth);
} }
while (mWheelAccumulatedDeltaX<=-120) { while (mWheelAccumulatedDeltaX<=-120) {
mWheelAccumulatedDeltaX+=120; mWheelAccumulatedDeltaX+=120;
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed); horizontalScrollBar()->setValue(horizontalScrollBar()->value()-sign*mMouseWheelScrollSpeed*mCharWidth);
} }
} }
event->accept(); event->accept();

View File

@ -93,7 +93,7 @@ enum EditorOption {
eoScrollByOneLess = 0x00001000, //Forces scrolling to be one less eoScrollByOneLess = 0x00001000, //Forces scrolling to be one less
eoScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker eoScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker
eoScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line eoScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line
// eoShowSpecialChars = 0x00008000, //Shows the special Characters eoInvertMouseScroll = 0x00008000, //Shows the special Characters
// eoSpecialLineDefaultFg = 0x00010000, //disables the foreground text color override when using the OnSpecialLineColor event // eoSpecialLineDefaultFg = 0x00010000, //disables the foreground text color override when using the OnSpecialLineColor event
eoTabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected eoTabIndent = 0x00020000, //When active <Tab> and <Shift><Tab> act as block indent, unindent when text is selected
eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters