Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
1224eae1
Commit
1224eae1
authored
Mar 25, 2012
by
Max-Wilhelm Bruker
Browse files
added button to test custom translation file
parent
95dd3fc0
Changes
5
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/dlg_settings.cpp
View file @
1224eae1
...
...
@@ -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
);
...
...
@@ -136,9 +140,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"
));
...
...
@@ -555,6 +569,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
);
...
...
cockatrice/src/dlg_settings.h
View file @
1224eae1
...
...
@@ -27,6 +27,7 @@ public:
GeneralSettingsPage
();
void
retranslateUi
();
private
slots
:
void
customTranslationButtonClicked
();
void
deckPathButtonClicked
();
void
picsPathButtonClicked
();
void
cardDatabasePathButtonClicked
();
...
...
@@ -39,6 +40,7 @@ signals:
private:
QStringList
findQmFiles
();
QString
languageName
(
const
QString
&
qmFile
);
QPushButton
*
customTranslationButton
;
QLineEdit
*
deckPathEdit
,
*
picsPathEdit
,
*
cardDatabasePathEdit
;
QGroupBox
*
personalGroupBox
,
*
pathsGroupBox
;
QComboBox
*
languageBox
;
...
...
cockatrice/src/main.cpp
View file @
1224eae1
...
...
@@ -62,7 +62,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
);
}
...
...
cockatrice/src/settingscache.cpp
View file @
1224eae1
...
...
@@ -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
();
...
...
@@ -36,6 +37,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
;
...
...
cockatrice/src/settingscache.h
View file @
1224eae1
...
...
@@ -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
,
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
getPicsPath
()
const
{
return
picsPath
;
}
...
...
@@ -67,6 +69,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
setPicsPath
(
const
QString
&
_picsPath
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment