Commit eced4e23 authored by Max-Wilhelm Bruker's avatar Max-Wilhelm Bruker
Browse files

merge

parents 3b70ad8c 1224eae1
#ifndef CLIENT_METATYPES_H
#define CLIENT_METATYPES_H
#include <QMetaType>
Q_DECLARE_METATYPE(QVariant)
Q_DECLARE_METATYPE(CommandContainer)
Q_DECLARE_METATYPE(Response)
Q_DECLARE_METATYPE(Response::ResponseCode)
Q_DECLARE_METATYPE(ClientStatus)
Q_DECLARE_METATYPE(RoomEvent)
Q_DECLARE_METATYPE(GameEventContainer)
Q_DECLARE_METATYPE(Event_ServerIdentification)
Q_DECLARE_METATYPE(Event_ConnectionClosed)
Q_DECLARE_METATYPE(Event_ServerShutdown)
Q_DECLARE_METATYPE(Event_AddToList)
Q_DECLARE_METATYPE(Event_RemoveFromList)
Q_DECLARE_METATYPE(Event_UserJoined)
Q_DECLARE_METATYPE(Event_UserLeft)
Q_DECLARE_METATYPE(Event_ServerMessage)
Q_DECLARE_METATYPE(Event_ListRooms)
Q_DECLARE_METATYPE(Event_GameJoined)
Q_DECLARE_METATYPE(Event_UserMessage)
Q_DECLARE_METATYPE(ServerInfo_User)
Q_DECLARE_METATYPE(QList<ServerInfo_User>)
Q_DECLARE_METATYPE(Event_ReplayAdded)
#endif
\ No newline at end of file
......@@ -26,6 +26,8 @@ GeneralSettingsPage::GeneralSettingsPage()
{
languageLabel = new QLabel;
languageBox = new QComboBox;
customTranslationButton = new QPushButton("...");
customTranslationButton->setMaximumWidth(50);
QString setLanguage = settingsCache->getLang();
QStringList qmFiles = findQmFiles();
......@@ -40,12 +42,14 @@ GeneralSettingsPage::GeneralSettingsPage()
picDownloadCheckBox->setChecked(settingsCache->getPicDownload());
connect(languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int)));
connect(customTranslationButton, SIGNAL(clicked()), this, SLOT(customTranslationButtonClicked()));
connect(picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int)));
QGridLayout *personalGrid = new QGridLayout;
personalGrid->addWidget(languageLabel, 0, 0);
personalGrid->addWidget(languageBox, 0, 1);
personalGrid->addWidget(picDownloadCheckBox, 1, 0, 1, 2);
personalGrid->addWidget(customTranslationButton, 0, 2);
personalGrid->addWidget(picDownloadCheckBox, 1, 0, 1, 3);
personalGroupBox = new QGroupBox;
personalGroupBox->setLayout(personalGrid);
......@@ -155,9 +159,19 @@ void GeneralSettingsPage::cardDatabasePathButtonClicked()
void GeneralSettingsPage::languageBoxChanged(int index)
{
settingsCache->setCustomTranslationFile(QString());
settingsCache->setLang(languageBox->itemData(index).toString());
}
void GeneralSettingsPage::customTranslationButtonClicked()
{
QString path = QFileDialog::getOpenFileName(this, tr("Choose path"));
if (path.isEmpty())
return;
settingsCache->setCustomTranslationFile(path);
}
void GeneralSettingsPage::retranslateUi()
{
personalGroupBox->setTitle(tr("Personal settings"));
......@@ -575,6 +589,7 @@ DlgSettings::DlgSettings(QWidget *parent)
: QDialog(parent)
{
connect(settingsCache, SIGNAL(langChanged()), this, SLOT(updateLanguage()));
connect(settingsCache, SIGNAL(customTranslationFileChanged()), this, SLOT(updateLanguage()));
contentsWidget = new QListWidget;
contentsWidget->setViewMode(QListView::IconMode);
......
......@@ -27,20 +27,16 @@ public:
GeneralSettingsPage();
void retranslateUi();
private slots:
void customTranslationButtonClicked();
void deckPathButtonClicked();
void replaysPathButtonClicked();
void picsPathButtonClicked();
void cardDatabasePathButtonClicked();
void languageBoxChanged(int index);
signals:
/* void picsPathChanged(const QString &path);
void replaysPathChanged(const QString &path);
void cardDatabasePathChanged(const QString &path);
void changeLanguage(const QString &qmFile);
void picDownloadChanged(int state);
*/private:
private:
QStringList findQmFiles();
QString languageName(const QString &qmFile);
QPushButton *customTranslationButton;
QLineEdit *deckPathEdit, *replaysPathEdit, *picsPathEdit, *cardDatabasePathEdit;
QGroupBox *personalGroupBox, *pathsGroupBox;
QComboBox *languageBox;
......
......@@ -63,7 +63,10 @@ void installNewTranslator()
qtTranslator->load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qApp->installTranslator(qtTranslator);
translator->load(translationPrefix + "_" + lang, ":/translations");
if (!settingsCache->getCustomTranslationFile().isEmpty())
translator->load(settingsCache->getCustomTranslationFile());
else
translator->load(translationPrefix + "_" + lang, ":/translations");
qApp->installTranslator(translator);
}
......
......@@ -5,6 +5,7 @@ SettingsCache::SettingsCache()
{
settings = new QSettings(this);
customTranslationFile = settings->value("personal/custom_translation").toString();
lang = settings->value("personal/lang").toString();
deckPath = settings->value("paths/decks").toString();
......@@ -37,6 +38,13 @@ SettingsCache::SettingsCache()
priceTagFeature = settings->value("deckeditor/pricetags", false).toBool();
}
void SettingsCache::setCustomTranslationFile(const QString &_customTranslationFile)
{
customTranslationFile = _customTranslationFile;
settings->setValue("personal/custom_translation", customTranslationFile);
emit customTranslationFileChanged();
}
void SettingsCache::setLang(const QString &_lang)
{
lang = _lang;
......
......@@ -8,6 +8,7 @@ class QSettings;
class SettingsCache : public QObject {
Q_OBJECT
signals:
void customTranslationFileChanged();
void langChanged();
void picsPathChanged();
void cardDatabasePathChanged();
......@@ -25,7 +26,7 @@ signals:
private:
QSettings *settings;
QString lang;
QString customTranslationFile, lang;
QString deckPath, replaysPath, picsPath, cardDatabasePath;
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
bool picDownload;
......@@ -43,6 +44,7 @@ private:
bool priceTagFeature;
public:
SettingsCache();
QString getCustomTranslationFile() const { return customTranslationFile; }
QString getLang() const { return lang; }
QString getDeckPath() const { return deckPath; }
QString getReplaysPath() const { return replaysPath; }
......@@ -68,6 +70,7 @@ public:
QString getSoundPath() const { return soundPath; }
bool getPriceTagFeature() const { return priceTagFeature; }
public slots:
void setCustomTranslationFile(const QString &_customTranslationFile);
void setLang(const QString &_lang);
void setDeckPath(const QString &_deckPath);
void setReplaysPath(const QString &_replaysPath);
......
......@@ -225,6 +225,7 @@ void MainWindow::actAbout()
+ tr("Czech:") + " Ondřej Trhoň<br>"
// + tr("Slovak:") + " Ganjalf Rendy<br>"
+ tr("Italian:") + " Luigi Sciolla<br>"
+ tr("Swedish:") + " Jessica Dahl<br>"
));
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
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