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();
} }
} }
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>733</width> <width>686</width>
<height>548</height> <height>656</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
...@@ -20,116 +20,30 @@ ...@@ -20,116 +20,30 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin"> <item>
<number>9</number> <widget class="QGroupBox" name="langBox">
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="2" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox_2">
<property name="title"> <property name="title">
<string>Privacy / Network Interaction</string> <string>Language</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout">
<item row="2" column="1"> <item>
<spacer name="horizontalSpacer_2"> <widget class="QLabel" name="label">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="updatesDays">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> days</string>
</property>
<property name="prefix">
<string>Every </string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="filterLabel">
<property name="text"> <property name="text">
<string>Filter:</string> <string>Menus language:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="margin">
<number>5</number>
</property> </property>
<property name="buddy"> <property name="buddy">
<cstring>recentlyPlayedFilters</cstring> <cstring>langCombo</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3" colspan="2"> <item>
<widget class="QLineEdit" name="recentlyPlayedFilters"> <widget class="QComboBox" name="langCombo"/>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Separate words by | (without space)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="saveRecentlyPlayed">
<property name="minimumSize">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Save recently played items</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="updatesBox">
<property name="minimumSize">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Activate updates notifier</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="0" colspan="2"> <item>
<widget class="QGroupBox" name="LooknfeelBox"> <widget class="QGroupBox" name="LooknfeelBox">
<property name="title"> <property name="title">
<string>Look and feel</string> <string>Look and feel</string>
...@@ -404,7 +318,16 @@ ...@@ -404,7 +318,16 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QGridLayout" name="gridLayout_7"> <layout class="QGridLayout" name="gridLayout_7">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="1" column="1"> <item row="1" column="1">
...@@ -487,7 +410,176 @@ ...@@ -487,7 +410,176 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item>
<widget class="QGroupBox" name="OneInterfaceBox">
<property name="title">
<string>Playlist and Instances</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="0">
<widget class="QLabel" name="artFetchLabel">
<property name="minimumSize">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Album art download policy:</string>
</property>
<property name="buddy">
<cstring>artFetcher</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="treePlaylist">
<property name="text">
<string>Display playlist tree</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="EnqueueOneInterfaceMode">
<property name="text">
<string>Enqueue items into playlist in one instance mode</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="playPauseBox">
<property name="text">
<string>Pause on the last frame of a video</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="OneInterfaceMode">
<property name="text">
<string>Allow only one instance</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="artFetcher"/>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="sqlMLbtn">
<property name="text">
<string>Configure Media Library</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="oneInstanceFromFile">
<property name="text">
<string>Use only one instance when started from file manager</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Privacy / Network Interaction</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="2" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="updatesDays">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> days</string>
</property>
<property name="prefix">
<string>Every </string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="filterLabel">
<property name="text">
<string>Filter:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="margin">
<number>5</number>
</property>
<property name="buddy">
<cstring>recentlyPlayedFilters</cstring>
</property>
</widget>
</item>
<item row="2" column="3" colspan="2">
<widget class="QLineEdit" name="recentlyPlayedFilters">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Separate words by | (without space)</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="saveRecentlyPlayed">
<property name="minimumSize">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Save recently played items</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="updatesBox">
<property name="minimumSize">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Activate updates notifier</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="osGroupBox"> <widget class="QGroupBox" name="osGroupBox">
<property name="title"> <property name="title">
<string>Operating System Integration</string> <string>Operating System Integration</string>
...@@ -560,76 +652,6 @@ ...@@ -560,76 +652,6 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="OneInterfaceBox">
<property name="title">
<string>Playlist and Instances</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="0">
<widget class="QLabel" name="artFetchLabel">
<property name="minimumSize">
<size>
<width>220</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Album art download policy:</string>
</property>
<property name="buddy">
<cstring>artFetcher</cstring>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="treePlaylist">
<property name="text">
<string>Display playlist tree</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="EnqueueOneInterfaceMode">
<property name="text">
<string>Enqueue items into playlist in one instance mode</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="playPauseBox">
<property name="text">
<string>Pause on the last frame of a video</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="OneInterfaceMode">
<property name="text">
<string>Allow only one instance</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="artFetcher"/>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="sqlMLbtn">
<property name="text">
<string>Configure Media Library</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="oneInstanceFromFile">
<property name="text">
<string>Use only one instance when started from file manager</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
......
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