From f4211e0b23e54f08116252e29a2c5e84562fce5e Mon Sep 17 00:00:00 2001 From: Alf Gaida Date: Thu, 24 Sep 2015 00:53:29 +0200 Subject: [PATCH] Adding upstream version 0.9.0+20150923. --- CMakeLists.txt | 1 + .../lxqt-config-appearance.desktop.in | 2 +- .../lxqt-config-file-associations.desktop.in | 2 +- lxqt-config-input/keyboardconfig.cpp | 12 +- lxqt-config-input/keyboardconfig.h | 2 + lxqt-config-input/keyboardconfig.ui | 9 +- .../lxqt-config-input.desktop.in | 2 +- lxqt-config-locale/CMakeLists.txt | 58 +++ lxqt-config-locale/localeconfig.cpp | 452 ++++++++++++++++++ lxqt-config-locale/localeconfig.h | 79 +++ lxqt-config-locale/localeconfig.ui | 385 +++++++++++++++ .../lxqt-config-locale.desktop.in | 11 + lxqt-config-locale/main.cpp | 53 ++ .../translations/lxqt-config-locale.ts | 110 +++++ src/lxqt-config.desktop.in | 2 +- 15 files changed, 1174 insertions(+), 6 deletions(-) create mode 100644 lxqt-config-locale/CMakeLists.txt create mode 100644 lxqt-config-locale/localeconfig.cpp create mode 100644 lxqt-config-locale/localeconfig.h create mode 100644 lxqt-config-locale/localeconfig.ui create mode 100644 lxqt-config-locale/lxqt-config-locale.desktop.in create mode 100644 lxqt-config-locale/main.cpp create mode 100644 lxqt-config-locale/translations/lxqt-config-locale.ts diff --git a/CMakeLists.txt b/CMakeLists.txt index 8141dde..883d584 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ add_subdirectory(lxqt-config-input) add_subdirectory(lxqt-config-file-associations) add_subdirectory(lxqt-config-appearance) add_subdirectory(lxqt-config-monitor) +add_subdirectory(lxqt-config-locale) # building tarball with CPack ------------------------------------------------- include(InstallRequiredSystemLibraries) diff --git a/lxqt-config-appearance/lxqt-config-appearance.desktop.in b/lxqt-config-appearance/lxqt-config-appearance.desktop.in index 2fae068..8565232 100644 --- a/lxqt-config-appearance/lxqt-config-appearance.desktop.in +++ b/lxqt-config-appearance/lxqt-config-appearance.desktop.in @@ -6,6 +6,6 @@ Comment=Appearance settings for LXQt Exec=lxqt-config-appearance Icon=preferences-desktop-theme Categories=Settings;DesktopSettings;Qt;LXQt; -OnlyShowIn=LXDE;LXQt; +OnlyShowIn=LXQt; #TRANSLATIONS_DIR=translations diff --git a/lxqt-config-file-associations/lxqt-config-file-associations.desktop.in b/lxqt-config-file-associations/lxqt-config-file-associations.desktop.in index ca8ecd0..f686f7a 100644 --- a/lxqt-config-file-associations/lxqt-config-file-associations.desktop.in +++ b/lxqt-config-file-associations/lxqt-config-file-associations.desktop.in @@ -6,6 +6,6 @@ Comment=Configure applications associated with known file types Exec=lxqt-config-file-associations Icon=preferences-desktop-filetype-association Categories=Settings;DesktopSettings;Qt;LXQt; -OnlyShowIn=LXDE;LXQt; +OnlyShowIn=LXQt; #TRANSLATIONS_DIR=translations diff --git a/lxqt-config-input/keyboardconfig.cpp b/lxqt-config-input/keyboardconfig.cpp index 8be4c76..996d24d 100644 --- a/lxqt-config-input/keyboardconfig.cpp +++ b/lxqt-config-input/keyboardconfig.cpp @@ -44,7 +44,8 @@ KeyboardConfig::KeyboardConfig(LXQt::Settings* _settings, QSettings* _qtSettings interval(30), oldInterval(30), beep(true), - oldBeep(true) { + oldBeep(true), + numlock(false) { ui.setupUi(this); @@ -58,6 +59,7 @@ KeyboardConfig::KeyboardConfig(LXQt::Settings* _settings, QSettings* _qtSettings connect(ui.keyboardInterval, SIGNAL(valueChanged(int)), SLOT(onKeyboardSliderChanged(int))); connect(ui.keyboardBeep, SIGNAL(toggled(bool)), SLOT(onKeyboardBeepToggled(bool))); connect(ui.cursorFlashTime, SIGNAL(valueChanged(int)), SLOT(onCorsorFlashTimeChanged(int))); + connect(ui.keyboardNumLock, SIGNAL(toggled(bool)), SLOT(onKeyboardNumLockToggled(bool))); } KeyboardConfig::~KeyboardConfig() { @@ -68,6 +70,7 @@ void KeyboardConfig::initControls() { ui.keyboardDelay->setValue(delay); ui.keyboardInterval->setValue(interval); ui.keyboardBeep->setChecked(beep); + ui.keyboardNumLock->setChecked(numlock); qtSettings->beginGroup(QLatin1String("Qt")); int value = qtSettings->value(QLatin1String("cursorFlashTime"), 1000).toInt(); @@ -98,6 +101,11 @@ void KeyboardConfig::onKeyboardBeepToggled(bool checked) { accept(); } +void KeyboardConfig::onKeyboardNumLockToggled(bool checked) { + numlock = checked; + accept(); +} + void KeyboardConfig::onCorsorFlashTimeChanged(int value) { qtSettings->beginGroup(QLatin1String("Qt")); @@ -115,6 +123,7 @@ void KeyboardConfig::loadSettings() { oldDelay = delay = settings->value("delay", 500).toInt(); oldInterval = interval = settings->value("interval", 30).toInt(); oldBeep = beep = settings->value("beep", true).toBool(); + numlock = settings->value("numlock", false).toBool(); settings->endGroup(); } @@ -123,6 +132,7 @@ void KeyboardConfig::accept() { settings->setValue("delay", delay); settings->setValue("interval", interval); settings->setValue("beep", beep); + settings->setValue("numlock", numlock); settings->endGroup(); } diff --git a/lxqt-config-input/keyboardconfig.h b/lxqt-config-input/keyboardconfig.h index 085baa5..505edc3 100644 --- a/lxqt-config-input/keyboardconfig.h +++ b/lxqt-config-input/keyboardconfig.h @@ -49,6 +49,7 @@ private Q_SLOTS: void onKeyboardSliderChanged(int value); void onKeyboardBeepToggled(bool checked); void onCorsorFlashTimeChanged(int value); + void onKeyboardNumLockToggled(bool checked); private: Ui::KeyboardConfig ui; @@ -60,6 +61,7 @@ private: int oldInterval; bool beep; bool oldBeep; + bool numlock; }; #endif // KEYBOARDCONFIG_H diff --git a/lxqt-config-input/keyboardconfig.ui b/lxqt-config-input/keyboardconfig.ui index c681023..99647f9 100644 --- a/lxqt-config-input/keyboardconfig.ui +++ b/lxqt-config-input/keyboardconfig.ui @@ -7,7 +7,7 @@ 0 0 375 - 232 + 276 @@ -161,6 +161,13 @@ + + + + Turn on NumLock after login + + + diff --git a/lxqt-config-input/lxqt-config-input.desktop.in b/lxqt-config-input/lxqt-config-input.desktop.in index 52f19f6..b1088b9 100644 --- a/lxqt-config-input/lxqt-config-input.desktop.in +++ b/lxqt-config-input/lxqt-config-input.desktop.in @@ -6,6 +6,6 @@ Comment=Configure keyboard, mouse, and other input devices Exec=lxqt-config-input Icon=input-keyboard Categories=Qt;Settings;HardwareSettings;DesktopSettings;LXQt; -OnlyShowIn=LXDE;LXQt; +OnlyShowIn=LXQt; #TRANSLATIONS_DIR=translations diff --git a/lxqt-config-locale/CMakeLists.txt b/lxqt-config-locale/CMakeLists.txt new file mode 100644 index 0000000..0ec12db --- /dev/null +++ b/lxqt-config-locale/CMakeLists.txt @@ -0,0 +1,58 @@ +project(lxqt-config-locale) + +set(H_FILES + localeconfig.h +) + + +set(CPP_FILES + main.cpp + localeconfig.cpp +) + +set(UI_FILES + localeconfig.ui +) + +# Translations ********************************** +lxqt_translate_ts(QM_FILES + UPDATE_TRANSLATIONS + ${UPDATE_TRANSLATIONS} + SOURCES + ${H_FILES} + ${CPP_FILES} + ${UI_FILES} + INSTALL_DIR + "${LXQT_TRANSLATIONS_DIR}/${PROJECT_NAME}" +) + +lxqt_app_translation_loader(QM_LOADER ${PROJECT_NAME}) +lxqt_translate_desktop(DESKTOP_FILES SOURCES ${PROJECT_NAME}.desktop.in) + +#************************************************ + +add_executable(${PROJECT_NAME} + ${CPP_FILES} + ${RESOURCES} + ${QRC_SOURCES} + ${QM_FILES} + ${DESKTOP_FILES} + ${QM_LOADER} +) + +target_link_libraries(${PROJECT_NAME} + Qt5::Widgets + Qt5::Xml + lxqt +) + +install(TARGETS + ${PROJECT_NAME} + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime +) +install(FILES + ${DESKTOP_FILES} + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" + COMPONENT Runtime +) diff --git a/lxqt-config-locale/localeconfig.cpp b/lxqt-config-locale/localeconfig.cpp new file mode 100644 index 0000000..69cfd31 --- /dev/null +++ b/lxqt-config-locale/localeconfig.cpp @@ -0,0 +1,452 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)GPL2+ + * + * + * Copyright: 2014 LXQt team + * 2014 Sebastian Kügler + * Authors: + * Julien Lavergne + * Sebastian Kügler + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * + * END_COMMON_COPYRIGHT_HEADER + * + * Based on plasma-desktop/kcms/formats module + */ + +#include "localeconfig.h" +#include "ui_localeconfig.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const static QString lcLang = QStringLiteral("LANG"); + +const static QString lcNumeric = QStringLiteral("LC_NUMERIC"); +const static QString lcTime = QStringLiteral("LC_TIME"); +const static QString lcMonetary = QStringLiteral("LC_MONETARY"); +const static QString lcMeasurement = QStringLiteral("LC_MEASUREMENT"); +const static QString lcCollate = QStringLiteral("LC_COLLATE"); +const static QString lcCtype = QStringLiteral("LC_CTYPE"); + +const static QString lcLanguage = QStringLiteral("LANGUAGE"); + +LocaleConfig::LocaleConfig(LXQt::Settings* settings, LXQt::Settings* session_settings, QWidget* parent) : + QWidget(parent), + m_ui(new Ui::LocaleConfig), + hasChanged(new bool), + mSettings(settings), + sSettings(session_settings) + + +{ + m_ui->setupUi(this); + m_combos << m_ui->comboGlobal + << m_ui->comboNumbers + << m_ui->comboTime + << m_ui->comboCurrency + << m_ui->comboMeasurement + << m_ui->comboCollate; + + hasChanged = false; + + initControls(); +} + + +LocaleConfig::~LocaleConfig() +{ + delete m_ui; +} + +bool countryLessThan(const QLocale & c1, const QLocale & c2) +{ + return QString::localeAwareCompare(c1.nativeCountryName(), c2.nativeCountryName()) < 0; +} + +void LocaleConfig::load() +{ + QList allLocales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry); + qSort(allLocales.begin(), allLocales.end(), countryLessThan); + foreach(QComboBox * combo, m_combos) + { + initCombo(combo, allLocales); + } + + readConfig(); + + foreach(QComboBox * combo, m_combos) + { + connectCombo(combo); + } + + connect(m_ui->checkDetailed, &QAbstractButton::toggled, [ = ]() + { + updateExample(); + updateEnabled(); + hasChanged = true; + }); + + updateEnabled(); + updateExample(); + hasChanged = false; +} + +void LocaleConfig::initCombo(QComboBox *combo, const QList & allLocales) +{ + combo->clear(); + const QString clabel = tr("No change"); + combo->setInsertPolicy(QComboBox::InsertAlphabetically); + combo->addItem(clabel, QString()); + foreach(const QLocale & l, allLocales) + { + addLocaleToCombo(combo, l); + } +} + +void LocaleConfig::connectCombo(QComboBox *combo) +{ + connect(combo, &QComboBox::currentTextChanged, [ = ]() + { + hasChanged = true; + updateExample(); + }); +} + +void LocaleConfig::addLocaleToCombo(QComboBox *combo, const QLocale &locale) +{ + const QString clabel = !locale.nativeCountryName().isEmpty() ? locale.nativeCountryName() : locale.countryToString(locale.country()); + // This needs to use name() rather than bcp47name() or later on the export will generate a non-sense locale (e.g. "it" instead of + // "it_IT") + // TODO: Properly handle scripts (@foo) + QString cvalue = locale.name(); + if (!cvalue.contains('.')) + { // explicitely add the encoding, otherwise Qt doesn't accept dead keys and garbles the output as well + cvalue.append(QLatin1Char('.') + QTextCodec::codecForLocale()->name()); + } + + QString flagcode; + const QStringList split = locale.name().split('_'); + if (split.count() > 1) + { + flagcode = split[1].toLower(); + } + /* TODO Find a better place for flags ... */ + QString flag(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kf5/locale/countries/%1/flag.png").arg(flagcode))); + QIcon flagIcon; + if (!flag.isEmpty()) + { + flagIcon = QIcon(flag); + } + + QString itemResult; + itemResult = QString("%1 - %2 (%3)") + .arg(clabel) + .arg(locale.nativeLanguageName()) + .arg(locale.name()); + + combo->addItem(flagIcon, itemResult, cvalue); +} + +void setCombo(QComboBox *combo, const QString &key) +{ + const int ix = combo->findData(key); + if (ix > -1) + { + combo->setCurrentIndex(ix); + } +} + +void LocaleConfig::readConfig() +{ + mSettings->beginGroup("Formats"); + + bool useDetailed = mSettings->value("useDetailed", false).toBool(); + m_ui->checkDetailed->setChecked(useDetailed); + + setCombo(m_ui->comboGlobal, mSettings->value(lcLang, qgetenv(lcLang.toLatin1())).toString()); + + setCombo(m_ui->comboNumbers, mSettings->value(lcNumeric, qgetenv(lcNumeric.toLatin1())).toString()); + setCombo(m_ui->comboTime, mSettings->value(lcTime, qgetenv(lcTime.toLatin1())).toString()); + setCombo(m_ui->comboCollate, mSettings->value(lcCollate, qgetenv(lcCollate.toLatin1())).toString()); + setCombo(m_ui->comboCurrency, mSettings->value(lcMonetary, qgetenv(lcMonetary.toLatin1())).toString()); + setCombo(m_ui->comboMeasurement, mSettings->value(lcMeasurement, qgetenv(lcMeasurement.toLatin1())).toString()); + + updateEnabled(); + + mSettings->endGroup(); +} + +void LocaleConfig::writeConfig() +{ + mSettings->beginGroup("Formats"); + + // global ends up empty here when OK button is clicked from kcmshell5, + // apparently the data in the combo is gone by the time save() is called. + // This might be a problem in KCModule, but does not directly affect us + // since within systemsettings, it works fine. + // See https://bugs.kde.org/show_bug.cgi?id=334624 + if (m_ui->comboGlobal->count() == 0) + { + qWarning() << "Couldn't read data from UI, writing configuration failed."; + return; + } + const QString global = m_ui->comboGlobal->currentData().toString(); + + if (!m_ui->checkDetailed->isChecked()) + { + // Global setting, clean up config + mSettings->remove("useDetailed"); + if (global.isEmpty()) + { + mSettings->remove(lcLang); + } + else + { + mSettings->setValue(lcLang, global); + } + mSettings->remove(lcNumeric); + mSettings->remove(lcTime); + mSettings->remove(lcMonetary); + mSettings->remove(lcMeasurement); + mSettings->remove(lcCollate); + mSettings->remove(lcCtype); + } + else + { + // Save detailed settings + mSettings->setValue("useDetailed", true); + + if (global.isEmpty()) + { + mSettings->remove(lcLang); + } + else + { + mSettings->setValue(lcLang, global); + } + + const QString numeric = m_ui->comboNumbers->currentData().toString(); + if (numeric.isEmpty()) + { + mSettings->remove(lcNumeric); + } + else + { + mSettings->setValue(lcNumeric, numeric); + } + + const QString time = m_ui->comboTime->currentData().toString(); + if (time.isEmpty()) + { + mSettings->remove(lcTime); + } + else + { + mSettings->setValue(lcTime, time); + } + + const QString monetary = m_ui->comboCurrency->currentData().toString(); + if (monetary.isEmpty()) + { + mSettings->remove(lcMonetary); + } + else + { + mSettings->setValue(lcMonetary, monetary); + } + + const QString measurement = m_ui->comboMeasurement->currentData().toString(); + if (measurement.isEmpty()) + { + mSettings->remove(lcMeasurement); + } + else + { + mSettings->setValue(lcMeasurement, measurement); + } + + const QString collate = m_ui->comboCollate->currentData().toString(); + if (collate.isEmpty()) + { + mSettings->remove(lcCollate); + } + else + { + mSettings->setValue(lcCollate, collate); + } + } + mSettings->endGroup(); +} + +void LocaleConfig::saveSettings() +{ + if (hasChanged) + { + QMessageBox msgBox; + msgBox.setWindowTitle(tr("Format Settings Changed")); + msgBox.setText(tr("Save the settings ? (they will take effect the next time you log in)")); + msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Cancel); + + int ret = msgBox.exec(); + if( ret == QMessageBox::Save ) + { + writeConfig(); + writeExports(); + } + } + +} + +void LocaleConfig::writeExports() +{ + sSettings->beginGroup("Environment"); + mSettings->beginGroup("Formats"); + if (!mSettings->value(lcLang).toString().isNull()) + { + sSettings->setValue(lcLang, mSettings->value(lcLang).toString()); + + if (mSettings->value("useDetailed").toBool()) + { + if (!mSettings->value(lcNumeric).toString().isNull()) + { + sSettings->setValue(lcNumeric, mSettings->value(lcNumeric).toString()); + } + if (!mSettings->value(lcTime).toString().isNull()) + { + sSettings->setValue(lcTime, mSettings->value(lcTime).toString()); + } + if (!mSettings->value(lcCollate).toString().isNull()) + { + sSettings->setValue(lcCollate, mSettings->value(lcCollate).toString()); + } + if (!mSettings->value(lcMonetary).toString().isNull()) + { + sSettings->setValue(lcMonetary, mSettings->value(lcMonetary).toString()); + } + if (!mSettings->value(lcMeasurement).toString().isNull()) + { + sSettings->setValue(lcMeasurement, mSettings->value(lcMeasurement).toString()); + } + } + else + { + sSettings->setValue(lcNumeric, mSettings->value(lcLang).toString()); + sSettings->setValue(lcTime, mSettings->value(lcLang).toString()); + sSettings->setValue(lcCollate, mSettings->value(lcLang).toString()); + sSettings->setValue(lcMonetary, mSettings->value(lcLang).toString()); + sSettings->setValue(lcMeasurement, mSettings->value(lcLang).toString()); + } + } + mSettings->endGroup(); + sSettings->endGroup(); + sSettings->sync(); +} + +void LocaleConfig::defaults() +{ + m_ui->checkDetailed->setChecked(false); + + // restore user defaults from env vars + setCombo(m_ui->comboGlobal, qgetenv(lcLang.toLatin1())); + setCombo(m_ui->comboNumbers, qgetenv(lcNumeric.toLatin1())); + setCombo(m_ui->comboTime, qgetenv(lcTime.toLatin1())); + setCombo(m_ui->comboCollate, qgetenv(lcCollate.toLatin1())); + setCombo(m_ui->comboCurrency, qgetenv(lcMonetary.toLatin1())); + setCombo(m_ui->comboMeasurement, qgetenv(lcMeasurement.toLatin1())); + + updateEnabled(); +} + +void LocaleConfig::updateEnabled() +{ + const bool enabled = m_ui->checkDetailed->isChecked(); + + m_ui->labelNumbers->setEnabled(enabled); + m_ui->labelTime->setEnabled(enabled); + m_ui->labelCurrency->setEnabled(enabled); + m_ui->labelMeasurement->setEnabled(enabled); + m_ui->labelCollate->setEnabled(enabled); + m_ui->comboNumbers->setEnabled(enabled); + m_ui->comboTime->setEnabled(enabled); + m_ui->comboCurrency->setEnabled(enabled); + m_ui->comboMeasurement->setEnabled(enabled); + m_ui->comboCollate->setEnabled(enabled); +} + +void LocaleConfig::updateExample() +{ + const bool useDetailed = m_ui->checkDetailed->isChecked(); + + QLocale nloc; + QLocale tloc; + QLocale cloc; + QLocale mloc; + + if (useDetailed) + { + nloc = QLocale(m_ui->comboNumbers->currentData().toString()); + tloc = QLocale(m_ui->comboTime->currentData().toString()); + cloc = QLocale(m_ui->comboCurrency->currentData().toString()); + mloc = QLocale(m_ui->comboMeasurement->currentData().toString()); + } + else + { + nloc = QLocale(m_ui->comboGlobal->currentData().toString()); + tloc = QLocale(m_ui->comboGlobal->currentData().toString()); + cloc = QLocale(m_ui->comboGlobal->currentData().toString()); + mloc = QLocale(m_ui->comboGlobal->currentData().toString()); + } + + const QString numberExample = nloc.toString(1000.01); + const QString timeExample = tloc.toString(QDateTime::currentDateTime()); + const QString currencyExample = cloc.toCurrencyString(24); + + QString measurementSetting; + if (mloc.measurementSystem() == QLocale::ImperialUKSystem) + { + measurementSetting = tr("Imperial UK"); + } + else if (mloc.measurementSystem() == QLocale::ImperialUSSystem) + { + measurementSetting = tr("Imperial US"); + } + else + { + measurementSetting = tr("Metric"); + } + + m_ui->exampleNumbers->setText(numberExample); + m_ui->exampleTime->setText(timeExample); + m_ui->exampleCurrency->setText(currencyExample); + m_ui->exampleMeasurement->setText(measurementSetting); +} + +void LocaleConfig::initControls() +{ + defaults(); + load(); + hasChanged = false; +} diff --git a/lxqt-config-locale/localeconfig.h b/lxqt-config-locale/localeconfig.h new file mode 100644 index 0000000..a25a513 --- /dev/null +++ b/lxqt-config-locale/localeconfig.h @@ -0,0 +1,79 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)GPL2+ + * + * + * Copyright: 2014 LXQt team + * 2014 Sebastian Kügler + * Authors: + * Julien Lavergne + * Sebastian Kügler + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * + * END_COMMON_COPYRIGHT_HEADER */ + +#ifndef LOCALECONFIG_H +#define LOCALECONFIG_H + +#include +#include + +class QTreeWidgetItem; +class QSettings; + + +namespace Ui { + class LocaleConfig; +} + +class QComboBox; +class QMessageWidget; + +class LocaleConfig : public QWidget +{ + Q_OBJECT + +public: + explicit LocaleConfig(LXQt::Settings *settings, LXQt::Settings *session_settings, QWidget *parent = 0); + ~LocaleConfig(); + + void load(); + void save(); + void defaults(); + +public slots: + void initControls(); + void saveSettings(); + +private: + void addLocaleToCombo(QComboBox *combo, const QLocale &locale); + void initCombo(QComboBox *combo, const QList &allLocales); + void connectCombo(QComboBox *combo); + QList m_combos; + + void readConfig(); + void writeConfig(); + void writeExports(); + + void updateExample(); + void updateEnabled(); + + Ui::LocaleConfig *m_ui; + bool hasChanged; + LXQt::Settings *mSettings; + LXQt::Settings *sSettings; +}; + +#endif // LOCALECONFIG_H diff --git a/lxqt-config-locale/localeconfig.ui b/lxqt-config-locale/localeconfig.ui new file mode 100644 index 0000000..f7aecc3 --- /dev/null +++ b/lxqt-config-locale/localeconfig.ui @@ -0,0 +1,385 @@ + + + Sebastian Kuegler + LocaleConfig + + + + 0 + 0 + 600 + 450 + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + 6 + + + 6 + + + + + Re&gion: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + comboGlobal + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + + + + + De&tailed Settings + + + + + + + &Numbers: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + comboNumbers + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + + + + + &Time: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + comboTime + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + + + + + Currenc&y: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + comboCurrency + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + + + + + Measurement &Units: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + comboMeasurement + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + + + + + Co&llation and Sorting: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + comboCollate + + + + + + + + 0 + 0 + + + + + 300 + 0 + + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + <b>Examples</b> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Numbers: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Time: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Currency: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Measurement Units: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 16 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 32 + + + + + + + + + + + + + + + + diff --git a/lxqt-config-locale/lxqt-config-locale.desktop.in b/lxqt-config-locale/lxqt-config-locale.desktop.in new file mode 100644 index 0000000..46cf666 --- /dev/null +++ b/lxqt-config-locale/lxqt-config-locale.desktop.in @@ -0,0 +1,11 @@ +[Desktop Entry] +Type=Application +Name=Locale +GenericName=Locale settings +Comment=Locale settings for LXQt +Exec=lxqt-config-locale +Icon=preferences-desktop-locale +Categories=Settings;DesktopSettings;Qt;LXQt; +OnlyShowIn=LXQt; + +#TRANSLATIONS_DIR=translations diff --git a/lxqt-config-locale/main.cpp b/lxqt-config-locale/main.cpp new file mode 100644 index 0000000..80fc396 --- /dev/null +++ b/lxqt-config-locale/main.cpp @@ -0,0 +1,53 @@ +/* BEGIN_COMMON_COPYRIGHT_HEADER + * (c)GPL2+ + * + * + * Copyright: 2014 LXQt team + * + * Authors: + * Julien Lavergne + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * + * END_COMMON_COPYRIGHT_HEADER */ + +#include + +#include +#include +#include +#include "localeconfig.h" + +int main (int argc, char **argv) +{ + LXQt::SingleApplication app(argc, argv); + LXQt::Settings settings("LXQt-config-locale"); + LXQt::Settings session_settings("LXQt-session"); + LXQt::ConfigDialog* dialog = new LXQt::ConfigDialog(QObject::tr("LXQt Locale Configuration"), &settings); + + app.setActivationWindow(dialog); + + LocaleConfig* localePage = new LocaleConfig(&settings, &session_settings, dialog); + dialog->addPage(localePage, QObject::tr("Locale Settings"), QStringList() << "preferences-desktop-locale" << "preferences-desktop"); + QObject::connect(dialog, SIGNAL(reset()), localePage, SLOT(initControls())); + QObject::connect(dialog, SIGNAL(save()), localePage, SLOT(saveSettings())); + + dialog->setAttribute(Qt::WA_DeleteOnClose); + dialog->setWindowIcon(QIcon::fromTheme("preferences-desktop-locale")); + dialog->show(); + + return app.exec(); +} + diff --git a/lxqt-config-locale/translations/lxqt-config-locale.ts b/lxqt-config-locale/translations/lxqt-config-locale.ts new file mode 100644 index 0000000..f9eabc3 --- /dev/null +++ b/lxqt-config-locale/translations/lxqt-config-locale.ts @@ -0,0 +1,110 @@ + + + + + LocaleConfig + + + Re&gion: + + + + + De&tailed Settings + + + + + &Numbers: + + + + + &Time: + + + + + Currenc&y: + + + + + Measurement &Units: + + + + + Co&llation and Sorting: + + + + + <b>Examples</b> + + + + + Numbers: + + + + + Time: + + + + + Currency: + + + + + Measurement Units: + + + + + No change + + + + + Format Settings Changed + + + + + Save the settings ? (they will take effect the next time you log in) + + + + + Imperial UK + + + + + Imperial US + + + + + Metric + + + + + QObject + + + LXQt Locale Configuration + + + + + Locale Settings + + + + diff --git a/src/lxqt-config.desktop.in b/src/lxqt-config.desktop.in index 095dfe6..e36dd86 100644 --- a/src/lxqt-config.desktop.in +++ b/src/lxqt-config.desktop.in @@ -6,6 +6,6 @@ Comment=Configure your system Exec=lxqt-config Icon=preferences-system Categories=Settings;DesktopSettings;Qt;LXQt; -OnlyShowIn=LXDE;LXQt; +OnlyShowIn=LXQt; #TRANSLATIONS_DIR=translations