Load QML modules in a central place + dummy QML slideshow.
This commit is contained in:
parent
14ddba70ef
commit
9622888d1d
@ -13,6 +13,9 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/libcalamaresui )
|
||||
include_directories( ${CMAKE_CURRENT_LIST_DIR}/libcalamaresui )
|
||||
add_subdirectory( libcalamaresui )
|
||||
|
||||
# all things qml
|
||||
add_subdirectory( qml )
|
||||
|
||||
# application
|
||||
add_subdirectory( calamares )
|
||||
|
||||
@ -21,3 +24,4 @@ add_subdirectory( modules )
|
||||
|
||||
# branding components
|
||||
add_subdirectory( branding )
|
||||
|
||||
|
@ -1,13 +1,63 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0;
|
||||
import slideshow 1.0;
|
||||
import calamares.slideshow 1.0;
|
||||
|
||||
Presentation
|
||||
{
|
||||
id: presentation
|
||||
width: 1280
|
||||
height: 720
|
||||
|
||||
Timer {
|
||||
interval: 5000
|
||||
running: false
|
||||
repeat: true
|
||||
onTriggered: presentation.goToNextSlide()
|
||||
}
|
||||
|
||||
Slide {
|
||||
centeredText: "Calamares is really nice"
|
||||
|
||||
Image {
|
||||
id: background
|
||||
source: "squid.png"
|
||||
width: 200; height: 200
|
||||
fillMode: Image.PreserveAspectFit
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
Text {
|
||||
anchors.horizontalCenter: background.horizontalCenter
|
||||
anchors.top: background.bottom
|
||||
text: "This is a customizable QML slideshow.<br/>"+
|
||||
"Distributions should provide their own slideshow and list it in <br/>"+
|
||||
"their custom branding.desc file.<br/>"+
|
||||
"To create a Calamares presentation in QML, import calamares.slideshow,<br/>"+
|
||||
"define a Presentation element with as many Slide elements as needed."
|
||||
wrapMode: Text.WordWrap
|
||||
width: root.width
|
||||
horizontalAlignment: Text.Center
|
||||
}
|
||||
}
|
||||
|
||||
Slide {
|
||||
centeredText: "This is a second Slide element."
|
||||
}
|
||||
|
||||
Slide {
|
||||
centeredText: "This is a third Slide element."
|
||||
}
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ CalamaresApplication::init()
|
||||
|
||||
setQuitOnLastWindowClosed( false );
|
||||
|
||||
initQmlPath();
|
||||
initSettings();
|
||||
|
||||
initBranding();
|
||||
|
||||
setWindowIcon( QIcon( Calamares::Branding::instance()->
|
||||
@ -136,6 +136,64 @@ CalamaresApplication::startPhase( Calamares::Phase phase )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CalamaresApplication::initQmlPath()
|
||||
{
|
||||
QDir importPath;
|
||||
|
||||
QString subpath( "qml" );
|
||||
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
importPath = QDir( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( subpath ) );
|
||||
if ( !importPath.exists() || !importPath.isReadable() )
|
||||
{
|
||||
cLog() << "FATAL ERROR: explicitly configured application data directory"
|
||||
<< CalamaresUtils::appDataDir().absolutePath()
|
||||
<< "does not contain a valid QML modules directory at"
|
||||
<< importPath.absolutePath()
|
||||
<< "\nCowardly refusing to continue startup without the QML directory.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList qmlDirCandidatesByPriority;
|
||||
if ( isDebug() )
|
||||
{
|
||||
qmlDirCandidatesByPriority.append(
|
||||
QDir::current().absoluteFilePath(
|
||||
QString( "src/%1" )
|
||||
.arg( subpath ) ) );
|
||||
}
|
||||
qmlDirCandidatesByPriority.append( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( subpath ) );
|
||||
|
||||
foreach ( const QString& path, qmlDirCandidatesByPriority )
|
||||
{
|
||||
QDir dir( path );
|
||||
if ( dir.exists() && dir.isReadable() )
|
||||
{
|
||||
importPath = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !importPath.exists() || !importPath.isReadable() )
|
||||
{
|
||||
cLog() << "FATAL ERROR: none of the expected QML paths ("
|
||||
<< qmlDirCandidatesByPriority.join( ", " )
|
||||
<< ") exist."
|
||||
<< "\nCowardly refusing to continue startup without the QML directory.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
CalamaresUtils::setQmlModulesDir( importPath );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CalamaresApplication::initSettings()
|
||||
{
|
||||
|
@ -53,6 +53,7 @@ private slots:
|
||||
void onPluginsReady();
|
||||
|
||||
private:
|
||||
void initQmlPath();
|
||||
void initSettings();
|
||||
void initBranding();
|
||||
void initPlugins();
|
||||
|
@ -42,6 +42,7 @@ namespace CalamaresUtils
|
||||
{
|
||||
|
||||
static QDir s_appDataDir( CMAKE_INSTALL_FULL_DATADIR );
|
||||
static QDir s_qmlModulesDir( QString( CMAKE_INSTALL_FULL_DATADIR ) + "/qml" );
|
||||
static bool s_isAppDataDirOverridden = false;
|
||||
|
||||
static QTranslator* s_translator = nullptr;
|
||||
@ -77,6 +78,14 @@ isWritableDir( const QDir& dir )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QDir
|
||||
qmlModulesDir()
|
||||
{
|
||||
return s_qmlModulesDir;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setAppDataDir( const QDir& dir )
|
||||
{
|
||||
@ -176,6 +185,13 @@ installTranslator( const QString& localeName, QObject* parent )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
setQmlModulesDir( const QDir &dir )
|
||||
{
|
||||
s_qmlModulesDir = dir;
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
removeDiacritics( const QString& string )
|
||||
{
|
||||
|
@ -33,6 +33,7 @@ class QObject;
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
DLLEXPORT QDir qmlModulesDir();
|
||||
DLLEXPORT QDir appDataDir();
|
||||
DLLEXPORT QDir appLogDir();
|
||||
DLLEXPORT QDir systemLibDir();
|
||||
@ -44,6 +45,8 @@ namespace CalamaresUtils
|
||||
DLLEXPORT void setAppDataDir( const QDir& dir );
|
||||
DLLEXPORT bool isAppDataDirOverridden();
|
||||
|
||||
DLLEXPORT void setQmlModulesDir( const QDir& dir );
|
||||
|
||||
DLLEXPORT QString removeDiacritics( const QString& string );
|
||||
}
|
||||
|
||||
|
@ -45,5 +45,3 @@ calamares_add_library( ${CALAMARESUI_LIBRARY_TARGET}
|
||||
EXPORT CalamaresLibraryDepends
|
||||
VERSION ${CALAMARES_VERSION_SHORT}
|
||||
)
|
||||
|
||||
add_subdirectory( slideshow )
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -52,61 +53,8 @@ InstallationViewStep::InstallationViewStep( QObject* parent )
|
||||
m_slideShow->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
m_slideShow->setResizeMode( QQuickWidget::SizeRootObjectToView );
|
||||
|
||||
QDir importPath;
|
||||
{
|
||||
QString subpath( "slideshow" );
|
||||
m_slideShow->engine()->addImportPath( CalamaresUtils::qmlModulesDir().absolutePath() );
|
||||
|
||||
if ( CalamaresUtils::isAppDataDirOverridden() )
|
||||
{
|
||||
importPath = QDir( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( subpath ) );
|
||||
if ( !importPath.exists() || !importPath.isReadable() )
|
||||
{
|
||||
cLog() << "FATAL ERROR: explicitly configured application data directory"
|
||||
<< CalamaresUtils::appDataDir().absolutePath()
|
||||
<< "does not contain a valid slideshow directory at"
|
||||
<< importPath.absolutePath()
|
||||
<< "\nCowardly refusing to continue startup without slideshow.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList slideshowDirCandidatesByPriority;
|
||||
if ( Calamares::Settings::instance()->debugMode() )
|
||||
{
|
||||
slideshowDirCandidatesByPriority.append(
|
||||
QDir::current().absoluteFilePath(
|
||||
QString( "src/libcalamaresui/%1" )
|
||||
.arg( subpath ) ) );
|
||||
}
|
||||
slideshowDirCandidatesByPriority.append( CalamaresUtils::appDataDir()
|
||||
.absoluteFilePath( subpath ) );
|
||||
|
||||
foreach ( const QString& path, slideshowDirCandidatesByPriority )
|
||||
{
|
||||
QDir dir( path );
|
||||
if ( dir.exists() && dir.isReadable() )
|
||||
{
|
||||
importPath = dir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !importPath.exists() || !importPath.isReadable() )
|
||||
{
|
||||
cLog() << "FATAL ERROR: none of the expected slideshow paths ("
|
||||
<< slideshowDirCandidatesByPriority.join( ", " )
|
||||
<< ") exist."
|
||||
<< "\nCowardly refusing to continue startup without slideshow.";
|
||||
::exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
}
|
||||
cDebug() << "importPath:" << importPath;
|
||||
importPath.cdUp();
|
||||
|
||||
m_slideShow->engine()->addImportPath( importPath.absolutePath() );
|
||||
m_slideShow->setSource( QUrl::fromLocalFile( Calamares::Branding::instance()
|
||||
->slideshowPath() ) );
|
||||
|
||||
@ -117,8 +65,7 @@ InstallationViewStep::InstallationViewStep( QObject* parent )
|
||||
connect( JobQueue::instance(), &JobQueue::progress,
|
||||
this, &InstallationViewStep::updateFromJobQueue );
|
||||
|
||||
cDebug() << "importPathList:" << m_slideShow->engine()->importPathList();
|
||||
|
||||
cDebug() << "QML import paths:" << m_slideShow->engine()->importPathList();
|
||||
}
|
||||
|
||||
QString
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -1,14 +0,0 @@
|
||||
set( QML_FILES
|
||||
qmldir
|
||||
Presentation.qml
|
||||
Slide.qml
|
||||
)
|
||||
|
||||
set( SLIDESHOW_DIR share/calamares/slideshow )
|
||||
|
||||
foreach( QML_FILE ${QML_FILES} )
|
||||
configure_file( ${QML_FILE} ${QML_FILE} COPYONLY )
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${QML_FILE}
|
||||
DESTINATION ${SLIDESHOW_DIR} )
|
||||
endforeach()
|
||||
|
1
src/qml/CMakeLists.txt
Normal file
1
src/qml/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory( calamares )
|
27
src/qml/calamares/CMakeLists.txt
Normal file
27
src/qml/calamares/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" )
|
||||
|
||||
# Iterate over all the subdirectories which have a qmldir file, copy them over to the build dir,
|
||||
# and install them into share/calamares/qml/calamares
|
||||
foreach( SUBDIRECTORY ${SUBDIRECTORIES} )
|
||||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}"
|
||||
AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/qmldir" )
|
||||
|
||||
set( QML_DIR share/calamares/qml )
|
||||
set( QML_MODULE_DESTINATION ${QML_DIR}/calamares/${SUBDIRECTORY} )
|
||||
|
||||
# We glob all the files inside the subdirectory, and we make sure they are
|
||||
# synced with the bindir structure and installed.
|
||||
file( GLOB QML_MODULE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*" )
|
||||
foreach( QML_MODULE_FILE ${QML_MODULE_FILES} )
|
||||
if( NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/${QML_MODULE_FILE} )
|
||||
configure_file( ${SUBDIRECTORY}/${QML_MODULE_FILE} ${SUBDIRECTORY}/${QML_MODULE_FILE} COPYONLY )
|
||||
|
||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${QML_MODULE_FILE}
|
||||
DESTINATION ${QML_MODULE_DESTINATION} )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
message( "-- ${BoldYellow}Configured QML module: ${BoldRed}calamares.${SUBDIRECTORY}${ColorReset}" )
|
||||
|
||||
endif()
|
||||
endforeach()
|
@ -1,4 +1,4 @@
|
||||
module slideshow
|
||||
module calamares.slideshow
|
||||
Presentation 1.0 Presentation.qml
|
||||
Slide 1.0 Slide.qml
|
||||
|
Loading…
Reference in New Issue
Block a user