Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Razor-qt/razor-qt
Browse files Browse the repository at this point in the history
  • Loading branch information
Kermit committed Sep 25, 2011
2 parents 0053e90 + 0496b9a commit 5ec6c1c
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ razorqt-desktop/razor-desktop
razorqt-panel/panel/razor-panel
razorqt-session/razor-session
*~
CMakeLists.txt.user
/build
CMakeLists.txt.user*
/build
16 changes: 14 additions & 2 deletions librazorqt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ set(razorqt_HDRS
librazor-upower/battery.h
librazor-upower/ucpufreq.h
librazor-upower/upower.h
razorqt/libtranslate.h
)

set(razorqt_SRCS
Expand Down Expand Up @@ -76,8 +77,18 @@ set(razorqt_MOCS
librazor-upower/upower.h
)

# Translations **********************************
file(GLOB TS_FILES
razorqt/translations/*.ts
)
#************************************************


QT4_WRAP_CPP(MOCS ${razorqt_MOCS})
QT4_ADD_TRANSLATION(QM_FILES ${TS_FILES})

set(APP_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/librazorqt)
add_definitions(-DTRANSLATIONS_DIR=\"${APP_SHARE_DIR}\")

set ( razorqt_UIS
razorqt/aboutdlg.ui
Expand All @@ -104,6 +115,7 @@ set_target_properties(razorqt PROPERTIES

install(TARGETS razorqt DESTINATION lib${LIB_SUFFIX})
install(FILES ${razorqt_HDRS} DESTINATION include/razorqt)
install(FILES ${QM_FILES} DESTINATION ${APP_SHARE_DIR})

# our Qxt library
set ( razorqxt_HDRS
Expand All @@ -119,9 +131,9 @@ set ( razorqxt_SRC

QT4_WRAP_CPP(qxt_MOCS ${razorqxt_HDRS})

add_library ( razorqxt SHARED ${razorqxt_SRC} ${qxt_MOCS} )
add_library( razorqxt SHARED ${razorqxt_SRC} ${qxt_MOCS} ${QM_FILES})

target_link_libraries ( razorqxt ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}
target_link_libraries( razorqxt ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}
${X11_X11_LIB} )

set_target_properties(razorqxt PROPERTIES
Expand Down
14 changes: 13 additions & 1 deletion librazorqt/qtxdg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,18 @@ set(QTXDG_MOCS

set(QT_USE_QTXML True)

# Translations **********************************
file(GLOB TS_FILES
translations/*.ts
)
#************************************************


#**********************************************************
cmake_minimum_required( VERSION 2.6 )

QT4_WRAP_CPP(QTXDG_CXX ${QTXDG_MOCS})
qt4_add_translation(QM_FILES ${TS_FILES})

if (NOT CMAKE_BUILD_TYPE)
set ( CMAKE_BUILD_TYPE Release )
Expand Down Expand Up @@ -110,7 +118,10 @@ IF (NOT DEFINED LIB_SUFFIX)
ENDIF (NOT DEFINED LIB_SUFFIX)


add_library(qtxdg SHARED ${QTXDG_PUBLIC_HDRS} ${QTXDG_PRIVATE_HDRS} ${QTXDG_SRCS} ${QTXDG_CXX})
set(APP_SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/qtxdg)
add_definitions(-DTRANSLATIONS_DIR=\"${APP_SHARE_DIR}\")

add_library(qtxdg SHARED ${QTXDG_PUBLIC_HDRS} ${QTXDG_PRIVATE_HDRS} ${QTXDG_SRCS} ${QTXDG_CXX} ${QM_FILES})
target_link_libraries(qtxdg ${QT_LIBRARIES} ${X11_X11_LIB} ${LIBMAGIC_LIBRARY})

set_target_properties(qtxdg PROPERTIES
Expand All @@ -120,6 +131,7 @@ set_target_properties(qtxdg PROPERTIES

install(TARGETS qtxdg DESTINATION lib${LIB_SUFFIX})
install(FILES ${QTXDG_PUBLIC_HDRS} DESTINATION include/qtxdg)
install(FILES ${QM_FILES} DESTINATION ${APP_SHARE_DIR})

#find_package(Doxygen)
#if(DOXYGEN_FOUND)
Expand Down
24 changes: 24 additions & 0 deletions librazorqt/qtxdg/translations/qtxdg_ru_RU.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU">
<context>
<name>XdgMenuReader</name>
<message>
<location filename="../xdgmenureader.cpp" line="73"/>
<source>Menu file not defined.</source>
<translation>Не задан файл меню.</translation>
</message>
<message>
<location filename="../xdgmenureader.cpp" line="90"/>
<source>%1 not loading: %2</source>
<translation>%1 не загружен: %2</translation>
</message>
<message>
<location filename="../xdgmenureader.cpp" line="101"/>
<source>Parse error at line %1, column %2:
%3</source>
<translation>Ошибка разбора, сторка %1, столбец %2:
%3</translation>
</message>
</context>
</TS>
14 changes: 14 additions & 0 deletions librazorqt/qtxdg/translations/translate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

PROJECT=qtxdg
NO_OBSOLETE="-noobsolete"

if [ "$1" = "" ]; then
TS_FILE=${PROJECT}_`echo $LANG | awk -F"." '{print($1)}'`.ts
else
TS_FILE=$1
fi


lupdate $NO_OBSOLETE -recursive .. -ts $TS_FILE && linguist $TS_FILE

21 changes: 20 additions & 1 deletion librazorqt/qtxdg/xdgmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "xdgdirs.h"
#include "xdgmenulayoutprocessor.h"

#include <QDebug>
#include <QtCore/QDebug>
#include <QtXml/QDomElement>
#include <QtXml/QDomNamedNodeMap>
#include <QtCore/QFile>
Expand All @@ -45,6 +45,24 @@
#include <QtCore/QHash>
#include <QtCore/QLocale>
#include <QtCore/QFileSystemWatcher>
#include <QtCore/QTranslator>
#include <QtCore/QCoreApplication>


void installTranslation(const QString &name)
{
static bool alreadyLoaded = false;

if (alreadyLoaded)
return;

QString locale = QLocale::system().name();
QTranslator *translator = new QTranslator();
translator->load(QString("%1/%2_%3.qm").arg(TRANSLATIONS_DIR, name, locale));

QCoreApplication::installTranslator(translator);
alreadyLoaded = true;
}


/************************************************
Expand All @@ -54,6 +72,7 @@ XdgMenu::XdgMenu(QObject *parent) :
QObject(parent),
d_ptr(new XdgMenuPrivate(this))
{
installTranslation("qtxdg");
}


Expand Down
1 change: 0 additions & 1 deletion librazorqt/qtxdg/xdgmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <QObject>
#include <QtCore/QString>
#include <QtCore/QStringList>
#include <QHash>
#include <QtXml/QDomDocument>


Expand Down
2 changes: 2 additions & 0 deletions librazorqt/razorqt/addplugindialog/addplugindialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QAbstractTextDocumentLayout>

#include <QLineEdit>
#include "libtranslate.h"

#define SEARCH_ROLE Qt::UserRole
#define INDEX_ROLE SEARCH_ROLE+1
Expand Down Expand Up @@ -125,6 +126,7 @@ AddPluginDialog::AddPluginDialog(RazorPluginInfoList* plugins, QWidget *parent):
mTimerId(0)

{
libTranslate("librazorqt");
ui->setupUi(this);
QListWidget* pluginList = ui->pluginList;

Expand Down
24 changes: 24 additions & 0 deletions librazorqt/razorqt/libtranslate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef LIBTRANSLATE_H
#define LIBTRANSLATE_H

#include <QtCore/QTranslator>
#include <QtCore/QCoreApplication>
#include <QtCore/QLocale>

inline void libTranslate(const QString &name)
{
static bool alreadyLoaded = false;

if (alreadyLoaded)
return;

QString locale = QLocale::system().name();
QTranslator *translator = new QTranslator();
translator->load(QString("%1/%2_%3.qm").arg(TRANSLATIONS_DIR, name, locale));

QCoreApplication::installTranslator(translator);
alreadyLoaded = true;
}


#endif // LIBTRANSLATE_H
2 changes: 2 additions & 0 deletions librazorqt/razorqt/powermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QMessageBox>
#include <QApplication>
#include <QDesktopWidget>
#include "libtranslate.h"

class MessageBox: public QMessageBox
{
Expand Down Expand Up @@ -68,6 +69,7 @@ PowerManager::PowerManager(QObject * parent)
: QObject(parent),
m_parentWidget(0)
{
libTranslate("librazorqt");
m_upower = new UPower();
connect(m_upower, SIGNAL(suspendFail()), this, SLOT(suspendFailed()));
connect(m_upower, SIGNAL(hibernateFail()), this, SLOT(hibernateFailed()));
Expand Down
2 changes: 2 additions & 0 deletions librazorqt/razorqt/razoraboutdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define RAZORABOUTDLG_CPP
#include "razoraboutdlg.h"
#include "ui_aboutdlg.h"
#include "libtranslate.h"

/**
* @brief prepares the data to show and fills the form, then shows.
Expand All @@ -16,6 +17,7 @@ class RazorAboutDLGPrivate: public Ui_about, public QDialog
//
RazorAboutDLGPrivate::RazorAboutDLGPrivate()
{
libTranslate("librazorqt");
setupUi(this);
QString content("<html><body>"
"<h1>Razor Desktop Toolbox<img src=\"images://razor_logo.png\" align=\"right\" /></h1>"
Expand Down
2 changes: 2 additions & 0 deletions librazorqt/razorqt/razorshortcutbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <QtGui/QKeyEvent>
#include <QtCore/QDebug>
#include "libtranslate.h"

/************************************************
Expand All @@ -36,6 +37,7 @@ RazorShortcutButton::RazorShortcutButton(QWidget *parent) :
QToolButton(parent),
d_ptr(new RazorShortcutButtonPrivate(this))
{
libTranslate("librazorqt");
setFocusPolicy(Qt::StrongFocus);
setPopupMode(QToolButton::MenuButtonPopup);
setCheckable(true);
Expand Down
7 changes: 4 additions & 3 deletions librazorqt/razorqt/screensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@

#include <qtxdg/xdgicon.h>
#include "screensaver.h"

#include "libtranslate.h"

ScreenSaver::ScreenSaver(QObject * parent)
: QObject(parent)
{
libTranslate("librazorqt");
m_xdgProcess = new QProcess(this);
connect(m_xdgProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(xdgProcess_finished(int,QProcess::ExitStatus)));
Expand Down Expand Up @@ -64,7 +65,7 @@ void ScreenSaver::xdgProcess_finished(int err, QProcess::ExitStatus status)
QMessageBox::warning(p,
tr("Screen Saver Activation Error"),
tr("An error occurred starting screensaver. "
"xdg-screensaver cannot be started due its crash")
"xdg-screensaver cannot be started due its crash.")
);
}
else if (err == -2)
Expand All @@ -80,7 +81,7 @@ void ScreenSaver::xdgProcess_finished(int err, QProcess::ExitStatus status)
QMessageBox::warning(p,
tr("Screen Saver Activation Error"),
tr("An error occurred starting screensaver. "
"xdg-screensaver cannot be started")
"xdg-screensaver cannot be started.")
);
}
else if (err == 0)
Expand Down
Loading

0 comments on commit 5ec6c1c

Please sign in to comment.