Commit b5260216 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Move uncategorized settings to a private category

parent ac37b124
...@@ -78,12 +78,12 @@ MainWindow::MainWindow( QWidget *parent ) : ...@@ -78,12 +78,12 @@ MainWindow::MainWindow( QWidget *parent ) :
//VLC Instance: //VLC Instance:
LibVLCpp::Instance::getInstance(); LibVLCpp::Instance::getInstance();
//Creating the project manager first (so it can create all the project variables)
GUIProjectManager::getInstance();
//Preferences //Preferences
initVlmcPreferences(); initVlmcPreferences();
//Creating the project manager so it can create all the project variables
GUIProjectManager::getInstance();
// GUI // GUI
DockWidgetManager::getInstance( this )->setMainWindow( this ); DockWidgetManager::getInstance( this )->setMainWindow( this );
createGlobalPreferences(); createGlobalPreferences();
...@@ -128,6 +128,7 @@ MainWindow::MainWindow( QWidget *parent ) : ...@@ -128,6 +128,7 @@ MainWindow::MainWindow( QWidget *parent ) :
connect( Library::getInstance(), SIGNAL( clipRemoved( const QUuid& ) ), connect( Library::getInstance(), SIGNAL( clipRemoved( const QUuid& ) ),
clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) ); clipRenderer, SLOT( clipUnloaded( const QUuid& ) ) );
//FIXME: Lazy init this
// Wizard // Wizard
m_pWizard = new ProjectWizard( this ); m_pWizard = new ProjectWizard( this );
m_pWizard->setModal( true ); m_pWizard->setModal( true );
...@@ -137,12 +138,10 @@ MainWindow::MainWindow( QWidget *parent ) : ...@@ -137,12 +138,10 @@ MainWindow::MainWindow( QWidget *parent ) :
if ( restoreSession() == true ) if ( restoreSession() == true )
return ; return ;
#endif #endif
QSettings s;
// Restore the geometry // Restore the geometry
restoreGeometry( s.value( "MainWindowGeometry" ).toByteArray() ); restoreGeometry( VLMC_GET_BYTEARRAY( "private/MainWindowGeometry" ) );
// Restore the layout // Restore the layout
restoreState( s.value( "MainWindowState" ).toByteArray() ); restoreState( VLMC_GET_BYTEARRAY( "private/MainWindowState" ) );
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -156,9 +155,7 @@ MainWindow::~MainWindow() ...@@ -156,9 +155,7 @@ MainWindow::~MainWindow()
void void
MainWindow::showWizard() MainWindow::showWizard()
{ {
QSettings s; if ( VLMC_GET_BOOL( "private/ShowWizardStartup" ) )
if ( s.value( "ShowWizardStartup", true ).toBool() )
m_pWizard->show(); m_pWizard->show();
} }
...@@ -322,18 +319,31 @@ MainWindow::initVlmcPreferences() ...@@ -322,18 +319,31 @@ MainWindow::initVlmcPreferences()
QT_TRANSLATE_NOOP( "PreferenceWidget", "Proxy Password" ), QT_TRANSLATE_NOOP( "PreferenceWidget", "Proxy Password" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Set Proxy Password, if any." ) ); QT_TRANSLATE_NOOP( "PreferenceWidget", "Set Proxy Password, if any." ) );
// Setup private variables
VLMC_CREATE_PRIVATE_PREFERENCE_BOOL( "private/CleanQuit", true );
VLMC_CREATE_PRIVATE_PREFERENCE_STRING( "private/EmergencyBackup", "" );
VLMC_CREATE_PRIVATE_PREFERENCE_STRING( "private/ImportPreviouslySelectPath", QDir::homePath() );
VLMC_CREATE_PRIVATE_PREFERENCE_BYTEARRAY( "private/MainWindowGeometry", "" );
VLMC_CREATE_PRIVATE_PREFERENCE_BYTEARRAY( "private/MainWindowState", "" );
VLMC_CREATE_PRIVATE_PREFERENCE_STRING( "private/RecentsProjects", "" );
VLMC_CREATE_PRIVATE_PREFERENCE_BOOL( "private/ShowWizardStartup", true );
VLMC_CREATE_PRIVATE_PREFERENCE_STRING( "private/VlmcVersion", PROJECT_VERSION_MAJOR );
//Load saved preferences : //Load saved preferences :
QSettings s; loadVlmcPreferences( "private" );
if ( s.value( "VlmcVersion" ).toString() != PROJECT_VERSION_MAJOR ) if ( VLMC_GET_STRING( "private/VlmcVersion" ) == PROJECT_VERSION_MAJOR )
s.clear();
else
{ {
loadVlmcPreferences( "keyboard" ); loadVlmcPreferences( "keyboard" );
loadVlmcPreferences( "general" ); loadVlmcPreferences( "general" );
loadVlmcPreferences( "youtube" ); loadVlmcPreferences( "youtube" );
loadVlmcPreferences( "network" ); loadVlmcPreferences( "network" );
} }
s.setValue( "VlmcVersion", PROJECT_VERSION_MAJOR ); else
{
QSettings s;
s.clear();
}
SettingsManager::getInstance()->setValue( "private/VlmcVersion", PROJECT_VERSION_MAJOR, SettingsManager::Vlmc );
} }
void void
...@@ -343,8 +353,9 @@ MainWindow::loadVlmcPreferences( const QString &subPart ) ...@@ -343,8 +353,9 @@ MainWindow::loadVlmcPreferences( const QString &subPart )
s.beginGroup( subPart ); s.beginGroup( subPart );
foreach ( QString key, s.allKeys() ) foreach ( QString key, s.allKeys() )
{ {
SettingsManager::getInstance()->setValue( subPart + "/" + key, s.value( key ), QVariant value = s.value( key );
SettingsManager::Vlmc ); vlmcDebug() << "Loading" << key << "=>" << value;
SettingsManager::getInstance()->setValue( subPart + "/" + key, value, SettingsManager::Vlmc );
} }
} }
...@@ -771,13 +782,12 @@ MainWindow::saveSettings() ...@@ -771,13 +782,12 @@ MainWindow::saveSettings()
clearTemporaryFiles(); clearTemporaryFiles();
if ( pm->askForSaveIfModified() ) if ( pm->askForSaveIfModified() )
{ {
QSettings s; SettingsManager* sm = SettingsManager::getInstance();
// Save the current geometry // Save the current geometry
s.setValue( "MainWindowGeometry", saveGeometry() ); sm->setValue( "private/MainWindowGeometry", saveGeometry(), SettingsManager::Vlmc );
// Save the current layout // Save the current layout
s.setValue( "MainWindowState", saveState() ); sm->setValue( "private/MainWindowState", saveState(), SettingsManager::Vlmc );
s.setValue( "CleanQuit", true ); sm->setValue( "private/CleanQuit", true, SettingsManager::Vlmc );
s.sync();
return true; return true;
} }
return false; return false;
...@@ -834,15 +844,9 @@ MainWindow::on_actionCrash_triggered() ...@@ -834,15 +844,9 @@ MainWindow::on_actionCrash_triggered()
bool bool
MainWindow::restoreSession() MainWindow::restoreSession()
{ {
QSettings s; bool cleanQuit = VLMC_GET_BOOL( "private/CleanQuit" );
bool fileCreated = false;
bool ret = false; bool ret = false;
fileCreated = s.contains( "VlmcVersion" );
if ( fileCreated == true )
{
bool cleanQuit = s.value( "CleanQuit", true ).toBool();
if ( cleanQuit == false ) if ( cleanQuit == false )
{ {
QMessageBox::StandardButton res = QMessageBox::question( this, tr( "Crash recovery" ), tr( "VLMC didn't closed nicely. Do you want to recover your project?" ), QMessageBox::StandardButton res = QMessageBox::question( this, tr( "Crash recovery" ), tr( "VLMC didn't closed nicely. Do you want to recover your project?" ),
...@@ -855,9 +859,7 @@ MainWindow::restoreSession() ...@@ -855,9 +859,7 @@ MainWindow::restoreSession()
QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) ); QMessageBox::warning( this, tr( "Can't restore project" ), tr( "VLMC didn't manage to restore your project. We apology for the inconvenience" ) );
} }
} }
} SettingsManager::getInstance()->setValue( "private/CleanQuit", true, SettingsManager::Vlmc );
s.setValue( "CleanQuit", false );
s.sync();
return ret; return ret;
} }
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "MediaListView.h" #include "MediaListView.h"
#include "MetaDataManager.h" #include "MetaDataManager.h"
#include "PreviewWidget.h" #include "PreviewWidget.h"
#include "SettingsManager.h"
#include "TagWidget.h" #include "TagWidget.h"
#include "Transcoder.h" #include "Transcoder.h"
#include "VlmcDebug.h" #include "VlmcDebug.h"
...@@ -288,19 +289,17 @@ ImportController::collapseAllButCurrentPath() ...@@ -288,19 +289,17 @@ ImportController::collapseAllButCurrentPath()
void void
ImportController::saveCurrentPath() ImportController::saveCurrentPath()
{ {
QSettings s; SettingsManager::getInstance()->setValue( "private/ImportPreviouslySelectPath",
s.setValue( "ImportPreviouslySelectPath", m_currentlyWatchedDir ); m_currentlyWatchedDir, SettingsManager::Vlmc );
s.sync();
} }
void void
ImportController::restoreCurrentPath() ImportController::restoreCurrentPath()
{ {
QSettings s; QString path = VLMC_GET_STRING( "private/ImportPreviouslySelectPath" );
QVariant path = s.value( "ImportPreviouslySelectPath", QDir::homePath() ); if ( QFile::exists( path ) == false )
if ( QFile::exists( path.toString() ) == false )
path = QDir::homePath(); path = QDir::homePath();
QFileInfo info = path.toString(); QFileInfo info = path;
m_currentlyWatchedDir = info.absoluteFilePath(); m_currentlyWatchedDir = info.absoluteFilePath();
} }
......
...@@ -35,6 +35,7 @@ TrackControls::TrackControls( GraphicsTrack* track, QWidget *parent ) : ...@@ -35,6 +35,7 @@ TrackControls::TrackControls( GraphicsTrack* track, QWidget *parent ) :
m_ui( new Ui::TrackControls ), m_ui( new Ui::TrackControls ),
m_track( track ) m_track( track )
{ {
//FIXME: This type of things should be in the project settings
QSettings s( QSettings::UserScope, qApp->organizationName(), "timeline" ); QSettings s( QSettings::UserScope, qApp->organizationName(), "timeline" );
if ( track->mediaType() == Workflow::VideoTrack && if ( track->mediaType() == Workflow::VideoTrack &&
s.contains( "video" + QString::number( track->trackNumber() ) ) ) s.contains( "video" + QString::number( track->trackNumber() ) ) )
......
...@@ -217,6 +217,5 @@ WelcomePage::setProjectPath( const QString& path ) ...@@ -217,6 +217,5 @@ WelcomePage::setProjectPath( const QString& path )
void void
WelcomePage::hideWizardAtStartup( bool hidden ) WelcomePage::hideWizardAtStartup( bool hidden )
{ {
QSettings s; SettingsManager::getInstance()->setValue( "private/ShowWizardStartup", !hidden, SettingsManager::Vlmc );
s.setValue( "ShowWizardStartup", !hidden );
} }
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QXmlStreamWriter>
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
...@@ -46,8 +45,7 @@ const QString ProjectManager::backupSuffix = "~"; ...@@ -46,8 +45,7 @@ const QString ProjectManager::backupSuffix = "~";
ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false ) ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
{ {
QSettings s; m_recentsProjects = VLMC_GET_STRINGLIST( "private/RecentsProjects" );
m_recentsProjects = s.value( "RecentsProjects" ).toStringList();
//If the variable was empty, it will return a list with one empty string in it. //If the variable was empty, it will return a list with one empty string in it.
m_recentsProjects.removeAll( "" ); m_recentsProjects.removeAll( "" );
...@@ -176,8 +174,7 @@ ProjectManager::removeProject( const QString& project ) ...@@ -176,8 +174,7 @@ ProjectManager::removeProject( const QString& project )
// Remove all occurence of fileName // Remove all occurence of fileName
m_recentsProjects.removeAll( project ); m_recentsProjects.removeAll( project );
QSettings s; SettingsManager::getInstance()->setValue( "private/RecentsProjects", m_recentsProjects, SettingsManager::Vlmc );
s.setValue( "RecentsProjects", m_recentsProjects );
} }
void void
...@@ -215,9 +212,7 @@ ProjectManager::emergencyBackup() ...@@ -215,9 +212,7 @@ ProjectManager::emergencyBackup()
else else
name = createAutoSaveOutputFileName( QDir::currentPath() + "/unsavedproject" ); name = createAutoSaveOutputFileName( QDir::currentPath() + "/unsavedproject" );
__saveProject( name ); __saveProject( name );
QSettings s; SettingsManager::getInstance()->setValue( "private/EmergencyBackup", name, SettingsManager::Vlmc );
s.setValue( "EmergencyBackup", name );
s.sync();
} }
bool bool
...@@ -288,8 +283,7 @@ ProjectManager::saveAs( const QString &outputFileName ) ...@@ -288,8 +283,7 @@ ProjectManager::saveAs( const QString &outputFileName )
bool bool
ProjectManager::loadEmergencyBackup() ProjectManager::loadEmergencyBackup()
{ {
QSettings s; QString lastProject = VLMC_GET_STRING( "private/EmergencyBackup" );
QString lastProject = s.value( "EmergencyBackup" ).toString();
if ( QFile::exists( lastProject ) == true ) if ( QFile::exists( lastProject ) == true )
{ {
loadProject( lastProject ); loadProject( lastProject );
......
...@@ -46,6 +46,7 @@ class SettingValue : public QObject ...@@ -46,6 +46,7 @@ class SettingValue : public QObject
Language, Language,
KeyboardShortcut, KeyboardShortcut,
Path, Path,
ByteArray, // For now this is only for private variables, and is not expected to be used at any time
//For effect engine settings: //For effect engine settings:
Color, Color,
Position Position
......
...@@ -38,11 +38,13 @@ class QDomElement; ...@@ -38,11 +38,13 @@ class QDomElement;
//Var helpers : //Var helpers :
#define VLMC_GET_STRING( key ) SettingsManager::getInstance()->value( key )->get().toString() #define VLMC_GET_STRING( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toString()
#define VLMC_GET_INT( key ) SettingsManager::getInstance()->value( key )->get().toInt() #define VLMC_GET_INT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toInt()
#define VLMC_GET_UINT( key ) SettingsManager::getInstance()->value( key )->get().toUInt() #define VLMC_GET_UINT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toUInt()
#define VLMC_GET_DOUBLE( key ) SettingsManager::getInstance()->value( key )->get().toDouble() #define VLMC_GET_DOUBLE( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc)->get().toDouble()
#define VLMC_GET_BOOL( key ) SettingsManager::getInstance()->value( key )->get().toBool() #define VLMC_GET_BOOL( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc)->get().toBool()
#define VLMC_GET_STRINGLIST( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toStringList()
#define VLMC_GET_BYTEARRAY( key ) SettingsManager::getInstance()->value( key, SettingsManager::Vlmc )->get().toByteArray()
#define VLMC_PROJECT_GET_STRING( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toString() #define VLMC_PROJECT_GET_STRING( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toString()
#define VLMC_PROJECT_GET_INT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toInt() #define VLMC_PROJECT_GET_INT( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toInt()
...@@ -92,10 +94,15 @@ SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \ ...@@ -92,10 +94,15 @@ SettingsManager::getInstance()->createVar( type, key, defaultValue, name, \
VLMC_CREATE_PREFERENCE( SettingValue::String, key, defaultValue, "", "", SettingValue::Private ) VLMC_CREATE_PREFERENCE( SettingValue::String, key, defaultValue, "", "", SettingValue::Private )
#define VLMC_CREATE_PRIVATE_PREFERENCE_INT( key, defaultValue ) \ #define VLMC_CREATE_PRIVATE_PREFERENCE_INT( key, defaultValue ) \
VLMC_CREATE_PREFERENCE( SettingValue::Int, key, defaultValue, "", "", SettingValue::Private ) VLMC_CREATE_PREFERENCE( SettingValue::Int, key, defaultValue, "", "", SettingValue::Private )
#define VLMC_CREATE_PRIVATE_PROJECT_STRING( key, defaultValue ) \ #define VLMC_CREATE_PRIVATE_PREFERENCE_BOOL( key, defaultValue ) \
VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, "", "", SettingValue::Private ) VLMC_CREATE_PREFERENCE( SettingValue::Bool, key, defaultValue, "", "", SettingValue::Private )
#define VLMC_CREATE_PRIVATE_PREFERENCE_BYTEARRAY( key, defaultValue ) \
VLMC_CREATE_PREFERENCE( SettingValue::ByteArray, key, defaultValue, "", "", SettingValue::Private )
#define VLMC_CREATE_PREFERENCE_PASSWORD( key, defaultValue, name, desc ) \ #define VLMC_CREATE_PREFERENCE_PASSWORD( key, defaultValue, name, desc ) \
VLMC_CREATE_PREFERENCE( SettingValue::String, key, defaultValue, name, desc, SettingValue::Password ) VLMC_CREATE_PREFERENCE( SettingValue::String, key, defaultValue, name, desc, SettingValue::Password )
#define VLMC_CREATE_PRIVATE_PROJECT_STRING( key, defaultValue ) \
VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, "", "", SettingValue::Private )
class SettingsManager : public QObject, public Singleton<SettingsManager> class SettingsManager : public QObject, public Singleton<SettingsManager>
......
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