Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code: Add Qt6 compatibility #2299

Merged
merged 13 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/autobuild/ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -eu

QT_DIR=/usr/local/opt/qt
AQTINSTALL_VERSION=2.0.6
AQTINSTALL_VERSION=2.1.0

if [[ ! ${QT_VERSION:-} =~ [0-9]+\.[0-9]+\..* ]]; then
echo "Environment variable QT_VERSION must be set to a valid Qt version"
Expand All @@ -19,7 +19,14 @@ setup() {
else
echo "Installing Qt"
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}"
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac ios "${QT_VERSION}" --archives qtbase qttools qttranslations qtmacextras
# Install actual ios Qt:
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac ios "${QT_VERSION}" --archives qtbase qttools qttranslations
if [[ ! "${QT_VERSION}" =~ 5\..* ]]; then
Copy link
Collaborator

@pljones pljones Mar 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using the QT version to check the target platform? That doesn't seem right. Why not have parameter or separate variable? (i.e. pass in ios or desktop, or default to ios and override when wanted.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, it's quite something else: This is all about the ios target platform.
The issue is that Qt5 ships qmake as part of the aqt installation, while Qt6 only ships a shim which redirects to the mac/desktop qmake. Therefore, this is needed additionally for Qt6.

Maybe the comment should be improved?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

# Starting with Qt6, ios' qtbase install does no longer include a real qmake binary.
# Instead, it is a script which invokes the mac desktop qmake.
# As of aqtinstall 2.1.0 / 04/2022, desktop qtbase has to be installed manually:
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop "${QT_VERSION}" --archives qtbase
fi
fi
}

Expand Down
2 changes: 1 addition & 1 deletion .github/autobuild/mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ setup() {
else
echo "Installing Qt..."
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}"
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop "${QT_VERSION}" --archives qtbase qttools qttranslations qtmacextras
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop "${QT_VERSION}" --archives qtbase qttools qttranslations
fi
}

Expand Down
2 changes: 1 addition & 1 deletion .github/autobuild/windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Function Install-Qt
"desktop",
"$QtVersion",
"$QtArch",
"--archives", "qtbase", "qttools", "qttranslations", "qtwinextras"
"--archives", "qtbase", "qttools", "qttranslations"
)
aqt install-qt @Args
if ( !$? )
Expand Down
17 changes: 12 additions & 5 deletions Jamulus.pro
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ win32 {
advapi32.lib \
winmm.lib \
ws2_32.lib
greaterThan(QT_MAJOR_VERSION, 5) {
# Qt5 had a special qtmain library which took care of forwarding the MSVC default WinMain() entrypoint to
# the platform-agnostic main().
# Qt6 is still supposed to have that lib under the new name QtEntryPoint. As it does not seem
# to be effective when building with qmake, we are rather instructing MSVC to use the platform-agnostic
# main() entrypoint directly:
QMAKE_LFLAGS += /subsystem:windows /ENTRY:mainCRTStartup
}
ann0see marked this conversation as resolved.
Show resolved Hide resolved
}

