Skip to content
This repository was archived by the owner on Aug 17, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 61 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
#
# Qt
#
option(PROJECT_TRANSLATIONS_UPDATE "Update source translations [default: OFF]" OFF)
set(PROJECT_QT_VERSION 5 CACHE STRING "Qt version to use: 5 (default) or 6")
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
Expand Down Expand Up @@ -49,7 +50,6 @@ set(PROJECT_SOURCES
src/window.cpp
src/main.cpp
)
set(PROJECT_RESOURCES resources/app.qrc)

#
# Resources
Expand All @@ -61,14 +61,58 @@ ecm_add_app_icon(PROJECT_SOURCES ICONS
resources/icons/32-apps-${PROJECT_ID}.png
resources/icons/sc-apps-${PROJECT_ID}.svg
)
source_group("Resource Files" FILES ${PROJECT_RESOURCES})
set(PROJECT_RESOURCES
resources/app.qrc
resources/freedesktop/${PROJECT_ID}.desktop
)
set(PROJECT_TRANSLATION_TEMPLATE resources/translations/${PROJECT_ID}.ts)
file(GLOB PROJECT_TRANSLATION_SOURCES "resources/translations/${PROJECT_ID}_*.ts")

source_group("Resource Files" FILES
${PROJECT_RESOURCES}
${PROJECT_TRANSLATION_TEMPLATE}
${PROJECT_TRANSLATION_SOURCES}
)

#
# Translations
#
if(${QT_VERSION_MAJOR} VERSION_LESS 6.2)
if(PROJECT_TRANSLATIONS_UPDATE)
# the first call creates/updates the <appname>.ts template file, it should not be compiled,
# the other the actual <appname>_<country-code>.ts translation files to be installed later.
qt_create_translation(QM_DUMMY
${PROJECT_SOURCES}
${PROJECT_TRANSLATION_TEMPLATE}
)
qt_create_translation(PROJECT_QM_FILES
${PROJECT_SOURCES}
${PROJECT_TRANSLATION_SOURCES}
)
add_custom_target(TemplateUpdate ALL DEPENDS ${QM_DUMMY})
endif()
qt_add_translation(PROJECT_QM_FILES ${PROJECT_TRANSLATION_SOURCES})
else()
# FIXME: updating the .ts files seems not to work in Qt6, even by using the deprecated
# qt_create_translation() used with Qt5. It's not clear where qt_add_lupdate() call
# should be placed, qt_add_lrelease() wants to be called after add_executable() for sure.
if(PROJECT_TRANSLATIONS_UPDATE)
qt_add_lupdate(${PROJECT_NAME}
TS_FILES ${PROJECT_TRANSLATION_TEMPLATE} ${PROJECT_TRANSLATION_SOURCES}
SOURCES ${PROJECT_SOURCES}
)
endif()
endif()

#
# Build
#
add_executable(${PROJECT_NAME}
${PROJECT_SOURCES}
${PROJECT_QM_FILES}
${PROJECT_RESOURCES}
${PROJECT_SOURCES}
${PROJECT_TRANSLATION_SOURCES}
${PROJECT_TRANSLATION_TEMPLATE}
)
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
Expand All @@ -91,6 +135,13 @@ set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "${PROJECT_ID}")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Woverloaded-virtual)
target_compile_definitions(${PROJECT_NAME} PRIVATE PROJECT_DATA_DIR="${PROJECT_DATA_DIR}")

if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL 6.2)
qt_add_lrelease(${PROJECT_NAME}
TS_FILES ${PROJECT_TRANSLATION_SOURCES}
QM_FILES_OUTPUT_VARIABLE PROJECT_QM_FILES
)
endif()

