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) set(QT_VERSION 6.5.0)
# API that was deprecated before Qt 5.15 causes a compile error # API that was deprecated before Qt 5.15 causes a compile error
add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060400) add_compile_definitions(QT_DISABLE_DEPRECATED_BEFORE=0x060400)
set(BUILD_KF5Crash OFF) # TODO: Qt6
else() else()
message(STATUS "Building Calamares with Qt5") message(STATUS "Building Calamares with Qt5")
set(qtname "Qt5") set(qtname "Qt5")

View File

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

View File

@ -38,8 +38,11 @@ calamares_autorcc( calamares_bin )
target_link_libraries( target_link_libraries(
calamares_bin 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) if(BUILD_KF5Crash)
target_link_libraries(calamares_bin PRIVATE KF5::Crash) target_link_libraries(calamares_bin PRIVATE KF5::Crash)
target_compile_definitions(calamares_bin PRIVATE BUILD_KF5Crash) target_compile_definitions(calamares_bin PRIVATE BUILD_KF5Crash)
@ -59,8 +62,8 @@ install(
if(BUILD_TESTING) if(BUILD_TESTING)
# Don't install, these are just for enable_testing # Don't install, these are just for enable_testing
add_executable(loadmodule testmain.cpp) 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) 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() endif()

View File

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

View File

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