- enhancement: Limit max speed for mouse scroll (and touch pad?)

This commit is contained in:
Roy Qu 2023-02-17 15:33:33 +08:00
parent 52eb2960ac
commit dbdf098b94
10 changed files with 131 additions and 186 deletions

View File

@ -34,6 +34,7 @@ Red Panda C++ Version 2.12
- enhancement: Delay for tooltips.
- enhancement: "Tool tips delay" option in Options/editor/Tooltips
- change: Remove "Compile & Run" menu item. It's replaced by "Run".
- enhancement: Limit max speed for mouse scroll (and touch pad?)
Red Panda C++ Version 2.11

View File

@ -2189,7 +2189,7 @@ void MainWindow::debug()
tr("Enable debugging"),
tr("You are not using a Debug compiler setting.")
+"<BR /><BR />"
+tr("Please choose a Debug compiler set in the toolbar, or enable the \"generate debugging info (-g3)\" and disable the \"strip additional info (-s)\" options in the compiler set settings's \"settings\" page.")
+tr("Please choose a Debug compiler set in the toolbarin the compiler set settings's \"settings\" page.")
+"<BR /><BR />"
+tr("Do you want to set it now?")
) == QMessageBox::Yes) {

View File

@ -1708,7 +1708,6 @@ Settings::CompilerSet::CompilerSet(const Settings::CompilerSet &set):
mCppCompiler(set.mCppCompiler),
mMake(set.mMake),
mDebugger(set.mDebugger),
mProfiler(set.mProfiler),
mResourceCompiler(set.mResourceCompiler),
mDebugServer(set.mDebugServer),
mAssembler(set.assembler()),
@ -1965,16 +1964,6 @@ void Settings::CompilerSet::setDebugger(const QString &name)
mDebugger = name;
}
const QString &Settings::CompilerSet::profiler() const
{
return mProfiler;
}
void Settings::CompilerSet::setProfiler(const QString &name)
{
mProfiler = name;
}
const QString &Settings::CompilerSet::resourceCompiler() const
{
return mResourceCompiler;
@ -2348,7 +2337,6 @@ void Settings::CompilerSet::setExecutables()
}
mMake = findProgramInBinDirs(MAKE_PROGRAM);
mResourceCompiler = findProgramInBinDirs(WINDRES_PROGRAM);
mProfiler = findProgramInBinDirs(GPROF_PROGRAM);
mAssembler = findProgramInBinDirs(ASSEMBLER);
}
@ -3108,10 +3096,8 @@ void Settings::CompilerSets::saveSet(int index)
savePath("debug_server", pSet->debugServer());
savePath("make", pSet->make());
savePath("windres", pSet->resourceCompiler());
savePath("profiler", pSet->profiler());
savePath("assembler", pSet->assembler());
mSettings->mSettings.remove("Options");
foreach(const PCompilerOption& option, CompilerInfoManager::getInstance()->getCompilerOptions(pSet->compilerType())) {
mSettings->mSettings.remove(option->key);
@ -3188,7 +3174,6 @@ Settings::PCompilerSet Settings::CompilerSets::loadSet(int index)
pSet->setDebugServer(loadPath("debug_server"));
pSet->setMake(loadPath("make"));
pSet->setResourceCompiler(loadPath("windres"));
pSet->setProfiler(loadPath("profiler"));
pSet->setAssembler(loadPath("assembler"));
pSet->setDumpMachine(mSettings->mSettings.value("DumpMachine").toString());

View File

@ -1332,8 +1332,6 @@ public:
void setMake(const QString& name);
const QString& debugger() const;
void setDebugger(const QString& name);
const QString& profiler() const;
void setProfiler(const QString& name);
const QString& resourceCompiler() const;
void setResourceCompiler(const QString& name);
const QString &debugServer() const;
@ -1430,7 +1428,6 @@ public:
QString mCppCompiler;
QString mMake;
QString mDebugger;
QString mProfiler;
QString mResourceCompiler;
QString mDebugServer;
QString mAssembler;

View File

@ -98,7 +98,6 @@ static void loadCompilerSetSettings(Settings::PCompilerSet pSet, Ui::CompilerSet
ui->txtDebugger->setText(pSet->debugger());
ui->txtGDBServer->setText(pSet->debugServer());
ui->txtResourceCompiler->setText(pSet->resourceCompiler());
ui->txtProfiler->setText(pSet->profiler());
ui->txtAssembler->setText(pSet->assembler());
if (pSet->execCharset() == ENCODING_AUTO_DETECT
@ -208,7 +207,6 @@ void CompilerSetOptionWidget::saveCurrentCompilerSet()
pSet->setDebugger(ui->txtDebugger->text().trimmed());
pSet->setDebugServer(ui->txtGDBServer->text().trimmed());
pSet->setResourceCompiler(ui->txtResourceCompiler->text().trimmed());
pSet->setProfiler(ui->txtProfiler->text().trimmed());
pSet->setAssembler(ui->txtAssembler->text().trimmed());
pSet->binDirs()=mBinDirWidget->dirList();
@ -335,7 +333,6 @@ void CompilerSetOptionWidget::updateIcons(const QSize& /*size*/)
pIconsManager->setIcon(ui->btnChooseGDB, IconsManager::ACTION_FILE_OPEN_FOLDER);
pIconsManager->setIcon(ui->btnChooseGDBServer, IconsManager::ACTION_FILE_OPEN_FOLDER);
pIconsManager->setIcon(ui->btnChooseMake, IconsManager::ACTION_FILE_OPEN_FOLDER);
pIconsManager->setIcon(ui->btnChooseProfiler, IconsManager::ACTION_FILE_OPEN_FOLDER);
pIconsManager->setIcon(ui->btnChooseAssembler, IconsManager::ACTION_FILE_OPEN_FOLDER);
pIconsManager->setIcon(ui->btnChooseResourceCompiler, IconsManager::ACTION_FILE_OPEN_FOLDER);
}
@ -437,18 +434,6 @@ void CompilerSetOptionWidget::on_btnChooseResourceCompiler_clicked()
}
void CompilerSetOptionWidget::on_btnChooseProfiler_clicked()
{
QString fileName = QFileDialog::getOpenFileName(
this,
tr("Locate gprof"),
getBinDir(),
tr("Executable files (*.exe)"));
if (fileExists(fileName))
ui->txtProfiler->setText(fileName);
}
void CompilerSetOptionWidget::on_btnChooseAssembler_clicked()
{
QString fileName = QFileDialog::getOpenFileName(

View File

@ -70,7 +70,6 @@ private slots:
void on_btnChooseGDB_clicked();
void on_btnChooseGDBServer_clicked();
void on_btnChooseResourceCompiler_clicked();
void on_btnChooseProfiler_clicked();
void on_btnChooseAssembler_clicked();
};

View File

@ -110,7 +110,7 @@
<item>
<widget class="QTabWidget" name="settingTabs">
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<property name="movable">
<bool>false</bool>
@ -249,90 +249,16 @@
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="2">
<widget class="QToolButton" name="btnChooseResourceCompiler">
<property name="toolTip">
<string>Choose Resource Compiler</string>
</property>
<item row="0" column="1">
<widget class="QLineEdit" name="txtCCompiler"/>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="txtAssembler"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="btnChooseCCompiler">
<property name="toolTip">
<string>Choose C Compiler</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="txtProfiler"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="txtDebugger"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>C++ Compiler(g++)</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="btnChooseGDBServer">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="txtResourceCompiler"/>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="btnChooseCppCompiler">
<property name="toolTip">
<string>Choose C++ Compiler</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QToolButton" name="btnChooseProfiler">
<property name="toolTip">
<string>Choose Profiler</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
<string>make</string>
</property>
</widget>
</item>
@ -351,16 +277,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>make</string>
<string>C++ Compiler(g++)</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="txtGDBServer"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
@ -368,19 +291,24 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="txtCCompiler"/>
<item row="2" column="1">
<widget class="QLineEdit" name="txtMake"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<item row="1" column="2">
<widget class="QToolButton" name="btnChooseCppCompiler">
<property name="toolTip">
<string>Choose C++ Compiler</string>
</property>
<property name="text">
<string>C Compiler(gcc)</string>
<string>...</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="txtCppCompiler"/>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="btnChooseMake">
<property name="toolTip">
@ -396,30 +324,6 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Profiler(gprof)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="txtMake"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Resource Compilerwindres)</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>gdb</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
@ -427,8 +331,18 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="txtAssembler"/>
<item row="5" column="1">
<widget class="QLineEdit" name="txtResourceCompiler"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>C Compiler(gcc)</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="txtCppCompiler"/>
</item>
<item row="6" column="2">
<widget class="QToolButton" name="btnChooseAssembler">
@ -441,6 +355,67 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="btnChooseCCompiler">
<property name="toolTip">
<string>Choose C Compiler</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Resource Compilerwindres)</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="txtGDBServer"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="txtDebugger"/>
</item>
<item row="5" column="2">
<widget class="QToolButton" name="btnChooseResourceCompiler">
<property name="toolTip">
<string>Choose Resource Compiler</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/053-open.png</normalon>
</iconset>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QToolButton" name="btnChooseGDBServer">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>gdb</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -30,7 +30,6 @@
#define GDB32_PROGRAM "gdb32.exe"
#define MAKE_PROGRAM "mingw32-make.exe"
#define WINDRES_PROGRAM "windres.exe"
#define GPROF_PROGRAM "gprof.exe"
#define CLEAN_PROGRAM "del /q /f"
#define CPP_PROGRAM "cpp.exe"
#define GIT_PROGRAM "git.exe"
@ -65,7 +64,6 @@
#define GDB32_PROGRAM "gdb32"
#define MAKE_PROGRAM "make"
#define WINDRES_PROGRAM ""
#define GPROF_PROGRAM "gprof"
#define CLEAN_PROGRAM "rm -rf"
#define CPP_PROGRAM "cpp"
#define GIT_PROGRAM "git"

