Skip to content

Commit

Permalink
Resources: translations, appstream metainfo, desktop file update
Browse files Browse the repository at this point in the history
  • Loading branch information
redtide authored and johanmalm committed Apr 11, 2024
1 parent 9e06835 commit 7f2d04f
Show file tree
Hide file tree
Showing 15 changed files with 657 additions and 13 deletions.
25 changes: 25 additions & 0 deletions BSD-3-Clause
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
License: BSD-3-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. 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.
3. Neither the name of the University 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 HOLDERS 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.

91 changes: 87 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

include(Config.cmake)

# QtCreator doesn't use the system locale and I see no way to prefix with LANG=XYZ.UTF-8 the command,
# so enabling these 2 settings we can test any language, see initLocale() in main.cpp.
set(PROJECT_TRANSLATION_TEST_ENABLED 0 CACHE STRING "Whether to enable translation testing [default: 0]")
set(PROJECT_TRANSLATION_TEST_LANGUAGE "en" CACHE STRING "Country code of language to test in IDE [default: en]")
set(PROJECT_QT_VERSION 6 CACHE STRING "Qt version to use [Default: 6]")
option(PROJECT_TRANSLATIONS_UPDATE "Update source translations [default: OFF]" OFF)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined")

find_package(QT NAMES Qt${PROJECT_QT_VERSION})
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
find_package(LibXml2 REQUIRED)
Expand All @@ -37,10 +46,56 @@ set(PROJECT_SOURCES
keyboard-layouts.c
keyboard-layouts.h
)
source_group("" FILES ${PROJECT_SOURCES})
set(PROJECT_OTHER_FILES
.github/workflows/build.yml
README.md
)
file(GLOB PROJECT_TRANSLATION_SOURCES "${PROJECT_TRANSLATIONS_DIR}/*")
source_group("" FILES
${PROJECT_SOURCES}
${PROJECT_TRANSLATION_SOURCES}
)
#===================================================================================================
# Translations
#===================================================================================================
include(GNUInstallDirs)
include(LXQtTranslate)

lxqt_translate_ts(PROJECT_QM_FILES
SOURCES ${PROJECT_SOURCES}
TEMPLATE ${PROJECT_ID}
TRANSLATION_DIR "${PROJECT_TRANSLATIONS_DIR}"
UPDATE_TRANSLATIONS ${PROJECT_TRANSLATIONS_UPDATE}
INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_ID}/translations"
)
lxqt_translate_desktop(PROJECT_DESKTOP_FILES
SOURCES "${CMAKE_BINARY_DIR}/${PROJECT_APPSTREAM_ID}.desktop.in"
TRANSLATION_DIR "${PROJECT_TRANSLATIONS_DIR}"
USE_YAML
)
#===================================================================================================
# Application
#===================================================================================================
qt_add_executable(${PROJECT_NAME} MANUAL_FINALIZATION
${PROJECT_SOURCES}
${PROJECT_DESKTOP_FILES}
${PROJECT_OTHER_FILES}
${PROJECT_QM_FILES}
${PROJECT_TRANSLATION_SOURCES}
)
set(PROJECT_ICON_SYSTEM_PATH "${CMAKE_INSTALL_FULL_DATADIR}/icons/hicolor/scalable/apps")
file(COPY_FILE "${CMAKE_SOURCE_DIR}/data/${PROJECT_APPSTREAM_ID}.svg"
"${CMAKE_BINARY_DIR}/${PROJECT_APPSTREAM_ID}.svg"
)
target_compile_definitions(${PROJECT_NAME} PRIVATE
APPLICATION_NAME="${PROJECT_NAME}"
APPLICATION_VERSION="${PROJECT_VERSION}"
PROJECT_ID="${PROJECT_ID}"
PROJECT_APPSTREAM_ID="${PROJECT_APPSTREAM_ID}"
PROJECT_DATA_DIR="${CMAKE_INSTALL_FULL_DATADIR}/${PROJECT_NAME}"
PROJECT_ICON_SYSTEM_PATH="${PROJECT_ICON_SYSTEM_PATH}"
PROJECT_TRANSLATION_TEST_ENABLED=${PROJECT_TRANSLATION_TEST_ENABLED}
PROJECT_TRANSLATION_TEST_LANGUAGE="${PROJECT_TRANSLATION_TEST_LANGUAGE}"
)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLIB_INCLUDE_DIRS})
target_include_directories(${PROJECT_NAME} PRIVATE ${LIBXML2_INCLUDE_DIR})
Expand All @@ -51,11 +106,39 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
${LIBXML2_LIBRARIES}
)
#target_link_options(${PROJECT_NAME} BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address)

