Skip to content

Commit

Permalink
Merge pull request #666 from jdpurcell/qt_6_5
Browse files Browse the repository at this point in the history
Update Qt to 6.5.3
  • Loading branch information
jurplel authored May 6, 2024
2 parents 2aff9b3 + 9a38b12 commit 018ef8a
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 26 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ jobs:
qtVersion: '5.15.2'
- runner: 'ubuntu-20.04'
qtVersion: '5.9'
osSuffix: '_qt5.9'
skipPlugins: 'true'
- runner: 'macos-latest'
qtVersion: '6.2.2'
- runner: 'macos-12'
qtVersion: '6.5.3'
qtModules: 'qtimageformats'
- runner: 'macos-latest'
- runner: 'macos-12'
qtVersion: '5.15.2'
osSuffix: '_legacy'
- runner: 'windows-2019'
qtVersion: '6.2.2'
qtVersion: '6.5.3'
qtArch: 'win64_msvc2019_64'
osSuffix: '_64'
qtModules: 'qtimageformats'
Expand All @@ -47,7 +48,7 @@ jobs:
echo "buildNumString=$buildNum" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install Qt
uses: jurplel/install-qt-action@v3
Expand Down Expand Up @@ -76,7 +77,7 @@ jobs:
}
- name: 'Upload Artifact'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: qView${{ env.nightlyString }}-${{ runner.os }}${{ matrix.osSuffix }}-${{ env.buildNumString }}
path: bin
3 changes: 2 additions & 1 deletion dist/scripts/download-plugins.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ if ($IsWindows) {
}

$binaryBaseUrl = "https://github.com/jurplel/kimageformats-binaries/releases/download/cont"
$pluginQtVersion = If ($qtVersion -like '6.*') { "6.4.3" } Else { $qtVersion }

if ($pluginNames.count -eq 0) {
Write-Host "the pluginNames array is empty."
}

foreach ($pluginName in $pluginNames) {
$arch = If (-not $env:arch -or $env:arch -eq '') { "" } Else { "-$env:arch" }
$artifactName = "$pluginName-$imageName-$qtVersion$arch.zip"
$artifactName = "$pluginName-$imageName-$pluginQtVersion$arch.zip"
$downloadUrl = "$binaryBaseUrl/$artifactName"

Write-Host "Downloading $downloadUrl"
Expand Down
7 changes: 4 additions & 3 deletions dist/scripts/macdeploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ fi
cd bin

macdeployqt qView.app
codesign --sign - --deep qView.app
if [ $1 != "" ]; then
mv qView.app qView-nightly-$1\.app
macdeployqt *.app -codesign=- -dmg
BUILD_NAME=qView-nightly-$1
mv qView.app "$BUILD_NAME.app"
hdiutil create -volname "$BUILD_NAME" -srcfolder "$BUILD_NAME.app" -fs HFS+ "$BUILD_NAME.dmg"
else
brew install create-dmg
codesign --sign - --deep qView.app
create-dmg --volname "qView $VERSION" --window-size 660 400 --icon-size 160 --icon "qView.app" 180 170 --hide-extension qView.app --app-drop-link 480 170 "qView-$VERSION.dmg" "qView.app"
fi

Expand Down
25 changes: 19 additions & 6 deletions dist/scripts/windeployqt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,32 @@ param
$NightlyVersion = ""
)

$qtVersion = ((qmake --version -split '\n')[1] -split ' ')[3]
Write-Host "Detected Qt Version $qtVersion"

# Download and extract openssl
if ($qtVersion -like '5.*') {
$openSslDownloadUrl = "https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-1.1.1w.zip"
$openSslFolderVersion = "1.1"
$openSslFilenameVersion = "1_1"
} else {
$openSslDownloadUrl = "https://download.firedaemon.com/FireDaemon-OpenSSL/openssl-3.2.1.zip"
$openSslFolderVersion = "3"
$openSslFilenameVersion = "3"
}
Write-Host "Downloading $openSslDownloadUrl"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest https://www.firedaemon.com/download-firedaemon-openssl-1-zip -O openssl.zip
Invoke-WebRequest -Uri $openSslDownloadUrl -OutFile openssl.zip
7z x -y .\openssl.zip

