Skip to content

Commit

Permalink
Merge branch 'feature/qt6'
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronwhite committed Oct 6, 2024
2 parents f29a526 + 0642f64 commit c50c194
Show file tree
Hide file tree
Showing 32 changed files with 233 additions and 280 deletions.
47 changes: 21 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install Apt Dependencies
run: sudo apt update && sudo apt install ninja-build qtbase5-dev qttools5-dev libboost-dev libboost-date-time-dev libboost-iostreams-dev nlohmann-json3-dev libasound2-dev librtmidi-dev libminizip-dev doctest-dev
- name: Install Other Dependencies
run: vcpkg install pugixml
run: sudo apt update && sudo apt install ninja-build qt6-base-dev libglx-dev libgl1-mesa-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libboost-dev libboost-date-time-dev libboost-iostreams-dev nlohmann-json3-dev libasound2-dev librtmidi-dev libpugixml-dev libminizip-dev doctest-dev
- name: Create Build Directory
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Generate Project
Expand All @@ -40,7 +38,7 @@ jobs:

- name: Version number
id: version
run: echo "::set-output name=VERSION_ID::$(git describe --tags --long --always)"
run: echo "VERSION_ID=$(git describe --tags --long --always)" >> $GITHUB_OUTPUT

- name: Install Dependencies
# Note: remove existing Github actions python to work around conflicts (https://github.com/actions/setup-python/issues/577)
Expand All @@ -49,9 +47,17 @@ jobs:
rm /usr/local/bin/idle3*
rm /usr/local/bin/pydoc3*
rm /usr/local/bin/python3*
brew install --overwrite boost cmake doctest minizip ninja nlohmann-json pugixml qt5 pugixml rtmidi
brew install --overwrite boost cmake doctest minizip ninja nlohmann-json pugixml pugixml rtmidi
# Note: we avoid using the homebrew Qt since it breaks macdeployqt (https://github.com/Homebrew/brew/issues/15354)
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
arch: clang_64
version: 6.7.2