include(GNUInstallDirs)
#===================================================================================================
# Installation
#===================================================================================================
configure_file("${CMAKE_SOURCE_DIR}/data/${PROJECT_APPSTREAM_ID}.desktop.in"
"${CMAKE_BINARY_DIR}/${PROJECT_APPSTREAM_ID}.desktop.in" @ONLY
)
configure_file("${CMAKE_SOURCE_DIR}/data/${PROJECT_APPSTREAM_ID}.appdata.xml.in"
"${CMAKE_BINARY_DIR}/${PROJECT_APPSTREAM_ID}.appdata.xml" @ONLY
)
install(TARGETS ${PROJECT_NAME}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_APPSTREAM_ID}.appdata.xml"
DESTINATION "${CMAKE_INSTALL_DATADIR}/metainfo"
)
install(FILES "${PROJECT_DESKTOP_FILES}"
DESTINATION "${CMAKE_INSTALL_DATADIR}/applications"
)
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_APPSTREAM_ID}.svg"
# Don't use PROJECT_ICON_SYSTEM_PATH here which is absolute and doesn't take prefixes into account
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps"
)
qt_finalize_executable(${PROJECT_NAME})
#===================================================================================================
# Configuration report
#===================================================================================================
message(STATUS "
Project name: ${PROJECT_NAME}
Version: ${PROJECT_VERSION}
Qt version: ${QT_VERSION}
Build type: ${CMAKE_BUILD_TYPE}
Install prefix: ${CMAKE_INSTALL_PREFIX}
Update translations before build: ${PROJECT_TRANSLATIONS_UPDATE}
")
31 changes: 31 additions & 0 deletions Config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#===============================================================================
# Editable project configuration
#
# Essential, non translatable application information (except DESCRIPTION).
# Translatable strings are passed via code.
#===============================================================================
set(PROJECT_ID "labwc-tweaks")
list(APPEND PROJECT_CATEGORIES "Settings;System") # Freedesktop menu categories
list(APPEND PROJECT_KEYWORDS "labwc;wayland;compositor")
set(PROJECT_AUTHOR_NAME "Labwc Team")
set(PROJECT_COPYRIGHT_YEAR "2024") # TODO: from git
set(PROJECT_DESCRIPTION "Labwc Wayland compositor settings")
set(PROJECT_ORGANIZATION_NAME "labwc")
set(PROJECT_ORGANIZATION_URL "${PROJECT_ORGANIZATION_NAME}.github.io")
set(PROJECT_ORGANIZATION_ID "io.github.${PROJECT_ORGANIZATION_NAME}")
set(PROJECT_REPOSITORY_URL "https://github.com/${PROJECT_ORGANIZATION_NAME}/${PROJECT_ID}")
set(PROJECT_REPOSITORY_BRANCH "master")
set(PROJECT_HOMEPAGE_URL ${PROJECT_REPOSITORY_URL}) # TODO: "https://${PROJECT_ORGANIZATION_URL}/${PROJECT_ID}"
set(PROJECT_SPDX_ID "GPL-2.0-only")
set(PROJECT_TRANSLATIONS_DIR "${CMAKE_SOURCE_DIR}/data/translations")
set(PROJECT_SCREENSHOT_URL "https://github-production-user-asset-6210df.s3.amazonaws.com/1019119/294060534-84ef3747-f336-444e-9e2c-9a417ebe67e5.png")
#===============================================================================
# Appstream
#===============================================================================
set(PROJECT_APPSTREAM_SPDX_ID "CC0-1.0")
set(PROJECT_APPSTREAM_ID "labwc_tweaks")
#===============================================================================
# Adapt to CMake variables
#===============================================================================
set(${PROJECT_NAME}_DESCRIPTION "${PROJECT_DESCRIPTION}")
set(${PROJECT_NAME}_HOMEPAGE_URL "${PROJECT_HOMEPAGE_URL}")
50 changes: 50 additions & 0 deletions bin/lxqt-transupdate
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/sh

#=============================================================================
# Copyright 2018 Alf Gaida <[email protected]>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
#=============================================================================

# lxqt-transupdate
# Update LXQt translation files.

# just to be sure - for distributions that user qtchooser
# Debian and derivatives, Fedora, FreeBSD, Mageia, OpenMandriva, PCLinuxOS
export QT_SELECT=6

TEMPLATES=$(find . -name \*.ts | grep -v '_')
for i in $TEMPLATES; do
echo "\n\n==== $i ====\n"
TRANSDIR=$(dirname $i)
SOURCEDIR=$(dirname $TRANSDIR)
# template-update
echo "== Template Update =="
echo "lupdate $SOURCEDIR -ts $i -locations absolute -no-obsolete\n"
lupdate $SOURCEDIR -ts $i -locations absolute -no-obsolete
echo
echo "== Language updates =="
echo "lupdate $SOURCEDIR -ts $TRANSDIR/*_*.ts -locations absolute -no-obsolete\n"
lupdate $SOURCEDIR -ts $TRANSDIR/*_*.ts -locations absolute -no-obsolete
done
Loading

0 comments on commit 7f2d04f

Please sign in to comment.