calamares: adapt UI-parts to Qt6

This commit is contained in:
Adriaan de Groot 2023-09-03 22:18:10 +02:00
parent e1b20fe0a9
commit 2ffcfb3ddd
5 changed files with 30 additions and 17 deletions

View File

@ -169,6 +169,8 @@ if(WITH_QT6)
set(QT_VERSION 6.5.0)
# API that was deprecated before Qt 5.15 causes a compile error
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060400)
set(BUILD_KF5Crash OFF) # TODO: Qt6
else()
message(STATUS "Building Calamares with Qt5")
set(qtname "Qt5")

View File

@ -14,13 +14,13 @@ include(CalamaresAddTranslations)
add_subdirectory(libcalamares)
add_subdirectory(libcalamaresui)
if(NOT WITH_QT6) # TODO: Qt6
# all things qml
add_subdirectory(qml/calamares)
# application
add_subdirectory(calamares)
if(NOT WITH_QT6) # TODO: Qt6
# plugins
add_subdirectory(modules)

View File

@ -38,8 +38,11 @@ calamares_autorcc( calamares_bin )
target_link_libraries(
calamares_bin
PRIVATE calamares calamaresui calamares-i18n kdsingleapplication Qt5::Core Qt5::Widgets KF5::CoreAddons
PRIVATE calamares calamaresui calamares-i18n kdsingleapplication ${qtname}::Core ${qtname}::Widgets
)
if(NOT WITH_QT6) # TODO: Qt6
target_link_libraries(calamares_bin PRIVATE KF5::CoreAddons)
endif()
if(BUILD_KF5Crash)
target_link_libraries(calamares_bin PRIVATE KF5::Crash)
target_compile_definitions(calamares_bin PRIVATE BUILD_KF5Crash)
@ -59,8 +62,8 @@ install(
if(BUILD_TESTING)
# Don't install, these are just for enable_testing
add_executable(loadmodule testmain.cpp)
target_link_libraries(loadmodule PRIVATE Qt5::Core Qt5::Widgets calamares calamaresui)
target_link_libraries(loadmodule PRIVATE ${qtname}::Core ${qtname}::Widgets calamares calamaresui)
add_executable(test_conf test_conf.cpp)
target_link_libraries(test_conf PUBLIC yamlcpp::yamlcpp Qt5::Core)
target_link_libraries(test_conf PUBLIC yamlcpp::yamlcpp ${qtname}::Core)
endif()

View File

@ -30,7 +30,6 @@
#include "utils/Retranslator.h"
#include "viewpages/ViewStep.h"
#include <QDesktopWidget>
#include <QDir>
#include <QFileInfo>
#include <QScreen>

View File

@ -27,7 +27,9 @@
#include <QApplication>
#include <QBoxLayout>
#include <QCloseEvent>
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <QDesktopWidget>
#endif
#include <QFile>
#include <QFileInfo>
#include <QLabel>
@ -39,6 +41,16 @@
#endif
#include <QTreeView>
static QSize
desktopSize( QWidget* w )
{
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
return qApp->desktop()->availableGeometry( w ).size();
#else
return w->screen()->availableGeometry().size();
#endif
}
static inline int
windowDimensionToPixels( const Calamares::Branding::WindowDimension& u )
{
@ -143,11 +155,9 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug,
CalamaresUtils::Original,
2 * QSize( defaultFontHeight, defaultFontHeight ) ) );
CALAMARES_RETRANSLATE_FOR(
aboutDialog,
aboutDialog->setText(
QCoreApplication::translate( "calamares-sidebar", "About" ) );
aboutDialog->setToolTip( QCoreApplication::translate( "calamares-sidebar",
"Show information about Calamares" ) ); );
aboutDialog, aboutDialog->setText( QCoreApplication::translate( "calamares-sidebar", "About" ) );
aboutDialog->setToolTip(
QCoreApplication::translate( "calamares-sidebar", "Show information about Calamares" ) ); );
extraButtons->addWidget( aboutDialog );
aboutDialog->setFlat( true );
aboutDialog->setCheckable( true );
@ -159,11 +169,10 @@ getWidgetSidebar( Calamares::DebugWindowManager* debug,
debugWindowBtn->setObjectName( "debugButton" );
debugWindowBtn->setIcon( CalamaresUtils::defaultPixmap(
CalamaresUtils::Bugs, CalamaresUtils::Original, 2 * QSize( defaultFontHeight, defaultFontHeight ) ) );
CALAMARES_RETRANSLATE_FOR( debugWindowBtn,
debugWindowBtn->setText( QCoreApplication::translate(
"calamares-sidebar", "Debug" ) );
debugWindowBtn->setToolTip( QCoreApplication::translate(
"calamares-sidebar", "Show debug information" ) ); );
CALAMARES_RETRANSLATE_FOR(
debugWindowBtn, debugWindowBtn->setText( QCoreApplication::translate( "calamares-sidebar", "Debug" ) );
debugWindowBtn->setToolTip(
QCoreApplication::translate( "calamares-sidebar", "Show debug information" ) ); );
extraButtons->addWidget( debugWindowBtn );
debugWindowBtn->setFlat( true );
debugWindowBtn->setCheckable( true );
@ -409,7 +418,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
// Needs to match what's checked in DebugWindow
this->setObjectName( "mainApp" );
QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
QSize availableSize = desktopSize( this );
QSize minimumSize( qBound( windowMinimumWidth, availableSize.width(), windowPreferredWidth ),
qBound( windowMinimumHeight, availableSize.height(), windowPreferredHeight ) );
setMinimumSize( minimumSize );
@ -507,7 +516,7 @@ void
CalamaresWindow::ensureSize( QSize size )
{
auto mainGeometry = this->geometry();
QSize availableSize = qApp->desktop()->availableGeometry( this ).size();
QSize availableSize = desktopSize( this );
// We only care about vertical sizes that are big enough
int embiggenment = qMax( 0, size.height() - m_viewManager->centralWidget()->size().height() );