- name: Generate Project
run: cmake -S ${GITHUB_WORKSPACE} -B ${{runner.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5/lib/cmake
run: cmake -S ${GITHUB_WORKSPACE} -B ${{runner.workspace}}/build -G Ninja -DCMAKE_BUILD_TYPE=Release
- name: Build
run: cmake --build ${{runner.workspace}}/build
- name: Test
Expand Down Expand Up @@ -83,37 +89,26 @@ jobs:

runs-on: windows-2022

# Run both 32-bit and 64-bit builds.
strategy:
matrix:
arch: [x64, x86]
include:
- arch: x64
cmake_arch: x64
qt_arch: win64_msvc2019_64
- arch: x86
cmake_arch: Win32
qt_arch: win32_msvc2019

steps:
- uses: actions/checkout@v4

- name: Version number
id: version
run: echo "::set-output name=VERSION_ID::$(git describe --tags --long --always)"
run: echo "VERSION_ID=$(git describe --tags --long --always)" >> $GITHUB_OUTPUT
shell: bash

- name: Install Dependencies
run: vcpkg install --triplet ${{ matrix.arch }}-windows boost-algorithm boost-date-time boost-endian boost-functional boost-iostreams boost-rational boost-signals2 boost-stacktrace doctest minizip nlohmann-json pugixml
run: vcpkg install --triplet x64-windows boost-algorithm boost-date-time boost-endian boost-functional boost-iostreams boost-rational boost-signals2 boost-stacktrace doctest minizip nlohmann-json pugixml

# Building Qt via vcpkg would take a while ...
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
arch: ${{ matrix.qt_arch }}
version: 5.15.2
arch: win64_msvc2019_64
version: 6.7.2

- name: Generate Project
run: cmake -A ${{ matrix.cmake_arch }} -B ./build -DPTE_ENABLE_PCH=1 -DCMAKE_TOOLCHAIN_FILE="${env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
run: cmake -A x64 -B ./build -DPTE_ENABLE_PCH=1 -DCMAKE_TOOLCHAIN_FILE="${env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
- name: Build
run: cmake --build ./build --config Release
- name: Test
Expand All @@ -123,11 +118,11 @@ jobs:
run: |
choco install innosetup -y -v
iscc installer/windows/installer.iss
mv installer/windows/powertabeditor.exe installer/windows/powertabeditor-windows-${{ matrix.arch }}-${{ steps.version.outputs.VERSION_ID }}.exe
mv installer/windows/powertabeditor.exe installer/windows/powertabeditor-windows-${{ steps.version.outputs.VERSION_ID }}.exe
- name: Upload Installer
uses: actions/upload-artifact@v4
with:
name: powertabeditor-windows-${{ matrix.arch }}-${{ steps.version.outputs.VERSION_ID }}.exe
path: installer/windows/powertabeditor-windows-${{ matrix.arch }}-${{ steps.version.outputs.VERSION_ID }}.exe
name: powertabeditor-windows-${{ steps.version.outputs.VERSION_ID }}.exe
path: installer/windows/powertabeditor-windows-${{ steps.version.outputs.VERSION_ID }}.exe
if-no-files-found: error
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ Thanks to the following contributors who worked on this release:

### Changed
- Chord diagrams now display the fret number of the top fret instead of the next fret after it (#408)
- Removed the 32-bit Windows installers
- Updated the minimum required version of `RtMidi` to 4.0
- Updated the minimum required version of `boost` to 1.74
- Updated the minimum required version of `Qt` to 6.2

### Fixed
- Fixed a bug that caused some preferences such as custom shortcuts to not persist on macOS. Note that all other preferences (such as MIDI settings) are reset by this fix and will need to be manually changed to the desired values (#447).
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Power Tab Editor 2.0 - A powerful cross platform guitar tablature viewer and edi
* rational
* signals2
* stacktrace
* [Qt](http://qt-project.org/) >= 5.10 version or greater
* [Qt](http://qt-project.org/) >= 6.2 version or greater
* [nlohmann-json](https://github.com/nlohmann/json) >= 3.7.3
* [RtMidi](https://www.music.mcgill.ca/~gary/rtmidi/) >= 4.0
* [pugixml](https://pugixml.org/)
Expand All @@ -90,7 +90,7 @@ Power Tab Editor 2.0 - A powerful cross platform guitar tablature viewer and edi
#### Windows:
* Install Git - see https://help.github.com/articles/set-up-git
* Install [vcpkg](https://github.com/microsoft/vcpkg) and run `vcpkg install --triplet x64-windows boost-algorithm boost-date-time boost-endian boost-functional boost-iostreams boost-rational boost-signals2 boost-stacktrace doctest minizip nlohmann-json pugixml` to install dependencies.
* Install Qt by running `vcpkg install --triplet x64-windows qt5-base qt5-tools` (this may take a while), or install a binary release from the Qt website or https://github.com/miurahr/aqtinstall.
* Install Qt by running `vcpkg install --triplet x64-windows qtbase qttools` (this may take a while), or install a binary release from the Qt website or https://github.com/miurahr/aqtinstall.
* Open the project folder in Visual Studio and build.
* If running CMake manually, set `CMAKE_TOOLCHAIN_FILE` to `[vcpkg root]\scripts\buildsystems\vcpkg.cmake`

Expand All @@ -109,8 +109,9 @@ You'll have to update the variables for your specific paths to `$vcpkg_exe_path`
* These instructions assume a recent Ubuntu/Debian-based system, but the package names should be similar for other package managers.
* Install dependencies:
* `sudo apt update`
* `sudo apt install cmake qtbase5-dev qttools5-dev libboost-dev libboost-date-time-dev libboost-iostreams-dev nlohmann-json3-dev libasound2-dev librtmidi-dev libpugixml-dev libminizip-dev doctest-dev`
* `sudo apt-get install timidity-daemon` - timidity is not required for building, but is a good sequencer for MIDI playback.
* `sudo apt install cmake qt6-base-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libboost-dev libboost-date-time-dev libboost-iostreams-dev nlohmann-json3-dev libasound2-dev librtmidi-dev libpugixml-dev libminizip-dev doctest-dev`
* You may also need to install `libglx-dev libgl1-mesa-dev` along with Qt6
* `sudo apt install timidity-daemon` - timidity is not required for building, but is a good sequencer for MIDI playback.
* Optionally, use [Ninja](http://martine.github.io/ninja/) instead of `make` (`sudo apt install ninja-build`)
* Build:
* `mkdir build && cd build`
Expand All @@ -129,10 +130,11 @@ You'll have to update the variables for your specific paths to `$vcpkg_exe_path`
#### OS X:
* Install Xcode along with its Command Line Tools.
* Install dependencies:
* `brew install boost cmake doctest minizip ninja nlohmann-json pugixml qt@5 pugixml rtmidi`
* `brew install boost cmake doctest minizip ninja nlohmann-json pugixml qt6 pugixml rtmidi`
* Note that the Qt package from homebrew [does not currently work for building the installer|https://github.com/Homebrew/brew/issues/15354]. Installing via https://github.com/miurahr/aqtinstall is an alternative.
* Build:
* `mkdir build && cd build`
* `cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5/lib/cmake ..`
* `cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/local/opt/qt6/lib/cmake ..`
* To generate an Xcode project, switch to `-G Xcode` and then open and build `build/powertabeditor.xcodeproj`
* `ninja`
* Run:
Expand Down
2 changes: 1 addition & 1 deletion cmake/PTE_Executable.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function( pte_executable )

set( generated_files )
if ( PTE_EXE_RESOURCES )
qt5_add_resources( generated_files ${PTE_EXE_RESOURCES} )
qt_add_resources( generated_files ${PTE_EXE_RESOURCES} )
endif ()

if ( PTE_EXE_CONSOLE )
Expand Down
4 changes: 2 additions & 2 deletions cmake/PTE_Library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ function( pte_library )
set( generated_headers )
set( moc_files )
if ( PTE_LIB_FORMS )
qt5_wrap_ui( generated_headers ${PTE_LIB_FORMS} )
qt_wrap_ui( generated_headers ${PTE_LIB_FORMS} )
endif ()
if ( PTE_LIB_MOC_HEADERS )
qt5_wrap_cpp( moc_files ${PTE_LIB_MOC_HEADERS} )
qt_wrap_cpp( moc_files ${PTE_LIB_MOC_HEADERS} )
endif ()

add_library( ${PTE_LIB_NAME} STATIC
Expand Down
20 changes: 11 additions & 9 deletions cmake/third_party/Qt.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
find_package( Qt5Widgets REQUIRED )
find_package( Qt5Network REQUIRED )
find_package( Qt5PrintSupport REQUIRED )
find_package( Qt5LinguistTools REQUIRED )
find_package( Qt6 REQUIRED COMPONENTS
Widgets
Network
PrintSupport
LinguistTools
)

set( QT5_PLUGINS )
set( QT_PLUGINS )
if ( PLATFORM_WIN )
set( QT5_PLUGINS
Qt5::QWindowsIntegrationPlugin
Qt5::QWindowsVistaStylePlugin
set( QT_PLUGINS
Qt6::QWindowsIntegrationPlugin
Qt6::QModernWindowsStylePlugin
)
endif ()

# Find some standard paths to the Qt installation.
get_target_property( _uic_path Qt5::uic IMPORTED_LOCATION )
get_target_property( _uic_path Qt::lconvert IMPORTED_LOCATION )
get_filename_component( PTE_QT_BIN_DIR ${_uic_path} DIRECTORY )
get_filename_component( PTE_QT_ROOT_DIR ${PTE_QT_BIN_DIR} DIRECTORY )

Expand Down
14 changes: 13 additions & 1 deletion installer/osx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endif()
# Run macdeployqt on the bundle at install time.
install( CODE
"execute_process(
COMMAND ${macdeployqt_path} \"\${CMAKE_INSTALL_PREFIX}/Power Tab Editor.app\"
COMMAND ${macdeployqt_path} \"\${CMAKE_INSTALL_PREFIX}/Power Tab Editor.app\" -verbose=2
RESULT_VARIABLE retval
)
if ( NOT retval EQUAL 0 )
Expand All @@ -34,6 +34,18 @@ install( CODE
"
)

# Fix up the executable's rpath, which macdeployqt6 doesn't seem to do anymore...
install( CODE
"execute_process(
COMMAND install_name_tool -add_rpath \"@executable_path/../Frameworks\" \"\${CMAKE_INSTALL_PREFIX}/Power Tab Editor.app/Contents/MacOS/Power Tab Editor\"
RESULT_VARIABLE retval
)
if ( NOT retval EQUAL 0 )
message( FATAL_ERROR \"Failed to run install_name_tool\" )
endif ()
"
)

# Install the Qt translations (macdeployqt doesn't handle this)
install( FILES ${PTE_QT_TRANSLATION_FILES}
DESTINATION "${CPACK_PACKAGE_NAME}.app/Contents/Resources/translations"
Expand Down
2 changes: 1 addition & 1 deletion source/actions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,5 @@ pte_library(
MOC_HEADERS ${moc_headers}
DEPENDS
ptescore
Qt5::Widgets
Qt::Widgets
)
4 changes: 2 additions & 2 deletions source/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ pte_library(
ptepainters
ptewidgets
pteutil
Qt5::Widgets
Qt5::PrintSupport
Qt::Widgets
Qt::PrintSupport
)
7 changes: 3 additions & 4 deletions source/app/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ path getConfigDir()
path getUserDataDir()
{
return fromQString(
QStandardPaths::writableLocation(QStandardPaths::DataLocation));
QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
}

std::vector<path> getDataDirs()
{
std::vector<path> paths;
for (const QString &p :
QStandardPaths::standardLocations(QStandardPaths::DataLocation))
QStandardPaths::standardLocations(QStandardPaths::AppDataLocation))
{
paths.push_back(fromQString(p));
}
Expand All @@ -67,8 +67,7 @@ getTranslationDirs()
p /= "translations";

// Also check in the Qt translations folder.
paths.push_back(
fromQString(QLibraryInfo::location(QLibraryInfo::TranslationsPath)));
paths.push_back(fromQString(QLibraryInfo::path(QLibraryInfo::TranslationsPath)));

return paths;
}
Expand Down
23 changes: 7 additions & 16 deletions source/app/powertabeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@

#include <formats/fileformatmanager.h>

#include <QActionGroup>
#include <QCoreApplication>
#include <QDebug>
#include <QDesktopServices>
Expand All @@ -138,6 +139,7 @@
#include <QPrinter>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QRegularExpression>
#include <QScrollArea>
#include <QTabBar>
#include <QUrl>
Expand Down Expand Up @@ -458,11 +460,12 @@ bool PowerTabEditor::saveFileAs(int doc_index)
if (info.suffix().isEmpty())
{
const QString file_filter = dialog.selectedNameFilter();
QRegExp regex("\\*.(\\w+)");
if (regex.indexIn(file_filter, 0) < 0)
QRegularExpression regex("\\*.(\\w+)");
QRegularExpressionMatch match = regex.match(file_filter);
if (!match.hasMatch())
return false;

const QString extension = regex.cap(1);
const QString extension = match.captured(1);
path += ".";
path += extension;
}
Expand Down Expand Up @@ -2208,14 +2211,6 @@ void PowerTabEditor::updateWindowTitle()
setWindowTitle(name);
}

/// C++20 deprecated bitwise operations between different enum types, which
/// QKeySequence relies on.
inline constexpr int
operator|(Qt::Modifier m, Qt::Key k)
{
return static_cast<int>(m) | static_cast<int>(k);
}

void PowerTabEditor::createCommands()
{
// File-related commands.
Expand Down Expand Up @@ -3597,7 +3592,7 @@ void PowerTabEditor::createTabArea()
QVBoxLayout *layout = new QVBoxLayout(myPlaybackArea);
layout->addWidget(myTabWidget);
layout->addWidget(myPlaybackWidget, 0, Qt::AlignHCenter);
layout->setMargin(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);

enableEditing(false);
Expand Down Expand Up @@ -3760,11 +3755,7 @@ void PowerTabEditor::setupNewTab()
// Each tab is 200px wide, so we want to shorten the name if it's wider
// than 140px.
bool chopped = false;
#if (QT_VERSION >= QT_VERSION_CHECK(5,11,0))
while (fm.horizontalAdvance(title) > 140)
#else
while (fm.width(title) > 140)
#endif
{
title.chop(1);
chopped = true;
Expand Down
2 changes: 1 addition & 1 deletion source/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pte_library(
DEPENDS
PUBLIC
ptescore
Qt5::Core
Qt::Core
PRIVATE
rtmidi::rtmidi
${platform_deps}
Expand Down
6 changes: 3 additions & 3 deletions source/build/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ pte_executable(
DEPENDS
pteapp
ptedialogs
Qt5::Network
Qt5::Widgets
Qt::Network
Qt::Widgets
${platform_deps}
PLUGINS
${QT5_PLUGINS}
${QT_PLUGINS}
)

if ( PLATFORM_OSX )
Expand Down
Loading

0 comments on commit c50c194

Please sign in to comment.