From: Jean-Baptiste Kempf Date: Sat, 19 Jan 2008 07:52:53 +0000 (+0000) Subject: Qt4 - Prepare the work for file association from the interface. X-Git-Tag: 0.9.0-test0~3366 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=61fc0c2faabf6c6216721c0a1c55839b9b16eea0;p=vlc Qt4 - Prepare the work for file association from the interface. Ref #763. --- diff --git a/modules/gui/qt4/components/simple_preferences.cpp b/modules/gui/qt4/components/simple_preferences.cpp index 5f849d0561..a7827c0126 100644 --- a/modules/gui/qt4/components/simple_preferences.cpp +++ b/modules/gui/qt4/components/simple_preferences.cpp @@ -396,9 +396,12 @@ SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, #if defined( WIN32 ) || defined (__APPLE__) CONFIG_GENERIC( "language", StringList, NULL, language ); + BUTTONACT( ui.assoButton, assoDialog ); #else ui.language->hide(); ui.languageLabel->hide(); + ui.assoName->hide(); + ui.assoButton->hide(); #endif /* interface */ @@ -621,3 +624,8 @@ void SPrefsPanel::lastfm_Changed( int i_state ) else if( i_state == Qt::Unchecked ) config_RemoveIntf( VLC_OBJECT( p_intf ), "audioscrobbler" ); } + +void SPrefsPanel::assoDialog() +{ + +} diff --git a/modules/gui/qt4/components/simple_preferences.hpp b/modules/gui/qt4/components/simple_preferences.hpp index 004737e83f..7e249836cc 100644 --- a/modules/gui/qt4/components/simple_preferences.hpp +++ b/modules/gui/qt4/components/simple_preferences.hpp @@ -100,6 +100,7 @@ private: private slots: void lastfm_Changed( int ); void updateAudioOptions( int ); + void assoDialog(); }; #endif diff --git a/modules/gui/qt4/ui/sprefs_interface.ui b/modules/gui/qt4/ui/sprefs_interface.ui index fd1f3aa6af..3612ef094b 100644 --- a/modules/gui/qt4/ui/sprefs_interface.ui +++ b/modules/gui/qt4/ui/sprefs_interface.ui @@ -5,8 +5,8 @@ 0 0 - 445 - 535 + 485 + 578 @@ -136,21 +136,41 @@ _("Instances") - - + + _("Allow only one instance") - + _("Enqueue files in playlist when in one instance mode") + + + + _("File associations:") + + + + + + + + 0 + 0 + + + + _("Association Setup") + + + diff --git a/modules/gui/qt4/util/registry.cpp b/modules/gui/qt4/util/registry.cpp new file mode 100644 index 0000000000..af47deda89 --- /dev/null +++ b/modules/gui/qt4/util/registry.cpp @@ -0,0 +1,128 @@ +// License GPLv2+ + +#include "registry.hpp" + +QVLCRegistry::QVLCRegistry(HKEY rootKey) +{ + this->m_RootKey = rootKey; +} + +QVLCRegistry::~QVLCRegistry(void) +{ +} + +int QVLCRegistry::RegistryKeyExists(char *path) { + HKEY keyHandle; + if( RegOpenKeyEx(m_RootKey, path, 0, KEY_READ, &keyHandle) == ERROR_SUCCESS) { + RegCloseKey(keyHandle); + return 1; + } + return 0; +} + +int QVLCRegistry::RegistryValueExists(char *path, char *valueName) { + HKEY keyHandle; + int temp = 0; + DWORD size1; + DWORD valueType; + + if( RegOpenKeyEx(m_RootKey, path, 0, KEY_READ, &keyHandle) == ERROR_SUCCESS) { + if(RegQueryValueEx( keyHandle, valueName, NULL, &valueType, NULL, &size1) == ERROR_SUCCESS) { + temp = 1; + } + RegCloseKey(keyHandle); + } + return temp; +} + +void QVLCRegistry::WriteRegistryInt(char *path, char *valueName, int value) { + HKEY keyHandle; + + if( RegCreateKeyEx(m_RootKey, path, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &keyHandle, NULL) == ERROR_SUCCESS) { + RegSetValueEx(keyHandle,valueName,0,REG_DWORD,(LPBYTE)&value,sizeof(int)); + RegCloseKey(keyHandle); + } + +} + +void QVLCRegistry::WriteRegistryString(char *path, char *valueName, char *value) { + HKEY keyHandle; + + if( RegCreateKeyEx(m_RootKey, path, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &keyHandle, NULL) == ERROR_SUCCESS) { + RegSetValueEx(keyHandle,valueName,0,REG_SZ,(LPBYTE)value,(DWORD)(strlen(value)+1)); + RegCloseKey(keyHandle); + } +} + +void QVLCRegistry::WriteRegistryDouble(char *path, char *valueName, double value) { + HKEY keyHandle; + if( RegCreateKeyEx(m_RootKey, path, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &keyHandle, NULL) == ERROR_SUCCESS) { + RegSetValueEx(keyHandle,valueName,0,REG_BINARY,(LPBYTE)&value,sizeof(double)); + RegCloseKey(keyHandle); + } +} + +int QVLCRegistry::ReadRegistryInt(char *path, char *valueName, int default_value) { + HKEY keyHandle; + int tempValue; + DWORD size1; + DWORD valueType; + + if( RegOpenKeyEx(m_RootKey, path, 0, KEY_READ, &keyHandle) == ERROR_SUCCESS) { + if(RegQueryValueEx( keyHandle, valueName, NULL, &valueType, NULL, &size1) == ERROR_SUCCESS) { + if(valueType == REG_DWORD) { + if(RegQueryValueEx( keyHandle, valueName, NULL, &valueType, (LPBYTE)&tempValue, &size1) == ERROR_SUCCESS) { + default_value = tempValue; + }; + } + } + RegCloseKey(keyHandle); + } + return default_value; +} + +char * QVLCRegistry::ReadRegistryString(char *path, char *valueName, char *default_value) { + HKEY keyHandle; + char *tempValue = NULL; + DWORD size1; + DWORD valueType; + + if( RegOpenKeyEx(m_RootKey, path, 0, KEY_READ, &keyHandle) == ERROR_SUCCESS) { + if(RegQueryValueEx( keyHandle, valueName, NULL, &valueType, NULL, &size1) == ERROR_SUCCESS) { + if(valueType == REG_SZ) { + // free + tempValue = (char *)malloc(size1+1); // +1 für NullByte`? + if(RegQueryValueEx( keyHandle, valueName, NULL, &valueType, (LPBYTE)tempValue, &size1) == ERROR_SUCCESS) { + default_value = tempValue; + }; + } + } + RegCloseKey(keyHandle); + } + if(tempValue == NULL) { + // wenn tempValue nicht aus registry gelesen wurde dafür sorgen das ein neuer String mit der Kopie von DefaultValue + // geliefert wird - das macht das Handling des Rückgabewertes der Funktion einfacher - immer schön mit free freigeben! + default_value = strdup(default_value); + } + + return default_value; +} + +double QVLCRegistry::ReadRegistryDouble(char *path, char *valueName, double default_value) { + HKEY keyHandle; + double tempValue; + DWORD size1; + DWORD valueType; + + if( RegOpenKeyEx(m_RootKey, path, 0, KEY_READ, &keyHandle) == ERROR_SUCCESS) { + if(RegQueryValueEx( keyHandle, valueName, NULL, &valueType, NULL, &size1) == ERROR_SUCCESS) { + if((valueType == REG_BINARY) && (size1 == sizeof(double))) { + if(RegQueryValueEx( keyHandle, valueName, NULL, &valueType, (LPBYTE)&tempValue, &size1) == ERROR_SUCCESS) { + default_value = tempValue; + }; + } + } + RegCloseKey(keyHandle); + } + return default_value; +} diff --git a/modules/gui/qt4/util/registry.hpp b/modules/gui/qt4/util/registry.hpp new file mode 100644 index 0000000000..c3032bd786 --- /dev/null +++ b/modules/gui/qt4/util/registry.hpp @@ -0,0 +1,30 @@ +// License GPLv2 or later +// Code from ATMO + +#ifndef QVLC_REGISTRY_H +#define QVLC_REGISTRY_H + +#include + +class QVLCRegistry +{ +private: + HKEY m_RootKey; + char m_pathBuffer[256]; +public: + QVLCRegistry(HKEY rootKey); + ~QVLCRegistry(void); + + void WriteRegistryInt(char *path, char *valueName, int value); + void WriteRegistryString(char *path, char *valueName, char *value); + void WriteRegistryDouble(char *path, char *valueName, double value); + + int ReadRegistryInt(char *path, char *valueName, int default_value); + char * ReadRegistryString(char *path, char *valueName, char *default_value); + double ReadRegistryDouble(char *path, char *valueName, double default_value); + + int RegistryKeyExists(char *path); + int RegistryValueExists(char *path, char *valueName); +}; + +#endif