From c1b4fc5523584be0460ab6fad4cb92f7b4d87208 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 18 Jan 2022 20:10:30 +0100 Subject: [PATCH 1/7] Update pre-commit hooks --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9aeb7b21a31..6a2ac4e8ce6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ default_language_version: python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.1.0 hooks: - id: fix-byte-order-marker exclude: ^.*(\.cbproj|\.groupproj|\.props|\.sln|\.vcxproj|\.vcxproj.filters)$ @@ -63,7 +63,7 @@ repos: #args: [--ignore-words, .codespellignore, --ignore-regex, "\\W(?:m_p*(?=[A-Z])|m_(?=\\w)|pp*(?=[A-Z])|k(?=[A-Z])|s_(?=\\w))"] exclude: ^(packaging/wix/LICENSE.rtf|src/dialog/dlgabout\.cpp|.*\.(?:pot?|ts|wxl))$ - repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.0.0-1 + rev: v8.7.0 hooks: - id: eslint args: [--fix, --report-unused-disable-directives] @@ -83,7 +83,7 @@ repos: language: python files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|m|mm|proto|vert)$ - repo: https://github.com/psf/black - rev: 21.9b0 + rev: 21.12b0 hooks: - id: black files: ^tools/.*$ @@ -94,11 +94,11 @@ repos: files: ^tools/.*$ types: [text, python] - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.7.2.1 + rev: v0.8.0.3 hooks: - id: shellcheck - repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.3.2 + rev: v0.4.0 hooks: - id: markdownlint-cli2 - repo: local From e1f80e935ccbab55af3750b3a106fa6454a2bb2e Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 18 Jan 2022 20:14:47 +0100 Subject: [PATCH 2/7] Fix shellcheck warning SC2048 --- src/test/soundFileFormats/generateFiles.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/soundFileFormats/generateFiles.sh b/src/test/soundFileFormats/generateFiles.sh index 42f38d6da8a..b3b14bc5b7b 100755 --- a/src/test/soundFileFormats/generateFiles.sh +++ b/src/test/soundFileFormats/generateFiles.sh @@ -17,12 +17,12 @@ samplerates=(22050 32000 44100 48000 96000) if [ "$1" == "clean" ] then - for format in ${formats[*]} + for format in "${formats[@]}" do - for rate in ${samplerates[*]} + for rate in "${samplerates[@]}" do friendlyrate=$(( "$rate" / 1000 )) - for channel in ${channels[*]} + for channel in "${channels[@]}" do if [ "$channel" -eq 1 ] then @@ -44,7 +44,7 @@ then fi fi - for ssize in ${samplesizes[*]} + for ssize in "${samplesizes[@]}" do if [ -e "test${ssize}bit${friendlyrate}k${friendlychannel}.${format}" ] then @@ -80,7 +80,7 @@ then fi # Do the conversions/generate the table -for format in ${formats[*]} +for format in "${formats[@]}" do if [ "$1" == "table" ] then @@ -104,7 +104,7 @@ do echo "==== $friendlyformat ====" echo "^ Channels ^ Bit depth ^ Sample Rate ^ Does it work? ^" fi - for channel in ${channels[*]} + for channel in "${channels[@]}" do if [ "$channel" -eq 1 ] then @@ -116,7 +116,7 @@ do friendlychannel="Stereo" lameopt=() fi - for ssize in ${samplesizes[*]} + for ssize in "${samplesizes[@]}" do # Hack because sox doesn't abort if the parameters are out of spec if [ "$ssize" -gt 24 ] && [ "$format" == "flac" ] @@ -133,7 +133,7 @@ do then break fi - for rate in ${samplerates[*]} + for rate in "${samplerates[@]}" do friendlyrate=$(( "$rate" / 1000 )) problem="false" From ac5e4c41069b61c3be178bb7b277e288b405c35d Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 14 Jan 2022 14:04:39 +0100 Subject: [PATCH 3/7] Fix segfault when using midi.sendShortMsg and platform vnc This fixes lp1956144 by adding a missing null check --- src/util/screensaver.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/util/screensaver.cpp b/src/util/screensaver.cpp index 2c1cc970f3b..85f1006bef9 100644 --- a/src/util/screensaver.cpp +++ b/src/util/screensaver.cpp @@ -174,8 +174,10 @@ void ScreenSaverHelper::triggerUserActivity() name=getenv("DISPLAY"); } display=XOpenDisplay(name); - XResetScreenSaver(display); - XCloseDisplay(display); + if (display != nullptr) { + XResetScreenSaver(display); + XCloseDisplay(display); + } return; } // Disabling the method with DBus since it seems to be failing on several systems. From acf1458a01df71b85ba90f26c6432148477a90b7 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 18 Jan 2022 23:55:06 +0100 Subject: [PATCH 4/7] Add missing Q_OBJECT macro to QObject-derived classes These were found by clazy. --- src/control/control.h | 1 + src/controllers/bulk/bulkenumerator.h | 1 + src/controllers/delegates/midibytedelegate.h | 1 + src/controllers/delegates/midichanneldelegate.h | 1 + src/controllers/delegates/midiopcodedelegate.h | 1 + src/controllers/hid/hidenumerator.h | 1 + src/effects/chains/equalizereffectchain.h | 1 + src/effects/chains/outputeffectchain.h | 1 + src/effects/chains/pergroupeffectchain.h | 1 + src/effects/chains/quickeffectchain.h | 1 + src/effects/chains/standardeffectchain.h | 1 + src/engine/bufferscalers/enginebufferscalelinear.h | 1 + src/engine/enginepregain.h | 1 + src/engine/positionscratchcontroller.h | 1 + src/library/proxytrackmodel.h | 1 + src/library/rekordbox/rekordboxfeature.h | 1 + src/library/serato/seratoplaylistmodel.h | 1 + src/library/traktor/traktorfeature.h | 2 ++ src/qml/asyncimageprovider.h | 1 + src/util/battery/batterylinux.h | 1 + src/util/battery/batterymac.h | 1 + src/util/battery/batterywindows.h | 1 + src/util/workerthreadscheduler.h | 1 + src/vinylcontrol/vinylcontrol.h | 1 + src/vinylcontrol/vinylcontrolxwax.h | 1 + src/widget/wanalysislibrarytableview.h | 1 + src/widget/woverviewhsv.h | 1 + src/widget/woverviewlmh.h | 1 + src/widget/woverviewrgb.h | 1 + 29 files changed, 30 insertions(+) diff --git a/src/control/control.h b/src/control/control.h index 8c2332cefd9..69c6b6e10de 100644 --- a/src/control/control.h +++ b/src/control/control.h @@ -209,6 +209,7 @@ class ControlDoublePrivate : public QObject { /// The constant ControlDoublePrivate version is used as dummy for default /// constructed control objects class ControlDoublePrivateConst : public ControlDoublePrivate { + Q_OBJECT public: ~ControlDoublePrivateConst() override = default; diff --git a/src/controllers/bulk/bulkenumerator.h b/src/controllers/bulk/bulkenumerator.h index b1c2569f33c..05c55275c09 100644 --- a/src/controllers/bulk/bulkenumerator.h +++ b/src/controllers/bulk/bulkenumerator.h @@ -6,6 +6,7 @@ struct libusb_context; /// Locate supported USB bulk controllers class BulkEnumerator : public ControllerEnumerator { + Q_OBJECT public: explicit BulkEnumerator(UserSettingsPointer pConfig); virtual ~BulkEnumerator(); diff --git a/src/controllers/delegates/midibytedelegate.h b/src/controllers/delegates/midibytedelegate.h index 83700de56b3..e777966031b 100644 --- a/src/controllers/delegates/midibytedelegate.h +++ b/src/controllers/delegates/midibytedelegate.h @@ -3,6 +3,7 @@ #include class MidiByteDelegate : public QStyledItemDelegate { + Q_OBJECT public: MidiByteDelegate(QObject* pParent); virtual ~MidiByteDelegate(); diff --git a/src/controllers/delegates/midichanneldelegate.h b/src/controllers/delegates/midichanneldelegate.h index b6dd7c7e563..bd5300faae3 100644 --- a/src/controllers/delegates/midichanneldelegate.h +++ b/src/controllers/delegates/midichanneldelegate.h @@ -3,6 +3,7 @@ #include class MidiChannelDelegate : public QStyledItemDelegate { + Q_OBJECT public: MidiChannelDelegate(QObject* pParent); virtual ~MidiChannelDelegate(); diff --git a/src/controllers/delegates/midiopcodedelegate.h b/src/controllers/delegates/midiopcodedelegate.h index 0b9963bd5a0..166c50512bb 100644 --- a/src/controllers/delegates/midiopcodedelegate.h +++ b/src/controllers/delegates/midiopcodedelegate.h @@ -3,6 +3,7 @@ #include class MidiOpCodeDelegate : public QStyledItemDelegate { + Q_OBJECT public: MidiOpCodeDelegate(QObject* pParent); virtual ~MidiOpCodeDelegate(); diff --git a/src/controllers/hid/hidenumerator.h b/src/controllers/hid/hidenumerator.h index 6d35a22a2c5..8485b408a47 100644 --- a/src/controllers/hid/hidenumerator.h +++ b/src/controllers/hid/hidenumerator.h @@ -5,6 +5,7 @@ /// This class handles discovery and enumeration of DJ controllers that use the /// USB-HID protocol. class HidEnumerator : public ControllerEnumerator { + Q_OBJECT public: HidEnumerator() = default; ~HidEnumerator() override; diff --git a/src/effects/chains/equalizereffectchain.h b/src/effects/chains/equalizereffectchain.h index 153ca1b864f..98a15973838 100644 --- a/src/effects/chains/equalizereffectchain.h +++ b/src/effects/chains/equalizereffectchain.h @@ -9,6 +9,7 @@ /// EqualizerEffectChain is hardwired to one input channel, always /// enabled, and has the mix knob fully enabled. class EqualizerEffectChain : public PerGroupEffectChain { + Q_OBJECT public: EqualizerEffectChain(const QString& group, EffectsManager* pEffectsManager, diff --git a/src/effects/chains/outputeffectchain.h b/src/effects/chains/outputeffectchain.h index 195594b8bd6..93f41172297 100644 --- a/src/effects/chains/outputeffectchain.h +++ b/src/effects/chains/outputeffectchain.h @@ -5,6 +5,7 @@ /// OutputEffectChain is hardwired to only one of Mixxx's outputs. /// This is used for the main mix equalizer. class OutputEffectChain : public EffectChain { + Q_OBJECT public: OutputEffectChain(EffectsManager* pEffectsManager, EffectsMessengerPointer pEffectsMessenger); diff --git a/src/effects/chains/pergroupeffectchain.h b/src/effects/chains/pergroupeffectchain.h index 45174610528..acf10c3743c 100644 --- a/src/effects/chains/pergroupeffectchain.h +++ b/src/effects/chains/pergroupeffectchain.h @@ -5,6 +5,7 @@ /// PerGroupEffectChain is a base class hardwired for one input channel. /// The routing switches are not presented to the user. class PerGroupEffectChain : public EffectChain { + Q_OBJECT public: PerGroupEffectChain(const QString& group, const QString& chainSlotGroup, diff --git a/src/effects/chains/quickeffectchain.h b/src/effects/chains/quickeffectchain.h index 7f35486219d..34c747281f7 100644 --- a/src/effects/chains/quickeffectchain.h +++ b/src/effects/chains/quickeffectchain.h @@ -8,6 +8,7 @@ /// then load it into QuickEffectChain. QuickEffectChain is hardwired to one /// input channel with the mix knob fully enabled. class QuickEffectChain : public PerGroupEffectChain { + Q_OBJECT public: QuickEffectChain(const QString& group, EffectsManager* pEffectsManager, diff --git a/src/effects/chains/standardeffectchain.h b/src/effects/chains/standardeffectchain.h index 9a470e41f7c..fe0473e7413 100644 --- a/src/effects/chains/standardeffectchain.h +++ b/src/effects/chains/standardeffectchain.h @@ -8,6 +8,7 @@ /// linkings. However, the chain enable switch is hidden because it /// is redundant with the input routing switches and effect enable switches. class StandardEffectChain : public EffectChain { + Q_OBJECT public: StandardEffectChain(unsigned int iChainNumber, EffectsManager* pEffectsManager, diff --git a/src/engine/bufferscalers/enginebufferscalelinear.h b/src/engine/bufferscalers/enginebufferscalelinear.h index 4d7b989c295..5c7882ee1c0 100644 --- a/src/engine/bufferscalers/enginebufferscalelinear.h +++ b/src/engine/bufferscalers/enginebufferscalelinear.h @@ -8,6 +8,7 @@ constexpr int kiLinearScaleReadAheadLength = 10240; class EngineBufferScaleLinear : public EngineBufferScale { + Q_OBJECT public: explicit EngineBufferScaleLinear( ReadAheadManager *pReadAheadManager); diff --git a/src/engine/enginepregain.h b/src/engine/enginepregain.h index 2d5b1b50f8b..eb3dd3f6f9f 100644 --- a/src/engine/enginepregain.h +++ b/src/engine/enginepregain.h @@ -12,6 +12,7 @@ class ControlObject; // including user pregain adjustment, ReplayGain value, and vinyl-like // adjustments in volume relative to playback speed. class EnginePregain : public EngineObject { + Q_OBJECT public: EnginePregain(const QString& group); ~EnginePregain() override; diff --git a/src/engine/positionscratchcontroller.h b/src/engine/positionscratchcontroller.h index 9d5a8bd0695..3969048a2f8 100644 --- a/src/engine/positionscratchcontroller.h +++ b/src/engine/positionscratchcontroller.h @@ -10,6 +10,7 @@ class VelocityController; class RateIIFilter; class PositionScratchController : public QObject { + Q_OBJECT public: PositionScratchController(const QString& group); virtual ~PositionScratchController(); diff --git a/src/library/proxytrackmodel.h b/src/library/proxytrackmodel.h index b7ac388433d..d56ef77eeb5 100644 --- a/src/library/proxytrackmodel.h +++ b/src/library/proxytrackmodel.h @@ -13,6 +13,7 @@ // TrackModel search calls will not be delivered to the composed TrackModel // because filtering is handled by the QSortFilterProxyModel. class ProxyTrackModel : public QSortFilterProxyModel, public TrackModel { + Q_OBJECT public: // Construct a new ProxyTrackModel with pTrackModel as the TrackModel it // composes. If bHandleSearches is true, then search signals will not be diff --git a/src/library/rekordbox/rekordboxfeature.h b/src/library/rekordbox/rekordboxfeature.h index 0d3c607c076..68f9b3e467c 100644 --- a/src/library/rekordbox/rekordboxfeature.h +++ b/src/library/rekordbox/rekordboxfeature.h @@ -40,6 +40,7 @@ class TrackCollectionManager; class BaseExternalPlaylistModel; class RekordboxPlaylistModel : public BaseExternalPlaylistModel { + Q_OBJECT public: RekordboxPlaylistModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, diff --git a/src/library/serato/seratoplaylistmodel.h b/src/library/serato/seratoplaylistmodel.h index 18a73b311f0..f2daa327bf4 100644 --- a/src/library/serato/seratoplaylistmodel.h +++ b/src/library/serato/seratoplaylistmodel.h @@ -7,6 +7,7 @@ class TrackCollectionManager; class BaseExternalPlaylistModel; class SeratoPlaylistModel : public BaseExternalPlaylistModel { + Q_OBJECT public: SeratoPlaylistModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, diff --git a/src/library/traktor/traktorfeature.h b/src/library/traktor/traktorfeature.h index fcb56b14320..6e3e1200896 100644 --- a/src/library/traktor/traktorfeature.h +++ b/src/library/traktor/traktorfeature.h @@ -13,6 +13,7 @@ #include "library/treeitemmodel.h" class TraktorTrackModel : public BaseExternalTrackModel { + Q_OBJECT public: TraktorTrackModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, @@ -21,6 +22,7 @@ class TraktorTrackModel : public BaseExternalTrackModel { }; class TraktorPlaylistModel : public BaseExternalPlaylistModel { + Q_OBJECT public: TraktorPlaylistModel(QObject* parent, TrackCollectionManager* pTrackCollectionManager, diff --git a/src/qml/asyncimageprovider.h b/src/qml/asyncimageprovider.h index 8544a42e69f..ed2ed83d9dd 100644 --- a/src/qml/asyncimageprovider.h +++ b/src/qml/asyncimageprovider.h @@ -11,6 +11,7 @@ namespace mixxx { namespace qml { class AsyncImageResponse : public QQuickImageResponse, public QRunnable { + Q_OBJECT public: AsyncImageResponse(const QString& id, const QSize& requestedSize); QQuickTextureFactory* textureFactory() const override; diff --git a/src/util/battery/batterylinux.h b/src/util/battery/batterylinux.h index eb1e5e059d9..55ef892e822 100644 --- a/src/util/battery/batterylinux.h +++ b/src/util/battery/batterylinux.h @@ -3,6 +3,7 @@ #include "util/battery/battery.h" class BatteryLinux : public Battery { + Q_OBJECT public: explicit BatteryLinux(QObject* pParent=nullptr); ~BatteryLinux() override; diff --git a/src/util/battery/batterymac.h b/src/util/battery/batterymac.h index 77656e06933..43a79c57814 100644 --- a/src/util/battery/batterymac.h +++ b/src/util/battery/batterymac.h @@ -3,6 +3,7 @@ #include "util/battery/battery.h" class BatteryMac : public Battery { + Q_OBJECT public: BatteryMac(QObject* pParent=nullptr); virtual ~BatteryMac(); diff --git a/src/util/battery/batterywindows.h b/src/util/battery/batterywindows.h index 4981d11ed68..6a36f880a8e 100644 --- a/src/util/battery/batterywindows.h +++ b/src/util/battery/batterywindows.h @@ -3,6 +3,7 @@ #include "util/battery/battery.h" class BatteryWindows : public Battery { + Q_OBJECT public: BatteryWindows(QObject* pParent=nullptr); ~BatteryWindows() override = default; diff --git a/src/util/workerthreadscheduler.h b/src/util/workerthreadscheduler.h index 0667ab5e794..676bba768d1 100644 --- a/src/util/workerthreadscheduler.h +++ b/src/util/workerthreadscheduler.h @@ -10,6 +10,7 @@ class WorkerThread; /// as a worker thread. The maximum number of worker threads is /// limited. class WorkerThreadScheduler : public WorkerThread { + Q_OBJECT public: explicit WorkerThreadScheduler( int maxWorkers, diff --git a/src/vinylcontrol/vinylcontrol.h b/src/vinylcontrol/vinylcontrol.h index c3ffd02a2ba..ced857a2f60 100644 --- a/src/vinylcontrol/vinylcontrol.h +++ b/src/vinylcontrol/vinylcontrol.h @@ -9,6 +9,7 @@ class ControlProxy; class VinylControl : public QObject { + Q_OBJECT public: VinylControl(UserSettingsPointer pConfig, const QString& group); virtual ~VinylControl(); diff --git a/src/vinylcontrol/vinylcontrolxwax.h b/src/vinylcontrol/vinylcontrolxwax.h index 1082a9ac7c6..c223108938f 100644 --- a/src/vinylcontrol/vinylcontrolxwax.h +++ b/src/vinylcontrol/vinylcontrolxwax.h @@ -21,6 +21,7 @@ extern "C" { #define QUALITY_RING_SIZE 32 class VinylControlXwax : public VinylControl { + Q_OBJECT public: VinylControlXwax(UserSettingsPointer pConfig, const QString& group); virtual ~VinylControlXwax(); diff --git a/src/widget/wanalysislibrarytableview.h b/src/widget/wanalysislibrarytableview.h index b732a0f54b2..32924655ab2 100644 --- a/src/widget/wanalysislibrarytableview.h +++ b/src/widget/wanalysislibrarytableview.h @@ -6,6 +6,7 @@ #include "widget/wtracktableview.h" class WAnalysisLibraryTableView : public WTrackTableView { + Q_OBJECT public: WAnalysisLibraryTableView( QWidget* parent, diff --git a/src/widget/woverviewhsv.h b/src/widget/woverviewhsv.h index 9876040adf2..3fa9bf7d153 100644 --- a/src/widget/woverviewhsv.h +++ b/src/widget/woverviewhsv.h @@ -3,6 +3,7 @@ #include "widget/woverview.h" class WOverviewHSV : public WOverview { + Q_OBJECT public: WOverviewHSV( const QString& group, diff --git a/src/widget/woverviewlmh.h b/src/widget/woverviewlmh.h index 3b1913c85bc..8bc05fb3c8a 100644 --- a/src/widget/woverviewlmh.h +++ b/src/widget/woverviewlmh.h @@ -3,6 +3,7 @@ #include "widget/woverview.h" class WOverviewLMH : public WOverview { + Q_OBJECT public: WOverviewLMH( const QString& group, diff --git a/src/widget/woverviewrgb.h b/src/widget/woverviewrgb.h index d249243998d..000b60be4f1 100644 --- a/src/widget/woverviewrgb.h +++ b/src/widget/woverviewrgb.h @@ -3,6 +3,7 @@ #include "widget/woverview.h" class WOverviewRGB : public WOverview { + Q_OBJECT public: WOverviewRGB( const QString& group, From 0a863eea137ec76786d38c89676c3f1088cc2d74 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 18 Jan 2022 23:56:25 +0100 Subject: [PATCH 5/7] WSizeAwareStack: Move SizeAwareLayout to header file --- src/widget/wsizeawarestack.cpp | 103 ++++++++++++++++----------------- src/widget/wsizeawarestack.h | 11 +++- 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/src/widget/wsizeawarestack.cpp b/src/widget/wsizeawarestack.cpp index 3032110624e..5de9102a9c1 100644 --- a/src/widget/wsizeawarestack.cpp +++ b/src/widget/wsizeawarestack.cpp @@ -6,71 +6,66 @@ #include "moc_wsizeawarestack.cpp" -class SizeAwareLayout : public QStackedLayout -{ - public: - QSize minimumSize() const override - { - QSize s(0, 0) ; - QWidget *w = widget(0); - if (w) { - // Minimum Widget is at index 0; - s = w->minimumSize(); - } - return s; +QSize SizeAwareLayout::minimumSize() const { + QSize s(0, 0); + QWidget* w = widget(0); + if (w) { + // Minimum Widget is at index 0; + s = w->minimumSize(); } + return s; +} - int setCurrentIndexForSize(const QSize& s) { - int n = count(); - if (n <= 0) { - return -1; - } +int SizeAwareLayout::setCurrentIndexForSize(const QSize& s) { + int n = count(); + if (n <= 0) { + return -1; + } - int i = currentIndex(); + int i = currentIndex(); - QWidget *wc = widget(i); - bool notFit = false; - if (i > 0) { - // Check minimum, but not for the smallest, it is the fallback - notFit = wc->minimumHeight() > s.height() || wc->minimumWidth() > s.width(); - } - if (i < n - 1 && !notFit) { - // Check maximum, but not for the biggest, it is the fallback - notFit = wc->maximumHeight() < s.height() || wc->maximumWidth() < s.width(); - } + QWidget* wc = widget(i); + bool notFit = false; + if (i > 0) { + // Check minimum, but not for the smallest, it is the fallback + notFit = wc->minimumHeight() > s.height() || wc->minimumWidth() > s.width(); + } + if (i < n - 1 && !notFit) { + // Check maximum, but not for the biggest, it is the fallback + notFit = wc->maximumHeight() < s.height() || wc->maximumWidth() < s.width(); + } - if (notFit) { - QWidget *w; - for (i = 0; i < n; ++i) { - w = widget(i); - if (w) { - if (w->maximumHeight() >= s.height() && w->maximumWidth() >= s.width() && - w->minimumHeight() <= s.height() && w->minimumWidth() <= s.width()) { - // perfectly fit - setCurrentIndex(i); - return i; - } + if (notFit) { + QWidget* w; + for (i = 0; i < n; ++i) { + w = widget(i); + if (w) { + if (w->maximumHeight() >= s.height() && w->maximumWidth() >= s.width() && + w->minimumHeight() <= s.height() && w->minimumWidth() <= s.width()) { + // perfectly fit + setCurrentIndex(i); + return i; } } - // no perfect fit, check minimum only to avoid chopping - for (i = n-1; i >= 0; --i) { - w = widget(i); - if (w) { - if (w->minimumHeight() <= s.height() && w->minimumWidth() <= s.width()) { - // fit with gap - setCurrentIndex(i); - return i; - } + } + // no perfect fit, check minimum only to avoid chopping + for (i = n - 1; i >= 0; --i) { + w = widget(i); + if (w) { + if (w->minimumHeight() <= s.height() && w->minimumWidth() <= s.width()) { + // fit with gap + setCurrentIndex(i); + return i; } } - // fallback: take smallest - setCurrentIndex(0); - return 0; } - - return i; + // fallback: take smallest + setCurrentIndex(0); + return 0; } -}; + + return i; +} WSizeAwareStack::WSizeAwareStack(QWidget* parent) : QWidget(parent), diff --git a/src/widget/wsizeawarestack.h b/src/widget/wsizeawarestack.h index 97032b89407..918c8d5d634 100644 --- a/src/widget/wsizeawarestack.h +++ b/src/widget/wsizeawarestack.h @@ -1,11 +1,18 @@ #pragma once -#include #include +#include +#include +#include #include "widget/wbasewidget.h" -class SizeAwareLayout; +class SizeAwareLayout : public QStackedLayout { + Q_OBJECT + public: + QSize minimumSize() const override; + int setCurrentIndexForSize(const QSize& s); +}; class WSizeAwareStack : public QWidget, public WBaseWidget { Q_OBJECT From a6f7d2abc77a88b156c450e93569bae5c1e79791 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 18 Jan 2022 23:57:10 +0100 Subject: [PATCH 6/7] qHash: Use qhash_seed_t instead of uint as return value --- src/effects/backends/effectmanifestparameter.h | 5 +++-- src/effects/defs.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/effects/backends/effectmanifestparameter.h b/src/effects/backends/effectmanifestparameter.h index 9faed4a8f83..ed711957f9e 100644 --- a/src/effects/backends/effectmanifestparameter.h +++ b/src/effects/backends/effectmanifestparameter.h @@ -7,6 +7,7 @@ #include "effects/defs.h" #include "util/assert.h" +#include "util/compatibility/qhash.h" class EffectManifestParameter; typedef QSharedPointer EffectManifestParameterPointer; @@ -277,6 +278,6 @@ QDebug operator<<(QDebug dbg, const EffectManifestParameter& parameter); typedef EffectManifestParameter::ParameterType EffectParameterType; -inline uint qHash(const EffectParameterType& parameterType) { - return static_cast(parameterType); +inline qhash_seed_t qHash(const EffectParameterType& parameterType) { + return static_cast(parameterType); } diff --git a/src/effects/defs.h b/src/effects/defs.h index e6284a3e55c..d1ba49b8590 100644 --- a/src/effects/defs.h +++ b/src/effects/defs.h @@ -20,8 +20,8 @@ enum class EffectBackendType { Unknown }; -inline uint qHash(const EffectBackendType& backendType) { - return static_cast(backendType); +inline qhash_seed_t qHash(const EffectBackendType& backendType) { + return static_cast(backendType); } enum class SignalProcessingStage { From c4cfc8fbadd8f32da428102ca85483fdd295bbe3 Mon Sep 17 00:00:00 2001 From: Jan Holthuis Date: Tue, 18 Jan 2022 23:58:56 +0100 Subject: [PATCH 7/7] Use QDir::setPath() instead of deprecated QDir::operator=() --- src/library/export/dlglibraryexport.cpp | 4 ++-- src/library/serato/seratofeature.cpp | 2 +- src/util/desktophelper.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/library/export/dlglibraryexport.cpp b/src/library/export/dlglibraryexport.cpp index 9b0e6eff5f6..26fbdf73ae6 100644 --- a/src/library/export/dlglibraryexport.cpp +++ b/src/library/export/dlglibraryexport.cpp @@ -203,8 +203,8 @@ void DlgLibraryExport::exportRequested() { // Construct a request to export the library/crates. auto pRequest = QSharedPointer::create(); - pRequest->engineLibraryDbDir = QDir{databaseDirectory}; - pRequest->musicFilesDir = QDir{musicDirectory}; + pRequest->engineLibraryDbDir.setPath(databaseDirectory); + pRequest->musicFilesDir.setPath(musicDirectory); pRequest->exportVersion = exportVersion; if (m_pCratesList->isEnabled()) { const auto selectedItems = m_pCratesList->selectedItems(); diff --git a/src/library/serato/seratofeature.cpp b/src/library/serato/seratofeature.cpp index 0819189b6ed..379e5cbf08e 100644 --- a/src/library/serato/seratofeature.cpp +++ b/src/library/serato/seratofeature.cpp @@ -454,7 +454,7 @@ QString parseDatabase(mixxx::DbConnectionPoolPtr dbConnectionPool, TreeItem* dat // Serato does not exist on Linux, if it did, it would probably just mirror // the way paths are handled on OSX. if (databaseRootDir.canonicalPath().startsWith(QDir::homePath())) { - databaseRootDir = QDir::root(); + databaseRootDir.setPath(QDir::rootPath()); } #endif diff --git a/src/util/desktophelper.cpp b/src/util/desktophelper.cpp index 06faae00cd7..8f9018507ee 100644 --- a/src/util/desktophelper.cpp +++ b/src/util/desktophelper.cpp @@ -159,7 +159,7 @@ void DesktopHelper::openInFileBrowser(const QStringList& paths) { // Otherwise nothing would happen... if (!dir.exists()) { // it ensures a valid dir for any OS (Windows) - dir = QDir::home(); + dir.setPath(QDir::homePath()); } // not open the same dir twice dirPath = dir.absolutePath();