From: <sv...@va...> - 2010-02-28 14:11:53
|
Author: cerion Date: 2010-02-28 13:33:46 +0000 (Sun, 28 Feb 2010) New Revision: 477 Log: Reintroduced some more options/cfg funtionality. More refactoring, so less internals are spread around: OptionPages save their edits via the underlying option - that is responsible then for saving to vkConfig, and for signalling to whoever is listening that it's value has changed. This allows us to remove all responsibility of applying the effects of any changes from the option_pages: we just connect to the relevant option->valueChanged() signal. e.g. valkyrie_options_page & vkConfig don't know about MainWindow anymore. Modified: branches/valkyrie_qt4port/help/help_handbook.cpp branches/valkyrie_qt4port/main.cpp branches/valkyrie_qt4port/mainwindow.cpp branches/valkyrie_qt4port/mainwindow.h branches/valkyrie_qt4port/objects/helgrind_object.h branches/valkyrie_qt4port/objects/memcheck_object.cpp branches/valkyrie_qt4port/objects/memcheck_object.h branches/valkyrie_qt4port/objects/tool_object.cpp branches/valkyrie_qt4port/objects/tool_object.h branches/valkyrie_qt4port/objects/valgrind_object.cpp branches/valkyrie_qt4port/objects/valgrind_object.h branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/objects/valkyrie_object.h branches/valkyrie_qt4port/objects/vk_objects.cpp branches/valkyrie_qt4port/objects/vk_objects.h branches/valkyrie_qt4port/options/helgrind_options_page.cpp branches/valkyrie_qt4port/options/helgrind_options_page.h branches/valkyrie_qt4port/options/memcheck_options_page.cpp branches/valkyrie_qt4port/options/memcheck_options_page.h branches/valkyrie_qt4port/options/valgrind_options_page.cpp branches/valkyrie_qt4port/options/valgrind_options_page.h branches/valkyrie_qt4port/options/valkyrie_options_page.cpp branches/valkyrie_qt4port/options/valkyrie_options_page.h branches/valkyrie_qt4port/options/vk_option.cpp branches/valkyrie_qt4port/options/vk_option.h branches/valkyrie_qt4port/options/vk_options_dialog.cpp branches/valkyrie_qt4port/options/vk_options_page.cpp branches/valkyrie_qt4port/options/vk_options_page.h branches/valkyrie_qt4port/options/widgets/opt_base_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_cb_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_ck_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_lb_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_le_widget.cpp branches/valkyrie_qt4port/options/widgets/opt_sp_widget.cpp branches/valkyrie_qt4port/toolview/helgrindview.cpp branches/valkyrie_qt4port/toolview/memcheckview.cpp branches/valkyrie_qt4port/toolview/toolview.cpp branches/valkyrie_qt4port/toolview/toolview.h branches/valkyrie_qt4port/toolview/vglogview.cpp branches/valkyrie_qt4port/utils/vk_config.cpp branches/valkyrie_qt4port/utils/vk_config.h branches/valkyrie_qt4port/utils/vk_messages.cpp Modified: branches/valkyrie_qt4port/help/help_handbook.cpp =================================================================== --- branches/valkyrie_qt4port/help/help_handbook.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/help/help_handbook.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -250,7 +250,7 @@ historyMenu->removeAction( act ); if ( found ) { // found more than once! - VK_DEBUG( "found double entry in historyMenu: ", qPrintable( act->text() ) ); + VK_DEBUG( "found double entry in historyMenu: %s", qPrintable( act->text() ) ); } else { if ( ! historyMenu->actions().isEmpty() ) { historyMenu->insertAction( historyMenu->actions().first(), act ); @@ -438,7 +438,7 @@ foreach( QAction* act, historyMenu->actions() ) { history << act->text(); } - vkConfig->setValue( "handbook/history", history ); + vkConfig->setValue( "valkyrie/handbook_history", history ); int nBookmarks = 0; QStringList bookmarks; @@ -449,7 +449,7 @@ nBookmarks++; } } - vkConfig->setValue( "handbook/bookmarks", bookmarks ); + vkConfig->setValue( "valkyrie/handbook_bookmarks", bookmarks ); vk_assert( nBookmarks <= max_bookmarks ); @@ -494,13 +494,13 @@ void HandBook::readHistory() { bool ok = false; - max_history = vkConfig->value( "valkyrie_handbook/max_history", 20 ).toInt( &ok ); - if (!ok) cerr << "Error: bad value for config::valkyrie_handbook/max_history" << endl; + max_history = vkConfig->value( "valkyrie/handbook_max_history", 20 ).toInt( &ok ); + if (!ok) cerr << "Error: bad value for config::valkyrie/handbook_max_history" << endl; // TODO: do this via vkConfig! #if 0 //TODO: need to write to _global_ config, not project/temp config... - QStringList history = vkConfig->value( "handbook/history" ).toStringList(); + QStringList history = vkConfig->value( "valkyrie/handbook_history" ).toStringList(); int len = history.count() > max_history ? max_history : history.count(); for ( int idx=0; idx < len; idx++ ) { QString link = history.at( idx ); @@ -537,18 +537,18 @@ void HandBook::readBookmarks() { bool ok = false; - max_bookmarks = vkConfig->value( "valkyrie_handbook/max_bookmarks", 20 ).toInt(&ok); - if (!ok) cerr << "Error: bad value for config::valkyrie_handbook/max_bookmarks" << endl; + max_bookmarks = vkConfig->value( "valkyrie/handbook_max_bookmarks", 20 ).toInt(&ok); + if (!ok) cerr << "Error: bad value for config::valkyrie/handbook_max_bookmarks" << endl; // TODO: do this via vkConfig! #if 0 //TODO: need to write to _global_ config, not project/temp config... - QStringList bookmarks = vkConfig->value( "handbook/bookmarks" ).toStringList(); + QStringList bookmarks = vkConfig->value( "valkyrie/handbook_bookmarks" ).toStringList(); int len = bookmarks.count() > max_bookmarks ? max_bookmarks : bookmarks.count(); for ( int idx=0; idx < len; idx++ ) { QString str = bookmarks.at( idx ); - QStringList sl = str.split( vkConfig->vkSepChar ); + QStringList sl = str.split( vkConfig->vkSepChar ); //, QString::SkipEmptyParts QString title = sl.first(); QString url = sl.last(); @@ -568,7 +568,7 @@ QTextStream stream( &aFile ); for ( int idx=0; idx < max_bookmarks && !stream.atEnd(); idx++ ) { // read in one line at a time, and split on vkSepChar - QStringList sl = stream.readLine().split( vkConfig->vkSepChar ); + QStringList sl = stream.readLine().split( vkConfig->vkSepChar, QString::SkipEmptyParts ); QString title = sl.first(); QString url = sl.last(); Modified: branches/valkyrie_qt4port/main.cpp =================================================================== --- branches/valkyrie_qt4port/main.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/main.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -52,13 +52,14 @@ // Start turning the engine over app = new QApplication( argc, argv ); - // ------------------------------------------------------------ // Setup application config settings QCoreApplication::setOrganizationName("OpenWorks"); QCoreApplication::setOrganizationDomain("openworks.co.uk"); QCoreApplication::setApplicationName("Valkyrie"); + QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedKingdom)); + VkConfig::createConfig( &valkyrie, &vkConfig ); if ( vkConfig == NULL ) { VK_DEBUG("Failed to initialise config properly: Aborting" ); Modified: branches/valkyrie_qt4port/mainwindow.cpp =================================================================== --- branches/valkyrie_qt4port/mainwindow.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/mainwindow.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -19,6 +19,9 @@ ****************************************************************************/ #include <QApplication> +#include <QColor> +#include <QColorGroup> +#include <QEvent> #include <QFileDialog> #include <QInputDialog> #include <QMenu> @@ -62,15 +65,16 @@ */ MainWindow::MainWindow( Valkyrie* vk ) : QMainWindow(), - valkyrie( vk ), optionsDialog( 0 ) + valkyrie( vk ), toolViewStack( 0 ), statusLabel( 0 ), + handBook( 0 ), optionsDialog( 0 ) { setObjectName( QString::fromUtf8("MainWindowClass") ); QString title = vkConfig->vkName; title[0] = title[0].toUpper(); setWindowTitle( title ); - // TODO: QtCoreApplication? - //setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom)); + lastAppFont = qApp->font(); + lastPalette = qApp->palette(); QIcon icon_vk; icon_vk.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/valkyrie.xpm") ), QIcon::Normal, QIcon::Off ); @@ -85,8 +89,30 @@ setupMenus(); setupToolBars(); setupStatusBar(); - setStatus( "Status message goes here..." ); + + // functions for dealing with config updates + VkOption* opt = valkyrie->getOption( VALKYRIE::ICONTXT ); + connect( opt, SIGNAL( valueChanged() ), this, SLOT( showLabels() ) ); + opt = valkyrie->getOption( VALKYRIE::TOOLTIP ); + connect( opt, SIGNAL( valueChanged() ), this, SLOT( showToolTips() ) ); + opt = valkyrie->getOption( VALKYRIE::FNT_GEN_SYS ); + connect( opt, SIGNAL( valueChanged() ), this, SLOT( setGenFont() ) ); + opt = valkyrie->getOption( VALKYRIE::FNT_GEN_USR ); + connect( opt, SIGNAL( valueChanged() ), this, SLOT( setGenFont() ) ); + opt = valkyrie->getOption( VALKYRIE::FNT_TOOL_USR ); + connect( opt, SIGNAL( valueChanged() ), this, SLOT( setToolFont() ) ); + opt = valkyrie->getOption( VALKYRIE::PALETTE ); + connect( opt, SIGNAL( valueChanged() ), this, SLOT( setPalette() ) ); + + showLabels(); + showToolTips(); + setGenFont(); + setToolFont(); + setPalette(); + + updateEventFilters( this ); + updateEventFilters( handBook ); } @@ -101,8 +127,10 @@ delete toolViewStack; // Save window position to config. - vkConfig->setValue( "valkyrie_mainwindow/size", size() ); - vkConfig->setValue( "valkyrie_mainwindow/pos", pos() ); + VkOption* opt = valkyrie->getOption( VALKYRIE::MW_SIZE ); + opt->updateConfig( size() ); + opt = valkyrie->getOption( VALKYRIE::MW_POS ); + opt->updateConfig( pos() ); vkConfig->sync(); // handbook has no parent, so have to delete it. @@ -112,8 +140,8 @@ /*! - Allow a tool to insert a menu into the main menuBar. - A tool can't do this directly via it's parent pointer, as it needs access + Allow a tool to insert a menu into the main menuBar. + A tool can't do this directly via it's parent pointer, as it needs access to private vars for positioning within the menu. \sa removeToolMenuAction() @@ -142,8 +170,10 @@ */ void MainWindow::setupLayout() { - resize( vkConfig->value( "valkyrie_mainwindow/size", QSize(600, 600)).toSize()); - move( vkConfig->value( "valkyrie_mainwindow/pos", QPoint(400, 0)).toPoint()); + VkOption* opt = valkyrie->getOption( VALKYRIE::MW_SIZE ); + resize( vkConfig->value( opt->configKey(), QSize(600, 600)).toSize() ); + opt = valkyrie->getOption( VALKYRIE::MW_POS ); + move( vkConfig->value( opt->configKey(), QPoint(400, 0)).toPoint() ); toolViewStack = new ToolViewStack( this ); setCentralWidget( toolViewStack ); @@ -155,13 +185,13 @@ */ void MainWindow::setupActions() { - // TODO: shortcuts & tips + // TODO: shortcuts // act->setShortcut( tr("Ctrl+XXX") ); - // act->setStatusTip( tr("here's a tip") ); actFile_NewProj = new QAction( this ); actFile_NewProj->setObjectName( QString::fromUtf8("actFile_NewProj") ); actFile_NewProj->setText( QApplication::translate("MainWindowClass", "&New Project...", 0, QApplication::UnicodeUTF8) ); + actFile_NewProj->setToolTip( tr("Create a project to save your configuration") ); QIcon icon_newproj; icon_newproj.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/filenew.png") ), QIcon::Normal, QIcon::Off ); actFile_NewProj->setIcon( icon_newproj ); @@ -170,6 +200,7 @@ actFile_OpenProj = new QAction( this ); actFile_OpenProj->setObjectName( QString::fromUtf8("actFile_OpenProj") ); actFile_OpenProj->setText( QApplication::translate("MainWindowClass", "&Open Project...", 0, QApplication::UnicodeUTF8) ); + actFile_OpenProj->setToolTip( tr("Open an existing project to load a saved configuration") ); QIcon icon_openproj; icon_openproj.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/folder_blue.png") ), QIcon::Normal, QIcon::Off ); actFile_OpenProj->setIcon( icon_openproj ); @@ -177,12 +208,14 @@ actFile_Close = new QAction( this ); actFile_Close->setObjectName( QString::fromUtf8("actFile_Close") ); + actFile_Close->setToolTip( tr("Close the currently active tool") ); actFile_Close->setText( QApplication::translate("MainWindowClass", "&Close Tool", 0, QApplication::UnicodeUTF8) ); connect( actFile_Close, SIGNAL( triggered() ), this, SLOT( closeToolView() ) ); actFile_Exit = new QAction( this ); actFile_Exit->setObjectName( QString::fromUtf8("actFile_Exit") ); actFile_Exit->setText( QApplication::translate("MainWindowClass", "E&xit", 0, QApplication::UnicodeUTF8) ); + actFile_Exit->setToolTip( tr("Exit Valkyrie") ); QIcon icon_exit; icon_exit.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/exit.png") ), QIcon::Normal, QIcon::Off ); actFile_Exit->setIcon( icon_exit ); @@ -191,6 +224,7 @@ actEdit_Options = new QAction( this ); actEdit_Options->setObjectName( QString::fromUtf8("actEdit_Options") ); actEdit_Options->setText( QApplication::translate("MainWindowClass", "O&ptions", 0, QApplication::UnicodeUTF8) ); + actEdit_Options->setToolTip( tr("Open the options-editing window") ); QIcon icon_options; icon_options.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/gear.png") ), QIcon::Normal, QIcon::Off ); actEdit_Options->setIcon( icon_options ); @@ -199,6 +233,7 @@ actProcess_Run = new QAction( this ); actProcess_Run->setObjectName( QString::fromUtf8("actProcess_Run") ); actProcess_Run->setText( QApplication::translate("MainWindowClass", "&Run", 0, QApplication::UnicodeUTF8) ); + actProcess_Run->setToolTip( tr("Run Valgrind with the currently active tool") ); actProcess_Run->setShortcut( QApplication::translate("MainWindowClass", "Ctrl+R", 0, QApplication::UnicodeUTF8) ); QIcon icon_run; icon_run.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/valgrind_run.png") ), QIcon::Normal, QIcon::Off ); @@ -209,6 +244,7 @@ actProcess_Stop = new QAction( this ); actProcess_Stop->setObjectName( QString::fromUtf8("actProcess_Stop") ); actProcess_Stop->setText( QApplication::translate("MainWindowClass", "S&top", 0, QApplication::UnicodeUTF8) ); + actProcess_Stop->setToolTip( tr("Stop Valgrind") ); QIcon icon_stop; icon_stop.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/valgrind_stop.png") ), QIcon::Normal, QIcon::Off ); actProcess_Stop->setIcon( icon_stop ); @@ -217,6 +253,7 @@ actHelp_Handbook = new QAction( this ); actHelp_Handbook->setObjectName( QString::fromUtf8("actHelp_Handbook") ); actHelp_Handbook->setText( QApplication::translate("MainWindowClass", "Handbook", 0, QApplication::UnicodeUTF8) ); + actHelp_Handbook->setToolTip( tr("Open the Valkyrie Handbook") ); actHelp_Handbook->setShortcut( QApplication::translate("MainWindowClass", "F1", 0, QApplication::UnicodeUTF8) ); QIcon icon_handbook; icon_handbook.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/tb_handbook_help.xpm") ), QIcon::Normal, QIcon::Off ); @@ -356,7 +393,7 @@ mainToolBar = new QToolBar( this ); mainToolBar->setObjectName( QString::fromUtf8("mainToolBar") ); this->addToolBar( Qt::TopToolBarArea, mainToolBar ); - + // ------------------------------------------------------------ // Add actions to toolbar mainToolBar->addAction( actProcess_Run ); @@ -379,8 +416,6 @@ // Basic statusbar setup mainStatusBar = this->statusBar(); mainStatusBar->setObjectName( QString::fromUtf8("mainStatusBar ") ); -//TODO: why disable? -// mainStatusBar->setSizeGripEnabled( false ); statusLabel = new QLabel( mainStatusBar ); statusLabel->setObjectName( QString::fromUtf8("statusLabel ") ); @@ -390,6 +425,35 @@ /*! + Install our eventFilter for given widgets and all its children. + Just to support tooltips suppression - apparently the only way :-( +*/ +void MainWindow::updateEventFilters( QObject* obj ) +{ + foreach( QObject* obj, obj->children() ) { + obj->installEventFilter( this ); + updateEventFilters( obj ); + } +} + + +/*! + EventFilter: installed for all widgets. + If configure option given, suppress all ToolTips +*/ +bool MainWindow::eventFilter( QObject* obj, QEvent* e ) +{ + if ( !fShowToolTips && e->type() == QEvent::ToolTip ) { + // eat tooltip event + return true; + } else { + // pass the event on to the parent class + return QMainWindow::eventFilter( obj, e ); + } +} + + +/*! Show a requested ToolView, from the given \a toolId. The ToolViews are created and shown on demand. @@ -402,7 +466,7 @@ // already loaded and visible. return; } - // else: toolview maybe loaded, but isn't visible... + // else: toolview may still be loaded, but not visible... ToolView* nextView = toolViewStack->findView( toolId ); if ( nextView == 0) { @@ -412,6 +476,7 @@ ToolObject* nextTool = valkyrie->valgrind()->getToolObj( toolId ); vk_assert( nextTool != 0 ); + // Factory Method to create views nextView = nextTool->createView( this ); vk_assert( nextView != 0 ); @@ -419,15 +484,18 @@ this, SLOT(updateVgButtons(bool)) ); connect( nextTool, SIGNAL(message(QString)), this, SLOT(setStatus(QString)) ); -/* TODO - connect( this, SIGNAL(toolbarLabelsToggled(bool)), - nextView, SLOT(toggleToolbarLabels(bool)) ); -*/ - // view starts tool processes via this signal - connect( nextView, SIGNAL(run(int)), - this, SLOT(runTool(int)) ); + // Set a vg logfile. Loading done by tool_object + connect( nextView, SIGNAL(logFileChosen(QString)), + this, SLOT(setLogFile(QString)) ); + //TODO: perhaps bring emcheck::fileSaveDialog() here too... + // + Memcheck::saveParsedOutput() + + // view starts tool processes via this signal + connect( nextView, SIGNAL(run(int)), + this, SLOT(runTool(int)) ); + // add view to the stack toolViewStack->addView( nextView ); } @@ -436,7 +504,6 @@ toolViewStack->raiseView( nextView ); setToggles( toolId ); - updateVgFlags(); } @@ -473,7 +540,6 @@ } else { // at least one toolview found: update state - updateVgFlags(); // enable the relevant action in the tool actiongroup // TODO: nicer way to do this? - maybe connect sig/slot toolview to action? @@ -493,8 +559,137 @@ } +void MainWindow::showLabels() +{ + VkOption* opt = valkyrie->getOption( VALKYRIE::ICONTXT ); + bool show = vkConfig->value( opt->configKey() ).toBool(); + if ( show ) { + setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); + } else { + setToolButtonStyle( Qt::ToolButtonIconOnly ); + } +} + +void MainWindow::showToolTips() +{ + VkOption* opt = valkyrie->getOption( VALKYRIE::TOOLTIP ); + fShowToolTips = vkConfig->value( opt->configKey() ).toBool(); +} + + +void MainWindow::setGenFont() +{ + // TODO: qApp->setFont will be called twice if FNT_GEN_USR && FNT_GEN_SYS + // are both modified together - do we care? + + QFont fnt; + VkOption* opt = valkyrie->getOption( VALKYRIE::FNT_GEN_SYS ); + bool useVkSysFont = vkConfig->value( opt->configKey() ).toBool(); + if ( useVkSysFont ) { + fnt = lastAppFont; + } else { + lastAppFont = qApp->font(); + VkOption* opt = valkyrie->getOption( VALKYRIE::FNT_GEN_USR ); + QString str_fnt = vkConfig->value( opt->configKey() ).toString(); + fnt.fromString( str_fnt ); + } + + if ( qApp->font() != fnt ) { + qApp->setFont( fnt ); + } +} + +void MainWindow::setToolFont() +{ + QFont fnt; + VkOption* opt = valkyrie->getOption( VALKYRIE::FNT_TOOL_USR ); + QString str = vkConfig->value( opt->configKey() ).toString(); + fnt.fromString( str ); + + // set font for all tool views + foreach ( ToolObject* tool, valkyrie->valgrind()->getToolObjList() ) { + ToolView* tv = tool->view(); + if (tv != NULL) { + tv->setToolFont( fnt ); + } + } +} + +void MainWindow::setPalette() +{ + QPalette pal; + VkOption* opt = valkyrie->getOption( VALKYRIE::PALETTE ); + bool useVkPalette = vkConfig->value( opt->configKey() ).toBool(); + if ( !useVkPalette ) { + pal = lastPalette; + } else { + lastPalette = qApp->palette(); + + QColor bg = vkConfig->value( "valkyrie/colour_background" ).value<QColor>(); + QColor base = vkConfig->value( "valkyrie/colour_base" ).value<QColor>(); + QColor text = vkConfig->value( "valkyrie/colour_text" ).value<QColor>(); + QColor dkgray = vkConfig->value( "valkyrie/colour_dkgray" ).value<QColor>(); + QColor hilite = vkConfig->value( "valkyrie/colour_highlight" ).value<QColor>(); + + // anything not ok -> return default qApp palette: + if ( bg.isValid() && base.isValid() && text.isValid() && + dkgray.isValid() && hilite.isValid() ) { + + pal = QPalette( bg, bg ); + // 3 colour groups: active, inactive, disabled + // bg colour for text entry widgets + pal.setColor( QPalette::Active, QPalette::Base, base ); + pal.setColor( QPalette::Inactive, QPalette::Base, base ); + pal.setColor( QPalette::Disabled, QPalette::Base, base ); + // general bg colour + pal.setColor( QPalette::Active, QPalette::Window, bg ); + pal.setColor( QPalette::Inactive, QPalette::Window, bg ); + pal.setColor( QPalette::Disabled, QPalette::Window, bg ); + // same as bg + pal.setColor( QPalette::Active, QPalette::Button, bg ); + pal.setColor( QPalette::Inactive, QPalette::Button, bg ); + pal.setColor( QPalette::Disabled, QPalette::Button, bg ); + // general fg colour - same as Text + pal.setColor( QPalette::Active, QPalette::WindowText, text ); + pal.setColor( QPalette::Inactive, QPalette::WindowText, text ); + pal.setColor( QPalette::Disabled, QPalette::WindowText, dkgray ); + // same as fg + pal.setColor( QPalette::Active, QPalette::Text, text ); + pal.setColor( QPalette::Inactive, QPalette::Text, text ); + pal.setColor( QPalette::Disabled, QPalette::Text, dkgray ); + // same as text and fg + pal.setColor( QPalette::Active, QPalette::ButtonText, text ); + pal.setColor( QPalette::Inactive, QPalette::ButtonText, text ); + pal.setColor( QPalette::Disabled, QPalette::ButtonText, dkgray ); + // highlight + pal.setColor( QPalette::Active, QPalette::Highlight, hilite ); + pal.setColor( QPalette::Inactive, QPalette::Highlight, hilite ); + pal.setColor( QPalette::Disabled, QPalette::Highlight, hilite ); + // contrast with highlight + pal.setColor( QPalette::Active, QPalette::HighlightedText, base ); + pal.setColor( QPalette::Inactive, QPalette::HighlightedText, base ); + pal.setColor( QPalette::Disabled, QPalette::HighlightedText, base ); + } + } + + if ( qApp->palette() != pal ) { + qApp->setPalette( pal ); + } +} + + /*! + set logfile name to be loaded +*/ +void MainWindow::setLogFile( QString logFilename ) +{ + VkOption* opt = valkyrie->getOption( VALKYRIE::VIEW_LOG ); + opt->updateConfig( logFilename ); +} + + +/*! Create a new project: Save configuration in a project file. */ @@ -550,7 +745,7 @@ return; } - vkConfig->openProject( proj_filename ); + vkConfig->openProject( valkyrie, proj_filename ); } @@ -590,27 +785,8 @@ } -/*! - Called by this->showToolView(), - and optionsDlg::flagsChanged() signal -*/ -void MainWindow::updateVgFlags() -{ - // update valkyrie's flags: if there's a visible ToolView - if ( toolViewStack->isVisible() ) - valkyrie->updateVgFlags( toolViewStack->currentToolId() ); -//TODO: maybe. -#if 0 - // update flags display - if ( m_flagsLabel->isVisible() ) { - showFlagsWidget( true ); - } -#endif -} - - /*! Calls showToolView() for a chosen valgrind tool. @@ -624,13 +800,15 @@ { VGTOOL::ToolID toolId = (VGTOOL::ToolID)action->property( "toolId" ).toInt(); - cerr << "MainWindow::toolGroupTriggered() for toolview " << toolId << endl; +// cerr << "MainWindow::toolGroupTriggered() for toolview " << toolId << endl; + // widgets may have been added: update event filters + updateEventFilters( this ); + showToolView( toolId ); } - /*! Open the Options dialog. */ @@ -649,9 +827,7 @@ #else VkOptionsDialog optionsDlg( this ); - // let the flags widget know that flags may have been modified - connect( &optionsDlg, SIGNAL(flagsChanged()), - this, SLOT(updateVgFlags()) ); + updateEventFilters( &optionsDlg ); optionsDlg.exec(); #endif Modified: branches/valkyrie_qt4port/mainwindow.h =================================================================== --- branches/valkyrie_qt4port/mainwindow.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/mainwindow.h 2010-02-28 13:33:46 UTC (rev 477) @@ -22,10 +22,13 @@ #define __MAINWINDOW_H #include <QActionGroup> +#include <QEvent> +#include <QFont> #include <QLabel> +#include <QMainWindow> +#include <QPalette> #include <QPlainTextEdit> #include <QStatusBar> -#include <QMainWindow> #include <QToolButton> #include <QVBoxLayout> @@ -59,6 +62,8 @@ void setupToolBars(); void setupStatusBar(); void setToggles( VGTOOL::ToolID toolId ); + void updateEventFilters( QObject* obj ); + bool eventFilter( QObject* obj, QEvent* e ); private slots: void toolGroupTriggered( QAction* ); @@ -73,15 +78,19 @@ void openAboutVk(); void openAboutLicense(); void openAboutSupport(); - void updateVgFlags(); void updateVgButtons( bool running ); -private: - Valkyrie* valkyrie; - ToolViewStack* toolViewStack; - QLabel* statusLabel; - HandBook* handBook; + // functions for dealing with config updates + void showLabels(); + void showToolTips(); + void setGenFont(); + void setToolFont(); + void setPalette(); + // functions for dealing with toolview updates + void setLogFile( QString logFilename ); + + private: QAction* actFile_NewProj; QAction* actFile_OpenProj; @@ -108,7 +117,16 @@ QToolBar* mainToolBar; QStatusBar* mainStatusBar; +private: + Valkyrie* valkyrie; + ToolViewStack* toolViewStack; + QLabel* statusLabel; + HandBook* handBook; VkOptionsDialog* optionsDialog; + + bool fShowToolTips; + QFont lastAppFont; + QPalette lastPalette; }; #endif // __MAINWINDOW_H Modified: branches/valkyrie_qt4port/objects/helgrind_object.h =================================================================== --- branches/valkyrie_qt4port/objects/helgrind_object.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/helgrind_object.h 2010-02-28 13:33:46 UTC (rev 477) @@ -53,6 +53,7 @@ ToolView* createView( QWidget* parent ); unsigned int maxOptId() { return HELGRIND::NUM_OPTS; } int checkOptArg( int optid, QString& argval ); + VkOptionsPage* createVkOptionsPage(); bool start( int procId, QStringList vgflags ) { return false; } Modified: branches/valkyrie_qt4port/objects/memcheck_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/memcheck_object.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -231,38 +231,6 @@ } -/* called from Valkyrie::updateVgFlags() whenever flags have been changed */ -QStringList Memcheck::modifiedVgFlags() -{ - QStringList modFlags; -#if 0 - QString defVal, cfgVal, flag; - - Option* opt; - for ( opt = m_optList.first(); opt; opt = m_optList.next() ) { - flag = opt->m_longFlag.isEmpty() ? opt->m_shortFlag - : opt->m_longFlag; - defVal = opt->m_defaultValue; /* opt holds the default */ - cfgVal = vkConfig->rdEntry( opt->m_longFlag, name() ); - - switch ( (Memcheck::mcOpts)opt->m_key ) { - - /* when using xml output from valgrind, this option is preset to - 'full' by valgrind, so this option should not be used. */ - case LEAK_CHECK: - /* ignore this opt */ - break; - - default: - if ( defVal != cfgVal ) - modFlags << "--" + opt->m_longFlag + "=" + cfgVal; - } - } -#endif - return modFlags; -} - - /* Creates this tool's ToolView window, and sets up and connections between them */ ToolView* Memcheck::createView( QWidget* parent ) @@ -477,7 +445,7 @@ /*! - Parse log file given by [valkyrie::view-log] entry. + Parse log file given by [VALKYRIE::VIEW_LOG] entry. Called by valkyrie->runTool() if cmdline --view-log=<file> specified. MemcheckView::openLogFile() if gui parse-log selected. If 'checked' == true, file perms/format has already been checked @@ -487,7 +455,8 @@ vk_assert( getToolView() != 0 ); //TODO: pass this via flags from the toolview, or something. - QString log_file = vkConfig->value( "valkyrie/view-log" ).toString(); + VkOption* opt = options.getOption( VALKYRIE::VIEW_LOG ); + QString log_file = vkConfig->value( opt->configKey() ).toString(); statusMsg( "Parsing", log_file ); //TODO: file checks @@ -842,6 +811,7 @@ return true; } + /* Save to file - we already have everything in saveFname logfile, so just copy that */ Modified: branches/valkyrie_qt4port/objects/memcheck_object.h =================================================================== --- branches/valkyrie_qt4port/objects/memcheck_object.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/memcheck_object.h 2010-02-28 13:33:46 UTC (rev 477) @@ -81,9 +81,6 @@ VkOptionsPage* createVkOptionsPage(); - // returns a list of non-default flags to pass to valgrind - QStringList modifiedVgFlags(); - public slots: bool fileSaveDialog( QString fname=QString() ); void stop(); Modified: branches/valkyrie_qt4port/objects/tool_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/tool_object.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/tool_object.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -86,26 +86,27 @@ m_view->close( true/*alsoDelete*/ ); m_view = 0; } +#endif ToolView* ToolObject::view() { - return m_view; + return toolView; } /* called from Valkyrie::updateVgFlags() whenever flags have been changed */ -QStringList ToolObject::modifiedVgFlags() +QStringList ToolObject::getVgFlags() { QStringList modFlags; - for ( Option* opt = m_optList.first(); opt; opt = m_optList.next() ) { + foreach( VkOption* opt, options.getOptionHash() ) { - QString defVal = opt->m_defaultValue; /* opt holds the default */ - QString cfgVal = vkConfig->rdEntry( opt->m_longFlag, name() ); + QString defVal = opt->dfltValue.toString(); + QString cfgVal = vkConfig->value( opt->configKey() ).toString(); - if ( defVal != cfgVal ) - modFlags << "--" + opt->m_longFlag + "=" + cfgVal; + if ( defVal != cfgVal ) { + modFlags << "--" + opt->longFlag + "=" + cfgVal; + } } return modFlags; } -#endif Modified: branches/valkyrie_qt4port/objects/tool_object.h =================================================================== --- branches/valkyrie_qt4port/objects/tool_object.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/tool_object.h 2010-02-28 13:33:46 UTC (rev 477) @@ -60,8 +60,9 @@ // called by MainWin::closeToolView() virtual bool queryDone() = 0; virtual void deleteView(); - ToolView* view(); */ + ToolView* view(); + // start a process: may fail virtual bool start( int procId, QStringList vgflags ) = 0; // stop a process: doesn't exit until success @@ -69,12 +70,10 @@ bool isRunning(); -/* - virtual OptionsPage* createOptionsPage( OptionsWindow* parent ) = 0; + virtual VkOptionsPage* createVkOptionsPage() = 0; // returns a list of non-default flags to pass to valgrind - virtual QStringList modifiedVgFlags(); -*/ + virtual QStringList getVgFlags(); signals: void running( bool ); Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -31,7 +31,7 @@ #include "objects/memcheck_object.h" //#include "cachegrind_object.h" //#include "massif_object.h" -//#include "vk_option.h" // PERROR* and friends +#include "options/vk_option.h" #include "utils/vk_utils.h" // vk_assert, VK_DEBUG, etc. @@ -70,7 +70,6 @@ */ void Valgrind::setupOptions() { - // ------------------------------------------------------------ // tool options.addOpt( @@ -590,7 +589,7 @@ case VALGRIND::SUPPS_DIRS: { /* not popt: only reaches here from gui */ /* check all entries are valid dirs */ - QStringList dirs = QStringList::split(sep, argval); + QStringList dirs = QStringList::split(sep, argval); //, QString::SkipEmptyParts QStringList::iterator it = dirs.begin(); for (; it != dirs.end(); ++it) { /* check dirs ok */ @@ -603,7 +602,7 @@ case VALGRIND::SUPPS_AVAIL: /* not popt: only reaches here from gui */ case VALGRIND::SUPPS_SEL: { /* is popt: --suppressions */ - QStringList files = QStringList::split(sep, argval); + QStringList files = QStringList::split(sep, argval); //, QString::SkipEmptyParts QStringList::iterator it = files.begin(); for (; it != files.end(); ++it) { /* check files ok & readable */ @@ -704,59 +703,70 @@ } -#if 0 -/* valkyrie hijacks any log-to-file flags; these are not passed to - valgrind, but are used after parsing has finished to save to. */ -QStringList Valgrind::modifiedVgFlags( const ToolObject* tool_obj ) +/*! + Return list of non-default flags, including those for tool_obj. + + Note: Valkyrie hijacks any log-to-file flags; these are not passed to + valgrind, but are used after parsing has finished to save to. +*/ +QStringList Valgrind::getVgFlags( ToolObject* tool_obj ) { QStringList modFlags; - QString defVal, cfgVal, flag; - for ( Option* opt = m_optList.first(); opt; opt = m_optList.next() ) { - flag = opt->m_longFlag.isEmpty() ? opt->m_shortFlag - : opt->m_longFlag; - defVal = opt->m_defaultValue; - cfgVal = vkConfig->rdEntry( opt->cfgKey(), name() ); + foreach( VkOption* opt, options.getOptionHash() ) { + QString defVal = opt->dfltValue.toString(); + QString cfgVal = vkConfig->value( opt->configKey() ).toString(); - switch ( (Valgrind::vgOpts)opt->m_key ) { + switch ( (VALGRIND::vgOptId)opt->optid ) { - /* we never want these included */ + // we never want these included case VALGRIND::TOOL: /* tool set by valkyrie */ case VALGRIND::SUPPS_DIRS: /* false option */ case VALGRIND::SUPPS_AVAIL: /* false option */ + // ignore these opts break; - /* only error-reporting tools have suppressions */ + // only error-reporting tools have suppressions case VALGRIND::SUPPS_SEL: { - if ( tool_obj->name() == "memcheck" ) { - /* we need '--suppressions=' before each and every filename */ - QString optEntry = vkConfig->rdEntry( opt->cfgKey(), name() ); - QStringList files = QStringList::split( ",", optEntry ); - for ( unsigned int i=0; i<files.count(); i++ ) { - modFlags << "--" + opt->cfgKey() + "=" + files[i]; + if ( tool_obj->objectName() == "memcheck" ) { + // we need '--suppressions=' before each and every filename + QString optEntry = vkConfig->value( opt->configKey() ).toString(); + QStringList files = optEntry.split( ",", QString::SkipEmptyParts ); + for ( int i=0; i<files.count(); i++ ) { + modFlags << "--" + opt->longFlag + "=" + files[i]; } + } else { + // ignore opt } } break; - /* for memcheck we always need xml=yes */ + // for memcheck we always need xml=yes case VALGRIND::XML_OUTPUT: - if ( tool_obj->name() == "memcheck") - modFlags << "--" + opt->cfgKey() + "=yes"; - else - if ( defVal != cfgVal ) - modFlags << "--" + opt->cfgKey() + "=" + cfgVal; + if ( tool_obj->objectName() == "memcheck") { + modFlags << "--" + opt->longFlag + "=yes"; + } else { + if ( defVal != cfgVal ) { + modFlags << "--" + opt->longFlag + "=" + cfgVal; + } + } break; - /* for memcheck we needs this enabled to keep the xml clean */ + // for memcheck we need this enabled to keep the xml clean case VALGRIND::SILENT_CH: - if ( tool_obj->name() == "memcheck") - modFlags << "--" + opt->cfgKey() + "=yes"; - else - if ( defVal != cfgVal ) - modFlags << "--" + opt->cfgKey() + "=" + cfgVal; + if ( tool_obj->objectName() == "memcheck") { + modFlags << "--" + opt->longFlag + "=yes"; + } else { + if ( defVal != cfgVal ) { + modFlags << "--" + opt->longFlag + "=" + cfgVal; + } + } break; + // memcheck presets/ignores these options for xml output + // - ignore these opts + // - see valgrind/docs/internals/xml_output.txt + // Note: gui options not disabled: other tools use these options case VALGRIND::VERBOSITY: case VALGRIND::TRACK_FDS: case VALGRIND::TIME_STAMP: @@ -765,38 +775,38 @@ case VALGRIND::ERROR_LIMIT: case VALGRIND::DB_ATTACH: case VALGRIND::DB_COMMAND: - if ( defVal != cfgVal ) { - // disabled for now: /* gui options not disabled: other tools use these options */ - if ( tool_obj->name() == "memcheck") { - /* memcheck presets/ignores these options for xml output - - ignore these opts - - see valgrind/docs/internals/xml_output.txt */ - } else { - modFlags << "--" + opt->cfgKey() + "=" + cfgVal; + if ( tool_obj->objectName() == "memcheck") { + // ignore these opts + } else { + if ( defVal != cfgVal ) { + modFlags << "--" + opt->longFlag + "=" + cfgVal; } } break; - /* all tools use an internal logging option, - all logging options should therefore not be used */ + // all tools use an internal logging option, + // so logging options should not be used case VALGRIND::LOG_FILE: case VALGRIND::LOG_FD: case VALGRIND::LOG_SOCKET: - /* ignore these opts */ + // ignore these opts break; + // default: add --option=value default: if ( defVal != cfgVal ) { - modFlags << "--" + opt->cfgKey() + "=" + cfgVal; + modFlags << "--" + opt->longFlag + "=" + cfgVal; } break; } } + // Collect non-default tool flags: + modFlags += tool_obj->getVgFlags(); + return modFlags; } -#endif /*! Register tools Modified: branches/valkyrie_qt4port/objects/valgrind_object.h =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/valgrind_object.h 2010-02-28 13:33:46 UTC (rev 477) @@ -80,10 +80,8 @@ Valgrind(); ~Valgrind(); -#if 0 - /* returns a list of non-default flags to pass to valgrind */ - QStringList modifiedVgFlags( const ToolObject* tool_obj ); -#endif + QStringList getVgFlags( ToolObject* tool_obj ); + unsigned int maxOptId() { return VALGRIND::NUM_OPTS; } int checkOptArg( int optid, QString& argval ); Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -26,6 +26,7 @@ #include "utils/vk_utils.h" #include <QFile> +#include <QPoint> #include <QStringList> @@ -62,8 +63,6 @@ } - - /*! Setup the options for this object. */ @@ -91,8 +90,8 @@ 'v', "", "", + PACKAGE_VERSION, "", - "", "display version information and exit", urlNone, VkOPT::ARG_NONE, @@ -151,7 +150,7 @@ '\0', "", "true|false", - "true", + "false", "Show toolbar text labels", "", urlValkyrie::toolLabels, @@ -340,55 +339,118 @@ VkOPT::NOT_POPT, VkOPT::WDG_LEDIT ); -} + options.addOpt( + VALKYRIE::VIEW_LOG, + this->objectName(), + "view-log", + 'v', + "<file>", + "", + "", + "", + "parse and view a valgrind logfile", + urlNone, + VkOPT::ARG_STRING, + VkOPT::WDG_NONE + ); -void Valkyrie::setConfigDefaults() -{ - vkConfig->beginGroup( this->objectName() ); - OptionHash opts = options.getOptionHash(); - for ( Iter_OptionHash it = opts.begin(); it != opts.end(); ++it ) { - VkOption* opt = it.value(); + // Internal configuration + options.addOpt( + VALKYRIE::MW_SIZE, this->objectName(), "mainwindow_size", + '\0', "", "", QSize(600, 600), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); - /* Don't create config entries for these options: - They don't hold persistent data, and have no associated option widget */ - if (opt->optid == VALKYRIE::HELP ) continue; - if (opt->optid == VALKYRIE::VGHELP ) continue; + options.addOpt( + VALKYRIE::MW_POS, this->objectName(), "mainwindow_pos", + '\0', "", "", QPoint(400, 0), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); - vkConfig->setValue( opt->longFlag, opt->dfltValue ); - } + options.addOpt( + VALKYRIE::HB_HIST, this->objectName(), "handbook_history", + '\0', "", "", "", "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); - vkConfig->endGroup(); + options.addOpt( + VALKYRIE::HB_BKMK, this->objectName(), "handbook_bookmarks", + '\0', "", "", "", "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); + options.addOpt( + VALKYRIE::HB_MXHIST, this->objectName(), "handbook_max_history", + '\0', "", "", "20", "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); - // Colour Defaults - vkConfig->beginGroup( this->objectName() + "_colours" ); - vkConfig->setValue( "background", QColor(214,205,187) ); - vkConfig->setValue( "base", QColor(255,255,255) ); - vkConfig->setValue( "dkgray", QColor(128,128,128) ); - vkConfig->setValue( "editColor", QColor(254,222,190) ); - vkConfig->setValue( "highlight", QColor(147, 40, 40) ); - vkConfig->setValue( "nullColor", QColor(239,227,211) ); - vkConfig->setValue( "text", QColor(0, 0, 0) ); - vkConfig->endGroup(); + options.addOpt( + VALKYRIE::HB_MXBKMK, this->objectName(), "handbook_max_bookmarks", + '\0', "", "", "20", "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); - // MainWindow Defaults - vkConfig->beginGroup( this->objectName() + "_mainwindow" ); - vkConfig->setValue( "size", QSize(600, 600) ); - vkConfig->setValue( "pos", QPoint(400, 0) ); - vkConfig->endGroup(); + options.addOpt( + VALKYRIE::COL_BKGD, this->objectName(), "colour_background", + '\0', "", "", QColor(214,205,187), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); - // Handbook defaults - vkConfig->beginGroup( this->objectName() + "_handbook" ); - vkConfig->setValue( "max_bookmarks", "20" ); - vkConfig->setValue( "max_history", "20" ); - vkConfig->endGroup(); + options.addOpt( + VALKYRIE::COL_BASE, this->objectName(), "colour_base", + '\0', "", "", QColor(255,255,255), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); + + options.addOpt( + VALKYRIE::COL_DKGR, this->objectName(), "colour_dkgray", + '\0', "", "", QColor(128,128,128), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); + + options.addOpt( + VALKYRIE::COL_EDIT, this->objectName(), "colour_edit", + '\0', "", "", QColor(254,222,190), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); + + options.addOpt( + VALKYRIE::COL_HILT, this->objectName(), "colour_highlight", + '\0', "", "", QColor(147, 40, 40), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); + + options.addOpt( + VALKYRIE::COL_NULL, this->objectName(), "colour_null", + '\0', "", "", QColor(239,227,211), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); + + options.addOpt( + VALKYRIE::COL_TEXT, this->objectName(), "colour_text", + '\0', "", "", QColor( 0, 0, 0), "", "", + urlNone, VkOPT::NOT_POPT, VkOPT::WDG_NONE + ); } +void Valkyrie::setConfigDefaults() +{ + foreach( VkOption* opt, options.getOptionHash() ) { + // Don't create config entries for these options: + // - They don't hold persistent data, and have no associated option widget + if (opt->optid == VALKYRIE::HELP ) continue; + if (opt->optid == VALKYRIE::VGHELP ) continue; + opt->updateConfig( opt->dfltValue ); + } + } + + /*! Check \a argval for the option given by \a optGrp and \a optid. The \a argval may be updated. @@ -441,7 +503,7 @@ if ( !QFile::exists( proj_filename ) ) { vkConfig->createNewProject( proj_filename ); } else { - vkConfig->openProject( proj_filename ); + vkConfig->openProject( this, proj_filename ); } } @@ -486,11 +548,25 @@ } break; case VALKYRIE::SRC_EDITOR: { - QString ed_file = QStringList::split(" ", argval).first(); + QString ed_file = QStringList::split(" ", argval).first(); //, QString::SkipEmptyParts QString ed = binaryCheck( &errval, ed_file ); argval.replace( ed_file, ed ); } break; +#if 0 //TODO: return ok, but give warning. + + // if no "%n", give warning + if ( argval.indexOf( "%n" ) == -1 ) { + QFileInfo fi( argval.split(" ", QString::SkipEmptyParts).first() ); + if ( !fi.fileName().startsWith("emacs") && !fi.fileName().startsWith("nedit") ) { + vkInfo( this, "Unknown Source Editor", + "If possible, set an editor flag to allow the \ + editor to be opened at a target line-number, \ + where %%n will be replaced with the line-number." ); + } + } +#endif + case VALKYRIE::PROJ_FILE: { #if 0 // TODO: review this @@ -583,12 +659,39 @@ } +/*! + Find the option owner, find option within that owner. + Called from VkConfig::readFromConfigFile(...) + Warning: slow! +*/ +VkOption* Valkyrie::findOption( QString& optKey ) +{ + QStringList parts = optKey.split( "/", QString::SkipEmptyParts ); + vk_assert( parts.count() == 2 ); + QString optGrp = parts.at(0); + QString optFlag = parts.at(1); + VkObjectList objList = this->vkObjList(); + for (int i = 0; i < objList.size(); ++i) { + VkObject* obj = objList.at(i); + if ( obj->objectName() == optGrp ) { + foreach( VkOption* opt, obj->getOptions() ) { + if ( opt->longFlag == optFlag ) { + return opt; + } + } + } + } + return NULL; +} + + +#if 0 /*! Find the option owner, find option within that owner. */ -VkOption* Valkyrie::findOption( QString optGrp, int optid ) +VkOption* Valkyrie::findOption( QString& optGrp, int optid ) { VkObjectList objList = this->vkObjList(); for (int i = 0; i < objList.size(); ++i) { @@ -600,8 +703,10 @@ } return NULL; } +#endif + /*! Return list of all VkObjects */ @@ -649,36 +754,52 @@ ToolObject* activeTool = valgrind()->getToolObj( tId ); vk_assert( activeTool != 0 ); + QStringList vg_flags = getVgFlags( tId ); + return activeTool->start( procId, vg_flags ); } /*! - Update flags for current tool - Called by MainWindow::updateVgFlags() - - which is triggered by optionsWin::flagsChanged signal + Returns valgrind flags for given tool */ -void Valkyrie::updateVgFlags( VGTOOL::ToolID tId ) +QStringList Valkyrie::getVgFlags( VGTOOL::ToolID tId ) { -cerr << "Valkyrie::updateVgFlags( " << tId << ")" << endl; - vk_assert( tId != VGTOOL::ID_NULL ); ToolObject* tool = valgrind()->getToolObj( tId ); vk_assert( tool != 0 ); - QString vg_exec = vkConfig->value( "valkyrie/vg-exec" ).toString(); - if (vg_exec.isEmpty()) - vg_exec = "valgrind"; // hope it's in $PATH + // if we don't find it in config, let's hope it's in $PATH + VkOption* opt = options.getOption( VALKYRIE::VG_EXEC ); + QString vg_exec = vkConfig->value( opt->configKey(), "valgrind" ).toString(); - // modifiedVgFlags() functions return non-default flags - vg_flags.clear(); - vg_flags << vg_exec; // path/to/valgrind - vg_flags << "--tool=" + tool->objectName(); // tool + QStringList vg_flags; + vg_flags << vg_exec; // path/to/valgrind + vg_flags << "--tool=" + tool->objectName(); // active tool (!= valgrind()->TOOL) + vg_flags += valgrind()->getVgFlags( tool ); // valgrind (+ tool) opts + vg_flags += getTargetFlags(); // valkyrie opts -//TODO: - vg_flags << "ls"; -// vg_flags += valgrind()->modifiedVgFlags( tool ); // valgrind opts -// vg_flags += tool->modifiedVgFlags(); // tool opts -// vg_flags += this->modifiedVgFlags(); // valkyrie opts + return vg_flags; } + +/*! + Returns valgrind flags for given tool +*/ +QStringList Valkyrie::getTargetFlags() +{ + QStringList modFlags; + VkOption* opt = options.getOption( VALKYRIE::BINARY ); + QString cfgVal = vkConfig->value( opt->configKey() ).toString(); + + // only add binary & bin_flags if binary present + if ( !cfgVal.isEmpty() ) { + modFlags << cfgVal; + + // add any target binary flags + opt = options.getOption( VALKYRIE::BIN_FLAGS ); + cfgVal = vkConfig->value( opt->configKey() ).toString(); + modFlags += cfgVal.split( " ", QString::SkipEmptyParts ); + } + return modFlags; +} Modified: branches/valkyrie_qt4port/objects/valkyrie_object.h =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/valkyrie_object.h 2010-02-28 13:33:46 UTC (rev 477) @@ -24,6 +24,7 @@ #include "objects/valgrind_object.h" #include "objects/vk_objects.h" + // ============================================================ namespace VALKYRIE { /*! @@ -48,6 +49,20 @@ VG_EXEC, // path to valgrind executable BINARY, // user-binary to be valgrindised BIN_FLAGS, // flags for user-binary + VIEW_LOG, + MW_SIZE, + MW_POS, + HB_HIST, + HB_BKMK, + HB_MXHIST, + HB_MXBKMK, + COL_BKGD, + COL_BASE, + COL_DKGR, + COL_EDIT, + COL_HILT, + COL_NULL, + COL_TEXT, NUM_OPTS }; } @@ -69,7 +84,6 @@ #if 0 // TODO bool queryToolDone( int tId ); #endif - void updateVgFlags( VGTOOL::ToolID tId ); unsigned int maxOptId() { return VALKYRIE::NUM_OPTS; } @@ -88,18 +102,20 @@ - VkOption* findOption( QString optGrp, int optid ); + VkOption* findOption( QString& optKey ); +// VkOption* findOption( QString& optGrp, int optid ); // list of all objects const VkObjectList vkObjList(); // VkObject* vkObject( int objId ); private: + QStringList getVgFlags( VGTOOL::ToolID tId ); + QStringList getTargetFlags(); void setupOptions(); private: Valgrind* m_valgrind; - QStringList vg_flags; }; Modified: branches/valkyrie_qt4port/objects/vk_objects.cpp =================================================================== --- branches/valkyrie_qt4port/objects/vk_objects.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/vk_objects.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -72,7 +72,7 @@ VkOption* opt = getOption( optid ); vk_assert( opt != NULL ); - vkConfig->setValue( opt->configKey(), argval ); + opt->updateConfig( argval ); } @@ -82,15 +82,7 @@ */ void VkObject::setConfigDefaults() { - vkConfig->beginGroup( this->objectName() ); - - OptionHash opts = options.getOptionHash(); - for ( Iter_OptionHash it = opts.begin(); it != opts.end(); ++it ) { - VkOption* opt = it.value(); - QString config_key = opt->longFlag; - QString config_value = opt->dfltValue; - vkConfig->setValue( config_key, config_value ); - } - - vkConfig->endGroup(); + foreach( VkOption* opt, options.getOptionHash() ) { + opt->updateConfig( opt->dfltValue ); + } } Modified: branches/valkyrie_qt4port/objects/vk_objects.h =================================================================== --- branches/valkyrie_qt4port/objects/vk_objects.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/objects/vk_objects.h 2010-02-28 13:33:46 UTC (rev 477) @@ -47,7 +47,7 @@ virtual unsigned int maxOptId() = 0; - /*! check argval for this option, updating if necessary. + /*! check argval for given option (updating argval if necessary). called by parseCmdArgs() and gui option pages */ virtual int checkOptArg( int optid, QString& argval ) = 0; Modified: branches/valkyrie_qt4port/options/helgrind_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/helgrind_options_page.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/options/helgrind_options_page.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -71,14 +71,3 @@ // sanity checks vk_assert( m_itemList.count() <= HELGRIND::NUM_OPTS ); } - - - - -/*! - called when user clicks "Apply" / "Ok" / "Reset" buttons. -*/ -void HelgrindOptionsPage::applyOption( int ) {} - - - Modified: branches/valkyrie_qt4port/options/helgrind_options_page.h =================================================================== --- branches/valkyrie_qt4port/options/helgrind_options_page.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/options/helgrind_options_page.h 2010-02-28 13:33:46 UTC (rev 477) @@ -32,7 +32,6 @@ public: HelgrindOptionsPage( VkObject* obj ); - void applyOption( int optId ); private: void setupOptions(); Modified: branches/valkyrie_qt4port/options/memcheck_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/memcheck_options_page.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/options/memcheck_options_page.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -113,25 +113,3 @@ // sanity checks vk_assert( m_itemList.count() <= MEMCHECK::NUM_OPTS ); } - - - - -/*! - called when user clicks "Apply" / "Ok" / "Reset" buttons. -*/ -void MemcheckOptionsPage::applyOption( int optId ) -{ - vk_assert( optId >= 0 && optId < MEMCHECK::NUM_OPTS ); - -// QString argval = m_itemList[optId]->currValue(); - - /* apply option */ - switch ( optId ) { - default: - break; - } -} - - - Modified: branches/valkyrie_qt4port/options/memcheck_options_page.h =================================================================== --- branches/valkyrie_qt4port/options/memcheck_options_page.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/options/memcheck_options_page.h 2010-02-28 13:33:46 UTC (rev 477) @@ -32,7 +32,6 @@ public: MemcheckOptionsPage( VkObject* obj ); - void applyOption( int optId ); private: void setupOptions(); Modified: branches/valkyrie_qt4port/options/valgrind_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-02-28 13:33:46 UTC (rev 477) @@ -298,9 +298,9 @@ - update suppDirs, suppsAvail from each path in lbSel */ QChar sep = vkConfig->vkSepChar; LbWidget* lbSel = (LbWidget*)m_itemList[Valgrind::SUPPS_SEL ]; - QStringList currSupps = QStringList::split( sep, lbSel->currValue() ); + QStringList currSupps = QStringList::split( sep, lbSel->currValue() ); //, QString::SkipEmptyParts LbWidget* lbDirs = (LbWidget*)m_itemList[Valgrind::SUPPS_DIRS]; - QStringList suppDirs = QStringList::split( sep, lbDirs->currValue() ); + QStringList suppDirs = QStringList::split( sep, lbDirs->currValue() ); //, QString::SkipEmptyParts for ( unsigned int i=0; i<currSupps.count(); i++ ) { QFileInfo fi( currSupps[i] ); @@ -318,23 +318,7 @@ } #endif -/* called when user clicks "Apply" / "Ok" / "Reset" buttons. */ -void ValgrindOptionsPage::applyOption( int optId ) -{ - vk_assert( optId >= 0 && optId < VALGRIND::NUM_OPTS ); -#if 0 -// QString argval = m_itemList[optId]->currValue(); - - /* apply option */ - switch ( optId ) { - default: - break; - } -#endif -} - - void ValgrindOptionsPage::getDbBin() { vkPrintErr("TODO: ValgrindOptionsPage::getDbBin()\n"); @@ -352,7 +336,7 @@ QChar sep = vkConfig->vkSepChar; /* Get list of dirs from "valgrind::supps-dirs" */ - QStringList suppDirs = lbDirs->currValue().split( sep ); + QStringList suppDirs = lbDirs->currValue().split( sep, QString::SkipEmptyParts ); for ( int i=0; i<suppDirs.count(); i++ ) { /* for each suppDir, find all supp files */ @@ -378,7 +362,7 @@ LbWidget* lbAvail = (LbWidget*)m_itemList[VALGRIND::SUPPS_AVAIL]; LbWidget* lbSel = (LbWidget*)m_itemList[VALGRIND::SUPPS_SEL ]; QStringList suppsAvail = m_allAvailSuppFiles; - QStringList currSupps = lbSel->currValue().split( sep ); + QStringList currSupps = lbSel->currValue().split( sep, QString::SkipEmptyParts ); for ( int i=0; i<currSupps.count(); i++ ) { int idx = suppsAvail.indexOf( currSupps[i] ); Modified: branches/valkyrie_qt4port/options/valgrind_options_page.h =================================================================== --- branches/valkyrie_qt4port/options/valgrind_options_page.h 2010-02-13 00:27:22 UTC (rev 476) +++ branches/valkyrie_qt4port/options/valgrind_options_page.h 2010-02-28 13:33:46 UTC (re... [truncated message content] |