From cb961007c534b260b779ed513d33843a9dce01f4 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 27 Nov 2012 14:18:41 +0100 Subject: Examples: move widgets specific "tools" examples to the correct place examples/tools -> examples/widgets/tools Change-Id: I8b9e23c45e07ce5cd9da8f24a9a9f7ae10b2b107 Reviewed-by: hjk --- examples/widgets/tools/i18n/i18n.desktop | 11 ++ examples/widgets/tools/i18n/i18n.pro | 30 ++++ examples/widgets/tools/i18n/i18n.qrc | 18 +++ examples/widgets/tools/i18n/languagechooser.cpp | 166 +++++++++++++++++++++ examples/widgets/tools/i18n/languagechooser.h | 85 +++++++++++ examples/widgets/tools/i18n/main.cpp | 54 +++++++ examples/widgets/tools/i18n/mainwindow.cpp | 95 ++++++++++++ examples/widgets/tools/i18n/mainwindow.h | 76 ++++++++++ .../widgets/tools/i18n/translations/i18n_ar.qm | Bin 0 -> 736 bytes .../widgets/tools/i18n/translations/i18n_ar.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_cs.qm | Bin 0 -> 796 bytes .../widgets/tools/i18n/translations/i18n_cs.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_de.qm | Bin 0 -> 848 bytes .../widgets/tools/i18n/translations/i18n_de.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_el.qm | Bin 0 -> 804 bytes .../widgets/tools/i18n/translations/i18n_el.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_en.qm | Bin 0 -> 810 bytes .../widgets/tools/i18n/translations/i18n_en.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_eo.qm | Bin 0 -> 806 bytes .../widgets/tools/i18n/translations/i18n_eo.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_fr.qm | Bin 0 -> 844 bytes .../widgets/tools/i18n/translations/i18n_fr.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_it.qm | Bin 0 -> 808 bytes .../widgets/tools/i18n/translations/i18n_it.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_jp.qm | Bin 0 -> 722 bytes .../widgets/tools/i18n/translations/i18n_jp.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_ko.qm | Bin 0 -> 690 bytes .../widgets/tools/i18n/translations/i18n_ko.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_no.qm | Bin 0 -> 804 bytes .../widgets/tools/i18n/translations/i18n_no.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_ru.qm | Bin 0 -> 806 bytes .../widgets/tools/i18n/translations/i18n_ru.ts | 59 ++++++++ .../widgets/tools/i18n/translations/i18n_sv.qm | Bin 0 -> 814 bytes .../widgets/tools/i18n/translations/i18n_sv.ts | 57 +++++++ .../widgets/tools/i18n/translations/i18n_zh.qm | Bin 0 -> 700 bytes .../widgets/tools/i18n/translations/i18n_zh.ts | 57 +++++++ 36 files changed, 1335 insertions(+) create mode 100644 examples/widgets/tools/i18n/i18n.desktop create mode 100644 examples/widgets/tools/i18n/i18n.pro create mode 100644 examples/widgets/tools/i18n/i18n.qrc create mode 100644 examples/widgets/tools/i18n/languagechooser.cpp create mode 100644 examples/widgets/tools/i18n/languagechooser.h create mode 100644 examples/widgets/tools/i18n/main.cpp create mode 100644 examples/widgets/tools/i18n/mainwindow.cpp create mode 100644 examples/widgets/tools/i18n/mainwindow.h create mode 100644 examples/widgets/tools/i18n/translations/i18n_ar.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_ar.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_cs.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_cs.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_de.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_de.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_el.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_el.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_en.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_en.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_eo.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_eo.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_fr.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_fr.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_it.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_it.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_jp.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_jp.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_ko.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_ko.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_no.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_no.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_ru.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_ru.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_sv.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_sv.ts create mode 100644 examples/widgets/tools/i18n/translations/i18n_zh.qm create mode 100644 examples/widgets/tools/i18n/translations/i18n_zh.ts (limited to 'examples/widgets/tools/i18n') diff --git a/examples/widgets/tools/i18n/i18n.desktop b/examples/widgets/tools/i18n/i18n.desktop new file mode 100644 index 0000000000..e1632c4d04 --- /dev/null +++ b/examples/widgets/tools/i18n/i18n.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Type=Application +Terminal=false +Name=I18N +Exec=/opt/usr/bin/i18n +Icon=i18n +X-Window-Icon= +X-HildonDesk-ShowInToolbar=true +X-Osso-Type=application/x-executable diff --git a/examples/widgets/tools/i18n/i18n.pro b/examples/widgets/tools/i18n/i18n.pro new file mode 100644 index 0000000000..a02e25dcd0 --- /dev/null +++ b/examples/widgets/tools/i18n/i18n.pro @@ -0,0 +1,30 @@ +HEADERS = languagechooser.h \ + mainwindow.h +SOURCES = languagechooser.cpp \ + main.cpp \ + mainwindow.cpp +RESOURCES += i18n.qrc +TRANSLATIONS += translations/i18n_ar.ts \ + translations/i18n_cs.ts \ + translations/i18n_de.ts \ + translations/i18n_el.ts \ + translations/i18n_en.ts \ + translations/i18n_eo.ts \ + translations/i18n_fr.ts \ + translations/i18n_it.ts \ + translations/i18n_jp.ts \ + translations/i18n_ko.ts \ + translations/i18n_no.ts \ + translations/i18n_ru.ts \ + translations/i18n_sv.ts \ + translations/i18n_zh.ts + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/tools/i18n +sources.files = $$SOURCES $$HEADERS $$RESOURCES translations i18n.pro +sources.path = $$[QT_INSTALL_EXAMPLES]/tools/i18n +INSTALLS += target sources + +QT += widgets + +simulator: warning(This example might not fully work on Simulator platform) diff --git a/examples/widgets/tools/i18n/i18n.qrc b/examples/widgets/tools/i18n/i18n.qrc new file mode 100644 index 0000000000..16a89f140b --- /dev/null +++ b/examples/widgets/tools/i18n/i18n.qrc @@ -0,0 +1,18 @@ + + + translations/i18n_ar.qm + translations/i18n_cs.qm + translations/i18n_de.qm + translations/i18n_el.qm + translations/i18n_en.qm + translations/i18n_eo.qm + translations/i18n_fr.qm + translations/i18n_it.qm + translations/i18n_jp.qm + translations/i18n_ko.qm + translations/i18n_no.qm + translations/i18n_ru.qm + translations/i18n_sv.qm + translations/i18n_zh.qm + + diff --git a/examples/widgets/tools/i18n/languagechooser.cpp b/examples/widgets/tools/i18n/languagechooser.cpp new file mode 100644 index 0000000000..0728e29547 --- /dev/null +++ b/examples/widgets/tools/i18n/languagechooser.cpp @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "languagechooser.h" +#include "mainwindow.h" + +#ifdef Q_WS_MAC +QT_BEGIN_NAMESPACE +extern void qt_mac_set_menubar_merge(bool merge); +QT_END_NAMESPACE +#endif + +LanguageChooser::LanguageChooser(QWidget *parent) + : QDialog(parent, Qt::WindowStaysOnTopHint) +{ + groupBox = new QGroupBox("Languages"); + + QGridLayout *groupBoxLayout = new QGridLayout; + + QStringList qmFiles = findQmFiles(); + for (int i = 0; i < qmFiles.size(); ++i) { + QCheckBox *checkBox = new QCheckBox(languageName(qmFiles[i])); + qmFileForCheckBoxMap.insert(checkBox, qmFiles[i]); + connect(checkBox, SIGNAL(toggled(bool)), this, SLOT(checkBoxToggled())); + groupBoxLayout->addWidget(checkBox, i / 2, i % 2); + } + groupBox->setLayout(groupBoxLayout); + + buttonBox = new QDialogButtonBox; + + showAllButton = buttonBox->addButton("Show All", + QDialogButtonBox::ActionRole); + hideAllButton = buttonBox->addButton("Hide All", + QDialogButtonBox::ActionRole); + + connect(showAllButton, SIGNAL(clicked()), this, SLOT(showAll())); + connect(hideAllButton, SIGNAL(clicked()), this, SLOT(hideAll())); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(groupBox); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + +#ifdef Q_WS_MAC + qt_mac_set_menubar_merge(false); +#endif + + setWindowTitle("I18N"); +} + +bool LanguageChooser::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::Close) { + MainWindow *window = qobject_cast(object); + if (window) { + QCheckBox *checkBox = mainWindowForCheckBoxMap.key(window); + if (checkBox) + checkBox->setChecked(false); + } + } + return QWidget::eventFilter(object, event); +} + +void LanguageChooser::closeEvent(QCloseEvent * /* event */) +{ + qApp->quit(); +} + +void LanguageChooser::checkBoxToggled() +{ + QCheckBox *checkBox = qobject_cast(sender()); + MainWindow *window = mainWindowForCheckBoxMap[checkBox]; + if (!window) { + QTranslator translator; + translator.load(qmFileForCheckBoxMap[checkBox]); + qApp->installTranslator(&translator); + + window = new MainWindow; + window->setPalette(colorForLanguage(checkBox->text())); + + window->installEventFilter(this); + mainWindowForCheckBoxMap.insert(checkBox, window); + } + window->setVisible(checkBox->isChecked()); +} + +void LanguageChooser::showAll() +{ + foreach (QCheckBox *checkBox, qmFileForCheckBoxMap.keys()) + checkBox->setChecked(true); +} + +void LanguageChooser::hideAll() +{ + foreach (QCheckBox *checkBox, qmFileForCheckBoxMap.keys()) + checkBox->setChecked(false); +} + +QStringList LanguageChooser::findQmFiles() +{ + QDir dir(":/translations"); + QStringList fileNames = dir.entryList(QStringList("*.qm"), QDir::Files, + QDir::Name); + QMutableStringListIterator i(fileNames); + while (i.hasNext()) { + i.next(); + i.setValue(dir.filePath(i.value())); + } + return fileNames; +} + +QString LanguageChooser::languageName(const QString &qmFile) +{ + QTranslator translator; + translator.load(qmFile); + + return translator.translate("MainWindow", "English"); +} + +QColor LanguageChooser::colorForLanguage(const QString &language) +{ + uint hashValue = qHash(language); + int red = 156 + (hashValue & 0x3F); + int green = 156 + ((hashValue >> 6) & 0x3F); + int blue = 156 + ((hashValue >> 12) & 0x3F); + return QColor(red, green, blue); +} diff --git a/examples/widgets/tools/i18n/languagechooser.h b/examples/widgets/tools/i18n/languagechooser.h new file mode 100644 index 0000000000..4d350674e5 --- /dev/null +++ b/examples/widgets/tools/i18n/languagechooser.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef LANGUAGECHOOSER_H +#define LANGUAGECHOOSER_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QAbstractButton; +class QCheckBox; +class QDialogButtonBox; +class QGroupBox; +QT_END_NAMESPACE +class MainWindow; + +class LanguageChooser : public QDialog +{ + Q_OBJECT + +public: + LanguageChooser(QWidget *parent = 0); + +protected: + bool eventFilter(QObject *object, QEvent *event); + void closeEvent(QCloseEvent *event); + +private slots: + void checkBoxToggled(); + void showAll(); + void hideAll(); + +private: + QStringList findQmFiles(); + QString languageName(const QString &qmFile); + QColor colorForLanguage(const QString &language); + + QGroupBox *groupBox; + QDialogButtonBox *buttonBox; + QAbstractButton *showAllButton; + QAbstractButton *hideAllButton; + QMap qmFileForCheckBoxMap; + QMap mainWindowForCheckBoxMap; +}; + +#endif diff --git a/examples/widgets/tools/i18n/main.cpp b/examples/widgets/tools/i18n/main.cpp new file mode 100644 index 0000000000..f57f2b4b2e --- /dev/null +++ b/examples/widgets/tools/i18n/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "languagechooser.h" +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + Q_INIT_RESOURCE(i18n); + + QApplication app(argc, argv); + LanguageChooser chooser; + chooser.show(); + return app.exec(); +} diff --git a/examples/widgets/tools/i18n/mainwindow.cpp b/examples/widgets/tools/i18n/mainwindow.cpp new file mode 100644 index 0000000000..a2e6da5e38 --- /dev/null +++ b/examples/widgets/tools/i18n/mainwindow.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "mainwindow.h" + +static const char * const listEntries[] = { + QT_TRANSLATE_NOOP("MainWindow", "First"), + QT_TRANSLATE_NOOP("MainWindow", "Second"), + QT_TRANSLATE_NOOP("MainWindow", "Third"), + 0 +}; + +MainWindow::MainWindow() +{ + centralWidget = new QWidget; + setCentralWidget(centralWidget); + + createGroupBox(); + + listWidget = new QListWidget; + for (int i = 0; listEntries[i]; ++i) + listWidget->addItem(tr(listEntries[i])); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(groupBox); + mainLayout->addWidget(listWidget); + centralWidget->setLayout(mainLayout); + + exitAction = new QAction(tr("E&xit"), this); + connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->setPalette(QPalette(Qt::red)); + fileMenu->addAction(exitAction); + + setWindowTitle(tr("Language: %1").arg(tr("English"))); + statusBar()->showMessage(tr("Internationalization Example")); + + if (tr("LTR") == "RTL") + setLayoutDirection(Qt::RightToLeft); +} + +void MainWindow::createGroupBox() +{ + groupBox = new QGroupBox(tr("View")); + perspectiveRadioButton = new QRadioButton(tr("Perspective")); + isometricRadioButton = new QRadioButton(tr("Isometric")); + obliqueRadioButton = new QRadioButton(tr("Oblique")); + perspectiveRadioButton->setChecked(true); + + QVBoxLayout *groupBoxLayout = new QVBoxLayout; + groupBoxLayout->addWidget(perspectiveRadioButton); + groupBoxLayout->addWidget(isometricRadioButton); + groupBoxLayout->addWidget(obliqueRadioButton); + groupBox->setLayout(groupBoxLayout); +} diff --git a/examples/widgets/tools/i18n/mainwindow.h b/examples/widgets/tools/i18n/mainwindow.h new file mode 100644 index 0000000000..ab1131227d --- /dev/null +++ b/examples/widgets/tools/i18n/mainwindow.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names +** of its contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +QT_BEGIN_NAMESPACE +class QAction; +class QGroupBox; +class QLabel; +class QListWidget; +class QMenu; +class QRadioButton; +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(); + +private: + void createGroupBox(); + + QWidget *centralWidget; + QLabel *label; + QGroupBox *groupBox; + QListWidget *listWidget; + QRadioButton *perspectiveRadioButton; + QRadioButton *isometricRadioButton; + QRadioButton *obliqueRadioButton; + QMenu *fileMenu; + QAction *exitAction; +}; + +#endif diff --git a/examples/widgets/tools/i18n/translations/i18n_ar.qm b/examples/widgets/tools/i18n/translations/i18n_ar.qm new file mode 100644 index 0000000000..a134c468bb Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_ar.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_ar.ts b/examples/widgets/tools/i18n/translations/i18n_ar.ts new file mode 100644 index 0000000000..a7ec2c9404 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_ar.ts @@ -0,0 +1,57 @@ + + + MainWindow + + First + أول + + + Internationalization Example + مثال التدويل + + + Isometric + متماثل + + + Language: %1 + اللغة: %1 + + + English + العربية + + + Oblique + مصمت + + + Perspective + منظور + + + Second + ثانى + + + Third + ثالث + + + View + مرئى + + + E&xit + أخرج + + + &File + الملف + + + LTR + RTL + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_cs.qm b/examples/widgets/tools/i18n/translations/i18n_cs.qm new file mode 100644 index 0000000000..5b7ff95b05 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_cs.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_cs.ts b/examples/widgets/tools/i18n/translations/i18n_cs.ts new file mode 100644 index 0000000000..6c4dee9b2e --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_cs.ts @@ -0,0 +1,57 @@ + + + MainWindow + + View + Pohled + + + &File + &Soubor + + + E&xit + &Konec + + + First + První + + + Third + Třetí + + + Language: %1 + Jayzk: %1 + + + English + Český + + + Oblique + Nakloněný + + + Second + Druhý + + + Isometric + Isometrický + + + Perspective + Perspektivní + + + Internationalization Example + Ukázka lokalizace + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_de.qm b/examples/widgets/tools/i18n/translations/i18n_de.qm new file mode 100644 index 0000000000..177fc49b8b Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_de.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_de.ts b/examples/widgets/tools/i18n/translations/i18n_de.ts new file mode 100644 index 0000000000..249a61d020 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_de.ts @@ -0,0 +1,57 @@ + + + MainWindow + + View + Ansicht + + + &File + &Datei + + + E&xit + Be&enden + + + First + Erstens + + + Third + Drittens + + + English + Deutsch + + + Language: %1 + Sprache: %1 + + + Oblique + Schief + + + Second + Zweitens + + + Isometric + Isometrisch + + + Perspective + Perspektivisch + + + Internationalization Example + Internationalisierungsbeispiel + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_el.qm b/examples/widgets/tools/i18n/translations/i18n_el.qm new file mode 100644 index 0000000000..5483291bb0 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_el.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_el.ts b/examples/widgets/tools/i18n/translations/i18n_el.ts new file mode 100644 index 0000000000..d23a0aad3e --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_el.ts @@ -0,0 +1,57 @@ + + + MainWindow + + &File + &Αρχείο + + + E&xit + Έ&ξοδος + + + First + Πρώτο + + + Internationalization Example + Παράδειγμα διεθνοποίησης + + + Isometric + Ισομετρική + + + Language: %1 + Γλώσσα: %1 + + + English + Ελληνικά + + + Oblique + Πλάγια + + + Perspective + Προοπτική + + + Second + Δεύτερο + + + Third + Τρίτο + + + View + Όψη + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_en.qm b/examples/widgets/tools/i18n/translations/i18n_en.qm new file mode 100644 index 0000000000..9190ac7e6f Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_en.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_en.ts b/examples/widgets/tools/i18n/translations/i18n_en.ts new file mode 100644 index 0000000000..ca38e958c1 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_en.ts @@ -0,0 +1,57 @@ + + + MainWindow + + E&xit + E&xit + + + &File + &File + + + Internationalization Example + Internationalization Example + + + Language: %1 + Language: %1 + + + English + English + + + View + View + + + Perspective + Perspective + + + Isometric + Isometric + + + Oblique + Oblique + + + First + First + + + Second + Second + + + Third + Third + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_eo.qm b/examples/widgets/tools/i18n/translations/i18n_eo.qm new file mode 100644 index 0000000000..a8457bef06 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_eo.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_eo.ts b/examples/widgets/tools/i18n/translations/i18n_eo.ts new file mode 100644 index 0000000000..16a37becd9 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_eo.ts @@ -0,0 +1,57 @@ + + + MainWindow + + &File + &Dosiero + + + First + Unue + + + Internationalization Example + Ekzemplo pri internaciigo + + + Isometric + Isometria + + + Language: %1 + Lingvo: %1 + + + English + Esperanto + + + Oblique + Oblikva + + + Perspective + Perspektiva + + + Second + Due + + + Third + Trie + + + View + Aspekto + + + E&xit + &Fini + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_fr.qm b/examples/widgets/tools/i18n/translations/i18n_fr.qm new file mode 100644 index 0000000000..3e8a69b80d Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_fr.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_fr.ts b/examples/widgets/tools/i18n/translations/i18n_fr.ts new file mode 100644 index 0000000000..0012892ef2 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_fr.ts @@ -0,0 +1,57 @@ + + + MainWindow + + View + Vue + + + &File + &Fichier + + + E&xit + &Quitter + + + First + Premier + + + Third + Troisième + + + Language: %1 + Langue : %1 + + + English + Français + + + Oblique + Oblique + + + Second + Deuxième + + + Isometric + Isométrique + + + Perspective + Perspective + + + Internationalization Example + Exemple d'internationalisation + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_it.qm b/examples/widgets/tools/i18n/translations/i18n_it.qm new file mode 100644 index 0000000000..3dffd30548 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_it.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_it.ts b/examples/widgets/tools/i18n/translations/i18n_it.ts new file mode 100644 index 0000000000..d516a277b6 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_it.ts @@ -0,0 +1,57 @@ + + + MainWindow + + First + Primo + + + Internationalization Example + Esempio di localizzazione + + + Isometric + Isometrica + + + Language: %1 + Lingua: %1 + + + English + Italiano + + + Oblique + Obliqua + + + Perspective + Prospettica + + + Second + Secondo + + + Third + Terzo + + + View + Vista + + + E&xit + &Esci + + + &File + &File + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_jp.qm b/examples/widgets/tools/i18n/translations/i18n_jp.qm new file mode 100644 index 0000000000..017bc96cfc Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_jp.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_jp.ts b/examples/widgets/tools/i18n/translations/i18n_jp.ts new file mode 100644 index 0000000000..067b5a8a0b --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_jp.ts @@ -0,0 +1,57 @@ + + + MainWindow + + &File + ファイル(&F) + + + E&xit + 終了(&X) + + + First + 第一行 + + + Internationalization Example + 国際化(i18n)の例 + + + Isometric + 等角投影法 + + + Language: %1 + 言語: %1 + + + English + 日本語 + + + Oblique + 斜め投影法 + + + Perspective + 遠近法 + + + Second + 第二行 + + + Third + 第三行 + + + View + 表示方式 + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_ko.qm b/examples/widgets/tools/i18n/translations/i18n_ko.qm new file mode 100644 index 0000000000..d61b93db39 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_ko.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_ko.ts b/examples/widgets/tools/i18n/translations/i18n_ko.ts new file mode 100644 index 0000000000..bfd5924518 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_ko.ts @@ -0,0 +1,57 @@ + + + MainWindow + + &File + 파일&F + + + E&xit + 종료&X + + + First + 첫번째 + + + Internationalization Example + 국제화 예제 + + + Isometric + 등측도 + + + Language: %1 + 언어 : %1 + + + English + 한국어 + + + Oblique + 빗각 + + + Perspective + 원근화법 + + + Second + 두번째 + + + Third + 세번째 + + + View + 보기 + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_no.qm b/examples/widgets/tools/i18n/translations/i18n_no.qm new file mode 100644 index 0000000000..c84b0d74ba Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_no.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_no.ts b/examples/widgets/tools/i18n/translations/i18n_no.ts new file mode 100644 index 0000000000..2e06974997 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_no.ts @@ -0,0 +1,57 @@ + + + MainWindow + + View + Vis + + + &File + &Fil + + + E&xit + &Avslutt + + + First + Første + + + Third + Tredje + + + Language: %1 + Språk: %1 + + + English + Norsk + + + Oblique + Skjevt + + + Second + Andre + + + Isometric + Isometrisk + + + Perspective + Perspektiv + + + Internationalization Example + Internasjonaliseringseksempel + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_ru.qm b/examples/widgets/tools/i18n/translations/i18n_ru.qm new file mode 100644 index 0000000000..a76e1b8703 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_ru.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_ru.ts b/examples/widgets/tools/i18n/translations/i18n_ru.ts new file mode 100644 index 0000000000..748cc12fd9 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_ru.ts @@ -0,0 +1,59 @@ + + + + + MainWindow + + View + Вид + + + &File + Файл + + + E&xit + Выход + + + First + Первый + + + Third + Третий + + + Language: %1 + Язык: %1 + + + English + Русский + + + Oblique + Курсив + + + Second + Второй + + + Isometric + Изометрический + + + Perspective + Перспектива + + + Internationalization Example + Пример интернационализации + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_sv.qm b/examples/widgets/tools/i18n/translations/i18n_sv.qm new file mode 100644 index 0000000000..7204b308b1 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_sv.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_sv.ts b/examples/widgets/tools/i18n/translations/i18n_sv.ts new file mode 100644 index 0000000000..ac4ab98bd3 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_sv.ts @@ -0,0 +1,57 @@ + + + MainWindow + + View + Visa + + + &File + &Arkiv + + + E&xit + &Avsluta + + + First + Första + + + Third + Tredje + + + Language: %1 + Språk: %1 + + + English + Svenska + + + Oblique + Skevt + + + Second + Andra + + + Isometric + Isometriskt + + + Perspective + Perspektivt + + + Internationalization Example + Internationaliseringsexempel + + + LTR + LTR + + + diff --git a/examples/widgets/tools/i18n/translations/i18n_zh.qm b/examples/widgets/tools/i18n/translations/i18n_zh.qm new file mode 100644 index 0000000000..32053f4633 Binary files /dev/null and b/examples/widgets/tools/i18n/translations/i18n_zh.qm differ diff --git a/examples/widgets/tools/i18n/translations/i18n_zh.ts b/examples/widgets/tools/i18n/translations/i18n_zh.ts new file mode 100644 index 0000000000..3b715470a8 --- /dev/null +++ b/examples/widgets/tools/i18n/translations/i18n_zh.ts @@ -0,0 +1,57 @@ + + + MainWindow + + View + 视图 + + + &File + 文件[&F] + + + E&xit + 退出[&x] + + + First + 第一个 + + + Third + 第三个 + + + Language: %1 + 语言: %1 + + + English + 简体中文 + + + Oblique + 斜投影 + + + Second + 第二个 + + + Isometric + 等角投影 + + + Perspective + 透视投影 + + + Internationalization Example + 国际化范例 + + + LTR + LTR + + + -- cgit v1.2.3