diff --git a/.clang-format b/.clang-format index 6ef53c0ba9f..2dd10f73e29 100644 --- a/.clang-format +++ b/.clang-format @@ -1,7 +1,7 @@ --- # Language Language: Cpp -Standard: Cpp11 # Cpp14 and Cpp17 are not supported by clang 11 +Standard: c++20 # Indentation TabWidth: 4 diff --git a/.clang-tidy b/.clang-tidy index 5de9376e5cd..9c69f4c3c14 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -20,7 +20,6 @@ Checks: > readability-simplify-boolean-expr WarningsAsErrors: '' HeaderFilterRegex: '' # don't show errors from headers -AnalyzeTemporaryDtors: false FormatStyle: none User: user CheckOptions: diff --git a/cmake/modules/ErrorFlags.cmake b/cmake/modules/ErrorFlags.cmake index 57cc6ad49f8..175c95611e7 100644 --- a/cmake/modules/ErrorFlags.cmake +++ b/cmake/modules/ErrorFlags.cmake @@ -65,6 +65,10 @@ elseif(MSVC) "/WX" # Treat warnings as errors ) endif() + + # Silence deprecation warnings for the std::atomic_... family of functions. + # TODO: Remove once C++20's std::atomic is fully supported. + add_compile_definitions("_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING") endif() # Add the flags to the whole directory tree. We use the third-party flags for diff --git a/include/DeprecationHelper.h b/include/DeprecationHelper.h index b9be6d42ff3..02a57c3fa40 100644 --- a/include/DeprecationHelper.h +++ b/include/DeprecationHelper.h @@ -27,7 +27,10 @@ #ifndef LMMS_DEPRECATIONHELPER_H #define LMMS_DEPRECATIONHELPER_H +#include + #include +#include #include namespace lmms @@ -64,6 +67,30 @@ inline QPoint position(QWheelEvent *wheelEvent) #endif } + +namespace detail +{ + +template +inline constexpr bool IsKeyOrModifier = std::is_same_v + || std::is_same_v || std::is_same_v; + +} // namespace detail + + +/** + * @brief Combines Qt key and modifier arguments together, + * replacing `A | B` which was deprecated in C++20 + * due to the enums being different types. (P1120R0) + * @param args Any number of Qt::Key, Qt::Modifier, or Qt::KeyboardModifier + * @return The combination of the given keys/modifiers as an int + */ +template && ...), bool> = true> +constexpr int combine(Args... args) +{ + return (0 | ... | static_cast(args)); +} + } // namespace lmms #endif // LMMS_DEPRECATIONHELPER_H diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 04862cac1ba..7b63e5ead9d 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -2,8 +2,8 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") SET(CMAKE_DEBUG_POSTFIX "") -# Enable C++17 -SET(CMAKE_CXX_STANDARD 17) +# Enable C++20 +SET(CMAKE_CXX_STANDARD 20) IF(LMMS_BUILD_APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp index 2b0ca4fecf7..8b2c0f35eee 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp @@ -341,7 +341,6 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) m_waterfall = new SaWaterfallView(controls, processor, this); display_splitter->addWidget(m_waterfall); m_waterfall->setVisible(m_controls->m_waterfallModel.value()); - connect(&controls->m_waterfallModel, &BoolModel::dataChanged, [=] {m_waterfall->updateVisibility();}); } diff --git a/plugins/SpectrumAnalyzer/SaWaterfallView.cpp b/plugins/SpectrumAnalyzer/SaWaterfallView.cpp index 5169a4b499f..b3e57d7c0ab 100644 --- a/plugins/SpectrumAnalyzer/SaWaterfallView.cpp +++ b/plugins/SpectrumAnalyzer/SaWaterfallView.cpp @@ -54,6 +54,7 @@ SaWaterfallView::SaWaterfallView(SaControls *controls, SaProcessor *processor, Q setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); connect(getGUI()->mainWindow(), SIGNAL(periodicUpdate()), this, SLOT(periodicUpdate())); + connect(&controls->m_waterfallModel, &BoolModel::dataChanged, this, &SaWaterfallView::updateVisibility); m_displayTop = 1; m_displayBottom = height() -2; diff --git a/plugins/Vibed/NineButtonSelector.cpp b/plugins/Vibed/NineButtonSelector.cpp index 3a68e5ee69e..38c890d8019 100644 --- a/plugins/Vibed/NineButtonSelector.cpp +++ b/plugins/Vibed/NineButtonSelector.cpp @@ -47,7 +47,7 @@ NineButtonSelector::NineButtonSelector(std::array onOffIcons, int d m_buttons[i]->setActiveGraphic(onOffIcons[i * 2]); m_buttons[i]->setInactiveGraphic(onOffIcons[(i * 2) + 1]); m_buttons[i]->setChecked(false); - connect(m_buttons[i].get(), &PixmapButton::clicked, this, [=](){ this->buttonClicked(i); }); + connect(m_buttons[i].get(), &PixmapButton::clicked, this, [=, this](){ buttonClicked(i); }); } m_lastBtn = m_buttons[defaultButton].get(); diff --git a/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt b/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt index 3f861e2d566..8281d2a3092 100644 --- a/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt +++ b/plugins/VstBase/RemoteVstPlugin/CMakeLists.txt @@ -6,7 +6,7 @@ endif() project(RemoteVstPlugin LANGUAGES CXX) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) include(CheckCXXPreprocessor) include(CheckCXXSourceCompiles) @@ -73,7 +73,7 @@ if(MSVC) endif() if(IS_MINGW) - SET(CMAKE_REQUIRED_FLAGS "-std=c++17") + SET(CMAKE_REQUIRED_FLAGS "-std=c++20") endif() if(LMMS_BUILD_WIN32) diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt index e5cb6252756..a959e3c7b0f 100644 --- a/src/3rdparty/CMakeLists.txt +++ b/src/3rdparty/CMakeLists.txt @@ -15,7 +15,7 @@ ADD_SUBDIRECTORY(weakjack) add_library(ringbuffer OBJECT ringbuffer/src/lib/ringbuffer.cpp ) -target_compile_features(ringbuffer PUBLIC cxx_std_17) +target_compile_features(ringbuffer PUBLIC cxx_std_20) target_include_directories(ringbuffer PUBLIC ringbuffer/include "${CMAKE_CURRENT_BINARY_DIR}" diff --git a/src/3rdparty/hiir/CMakeLists.txt b/src/3rdparty/hiir/CMakeLists.txt index e954ff187f5..248322adb3d 100644 --- a/src/3rdparty/hiir/CMakeLists.txt +++ b/src/3rdparty/hiir/CMakeLists.txt @@ -1,3 +1,3 @@ add_library(hiir INTERFACE) target_include_directories(hiir INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_compile_features(hiir INTERFACE cxx_std_17) +target_compile_features(hiir INTERFACE cxx_std_20) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7645e49e34e..c458a5cd227 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,8 +9,8 @@ SET(CMAKE_AUTOMOC ON) SET(CMAKE_AUTOUIC ON) SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) -# Enable C++17 -SET(CMAKE_CXX_STANDARD 17) +# Enable C++20 +SET(CMAKE_CXX_STANDARD 20) IF(LMMS_BUILD_APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") diff --git a/src/gui/ControllerRackView.cpp b/src/gui/ControllerRackView.cpp index e7d2efebd06..1cc80c08fae 100644 --- a/src/gui/ControllerRackView.cpp +++ b/src/gui/ControllerRackView.cpp @@ -23,6 +23,8 @@ * */ +#include "ControllerRackView.h" + #include #include #include @@ -30,13 +32,13 @@ #include #include -#include "Song.h" +#include "ControllerView.h" +#include "DeprecationHelper.h" #include "embed.h" #include "GuiApplication.h" -#include "MainWindow.h" -#include "ControllerRackView.h" -#include "ControllerView.h" #include "LfoController.h" +#include "MainWindow.h" +#include "Song.h" #include "SubWindow.h" namespace lmms::gui @@ -167,13 +169,13 @@ void ControllerRackView::addController(Controller* controller) connect(controllerView, &ControllerView::removedController, this, &ControllerRackView::deleteController, Qt::QueuedConnection); auto moveUpAction = new QAction(controllerView); - moveUpAction->setShortcut(Qt::Key_Up | Qt::AltModifier); + moveUpAction->setShortcut(combine(Qt::Key_Up, Qt::AltModifier)); moveUpAction->setShortcutContext(Qt::WidgetShortcut); connect(moveUpAction, &QAction::triggered, controllerView, &ControllerView::moveUp); controllerView->addAction(moveUpAction); auto moveDownAction = new QAction(controllerView); - moveDownAction->setShortcut(Qt::Key_Down | Qt::AltModifier); + moveDownAction->setShortcut(combine(Qt::Key_Down, Qt::AltModifier)); moveDownAction->setShortcutContext(Qt::WidgetShortcut); connect(moveDownAction, &QAction::triggered, controllerView, &ControllerView::moveDown); controllerView->addAction(moveDownAction); diff --git a/src/gui/EffectRackView.cpp b/src/gui/EffectRackView.cpp index b43ec7648b0..6a4b3124d05 100644 --- a/src/gui/EffectRackView.cpp +++ b/src/gui/EffectRackView.cpp @@ -23,13 +23,15 @@ * */ +#include "EffectRackView.h" + #include #include #include #include #include -#include "EffectRackView.h" +#include "DeprecationHelper.h" #include "EffectSelectDialog.h" #include "EffectView.h" #include "GroupBox.h" @@ -176,13 +178,13 @@ void EffectRackView::update() connect(view, &EffectView::deletedPlugin, this, &EffectRackView::deletePlugin, Qt::QueuedConnection); QAction* moveUpAction = new QAction(view); - moveUpAction->setShortcut(Qt::Key_Up | Qt::AltModifier); + moveUpAction->setShortcut(combine(Qt::Key_Up, Qt::AltModifier)); moveUpAction->setShortcutContext(Qt::WidgetShortcut); connect(moveUpAction, &QAction::triggered, view, &EffectView::moveUp); view->addAction(moveUpAction); QAction* moveDownAction = new QAction(view); - moveDownAction->setShortcut(Qt::Key_Down | Qt::AltModifier); + moveDownAction->setShortcut(combine(Qt::Key_Down, Qt::AltModifier)); moveDownAction->setShortcutContext(Qt::WidgetShortcut); connect(moveDownAction, &QAction::triggered, view, &EffectView::moveDown); view->addAction(moveDownAction); diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index e5168fac8bb..a9f18d6fdc5 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -635,7 +635,7 @@ void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e ) contextMenu.addAction( tr( "Send to active instrument-track" ), - [=]{ sendToActiveInstrumentTrack(file); } + [=, this]{ sendToActiveInstrumentTrack(file); } ); contextMenu.addSeparator(); @@ -643,7 +643,7 @@ void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent * e ) contextMenu.addAction( QIcon(embed::getIconPixmap("folder")), tr("Open containing folder"), - [=]{ openContainingFolder(file); } + [=, this]{ openContainingFolder(file); } ); auto songEditorHeader = new QAction(tr("Song Editor"), nullptr); @@ -676,14 +676,14 @@ QList FileBrowserTreeWidget::getContextActions(FileItem* file, bool so auto toInstrument = new QAction(instrumentAction + tr(" (%2Enter)").arg(shortcutMod), nullptr); connect(toInstrument, &QAction::triggered, - [=]{ openInNewInstrumentTrack(file, songEditor); }); + [=, this]{ openInNewInstrumentTrack(file, songEditor); }); result.append(toInstrument); if (songEditor && fileIsSample) { auto toSampleTrack = new QAction(tr("Send to new sample track (Shift + Enter)"), nullptr); connect(toSampleTrack, &QAction::triggered, - [=]{ openInNewSampleTrack(file); }); + [=, this]{ openInNewSampleTrack(file); }); result.append(toSampleTrack); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index c45ea14aca1..48d2ddb3025 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -38,6 +38,7 @@ #include "AboutDialog.h" #include "AutomationEditor.h" #include "ControllerRackView.h" +#include "DeprecationHelper.h" #include "embed.h" #include "Engine.h" #include "ExportProjectDialog.h" @@ -293,11 +294,11 @@ void MainWindow::finalize() project_menu->addAction( embed::getIconPixmap( "project_save" ), tr( "Save &As..." ), this, SLOT(saveProjectAs()), - Qt::CTRL + Qt::SHIFT + Qt::Key_S ); + combine(Qt::CTRL, Qt::SHIFT, Qt::Key_S)); project_menu->addAction( embed::getIconPixmap( "project_save" ), tr( "Save as New &Version" ), this, SLOT(saveProjectAsNewVersion()), - Qt::CTRL + Qt::ALT + Qt::Key_S ); + combine(Qt::CTRL, Qt::ALT, Qt::Key_S)); project_menu->addAction( embed::getIconPixmap( "project_save" ), tr( "Save as default template" ), @@ -312,23 +313,23 @@ void MainWindow::finalize() tr( "E&xport..." ), this, SLOT(onExportProject()), - Qt::CTRL + Qt::Key_E ); + combine(Qt::CTRL, Qt::Key_E)); project_menu->addAction( embed::getIconPixmap( "project_export" ), tr( "E&xport Tracks..." ), this, SLOT(onExportProjectTracks()), - Qt::CTRL + Qt::SHIFT + Qt::Key_E ); + combine(Qt::CTRL, Qt::SHIFT, Qt::Key_E)); project_menu->addAction( embed::getIconPixmap( "midi_file" ), tr( "Export &MIDI..." ), this, SLOT(onExportProjectMidi()), - Qt::CTRL + Qt::Key_M ); + combine(Qt::CTRL, Qt::Key_M)); project_menu->addSeparator(); project_menu->addAction( embed::getIconPixmap( "exit" ), tr( "&Quit" ), qApp, SLOT(closeAllWindows()), - Qt::CTRL + Qt::Key_Q ); + combine(Qt::CTRL, Qt::Key_Q)); auto edit_menu = new QMenu(this); menuBar()->addMenu( edit_menu )->setText( tr( "&Edit" ) ); @@ -341,13 +342,13 @@ void MainWindow::finalize() this, SLOT(redo()), QKeySequence::Redo ); // Ensure that both (Ctrl+Y) and (Ctrl+Shift+Z) activate redo shortcut regardless of OS defaults - if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::Key_Y)) + if (QKeySequence(QKeySequence::Redo) != QKeySequence(combine(Qt::CTRL, Qt::Key_Y))) { - new QShortcut( QKeySequence( Qt::CTRL + Qt::Key_Y ), this, SLOT(redo())); + new QShortcut(QKeySequence(combine(Qt::CTRL, Qt::Key_Y)), this, SLOT(redo())); } - if (QKeySequence(QKeySequence::Redo) != QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Z )) + if (QKeySequence(QKeySequence::Redo) != QKeySequence(combine(Qt::CTRL, Qt::SHIFT, Qt::Key_Z))) { - new QShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_Z ), this, SLOT(redo())); + new QShortcut(QKeySequence(combine(Qt::CTRL, Qt::SHIFT, Qt::Key_Z)), this, SLOT(redo())); } edit_menu->addSeparator(); @@ -446,31 +447,31 @@ void MainWindow::finalize() // window-toolbar auto song_editor_window = new ToolButton(embed::getIconPixmap("songeditor"), tr("Song Editor") + " (Ctrl+1)", this, SLOT(toggleSongEditorWin()), m_toolBar); - song_editor_window->setShortcut( Qt::CTRL + Qt::Key_1 ); + song_editor_window->setShortcut(combine(Qt::CTRL, Qt::Key_1)); auto pattern_editor_window = new ToolButton(embed::getIconPixmap("pattern_track_btn"), tr("Pattern Editor") + " (Ctrl+2)", this, SLOT(togglePatternEditorWin()), m_toolBar); - pattern_editor_window->setShortcut(Qt::CTRL + Qt::Key_2); + pattern_editor_window->setShortcut(combine(Qt::CTRL, Qt::Key_2)); auto piano_roll_window = new ToolButton( embed::getIconPixmap("piano"), tr("Piano Roll") + " (Ctrl+3)", this, SLOT(togglePianoRollWin()), m_toolBar); - piano_roll_window->setShortcut( Qt::CTRL + Qt::Key_3 ); + piano_roll_window->setShortcut(combine(Qt::CTRL, Qt::Key_3)); auto automation_editor_window = new ToolButton(embed::getIconPixmap("automation"), tr("Automation Editor") + " (Ctrl+4)", this, SLOT(toggleAutomationEditorWin()), m_toolBar); - automation_editor_window->setShortcut( Qt::CTRL + Qt::Key_4 ); + automation_editor_window->setShortcut(combine(Qt::CTRL, Qt::Key_4)); auto mixer_window = new ToolButton( embed::getIconPixmap("mixer"), tr("Mixer") + " (Ctrl+5)", this, SLOT(toggleMixerWin()), m_toolBar); - mixer_window->setShortcut( Qt::CTRL + Qt::Key_5 ); + mixer_window->setShortcut(combine(Qt::CTRL, Qt::Key_5)); auto controllers_window = new ToolButton(embed::getIconPixmap("controller"), tr("Show/hide controller rack") + " (Ctrl+6)", this, SLOT(toggleControllerRack()), m_toolBar); - controllers_window->setShortcut( Qt::CTRL + Qt::Key_6 ); + controllers_window->setShortcut(combine(Qt::CTRL, Qt::Key_6)); auto project_notes_window = new ToolButton(embed::getIconPixmap("project_notes"), tr("Show/hide project notes") + " (Ctrl+7)", this, SLOT(toggleProjectNotesWin()), m_toolBar); - project_notes_window->setShortcut( Qt::CTRL + Qt::Key_7 ); + project_notes_window->setShortcut(combine(Qt::CTRL, Qt::Key_7)); m_toolBarLayout->addWidget( song_editor_window, 1, 1 ); m_toolBarLayout->addWidget( pattern_editor_window, 1, 2 ); diff --git a/src/gui/MicrotunerConfig.cpp b/src/gui/MicrotunerConfig.cpp index 20660df4110..3b952ba0a7f 100644 --- a/src/gui/MicrotunerConfig.cpp +++ b/src/gui/MicrotunerConfig.cpp @@ -94,7 +94,7 @@ MicrotunerConfig::MicrotunerConfig() : auto scaleCombo = new ComboBox(); scaleCombo->setModel(&m_scaleComboModel); microtunerLayout->addWidget(scaleCombo, 1, 0, 1, 2); - connect(&m_scaleComboModel, &ComboBoxModel::dataChanged, [=] {updateScaleForm();}); + connect(&m_scaleComboModel, &ComboBoxModel::dataChanged, this, &MicrotunerConfig::updateScaleForm); m_scaleNameEdit = new QLineEdit("12-TET"); m_scaleNameEdit->setToolTip(tr("Scale description. Cannot start with \"!\" and cannot contain a newline character.")); @@ -106,8 +106,8 @@ MicrotunerConfig::MicrotunerConfig() : saveScaleButton->setToolTip(tr("Save scale definition to a file.")); microtunerLayout->addWidget(loadScaleButton, 3, 0, 1, 1); microtunerLayout->addWidget(saveScaleButton, 3, 1, 1, 1); - connect(loadScaleButton, &QPushButton::clicked, [=] {loadScaleFromFile();}); - connect(saveScaleButton, &QPushButton::clicked, [=] {saveScaleToFile();}); + connect(loadScaleButton, &QPushButton::clicked, this, &MicrotunerConfig::loadScaleFromFile); + connect(saveScaleButton, &QPushButton::clicked, this, &MicrotunerConfig::saveScaleToFile); m_scaleTextEdit = new QPlainTextEdit(); m_scaleTextEdit->setPlainText("100.0\n200.0\n300.0\n400.0\n500.0\n600.0\n700.0\n800.0\n900.0\n1000.0\n1100.0\n1200.0"); @@ -117,7 +117,7 @@ MicrotunerConfig::MicrotunerConfig() : auto applyScaleButton = new QPushButton(tr("Apply scale changes")); applyScaleButton->setToolTip(tr("Verify and apply changes made to the selected scale. To use the scale, select it in the settings of a supported instrument.")); microtunerLayout->addWidget(applyScaleButton, 6, 0, 1, 2); - connect(applyScaleButton, &QPushButton::clicked, [=] {applyScale();}); + connect(applyScaleButton, &QPushButton::clicked, this, &MicrotunerConfig::applyScale); // ---------------------------------- // Mapping sub-column @@ -132,7 +132,7 @@ MicrotunerConfig::MicrotunerConfig() : auto keymapCombo = new ComboBox(); keymapCombo->setModel(&m_keymapComboModel); microtunerLayout->addWidget(keymapCombo, 1, 2, 1, 2); - connect(&m_keymapComboModel, &ComboBoxModel::dataChanged, [=] {updateKeymapForm();}); + connect(&m_keymapComboModel, &ComboBoxModel::dataChanged, this, &MicrotunerConfig::updateKeymapForm); m_keymapNameEdit = new QLineEdit("default"); m_keymapNameEdit->setToolTip(tr("Keymap description. Cannot start with \"!\" and cannot contain a newline character.")); @@ -144,8 +144,8 @@ MicrotunerConfig::MicrotunerConfig() : saveKeymapButton->setToolTip(tr("Save key mapping definition to a file.")); microtunerLayout->addWidget(loadKeymapButton, 3, 2, 1, 1); microtunerLayout->addWidget(saveKeymapButton, 3, 3, 1, 1); - connect(loadKeymapButton, &QPushButton::clicked, [=] {loadKeymapFromFile();}); - connect(saveKeymapButton, &QPushButton::clicked, [=] {saveKeymapToFile();}); + connect(loadKeymapButton, &QPushButton::clicked, this, &MicrotunerConfig::loadKeymapFromFile); + connect(saveKeymapButton, &QPushButton::clicked, this, &MicrotunerConfig::saveKeymapToFile); m_keymapTextEdit = new QPlainTextEdit(); m_keymapTextEdit->setPlainText("0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11"); @@ -189,7 +189,7 @@ MicrotunerConfig::MicrotunerConfig() : auto applyKeymapButton = new QPushButton(tr("Apply keymap changes")); applyKeymapButton->setToolTip(tr("Verify and apply changes made to the selected key mapping. To use the mapping, select it in the settings of a supported instrument.")); microtunerLayout->addWidget(applyKeymapButton, 6, 2, 1, 2); - connect(applyKeymapButton, &QPushButton::clicked, [=] {applyKeymap();}); + connect(applyKeymapButton, &QPushButton::clicked, this, &MicrotunerConfig::applyKeymap); updateScaleForm(); updateKeymapForm(); @@ -325,7 +325,7 @@ void MicrotunerConfig::updateKeymapForm() */ bool MicrotunerConfig::validateScaleForm() { - auto fail = [=](QString message) {QMessageBox::critical(this, tr("Scale parsing error"), message);}; + auto fail = [this](const QString& message){ QMessageBox::critical(this, tr("Scale parsing error"), message); }; // check name QString name = m_scaleNameEdit->text(); @@ -373,7 +373,7 @@ bool MicrotunerConfig::validateScaleForm() */ bool MicrotunerConfig::validateKeymapForm() { - auto fail = [=](QString message) {QMessageBox::critical(this, tr("Keymap parsing error"), message);}; + auto fail = [this](const QString& message){ QMessageBox::critical(this, tr("Keymap parsing error"), message); }; // check name QString name = m_keymapNameEdit->text(); diff --git a/src/gui/PluginBrowser.cpp b/src/gui/PluginBrowser.cpp index 2594bdab374..4bf62d4ea11 100644 --- a/src/gui/PluginBrowser.cpp +++ b/src/gui/PluginBrowser.cpp @@ -297,7 +297,7 @@ void PluginDescWidget::contextMenuEvent(QContextMenuEvent* e) QMenu contextMenu(this); contextMenu.addAction( tr("Send to new instrument track"), - [=]{ openInNewInstrumentTrack(m_pluginKey.desc->name); } + [=, this]{ openInNewInstrumentTrack(m_pluginKey.desc->name); } ); contextMenu.exec(e->globalPos()); } diff --git a/src/gui/SideBarWidget.cpp b/src/gui/SideBarWidget.cpp index 5a73cb47166..5439b2791a4 100644 --- a/src/gui/SideBarWidget.cpp +++ b/src/gui/SideBarWidget.cpp @@ -50,7 +50,7 @@ SideBarWidget::SideBarWidget( const QString & _title, const QPixmap & _icon, m_closeBtn->resize(m_buttonSize); m_closeBtn->setToolTip(tr("Close")); connect(m_closeBtn, &QPushButton::clicked, - [=]() { this->closeButtonClicked(); }); + [this]() { this->closeButtonClicked(); }); } diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 3dc0285d282..0e56b934ef8 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -2037,17 +2037,17 @@ AutomationEditorWindow::AutomationEditorWindow() : auto editModeGroup = new ActionGroup(this); m_drawAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw"), tr("Draw mode (Shift+D)")); - m_drawAction->setShortcut(Qt::SHIFT | Qt::Key_D); + m_drawAction->setShortcut(combine(Qt::SHIFT, Qt::Key_D)); m_drawAction->setChecked(true); m_eraseAction = editModeGroup->addAction(embed::getIconPixmap("edit_erase"), tr("Erase mode (Shift+E)")); - m_eraseAction->setShortcut(Qt::SHIFT | Qt::Key_E); + m_eraseAction->setShortcut(combine(Qt::SHIFT, Qt::Key_E)); m_drawOutAction = editModeGroup->addAction(embed::getIconPixmap("edit_draw_outvalue"), tr("Draw outValues mode (Shift+C)")); - m_drawOutAction->setShortcut(Qt::SHIFT | Qt::Key_C); + m_drawOutAction->setShortcut(combine(Qt::SHIFT, Qt::Key_C)); m_editTanAction = editModeGroup->addAction(embed::getIconPixmap("edit_tangent"), tr("Edit tangents mode (Shift+T)")); - m_editTanAction->setShortcut(Qt::SHIFT | Qt::Key_T); + m_editTanAction->setShortcut(combine(Qt::SHIFT, Qt::Key_T)); m_editTanAction->setEnabled(false); m_flipYAction = new QAction(embed::getIconPixmap("flip_y"), tr("Flip vertically"), this); diff --git a/src/gui/editors/Editor.cpp b/src/gui/editors/Editor.cpp index ab12e3fb90b..c32fb5437c6 100644 --- a/src/gui/editors/Editor.cpp +++ b/src/gui/editors/Editor.cpp @@ -24,6 +24,7 @@ #include "Editor.h" +#include "DeprecationHelper.h" #include "GuiApplication.h" #include "MainWindow.h" #include "Song.h" @@ -118,8 +119,8 @@ Editor::Editor(bool record, bool stepRecord) : connect(m_toggleStepRecordingAction, SIGNAL(triggered()), this, SLOT(toggleStepRecording())); connect(m_stopAction, SIGNAL(triggered()), this, SLOT(stop())); new QShortcut(Qt::Key_Space, this, SLOT(togglePlayStop())); - new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Space), this, SLOT(togglePause())); - new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F11), this, SLOT(toggleMaximize())); + new QShortcut(QKeySequence(combine(Qt::SHIFT, Qt::Key_Space)), this, SLOT(togglePause())); + new QShortcut(QKeySequence(combine(Qt::SHIFT, Qt::Key_F11)), this, SLOT(toggleMaximize())); // Add actions to toolbar addButton(m_playAction, "playButton"); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 2193456e459..a2d7c832aaa 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -3098,7 +3098,7 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) // allow quantization grid up to 1/32 for normal notes else if (q < 6) { q = 6; } } - auto xCoordOfTick = [=](int tick) { + auto xCoordOfTick = [this](int tick) { return m_whiteKeyWidth + ( (tick - m_currentPosition) * m_ppb / TimePos::ticksPerBar() ); @@ -4764,10 +4764,10 @@ PianoRollWindow::PianoRollWindow() : drawAction->setChecked( true ); - drawAction->setShortcut( Qt::SHIFT | Qt::Key_D ); - eraseAction->setShortcut( Qt::SHIFT | Qt::Key_E ); - selectAction->setShortcut( Qt::SHIFT | Qt::Key_S ); - pitchBendAction->setShortcut( Qt::SHIFT | Qt::Key_T ); + drawAction->setShortcut(combine(Qt::SHIFT, Qt::Key_D)); + eraseAction->setShortcut(combine(Qt::SHIFT, Qt::Key_E)); + selectAction->setShortcut(combine(Qt::SHIFT, Qt::Key_S)); + pitchBendAction->setShortcut(combine(Qt::SHIFT, Qt::Key_T)); connect( editModeGroup, SIGNAL(triggered(int)), m_editor, SLOT(setEditMode(int))); @@ -4826,9 +4826,9 @@ PianoRollWindow::PianoRollWindow() : auto pasteAction = new QAction(embed::getIconPixmap("edit_paste"), tr("Paste (%1+V)").arg(UI_CTRL_KEY), this); - cutAction->setShortcut( Qt::CTRL | Qt::Key_X ); - copyAction->setShortcut( Qt::CTRL | Qt::Key_C ); - pasteAction->setShortcut( Qt::CTRL | Qt::Key_V ); + cutAction->setShortcut(combine(Qt::CTRL, Qt::Key_X)); + copyAction->setShortcut(combine(Qt::CTRL, Qt::Key_C)); + pasteAction->setShortcut(combine(Qt::CTRL, Qt::Key_V)); connect( cutAction, SIGNAL(triggered()), m_editor, SLOT(cutSelectedNotes())); connect( copyAction, SIGNAL(triggered()), m_editor, SLOT(copySelectedNotes())); @@ -4849,19 +4849,19 @@ PianoRollWindow::PianoRollWindow() : auto glueAction = new QAction(embed::getIconPixmap("glue"), tr("Glue"), noteToolsButton); connect(glueAction, SIGNAL(triggered()), m_editor, SLOT(glueNotes())); - glueAction->setShortcut( Qt::SHIFT | Qt::Key_G ); + glueAction->setShortcut(combine(Qt::SHIFT, Qt::Key_G)); auto knifeAction = new QAction(embed::getIconPixmap("edit_knife"), tr("Knife"), noteToolsButton); connect(knifeAction, &QAction::triggered, m_editor, &PianoRoll::setKnifeAction); - knifeAction->setShortcut( Qt::SHIFT | Qt::Key_K ); + knifeAction->setShortcut(combine(Qt::SHIFT, Qt::Key_K)); auto fillAction = new QAction(embed::getIconPixmap("fill"), tr("Fill"), noteToolsButton); connect(fillAction, &QAction::triggered, [this](){ m_editor->fitNoteLengths(true); }); - fillAction->setShortcut(Qt::SHIFT | Qt::Key_F); + fillAction->setShortcut(combine(Qt::SHIFT, Qt::Key_F)); auto cutOverlapsAction = new QAction(embed::getIconPixmap("cut_overlaps"), tr("Cut overlaps"), noteToolsButton); connect(cutOverlapsAction, &QAction::triggered, [this](){ m_editor->fitNoteLengths(false); }); - cutOverlapsAction->setShortcut(Qt::SHIFT | Qt::Key_C); + cutOverlapsAction->setShortcut(combine(Qt::SHIFT, Qt::Key_C)); auto minLengthAction = new QAction(embed::getIconPixmap("min_length"), tr("Min length as last"), noteToolsButton); connect(minLengthAction, &QAction::triggered, [this](){ m_editor->constrainNoteLengths(false); }); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 625601a3ebb..7d7b499af56 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,5 +28,5 @@ foreach(LMMS_TEST_SRC IN LISTS LMMS_TESTS) ${QT_QTTEST_LIBRARY} ) - target_compile_features(${LMMS_TEST_NAME} PRIVATE cxx_std_17) + target_compile_features(${LMMS_TEST_NAME} PRIVATE cxx_std_20) endforeach()