Create a dialog to configure module options

This commit is contained in:
2015-03-23 00:30:15 +00:00
parent dbd101e8de
commit c920ebe540
6 changed files with 65 additions and 67 deletions
+1
View File
@@ -62,6 +62,7 @@ set(plaYUVer_App_SRCS
external/qcustomplot.cpp
# Module Plugins
ModulesHandle.cpp
ModulesHandleOptDialog.cpp
ModuleHandleDock.cpp
PlaYUVerAppModuleIf.cpp
GridManager.cpp
+1 -1
View File
@@ -243,4 +243,4 @@ void ConfigureFormatDialog::StandardResolutionSelection()
m_spinBoxheight->setValue( currSize.height() );
}
} // Namespace SCode
} // NAMESPACE
+4
View File
@@ -28,6 +28,7 @@
#include "VideoHandle.h"
#include "PlaYUVerModuleFactory.h"
#include "DialogSubWindowSelector.h"
#include "ModulesHandleOptDialog.h"
namespace plaYUVer
{
@@ -302,6 +303,9 @@ Void ModulesHandle::enableModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
pcCurrModuleIf->m_pcSubWindow[i] = videoSubWindowList.at( i );
}
ModulesHandleOptDialog moduleOptDialog( m_pcParent, pcCurrModuleIf );
moduleOptDialog.runConfiguration();
if( pcCurrModuleIf->m_pcModule->m_iModuleType == FRAME_PROCESSING_MODULE )
{
if( ( pcCurrModuleIf->m_pcModule->m_uiModuleRequirements & MODULE_REQUIRES_NEW_WINDOW ) || bShowModulesNewWindow )
+7 -5
View File
@@ -43,20 +43,20 @@ class VideoSubWindow;
class PlaYUVerAppModuleIf
#ifdef PLAYUVER_THREADED_MODULES
: public QThread
: public QThread
#else
: public QObject
: public QObject
#endif
{
friend class ModulesHandle;
friend class ModuleHandleDock;
friend class ModulesHandleOptDialog;
private:
QAction* m_pcModuleAction;
PlaYUVerModuleIf* m_pcModule;
VideoSubWindow* m_pcSubWindow[MAX_NUMBER_FRAMES];
VideoSubWindow* m_pcDisplaySubWindow;
@@ -83,8 +83,10 @@ public:
PlaYUVerAppModuleIf* m_pcModule;
};
PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module );
virtual ~PlaYUVerAppModuleIf() {}
PlaYUVerAppModuleIf( QObject* parent, QAction* action, PlaYUVerModuleIf* module );
virtual ~PlaYUVerAppModuleIf()
{
}
protected:
virtual void run();
+25 -25
View File
@@ -59,7 +59,7 @@ Options::Options( const std::string& name )
Options::~Options()
{
for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
{
delete *it;
}
@@ -72,12 +72,12 @@ OptionBase* Options::operator[]( const std::string& optName )
OptionBase* Options::getOption( const std::string& optName )
{
Options::NamesMap::iterator opt_it;
Options::OptionMap::iterator opt_it;
opt_it = opt_short_map.find( optName );
if( opt_it != opt_short_map.end() )
{
NamesPtrList opt_list = ( *opt_it ).second;
for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
OptionsList opt_list = ( *opt_it ).second;
for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
{
return ( *it )->opt;
}
@@ -85,8 +85,8 @@ OptionBase* Options::getOption( const std::string& optName )
opt_it = opt_long_map.find( optName );
if( opt_it != opt_long_map.end() )
{
NamesPtrList opt_list = ( *opt_it ).second;
for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
OptionsList opt_list = ( *opt_it ).second;
for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
{
return ( *it )->opt;
}
@@ -96,7 +96,7 @@ OptionBase* Options::getOption( const std::string& optName )
void Options::addOption( OptionBase *opt )
{
Names* names = new Names();
Option* names = new Option();
names->opt = opt;
string& opt_string = opt->opt_string;
@@ -136,17 +136,17 @@ OptionSpecific Options::addOptions()
* default value */
Void Options::setDefaults()
{
// for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
// for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); it++ )
// {
// ( *it )->opt->setDefault();
// }
}
static void setOptions( Options::NamesPtrList& opt_list, const string& value )
static void setOptions( Options::OptionsList& opt_list, const string& value )
{
/* multiple options may be registered for the same name:
* allow each to parse value */
for( Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
for( Options::OptionsList::iterator it = opt_list.begin(); it != opt_list.end(); ++it )
{
( *it )->opt->parse( value );
}
@@ -158,7 +158,7 @@ static const char spaces[41] = " ";
* using the formatting: "-x, --long",
* if a short/long option isn't specified, it is not printed
*/
static void doHelpOpt( ostream& out, const Options::Names& entry, unsigned pad_short = 0 )
static void doHelpOpt( ostream& out, const Options::Option& entry, unsigned pad_short = 0 )
{
pad_short = min( pad_short, 8u );
@@ -192,7 +192,7 @@ void doHelp( ostream& out, Options& opts, unsigned columns )
const unsigned pad_short = 3;
/* first pass: work out the longest option name */
unsigned max_width = 0;
for( Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ )
for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ )
{
ostringstream line( ios_base::out );
doHelpOpt( line, **it, pad_short );
@@ -207,7 +207,7 @@ void doHelp( ostream& out, Options& opts, unsigned columns )
* - if the option text is longer than opt_width, place the help
* text at opt_width on the next line.
*/
for( Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ )
for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ )
{
ostringstream line( ios_base::out );
line << " ";
@@ -288,7 +288,7 @@ void doHelp( ostream& out, Options& opts, unsigned columns )
bool storePair( Options& opts, bool allow_long, bool allow_short, const string& name, const string& value )
{
bool found = false;
Options::NamesMap::iterator opt_it;
Options::OptionMap::iterator opt_it;
if( allow_long )
{
opt_it = opts.opt_long_map.find( name );
@@ -310,16 +310,16 @@ bool storePair( Options& opts, bool allow_long, bool allow_short, const string&
if( !found )
{
if( !opts.allow_unknow )
{
/* not found */
cerr << "Unknown option: `"
<< name
<< "' (value:`"
<< value
<< "')"
<< endl;
}
// if( !opts.allow_unknow )
// {
// /* not found */
// cerr << "Unknown option: `"
// << name
// << "' (value:`"
// << value
// << "')"
// << endl;
// }
return false;
}
@@ -535,7 +535,7 @@ void scanFile( Options& opts, istream& in )
* default value */
void setDefaults( Options& opts )
{
// for( Options::NamesPtrList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ )
// for( Options::OptionsList::iterator it = opts.opt_list.begin(); it != opts.opt_list.end(); it++ )
// {
// ( *it )->opt->setDefault();
// }
+27 -36
View File
@@ -106,7 +106,6 @@ struct OptionBase
virtual void parse( const std::string& arg ) = 0;
/* set the argument to the default value */
//virtual void setDefault() = 0;
int count()
{
return arg_count;
@@ -143,9 +142,9 @@ struct FlagOpt: public OptionBase
/** Type specific option storage */
template<typename T>
struct Option: public OptionBase
struct StandardOpt: public OptionBase
{
Option( const std::string& name, T& storage, const std::string& desc ) :
StandardOpt( const std::string& name, T& storage, const std::string& desc ) :
OptionBase( name, desc ),
opt_storage( storage )
{
@@ -163,7 +162,7 @@ struct Option: public OptionBase
/* Generic parsing */
template<typename T>
inline void Option<T>::parse( const std::string& arg )
inline void StandardOpt<T>::parse( const std::string& arg )
{
std::istringstream arg_ss( arg, std::istringstream::in );
arg_ss.exceptions( std::ios::failbit );
@@ -181,7 +180,7 @@ inline void Option<T>::parse( const std::string& arg )
/* string parsing is specialized -- copy the whole string, not just the
* first word */
template<>
inline void Option<std::string>::parse( const std::string& arg )
inline void StandardOpt<std::string>::parse( const std::string& arg )
{
opt_storage = arg;
arg_count++;
@@ -190,7 +189,7 @@ inline void Option<std::string>::parse( const std::string& arg )
/* string parsing is specialized -- copy the whole string, not just the
* first word */
template<>
inline void Option<std::vector<std::string> >::parse( const std::string& arg )
inline void StandardOpt<std::vector<std::string> >::parse( const std::string& arg )
{
opt_storage.push_back( arg );
arg_count++;
@@ -225,22 +224,18 @@ private:
};
class OptionSpecific;
struct Options
class Options
{
Options( const std::string& name = "" );
~Options();
public:
OptionSpecific addOptions();
Void setDefaults();
struct Names
struct Option
{
Names() :
Option() :
opt( 0 )
{
}
;
~Names()
~Option()
{
if( opt )
delete opt;
@@ -249,18 +244,28 @@ struct Options
std::list<std::string> opt_short;
OptionBase* opt;
};
typedef std::list<Option*> OptionsList;
OptionsList opt_list;
Options( const std::string& name = "" );
~Options();
OptionSpecific addOptions();
Void setDefaults();
OptionBase* operator[]( const std::string& optName );
OptionBase* getOption( const std::string& optName );
OptionsList& getOptionList()
{
return opt_list;
}
void addOption( OptionBase *opt );
typedef std::list<Names*> NamesPtrList;
NamesPtrList opt_list;
typedef std::map<std::string, NamesPtrList> NamesMap;
NamesMap opt_long_map;
NamesMap opt_short_map;
typedef std::map<std::string, OptionsList> OptionMap;
OptionMap opt_long_map;
OptionMap opt_short_map;
std::string opt_name;
@@ -286,24 +291,10 @@ public:
OptionSpecific&
operator()( const std::string& name, T& storage, const std::string& desc )
{
parent.addOption( new Option<T>( name, storage, desc ) );
parent.addOption( new StandardOpt<T>( name, storage, desc ) );
return *this;
}
// /**
// * Add option described by name to the parent Options list,
// * with storage for the option's value
// * with default_val as the default value
// * with desc as an optional help description
// */
// template<typename T>
// OptionSpecific&
// operator()( const std::string& name, T& storage, const std::string& desc )
// {
// parent.addOption( new Option<T>( name, storage, desc ) );
// return *this;
// }
/**
* Add option described by name to the parent Options list,
* with storage for the option's value