update plugininfo compiler
This commit is contained in:
parent
8f28d75120
commit
503939b559
@ -282,6 +282,16 @@ QList<QJsonObject> DeviceManager::pluginsMetadata()
|
|||||||
return pluginList;
|
return pluginList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceManager::setLocale(const QLocale &locale)
|
||||||
|
{
|
||||||
|
m_locale = locale;
|
||||||
|
foreach (DevicePlugin *plugin, m_devicePlugins.values()) {
|
||||||
|
if (!plugin->setLocale(m_locale))
|
||||||
|
qCWarning(dcDeviceManager()) << "Could not load translation" << m_locale.name() << "for plugin" << plugin->pluginName();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns all the \l{DevicePlugin}{DevicePlugins} loaded in the system. */
|
/*! Returns all the \l{DevicePlugin}{DevicePlugins} loaded in the system. */
|
||||||
QList<DevicePlugin *> DeviceManager::plugins() const
|
QList<DevicePlugin *> DeviceManager::plugins() const
|
||||||
{
|
{
|
||||||
@ -988,11 +998,6 @@ void DeviceManager::loadPlugins()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pluginIface->setLocale(m_locale))
|
|
||||||
qCWarning(dcDeviceManager()) << "Could not load translation" << m_locale.name() << "for plugin" << pluginIface->pluginName();
|
|
||||||
|
|
||||||
qApp->installTranslator(pluginIface->translator());
|
|
||||||
|
|
||||||
if (!verifyPluginMetadata(loader.metaData().value("MetaData").toObject()))
|
if (!verifyPluginMetadata(loader.metaData().value("MetaData").toObject()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1016,6 +1021,11 @@ void DeviceManager::loadPlugins()
|
|||||||
qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name();
|
qCDebug(dcDeviceManager) << "* Loaded device class:" << deviceClass.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!pluginIface->setLocale(m_locale))
|
||||||
|
qCWarning(dcDeviceManager()) << "Could not load translation" << m_locale.name() << "for plugin" << pluginIface->pluginName();
|
||||||
|
|
||||||
|
qApp->installTranslator(pluginIface->translator());
|
||||||
|
|
||||||
GuhSettings settings(GuhSettings::SettingsRolePlugins);
|
GuhSettings settings(GuhSettings::SettingsRolePlugins);
|
||||||
settings.beginGroup("PluginConfig");
|
settings.beginGroup("PluginConfig");
|
||||||
ParamList params;
|
ParamList params;
|
||||||
|
|||||||
@ -109,6 +109,8 @@ public:
|
|||||||
static QStringList pluginSearchDirs();
|
static QStringList pluginSearchDirs();
|
||||||
static QList<QJsonObject> pluginsMetadata();
|
static QList<QJsonObject> pluginsMetadata();
|
||||||
|
|
||||||
|
void setLocale(const QLocale &locale);
|
||||||
|
|
||||||
QList<DevicePlugin*> plugins() const;
|
QList<DevicePlugin*> plugins() const;
|
||||||
DevicePlugin* plugin(const PluginId &id) const;
|
DevicePlugin* plugin(const PluginId &id) const;
|
||||||
DeviceError setPluginConfig(const PluginId &pluginId, const ParamList &pluginConfig);
|
DeviceError setPluginConfig(const PluginId &pluginId, const ParamList &pluginConfig);
|
||||||
|
|||||||
@ -144,6 +144,8 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
|
||||||
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
/*! DevicePlugin constructor. DevicePlugins will be instantiated by the DeviceManager, its \a parent. */
|
||||||
@ -448,7 +450,19 @@ QTranslator *DevicePlugin::translator()
|
|||||||
|
|
||||||
bool DevicePlugin::setLocale(const QLocale &locale)
|
bool DevicePlugin::setLocale(const QLocale &locale)
|
||||||
{
|
{
|
||||||
return m_translator->load(locale, "mock", "_", GuhSettings::translationsPath(), ".qm");
|
// check if there are local translations
|
||||||
|
if (m_translator->load(locale, m_metaData.value("id").toString(), "-", QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath(), ".qm")) {
|
||||||
|
qCDebug(dcDeviceManager()) << "* Load translation" << locale.name() << "for" << pluginName() << "from" << QDir(QCoreApplication::applicationDirPath() + "../../translations/").absolutePath();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise use the system translations
|
||||||
|
if (m_translator->load(locale, m_metaData.value("id").toString(), "-", GuhSettings::translationsPath(), ".qm")) {
|
||||||
|
qCDebug(dcDeviceManager()) << "* Load translation" << locale.name() << "for" << pluginName() << "from" << GuhSettings::translationsPath();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
|
/*! Override this if your plugin supports Device with DeviceClass::CreationMethodAuto.
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
TRANSLATIONS = translations/mock_en_US.ts \
|
TRANSLATIONS = translations/en_US.ts \
|
||||||
translations/mock_de_DE.ts
|
translations/de_DE.ts
|
||||||
|
|
||||||
# Note: include after the TRANSLATIONS definition
|
# Note: include after the TRANSLATIONS definition
|
||||||
include(../../plugins.pri)
|
include(../../plugins.pri)
|
||||||
|
|||||||
@ -62,7 +62,6 @@ outputFile = open(args.builddir + "/" + args.output, "w")
|
|||||||
outputFileExtern = open(args.builddir + "/" + "extern-" + args.output, "w")
|
outputFileExtern = open(args.builddir + "/" + "extern-" + args.output, "w")
|
||||||
|
|
||||||
# Read json file
|
# Read json file
|
||||||
|
|
||||||
try:
|
try:
|
||||||
pluginMap = json.loads(inputFile.read())
|
pluginMap = json.loads(inputFile.read())
|
||||||
inputFile.close()
|
inputFile.close()
|
||||||
@ -72,6 +71,7 @@ except ValueError as error:
|
|||||||
inputFile.close()
|
inputFile.close()
|
||||||
exit -1
|
exit -1
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
# Methods
|
# Methods
|
||||||
|
|
||||||
def writePluginInfo(line):
|
def writePluginInfo(line):
|
||||||
@ -213,11 +213,15 @@ def writeTranslationStrings():
|
|||||||
def createTranslationFiles():
|
def createTranslationFiles():
|
||||||
for translation in args.translations:
|
for translation in args.translations:
|
||||||
translationFile = (sourceDir + "/" + translation)
|
translationFile = (sourceDir + "/" + translation)
|
||||||
translationOutput = os.path.splitext(translationFile)[0] + '.qm'
|
path, fileName = os.path.split(translationFile)
|
||||||
print " --> Translation update %s" % translationFile
|
translationOutput = (path + "/" + pluginMap['id'] + '-' + os.path.splitext(fileName)[0] + '.qm')
|
||||||
print subprocess.check_output(['lupdate', '-recursive', sourceDir, (args.builddir + "/" + args.output), '-ts', translationFile])
|
print(" --> Translation update %s" % translationFile)
|
||||||
print " --> Translation release %s" % translationOutput
|
print(subprocess.check_output(['lupdate', '-recursive', '-no-obsolete', sourceDir, (args.builddir + "/" + args.output), '-ts', translationFile]))
|
||||||
print subprocess.check_output(['lrelease', translationFile, '-qm', translationOutput])
|
print(" --> Translation release %s" % translationOutput)
|
||||||
|
print(subprocess.check_output(['lrelease', translationFile, '-qm', translationOutput]))
|
||||||
|
print(" --> Copy translation files to build dir %s" % args.builddir + '/translations/')
|
||||||
|
subprocess.check_output(['rsync', '-a', translationOutput, args.builddir + '/translations/'])
|
||||||
|
|
||||||
|
|
||||||
##################################################################################################################
|
##################################################################################################################
|
||||||
# write plugininfo.h
|
# write plugininfo.h
|
||||||
@ -227,8 +231,7 @@ print " --> generate plugininfo.h for plugin \"%s\" = %s" % (pluginMap['name'],
|
|||||||
writePluginInfo("/* This file is generated by the guh build system. Any changes to this file will")
|
writePluginInfo("/* This file is generated by the guh build system. Any changes to this file will")
|
||||||
writePluginInfo(" * be lost.")
|
writePluginInfo(" * be lost.")
|
||||||
writePluginInfo(" *")
|
writePluginInfo(" *")
|
||||||
writePluginInfo(" * If you want to change this file, edit the plugin's json file and add")
|
writePluginInfo(" * If you want to change this file, edit the plugin's json file.")
|
||||||
writePluginInfo(" * idName tags where appropriate.")
|
|
||||||
writePluginInfo(" */")
|
writePluginInfo(" */")
|
||||||
writePluginInfo("")
|
writePluginInfo("")
|
||||||
writePluginInfo("#ifndef PLUGININFO_H")
|
writePluginInfo("#ifndef PLUGININFO_H")
|
||||||
@ -262,11 +265,6 @@ writePluginInfo("#endif // PLUGININFO_H")
|
|||||||
outputFile.close()
|
outputFile.close()
|
||||||
print " --> generated successfully \"%s\"" % (args.output)
|
print " --> generated successfully \"%s\"" % (args.output)
|
||||||
|
|
||||||
##################################################################################################################
|
|
||||||
# Translate
|
|
||||||
if len(translationStrings) is not 0:
|
|
||||||
createTranslationFiles()
|
|
||||||
|
|
||||||
##################################################################################################################
|
##################################################################################################################
|
||||||
# Write extern-plugininfo.h
|
# Write extern-plugininfo.h
|
||||||
|
|
||||||
@ -300,5 +298,10 @@ writeExternPluginInfo("#endif // EXTERNPLUGININFO_H")
|
|||||||
outputFileExtern.close()
|
outputFileExtern.close()
|
||||||
print " --> generated successfully \"extern-%s\"" % (args.output)
|
print " --> generated successfully \"extern-%s\"" % (args.output)
|
||||||
|
|
||||||
|
##################################################################################################################
|
||||||
|
# Translate
|
||||||
|
if len(translationStrings) is not 0:
|
||||||
|
createTranslationFiles()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,8 @@ infofile.input = JSONFILES
|
|||||||
infofile.commands = $$top_srcdir/plugins/guh-generateplugininfo -j ${QMAKE_FILE_NAME} \
|
infofile.commands = $$top_srcdir/plugins/guh-generateplugininfo -j ${QMAKE_FILE_NAME} \
|
||||||
-o ${QMAKE_FILE_OUT} \
|
-o ${QMAKE_FILE_OUT} \
|
||||||
-b $$OUT_PWD \
|
-b $$OUT_PWD \
|
||||||
-t $$TRANSLATIONS
|
-t $$TRANSLATIONS; \
|
||||||
|
rsync -a "$$OUT_PWD"/translations/*.qm $$top_builddir/translations/;
|
||||||
|
|
||||||
QMAKE_EXTRA_COMPILERS += infofile
|
QMAKE_EXTRA_COMPILERS += infofile
|
||||||
|
|
||||||
|
|||||||
@ -456,6 +456,8 @@ GuhCore::GuhCore(QObject *parent) :
|
|||||||
connect(m_configuration, &GuhConfiguration::cloudProxyServerChanged, m_cloudManager, &CloudManager::onProxyServerUrlChanged);
|
connect(m_configuration, &GuhConfiguration::cloudProxyServerChanged, m_cloudManager, &CloudManager::onProxyServerUrlChanged);
|
||||||
connect(m_configuration, &GuhConfiguration::cloudAuthenticationServerChanged, m_cloudManager, &CloudManager::onAuthenticationServerUrlChanged);
|
connect(m_configuration, &GuhConfiguration::cloudAuthenticationServerChanged, m_cloudManager, &CloudManager::onAuthenticationServerUrlChanged);
|
||||||
|
|
||||||
|
connect(m_configuration, &GuhConfiguration::localeChanged, this, &GuhCore::onLocaleChanged);
|
||||||
|
|
||||||
connect(m_deviceManager, &DeviceManager::eventTriggered, this, &GuhCore::gotEvent);
|
connect(m_deviceManager, &DeviceManager::eventTriggered, this, &GuhCore::gotEvent);
|
||||||
connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &GuhCore::deviceStateChanged);
|
connect(m_deviceManager, &DeviceManager::deviceStateChanged, this, &GuhCore::deviceStateChanged);
|
||||||
connect(m_deviceManager, &DeviceManager::deviceAdded, this, &GuhCore::deviceAdded);
|
connect(m_deviceManager, &DeviceManager::deviceAdded, this, &GuhCore::deviceAdded);
|
||||||
@ -559,6 +561,11 @@ void GuhCore::onDateTimeChanged(const QDateTime &dateTime)
|
|||||||
executeRuleActions(actions);
|
executeRuleActions(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuhCore::onLocaleChanged()
|
||||||
|
{
|
||||||
|
m_deviceManager->setLocale(m_configuration->locale());
|
||||||
|
}
|
||||||
|
|
||||||
/*! Return the instance of the log engine */
|
/*! Return the instance of the log engine */
|
||||||
LogEngine* GuhCore::logEngine() const
|
LogEngine* GuhCore::logEngine() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -138,6 +138,7 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void gotEvent(const Event &event);
|
void gotEvent(const Event &event);
|
||||||
void onDateTimeChanged(const QDateTime &dateTime);
|
void onDateTimeChanged(const QDateTime &dateTime);
|
||||||
|
void onLocaleChanged();
|
||||||
void actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status);
|
void actionExecutionFinished(const ActionId &id, DeviceManager::DeviceError status);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -20,8 +20,9 @@ TRANSLATIONS *= $$top_srcdir/translations/guhd_en_US.ts \
|
|||||||
lrelease.input = TRANSLATIONS
|
lrelease.input = TRANSLATIONS
|
||||||
lrelease.CONFIG += no_link
|
lrelease.CONFIG += no_link
|
||||||
lrelease.output = $$top_srcdir/${QMAKE_FILE_BASE}.qm
|
lrelease.output = $$top_srcdir/${QMAKE_FILE_BASE}.qm
|
||||||
lrelease.commands = $$[QT_INSTALL_BINS]/lupdate $$_FILE_; \
|
lrelease.commands = $$[QT_INSTALL_BINS]/lupdate -no-obsolete $$_FILE_; \
|
||||||
$$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm;
|
$$[QT_INSTALL_BINS]/lrelease ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_PATH}/${QMAKE_FILE_BASE}.qm; \
|
||||||
|
rsync -a $$top_srcdir/translations/*.qm $$top_builddir/translations/;
|
||||||
|
|
||||||
QMAKE_EXTRA_COMPILERS += lrelease
|
QMAKE_EXTRA_COMPILERS += lrelease
|
||||||
PRE_TARGETDEPS += compiler_lrelease_make_all
|
PRE_TARGETDEPS += compiler_lrelease_make_all
|
||||||
|
|||||||
Reference in New Issue
Block a user