# Check if "arch" environment variable is win32
# If it is, install x86 binaries, otherwise x64 binaries
if ($env:arch.substring(3, 2) -eq '32') {
copy openssl-1.1\x86\bin\libssl-1_1.dll bin\
copy openssl-1.1\x86\bin\libcrypto-1_1.dll bin\
} Else {
copy openssl-1.1\x64\bin\libssl-1_1-x64.dll bin\
copy openssl-1.1\x64\bin\libcrypto-1_1-x64.dll bin\
copy openssl-$openSslFolderVersion\x86\bin\libssl-$openSslFilenameVersion.dll bin\
copy openssl-$openSslFolderVersion\x86\bin\libcrypto-$openSslFilenameVersion.dll bin\
} else {
copy openssl-$openSslFolderVersion\x64\bin\libssl-$openSslFilenameVersion-x64.dll bin\
copy openssl-$openSslFolderVersion\x64\bin\libcrypto-$openSslFilenameVersion-x64.dll bin\
}

# Run windeployqt which should be in path
Expand Down
20 changes: 16 additions & 4 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ MainWindow::MainWindow(QWidget *parent) :
populateOpenWithMenu(openWithFutureWatcher.result());
});

#ifdef COCOA_LOADED
QVCocoaFunctions::setFullSizeContentView(windowHandle());
#endif

// Load window geometry
QSettings settings;
restoreGeometry(settings.value("geometry").toByteArray());
Expand Down Expand Up @@ -189,6 +185,16 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)

void MainWindow::showEvent(QShowEvent *event)
{
#ifdef COCOA_LOADED
// Enable full size content view. With some Qt versions, this can break its restoreGeometry
// functionality even if we enable this after. Presumably restoreGeometry saves data for
// further processing after the window is shown, hence the timer here to queue this on the
// event loop and run after that processing happens.
QTimer::singleShot(0, this, [this]() {
QVCocoaFunctions::setFullSizeContentView(windowHandle(), true);
});
#endif

if (!menuBar()->sizeHint().isEmpty())
{
ui->fullscreenLabel->setMargin(0);
Expand All @@ -200,6 +206,12 @@ void MainWindow::showEvent(QShowEvent *event)

void MainWindow::closeEvent(QCloseEvent *event)
{
#ifdef COCOA_LOADED
// Full size content view can confuse saveGeometry, making it think the window is taller than
// it really is, so the restored window ends up taller. Turn it off before saving geometry.
QVCocoaFunctions::setFullSizeContentView(windowHandle(), false);
#endif

QSettings settings;
settings.setValue("geometry", saveGeometry());

Expand Down
2 changes: 1 addition & 1 deletion src/qvcocoafunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QVCocoaFunctions

static void setUserDefaults();

static void setFullSizeContentView(QWindow *window);
static void setFullSizeContentView(QWindow *window, const bool enable);

static void setVibrancy(bool alwaysDark, QWindow *window);

Expand Down
31 changes: 26 additions & 5 deletions src/qvcocoafunctions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,37 @@ static void fixNativeMenuEccentricities(QMenu *menu, NSMenu *nativeMenu)
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"];
}

// This function should only be called once because it sets observers
void QVCocoaFunctions::setFullSizeContentView(QWindow *window)
// This function should only be enabled once because it sets observers
void QVCocoaFunctions::setFullSizeContentView(QWindow *window, const bool enable)
{
auto *view = reinterpret_cast<NSView*>(window->winId());

// If this Qt and macOS version combination is already using layer-backed view, then enable full size content view
if (view.wantsLayer)
// Make sure the requested state isn't already in effect
if (enable == (view.window.styleMask & NSWindowStyleMaskFullSizeContentView))
return;

// Changing the style mask causes the window to resize, so snapshot the original size
NSRect originalFrame = view.window.frame;

if (enable)
{
// Proceed only if this Qt and macOS version combination is already using layer-backed view
if (!view.wantsLayer)
return;
view.window.styleMask |= NSWindowStyleMaskFullSizeContentView;
}
else
{
view.window.styleMask &= ~NSWindowStyleMaskFullSizeContentView;
}

// workaround for QTBUG-69975
// Restore original size after style mask change
[view.window setFrame:originalFrame display:YES];

#if QT_VERSION < QT_VERSION_CHECK(6, 2, 0)
// workaround for QTBUG-69975
if (enable)
{
[[NSNotificationCenter defaultCenter] addObserverForName:NSWindowDidExitFullScreenNotification object:view.window queue:nil usingBlock:^(NSNotification *notification){
auto *window = reinterpret_cast<NSWindow*>(notification.object);
window.styleMask |= NSWindowStyleMaskFullSizeContentView;
Expand All @@ -85,6 +105,7 @@ static void fixNativeMenuEccentricities(QMenu *menu, NSMenu *nativeMenu)
window.styleMask |= NSWindowStyleMaskFullSizeContentView;
}];
}
#endif
}

void QVCocoaFunctions::setVibrancy(bool alwaysDark, QWindow *window)
Expand Down

0 comments on commit 018ef8a

Please sign in to comment.