[vlmc-devel] commit: MainWindow: Cut and select tool are now in the toolbar ( and the menu) ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Tue Jul 20 11:53:38 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Jul 20 11:30:41 2010 +0200| [d031db859beae31070307d01e15d62996c94a8d5] | committer: Hugo Beauzée-Luyssen
MainWindow: Cut and select tool are now in the toolbar (and the menu)
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=d031db859beae31070307d01e15d62996c94a8d5
---
src/Gui/MainWindow.cpp | 71 +++++++++++++++++++---------------------------
src/Gui/MainWindow.h | 3 +-
src/Gui/ui/MainWindow.ui | 62 +++++++++++++++++++++++++++++++++-------
3 files changed, 82 insertions(+), 54 deletions(-)
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index dfc5e49..2651e02 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -91,6 +91,7 @@ MainWindow::MainWindow( QWidget *parent ) :
createGlobalPreferences();
createProjectPreferences();
initializeDockWidgets();
+ initToolbar();
createStatusBar();
#ifdef WITH_CRASHBUTTON
setupCrashTester();
@@ -176,14 +177,6 @@ void
MainWindow::initVlmcPreferences()
{
//Setup VLMC Keyboard Preference...
- VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/defaultmode", "n",
- QT_TRANSLATE_NOOP( "PreferenceWidget", "Select mode" ),
- QT_TRANSLATE_NOOP( "PreferenceWidget", "Select the selection tool in the timeline" ) );
-
- VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/cutmode", "x",
- QT_TRANSLATE_NOOP( "PreferenceWidget", "Cut mode" ),
- QT_TRANSLATE_NOOP( "PreferenceWidget", "Select the cut/razor tool in the timeline" ) );
-
VLMC_CREATE_PREFERENCE_KEYBOARD( "keyboard/mediapreview", "Ctrl+Return",
QT_TRANSLATE_NOOP( "PreferenceWidget", "Media preview" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Preview the selected media, or pause the current preview" ) );
@@ -252,6 +245,14 @@ MainWindow::initVlmcPreferences()
QT_TRANSLATE_NOOP( "PreferenceWidget", "Render the project" ),
QT_TRANSLATE_NOOP( "PreferenceWidget", "Render the project to a file" ), actionRender );
+ CREATE_MENU_SHORTCUT( "keyboard/defaultmode", "n",
+ QT_TRANSLATE_NOOP( "PreferenceWidget", "Selection mode" ),
+ QT_TRANSLATE_NOOP( "PreferenceWidget", "Select the selection tool in the timeline" ), actionSelection_mode );
+
+ CREATE_MENU_SHORTCUT( "keyboard/cutmode", "x",
+ QT_TRANSLATE_NOOP( "PreferenceWidget", "Cut mode" ),
+ QT_TRANSLATE_NOOP( "PreferenceWidget", "Select the cut/razor tool in the timeline" ), actionCut_mode );
+
//Setup VLMC Lang. Preferences...
VLMC_CREATE_PREFERENCE_LANGUAGE( "general/VLMCLang", "default",
QT_TRANSLATE_NOOP( "PreferenceWidget", "Language" ),
@@ -380,38 +381,6 @@ MainWindow::createStatusBar()
//Notifications:
createNotificationZone();
- // Mouse (default) tool
- QToolButton* mouseTool = new QToolButton( this );
- mouseTool->setAutoRaise( true );
- mouseTool->setCheckable( true );
- mouseTool->setIcon( QIcon( ":/images/mouse" ) );
- mouseTool->setStatusTip( tr( "Use the mouse tool to manipulate regions in the timeline" ) );
- m_ui.statusbar->addPermanentWidget( mouseTool );
-
- // Cut/Split tool
- QToolButton* splitTool = new QToolButton( this );
- splitTool->setAutoRaise( true );
- splitTool->setCheckable( true );
- splitTool->setIcon( QIcon( ":/images/editcut" ) );
- splitTool->setStatusTip( tr( "Use the scissors to cut regions in the timeline" ) );
- m_ui.statusbar->addPermanentWidget( splitTool );
-
- // Group the two previous buttons
- QButtonGroup* toolButtonGroup = new QButtonGroup( this );
- toolButtonGroup->addButton( mouseTool, TOOL_DEFAULT);
- toolButtonGroup->addButton( splitTool, TOOL_CUT );
- toolButtonGroup->setExclusive( true );
- mouseTool->setChecked( true );
-
- //Shortcut part:
- KeyboardShortcutHelper* defaultModeShortcut = new KeyboardShortcutHelper( "keyboard/defaultmode", this );
- KeyboardShortcutHelper* cutModeShortcut = new KeyboardShortcutHelper( "keyboard/cutmode", this );
- connect( defaultModeShortcut, SIGNAL( activated() ), mouseTool, SLOT( click() ) );
- connect( cutModeShortcut, SIGNAL( activated() ), splitTool, SLOT( click() ) );
-
- connect( toolButtonGroup, SIGNAL( buttonClicked( int ) ),
- this, SLOT( toolButtonClicked( int ) ) );
-
// Spacer
QWidget* spacer = new QWidget( this );
spacer->setFixedWidth( 20 );
@@ -490,6 +459,19 @@ MainWindow::initializeDockWidgets( void )
}
void
+MainWindow::initToolbar()
+{
+ QActionGroup *mouseActions = new QActionGroup( m_ui.toolBar );
+ mouseActions->addAction( m_ui.actionSelection_mode );
+ mouseActions->addAction( m_ui.actionCut_mode );
+ m_ui.actionSelection_mode->setChecked( true );
+ m_ui.toolBar->addActions( mouseActions->actions() );
+ connect( mouseActions, SIGNAL( triggered(QAction*) ),
+ this, SLOT( toolButtonClicked( QAction* ) ) );
+ m_ui.menuTools->addActions( mouseActions->actions() );
+}
+
+void
MainWindow::createGlobalPreferences()
{
m_globalPreferences = new Settings( SettingsManager::Vlmc, this );
@@ -679,9 +661,14 @@ MainWindow::registerWidgetInWindowMenu( QDockWidget* widget )
}
void
-MainWindow::toolButtonClicked( int id )
+MainWindow::toolButtonClicked( QAction *action )
{
- emit toolChanged( (ToolButtons)id );
+ if ( action == m_ui.actionSelection_mode )
+ emit toolChanged( TOOL_DEFAULT );
+ else if ( action == m_ui.actionCut_mode )
+ emit toolChanged( TOOL_CUT );
+ else
+ qCritical() << "Unknown tool. This should not happen !";
}
void
diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h
index 840708a..299de57 100644
--- a/src/Gui/MainWindow.h
+++ b/src/Gui/MainWindow.h
@@ -68,6 +68,7 @@ private:
void createProjectPreferences();
void initVlmcPreferences();
void loadVlmcPreferences( const QString& subPart );
+ void initToolbar();
#ifdef WITH_CRASHBUTTON
void setupCrashTester();
#endif
@@ -125,7 +126,7 @@ private slots:
void on_actionRedo_triggered();
void on_actionCrash_triggered();
void on_actionImport_triggered();
- void toolButtonClicked( int id );
+ void toolButtonClicked( QAction *action );
void projectUpdated( const QString& projectName, bool savedStatus );
void canUndoChanged( bool canUndo );
void canRedoChanged( bool canRedo );
diff --git a/src/Gui/ui/MainWindow.ui b/src/Gui/ui/MainWindow.ui
index 3dfb161..360ec6a 100644
--- a/src/Gui/ui/MainWindow.ui
+++ b/src/Gui/ui/MainWindow.ui
@@ -40,12 +40,6 @@
<addaction name="actionPreferences"/>
<addaction name="actionProject_Preferences"/>
</widget>
- <widget class="QMenu" name="menuView">
- <property name="title">
- <string>&View</string>
- </property>
- <addaction name="actionFullscreen"/>
- </widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>&Help</string>
@@ -54,11 +48,6 @@
<addaction name="separator"/>
<addaction name="actionAbout"/>
</widget>
- <widget class="QMenu" name="menuWindow">
- <property name="title">
- <string>&Window</string>
- </property>
- </widget>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>&File</string>
@@ -83,8 +72,25 @@
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
+ <widget class="QMenu" name="menuWindow">
+ <property name="title">
+ <string>&Window</string>
+ </property>
+ </widget>
+ <widget class="QMenu" name="menuView">
+ <property name="title">
+ <string>&View</string>
+ </property>
+ <addaction name="actionFullscreen"/>
+ </widget>
+ <widget class="QMenu" name="menuTools">
+ <property name="title">
+ <string>Tools</string>
+ </property>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
+ <addaction name="menuTools"/>
<addaction name="menuView"/>
<addaction name="menuWindow"/>
<addaction name="menuHelp"/>
@@ -116,6 +122,7 @@
<addaction name="actionPreferences"/>
<addaction name="actionProject_Preferences"/>
<addaction name="actionFullscreen"/>
+ <addaction name="separator"/>
</widget>
<action name="actionAbout">
<property name="icon">
@@ -295,6 +302,39 @@
<string>&Quit</string>
</property>
</action>
+ <action name="actionSelection_mode">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="../../../resources.qrc">
+ <normaloff>:/images/mouse</normaloff>:/images/mouse</iconset>
+ </property>
+ <property name="text">
+ <string>Selection mode</string>
+ </property>
+ <property name="toolTip">
+ <string>Use the mouse tool to manipulate regions in the timeline</string>
+ </property>
+ <property name="statusTip">
+ <string>Use the mouse tool to manipulate regions in the timeline</string>
+ </property>
+ </action>
+ <action name="actionCut_mode">
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="icon">
+ <iconset resource="../../../resources.qrc">
+ <normaloff>:/images/editcut</normaloff>:/images/editcut</iconset>
+ </property>
+ <property name="text">
+ <string>Cut mode</string>
+ </property>
+ <property name="toolTip">
+ <string>Use the scissors to cut regions in the timeline</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="../../../resources.qrc"/>
More information about the Vlmc-devel
mailing list