contains(CONFIG, "serveronly") {
Expand Down Expand Up @@ -154,9 +162,8 @@ win32 {
RC_FILE = mac/mainicon.icns
}

QT += macextras
HEADERS += mac/activity.h
OBJECTIVE_SOURCES += mac/activity.mm
HEADERS += mac/activity.h mac/badgelabel.h
OBJECTIVE_SOURCES += mac/activity.mm mac/badgelabel.mm
CONFIG += x86
QMAKE_TARGET_BUNDLE_PREFIX = io.jamulus

Expand Down Expand Up @@ -185,7 +192,8 @@ win32 {
-framework CoreMIDI \
-framework AudioToolbox \
-framework AudioUnit \
-framework Foundation
-framework Foundation \
-framework AppKit

contains(CONFIG, "jackonmac") {
message(Using JACK.)
Expand All @@ -208,7 +216,6 @@ win32 {

} else:ios {
QMAKE_INFO_PLIST = ios/Info.plist
QT += macextras
OBJECTIVE_SOURCES += ios/ios_app_delegate.mm
HEADERS += ios/ios_app_delegate.h
HEADERS += ios/sound.h
Expand Down
2 changes: 1 addition & 1 deletion ios/deploy_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -eu

# Create Xcode file and build
qmake -spec macx-xcode Jamulus.pro
/usr/bin/xcodebuild -project Jamulus.xcodeproj -scheme Jamulus -configuration Release clean archive -archivePath "build/Jamulus.xcarchive" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
/usr/bin/xcodebuild -project Jamulus.xcodeproj -scheme Jamulus -configuration Release clean archive -archivePath "build/Jamulus.xcarchive" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO CODE_SIGN_ENTITLEMENTS=""

# Generate ipa by copying the .app file from the xcarchive directory
mkdir build/Payload
Expand Down
27 changes: 27 additions & 0 deletions mac/badgelabel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/******************************************************************************\
* Copyright (c) 2022
*
* Author(s):
* The Jamulus Development Team
*
******************************************************************************
*
* This program 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 2 of the License, or (at your option) any later
* version.
*
* This program 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
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
\******************************************************************************/

#include <QString>

void SetMacBadgeLabelText ( const QString& text );
29 changes: 29 additions & 0 deletions mac/badgelabel.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/******************************************************************************\
* Copyright (c) 2022
*
* Author(s):
* The Jamulus Development Team
*
******************************************************************************
*
* This program 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 2 of the License, or (at your option) any later
* version.
*
* This program 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
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*
\******************************************************************************/

#include "badgelabel.h"
#import <AppKit/NSApplication.h>
#import <AppKit/NSDockTile.h>

void SetMacBadgeLabelText ( const QString& text ) { [[[NSApplication sharedApplication] dockTile] setBadgeLabel:text.toNSString()]; }
7 changes: 2 additions & 5 deletions src/clientdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,19 +938,16 @@ void CClientDlg::SetMyWindowTitle ( const int iNumClients )
#if defined( Q_OS_MACX )
// for MacOS only we show the number of connected clients as a
// badge label text if more than one user is connected
// (only available in Qt5.2)
# if QT_VERSION >= QT_VERSION_CHECK( 5, 2, 0 )
if ( iNumClients > 1 )
{
// show the number of connected clients
QtMac::setBadgeLabelText ( QString ( "%1" ).arg ( iNumClients ) );
SetMacBadgeLabelText ( QString ( "%1" ).arg ( iNumClients ) );
}
else
{
// clear the text (apply an empty string)
QtMac::setBadgeLabelText ( "" );
SetMacBadgeLabelText ( "" );
}
# endif
#endif
}

Expand Down
7 changes: 3 additions & 4 deletions src/clientdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <QLayout>
#include <QMessageBox>
#include <QFileDialog>
#include <QActionGroup>
#if QT_VERSION >= QT_VERSION_CHECK( 5, 6, 0 )
# include <QVersionNumber>
#endif
Expand All @@ -51,10 +52,8 @@
#include "connectdlg.h"
#include "analyzerconsole.h"
#include "ui_clientdlgbase.h"
#if defined( __APPLE__ ) || defined( __MACOSX )
# if QT_VERSION >= QT_VERSION_CHECK( 5, 2, 0 )
# include <QtMac>
# endif
#if defined( Q_OS_MACX )
# include "mac/badgelabel.h"
#endif

/* Definitions ****************************************************************/
Expand Down
38 changes: 24 additions & 14 deletions src/clientsettingsdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,21 +561,31 @@ CClientSettingsDlg::CClientSettingsDlg ( CClient* pNCliP, CClientSettings* pNSet
for ( int iCurCntry = static_cast<int> ( QLocale::AnyCountry ); iCurCntry < static_cast<int> ( QLocale::LastCountry ); iCurCntry++ )
{
// exclude the "None" entry since it is added after the sorting
if ( static_cast<QLocale::Country> ( iCurCntry ) != QLocale::AnyCountry )
if ( static_cast<QLocale::Country> ( iCurCntry ) == QLocale::AnyCountry )
ann0see marked this conversation as resolved.
Show resolved Hide resolved
{
// get current country enum
QLocale::Country eCountry = static_cast<QLocale::Country> ( iCurCntry );

// try to load icon from resource file name
QIcon CurFlagIcon;
CurFlagIcon.addFile ( CLocale::GetCountryFlagIconsResourceReference ( eCountry ) );

// only add the entry if a flag is available
if ( !CurFlagIcon.isNull() )
{
// create a combo box item with text and image
pcbxCountry->addItem ( QIcon ( CurFlagIcon ), QLocale::countryToString ( eCountry ), iCurCntry );
}
continue;
}

if ( !CLocale::IsCountryCodeSupported ( iCurCntry ) )
{
// The current Qt version which is the base for the loop may support
// more country codes than our protocol does. Therefore, skip
// the unsupported options to avoid surprises.
continue;
}

// get current country enum
QLocale::Country eCountry = static_cast<QLocale::Country> ( iCurCntry );

// try to load icon from resource file name
QIcon CurFlagIcon;
CurFlagIcon.addFile ( CLocale::GetCountryFlagIconsResourceReference ( eCountry ) );

// only add the entry if a flag is available
if ( !CurFlagIcon.isNull() )
{
// create a combo box item with text and image
pcbxCountry->addItem ( QIcon ( CurFlagIcon ), QLocale::countryToString ( eCountry ), iCurCntry );
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/connectdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,12 @@ void CConnectDlg::OnTimerPing()
bEnableIPv6 ) )
{
// if address is valid, send ping message using a new thread
#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
QFuture<void> f = QtConcurrent::run ( &CConnectDlg::EmitCLServerListPingMes, this, haServerAddress );
Q_UNUSED ( f );
#else
QtConcurrent::run ( this, &CConnectDlg::EmitCLServerListPingMes, haServerAddress );
#endif
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/levelmeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CLevelMeter::CLevelMeter ( QWidget* parent ) : QWidget ( parent ), eLevelMeterTy
QWidget* pLEDMeter = new QWidget();
QVBoxLayout* pLEDLayout = new QVBoxLayout ( pLEDMeter );
pLEDLayout->setAlignment ( Qt::AlignHCenter );
pLEDLayout->setMargin ( 0 );
pLEDLayout->setContentsMargins ( 0, 0, 0, 0 );
pLEDLayout->setSpacing ( 0 );

// create LEDs plus the clip LED
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,7 @@ QString UsageArguments ( char** argv )
" -L, --licence show an agreement window before users can connect\n"
" -m, --htmlstatus enable HTML status file, set file name\n"
" -o, --serverinfo registration info for this Server. Format:\n"
" [name];[city];[country as QLocale ID]\n"
" [name];[city];[country as Qt5 QLocale ID]\n"
pljones marked this conversation as resolved.
Show resolved Hide resolved
" --serverpublicip public IP address for this Server. Needed when\n"
" registering with a server list hosted\n"
" behind the same NAT\n"
Expand Down
Loading