Commit 25b21537 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Keyboard shortcut widget is automatically generated.

parent 9eefcff5
......@@ -43,6 +43,7 @@ SET(VLMC_SRCS
Gui/library/MediaListViewController.cpp
Gui/library/StackViewController.cpp
Gui/library/StackViewNavController.cpp
Gui/settings/KeyboardShortcut.cpp
Gui/settings/KeyboardShortcutInput.cpp
Gui/settings/Panel.cpp
Gui/settings/PreferenceWidget.cpp
......@@ -124,6 +125,8 @@ SET (VLMC_HDRS
Gui/MainWindow.h
Gui/PreviewRuler.h
Gui/PreviewWidget.h
Gui/settings/ISettingsCategorieWidget.h
Gui/settings/KeyboardShortcut.h
Gui/settings/KeyboardShortcutInput.h
Gui/settings/Panel.h
Gui/settings/PreferenceWidget.h
......
......@@ -23,12 +23,13 @@
#include "SettingValue.h"
#include <QtDebug>
SettingValue::SettingValue( const QVariant& defaultValue, const QString &name,
const QString& desc ) :
SettingValue::SettingValue( SettingValue::Type type, const QVariant& defaultValue,
const QString &name, const QString& desc ) :
m_val( defaultValue ),
m_defaultVal( defaultValue ),
m_name( name ),
m_desc( desc )
m_desc( desc ),
m_type( type )
{
}
......@@ -65,3 +66,9 @@ SettingValue::name() const
{
return m_name;
}
SettingValue::Type
SettingValue::type() const
{
return m_type;
}
......@@ -37,13 +37,22 @@ class SettingValue : public QObject
Q_OBJECT
Q_DISABLE_COPY( SettingValue );
public:
enum Type
{
Int,
Double,
String,
Bool,
Language,
KeyboardShortcut
};
/**
* \brief Constructs a setting value with its default value and description
*
* \param defaultValue The setting default value.
* \param desc The setting description
*/
SettingValue( const QVariant& defaultValue, const QString& name,
SettingValue( Type type, const QVariant& defaultValue, const QString& name,
const QString& desc );
/**
......@@ -67,6 +76,8 @@ class SettingValue : public QObject
void restoreDefault();
const QString &name() const;
Type type() const;
private:
/**
* \brief the QVariant containingthe value of the settings
......@@ -75,6 +86,7 @@ class SettingValue : public QObject
QVariant m_defaultVal;
QString m_name;
QString m_desc;
Type m_type;
signals:
/**
* \brief This signal is emmited while the m_val
......
......@@ -100,11 +100,11 @@ SettingsManager::value( const QString &key,
return NULL;
}
QHash<QString, QVariant>
SettingsManager::SettingHash
SettingsManager::group( const QString &groupName, SettingsManager::Type type )
{
QHash<QString, QVariant> ret;
QReadLocker rl( &m_rwLock );
SettingsManager::SettingHash ret;
QReadLocker rl( &m_rwLock );
QString grp = groupName + '/';
if ( type == Project )
......@@ -115,7 +115,7 @@ SettingsManager::group( const QString &groupName, SettingsManager::Type type )
for ( ; it != ed; ++it )
{
if ( it.key().startsWith( grp ) )
ret.insert( it.key(), it.value()->get() );
ret.insert( it.key(), it.value() );
}
}
else if ( type == Vlmc )
......@@ -127,7 +127,7 @@ SettingsManager::group( const QString &groupName, SettingsManager::Type type )
{
if ( it.key().startsWith( grp ) )
{
ret.insert( it.key(), it.value()->get() );
ret.insert( it.key(), it.value() );
}
}
}
......@@ -276,16 +276,16 @@ SettingsManager::commit( SettingsManager::Type type )
}
void
SettingsManager::createVar( const QString &key, const QVariant &defaultValue,
const QString &name, const QString &desc,
SettingsManager::Type type /*= Vlmc*/ )
SettingsManager::createVar( SettingValue::Type type, const QString &key,
const QVariant &defaultValue, const QString &name,
const QString &desc, SettingsManager::Type varType /*= Vlmc*/ )
{
QWriteLocker wlock( &m_rwLock );
if ( type == Vlmc && m_classicSettings.contains( key ) == false )
m_classicSettings.insert( key, new SettingValue( defaultValue, name, desc ) );
else if ( type == Project && m_xmlSettings.contains( key ) == false )
m_xmlSettings.insert( key, new SettingValue( defaultValue, name, desc ) );
if ( varType == Vlmc && m_classicSettings.contains( key ) == false )
m_classicSettings.insert( key, new SettingValue( type, defaultValue, name, desc ) );
else if ( varType == Project && m_xmlSettings.contains( key ) == false )
m_xmlSettings.insert( key, new SettingValue( type, defaultValue, name, desc ) );
else
Q_ASSERT_X( false, __FILE__, "creating an already created variable" );
}
......
......@@ -52,13 +52,36 @@ class QDomDocument;
#define VLMC_PROJECT_GET_BOOL( key ) SettingsManager::getInstance()->value( key, SettingsManager::Project )->get().toBool()
#define VLMC_CREATE_PROJECT_VAR( key, defaultValue, name, desc ) \
SettingsManager::getInstance()->createVar( key, defaultValue, QObject::tr( name ), \
#define VLMC_CREATE_PROJECT_VAR( type, key, defaultValue, name, desc ) \
SettingsManager::getInstance()->createVar( type, key, defaultValue, QObject::tr( name ), \
QObject::tr(desc), SettingsManager::Project );
#define VLMC_CREATE_PREFERENCE( key, defaultValue, name, desc ) \
SettingsManager::getInstance()->createVar( key, defaultValue, QObject::tr( name ), \
#define VLMC_CREATE_PROJECT_INT( key, defaultValue, name, desc ) \
VLMC_CREATE_PROJECT_VAR( SettingValue::Int, key, defaultValue, name, desc )
#define VLMC_CREATE_PROJECT_STRING( key, defaultValue, name, desc ) \
VLMC_CREATE_PROJECT_VAR( SettingValue::String, key, defaultValue, name, desc )
#define VLMC_CREATE_PROJECT_DOUBLE( key, defaultValue, name, desc ) \
VLMC_CREATE_PROJECT_VAR( SettingValue::Double, key, defaultValue, name, desc )
#define VLMC_CREATE_PROJECT_BOOL( key, defaultValue, name, desc ) \
VLMC_CREATE_PROJECT_VAR( SettingValue::Bool, key, defaultValue, name, desc )
#define VLMC_CREATE_PREFERENCE( type, key, defaultValue, name, desc ) \
SettingsManager::getInstance()->createVar( type, key, defaultValue, QObject::tr( name ), \
QObject::tr(desc), SettingsManager::Vlmc );
#define VLMC_CREATE_PREFERENCE_INT( key, defaultValue, name, desc ) \
VLMC_CREATE_PREFERENCE( SettingValue::Int, key, defaultValue, name, desc )
#define VLMC_CREATE_PREFERENCE_STRING( key, defaultValue, name, desc ) \
VLMC_CREATE_PREFERENCE( SettingValue::String, key, defaultValue, name, desc )
#define VLMC_CREATE_PREFERENCE_DOUBLE( key, defaultValue, name, desc ) \
VLMC_CREATE_PREFERENCE( SettingValue::Double, key, defaultValue, name, desc )
#define VLMC_CREATE_PREFERENCE_LANGUAGE( key, defaultValue, name, desc ) \
VLMC_CREATE_PREFERENCE( SettingValue::Language, key, defaultValue, name, desc )
#define VLMC_CREATE_PREFERENCE_KEYBOARD( key, defaultValue, name, desc ) \
VLMC_CREATE_PREFERENCE( SettingValue::KeyboardShortcut, key, defaultValue, name, desc )
#define VLMC_CREATE_PREFERENCE_BOOL( key, defaultValue, name, desc ) \
VLMC_CREATE_PREFERENCE( SettingValue::Bool, key, defaultValue, name, desc )
class SettingsManager : public QObject, public Singleton<SettingsManager>
{
Q_OBJECT
......@@ -79,13 +102,13 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
SettingsManager::Type = Vlmc);
SettingValue *value( const QString &key,
SettingsManager::Type type = Vlmc );
QHash<QString, QVariant> group( const QString &groupName,
SettingsManager::Type type = Vlmc );
SettingHash group( const QString &groupName,
SettingsManager::Type type = Vlmc );
void createVar( const QString &key,
void createVar( SettingValue::Type type, const QString &key,
const QVariant &defaultValue,
const QString &name, const QString &desc,
Type type = Vlmc );
Type varType = Vlmc );
bool watchValue( const QString &key,
QObject* receiver,
const char *method,
......
......@@ -166,26 +166,26 @@ void MainWindow::changeEvent( QEvent *e )
void
MainWindow::initVlmcPreferences()
{
VLMC_CREATE_PREFERENCE( "keyboard/defaultmode", "n", "Select mode", "Select the selection tool in the timeline" );
VLMC_CREATE_PREFERENCE( "keyboard/cutmode", "x", "Cut mode", "Select the cut/razor tool in the timeline" );
VLMC_CREATE_PREFERENCE( "keyboard/mediapreview", "Ctrl+Return", "Media preview", "Preview the selected media, or pause the current preview" );
VLMC_CREATE_PREFERENCE( "keyboard/renderpreview", "Space", "Render preview", "Preview the project, or pause the current preview" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/defaultmode", "n", "Select mode", "Select the selection tool in the timeline" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/cutmode", "x", "Cut mode", "Select the cut/razor tool in the timeline" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/mediapreview", "Ctrl+Return", "Media preview", "Preview the selected media, or pause the current preview" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/renderpreview", "Space", "Render preview", "Preview the project, or pause the current preview" );
//A bit nasty, but we better use what Qt's providing as default shortcut
VLMC_CREATE_PREFERENCE( "keyboard/undo", QKeySequence( QKeySequence::Undo ).toString().toLocal8Bit(), "Undo", "Undo the last action" );
VLMC_CREATE_PREFERENCE( "keyboard/redo", QKeySequence( QKeySequence::Redo ).toString().toLocal8Bit(), "Redo", "Redo the last action" );
VLMC_CREATE_PREFERENCE( "keyboard/help", QKeySequence( QKeySequence::HelpContents ).toString().toLocal8Bit(), "Help", "Toggle the help page" );
VLMC_CREATE_PREFERENCE( "keyboard/quit", "Ctrl+Q", "Quit", "Quit VLMC" );
VLMC_CREATE_PREFERENCE( "keyboard/preferences", "Alt+P", "Preferences", "Open VLMC preferences" );
VLMC_CREATE_PREFERENCE( "keyboard/fullscreen", "F", "Fullscreen", "Switch to fullscreen mode" );
VLMC_CREATE_PREFERENCE( "keyboard/newproject", QKeySequence( QKeySequence::New ).toString().toLocal8Bit(), "New project", "Open the new project wizzard" );
VLMC_CREATE_PREFERENCE( "keyboard/openproject", QKeySequence( QKeySequence::Open ).toString().toLocal8Bit(), "Open a project", "Open an existing project" );
VLMC_CREATE_PREFERENCE( "keyboard/save", QKeySequence( QKeySequence::Save ).toString().toLocal8Bit(), "Save", "Save the current project" );
VLMC_CREATE_PREFERENCE( "keyboard/saveas", "Ctrl+Shift+S", "Save as", "Save the current project to a new file" );
VLMC_CREATE_PREFERENCE( "keyboard/closeproject", QKeySequence( QKeySequence::Close ).toString().toLocal8Bit(), "Close the project", "Close the current project" );
VLMC_CREATE_PREFERENCE( "keyboard/importmedia", "Ctrl+I", "Import media", "Open the import window" );
VLMC_CREATE_PREFERENCE( "keyboard/renderproject", "Ctrl+R", "Render the project", "Render the project to a file" );
VLMC_CREATE_PREFERENCE( "global/VLMCLang", "en_US", "Langage", "The VLMC's UI language" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/undo", QKeySequence( QKeySequence::Undo ).toString().toLocal8Bit(), "Undo", "Undo the last action" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/redo", QKeySequence( QKeySequence::Redo ).toString().toLocal8Bit(), "Redo", "Redo the last action" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/help", QKeySequence( QKeySequence::HelpContents ).toString().toLocal8Bit(), "Help", "Toggle the help page" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/quit", "Ctrl+Q", "Quit", "Quit VLMC" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/preferences", "Alt+P", "Preferences", "Open VLMC preferences" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/fullscreen", "F", "Fullscreen", "Switch to fullscreen mode" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/newproject", QKeySequence( QKeySequence::New ).toString().toLocal8Bit(), "New project", "Open the new project wizzard" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/openproject", QKeySequence( QKeySequence::Open ).toString().toLocal8Bit(), "Open a project", "Open an existing project" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/save", QKeySequence( QKeySequence::Save ).toString().toLocal8Bit(), "Save", "Save the current project" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/saveas", "Ctrl+Shift+S", "Save as", "Save the current project to a new file" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/closeproject", QKeySequence( QKeySequence::Close ).toString().toLocal8Bit(), "Close the project", "Close the current project" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/importmedia", "Ctrl+I", "Import media", "Open the import window" );
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/renderproject", "Ctrl+R", "Render the project", "Render the project to a file" );
VLMC_CREATE_PREFERENCE_LANGUAGE( "global/VLMCLang", "en_US", "Langage", "The VLMC's UI language" );
}
void MainWindow::setupLibrary()
......@@ -337,18 +337,12 @@ void MainWindow::initializeDockWidgets( void )
void MainWindow::createGlobalPreferences()
{
m_globalPreferences = new Settings( this );
// m_globalPreferences->addWidget( tr ( "VLMC" ),
// new VLMCPreferences( m_globalPreferences ),
// QIcon( ":/images/images/vlmc.png" ),
// tr ( "VLMC settings" ) );
// m_globalPreferences->addWidget( tr ("Language preferences" ),
// new LanguagePreferences( m_globalPreferences ),
// QIcon( ":/images/images/vlmc.png" ),
// tr ( "Language settings" ) );
// m_globalPreferences->addWidget( tr ("Keyboard" ),
// new KeyboardShortcut( m_globalPreferences ),
// QIcon( ":/images/keyboard" ),
// tr( "Keyboard Settings" ) );
m_globalPreferences->addCategorie( "general", SettingsManager::Vlmc,
QIcon( ":/images/images/vlmc.png" ),
tr ( "VLMC settings" ) );
m_globalPreferences->addCategorie( "keyboard", SettingsManager::Vlmc,
QIcon( ":/images/keyboard" ),
tr( "Keyboard Settings" ) );
}
void MainWindow::createProjectPreferences()
......
/*****************************************************************************
* ISettingsCategorieWidget.h: Common interface for settings widgets.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef ISETTINGSCATEGORIEWIDGET_H
#define ISETTINGSCATEGORIEWIDGET_H
class QVariant;
class QWidget;
class ISettingsCategorieWidget
{
public:
virtual QWidget* widget() = 0;
virtual void save() = 0;
};
#endif // ISETTINGSCATEGORIEWIDGET_H
/*****************************************************************************
* KeyboardShortcut.h: Handle KeyboardShortcut setting type.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "KeyboardShortcut.h"
#include "KeyboardShortcutInput.h"
#include "SettingValue.h"
KeyboardShortcut::KeyboardShortcut( SettingValue *s, QWidget *parent /*= NULL*/ ) :
m_setting( s )
{
m_input = new KeyboardShortcutInput( s->name(), s->get().toString(), parent );
}
QWidget*
KeyboardShortcut::widget()
{
return m_input;
}
void
KeyboardShortcut::save()
{
m_setting->set( m_input->shortcut() );
}
/*****************************************************************************
* KeyboardShortcut.cpp: Handle KeyboardShortcut setting type.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzee-Luyssen <hugo@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef KEYBOARDSHORTCUT_H
#define KEYBOARDSHORTCUT_H
#include "ISettingsCategorieWidget.h"
#include <stddef.h>
class KeyboardShortcutInput;
class SettingValue;
class KeyboardShortcut : public ISettingsCategorieWidget
{
public:
KeyboardShortcut( SettingValue *s, QWidget *parent = NULL );
QWidget* widget();
void save();
private:
SettingValue *m_setting;
KeyboardShortcutInput *m_input;
};
#endif // KEYBOARDSHORTCUT_H
......@@ -25,6 +25,7 @@
#include <QTimer>
#include <QtDebug>
#include "SettingsManager.h"
#include "KeyboardShortcutInput.h"
KeyboardShortcutInput::KeyboardShortcutInput( const QString& name,
......@@ -57,6 +58,13 @@ void KeyboardShortcutInput::mouseReleaseEvent( QMouseEvent* )
{
}
QString
KeyboardShortcutInput::shortcut() const
{
QKeySequence seq( m_shortcuts[0], m_shortcuts[1], m_shortcuts[2], m_shortcuts[3] );
return seq.toString();
}
void KeyboardShortcutInput::release()
{
QKeySequence seq( m_shortcuts[0], m_shortcuts[1], m_shortcuts[2], m_shortcuts[3] );
......@@ -64,7 +72,6 @@ void KeyboardShortcutInput::release()
m_capturing = false;
setDown( false );
setText( seq.toString() );
emit changed( m_name, seq.toString() );
}
void KeyboardShortcutInput::cancel()
......
......@@ -33,7 +33,9 @@ class KeyboardShortcutInput : public QPushButton
public:
KeyboardShortcutInput( const QString& name, const QString& initialValue = QString(), QWidget* parent = NULL );
protected:
QString shortcut() const;
protected:
virtual void keyPressEvent( QKeyEvent* e );
virtual void mousePressEvent( QMouseEvent* e );
virtual void mouseReleaseEvent( QMouseEvent* e );
......@@ -50,8 +52,6 @@ class KeyboardShortcutInput : public QPushButton
unsigned int m_current;
int m_shortcuts[4];
int m_initialValue[4];
signals:
void changed( const QString&, const QString& );
};
#endif // KEYBOARDSHORTCUTINPUT_H
......@@ -21,19 +21,59 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "ISettingsCategorieWidget.h"
#include "PreferenceWidget.h"
#include "SettingsManager.h"
#include "KeyboardShortcut.h"
#include <QFormLayout>
#include <QtDebug>
#include <QWidget>
#include "PreferenceWidget.h"
#include <QLabel>
PreferenceWidget::PreferenceWidget( const QString &categorie, SettingsManager::Type type,
QWidget *parent ) :
QWidget( parent ),
m_categorie( categorie )
{
SettingsManager::SettingHash settings =
SettingsManager::getInstance()->group( categorie, type );
QFormLayout *layout = new QFormLayout( this );
foreach ( SettingValue* s, settings.values() )
{
ISettingsCategorieWidget *widget = widgetFactory( s );
if ( widget == NULL )
layout->addRow( s->name(), new QLabel( s->description() ) );
else
{
layout->addRow( s->name(), widget->widget() );
m_settings.push_back( widget );
}
}
PreferenceWidget::PreferenceWidget( QWidget* parent )
: QWidget( parent )
setLayout( layout );
}
ISettingsCategorieWidget*
PreferenceWidget::widgetFactory( SettingValue *s )
{
switch ( s->type() )
{
case SettingValue::KeyboardShortcut:
return new KeyboardShortcut( s, this );
default:
return NULL;
}
}
void
PreferenceWidget::load()
{
}
void
PreferenceWidget::loadThemAll( const QString& part,
bool defaults)
PreferenceWidget::save()
{
load();
foreach ( ISettingsCategorieWidget* w, m_settings )
w->save();
}
......@@ -26,20 +26,28 @@
#include <QWidget>
#include <QString>
#include "SettingsManager.h"
class ISettingsCategorieWidget;
class SettingValue;
class PreferenceWidget : public QWidget
{
Q_OBJECT
public:
PreferenceWidget( QWidget* parent = 0 );
typedef QList<ISettingsCategorieWidget*> SettingsList;
PreferenceWidget( const QString& categorie, SettingsManager::Type type,
QWidget* parent = 0 );
virtual ~PreferenceWidget() {}
virtual void load() = 0;
virtual void save() = 0;
virtual void load();
virtual void save();
private:
ISettingsCategorieWidget *widgetFactory( SettingValue* s );
protected slots:
void loadThemAll( const QString& part = "default",
bool defaults = false );
private:
QString m_categorie;
SettingsList m_settings;
};
#endif
......@@ -66,18 +66,15 @@ Settings::~Settings()
{
}
void Settings::addWidget( const QString& name,
PreferenceWidget* pWidget,
void Settings::addCategorie( const QString& name,
SettingsManager::Type type,
const QIcon& icon,
const QString& label )
{
connect( this, SIGNAL( loadSettings() ), pWidget, SLOT( loadThemAll() ) );
PreferenceWidget *pWidget = new PreferenceWidget( name, type, this );
// We don't want the widget to be visible
pWidget->hide();
// Save the widget name into a property
pWidget->setProperty( "name", name );
// Add the widget to the list
m_pWidgets.append( pWidget );
......@@ -128,10 +125,6 @@ QHBoxLayout* Settings::buildLayout()
return hLayout;
}
void Settings::save( void )
{
}
void Settings::buttonClicked( QAbstractButton* button )
{
bool save = false;
......@@ -159,7 +152,8 @@ void Settings::buttonClicked( QAbstractButton* button )
m_pWidgets.at( i )->save();
}
if ( hide == true ) setVisible( false );
if ( hide == true )
setVisible( false );
}
void Settings::switchWidget( int index )
......@@ -167,15 +161,8 @@ void Settings::switchWidget( int index )
PreferenceWidget* pWidget = m_pWidgets.at( index );
// This should never happen
if ( !pWidget ) return;
QString name( pWidget->property( "name" ).toString() );
// Set the panel name
m_title->setText( name );
// Also set the window title accordingly
setWindowTitle( tr( "Preferences: %1" ).arg( name ) );
if ( !pWidget )
return;
// If there is already a widget into the QScrollArea take it
// to avoid its deletion.
......
......@@ -36,8 +36,8 @@ class QHBoxLayout;
class QAbstractButton;
class QScrollArea;
class Panel;
class PreferenceWidget;
class Panel;
class PreferenceWidget;
class Settings : public QDialog
{
......@@ -49,15 +49,14 @@ class Settings : public QDialog
Qt::WindowFlags f = 0 );
virtual ~Settings();
void addWidget( const QString& name,
PreferenceWidget* pWidget,
const QIcon& icon,
const QString& label );
void addCategorie( const QString& name,
SettingsManager::Type type,
const QIcon& icon,
const QString& label );
void show();
private:
inline QHBoxLayout* buildLayout();
void save();
private:
QDialogButtonBox* m_buttons;
......
......@@ -74,30 +74,30 @@ ProjectManager::ProjectManager() : m_projectFile( NULL ), m_needSave( false )
connect( this, SIGNAL( projectClosed() ), Library::getInstance(), SLOT( clear() ) );
connect( this, SIGNAL( projectClosed() ), MainWorkflow::getInstance(), SLOT( clear() ) );
VLMC_CREATE_PROJECT_VAR( "video/VLMCOutputFPS", 29.97, "Output video FPS", "Frame Per Second used when previewing and rendering the project" );
VLMC_CREATE_PROJECT_VAR( "video/VideoProjectWidth", 480, "Video width", "Width resolution of the output video" );
VLMC_CREATE_PROJECT_VAR( "video/VideoProjectHeight", 300, "Video height", "Height resolution of the output video" );
VLMC_CREATE_PROJECT_VAR( "audio/AudioSampleRate", 0, "Audio samplerate", "Output project audio samplerate" );
VLMC_CREATE_PROJECT_VAR( "general/VLMCWorkspace", QDir::homePath(), "Workspace location", "The place where all project's videos will be stored" );
VLMC_CREATE_PROJECT_VAR( "general/ProjectName", unNamedProject, "Project name", "The project name" );
SettingsManager::getInstance()->watchValue( "project/ProjectName", this,
VLMC_CREATE_PROJECT_DOUBLE( "video/VLMCOutputFPS", 29.97, "Output video FPS", "Frame Per Second used when previewing and rendering the project" );
VLMC_CREATE_PROJECT_INT( "video/VideoProjectWidth", 480, "Video width", "Width resolution of the output video" );
VLMC_CREATE_PROJECT_INT( "video/VideoProjectHeight", 300, "Video height", "Height resolution of the output video" );
VLMC_CREATE_PROJECT_INT( "audio/AudioSampleRate", 0, "Audio samplerate", "Output project audio samplerate" );
VLMC_CREATE_PROJECT_STRING( "general/VLMCWorkspace", QDir::homePath(), "Workspace location", "The place where all project's videos will be stored" );
VLMC_CREATE_PROJECT_STRING( "general/ProjectName", unNamedProject, "Project name", "The project name" );
SettingsManager::getInstance()->watchValue( "general/ProjectName", this,
SLOT(projectNameChanged(QVariant) ),
SettingsManager::Project );
//Automatic save part :
m_timer = new QTimer( this );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( autoSaveRequired() ) );
VLMC_CREATE_PREFERENCE( "general/AutomaticBackup", false, "Automatic save",
VLMC_CREATE_PREFERENCE_BOOL( "general/AutomaticBackup", false, "Automatic save",
"When this option is activated,"
"VLMC will automatically save your project at a specified interval" );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackup", this,
SettingsManager::getInstance()->watchValue( "general/AutomaticBackup", this,
SLOT( automaticSaveEnabledChanged(QVariant) ),
SettingsManager::Vlmc,
Qt::QueuedConnection );
VLMC_CREATE_PREFERENCE( "general/AutomaticBackupInterval", 5, "Automatic save interval",
VLMC_CREATE_PREFERENCE_INT( "general/AutomaticBackupInterval", 5, "Automatic save interval",
"This is the interval that VLMC will wait between two automatic save" );
SettingsManager::getInstance()->watchValue( "global/AutomaticBackupInterval", this,
SettingsManager::getInstance()->watchValue( "general/AutomaticBackupInterval", this,
SLOT( automaticSaveIntervalChanged(QVariant) ),
SettingsManager::Vlmc,
Qt::QueuedConnection );
......
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