Prevent stealing focus when scrolling.
This commit is contained in:
parent
1d198db6e9
commit
cc92270ecb
|
@ -32,6 +32,7 @@
|
|||
#include "../vmisc/dialogs/vshortcutdialog.h"
|
||||
#include "../vmisc/theme/vtheme.h"
|
||||
#include "../vmisc/vabstractshortcutmanager.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "ui_puzzlepreferencesconfigurationpage.h"
|
||||
|
||||
#include <QStyleHints>
|
||||
|
@ -43,6 +44,16 @@ PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->langCombo);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxThemeMode);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->undoCount);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxDuration);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxUpdateInterval);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSensor);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxWheel);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxAcceleration);
|
||||
|
||||
InitLanguages(ui->langCombo);
|
||||
connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
[this]() { m_langChanged = true; });
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "../vmisc/theme/vtheme.h"
|
||||
#include "../vmisc/vsysexits.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "dialogs/dialogpuzzlepreferences.h"
|
||||
#include "dialogs/dialogsavemanuallayout.h"
|
||||
#include "dialogs/vpdialogabout.h"
|
||||
|
@ -333,6 +334,31 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent)
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxCurrentPieceBoxPositionX);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxCurrentPieceBoxPositionY);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxCurrentPieceAngle);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxLayoutUnit);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxSheetTemplates);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetPaperWidth);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetPaperHeight);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetMarginTop);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetMarginLeft);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetMarginRight);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetMarginBottom);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetGridColWidth);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetGridRowHeight);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxTileTemplates);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxTilePaperWidth);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxTilePaperHeight);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxTileMarginTop);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxTileMarginLeft);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxTileMarginRight);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxTileMarginBottom);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxSheetPiecesGap);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxHorizontalScale);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxVerticalScale);
|
||||
|
||||
connect(m_layout.data(), &VPLayout::PieceSelectionChanged, this, &VPMainWindow::on_PieceSelectionChanged);
|
||||
connect(m_layout.data(), &VPLayout::LayoutChanged, this, [this]() { LayoutWasSaved(false); });
|
||||
connect(m_layout.data(), &VPLayout::PieceTransformationChanged, this,
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
#include "../vmisc/dialogs/vshortcutdialog.h"
|
||||
#include "../vmisc/theme/vtheme.h"
|
||||
#include "../vmisc/vabstractshortcutmanager.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "ui_tapepreferencesconfigurationpage.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
#include <QStyleHints>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -49,6 +51,11 @@ TapePreferencesConfigurationPage::TapePreferencesConfigurationPage(QWidget *pare
|
|||
ui->setupUi(this);
|
||||
RetranslateUi();
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->langCombo);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxKnownMeasurements);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxThemeMode);
|
||||
|
||||
InitLanguages(ui->langCombo);
|
||||
connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
[this]() { m_langChanged = true; });
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "../vmisc/theme/vtheme.h"
|
||||
#include "../vmisc/vabstractshortcutmanager.h"
|
||||
#include "../vmisc/vvalentinasettings.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "ui_preferencesconfigurationpage.h"
|
||||
#include "vcommonsettings.h"
|
||||
|
||||
|
@ -52,6 +53,15 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
|
|||
ui->setupUi(this);
|
||||
RetranslateUi();
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->autoTime);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->langCombo);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxPieceLbelLanguage);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->unitCombo);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->labelCombo);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxThemeMode);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxPointerMode);
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
||||
// Tab General
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "../vmisc/vvalentinasettings.h"
|
||||
#include "../vwidgets/vmaingraphicsview.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "svgfont/svgdef.h"
|
||||
#include "svgfont/vsvgfont.h"
|
||||
#include "svgfont/vsvgfontengine.h"
|
||||
|
@ -74,6 +75,18 @@ PreferencesPatternPage::PreferencesPatternPage(QWidget *parent)
|
|||
ui->setupUi(this);
|
||||
RetranslateUi();
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxCurveApproximation);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxLineWidth);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxLineWidthUnit);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->defaultSeamAllowance);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxLabelFontSize);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->fontComboBoxLabelFont);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxSingleLineFont);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxDateFormats);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxTimeFormats);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxOpacity);
|
||||
|
||||
VValentinaSettings *settings = VAbstractValApplication::VApp()->ValentinaSettings();
|
||||
|
||||
ui->graphOutputCheck->setChecked(settings->GetGraphicalOutput());
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "../vlayout/vlayoutgenerator.h"
|
||||
#include "../vmisc/vabstractvalapplication.h"
|
||||
#include "../vmisc/vvalentinasettings.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "ui_dialoglayoutsettings.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
@ -54,6 +55,22 @@ DialogLayoutSettings::DialogLayoutSettings(VLayoutGenerator *generator, QWidget
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxTemplates);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxPaperWidth);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxPaperHeight);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxPaperSizeUnit);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxPaperSizeUnit);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxLeftField);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxRightField);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxTopField);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxBottomField);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxLayoutWidth);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxLayoutUnit);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxNestingTime);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxEfficiency);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxMultiplier);
|
||||
|
||||
VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale())
|
||||
: setLocale(QLocale::c());
|
||||
|
||||
|
@ -537,7 +554,8 @@ auto DialogLayoutSettings::PageToPixels(qreal value) const -> qreal
|
|||
auto DialogLayoutSettings::MakeGroupsHelp() -> QString
|
||||
{
|
||||
// that is REALLY dummy ... can't figure fast how to automate generation... :/
|
||||
return tr("\n\tThree groups: big, middle, small = 0;\n\tTwo groups: big, small = 1;\n\tDescending area = 2");
|
||||
return tr("\n\tThree groups: big, middle, small = 0;\n\tTwo groups: big, small = "
|
||||
"1;\n\tDescending area = 2");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "../vtools/undocommands/image/rotatebackgroundimage.h"
|
||||
#include "../vtools/undocommands/image/scalebackgroundimage.h"
|
||||
#include "../vtools/undocommands/image/zvaluemovebackgroundimage.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "ui_vwidgetbackgroundimages.h"
|
||||
|
||||
#include <QMenu>
|
||||
|
@ -154,6 +155,15 @@ VWidgetBackgroundImages::VWidgetBackgroundImages(VAbstractPattern *doc, QWidget
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxImageHorizontalTranslate);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxTranslateUnit);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxImageVerticalTranslate);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxScaleWidth);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxScaleUnit);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxScaleHeight);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxRotationAngle);
|
||||
|
||||
SCASSERT(doc != nullptr)
|
||||
|
||||
UpdateImages();
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "../vmisc/def.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vpropertyexplorer/checkablemessagebox.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
#include "../vmisc/compatibility.h"
|
||||
|
@ -58,6 +59,12 @@ WatermarkWindow::WatermarkWindow(const QString &patternPath, QWidget *parent)
|
|||
m_patternPath(patternPath)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxOpacity);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxTextRotation);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->spinBoxImageRotation);
|
||||
|
||||
m_okPathColor = ui->lineEditPath->palette().color(ui->lineEditPath->foregroundRole());
|
||||
|
||||
VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "../vpatterndb/vtranslatevars.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "ui_dialogsplinepath.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
|
@ -79,6 +80,13 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, VAbstractPattern *doc
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxNewPoint);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxPoint);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxPenStyle);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBoxColor);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->doubleSpinBoxApproximationScale);
|
||||
|
||||
InitIcons();
|
||||
|
||||
formulaBaseHeightAngle1 = ui->plainTextEditAngle1F->height();
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "../vpatterndb/vpiecenode.h"
|
||||
#include "../vpatterndb/vpiecepath.h"
|
||||
#include "../vwidgets/fancytabbar/fancytabbar.h"
|
||||
#include "../vwidgets/vmousewheelwidgetadjustmentguard.h"
|
||||
#include "dialogpatternmaterials.h"
|
||||
#include "dialogpiecepath.h"
|
||||
#include "dialogplacelabel.h"
|
||||
|
@ -203,6 +204,33 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, VAbstractPatter
|
|||
|
||||
InitIcons();
|
||||
|
||||
// Prevent stealing focus when scrolling
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabGrainline->comboBoxGrainlineCenterPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabGrainline->comboBoxGrainlineTopPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabGrainline->comboBoxGrainlineBottomPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabGrainline->comboBoxArrow);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxPieceLabelSize);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxDLCenterPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxDLTopLeftPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxDLBottomRightPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxPatternLabelSize);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxPLCenterPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxPLTopLeftPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxPLBottomRightPin);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->dateEditCustomerBirthDate);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxDateFormat);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->comboBoxTimeFormat);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabLabels->spinBoxQuantity);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPassmarks->comboBoxPassmarks);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->comboBoxMLStartPoint);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->comboBoxMLEndPoint);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->spinBoxPriority);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->comboBoxNodes);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->comboBoxAngle);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->comboBoxStartPoint);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->comboBoxEndPoint);
|
||||
VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(uiTabPaths->comboBoxIncludeType);
|
||||
|
||||
ChangeColor(uiTabPaths->labelEditName, OkColor(this));
|
||||
flagMainPathIsValid = MainPathIsValid();
|
||||
|
||||
|
|
62
src/libs/vwidgets/vmousewheelwidgetadjustmentguard.cpp
Normal file
62
src/libs/vwidgets/vmousewheelwidgetadjustmentguard.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vmousewheelwidgetadjustmentguard.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 31 1, 2024
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2024 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#include "vmousewheelwidgetadjustmentguard.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QWidget>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VMouseWheelWidgetAdjustmentGuard::VMouseWheelWidgetAdjustmentGuard(QObject *parent)
|
||||
: QObject{parent}
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(QWidget *w)
|
||||
{
|
||||
if (w == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
w->setFocusPolicy(Qt::StrongFocus);
|
||||
w->installEventFilter(new VMouseWheelWidgetAdjustmentGuard(w));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VMouseWheelWidgetAdjustmentGuard::eventFilter(QObject *o, QEvent *e) -> bool
|
||||
{
|
||||
const QWidget *widget = qobject_cast<QWidget *>(o);
|
||||
if (e->type() == QEvent::Wheel && (widget != nullptr) && !widget->hasFocus())
|
||||
{
|
||||
e->ignore();
|
||||
return true;
|
||||
}
|
||||
|
||||
return QObject::eventFilter(o, e);
|
||||
}
|
56
src/libs/vwidgets/vmousewheelwidgetadjustmentguard.h
Normal file
56
src/libs/vwidgets/vmousewheelwidgetadjustmentguard.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vmousewheelwidgetadjustmentguard.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 31 1, 2024
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2024 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
#ifndef VMOUSEWHEELWIDGETADJUSTMENTGUARD_H
|
||||
#define VMOUSEWHEELWIDGETADJUSTMENTGUARD_H
|
||||
|
||||
#include "qtclasshelpermacros.h"
|
||||
#include <QObject>
|
||||
|
||||
// Helps to prevent widget from stealing scroll event.
|
||||
// Install event filter
|
||||
// Example:
|
||||
// VMouseWheelWidgetAdjustmentGuard::InstallEventFilter(ui->comboBox);
|
||||
|
||||
class VMouseWheelWidgetAdjustmentGuard : public QObject
|
||||
{
|
||||
Q_OBJECT // NOLINT
|
||||
|
||||
public:
|
||||
explicit VMouseWheelWidgetAdjustmentGuard(QObject *parent = nullptr);
|
||||
~VMouseWheelWidgetAdjustmentGuard() override = default;
|
||||
|
||||
static void InstallEventFilter(QWidget *w);
|
||||
|
||||
protected:
|
||||
auto eventFilter(QObject *o, QEvent *e) -> bool override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(VMouseWheelWidgetAdjustmentGuard) // NOLINT
|
||||
};
|
||||
|
||||
#endif // VMOUSEWHEELWIDGETADJUSTMENTGUARD_H
|
|
@ -31,7 +31,8 @@ SOURCES += \
|
|||
$$PWD/vhighlighter.cpp \
|
||||
$$PWD/vpiecegrainline.cpp \
|
||||
$$PWD/vtoolbuttonpopup.cpp \
|
||||
$$PWD/vaspectratiopixmaplabel.cpp
|
||||
$$PWD/vaspectratiopixmaplabel.cpp \
|
||||
$$PWD/vmousewheelwidgetadjustmentguard.cpp
|
||||
|
||||
*msvc*:SOURCES += $$PWD/stable.cpp
|
||||
|
||||
|
@ -67,5 +68,6 @@ HEADERS += \
|
|||
$$PWD/vpiecegrainline.h \
|
||||
$$PWD/vpiecegrainline_p.h \
|
||||
$$PWD/vtoolbuttonpopup.h \
|
||||
$$PWD/vaspectratiopixmaplabel.h
|
||||
$$PWD/vaspectratiopixmaplabel.h \
|
||||
$$PWD/vmousewheelwidgetadjustmentguard.h
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ VLib {
|
|||
"velidedlabel.cpp",
|
||||
"vmaingraphicsscene.cpp",
|
||||
"vmaingraphicsview.cpp",
|
||||
"vmousewheelwidgetadjustmentguard.cpp",
|
||||
"vmousewheelwidgetadjustmentguard.h",
|
||||
"vtoolbuttonpopup.cpp",
|
||||
"vtoolbuttonpopup.h",
|
||||
"vwidgetpopup.cpp",
|
||||
|
|
Loading…
Reference in New Issue
Block a user