Merge branch 'branding'
Documentation lives both in Calamares and in the calamares-branding repo. Whether a slideshow has navigation arrows or not is up to the slideshow / branding component author, but Calamares now ships some support QML to make that easy. FIXES #841 FIXES #904main
@ -1,43 +1,136 @@
|
|||||||
include( CMakeColors )
|
# === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
#
|
||||||
function( calamares_add_branding_subdirectory )
|
# Calamares is free software: you can redistribute it and/or modify
|
||||||
set( SUBDIRECTORY ${ARGV0} )
|
# 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/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0+
|
||||||
|
# License-Filename: LICENSE
|
||||||
|
#
|
||||||
|
###
|
||||||
|
#
|
||||||
|
# Support macros for creating Calamares branding components.
|
||||||
|
#
|
||||||
|
# Calamares branding components have two parts:
|
||||||
|
# - a branding.desc file that tells Calamares how to describe the product
|
||||||
|
# (e.g. strings like "Generic GNU/Linux") and the name of a QML file
|
||||||
|
# (the "slideshow") that is displayed during installation.
|
||||||
|
# - the QML files themselves, plus supporting images etc.
|
||||||
|
#
|
||||||
|
# Branding components can be created inside the Calamares source tree
|
||||||
|
# (there is one example the `default/` branding, which is also connected
|
||||||
|
# to the default configuration shipped with Calamares), but they can be
|
||||||
|
# built outside of, and largely independently of, Calamares by using
|
||||||
|
# these CMake macros.
|
||||||
|
#
|
||||||
|
# See the calamares-examples repository for more examples.
|
||||||
|
#
|
||||||
|
include( CMakeParseArguments)
|
||||||
|
|
||||||
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
|
include( CMakeColors )
|
||||||
add_subdirectory( $SUBDIRECTORY )
|
|
||||||
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${SUBDIRECTORY}${ColorReset}" )
|
|
||||||
|
|
||||||
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/branding.desc" )
|
# Usage calamares_add_branding( <name> [DIRECTORY <dir>] [SUBDIRECTORIES <dir> ...])
|
||||||
set( BRANDING_DIR share/calamares/branding )
|
#
|
||||||
set( BRANDING_COMPONENT_DESTINATION ${BRANDING_DIR}/${SUBDIRECTORY} )
|
# Adds a branding component to the build:
|
||||||
|
# - the component's top-level files are copied into the build-dir;
|
||||||
|
# CMakeLists.txt is excluded from the glob.
|
||||||
|
# - the component's top-level files are installed into the component branding dir
|
||||||
|
#
|
||||||
|
# The branding component lives in <dir> if given, otherwise the
|
||||||
|
# current source directory. The branding component is installed
|
||||||
|
# with the given <name>, which is usually the name of the
|
||||||
|
# directory containing the component, and which must match the
|
||||||
|
# *componentName* in `branding.desc`.
|
||||||
|
#
|
||||||
|
# If SUBDIRECTORIES are given, then those are copied (each one level deep)
|
||||||
|
# to the installation location as well, preserving the subdirectory name.
|
||||||
|
function( calamares_add_branding NAME )
|
||||||
|
set( _CABT_DIRECTORY "." )
|
||||||
|
cmake_parse_arguments( _CABT "" "DIRECTORY" "SUBDIRECTORIES" ${ARGN} )
|
||||||
|
set( SUBDIRECTORY ${_CABT_DIRECTORY} )
|
||||||
|
set( _brand_dir ${_CABT_DIRECTORY} )
|
||||||
|
|
||||||
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
|
set( BRANDING_DIR share/calamares/branding )
|
||||||
message( "-- ${BoldYellow}Warning:${ColorReset} branding component ${BoldRed}${SUBDIRECTORY}${ColorReset} has a translations subdirectory but no CMakeLists.txt." )
|
set( BRANDING_COMPONENT_DESTINATION ${BRANDING_DIR}/${NAME} )
|
||||||
message( "" )
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# We glob all the files inside the subdirectory, and we make sure they are
|
foreach( _subdir "" ${_CABT_SUBDIRECTORIES} )
|
||||||
# synced with the bindir structure and installed.
|
file( GLOB BRANDING_COMPONENT_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${_brand_dir} "${_brand_dir}/${_subdir}/*" )
|
||||||
file( GLOB BRANDING_COMPONENT_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*" )
|
message(STATUS "${BRANDING_COMPONENT_FILES}")
|
||||||
foreach( BRANDING_COMPONENT_FILE ${BRANDING_COMPONENT_FILES} )
|
foreach( BRANDING_COMPONENT_FILE ${BRANDING_COMPONENT_FILES} )
|
||||||
if( NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/${BRANDING_COMPONENT_FILE} )
|
set( _subpath ${_brand_dir}/${BRANDING_COMPONENT_FILE} )
|
||||||
configure_file( ${SUBDIRECTORY}/${BRANDING_COMPONENT_FILE} ${SUBDIRECTORY}/${BRANDING_COMPONENT_FILE} COPYONLY )
|
if( NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_subpath} )
|
||||||
|
configure_file( ${_subpath} ${_subpath} COPYONLY )
|
||||||
|
|
||||||
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${BRANDING_COMPONENT_FILE}
|
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_subpath}
|
||||||
DESTINATION ${BRANDING_COMPONENT_DESTINATION} )
|
DESTINATION ${BRANDING_COMPONENT_DESTINATION}/${_subdir}/ )
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${NAME}${ColorReset}" )
|
||||||
|
if( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
|
||||||
|
message( " ${Green}TYPE:${ColorReset} branding component" )
|
||||||
|
message( " ${Green}BRANDING_COMPONENT_DESTINATION:${ColorReset} ${BRANDING_COMPONENT_DESTINATION}" )
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${SUBDIRECTORY}${ColorReset}" )
|
# Usage calamares_add_branding_translations( <name> [DIRECTORY <dir>])
|
||||||
if( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
|
#
|
||||||
message( " ${Green}TYPE:${ColorReset} branding component" )
|
# Adds the translations for a branding component to the build:
|
||||||
# message( " ${Green}FILES:${ColorReset} ${BRANDING_COMPONENT_FILES}" )
|
# - the component's lang/ directory is scanned for .ts files
|
||||||
message( " ${Green}BRANDING_COMPONENT_DESTINATION:${ColorReset} ${BRANDING_COMPONENT_DESTINATION}" )
|
# - the component's translations are installed into the component branding dir
|
||||||
message( "" )
|
#
|
||||||
|
# Translation files must be called calamares-<name>_<lang>.ts . Optionally
|
||||||
|
# the lang/ dir is found in the given <dir> instead of the current source
|
||||||
|
# directory.
|
||||||
|
function( calamares_add_branding_translations NAME )
|
||||||
|
set( _CABT_DIRECTORY "." )
|
||||||
|
cmake_parse_arguments( _CABT "" "DIRECTORY" "" ${ARGN} )
|
||||||
|
set( SUBDIRECTORY ${_CABT_DIRECTORY} )
|
||||||
|
set( _brand_dir ${_CABT_DIRECTORY} )
|
||||||
|
|
||||||
|
set( BRANDING_DIR share/calamares/branding )
|
||||||
|
set( BRANDING_COMPONENT_DESTINATION ${BRANDING_DIR}/${NAME} )
|
||||||
|
|
||||||
|
file( GLOB BRANDING_TRANSLATION_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${SUBDIRECTORY}/lang/calamares-${NAME}_*.ts" )
|
||||||
|
if ( BRANDING_TRANSLATION_FILES )
|
||||||
|
qt5_add_translation( QM_FILES ${BRANDING_TRANSLATION_FILES} )
|
||||||
|
add_custom_target( branding-translation-${NAME} ALL DEPENDS ${QM_FILES} )
|
||||||
|
install( FILES ${QM_FILES} DESTINATION ${BRANDING_COMPONENT_DESTINATION}/lang/ )
|
||||||
|
list( LENGTH BRANDING_TRANSLATION_FILES _branding_count )
|
||||||
|
message( " ${Green}BRANDING_TRANSLATIONS:${ColorReset} ${_branding_count} language(s)" )
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Usage calamares_add_branding_subdirectory( <dir> [SUBDIRECTORIES <dir> ...])
|
||||||
|
#
|
||||||
|
# Adds a branding component from a subdirectory:
|
||||||
|
# - if there is a CMakeLists.txt, use that
|
||||||
|
# - otherwise assume a "standard" setup with top-level files and a lang/ dir for translations
|
||||||
|
#
|
||||||
|
# If SUBDIRECTORIES are given, they are relative to <dir>, and are
|
||||||
|
# copied (one level deep) to the install location as well.
|
||||||
|
function( calamares_add_branding_subdirectory SUBDIRECTORY )
|
||||||
|
cmake_parse_arguments( _CABS "" "" "SUBDIRECTORIES" ${ARGN} )
|
||||||
|
|
||||||
|
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
|
||||||
|
add_subdirectory( ${SUBDIRECTORY} )
|
||||||
|
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/branding.desc" )
|
||||||
|
calamares_add_branding( ${SUBDIRECTORY} DIRECTORY ${SUBDIRECTORY} SUBDIRECTORIES ${_CABS_SUBDIRECTORIES} )
|
||||||
|
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
|
||||||
|
calamares_add_branding_translations( ${SUBDIRECTORY} DIRECTORY ${SUBDIRECTORY} )
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add branding component subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no branding.desc." )
|
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add branding component subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no branding.desc." )
|
||||||
message( "" )
|
|
||||||
endif()
|
endif()
|
||||||
|
message( "" )
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@ -1,73 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** BSD License Usage
|
|
||||||
** Alternatively, you may use this file under the terms of the BSD license
|
|
||||||
** as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
|
||||||
** contributors may be used to endorse or promote products derived
|
|
||||||
** from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
//![0]
|
|
||||||
import QtQuick 2.0
|
|
||||||
|
|
||||||
Item {
|
|
||||||
id: block
|
|
||||||
|
|
||||||
property int type: 0
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: img
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
source: {
|
|
||||||
if (type == 0)
|
|
||||||
return "redStone.png";
|
|
||||||
else if (type == 1)
|
|
||||||
return "blueStone.png";
|
|
||||||
else
|
|
||||||
return "greenStone.png";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![0]
|
|
||||||
@ -1,91 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** BSD License Usage
|
|
||||||
** Alternatively, you may use this file under the terms of the BSD license
|
|
||||||
** as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
|
||||||
** contributors may be used to endorse or promote products derived
|
|
||||||
** from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
import QtQuick 2.0
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: container
|
|
||||||
|
|
||||||
property string text: "Button"
|
|
||||||
|
|
||||||
signal clicked
|
|
||||||
|
|
||||||
width: buttonLabel.width + 20; height: buttonLabel.height + 5
|
|
||||||
border { width: 1; color: Qt.darker(activePalette.button) }
|
|
||||||
antialiasing: true
|
|
||||||
radius: 8
|
|
||||||
|
|
||||||
// color the button with a gradient
|
|
||||||
gradient: Gradient {
|
|
||||||
GradientStop {
|
|
||||||
position: 0.0
|
|
||||||
color: {
|
|
||||||
if (mouseArea.pressed)
|
|
||||||
return activePalette.dark
|
|
||||||
else
|
|
||||||
return activePalette.light
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GradientStop { position: 1.0; color: activePalette.button }
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: container.clicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: buttonLabel
|
|
||||||
anchors.centerIn: container
|
|
||||||
color: activePalette.buttonText
|
|
||||||
text: container.text
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,81 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** BSD License Usage
|
|
||||||
** Alternatively, you may use this file under the terms of the BSD license
|
|
||||||
** as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
|
||||||
** contributors may be used to endorse or promote products derived
|
|
||||||
** from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
//![0]
|
|
||||||
import QtQuick 2.0
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: container
|
|
||||||
|
|
||||||
function show(text) {
|
|
||||||
dialogText.text = text;
|
|
||||||
container.opacity = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function hide() {
|
|
||||||
container.opacity = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
width: dialogText.width + 20
|
|
||||||
height: dialogText.height + 20
|
|
||||||
opacity: 0
|
|
||||||
|
|
||||||
Text {
|
|
||||||
id: dialogText
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: ""
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![0]
|
|
||||||
|
Before Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 3.0 KiB |
@ -1,76 +0,0 @@
|
|||||||
---
|
|
||||||
componentName: samegame
|
|
||||||
|
|
||||||
# This selects between different welcome texts. When false, uses
|
|
||||||
# the traditional "Welcome to the %1 installer.", and when true,
|
|
||||||
# uses "Welcome to the Calamares installer for %1." This allows
|
|
||||||
# to distinguish this installer from other installers for the
|
|
||||||
# same distribution.
|
|
||||||
welcomeStyleCalamares: false
|
|
||||||
|
|
||||||
# These are strings shown to the user in the user interface.
|
|
||||||
# There is no provision for translating them -- since they
|
|
||||||
# are names, the string is included as-is.
|
|
||||||
#
|
|
||||||
# The four Url strings are the Urls used by the buttons in
|
|
||||||
# the welcome screen, and are not shown to the user. Clicking
|
|
||||||
# on the "Support" button, for instance, opens the link supportUrl.
|
|
||||||
# If a Url is empty, the corresponding button is not shown.
|
|
||||||
#
|
|
||||||
# bootloaderEntryName is how this installation / distro is named
|
|
||||||
# in the boot loader (e.g. in the GRUB menu).
|
|
||||||
strings:
|
|
||||||
productName: Generic GNU/Linux
|
|
||||||
shortProductName: Generic
|
|
||||||
version: 2018.1 LTS
|
|
||||||
shortVersion: 2018.1
|
|
||||||
versionedName: Generic GNU/Linux 2018.1 LTS "Tasseled Tambourine"
|
|
||||||
shortVersionedName: Generic 2018.1
|
|
||||||
bootloaderEntryName: Generic
|
|
||||||
productUrl: https://calamares.io/
|
|
||||||
supportUrl: https://github.com/calamares/calamares/issues
|
|
||||||
knownIssuesUrl: https://calamares.io/about/
|
|
||||||
releaseNotesUrl: https://calamares.io/about/
|
|
||||||
|
|
||||||
# Should the welcome image (productWelcome, below) be scaled
|
|
||||||
# up beyond its natural size? If false, the image does not grow
|
|
||||||
# with the window but remains the same size throughout (this
|
|
||||||
# may have surprising effects on HiDPI monitors).
|
|
||||||
welcomeExpandingLogo: true
|
|
||||||
|
|
||||||
# These images are loaded from the branding module directory.
|
|
||||||
#
|
|
||||||
# productIcon is used as the window icon, and will (usually) be used
|
|
||||||
# by the window manager to represent the application. This image
|
|
||||||
# should be square, and may be displayed by the window manager
|
|
||||||
# as small as 16x16 (but possibly larger).
|
|
||||||
# productLogo is used as the logo at the top of the left-hand column
|
|
||||||
# which shows the steps to be taken. The image should be square,
|
|
||||||
# and is displayed at 80x80 pixels (also on HiDPI).
|
|
||||||
# productWelcome is shown on the welcome page of the application in
|
|
||||||
# the middle of the window, below the welcome text. It can be
|
|
||||||
# any size and proportion, and will be scaled to fit inside
|
|
||||||
# the window. Use `welcomeExpandingLogo` to make it non-scaled.
|
|
||||||
# Recommended size is 320x150.
|
|
||||||
images:
|
|
||||||
productLogo: "squidball.png"
|
|
||||||
productIcon: "squidball.png"
|
|
||||||
productWelcome: "languages.png"
|
|
||||||
|
|
||||||
# The slideshow is displayed during execution steps (e.g. when the
|
|
||||||
# installer is actually writing to disk and doing other slow things).
|
|
||||||
slideshow: "samegame.qml"
|
|
||||||
|
|
||||||
# Colors for text and background components.
|
|
||||||
#
|
|
||||||
# - sidebarBackground is the background of the sidebar
|
|
||||||
# - sidebarText is the (foreground) text color
|
|
||||||
# - sidebarTextHighlight sets the background of the selected (current) step.
|
|
||||||
# Optional, and defaults to the application palette.
|
|
||||||
# - sidebarSelect is the text color of the selected step.
|
|
||||||
#
|
|
||||||
style:
|
|
||||||
sidebarBackground: "#292F34"
|
|
||||||
sidebarText: "#FFFFFF"
|
|
||||||
sidebarTextSelect: "#292F34"
|
|
||||||
sidebarTextHighlight: "#D35400"
|
|
||||||
|
Before Width: | Height: | Size: 149 B |
|
Before Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 148 B |
|
Before Width: | Height: | Size: 2.8 KiB |
@ -1,174 +0,0 @@
|
|||||||
/* This script file handles the game logic */
|
|
||||||
var maxColumn = 10;
|
|
||||||
var maxRow = 15;
|
|
||||||
var maxIndex = maxColumn * maxRow;
|
|
||||||
var board = new Array(maxIndex);
|
|
||||||
var component;
|
|
||||||
|
|
||||||
//Index function used instead of a 2D array
|
|
||||||
function index(column, row) {
|
|
||||||
return column + (row * maxColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
function startNewGame() {
|
|
||||||
//Calculate board size
|
|
||||||
maxColumn = Math.floor(gameCanvas.width / gameCanvas.blockSize);
|
|
||||||
maxRow = Math.floor(gameCanvas.height / gameCanvas.blockSize);
|
|
||||||
maxIndex = maxRow * maxColumn;
|
|
||||||
|
|
||||||
//Close dialogs
|
|
||||||
dialog.hide();
|
|
||||||
|
|
||||||
//Initialize Board
|
|
||||||
board = new Array(maxIndex);
|
|
||||||
gameCanvas.score = 0;
|
|
||||||
for (var column = 0; column < maxColumn; column++) {
|
|
||||||
for (var row = 0; row < maxRow; row++) {
|
|
||||||
board[index(column, row)] = null;
|
|
||||||
createBlock(column, row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function createBlock(column, row) {
|
|
||||||
if (component == null)
|
|
||||||
component = Qt.createComponent("Block.qml");
|
|
||||||
|
|
||||||
// Note that if Block.qml was not a local file, component.status would be
|
|
||||||
// Loading and we should wait for the component's statusChanged() signal to
|
|
||||||
// know when the file is downloaded and ready before calling createObject().
|
|
||||||
if (component.status == Component.Ready) {
|
|
||||||
var dynamicObject = component.createObject(gameCanvas);
|
|
||||||
if (dynamicObject == null) {
|
|
||||||
console.log("error creating block");
|
|
||||||
console.log(component.errorString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dynamicObject.type = Math.floor(Math.random() * 3);
|
|
||||||
dynamicObject.x = column * gameCanvas.blockSize;
|
|
||||||
dynamicObject.y = row * gameCanvas.blockSize;
|
|
||||||
dynamicObject.width = gameCanvas.blockSize;
|
|
||||||
dynamicObject.height = gameCanvas.blockSize;
|
|
||||||
board[index(column, row)] = dynamicObject;
|
|
||||||
} else {
|
|
||||||
console.log("error loading block component");
|
|
||||||
console.log(component.errorString());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var fillFound; //Set after a floodFill call to the number of blocks found
|
|
||||||
var floodBoard; //Set to 1 if the floodFill reaches off that node
|
|
||||||
|
|
||||||
//![1]
|
|
||||||
function handleClick(xPos, yPos) {
|
|
||||||
var column = Math.floor(xPos / gameCanvas.blockSize);
|
|
||||||
var row = Math.floor(yPos / gameCanvas.blockSize);
|
|
||||||
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
|
|
||||||
return;
|
|
||||||
if (board[index(column, row)] == null)
|
|
||||||
return;
|
|
||||||
//If it's a valid block, remove it and all connected (does nothing if it's not connected)
|
|
||||||
floodFill(column, row, -1);
|
|
||||||
if (fillFound <= 0)
|
|
||||||
return;
|
|
||||||
gameCanvas.score += (fillFound - 1) * (fillFound - 1);
|
|
||||||
shuffleDown();
|
|
||||||
victoryCheck();
|
|
||||||
}
|
|
||||||
//![1]
|
|
||||||
|
|
||||||
function floodFill(column, row, type) {
|
|
||||||
if (board[index(column, row)] == null)
|
|
||||||
return;
|
|
||||||
var first = false;
|
|
||||||
if (type == -1) {
|
|
||||||
first = true;
|
|
||||||
type = board[index(column, row)].type;
|
|
||||||
|
|
||||||
//Flood fill initialization
|
|
||||||
fillFound = 0;
|
|
||||||
floodBoard = new Array(maxIndex);
|
|
||||||
}
|
|
||||||
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
|
|
||||||
return;
|
|
||||||
if (floodBoard[index(column, row)] == 1 || (!first && type != board[index(column, row)].type))
|
|
||||||
return;
|
|
||||||
floodBoard[index(column, row)] = 1;
|
|
||||||
floodFill(column + 1, row, type);
|
|
||||||
floodFill(column - 1, row, type);
|
|
||||||
floodFill(column, row + 1, type);
|
|
||||||
floodFill(column, row - 1, type);
|
|
||||||
if (first == true && fillFound == 0)
|
|
||||||
return; //Can't remove single blocks
|
|
||||||
board[index(column, row)].opacity = 0;
|
|
||||||
board[index(column, row)] = null;
|
|
||||||
fillFound += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
function shuffleDown() {
|
|
||||||
//Fall down
|
|
||||||
for (var column = 0; column < maxColumn; column++) {
|
|
||||||
var fallDist = 0;
|
|
||||||
for (var row = maxRow - 1; row >= 0; row--) {
|
|
||||||
if (board[index(column, row)] == null) {
|
|
||||||
fallDist += 1;
|
|
||||||
} else {
|
|
||||||
if (fallDist > 0) {
|
|
||||||
var obj = board[index(column, row)];
|
|
||||||
obj.y += fallDist * gameCanvas.blockSize;
|
|
||||||
board[index(column, row + fallDist)] = obj;
|
|
||||||
board[index(column, row)] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Fall to the left
|
|
||||||
var fallDist = 0;
|
|
||||||
for (var column = 0; column < maxColumn; column++) {
|
|
||||||
if (board[index(column, maxRow - 1)] == null) {
|
|
||||||
fallDist += 1;
|
|
||||||
} else {
|
|
||||||
if (fallDist > 0) {
|
|
||||||
for (var row = 0; row < maxRow; row++) {
|
|
||||||
var obj = board[index(column, row)];
|
|
||||||
if (obj == null)
|
|
||||||
continue;
|
|
||||||
obj.x -= fallDist * gameCanvas.blockSize;
|
|
||||||
board[index(column - fallDist, row)] = obj;
|
|
||||||
board[index(column, row)] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//![2]
|
|
||||||
function victoryCheck() {
|
|
||||||
//Award bonus points if no blocks left
|
|
||||||
var deservesBonus = true;
|
|
||||||
for (var column = maxColumn - 1; column >= 0; column--)
|
|
||||||
if (board[index(column, maxRow - 1)] != null)
|
|
||||||
deservesBonus = false;
|
|
||||||
if (deservesBonus)
|
|
||||||
gameCanvas.score += 500;
|
|
||||||
|
|
||||||
//Check whether game has finished
|
|
||||||
if (deservesBonus || !(floodMoveCheck(0, maxRow - 1, -1)))
|
|
||||||
dialog.show("Game Over. Your score is " + gameCanvas.score);
|
|
||||||
}
|
|
||||||
//![2]
|
|
||||||
|
|
||||||
//only floods up and right, to see if it can find adjacent same-typed blocks
|
|
||||||
function floodMoveCheck(column, row, type) {
|
|
||||||
if (column >= maxColumn || column < 0 || row >= maxRow || row < 0)
|
|
||||||
return false;
|
|
||||||
if (board[index(column, row)] == null)
|
|
||||||
return false;
|
|
||||||
var myType = board[index(column, row)].type;
|
|
||||||
if (type == myType)
|
|
||||||
return true;
|
|
||||||
return floodMoveCheck(column + 1, row, myType) || floodMoveCheck(column, row - 1, board[index(column, row)].type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,113 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2017 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the examples of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** BSD License Usage
|
|
||||||
** Alternatively, you may use this file under the terms of the BSD license
|
|
||||||
** as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * Redistributions in binary form must reproduce the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer in
|
|
||||||
** the documentation and/or other materials provided with the
|
|
||||||
** distribution.
|
|
||||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
|
||||||
** contributors may be used to endorse or promote products derived
|
|
||||||
** from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
//![0]
|
|
||||||
import QtQuick 2.0
|
|
||||||
import "samegame.js" as SameGame
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: screen
|
|
||||||
|
|
||||||
width: 490; height: 720
|
|
||||||
|
|
||||||
SystemPalette { id: activePalette }
|
|
||||||
|
|
||||||
Item {
|
|
||||||
width: parent.width
|
|
||||||
anchors { top: parent.top; bottom: toolBar.top }
|
|
||||||
|
|
||||||
Image {
|
|
||||||
id: background
|
|
||||||
anchors.fill: parent
|
|
||||||
source: "background.jpg"
|
|
||||||
fillMode: Image.PreserveAspectCrop
|
|
||||||
}
|
|
||||||
|
|
||||||
//![1]
|
|
||||||
Item {
|
|
||||||
id: gameCanvas
|
|
||||||
|
|
||||||
property int score: 0
|
|
||||||
property int blockSize: 40
|
|
||||||
|
|
||||||
width: parent.width - (parent.width % blockSize)
|
|
||||||
height: parent.height - (parent.height % blockSize)
|
|
||||||
anchors.centerIn: parent
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
anchors.fill: parent
|
|
||||||
onClicked: SameGame.handleClick(mouse.x, mouse.y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![1]
|
|
||||||
}
|
|
||||||
|
|
||||||
//![2]
|
|
||||||
Dialog {
|
|
||||||
id: dialog
|
|
||||||
anchors.centerIn: parent
|
|
||||||
z: 100
|
|
||||||
}
|
|
||||||
//![2]
|
|
||||||
|
|
||||||
Rectangle {
|
|
||||||
id: toolBar
|
|
||||||
width: parent.width; height: 30
|
|
||||||
color: activePalette.window
|
|
||||||
anchors.bottom: screen.bottom
|
|
||||||
|
|
||||||
Button {
|
|
||||||
anchors { left: parent.left; verticalCenter: parent.verticalCenter }
|
|
||||||
text: "New Game"
|
|
||||||
onClicked: SameGame.startNewGame()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//![0]
|
|
||||||
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 3.0 KiB |
@ -0,0 +1,24 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NavButton {
|
||||||
|
id: backButton
|
||||||
|
anchors.left: parent.left
|
||||||
|
visible: parent.currentSlide > 0
|
||||||
|
isForward: false
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
NavButton {
|
||||||
|
id: forwardButton
|
||||||
|
anchors.right: parent.right
|
||||||
|
visible: parent.currentSlide + 1 < parent.slides.length;
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This is a navigation (arrow) button that fades in on hover, and
|
||||||
|
* which calls forward / backward navigation on the presentation it
|
||||||
|
* is in. It should be a child item of the presentation (not of a
|
||||||
|
* single slide). Use the ForwardButton or BackButton for a pre-
|
||||||
|
* configured instance that interacts with the presentation.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.5;
|
||||||
|
|
||||||
|
Image {
|
||||||
|
id: fade
|
||||||
|
|
||||||
|
property bool isForward : true
|
||||||
|
|
||||||
|
width: 100
|
||||||
|
height: 100
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
opacity: 0.3
|
||||||
|
|
||||||
|
OpacityAnimator {
|
||||||
|
id: fadeIn
|
||||||
|
target: fade
|
||||||
|
from: fade.opacity
|
||||||
|
to: 1.0
|
||||||
|
duration: 500
|
||||||
|
running: false
|
||||||
|
}
|
||||||
|
|
||||||
|
OpacityAnimator {
|
||||||
|
id: fadeOut
|
||||||
|
target: fade
|
||||||
|
from: fade.opacity
|
||||||
|
to: 0.3
|
||||||
|
duration: 250
|
||||||
|
running: false
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
onEntered: { fadeOut.running = false; fadeIn.running = true }
|
||||||
|
onExited: { fadeIn.running = false ; fadeOut.running = true }
|
||||||
|
onClicked: {
|
||||||
|
if (isForward)
|
||||||
|
fade.parent.goToNextSlide()
|
||||||
|
else
|
||||||
|
fade.parent.goToPreviousSlide()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2018, Adriaan de Groot <groot@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This control just shows a (non-translated) count of the slides
|
||||||
|
* in the slideshow in the format "n / total".
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick 2.5;
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: slideCounter
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
width: 100
|
||||||
|
height: 50
|
||||||
|
|
||||||
|
Text {
|
||||||
|
id: slideCounterText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
//: slide counter, %1 of %2 (numeric)
|
||||||
|
text: qsTr("%L1 / %L2").arg(parent.parent.currentSlide + 1).arg(parent.parent.slides.length)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,10 @@
|
|||||||
module calamares.slideshow
|
module calamares.slideshow
|
||||||
|
|
||||||
Presentation 1.0 Presentation.qml
|
Presentation 1.0 Presentation.qml
|
||||||
Slide 1.0 Slide.qml
|
Slide 1.0 Slide.qml
|
||||||
|
|
||||||
|
NavButton 1.0 NavButton.qml
|
||||||
|
ForwardButton 1.0 ForwardButton.qml
|
||||||
|
BackButton 1.0 BackButton.qml
|
||||||
|
|
||||||
|
SlideCounter 1.0 SlideCounter.qml
|
||||||
|
|||||||