Merge branch 'qml-sidebar'
This commit is contained in:
commit
6ff0ac72de
@ -45,7 +45,7 @@ windowPlacement: center
|
||||
# - "widget" or unset, use traditional sidebar (logo, items)
|
||||
# - "none", hide it entirely
|
||||
# - "qml", use sidebar.qml from branding folder
|
||||
sidebar: none
|
||||
sidebar: widget
|
||||
|
||||
# These are strings shown to the user in the user interface.
|
||||
# There is no provision for translating them -- since they
|
||||
|
@ -11,22 +11,19 @@ set( calamaresSources
|
||||
)
|
||||
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../libcalamares
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/libcalamares
|
||||
${CMAKE_SOURCE_DIR}/src//libcalamaresui
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/libcalamaresui
|
||||
${CMAKE_BINARY_DIR}/src/libcalamares
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Translations
|
||||
include( CalamaresAddTranslations )
|
||||
add_calamares_translations( ${CALAMARES_TRANSLATION_LANGUAGES} )
|
||||
qt5_add_resources( calamaresRc calamares.qrc )
|
||||
|
||||
set( final_src ${calamaresSources} ${calamaresRc} ${trans_outfile} )
|
||||
|
||||
add_executable( calamares_bin ${final_src} )
|
||||
add_executable( calamares_bin ${calamaresSources} ${calamaresRc} ${trans_outfile} )
|
||||
target_include_directories( calamares_bin PRIVATE ${CMAKE_SOURCE_DIR} )
|
||||
set_target_properties(calamares_bin
|
||||
PROPERTIES
|
||||
ENABLE_EXPORTS TRUE
|
||||
@ -37,7 +34,7 @@ calamares_autouic( calamares_bin )
|
||||
|
||||
target_link_libraries( calamares_bin
|
||||
PRIVATE
|
||||
${CALAMARES_LIBRARIES}
|
||||
calamares
|
||||
calamaresui
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
@ -63,6 +60,6 @@ install( FILES ${CMAKE_SOURCE_DIR}/data/images/squid.svg
|
||||
|
||||
if( BUILD_TESTING )
|
||||
add_executable( loadmodule testmain.cpp )
|
||||
target_link_libraries( loadmodule ${CALAMARES_LIBRARIES} Qt5::Core Qt5::Widgets calamaresui )
|
||||
target_link_libraries( loadmodule PRIVATE Qt5::Core Qt5::Widgets calamares calamaresui )
|
||||
# Don't install, it's just for enable_testing
|
||||
endif()
|
||||
|
@ -136,7 +136,8 @@ CalamaresWindow::getQmlSidebar( int desiredWidth )
|
||||
{
|
||||
CalamaresUtils::registerCalamaresModels();
|
||||
QQuickWidget* w = new QQuickWidget( this );
|
||||
w->setSource( QUrl( ":/sidebar.qml" ) );
|
||||
w->setSource( QUrl(
|
||||
CalamaresUtils::searchQmlFile( CalamaresUtils::QmlSearch::Both, QStringLiteral( "calamares-sidebar" ) ) ) );
|
||||
return w;
|
||||
}
|
||||
|
||||
|
35
src/calamares/calamares-sidebar.qml
Normal file
35
src/calamares/calamares-sidebar.qml
Normal file
@ -0,0 +1,35 @@
|
||||
import QtQuick 2.3
|
||||
import io.calamares.ui 1.0
|
||||
import io.calamares.core 1.0
|
||||
|
||||
Column {
|
||||
|
||||
Rectangle {
|
||||
id: hello
|
||||
width: 200
|
||||
height: 100
|
||||
color: "red"
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: Branding.string(Branding.VersionedName)
|
||||
}
|
||||
}
|
||||
|
||||
/* perhaps we could show a branding image here */
|
||||
|
||||
Repeater {
|
||||
model: ViewManager
|
||||
Rectangle {
|
||||
width: 200
|
||||
height: 75
|
||||
color: "black"
|
||||
|
||||
Text {
|
||||
color: completed ? "green" : "yellow"
|
||||
text: display
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
5
src/calamares/calamares.qrc
Normal file
5
src/calamares/calamares.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file alias="calamares-sidebar.qml">calamares-sidebar.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -52,30 +52,48 @@ callQMLFunction( QQuickItem* qmlObject, const char* method )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
searchQmlFile( QmlSearch method, const QString& configuredName, const Calamares::ModuleSystem::InstanceKey& i )
|
||||
/** @brief Appends to @p candidates suitable expansions of @p names
|
||||
*
|
||||
* Depending on @p method, adds search expansions for branding, or QRC,
|
||||
* or both (with branding having precedence).
|
||||
*/
|
||||
static void
|
||||
addExpansions( QmlSearch method, QStringList& candidates, const QStringList& names )
|
||||
{
|
||||
QString bPath( QStringLiteral( "%1/%2.qml" ) );
|
||||
QString qrPath( QStringLiteral( ":/%1.qml" ) );
|
||||
|
||||
cDebug() << "Looking for QML for" << i.toString();
|
||||
if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::BrandingOnly ) )
|
||||
{
|
||||
QString brandDir = Calamares::Branding::instance()->componentDirectory();
|
||||
std::transform( names.constBegin(),
|
||||
names.constEnd(),
|
||||
std::back_inserter( candidates ),
|
||||
[&]( const QString& s ) { return s.isEmpty() ? QString() : bPath.arg( brandDir, s ); } );
|
||||
}
|
||||
if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) )
|
||||
{
|
||||
std::transform( names.constBegin(),
|
||||
names.constEnd(),
|
||||
std::back_inserter( candidates ),
|
||||
[&]( const QString& s ) { return s.isEmpty() ? QString() : qrPath.arg( s ); } );
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Does actual search and returns result.
|
||||
*
|
||||
* Empty items in @p candidates are ignored.
|
||||
*/
|
||||
static QString
|
||||
searchQmlFile( QmlSearch method, const QString& configuredName, const QStringList& hints )
|
||||
{
|
||||
QStringList candidates;
|
||||
if ( configuredName.startsWith( '/' ) )
|
||||
{
|
||||
candidates << configuredName;
|
||||
}
|
||||
if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::BrandingOnly ) )
|
||||
{
|
||||
QString brandDir = Calamares::Branding::instance()->componentDirectory();
|
||||
candidates << ( configuredName.isEmpty() ? QString() : bPath.arg( brandDir, configuredName ) )
|
||||
<< bPath.arg( brandDir, i.toString() ) << bPath.arg( brandDir, i.module() );
|
||||
}
|
||||
if ( ( method == QmlSearch::Both ) || ( method == QmlSearch::QrcOnly ) )
|
||||
{
|
||||
candidates << ( configuredName.isEmpty() ? QString() : qrPath.arg( configuredName ) )
|
||||
<< qrPath.arg( i.toString() ) << qrPath.arg( i.module() );
|
||||
}
|
||||
addExpansions( method, candidates, hints );
|
||||
|
||||
for ( const QString& candidate : candidates )
|
||||
{
|
||||
if ( candidate.isEmpty() )
|
||||
@ -98,6 +116,20 @@ searchQmlFile( QmlSearch method, const QString& configuredName, const Calamares:
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString
|
||||
searchQmlFile( QmlSearch method, const QString& configuredName, const Calamares::ModuleSystem::InstanceKey& i )
|
||||
{
|
||||
cDebug() << "Looking for QML for" << i.toString();
|
||||
return searchQmlFile( method, configuredName, { configuredName, i.toString(), i.module() } );
|
||||
}
|
||||
|
||||
QString
|
||||
searchQmlFile( QmlSearch method, const QString& configuredName )
|
||||
{
|
||||
cDebug() << "Looking for QML for" << configuredName;
|
||||
return searchQmlFile( method, configuredName, { configuredName } );
|
||||
}
|
||||
|
||||
const NamedEnumTable< QmlSearch >&
|
||||
qmlSearchNames()
|
||||
{
|
||||
|
@ -70,6 +70,7 @@ UIDLLEXPORT const NamedEnumTable< QmlSearch >& qmlSearchNames();
|
||||
UIDLLEXPORT QString searchQmlFile( QmlSearch method,
|
||||
const QString& configuredName,
|
||||
const Calamares::ModuleSystem::InstanceKey& i );
|
||||
UIDLLEXPORT QString searchQmlFile( QmlSearch method, const QString& fileNameNoSuffix );
|
||||
|
||||
} // namespace CalamaresUtils
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user