Commit b7078463 authored by Hugo Beauzee-Luyssen's avatar Hugo Beauzee-Luyssen

Keyboard shortcuts are now displayed in the appropriate widget.

Edition is possible, but has absolutely no effect.
parent 7e52fcb4
......@@ -214,3 +214,11 @@ SettingsManager* SettingsManager::getInstance()
return ret;
}
const SettingsPart* SettingsManager::getConfigPart( const QString& part ) const
{
QHash<QString, SettingsPart*>::const_iterator it = m_data.find( part );
if ( it == m_data.end() )
return NULL;
return it.value();
}
......@@ -35,8 +35,10 @@
struct SettingsPart
{
typedef QHash<QString, QVariant> ConfigPair;
SettingsPart() {}
QHash<QString, QVariant> m_data;
ConfigPair m_data;
mutable QReadWriteLock m_lock;
bool m_rdOnly;
......@@ -56,6 +58,7 @@ class SettingsManager : public QObject, public QSingleton<SettingsManager>
void setValues( const QString& part, QHash<QString, QVariant> );
void setValue( const QString& part, const QString& key, const QVariant& value );
const QVariant& getValue( const QString& part, const QString& key ) const;
const SettingsPart* getConfigPart( const QString& part ) const;
void saveSettings( const QString& part, QDomDocument& xmlfile, QDomElement& root );
void loadSettings( const QString& part, const QDomElement& settings );
void addNewSettingsPart( const QString& name );
......
......@@ -20,6 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtDebug>
#include <QVariant>
#include "VLMCSettingsDefault.h"
......@@ -31,7 +32,6 @@ void VLMCSettingsDefault::load( const QString& part )
VLMCSettingsDefault::loadVLMCDefaults( part );
VLMCSettingsDefault::loadlanguageDefaults( part );
SettingsManager::getInstance()->commit();
return ;
}
......@@ -67,19 +67,18 @@ void VLMCSettingsDefault::loadKeyboardShortcutDefaults()
SettingsManager::getInstance()->addNewSettingsPart( "keyboard_shortcut" );
loadKeyboardShortcutDefaults( "default" );
loadKeyboardShortcutDefaults( "keyboard_shortcut" );
//Will be committed by the load method
SettingsManager::getInstance()->commit();
}
#define ADD_SHORTCUT(NAME, KEYS) setMan->setValue( part, QObject::tr( NAME ), QVariant( QObject::tr( KEYS ) ) )
void VLMCSettingsDefault::loadKeyboardShortcutDefaults( const QString& part )
{
QString tmp;
SettingsManager* setMan = SettingsManager::getInstance();
ADD_SHORTCUT( "Selection mode", "n" );
ADD_SHORTCUT( "Cut mode", "x" );
ADD_SHORTCUT( "Launch media preview", "Ctrl + Return" );
ADD_SHORTCUT( "Launch media preview", "Ctrl+Return" );
ADD_SHORTCUT( "Start render preview", "Space" );
//A bit nasty, but we better use what Qt's providing as default shortcut
ADD_SHORTCUT( "Undo", QKeySequence( QKeySequence::Undo ).toString().toLocal8Bit() );
......
......@@ -54,7 +54,7 @@
#include "MediaLibraryWidget.h"
#include "LanguagePreferences.h"
#include "ProjectManager.h"
//#include "KeyboardShortcut.h"
#include "KeyboardShortcut.h"
MainWindow::MainWindow( QWidget *parent ) :
QMainWindow( parent ), m_renderer( NULL )
......@@ -271,10 +271,10 @@ void MainWindow::createGlobalPreferences()
new LanguagePreferences( m_globalPreferences ),
QIcon( ":/images/images/vlmc.png" ),
"Langage settings");
// m_projectPreferences->addWidget( "Keyboard",
// new KeyboardShortcut,
// QIcon( ":/images/images/keyboard.png" ),
// tr( "Keyboard Settings" ) );
m_globalPreferences->addWidget( "Keyboard",
new KeyboardShortcut( m_globalPreferences ),
QIcon( ":/images/keyboard" ),
tr( "Keyboard Settings" ) );
m_globalPreferences->build();
}
......
......@@ -20,14 +20,27 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QtDebug>
#include "KeyboardShortcut.h"
#include "KeyboardShortcutInput.h"
#include "SettingsManager.h"
KeyboardShortcut::KeyboardShortcut( QWidget* parent ) :
PreferenceWidget( parent )
{
m_layout = new QFormLayout( this );
m_layout->addRow( tr( "Switch to cut mode" ), new KeyboardShortcutInput( this ) );
const SettingsPart* parts = SettingsManager::getInstance()->getConfigPart( "keyboard_shortcut" );
Q_ASSERT( parts != NULL );
SettingsPart::ConfigPair::const_iterator it = parts->m_data.begin();
SettingsPart::ConfigPair::const_iterator ite = parts->m_data.end();
while ( it != ite )
{
m_keySeq[it.key()] = new QKeySequence( it.value().toString() );
m_layout->addRow( it.key(), new KeyboardShortcutInput( m_keySeq[it.key()]->toString(), this ) );
++it;
}
setLayout( m_layout );
}
......
......@@ -24,6 +24,9 @@
#define KEYBOARDSHORTCUT_H
#include <QFormLayout>
#include <QHash>
#include <QString>
#include <QKeySequence>
#include "PreferenceWidget.h"
......@@ -35,7 +38,8 @@ class KeyboardShortcut : public PreferenceWidget
void load();
void save();
private:
QFormLayout* m_layout;
QFormLayout* m_layout;
QHash<QString, QKeySequence*> m_keySeq;
};
#endif // KEYBOARDSHORTCUT_H
......@@ -26,7 +26,7 @@
#include "KeyboardShortcutInput.h"
KeyboardShortcutInput::KeyboardShortcutInput( QWidget* parent ) :
KeyboardShortcutInput::KeyboardShortcutInput( const QString& initialValue, QWidget* parent ) :
QPushButton( parent ),
m_capturing( false ),
m_current( 0 )
......@@ -34,6 +34,7 @@ KeyboardShortcutInput::KeyboardShortcutInput( QWidget* parent ) :
m_timer = new QTimer( this );
m_timer->setSingleShot( true );
connect( m_timer, SIGNAL( timeout() ), this, SLOT( timeout() ) );
setText( initialValue );
}
void KeyboardShortcutInput::mousePressEvent( QMouseEvent* )
......
......@@ -31,7 +31,7 @@ class KeyboardShortcutInput : public QPushButton
Q_OBJECT
public:
KeyboardShortcutInput( QWidget* parent );
KeyboardShortcutInput( const QString& initialValue = QString(), QWidget* parent = NULL );
protected:
virtual void keyPressEvent( QKeyEvent* e );
virtual void mousePressEvent( QMouseEvent* e );
......
......@@ -12,8 +12,8 @@ HEADERS += AudioProjectPreferences.h \
Settings.h \
KeyboardShortcutInput.h \
VLMCPreferences.h \
VideoProjectPreferences.h
# KeyboardShortcut.h \
VideoProjectPreferences.h \
KeyboardShortcut.h \
SOURCES += AudioProjectPreferences.cpp \
Panel.cpp \
......@@ -22,5 +22,5 @@ SOURCES += AudioProjectPreferences.cpp \
Settings.cpp \
KeyboardShortcutInput.cpp \
VLMCPreferences.cpp \
VideoProjectPreferences.cpp
# KeyboardShortcut.cpp \
VideoProjectPreferences.cpp \
KeyboardShortcut.cpp \
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