Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b89d1c68 authored by John Layt's avatar John Layt

Plasma - New Translations KCM

Initial implementation of a new KCM to configure the LANGUAGE envvar
to control translations used by applications under Plasma. The list of
available langauges is currently only those installed for Plasma. We
may later add all installed po files, or allow the user to add a custom
langauge.

Currently this does not create the script for startkde to use to export
the setting.
parents
########### next target ###############
set(kcm_translations_PART_SRCS kcmtranslations.cpp)
qt5_wrap_ui(kcm_translations_PART_SRCS kcmtranslationswidget.ui)
add_library(kcm_translations ${kcm_translations_PART_SRCS})
target_link_libraries(kcm_translations
Qt5::Widgets
KF5::KCMUtils
KF5::I18n
KF5::KDELibs4Support
)
########### install files ###############
install(TARGETS kcm_translations DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES translations.desktop DESTINATION ${SERVICES_INSTALL_DIR})
#! /usr/bin/env bash
$EXTRACTRC *.ui >> rc.cpp
$XGETTEXT -ktranslate:1,1t -ktranslate:1c,2,2t *.cpp -o $podir/kcmtranslations.pot
This diff is collapsed.
/* This file is part of the KDE workspace
* Copyright 2014 John Layt <john@layt.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KCMTRANSLATIONS_H
#define KCMTRANSLATIONS_H
#include <QMap>
#include <KCModule>
#include <KSharedConfig>
#include <KConfigGroup>
class QListWidgetItem;
class QCheckBox;
class KPushButton;
class KComboBox;
class KIntNumInput;
namespace Ui {
class KCMTranslationsWidget;
}
/**
* @short A KCM to configure KDE Gui Translations
*
* This module is for changing the User's Gui Translations settings.
*/
class KCMTranslations : public KCModule
{
Q_OBJECT
public:
KCMTranslations(QWidget *parent, const QVariantList &);
virtual ~KCMTranslations();
virtual void load();
virtual void save();
virtual void defaults();
virtual QString quickHelp() const;
private Q_SLOTS:
void changedTranslationsAvailable( QListWidgetItem * item );
void changedTranslationsSelected( QListWidgetItem * item );
void installTranslations();
private:
void loadTranslations();
void changedTranslations();
void initWidgets();
void initTranslations();
void initTranslationsInstall();
// The list of translations currently set in the KCM
QStringList m_kcmTranslations;
// The currently saved list of user translations, used to check if value changed
QString m_configTranslations;
// The currently installed translations, used to check if users translations are valid
QStringList m_installedTranslations;
KConfigGroup m_config;
Ui::KCMTranslationsWidget *m_ui;
};
#endif //KCMTRANSLATIONS_H
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KCMTranslationsWidget</class>
<widget class="QWidget" name="KCMTranslationsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>702</width>
<height>425</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="m_tabWidgetSettings">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="KActionSelector" name="m_selectTranslations" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="availableLabel" stdset="0">
<string>Available Translations:</string>
</property>
<property name="selectedLabel" stdset="0">
<string>Preferred Translations:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="m_buttonTranslationsInstall">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Install more translations</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KActionSelector</class>
<extends>QWidget</extends>
<header>kactionselector.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>m_tabWidgetSettings</tabstop>
<tabstop>m_buttonTranslationsInstall</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
[Desktop Entry]
Exec=kcmshell5 translations
Icon=preferences-desktop-locale
Type=Service
X-KDE-ServiceTypes=KCModule
X-DocPath=kcontrol/translations/index.html
X-KDE-Library=kcm_translations
X-KDE-ParentApp=kcontrol
X-KDE-System-Settings-Parent-Category=locale
X-KDE-Weight=50
Name=Translations
Categories=Qt;KDE;X-KDE-settings-translations;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment