interactiveterminal: prepare for Qt6

- Try to build with KF6
- Bodge out the actual loading-of-konsole-part
This commit is contained in:
Adriaan de Groot 2023-09-10 21:44:47 +02:00
parent f4a80c1a01
commit 766c28ca82
3 changed files with 20 additions and 31 deletions

View File

@ -3,19 +3,12 @@
# SPDX-FileCopyrightText: 2020 Adriaan de Groot <groot@kde.org>
# SPDX-License-Identifier: BSD-2-Clause
#
if(WITH_QT6)
calamares_skip_module( "interactiveterminal (KDE Frameworks 5 only)" )
return()
endif()
find_package(${kfname}Service ${KF_VERSION})
find_package(${kfname}Parts ${KF_VERSION})
set_package_properties(${kfname}Service PROPERTIES PURPOSE "For finding KDE services at runtime")
set_package_properties(${kfname}Parts PROPERTIES PURPOSE "For finding KDE parts at runtime")
set(kf5_ver 5.41)
find_package(KF5Service ${kf5_ver})
find_package(KF5Parts ${kf5_ver})
set_package_properties(KF5Service PROPERTIES PURPOSE "For finding KDE services at runtime")
set_package_properties(KF5Parts PROPERTIES PURPOSE "For finding KDE parts at runtime")
if(KF5Parts_FOUND AND KF5Service_FOUND)
if(${kfname}Parts_FOUND AND ${kfname}Service_FOUND)
calamares_add_plugin(interactiveterminal
TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO
@ -23,8 +16,8 @@ if(KF5Parts_FOUND AND KF5Service_FOUND)
InteractiveTerminalViewStep.cpp
InteractiveTerminalPage.cpp
LINK_LIBRARIES
KF5::Service
KF5::Parts
${kfname}::Service
${kfname}::Parts
SHARED_LIB
)
else()

View File

@ -16,7 +16,11 @@
#include "widgets/TranslationFix.h"
#include <KParts/ReadOnlyPart>
#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
#include <KParts/kde_terminal_interface.h>
#else
#include <kde_terminal_interface.h>
#endif
#include <KService>
#include <kcoreaddons_version.h>
@ -26,7 +30,6 @@
#include <QMessageBox>
#include <QVBoxLayout>
InteractiveTerminalPage::InteractiveTerminalPage( QWidget* parent )
: QWidget( parent )
, m_layout( new QVBoxLayout( this ) )
@ -58,10 +61,12 @@ InteractiveTerminalPage::onActivate()
return;
}
#if KCOREADDONS_VERSION_MAJOR != 5
#error Incompatible with not-KF5
#endif
#if KCOREADDONS_VERSION_MINOR >= 86
#if KCOREADDONS_VERSION_MAJOR > 5 || KCOREADDONS_VERSION_MINOR > 200
#warning Using KF6
errorKonsoleNotInstalled();
return;
KParts::ReadOnlyPart* p = nullptr;
#elif KCOREADDONS_VERSION_MINOR >= 86
// 5.86 deprecated a bunch of KService and PluginFactory and related methods
auto md = KPluginMetaData::findPluginById( QString(), "konsolepart" );
if ( !md.isValid() )
@ -109,7 +114,6 @@ InteractiveTerminalPage::onActivate()
t->sendInput( QString( "%1\n" ).arg( m_command ) );
}
void
InteractiveTerminalPage::setCommand( const QString& command )
{

View File

@ -11,6 +11,7 @@
#include "InteractiveTerminalPage.h"
#include "compat/Variant.h"
#include "utils/Logger.h"
#include <QVariant>
@ -25,7 +26,6 @@ InteractiveTerminalViewStep::InteractiveTerminalViewStep( QObject* parent )
emit nextStatusChanged( true );
}
InteractiveTerminalViewStep::~InteractiveTerminalViewStep()
{
if ( m_widget && m_widget->parent() == nullptr )
@ -34,49 +34,42 @@ InteractiveTerminalViewStep::~InteractiveTerminalViewStep()
}
}
QString
InteractiveTerminalViewStep::prettyName() const
{
return tr( "Script" );
}
QWidget*
InteractiveTerminalViewStep::widget()
{
return m_widget;
}
bool
InteractiveTerminalViewStep::isNextEnabled() const
{
return true;
}
bool
InteractiveTerminalViewStep::isBackEnabled() const
{
return true;
}
bool
InteractiveTerminalViewStep::isAtBeginning() const
{
return true;
}
bool
InteractiveTerminalViewStep::isAtEnd() const
{
return true;
}
QList< Calamares::job_ptr >
InteractiveTerminalViewStep::jobs() const
{
@ -84,7 +77,6 @@ InteractiveTerminalViewStep::jobs() const
return QList< Calamares::job_ptr >();
}
void
InteractiveTerminalViewStep::onActivate()
{
@ -92,11 +84,11 @@ InteractiveTerminalViewStep::onActivate()
m_widget->onActivate();
}
void
InteractiveTerminalViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
if ( configurationMap.contains( "command" ) && configurationMap.value( "command" ).type() == QVariant::String )
if ( configurationMap.contains( "command" )
&& Calamares::typeOf( configurationMap.value( "command" ) ) == Calamares::StringVariantType )
{
m_widget->setCommand( configurationMap.value( "command" ).toString() );
}