Skip to content

Commit

Permalink
New option in "Environment" / "Appearance". To prevent mouse wheel ch…
Browse files Browse the repository at this point in the history
…ange combobox's current selection.
  • Loading branch information
royqh1979 committed Dec 26, 2024
1 parent f0028f5 commit b68a364
Show file tree
Hide file tree
Showing 12 changed files with 1,558 additions and 1,512 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Red Panda C++ Version 3.3
- fix: Color scheme's "Indent Guide Line" item is not used by the editor.
- fix: "Indent Guide Line" item doesn't show in the option / editor / color scheme page.
- fix: Remove not used option "indent guide line" in the option / editor / general page.
- change: Prevent mouse wheel change combobox's current selection.
- enhancement: New option in "Environment" / "Appearance". To prevent mouse wheel change combobox's current selection.
- enhancement: Add "Rainbow indents"/"Rainbow indent guides" options in the option / editor / color scheme page.
- enhancement: Manually select file type.
- enhancement: When ctrl+click to open a C/C++ header file not suffixed with .h/.hh/.hpp etc., auto set its type to C/C++ header.
Expand Down
3 changes: 2 additions & 1 deletion RedPandaIDE/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ BlockWheelEventFiler::~BlockWheelEventFiler()
bool BlockWheelEventFiler::eventFilter(QObject *watched, QEvent *event)
{
//Prevent QComboBox wheel event
if (event->type() == QEvent::Wheel) {
if (event->type() == QEvent::Wheel
&& !pSettings->environment().comboboxWheel()) {
QComboBox *p=qobject_cast<QComboBox*>(watched);
if (p && !(p->view() && p->view()->isVisible()))
return true;
Expand Down
16 changes: 14 additions & 2 deletions RedPandaIDE/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3808,7 +3808,8 @@ void Settings::Environment::doLoad()
mIconZoomFactor = doubleValue("icon_zoom_factor",1.0);
mLanguage = stringValue("language", QLocale::system().name());
mIconSet = stringValue("icon_set","contrast");
mUseCustomIconSet = boolValue("use_custom_icon_set", false);
mUseCustomIconSet = boolValue("use_custom_icon_set", false);
mComboboxWheel = boolValue("enable_combobox_wheel", false);

mCurrentFolder = stringValue("current_folder",QDir::currentPath());
if (!fileExists(mCurrentFolder)) {
Expand Down Expand Up @@ -4046,14 +4047,24 @@ void Settings::Environment::checkAndSetTerminal()
QMessageBox::critical(
nullptr,
QCoreApplication::translate("Settings","Error"),
QCoreApplication::translate("Settings","Can't find terminal program!"));
QCoreApplication::translate("Settings","Can't find terminal program!"));
}

QMap<QString, QString> Settings::Environment::terminalArgsPatternMagicVariables()
{
return mTerminalArgsPatternMagicVariables;
}

bool Settings::Environment::comboboxWheel() const
{
return mComboboxWheel;
}

void Settings::Environment::setComboboxWheel(bool newComboboxWheel)
{
mComboboxWheel=newComboboxWheel;
}

QList<Settings::Environment::TerminalItem> Settings::Environment::loadTerminalList() const
{
#ifdef Q_OS_WINDOWS
Expand Down Expand Up @@ -4128,6 +4139,7 @@ void Settings::Environment::doSave()
saveValue("icon_set",mIconSet);
saveValue("use_custom_icon_set", mUseCustomIconSet);
saveValue("use_custom_theme", mUseCustomTheme);
saveValue("enable_combobox_wheel", mComboboxWheel);

saveValue("current_folder",mCurrentFolder);
saveValue("default_open_folder",mDefaultOpenFolder);
Expand Down
4 changes: 4 additions & 0 deletions RedPandaIDE/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ class Settings

static QMap<QString, QString> terminalArgsPatternMagicVariables();

bool comboboxWheel() const;
void setComboboxWheel(bool newComboboxWheel);

private:
bool isTerminalValid();
void checkAndSetTerminal();
Expand All @@ -615,6 +618,7 @@ class Settings
QString mIconSet;
bool mUseCustomIconSet;
bool mUseCustomTheme;
bool mComboboxWheel;

QString mDefaultOpenFolder;
QString mTerminalPath;
Expand Down
2 changes: 2 additions & 0 deletions RedPandaIDE/settingsdialog/environmentappearancewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void EnvironmentAppearanceWidget::doLoad()
break;
}
}
ui->chkComboboxWheel->setChecked(pSettings->environment().comboboxWheel());
}

void EnvironmentAppearanceWidget::doSave()
Expand All @@ -83,6 +84,7 @@ void EnvironmentAppearanceWidget::doSave()
pSettings->environment().setIconZoomFactor(ui->spinZoomFactor->value());

pSettings->environment().setUseCustomIconSet(ui->chkUseCustomIconSet->isChecked());
pSettings->environment().setComboboxWheel(ui->chkComboboxWheel->isChecked());

pSettings->environment().save();
pMainWindow->applySettings();
Expand Down
Loading

0 comments on commit b68a364

Please sign in to comment.