#
# Install
#
Expand All @@ -102,6 +153,9 @@ if (UNIX AND NOT APPLE)
install(FILES "resources/freedesktop/${PROJECT_ID}.desktop"
DESTINATION "${CMAKE_INSTALL_DATADIR}/applications"
)
install(FILES "${PROJECT_QM_FILES}"
DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_ID}/translations"
)
ecm_install_icons(ICONS "sc-apps-${PROJECT_ID}.svg"
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons"
)
Expand All @@ -111,7 +165,8 @@ endif()
# Project information
#
message(STATUS "
Qt version: ${QT_VERSION}
Build type: ${CMAKE_BUILD_TYPE}
Install prefix: ${CMAKE_INSTALL_PREFIX}
Qt version: ${QT_VERSION}
Build type: ${CMAKE_BUILD_TYPE}
Install prefix: ${CMAKE_INSTALL_PREFIX}
Update translations before build: ${PROJECT_TRANSLATIONS_UPDATE}
")
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ Install (must be run as root if installing to /usr or /usr/local):

make install

## Translations

To contribute language translations, use Qt Linguist and/or manually:

- Copy `resource/translations/colorpick.ts` language template to
`resource/translations/colorpick_<country-code>.ts`, e.g.: `colorpick_de.ts`
- Set the language in the file:
from `<TS version="2.1">` to `<TS version="2.1" language="de">`
- Translate it and the `resources/freedesktop/colorpick.desktop` file by adding
e.g.: `GenericName[de]`, `Comment[de]` and optionally `Name[de]`
(see the existing translations as reference)
- Create a Pull Request with your changes.

## Author

Aurélien Gâteau
Expand Down
8 changes: 6 additions & 2 deletions resources/freedesktop/colorpick.desktop
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[Desktop Entry]
Type=Application
Version=1.0
Name=Colorpick
GenericName=A color picker
Icon=colorpick
TryExec=colorpick
Exec=colorpick
Categories=Qt;KDE;Graphics;Utility;

Name=Colorpick
GenericName=Color picker
Comment=Color picker with contrast control
GenericName[it]=Selettore di colori
Comment[it]=Selettore di colori con controllo del contrasto
101 changes: 101 additions & 0 deletions resources/translations/colorpick.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>ColorEditor</name>
<message>
<location filename="../../src/coloreditor.cpp" line="181"/>
<source>Inkscape</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="182"/>
<source>Hexa with #</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="183"/>
<source>Quoted hexa with #</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="184"/>
<source>Float values</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="185"/>
<source>Int values</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="186"/>
<source>CSS RGB Value</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ContrastPreview</name>
<message>
<location filename="../../src/contrastpreview.cpp" line="17"/>
<source>Contrast Example Text</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="55"/>
<source>Bad</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="57"/>
<source>Acceptable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="59"/>
<source>Good</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="61"/>
<source>Contrast Ratio</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>HsvColorSpace</name>
<message>
<location filename="../../src/hsvcolorspace.cpp" line="19"/>
<source>H</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/hsvcolorspace.cpp" line="20"/>
<source>S</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/hsvcolorspace.cpp" line="21"/>
<source>V</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>RgbColorSpace</name>
<message>
<location filename="../../src/rgbcolorspace.cpp" line="19"/>
<source>R</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/rgbcolorspace.cpp" line="20"/>
<source>G</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../src/rgbcolorspace.cpp" line="21"/>
<source>B</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
101 changes: 101 additions & 0 deletions resources/translations/colorpick_it.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="it">
<context>
<name>ColorEditor</name>
<message>
<location filename="../../src/coloreditor.cpp" line="181"/>
<source>Inkscape</source>
<translation></translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="182"/>
<source>Hexa with #</source>
<translation>Esadecimale con #</translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="183"/>
<source>Quoted hexa with #</source>
<translation>Esadecimale virgolettato con #</translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="184"/>
<source>Float values</source>
<translation>Valori decimali</translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="185"/>
<source>Int values</source>
<translation>Valori interi</translation>
</message>
<message>
<location filename="../../src/coloreditor.cpp" line="186"/>
<source>CSS RGB Value</source>
<translation>Valore CSS RGB</translation>
</message>
</context>
<context>
<name>ContrastPreview</name>
<message>
<location filename="../../src/contrastpreview.cpp" line="17"/>
<source>Contrast Example Text</source>
<translation>Esempio Contrasto</translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="55"/>
<source>Bad</source>
<translation>Pessimo</translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="57"/>
<source>Acceptable</source>
<translation>Accettabile</translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="59"/>
<source>Good</source>
<translation>Ottimo</translation>
</message>
<message>
<location filename="../../src/contrastpreview.cpp" line="61"/>
<source>Contrast Ratio</source>
<translation>Rapporto Contrasto</translation>
</message>
</context>
<context>
<name>HsvColorSpace</name>
<message>
<location filename="../../src/hsvcolorspace.cpp" line="19"/>
<source>H</source>
<translation></translation>
</message>
<message>
<location filename="../../src/hsvcolorspace.cpp" line="20"/>
<source>S</source>
<translation></translation>
</message>
<message>
<location filename="../../src/hsvcolorspace.cpp" line="21"/>
<source>V</source>
<translation></translation>
</message>
</context>
<context>
<name>RgbColorSpace</name>
<message>
<location filename="../../src/rgbcolorspace.cpp" line="19"/>
<source>R</source>
<translation></translation>
</message>
<message>
<location filename="../../src/rgbcolorspace.cpp" line="20"/>
<source>G</source>
<translation></translation>
</message>
<message>
<location filename="../../src/rgbcolorspace.cpp" line="21"/>
<source>B</source>
<translation></translation>
</message>
</context>
</TS>
2 changes: 1 addition & 1 deletion src/coloreditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void ColorEditor::fillCopyMenu()
};

auto addColorAction = [this](const QString &text, const QString &value) {
QString fullText = ColorEditor::tr("%1: %2").arg(text, value);
QString fullText = QString("%1: %2").arg(text, value);
QAction *action = mCopyMenu->addAction(fullText);
connect(action, &QAction::triggered, this, [value]() {
QApplication::clipboard()->setText(value);
Expand Down
3 changes: 2 additions & 1 deletion src/contrastpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void ContrastPreview::updateRatioLabel()
} else {
level = tr("Good");
}
QString text = tr("Contrast Ratio: %1:1 (%2)").arg(QLocale::system().toString(ratio, 'g', 2)).arg(level);
QString text = tr("Contrast Ratio");
text = text + QString(": %1:1 (%2)").arg(QLocale::system().toString(ratio, 'g', 2), level);
mRatioLabel->setText(text);
}

Expand Down
Loading