Skip to content

Commit

Permalink
Adapts to translations infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-pereira committed Oct 10, 2014
1 parent 1acfa6f commit bb680cc
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 14 deletions.
5 changes: 4 additions & 1 deletion liblxqt-config-cursor/CMakeLists.txt
Expand Up @@ -22,6 +22,8 @@ include_directories (
${CMAKE_CURRENT_SOURCE_DIR}/xcr
)

add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")

set ( lxqt-config-cursor_HDRS
# cfgfile.h
thememodel.h
Expand Down Expand Up @@ -52,6 +54,7 @@ set ( lxqt-config-cursor_SRCS
itemdelegate.cpp
thememodel.cpp
warninglabel.cpp
translationloader.cpp
)

set(lxqt-config-cursor_UIS
Expand All @@ -76,7 +79,7 @@ lxqt_translate_ts(QM_FILES
${lxqt-config-cursor_SRCS}
${lxqt-config-cursor_UIS}
INSTALLATION_DIR
${CMAKE_INSTALL_PREFIX}/share/lxqt/lxqt-config
${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
)

#************************************************
Expand Down
38 changes: 38 additions & 0 deletions liblxqt-config-cursor/translationloader.cpp
@@ -0,0 +1,38 @@
/*
* translationloader.cpp - an Qt5 automatic translations loader for libs
* Copyright (C) 2014 Luís Pereira <luis.artur.pereira@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#ifndef TRANSLATION_LOADER_H
#define TRANSLATION_LOADER_H

#include <QtGlobal>

#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))
#include <LXQt/Translator>
#include <QCoreApplication>

static void loadTranslation()
{
LxQt::Translator::translateLibrary(QLatin1String(PROJECT_NAME));
}

Q_COREAPP_STARTUP_FUNCTION(loadTranslation)
#endif

#endif // TRANSLATION_LOADER_H
4 changes: 3 additions & 1 deletion lxqt-config-appearance/CMakeLists.txt
Expand Up @@ -8,6 +8,8 @@ else()
set(QTX_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY})
endif()

add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")

include_directories (
${CMAKE_CURRENT_BINARY_DIR}
${QTX_INCLUDE_DIRS}
Expand Down Expand Up @@ -64,7 +66,7 @@ lxqt_translate_ts(QM_FILES
${CPP_FILES}
${UI_FILES}
INSTALLATION_DIR
${CMAKE_INSTALL_PREFIX}/share/lxqt/lxqt-config
${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
)

lxqt_translate_desktop(DESKTOP_FILES
Expand Down
7 changes: 5 additions & 2 deletions lxqt-config-appearance/main.cpp
Expand Up @@ -26,12 +26,12 @@
* END_COMMON_COPYRIGHT_HEADER */

#include <LXQt/Application>
#include <LXQt/Translator>

#include <XdgIcon>
#include <LXQt/Settings>
#include <LXQt/ConfigDialog>
#include "iconthemeconfig.h"
#include "lxqttranslate.h"
#include "lxqtthemeconfig.h"
#include "styleconfig.h"
#include "fontsconfig.h"
Expand All @@ -41,7 +41,10 @@
int main (int argc, char **argv)
{
LxQt::Application app(argc, argv);
TRANSLATE_APP;
LxQt::Translator::translateApplication(QLatin1String(PROJECT_NAME));
#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
LxQt::Translator::translateLibrary(QLatin1String("lxqt-config-cursor"));
#endif

LxQt::Settings* settings = new LxQt::Settings("lxqt");
LxQt::ConfigDialog* dialog = new LxQt::ConfigDialog(QObject::tr("LXQt Appearance Configuration"), settings);
Expand Down
4 changes: 3 additions & 1 deletion lxqt-config-file-associations/CMakeLists.txt
Expand Up @@ -12,6 +12,8 @@ include_directories (
${CMAKE_CURRENT_BINARY_DIR}
)

add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")

set(H_FILES
mimetypedata.h
mimetypeviewer.h
Expand Down Expand Up @@ -53,7 +55,7 @@ lxqt_translate_ts(QM_FILES
${CPP_FILES}
${UI_FILES}
INSTALLATION_DIR
${CMAKE_INSTALL_PREFIX}/share/lxqt/lxqt-config
${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
)

lxqt_translate_desktop(DESKTOP_FILES
Expand Down
4 changes: 3 additions & 1 deletion lxqt-config-file-associations/main.cpp
Expand Up @@ -24,6 +24,8 @@
* END_COMMON_COPYRIGHT_HEADER */

#include <LXQt/Application>
#include <LXQt/Translator>

#include <QDebug>
#include <QString>
#include <QStringList>
Expand All @@ -41,7 +43,7 @@
int main (int argc, char **argv)
{
LxQt::Application app(argc, argv);
TRANSLATE_APP;
LxQt::Translator::translateApplication(QLatin1String(PROJECT_NAME));

MimetypeViewer mimetypeViewer;
mimetypeViewer.show();
Expand Down
4 changes: 3 additions & 1 deletion lxqt-config-input/CMakeLists.txt
Expand Up @@ -12,6 +12,8 @@ endif()
# set(CMAKE_CXX_FLAGS "-DQT_NO_KEYWORDS -fno-exceptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")

add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")

include_directories(
${QTX_INCLUDE_DIRS}
${X11_INCLUDE_DIR}
Expand Down Expand Up @@ -59,7 +61,7 @@ lxqt_translate_ts(QM_FILES
${lxqt-config-input_SRCS}
${lxqt-config-input_UIS}
INSTALLATION_DIR
${CMAKE_INSTALL_PREFIX}/share/lxqt/lxqt-config
${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
)

lxqt_translate_desktop(DESKTOP_FILES
Expand Down
4 changes: 2 additions & 2 deletions lxqt-config-input/lxqt-config-input.cpp
Expand Up @@ -17,7 +17,7 @@
*/

#include <LXQt/Application>
#include "lxqttranslate.h"
#include <LXQt/Translator>
#include <LXQt/ConfigDialog>
#include <LXQt/Settings>
#include "mouseconfig.h"
Expand All @@ -27,7 +27,7 @@

int main(int argc, char** argv) {
LxQt::Application app(argc, argv);
TRANSLATE_APP;
LxQt::Translator::translateApplication(QLatin1String(PROJECT_NAME));

QByteArray configName = qgetenv("LXQT_SESSION_CONFIG");
if(configName.isEmpty())
Expand Down
4 changes: 3 additions & 1 deletion lxqt-config-monitor/CMakeLists.txt
Expand Up @@ -7,6 +7,8 @@ else()
set(QTX_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
endif()

add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")

include_directories (
${CMAKE_CURRENT_BINARY_DIR}
${QTX_INCLUDE_DIRS}
Expand Down Expand Up @@ -46,7 +48,7 @@ lxqt_translate_ts(QM_FILES
${CPP_FILES}
${UI_FILES}
INSTALLATION_DIR
${CMAKE_INSTALL_PREFIX}/share/lxqt/lxqt-config
${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
)

lxqt_translate_desktop(DESKTOP_FILES
Expand Down
4 changes: 2 additions & 2 deletions lxqt-config-monitor/main.cpp
Expand Up @@ -19,13 +19,13 @@

#include "main.h"
#include <LXQt/Application>
#include "lxqttranslate.h"
#include <LXQt/Translator>
#include "monitorsettingsdialog.h"
#include "xrandr.h"

int main(int argc, char** argv) {
LxQt::Application app(argc, argv);
TRANSLATE_APP;
LxQt::Translator::translateApplication(QLatin1String(PROJECT_NAME));

XRandRBackend *xrandr = new XRandRBackend();
MonitorSettingsDialog dlg(xrandr);
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -17,6 +17,7 @@ include_directories (
${QTXDG_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/qcategorizedview
)
add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")

set ( lxqt-config_HDRS
)
Expand Down Expand Up @@ -48,6 +49,8 @@ lxqt_translate_ts(QM_FILES
${lxqt-config_HDRS}
${lxqt-config_SRCS}
${lxqt-config_UIS}
INSTALLATION_DIR
${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}
)

lxqt_translate_desktop(DESKTOP_FILES
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Expand Up @@ -26,14 +26,14 @@
* END_COMMON_COPYRIGHT_HEADER */

#include <LXQt/Application>
#include "lxqttranslate.h"
#include <LXQt/Translator>
#include "mainwindow.h"


int main(int argc, char **argv)
{
LxQt::Application app(argc, argv);
TRANSLATE_APP;
LxQt::Translator::translateApplication(QLatin1String(PROJECT_NAME));

// ensure that we use lxqt-config.menu file.
qputenv("XDG_MENU_PREFIX", "lxqt-");
Expand Down

0 comments on commit bb680cc

Please sign in to comment.