Commit 3335e721 authored by Marco Martin's avatar Marco Martin
Browse files

initial import

parents
cmake_minimum_required(VERSION 3.0)
set(KF5_VERSION "5.47.0") # handled by release scripts
set(KF5_DEP_VERSION "5.47.0") # handled by release scripts
project(kirigami2gallery VERSION ${KF5_VERSION})
set(REQUIRED_QT_VERSION 5.8.0)
SET(CMAKE_CXX_STANDARD 11)
################# Disallow in-source build #################
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "kirigami gallery requires an out of source build. Please create a separate build directory and run 'cmake path_to_kirigami [options]' there.")
endif()
# Make CPack available to easy generate binary packages
include(CPack)
include(FeatureSummary)
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Gui Svg QuickControls2)
set(CMAKE_AUTOMOC ON)
set(AUTOMOC_MOC_OPTIONS -Muri=org.kde.kirigami)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
################# set KDE specific information #################
find_package(ECM 5.47.0 NO_MODULE)
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(GenerateExportHeader)
include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(CMakePackageConfigHelpers)
include(ECMPoQmTools)
include(ECMQMLModules)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(ECMQtDeclareLoggingCategory)
include(ECMAddQch)
include(KDECompilerSettings NO_POLICY_SCOPE)
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5Kirigami2")
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
find_package(Qt5AndroidExtras ${REQUIRED_QT_VERSION} REQUIRED)
endif()
ecm_find_qmlmodule(QtGraphicalEffects 1.0)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_subdirectory(src)
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
ecm_install_po_files_as_qm(po)
endif()
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
This diff is collapsed.
# Kirigami Gallery
Example application
## Build on Android:
Make sure to install **android-sdk**, **android-ndk** and **android-qt5-arch**, where **arch** should be the same architecture that you aim to deploy.
```sh
mkdir build
cd build
cmake .. \
-DQTANDROID_EXPORTED_TARGET=kirigami2gallery \
-DANDROID_APK_DIR=./src/ \
-DECM_DIR=/path/to/share/ECM/cmake \
-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \
-DECM_ADDITIONAL_FIND_ROOT_PATH=/path/to/Qt5.X.0/5.X/{arch} \
-DCMAKE_PREFIX_PATH=/path/to/Qt5.X.0/5.X/{arch}/path/to/Qt5Core \
-DANDROID_NDK=/path/to/Android/Sdk/ndk-bundle \
-DANDROID_SDK_ROOT=/path/to/Android/Sdk/ \
-DANDROID_SDK_BUILD_TOOLS_REVISION=26.0.2 \
-DCMAKE_INSTALL_PREFIX=/path/to/dummy/install/prefix
```
You need a `-DCMAKE_INSTALL_PREFIX` to somewhere in your home, but using an absolute path.
If you have a local checkout of the breeze-icons repo, you can avoid the cloning of the build dir
by passing also `-DBREEZEICONS_DIR=/path/to/existing/sources/of/breeze-icons`
```
make create-apk-kirigami2gallery
```
`./kirigami2gallery_build_apk/build/outputs/apk/kirigami2gallery_build_apk-debug.apk` will be generated
To directly install on a phone:
```
adb install -r ./kirigami2gallery_build_apk/build/outputs/apk/kirigami2gallery_build_apk-debug.apk
```
To perform this, your device need to be configureted with `USB debugging` and `install via USB` in `Developer options`.
> Some ambient variables must be set before the process: `ANDROID_NDK`, `ANDROID_SDK_ROOT`, `Qt5_android` and `JAVA_HOME`
```
export ANDROID_NDK=/path/to/android-ndk
export ANDROID_SDK_ROOT=/path/to/android-sdk
export Qt5_android=/path/to/android-qt5/5.X.0/{arch}
export PATH=$ANDROID_SDK_ROOT/platform-tools/:$PATH
# adapt the following path to your ant installation
export ANT=/usr/bin/ant
export JAVA_HOME=/path/to/lib/jvm/java-8-openjdk/
```
set(kirigami2gallery_SRCS
main.cpp
)
qt5_add_resources(RESOURCES resources.qrc)
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
find_package(KF5Kirigami2 ${KF5_DEP_VERSION})
set(kirigami2gallery_EXTRA_LIBS Qt5::AndroidExtras
#FIXME: we shouldn't have to link to it but otherwise the lib won't be packaged on Android
Qt5::QuickControls2 KF5::Kirigami2)
endif()
find_program(kpackagetool_cmd kpackagetool5)
if (kpackagetool_cmd)
set(component org.kde.kirigami2.gallery)
set(APPDATAFILE "${CMAKE_CURRENT_BINARY_DIR}/${component}.appdata.xml")
message(STATUS "${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/../gallerydata --appstream-metainfo-output ${APPDATAFILE}")
execute_process(
COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/../gallerydata --appstream-metainfo-output ${APPDATAFILE}
ERROR_VARIABLE appstreamerror
RESULT_VARIABLE result)
if (NOT result EQUAL 0)
message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}")
else()
if(appstreamerror)
message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}")
endif()
# OPTIONAL because desktop files can be NoDisplay so they render no XML.
install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR} OPTIONAL)
endif()
else()
message(WARNING "KPackage components should be specified in reverse domain notation. Appstream information won't be generated for ${component}.")
endif()
add_executable(kirigami2gallery ${kirigami2gallery_SRCS} ${RESOURCES})
target_link_libraries(kirigami2gallery Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg ${kirigami2gallery_EXTRA_LIBS})
install(TARGETS kirigami2gallery ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
if (CMAKE_SYSTEM_NAME STREQUAL "Android")
include(${CMAKE_SOURCE_DIR}/KF5Kirigami2Macros.cmake)
kirigami_package_breeze_icons(ICONS applications-graphics view-list-icons folder-sync view-list-details configure document-edit dialog-information dialog-positive dialog-warning dialog-error dialog-cancel document-decrypt system-run mail-reply-sender bookmarks folder media-record-symbolic add-placemark address-book-new-symbolic view-right-new view-right-close)
endif()
<?xml version='1.0' encoding='utf-8'?>
<manifest package="org.kde.kirigamigallery" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="2.3" android:versionCode="7" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Kirigami Gallery" android:icon="@drawable/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
android:name="org.qtproject.qt5.android.bindings.QtActivity"
android:label="Kirigami Gallery"
android:theme="@style/AppTheme"
android:screenOrientation="unspecified"
android:windowSoftInputMode="adjustResize"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<meta-data android:name="android.app.lib_name" android:value="kirigami2gallery"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/>
<meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/>
<meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/>
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/splash"/>
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
</activity>
</application>
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle" >
<solid android:color="#FF2196F3"/>
</shape>
</item>
<item>
<bitmap android:src="@drawable/kirigami_splash"
android:gravity="center"/>
</item>
</layer-list>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<item name="android:windowBackground">@drawable/kirigami_splash</item>
</style>
</resources>
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
import "gallery"
Kirigami.ApplicationWindow {
id: root
header: Kirigami.ToolBarApplicationHeader {}
globalDrawer: Kirigami.GlobalDrawer {
title: "Widget gallery"
titleIcon: "applications-graphics"
bannerImageSource: "banner.jpg"
actions: [
Kirigami.Action {
text: "Submenu 1"
iconName: "view-list-icons"
Kirigami.Action {
text: "Action 1"
onTriggered: showPassiveNotification(text + " clicked")
}
Kirigami.Action {
text: "Action 2"
onTriggered: showPassiveNotification(text + " clicked")
}
Kirigami.Action {
text: "Action 3"
onTriggered: showPassiveNotification(text + " clicked")
}
},
Kirigami.Action {
text: "Submenu 2"
iconName: "folder-sync"
Kirigami.Action {
text: "Action 4"
onTriggered: showPassiveNotification(text + " clicked")
}
Kirigami.Action {
text: "Action 5"
onTriggered: showPassiveNotification(text + " clicked")
}
},
Kirigami.Action {
text: "Checkable"
iconName: "go-next"
checkable: true
checked: false
onTriggered: {
showPassiveNotification("Action checked: " + checked)
}
},
Kirigami.Action {
text: "Open A Page"
iconName: "view-list-details"
checkable: true
//Need to do this, otherwise it breaks the bindings
property bool current: pageStack.currentItem ? pageStack.currentItem.objectName == "settingsPage" : false
onCurrentChanged: {
checked = current;
}
onTriggered: {
pageStack.push(settingsComponent);
}
},
Kirigami.Action {
text: "Open A Layer"
icon {
name: "configure"
color: Kirigami.Theme.activeTextColor
}
onTriggered: {
pageStack.layers.push(Qt.resolvedUrl("gallery/LayersGallery.qml"));
}
}
]
Controls.CheckBox {
checked: true
text: "Option 1"
}
Controls.CheckBox {
text: "Option 2"
}
Controls.CheckBox {
text: "Option 3"
}
Controls.Slider {
Layout.fillWidth: true
value: 0.5
}
}
pageStack.initialPage: mainPageComponent
Component {
id: settingsComponent
Kirigami.Page {
title: "Settings"
objectName: "settingsPage"
Rectangle {
anchors.fill: parent
Controls.Button {
anchors.centerIn: parent
text: "Remove Page"
onClicked: applicationWindow().pageStack.pop();
}
}
}
}
//Main app content
Component {
id: mainPageComponent
MainPage {}
}
}
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Controls 2.0 as Controls
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
import "gallery"
Kirigami.ApplicationWindow {
id: root
header: Kirigami.ApplicationHeader {}
globalDrawer: Kirigami.GlobalDrawer {
title: "Widget gallery"
titleIcon: "applications-graphics"
bannerImageSource: "banner.jpg"
actions: [
Kirigami.Action {
text: "Submenu 1"
iconName: "view-list-icons"
Kirigami.Action {
text: "Action 1"
onTriggered: showPassiveNotification(text + " clicked")
}
Kirigami.Action {
text: "Action 2"
onTriggered: showPassiveNotification(text + " clicked")
}
Kirigami.Action {
text: "Action 3"
onTriggered: showPassiveNotification(text + " clicked")
}
},
Kirigami.Action {
text: "Submenu 2"
iconName: "folder-sync"
Kirigami.Action {
text: "Action 4"
onTriggered: showPassiveNotification(text + " clicked")
}
Kirigami.Action {
text: "Action 5"
onTriggered: showPassiveNotification(text + " clicked")
}
},
Kirigami.Action {
text: "Checkable"
iconName: "go-next"
checkable: true
checked: false
onTriggered: {
showPassiveNotification("Action checked: " + checked)
}
},
Kirigami.Action {
text: "Open A Page"
iconName: "view-list-details"
checkable: true
//Need to do this, otherwise it breaks the bindings
property bool current: pageStack.currentItem ? pageStack.currentItem.objectName == "settingsPage" : false
onCurrentChanged: {
checked = current;
}
onTriggered: {
pageStack.push(settingsComponent);
}
},
Kirigami.Action {
text: "Open A Layer"
iconName: "configure"
onTriggered: {
pageStack.layers.push(Qt.resolvedUrl("gallery/LayersGallery.qml"));
}
}
]
Controls.CheckBox {
checked: true
text: "Option 1"
}
Controls.CheckBox {
text: "Option 2"
}
Controls.CheckBox {
text: "Option 3"
}
Controls.Slider {
Layout.fillWidth: true
value: 0.5
}
}
contextDrawer: Kirigami.ContextDrawer {
id: contextDrawer
}
pageStack.initialPage: mainPageComponent
Component {
id: settingsComponent
Kirigami.Page {
title: "Settings"
objectName: "settingsPage"
Rectangle {
anchors.fill: parent
Controls.Button {
anchors.centerIn: parent
text: "Remove Page"
onClicked: applicationWindow().pageStack.pop();
}
}
}
}
//Main app content
Component {
id: mainPageComponent
MainPage {}
}
}
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Controls 2.0 as QQC2
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
Kirigami.ScrollablePage {
id: pageRoot
implicitWidth: Kirigami.Units.gridUnit * 20
background: Rectangle {
color: Kirigami.Theme.backgroundColor
}
title: "Gallery"
//flickable: mainListView
actions {
contextualActions: [
Kirigami.Action {
text:"Action 1"
iconName: "document-decrypt"
onTriggered: showPassiveNotification("Action 1 clicked")
},
Kirigami.Action {
id: shareAction
visible: checkableAction.checked
text:"Action 2"
iconName: "document-share"
onTriggered: showPassiveNotification("Action 2 clicked")
},
Kirigami.Action {
id: checkableAction
text:"Checkable"
checkable: true
iconName: "dashboard-show"
onCheckedChanged: showPassiveNotification("Checked: " + checked)
}
]
}
ListView {
id: mainListView
currentIndex: -1
//currentIndex has focus, openPageIndex is the one actually open now
property int openPageIndex: -1
activeFocusOnTab: true
focus: true
model: ListModel {
ListElement {
text: "Button"
component: "Button"
}