implemented function to change language on the fly
This commit is contained in:
+7
-1
@@ -73,7 +73,7 @@ void cChapterWindow::setChapter(cChapter* lpChapter, cSceneList* lpSceneList)
|
||||
|
||||
ui->m_lpSceneList->resizeColumnToContents(0);
|
||||
|
||||
setWindowTitle(tr("[chapter] - ") + lpChapter->name());
|
||||
setWindowTitle(windowTitle() + lpChapter->name());
|
||||
|
||||
connect(ui->m_lpName, &cLineEdit::textChanged, this, &cChapterWindow::onNameChanged);
|
||||
connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cChapterWindow::onDescriptionChanged);
|
||||
@@ -85,6 +85,12 @@ cChapter* cChapterWindow::chapter()
|
||||
return(m_lpChapter);
|
||||
}
|
||||
|
||||
void cChapterWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(windowTitle() + m_lpChapter->name());
|
||||
}
|
||||
|
||||
void cChapterWindow::onSceneDoubleClicked(const QModelIndex& index)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpSceneModel->itemFromIndex(index);
|
||||
|
||||
@@ -57,6 +57,13 @@ public:
|
||||
*/
|
||||
cChapter* chapter();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[chapter] - </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -162,7 +162,7 @@ void cCharacterWindow::setCharacter(cCharacter* lpCharacter)
|
||||
QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
ui->m_lpLayout->addItem(lpSpacer);
|
||||
|
||||
setWindowTitle(tr("[character] - ") + lpCharacter->name());
|
||||
setWindowTitle(windowTitle() + lpCharacter->name());
|
||||
|
||||
connect(ui->m_lpFirstName, &cLineEdit::textChanged, this, &cCharacterWindow::onFirstNameChanged);
|
||||
connect(ui->m_lpMiddleName, &cLineEdit::textChanged, this, &cCharacterWindow::onMiddleNameChanged);
|
||||
@@ -197,6 +197,12 @@ cCharacter* cCharacterWindow::character()
|
||||
return(m_lpCharacter);
|
||||
}
|
||||
|
||||
void cCharacterWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(windowTitle() + m_lpCharacter->name());
|
||||
}
|
||||
|
||||
void cCharacterWindow::onFirstNameChanged(const QString& szText)
|
||||
{
|
||||
m_lpCharacter->setFirstName(szText);
|
||||
|
||||
@@ -54,6 +54,13 @@ public:
|
||||
*/
|
||||
cCharacter* character();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[character] - </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
|
||||
+93
-1
@@ -44,10 +44,11 @@
|
||||
#include <QDesktopServices>
|
||||
|
||||
|
||||
cMainWindow::cMainWindow(cSplashScreen *lpSplashScreen, QWidget *parent) :
|
||||
cMainWindow::cMainWindow(cSplashScreen *lpSplashScreen, QTranslator *lpTranslator, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::cMainWindow),
|
||||
m_lpSplashScreen(lpSplashScreen),
|
||||
m_lpTranslator(lpTranslator),
|
||||
m_lpOutlineModel(0),
|
||||
m_lpCharacterModel(0),
|
||||
m_lpPlaceModel(0),
|
||||
@@ -682,6 +683,96 @@ void cMainWindow::updateWindowTitle()
|
||||
setWindowTitle(szWindowTitle);
|
||||
}
|
||||
|
||||
void switchTranslator(QTranslator* lpTranslator, const QString& filename)
|
||||
{
|
||||
qApp->removeTranslator(lpTranslator);
|
||||
|
||||
if(lpTranslator->load(filename))
|
||||
qApp->installTranslator(lpTranslator);
|
||||
}
|
||||
|
||||
void cMainWindow::onLanguageChanged()
|
||||
{
|
||||
QSettings settings;
|
||||
QString szLanguage = settings.value("main/language").toString();
|
||||
QLocale locale = QLocale(szLanguage);
|
||||
|
||||
QLocale::setDefault(locale);
|
||||
switchTranslator(m_lpTranslator, QString("%1%2storyWriter_%3.qm").arg(localePath()).arg(QDir::separator()).arg(szLanguage));
|
||||
// switchTranslator(m_translatorQt, QString("qt_%1.qm").arg(szLanguage));
|
||||
}
|
||||
|
||||
void cMainWindow::changeEvent(QEvent* event)
|
||||
{
|
||||
if(event)
|
||||
{
|
||||
if(event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
retranslateMenu();
|
||||
retranslateWindows();
|
||||
}
|
||||
|
||||
// this event is send, if the system, language changes
|
||||
// case QEvent::LocaleChange:
|
||||
// {
|
||||
// QString locale = QLocale::system().name();
|
||||
// locale.truncate(locale.lastIndexOf('_'));
|
||||
// loadLanguage(locale);
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
QMainWindow::changeEvent(event);
|
||||
}
|
||||
|
||||
void cMainWindow::retranslateMenu()
|
||||
{
|
||||
QMenuBar* lpMenu = menuBar();
|
||||
if(lpMenu)
|
||||
retranslateActions(lpMenu->actions());
|
||||
|
||||
if(m_lpFileMenu)
|
||||
retranslateActions(m_lpFileMenu->actions());
|
||||
if(m_lpEditMenu)
|
||||
retranslateActions(m_lpEditMenu->actions());
|
||||
if(m_lpTextMenu)
|
||||
retranslateActions(m_lpTextMenu->actions());
|
||||
if(m_lpToolsMenu)
|
||||
retranslateActions(m_lpToolsMenu->actions());
|
||||
if(m_lpWindowMenu)
|
||||
retranslateActions(m_lpWindowMenu->actions());
|
||||
if(m_lpHelpMenu)
|
||||
retranslateActions(m_lpHelpMenu->actions());
|
||||
|
||||
if(m_lpFileToolBar)
|
||||
retranslateActions(m_lpFileToolBar->actions());
|
||||
if(m_lpEditToolBar)
|
||||
retranslateActions(m_lpEditToolBar->actions());
|
||||
if(m_lpTextToolBar)
|
||||
retranslateActions(m_lpTextToolBar->actions());
|
||||
if(m_lpFormatToolBar)
|
||||
retranslateActions(m_lpFormatToolBar->actions());
|
||||
}
|
||||
|
||||
void cMainWindow::retranslateActions(QList<QAction*> actionList)
|
||||
{
|
||||
for(int x = 0;x < actionList.count();x++)
|
||||
{
|
||||
QAction* lpAction = actionList[x];
|
||||
lpAction->setText(QApplication::translate("cMainWindow", lpAction->text().toUtf8().data()));
|
||||
}
|
||||
}
|
||||
|
||||
void cMainWindow::retranslateWindows()
|
||||
{
|
||||
for(int x = 0;x < ui->m_lpMainTab->count();x++)
|
||||
{
|
||||
cWidget* lpWidget = (cWidget*)ui->m_lpMainTab->widget(x);
|
||||
|
||||
lpWidget->retranslateUI();
|
||||
}
|
||||
}
|
||||
|
||||
void cMainWindow::onTextEditGotFocus(cTextEdit* lpTextEdit)
|
||||
{
|
||||
prepareTextEdit(lpTextEdit);
|
||||
@@ -1390,6 +1481,7 @@ void cMainWindow::onToolsOptions()
|
||||
{
|
||||
cOptionsDialog* lpOptionsDialog = new cOptionsDialog(this);
|
||||
|
||||
connect(lpOptionsDialog, &cOptionsDialog::onLanguageChanged, this, &cMainWindow::onLanguageChanged);
|
||||
lpOptionsDialog->exec();
|
||||
|
||||
delete lpOptionsDialog;
|
||||
|
||||
+40
-1
@@ -23,6 +23,8 @@
|
||||
#include <QMainWindow>
|
||||
#include <QMdiSubWindow>
|
||||
|
||||
#include <QTranslator>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include <QComboBox>
|
||||
@@ -56,7 +58,7 @@ public:
|
||||
\param lpSplashScreen
|
||||
\param parent
|
||||
*/
|
||||
explicit cMainWindow(cSplashScreen* lpSplashScreen, QWidget* parent = 0);
|
||||
explicit cMainWindow(cSplashScreen* lpSplashScreen, QTranslator* lpTranslator, QWidget* parent = 0);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -108,6 +110,12 @@ public:
|
||||
QAction* actionAlignJustify();
|
||||
|
||||
public slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onLanguageChanged
|
||||
*/
|
||||
void onLanguageChanged();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -647,6 +655,7 @@ private:
|
||||
|
||||
cSplashScreen* m_lpSplashScreen; /*!< Splash Screen */
|
||||
|
||||
QTranslator* m_lpTranslator; /*!< Pointer to the current translator */
|
||||
QStandardItemModel* m_lpOutlineModel; /*!< Item Model for Outline list */
|
||||
QStandardItemModel* m_lpCharacterModel; /*!< Item Model for Character list */
|
||||
QStandardItemModel* m_lpPlaceModel; /*!< Item Model for Place list */
|
||||
@@ -843,7 +852,37 @@ private:
|
||||
\fn updateRecentFileActions
|
||||
*/
|
||||
void updateRecentFileActions();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateMenu
|
||||
\param lpMenu
|
||||
*/
|
||||
void retranslateMenu();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateActions
|
||||
\param actionList
|
||||
*/
|
||||
void retranslateActions(QList<QAction*> actionList);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateWindows
|
||||
*/
|
||||
void retranslateWindows();
|
||||
protected:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn changeEvent
|
||||
\param event
|
||||
*/
|
||||
void changeEvent(QEvent* event);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
|
||||
+7
-1
@@ -60,7 +60,7 @@ void cObjectWindow::setObject(cObject* lpObject)
|
||||
QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
ui->m_lpLayout->addItem(lpSpacer);
|
||||
|
||||
setWindowTitle(tr("[object] - ") + lpObject->name());
|
||||
setWindowTitle(windowTitle() + lpObject->name());
|
||||
|
||||
connect(ui->m_lpName, &cLineEdit::textChanged, this, &cObjectWindow::onNameChanged);
|
||||
connect(ui->m_lpType, &cLineEdit::textChanged, this, &cObjectWindow::onTypeChanged);
|
||||
@@ -72,6 +72,12 @@ cObject* cObjectWindow::object()
|
||||
return(m_lpObject);
|
||||
}
|
||||
|
||||
void cObjectWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(windowTitle() + m_lpObject->name());
|
||||
}
|
||||
|
||||
void cObjectWindow::onNameChanged(const QString& szName)
|
||||
{
|
||||
m_lpObject->setName(szName);
|
||||
|
||||
@@ -54,6 +54,13 @@ public:
|
||||
*/
|
||||
cObject* object();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[object] - </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
|
||||
+11
@@ -6,6 +6,9 @@
|
||||
#include "common.h"
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QSettings>
|
||||
#include <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
||||
|
||||
QString uncompressText(const QByteArray& compressed)
|
||||
@@ -70,3 +73,11 @@ QByteArray textDocument2Blob(cTextDocument* lpTextDocument)
|
||||
|
||||
return(ba);
|
||||
}
|
||||
|
||||
QString localePath()
|
||||
{
|
||||
QSettings settings;
|
||||
QString szAppPath = QCoreApplication::applicationDirPath();
|
||||
QString szPath = settings.value("file/locale", QString("%1%2locale").arg(szAppPath).arg(QDir::separator())).toString();
|
||||
return(szPath);
|
||||
}
|
||||
|
||||
@@ -71,5 +71,12 @@ cTextDocument* blob2TextDocument(const QByteArray& ba);
|
||||
\return QByteArray
|
||||
*/
|
||||
QByteArray textDocument2Blob(cTextDocument* lpTextDocument);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn localePath
|
||||
\return QString
|
||||
*/
|
||||
QString localePath();
|
||||
|
||||
#endif // COMMON_H
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#include "coptionsdialog.h"
|
||||
#include "ui_coptionsdialog.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
#include <QLocale>
|
||||
#include <QSettings>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
cOptionsDialog::cOptionsDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
@@ -8,6 +16,9 @@ cOptionsDialog::cOptionsDialog(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
|
||||
m_lpCategoryModel = new QStandardItemModel(0, 1);
|
||||
ui->m_lpCategoryList->setModel(m_lpCategoryModel);
|
||||
|
||||
@@ -16,9 +27,85 @@ cOptionsDialog::cOptionsDialog(QWidget *parent) :
|
||||
m_lpCategoryModel->appendRow(lpItem);
|
||||
|
||||
ui->m_lpCategoryList->resizeColumnToContents(0);
|
||||
|
||||
QSettings settings;
|
||||
QString szCur = settings.value("main/language", "%SYSTEM%").toString();
|
||||
|
||||
ui->m_lpLanguage->addItem("AUTO", QString("SYSTEM"));
|
||||
if(!szCur.compare("%SYSTEM%", Qt::CaseInsensitive))
|
||||
ui->m_lpLanguage->setCurrentIndex(0);
|
||||
|
||||
QString szLanguage = QLocale::languageToString(QLocale("en").language());
|
||||
ui->m_lpLanguage->addItem(szLanguage, QString("en"));
|
||||
if(!szCur.compare("en", Qt::CaseInsensitive))
|
||||
ui->m_lpLanguage->setCurrentIndex(1);
|
||||
|
||||
QString szPath = localePath();
|
||||
QStringList localeList = QDir(szPath).entryList(QStringList() << "storyWriter*.qm");
|
||||
|
||||
for(int z = 0;z < localeList.count();z++)
|
||||
{
|
||||
QString szLocale = localeList[z];
|
||||
szLocale.truncate(szLocale.lastIndexOf("."));
|
||||
szLocale.remove(0, szLocale.indexOf('_') + 1);
|
||||
szLanguage = QLocale::languageToString(QLocale(szLocale).language());
|
||||
|
||||
ui->m_lpLanguage->addItem(szLanguage, szLocale);
|
||||
if(!szCur.compare(szLocale, Qt::CaseInsensitive))
|
||||
ui->m_lpLanguage->setCurrentIndex(z+2);
|
||||
}
|
||||
|
||||
connect(ui->m_lpLanguage, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &cOptionsDialog::onLanguageIndexChanged);
|
||||
connect(ui->m_lpButtonBox, QDialogButtonBox::clicked, this, &cOptionsDialog::onButtonClicked);
|
||||
}
|
||||
|
||||
cOptionsDialog::~cOptionsDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void cOptionsDialog::onLanguageIndexChanged(int /*index*/)
|
||||
{
|
||||
QString szLanguage = ui->m_lpLanguage->currentData().toString();
|
||||
QSettings settings;
|
||||
|
||||
if(szLanguage == "SYSTEM")
|
||||
szLanguage = "%SYSTEM%";
|
||||
|
||||
if(settings.value("main/language").toString().compare(szLanguage, Qt::CaseInsensitive))
|
||||
{
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void cOptionsDialog::onButtonClicked(QAbstractButton* button)
|
||||
{
|
||||
QString szLanguage = ui->m_lpLanguage->currentData().toString();
|
||||
QSettings settings;
|
||||
|
||||
if(szLanguage == "SYSTEM")
|
||||
szLanguage = "%SYSTEM%";
|
||||
|
||||
settings.setValue("main/language", szLanguage);
|
||||
|
||||
if(button == ui->m_lpButtonBox->button(QDialogButtonBox::Ok))
|
||||
{
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
onLanguageChanged();
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else if(button == ui->m_lpButtonBox->button(QDialogButtonBox::Apply))
|
||||
{
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
ui->m_lpButtonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
|
||||
onLanguageChanged();
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
|
||||
#include <QDialog>
|
||||
#include <QAbstractButton>
|
||||
|
||||
#include <QStandardItemModel>
|
||||
|
||||
@@ -35,6 +36,19 @@ public:
|
||||
*/
|
||||
~cOptionsDialog();
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onLanguageIndexChanged
|
||||
\param index
|
||||
*/
|
||||
void onLanguageIndexChanged(int index);
|
||||
|
||||
void onButtonClicked(QAbstractButton* button);
|
||||
signals:
|
||||
void onLanguageChanged();
|
||||
|
||||
private:
|
||||
Ui::cOptionsDialog* ui; /*!< TODO: describe */
|
||||
QStandardItemModel* m_lpCategoryModel; /*!< TODO: describe */
|
||||
|
||||
+56
-4
@@ -52,18 +52,70 @@
|
||||
<height>335</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QStackedWidget" name="m_lpCategoryStack">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="m_lpGeneralProperties">
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_3" columnstretch="0,1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="m_lpLanguage"/>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<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>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<widget class="QDialogButtonBox" name="m_lpButtonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -72,7 +124,7 @@
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<sender>m_lpButtonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>cOptionsDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
@@ -88,7 +140,7 @@
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<sender>m_lpButtonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>cOptionsDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
|
||||
+7
-1
@@ -71,7 +71,7 @@ void cPartWindow::setPart(cPart* lpPart, cChapterList* lpChapterList)
|
||||
|
||||
ui->m_lpChapterList->resizeColumnToContents(0);
|
||||
|
||||
setWindowTitle(tr("[part] - ") + lpPart->name());
|
||||
setWindowTitle(windowTitle() + lpPart->name());
|
||||
|
||||
connect(ui->m_lpName, &cLineEdit::textChanged, this, &cPartWindow::onNameChanged);
|
||||
connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cPartWindow::onDescriptionChanged);
|
||||
@@ -83,6 +83,12 @@ cPart* cPartWindow::part()
|
||||
return(m_lpPart);
|
||||
}
|
||||
|
||||
void cPartWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(windowTitle() + m_lpPart->name());
|
||||
}
|
||||
|
||||
void cPartWindow::onChapterDoubleClicked(const QModelIndex& index)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpChapterModel->itemFromIndex(index);
|
||||
|
||||
@@ -56,6 +56,12 @@ public:
|
||||
*/
|
||||
cPart* part();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[part] - </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
|
||||
+7
-1
@@ -64,7 +64,7 @@ void cPlaceWindow::setPlace(cPlace* lpPlace)
|
||||
QSpacerItem* lpSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
ui->m_lpLayout->addItem(lpSpacer);
|
||||
|
||||
setWindowTitle(tr("[place] - ") + lpPlace->name());
|
||||
setWindowTitle(windowTitle() + lpPlace->name());
|
||||
|
||||
connect(ui->m_lpName, &cLineEdit::textChanged, this, &cPlaceWindow::onNameChanged);
|
||||
connect(ui->m_lpType, &cLineEdit::textChanged, this, &cPlaceWindow::onTypeChanged);
|
||||
@@ -77,6 +77,12 @@ cPlace* cPlaceWindow::place()
|
||||
return(m_lpPlace);
|
||||
}
|
||||
|
||||
void cPlaceWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(windowTitle() + m_lpPlace->name());
|
||||
}
|
||||
|
||||
void cPlaceWindow::onNameChanged(const QString& szName)
|
||||
{
|
||||
m_lpPlace->setName(szName);
|
||||
|
||||
@@ -54,6 +54,13 @@ public:
|
||||
*/
|
||||
cPlace* place();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[place] - </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -58,8 +58,6 @@ void cPropertiesWindow::setBook(cBook* lpBook)
|
||||
ui->m_lpShortDescription->setDocument(lpBook->shortDescription());
|
||||
ui->m_lpDescription->setDocument(lpBook->description());
|
||||
|
||||
setWindowTitle(tr("[book] - properties"));
|
||||
|
||||
connect(ui->m_lpTitle, &cLineEdit::textChanged, this, &cPropertiesWindow::onTitleChanged);
|
||||
connect(ui->m_lpSubTitle, &cLineEdit::textChanged, this, &cPropertiesWindow::onSubTitleChanged);
|
||||
connect(ui->m_lpAuthor, &cLineEdit::textChanged, this, &cPropertiesWindow::onAuthorChanged);
|
||||
@@ -75,6 +73,11 @@ cBook* cPropertiesWindow::book()
|
||||
return(m_lpBook);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
|
||||
void cPropertiesWindow::onTitleChanged(const QString& szName)
|
||||
{
|
||||
m_lpBook->setTitle(szName);
|
||||
|
||||
@@ -54,6 +54,13 @@ public:
|
||||
*/
|
||||
cBook* book();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[properties]</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -96,7 +96,7 @@ void cRechercheWindow::setRecherche(cRecherche* lpRecherche, cCharacterList* lpC
|
||||
connect(ui->m_lpPlaceList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cRechercheWindow::onPlaceIndexChanged);
|
||||
connect(ui->m_lpObjectList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cRechercheWindow::onObjectIndexChanged);
|
||||
|
||||
setWindowTitle(tr("[recherche] - ") + lpRecherche->name());
|
||||
setWindowTitle(windowTitle() + lpRecherche->name());
|
||||
|
||||
connect(ui->m_lpName, &cLineEdit::textChanged, this, &cRechercheWindow::onNameChanged);
|
||||
connect(ui->m_lpLink, &cLineEdit::textChanged, this, &cRechercheWindow::onLinkChanged);
|
||||
@@ -108,6 +108,12 @@ cRecherche* cRechercheWindow::recherche()
|
||||
return(m_lpRecherche);
|
||||
}
|
||||
|
||||
void cRechercheWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(windowTitle() + m_lpRecherche->name());
|
||||
}
|
||||
|
||||
void cRechercheWindow::onNameChanged(const QString& szName)
|
||||
{
|
||||
m_lpRecherche->setName(szName);
|
||||
|
||||
@@ -54,6 +54,13 @@ public:
|
||||
*/
|
||||
cRecherche* recherche();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
private:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[recherche] - </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
|
||||
+7
-1
@@ -137,7 +137,7 @@ void cSceneWindow::setScene(cScene* lpScene, cCharacterList* lpCharacterList, cP
|
||||
connect(ui->m_lpPlaceList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onPlaceIndexChanged);
|
||||
connect(ui->m_lpObjectList, QOverload<int>::of(&cComboBox::currentIndexChanged), this, &cSceneWindow::onObjectIndexChanged);
|
||||
|
||||
setWindowTitle(tr("[scene] - ") + lpScene->name());
|
||||
setWindowTitle(windowTitle() + lpScene->name());
|
||||
|
||||
connect(ui->m_lpName, &cLineEdit::textChanged, this, &cSceneWindow::onNameChanged);
|
||||
connect(ui->m_lpDescription, &cTextEdit::textChanged, this, &cSceneWindow::onDescriptionChanged);
|
||||
@@ -153,6 +153,12 @@ cScene* cSceneWindow::scene()
|
||||
return(m_lpScene);
|
||||
}
|
||||
|
||||
void cSceneWindow::retranslateUI()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(windowTitle() + m_lpScene->name());
|
||||
}
|
||||
|
||||
void cSceneWindow::onCharacterShowDetails()
|
||||
{
|
||||
if(!ui->m_lpCharacterList->count())
|
||||
|
||||
@@ -56,6 +56,13 @@ public:
|
||||
*/
|
||||
cScene* scene();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
private:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
<string>[scene] - </string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
|
||||
+55
@@ -78,6 +78,61 @@ cWidget::cWidget(QWidget* parent) :
|
||||
{
|
||||
}
|
||||
|
||||
void cWidget::retranslateUI()
|
||||
{
|
||||
switch(m_type)
|
||||
{
|
||||
case TYPE_part:
|
||||
{
|
||||
cPartWindow* lpWindow = (cPartWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
case TYPE_chapter:
|
||||
{
|
||||
cChapterWindow* lpWindow = (cChapterWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
case TYPE_scene:
|
||||
{
|
||||
cSceneWindow* lpWindow = (cSceneWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
case TYPE_character:
|
||||
{
|
||||
cCharacterWindow* lpWindow = (cCharacterWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
case TYPE_object:
|
||||
{
|
||||
cObjectWindow* lpWindow = (cObjectWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
case TYPE_place:
|
||||
{
|
||||
cPlaceWindow* lpWindow = (cPlaceWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
case TYPE_recherche:
|
||||
{
|
||||
cRechercheWindow* lpWindow = (cRechercheWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
case TYPE_properties:
|
||||
{
|
||||
cPropertiesWindow* lpWindow = (cPropertiesWindow*)m_lpWidget;
|
||||
lpWindow->retranslateUI();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cWidget::setWindow(QMdiSubWindow* lpWindow)
|
||||
{
|
||||
m_lpWindow = lpWindow;
|
||||
|
||||
@@ -107,6 +107,13 @@ public:
|
||||
*/
|
||||
explicit cWidget(QWidget* parent);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn retranslateUI
|
||||
*/
|
||||
void retranslateUI();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
|
||||
a.setApplicationName("storyWriter");
|
||||
|
||||
QSettings settings;
|
||||
QTranslator translator;
|
||||
QTranslator* lpTranslator = new QTranslator;
|
||||
QString szLanguage = settings.value("main/language").toString();
|
||||
|
||||
if(!szLanguage.compare("%SYSTEM%"))
|
||||
@@ -45,8 +45,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(!szLanguage.isEmpty())
|
||||
{
|
||||
if(translator.load(QString("storyWriter_%1").arg(szLanguage), ":/locale"))
|
||||
a.installTranslator(&translator);
|
||||
if(lpTranslator->load(QString("storyWriter_%1").arg(szLanguage), ":/locale"))
|
||||
a.installTranslator(lpTranslator);
|
||||
}
|
||||
|
||||
#ifdef SHOW_SPLASH
|
||||
@@ -76,7 +76,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
lpSplash->showStatusMessage(QObject::tr("<center>initializing...</denter>"));
|
||||
|
||||
cMainWindow w(lpSplash);
|
||||
cMainWindow w(lpSplash, lpTranslator);
|
||||
|
||||
if(settings.value("main/maximized").toBool())
|
||||
w.showMaximized();
|
||||
|
||||
Binary file not shown.
+227
-200
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user