Commit 56107241 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt sprefs: save lang in registry

Close #9329
parent 7f4ef985
...@@ -51,9 +51,138 @@ ...@@ -51,9 +51,138 @@
#ifdef _WIN32 #ifdef _WIN32
# include <vlc_windows_interfaces.h> # include <vlc_windows_interfaces.h>
# include <vlc_charset.h>
#endif #endif
#include <vlc_modules.h> #include <vlc_modules.h>
static const char *const ppsz_language[] =
{
"auto",
"en",
"ar",
"bn",
"pt_BR",
"en_GB",
"el",
"bg",
"ca",
"zh_TW",
"cs",
"da",
"nl",
"fi",
"et",
"eu",
"fr",
"ga",
"gd",
"gl",
"ka",
"de",
"he",
"hr",
"hu",
"hy",
"is",
"id",
"it",
"ja",
"ko",
"lt",
"mn",
"ms",
"nb",
"nn",
"kk",
"km",
"ne",
"oc",
"fa",
"pl",
"pt_PT",
"pa",
"ro",
"ru",
"zh_CN",
"si",
"sr",
"sk",
"sl",
"ckb",
"es",
"sv",
"te",
"tr",
"uk",
"vi",
"wa",
NULL,
};
static const char *const ppsz_language_text[] =
{
N_("Auto"),
"American English",
"ﻉﺮﺒﻳ",
"বাংলা",
"Português Brasileiro",
"British English",
"Νέα Ελληνικά",
"български език",
"Català",
"正體中文",
"Čeština",
"Dansk",
"Nederlands",
"Suomi",
"eesti keel",
"Euskara",
"Français",
"Gaeilge",
"Gàidhlig",
"Galego",
"ქართული",
"Deutsch",
"עברית",
"hrvatski",
"Magyar",
"հայերեն",
"íslenska",
"Bahasa Indonesia",
"Italiano",
"日本語",
"한국어",
"lietuvių",
"Монгол хэл",
"Melayu",
"Bokmål",
"Nynorsk",
"Қазақ тілі",
"ភាសាខ្មែរ",
"नेपाली",
"Occitan",
"ﻑﺍﺮﺳی",
"Polski",
"Português",
"ਪੰਜਾਬੀ",
"Română",
"Русский",
"简体中文",
"සිංහල",
"српски",
"Slovensky",
"slovenščina",
"کوردیی سۆرانی",
"Español",
"Svenska",
"తెలుగు",
"Türkçe",
"украї́нська мо́ва",
"tiếng Việt",
"Walon",
};
/********************************************************************* /*********************************************************************
* The List of categories * The List of categories
*********************************************************************/ *********************************************************************/
...@@ -125,6 +254,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -125,6 +254,7 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
module_config_t *p_config; module_config_t *p_config;
ConfigControl *control; ConfigControl *control;
number = _number; number = _number;
lang = NULL;
#define CONFIG_GENERIC( option, type, label, qcontrol ) \ #define CONFIG_GENERIC( option, type, label, qcontrol ) \
p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \
...@@ -556,6 +686,29 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -556,6 +686,29 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
* Interface Panel * * Interface Panel *
*******************/ *******************/
START_SPREFS_CAT( Interface, qtr("Interface Settings") ); START_SPREFS_CAT( Interface, qtr("Interface Settings") );
#ifndef _WIN32
ui.langBox->hide();
#else
for( int i = 0; ppsz_language[i] != NULL; i++)
ui.langCombo->addItem( qfu(ppsz_language_text[i]), ppsz_language[i]);
CONNECT( ui.langCombo, currentIndexChanged( int ), this, langChanged( int ) );
HKEY h_key;
char *langReg = NULL;
if( RegOpenKeyEx( HKEY_CURRENT_USER, TEXT("Software\\VideoLAN\\VLC\\"), 0, KEY_READ, &h_key )
== ERROR_SUCCESS )
{
TCHAR szData[256];
DWORD len = 256;
if( RegQueryValueEx( h_key, TEXT("Lang"), NULL, NULL, (LPBYTE) &szData, &len ) == ERROR_SUCCESS ) {
langReg = FromWide( szData );
ui.langCombo->setCurrentIndex( ui.langCombo->findData(langReg) );
}
}
free( langReg);
#endif
// ui.defaultLabel->setFont( italicFont ); // ui.defaultLabel->setFont( italicFont );
ui.skinsLabel->setText( ui.skinsLabel->setText(
qtr( "This is VLC's skinnable interface. You can download other skins at" ) qtr( "This is VLC's skinnable interface. You can download other skins at" )
...@@ -874,7 +1027,9 @@ void SPrefsPanel::apply() ...@@ -874,7 +1027,9 @@ void SPrefsPanel::apply()
if( qobject_cast<QComboBox *>(optionWidgets["styleCB"]) ) if( qobject_cast<QComboBox *>(optionWidgets["styleCB"]) )
getSettings()->setValue( "MainWindow/QtStyle", getSettings()->setValue( "MainWindow/QtStyle",
qobject_cast<QComboBox *>(optionWidgets["styleCB"])->currentText() ); qobject_cast<QComboBox *>(optionWidgets["styleCB"])->currentText() );
#ifdef _WIN32
saveLang();
#endif
break; break;
} }
...@@ -984,6 +1139,11 @@ void SPrefsPanel::changeStyle( QString s_style ) ...@@ -984,6 +1139,11 @@ void SPrefsPanel::changeStyle( QString s_style )
}; };
} }
void SPrefsPanel::langChanged( int i )
{
lang = strdup( ppsz_language[i] );
}
void SPrefsPanel::configML() void SPrefsPanel::configML()
{ {
#ifdef SQL_MEDIA_LIBRARY #ifdef SQL_MEDIA_LIBRARY
...@@ -997,6 +1157,27 @@ void SPrefsPanel::configML() ...@@ -997,6 +1157,27 @@ void SPrefsPanel::configML()
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include "util/registry.hpp" #include "util/registry.hpp"
void SPrefsPanel::cleanLang() {
QVLCRegistry *qvReg = new QVLCRegistry( HKEY_CURRENT_USER );
qvReg->DeleteValue( "Software\\VideoLAN\\VLC\\", "Lang" );
qvReg->DeleteKey( "Software\\VideoLAN\\", "VLC" );
qvReg->DeleteKey( "Software\\", "VideoLAN" );
delete qvReg;
}
void SPrefsPanel::saveLang() {
if( !lang ) return;
if( !strncmp( lang, "auto", 4 ) ) {
cleanLang();
}
else
{
QVLCRegistry *qvReg = new QVLCRegistry( HKEY_CURRENT_USER );
qvReg->WriteRegistryString( "Software\\VideoLAN\\VLC\\", "Lang", lang );
}
}
bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current, bool SPrefsPanel::addType( const char * psz_ext, QTreeWidgetItem* current,
QTreeWidgetItem* parent, QVLCRegistry *qvReg ) QTreeWidgetItem* parent, QVLCRegistry *qvReg )
{ {
......
...@@ -96,6 +96,9 @@ public: ...@@ -96,6 +96,9 @@ public:
virtual ~SPrefsPanel(); virtual ~SPrefsPanel();
void apply(); void apply();
void clean(); void clean();
#ifdef _WIN32
void cleanLang();
#endif
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -107,9 +110,12 @@ private: ...@@ -107,9 +110,12 @@ private:
QStringList qs_filter; QStringList qs_filter;
QButtonGroup *radioGroup; QButtonGroup *radioGroup;
char *lang;
#ifdef _WIN32 #ifdef _WIN32
QList<QTreeWidgetItem *> listAsso; QList<QTreeWidgetItem *> listAsso;
bool addType( const char * psz_ext, QTreeWidgetItem*, QTreeWidgetItem*, QVLCRegistry* ); bool addType( const char * psz_ext, QTreeWidgetItem*, QTreeWidgetItem*, QVLCRegistry* );
void saveLang();
#endif #endif
/* Display only the options for the selected audio output */ /* Display only the options for the selected audio output */
...@@ -117,6 +123,7 @@ private slots: ...@@ -117,6 +123,7 @@ private slots:
void lastfm_Changed( int ); void lastfm_Changed( int );
void updateAudioOptions( int ); void updateAudioOptions( int );
void updateAudioVolume( int ); void updateAudioVolume( int );
void langChanged( int );
#ifdef _WIN32 #ifdef _WIN32
void assoDialog(); void assoDialog();
void saveAsso(); void saveAsso();
......
...@@ -334,6 +334,10 @@ void PrefsDialog::reset() ...@@ -334,6 +334,10 @@ void PrefsDialog::reset()
config_SaveConfigFile( p_intf ); config_SaveConfigFile( p_intf );
getSettings()->clear(); getSettings()->clear();
#ifdef _WIN32
simple_panels[0]->cleanLang();
#endif
accept(); accept();
} }
} }
......
This diff is collapsed.
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