View File

@ -43,7 +43,9 @@
namespace QSynedit {
QSynEdit::QSynEdit(QWidget *parent) : QAbstractScrollArea(parent),
mDropped(false)
mDropped{false},
mLastWheelEventTime{QDateTime::currentMSecsSinceEpoch()},
mWheelEventTimes{0}
{
mCharWidth=1;
mTextHeight = 1;
@ -3323,42 +3325,35 @@ void QSynEdit::updateModifiedStatus()
int QSynEdit::scanFrom(int Index, int canStopIndex)
{
SyntaxState iRange;
int Result = std::max(0,Index);
if (Result >= mDocument->count())
return Result;
SyntaxState state;
int result = std::max(0,Index);
if (result >= mDocument->count())
return result;
if (Result == 0) {
if (result == 0) {
mSyntaxer->resetState();
} else {
mSyntaxer->setState(mDocument->getSyntaxState(Result-1));
mSyntaxer->setState(mDocument->getSyntaxState(result-1));
}
do {
mSyntaxer->setLine(mDocument->getLine(Result), Result);
mSyntaxer->setLine(mDocument->getLine(result), result);
mSyntaxer->nextToEol();
iRange = mSyntaxer->getState();
if (Result > canStopIndex){
if (mDocument->getSyntaxState(Result) == iRange
&& mDocument->getSyntaxState(Result).blockLevel == iRange.blockLevel
&& mDocument->getSyntaxState(Result).blockStarted == iRange.blockStarted
&& mDocument->getSyntaxState(Result).blockEnded == iRange.blockEnded
&& mDocument->getSyntaxState(Result).blockEndedLastLine == iRange.blockEndedLastLine
&& mDocument->getSyntaxState(Result).braceLevel == iRange.braceLevel
&& mDocument->getSyntaxState(Result).parenthesisLevel == iRange.parenthesisLevel
&& mDocument->getSyntaxState(Result).bracketLevel == iRange.bracketLevel
state = mSyntaxer->getState();
if (result > canStopIndex){
if (mDocument->getSyntaxState(result) == state
) {
if (mUseCodeFolding)
rescanFolds();
return Result;// avoid the final Decrement
return result;// avoid the final Decrement
}
}
mDocument->setSyntaxState(Result,iRange);
Result ++ ;
} while (Result < mDocument->count());
Result--;
mDocument->setSyntaxState(result,state);
result ++ ;
} while (result < mDocument->count());
result--;
if (mUseCodeFolding)
rescanFolds();
return Result;
return result;
}
void QSynEdit::rescanRange(int line)
@ -6336,6 +6331,15 @@ void QSynEdit::leaveEvent(QEvent *)
void QSynEdit::wheelEvent(QWheelEvent *event)
{
qint64 current=QDateTime::currentMSecsSinceEpoch();
if (current-mLastWheelEventTime<=1000) {
mWheelEventTimes+=1;
if (mWheelEventTimes>30)
return;
} else {
mWheelEventTimes=0;
mLastWheelEventTime=current;
}
if (event->modifiers() == Qt::ShiftModifier) {
if (event->angleDelta().y()>0) {
horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed);

View File

@ -682,7 +682,6 @@ private:
PUndoList mUndoList;
PRedoList mRedoList;
QPoint mMouseDownPos;
int mMouseWheelAccumulator;
EditCaretType mOverwriteCaret;
EditCaretType mInsertCaret;
QPoint mCaretOffset;
@ -744,6 +743,8 @@ private:
BufferCoord mDragSelBeginSave;
BufferCoord mDragSelEndSave;
bool mDropped;
qint64 mLastWheelEventTime;
int mWheelEventTimes;
friend class QSynEditPainter;