added tool plugins
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@441 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -77,6 +77,7 @@
|
||||
#include "buffer_allocator.h"
|
||||
#include "setup_dialog.h"
|
||||
#include "audio_dummy.h"
|
||||
#include "tool.h"
|
||||
#include "tool_button.h"
|
||||
#include "project_journal.h"
|
||||
#include "automation_editor.h"
|
||||
@@ -97,7 +98,8 @@ mainWindow::mainWindow( engine * _engine ) :
|
||||
),
|
||||
engineObject( _engine ),
|
||||
m_workspace( NULL ),
|
||||
m_templatesMenu( NULL )
|
||||
m_templatesMenu( NULL ),
|
||||
m_tools_menu( NULL )
|
||||
{
|
||||
#ifdef QT4
|
||||
setAttribute( Qt::WA_DeleteOnClose );
|
||||
@@ -500,7 +502,7 @@ void mainWindow::finalize( void )
|
||||
this, SLOT( redo() ),
|
||||
Qt::CTRL + Qt::Key_R );
|
||||
|
||||
|
||||
|
||||
QMenu * settings_menu = new QMenu( this );
|
||||
#ifdef QT4
|
||||
menuBar()->addMenu( settings_menu )->setText( tr( "&Settings" ) );
|
||||
@@ -514,7 +516,33 @@ void mainWindow::finalize( void )
|
||||
tr( "Show setup wizard" ),
|
||||
configManager::inst(), SLOT( exec() ) );
|
||||
|
||||
|
||||
|
||||
m_tools_menu = new QMenu( this );
|
||||
vvector<plugin::descriptor> pluginDescriptors;
|
||||
plugin::getDescriptorsOfAvailPlugins( pluginDescriptors );
|
||||
for( vvector<plugin::descriptor>::iterator it =
|
||||
pluginDescriptors.begin();
|
||||
it != pluginDescriptors.end(); ++it )
|
||||
{
|
||||
if( it->type == plugin::Tool )
|
||||
{
|
||||
m_tools_menu->addAction( *it->logo, it->public_name );
|
||||
m_tools.push_back( tool::instantiate( it->name,
|
||||
this ) );
|
||||
}
|
||||
}
|
||||
if( m_tools_menu->count() )
|
||||
{
|
||||
#ifdef QT4
|
||||
menuBar()->addMenu( m_tools_menu )->setText( tr( "&Tools" ) );
|
||||
#else
|
||||
menuBar()->insertItem( tr( "&Tools" ), m_tools_menu );
|
||||
#endif
|
||||
connect( m_tools_menu, SIGNAL( activated( int ) ),
|
||||
this, SLOT( showTool( int ) ) );
|
||||
}
|
||||
|
||||
|
||||
// help-popup-menu
|
||||
QMenu * help_menu = new QMenu( this );
|
||||
#ifdef QT4
|
||||
@@ -1051,6 +1079,16 @@ void mainWindow::fillTemplatesMenu( void )
|
||||
|
||||
|
||||
|
||||
void mainWindow::showTool( int _idx )
|
||||
{
|
||||
tool * t = m_tools[m_tools_menu->indexOf( _idx )];
|
||||
t->show();
|
||||
t->setFocus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef QT4
|
||||
#undef addSeparator
|
||||
#endif
|
||||
|
||||
70
src/core/tool.cpp
Normal file
70
src/core/tool.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
#ifndef SINGLE_SOURCE_COMPILE
|
||||
|
||||
/*
|
||||
* tool.cpp - base class for all tool plugins (graphs, extensions, etc)
|
||||
*
|
||||
* Copyright (c) 2006 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
* 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 (see COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "tool.h"
|
||||
#include "main_window.h"
|
||||
|
||||
|
||||
|
||||
|
||||
tool::tool( mainWindow * _window, const descriptor * _descriptor ) :
|
||||
QWidget( _window->workspace() ),
|
||||
plugin( _descriptor, _window->eng() )
|
||||
{
|
||||
setWindowTitle( _descriptor->public_name );
|
||||
setWindowIcon( *_descriptor->logo );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
tool::~tool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
tool * tool::instantiate( const QString & _plugin_name, mainWindow * _window )
|
||||
{
|
||||
plugin * p = plugin::instantiate( _plugin_name, _window );
|
||||
// check whether instantiated plugin is an instrument
|
||||
if( dynamic_cast<tool *>( p ) != NULL )
|
||||
{
|
||||
// everything ok, so return pointer
|
||||
return( dynamic_cast<tool *>( p ) );
|
||||
}
|
||||
|
||||
// not quite... so delete plugin
|
||||
delete p;
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "src/core/piano_widget.cpp"
|
||||
#include "src/core/name_label.cpp"
|
||||
#include "src/core/preset_preview_play_handle.cpp"
|
||||
#include "src/core/tool.cpp"
|
||||
#include "src/core/track_container.cpp"
|
||||
#include "src/core/track.cpp"
|
||||
#include "src/core/file_browser.cpp"
|
||||
|
||||
Reference in New Issue
Block a user