From: <sv...@va...> - 2010-03-12 00:30:57
|
Author: cerion Date: 2010-03-12 00:30:43 +0000 (Fri, 12 Mar 2010) New Revision: 492 Log: options pages: - before saving to global config, query if user certain - brought back in functionality to help choose options: fonts, dirs, files, etc. - bigger font for option-page choice list Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp branches/valkyrie_qt4port/options/valgrind_options_page.cpp branches/valkyrie_qt4port/options/valkyrie_options_page.cpp branches/valkyrie_qt4port/options/vk_options_dialog.cpp branches/valkyrie_qt4port/options/vk_options_page.cpp branches/valkyrie_qt4port/utils/vk_config.cpp Modified: branches/valkyrie_qt4port/objects/valkyrie_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/objects/valkyrie_object.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -543,26 +543,32 @@ case VALKYRIE::FNT_GEN_SYS: case VALKYRIE::FNT_GEN_USR: case VALKYRIE::FNT_TOOL_USR: - case VALKYRIE::SRC_LINES: - case VALKYRIE::BROWSER: { + case VALKYRIE::SRC_LINES: { vk_assert( opt->argType == VkOPT::NOT_POPT ); return errval; } break; - // dir options: check for rwx permissions + // dir options: check for RWX permissions case VALKYRIE::DFLT_LOGDIR: case VALKYRIE::WORKING_DIR: { ( void ) dirCheck( &errval, argval, true, true, true ); } break; + // helper executables + case VALKYRIE::BROWSER: case VALKYRIE::SRC_EDITOR: { - // source editor executable: check for at least X permissions - QString ed_file = argval.split( " " ).first(); - QString ed = fileCheck( &errval, ed_file, false, false, true ); - argval.replace( ed_file, ed ); - argval = argval.simplified(); + if ( argval.isEmpty() ) { + // empty is fine. + } else { + // check for at least X permissions. + QString path = argval.split( " " ).first(); + QString file = fileCheck( &errval, path, false, false, true ); + argval.replace( path, file ); + argval = argval.simplified(); + } } break; + // valkyrie project file case VALKYRIE::PROJ_FILE: { // check file exists and has RW perms argval = fileCheck( &errval, argval, true, true ); Modified: branches/valkyrie_qt4port/options/valgrind_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/valgrind_options_page.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -291,8 +291,8 @@ -#if 0 -/* Called from OptionsWindow::categoryClicked() */ +#if 1 +/* Called from OptionsDialog::categoryClicked() */ void ValgrindOptionsPage::init() { /* if usr gave suppfile on cmdline (updating lbSel) @@ -329,9 +329,10 @@ } -/* Scan dirs set in option "valgrind::supps-dirs" for available - suppression files. - Update other widgets with result. +/*! + Scan dirs set in option "valgrind::supps-dirs" for available + suppression files. + Update other widgets with result. */ void ValgrindOptionsPage::suppDirsChanged() { @@ -339,12 +340,12 @@ LbWidget* lbDirs = ( LbWidget* )m_itemList[VALGRIND::SUPPS_DIRS]; QChar sep = vkConfig->vkSepChar; - /* Get list of dirs from "valgrind::supps-dirs" */ + // Get list of dirs from "valgrind::supps-dirs" QStringList suppDirs = lbDirs->currValue().split( sep, QString::SkipEmptyParts ); for ( int i = 0; i < suppDirs.count(); i++ ) { - /* for each suppDir, find all supp files */ + // for each suppDir, find all supp files QDir suppDir( suppDirs[i] ); QString path = suppDir.absolutePath() + '/'; QStringList entries = suppDir.entryList( QStringList( "*.supp" ), QDir::Files ); @@ -358,9 +359,10 @@ } -/* Given available suppfiles from dirscan, - remove those already selected in option "valgrind::supps-sel" - Set suppsAvail list with result. +/*! + Given available suppfiles from dirscan, + remove those already selected in option "valgrind::supps-sel" + Set suppsAvail list with result. */ void ValgrindOptionsPage::updateSuppsAvail() { @@ -382,8 +384,9 @@ } -/* Called by selecting an item in suppsAvail listbox. - Adds item to selected supps listbox (up to limit) +/*! + Called by selecting an item in suppsAvail listbox. + Adds item to selected supps listbox (up to limit) */ void ValgrindOptionsPage::updateSuppsSel( const QString& suppr ) { @@ -393,7 +396,7 @@ lbSel->insertItem( suppr ); } else { - /* valgrind doesn't accept any more suppression files */ + // valgrind doesn't accept any more suppression files vkError( this, "Error", "Valgrind won't accept more than %d suppression files", VG_CLO_MAX_SFILES ); Modified: branches/valkyrie_qt4port/options/valkyrie_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/valkyrie_options_page.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -19,8 +19,10 @@ ****************************************************************************/ #include <QApplication> -#include <QVBoxLayout> +#include <QFileDialog> +#include <QFontDialog> #include <QLabel> +#include <QVBoxLayout> #include "help/help_context.h" #include "help/help_urls.h" @@ -194,171 +196,167 @@ } -/* called by pbFont: conjures up a QFontDialog */ +/*! + Allows user to select a general font +*/ void ValkyrieOptionsPage::chooseGenFont() { - cerr << "TODO: ValkyrieOptionsPage::chooseGenFont()" << endl; -#if 0 // TODO LeWidget* fontLedit = (( LeWidget* )m_itemList[VALKYRIE::FNT_GEN_USR] ); QFont afont; - afont.fromString( fontLedit->initValue() ); + afont.fromString( fontLedit->currValue() ); bool ok; - QFont font = QFontDialog::getFont( &ok, afont, this ); + QFont font = QFontDialog::getFont( &ok, afont, this, "Select General Font" ); if ( ok ) { fontLedit->setCurrValue( font.toString() ); } - else { /* user clicked cancel */ - m_itemList[VALKYRIE::FNT_GEN_SYS]->reset(); - } - -#endif } -/* called by pbFont: conjures up a QFontDialog */ +/*! + Allows user to select a tool font +*/ void ValkyrieOptionsPage::chooseToolFont() { - cerr << "TODO: ValkyrieOptionsPage::chooseToolFont()" << endl; -#if 0 // TODO LeWidget* fontLedit = (( LeWidget* )m_itemList[VALKYRIE::FNT_TOOL_USR] ); QFont afont; - afont.fromString( fontLedit->initValue() ); + afont.fromString( fontLedit->currValue() ); bool ok; - QFont font = QFontDialog::getFont( &ok, afont, this ); + QFont font = QFontDialog::getFont( &ok, afont, this, "Select Tool Font" ); if ( ok ) { fontLedit->setCurrValue( font.toString() ); } - -#endif } +/*! + Allows user to select the source editor +*/ void ValkyrieOptionsPage::getEditor() { - cerr << "TODO: ValkyrieOptionsPage::getEditor()" << endl; -#if 0 // TODO - /* try and start up somewhere sensible */ - QString ed = m_itemList[VALKYRIE::SRC_EDITOR]->currValue(); - QString ed_file = QStringList::split( " ", ed ).first(); //, QString::SkipEmptyParts - QFileInfo fi( ed_file ); + // try and start up somewhere sensible + QString start_dir = "/"; + + // get current dir of current editor + LeWidget* editLedit = (( LeWidget* )m_itemList[VALKYRIE::SRC_EDITOR] ); + QString ed = editLedit->currValue(); + if ( !ed.isEmpty() ) { + QString ed_file = ed.split( " ", QString::SkipEmptyParts ).first(); + int err_val; + ed_file = fileCheck( &err_val, ed_file, false, false, true ); + + QFileInfo fi( ed_file ); + start_dir = fi.absolutePath(); + } - QString ed_path = - QFileDialog::getOpenFileName( fi.dirPath(), "All Files (*)", - this, "fdlg", "Select Source Editor" ); + QString editor = + QFileDialog::getOpenFileName( this, tr("Select Source Editor"), + start_dir, tr("All Files (*)")); - if ( ed_path.isEmpty() ) { /* user might have clicked Cancel */ - return; + if ( !editor.isEmpty() ) { // user might have clicked Cancel + + // for a few well known editors, add the + // go-to-line editor flag, plus our replacement string (%n) + QFileInfo fi( editor ); + if ( fi.fileName().startsWith( "emacs " ) || + fi.fileName().startsWith( "gedit " ) || + fi.fileName().startsWith( "gvim " ) || + fi.fileName().startsWith( "nano " ) || + fi.fileName().startsWith( "nedit " ) ) { + editor += " +%n"; + } + + editLedit->setCurrValue( editor ); + checkOption( VALKYRIE::SRC_EDITOR ); } - - fi.setFile( ed_path ); - - ed = ed_path; - - if ( fi.fileName().startsWith( "emacs" ) || - fi.fileName().startsWith( "nedit" ) ) { - /* add go-to-line flag + replacement string (%n) */ - ed += " +%n"; - } - - (( LeWidget* )m_itemList[VALKYRIE::SRC_EDITOR] )->setCurrValue( ed ); - checkOption( VALKYRIE::SRC_EDITOR ); -#endif } -/* allows user to select executable-to-debug */ +/*! + Allows user to select executable-to-debug +*/ void ValkyrieOptionsPage::getBinary() { - cerr << "TODO: ValkyrieOptionsPage::getBinary()" << endl; -#if 0 // TODO QString binfile = - QFileDialog::getOpenFileName( QString::null, "All Files (*)", - this, "fdlg", "Select Executable" ); - - if ( !binfile.isEmpty() ) { /* user might have clicked Cancel */ + QFileDialog::getOpenFileName( this, tr("Select Executable To Debug"), + "./", tr("All Files (*)")); + + if ( !binfile.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::BINARY] )->setCurrValue( binfile ); checkOption( VALKYRIE::BINARY ); } - -#endif } -/* allows user to select default browser */ +/*! + Allows user to select the default browser +*/ void ValkyrieOptionsPage::getBrowser() { - cerr << "TODO: ValkyrieOptionsPage::getBrowser()" << endl; -#if 0 // TODO QString brwsr = - QFileDialog::getOpenFileName( QString::null, "All Files (*)", - this, "fdlg", "Select Browser" ); - - if ( !brwsr.isEmpty() ) { /* user might have clicked Cancel */ + QFileDialog::getOpenFileName( this, tr("Select Browser"), + "./", tr("All Files (*)")); + + if ( !brwsr.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::BROWSER] )->setCurrValue( brwsr ); checkOption( VALKYRIE::BROWSER ); } - -#endif } -/* RM: allows user to specify which valgrind version to use. the guts - of this fn are essentially the same as the one in config.tests/valgrind.test */ +/*! + Allows user to specify which valgrind version to use. +*/ void ValkyrieOptionsPage::getVgExec() { - cerr << "TODO: ValkyrieOptionsPage::getVgExec()" << endl; -#if 0 // TODO - QString vg_exec_path = - QFileDialog::getOpenFileName( QString::null, "All Files (*)", - this, "fdlg", "Select Valgrind" ); + QString vg_exec = + QFileDialog::getOpenFileName( this, tr("Select Valgrind"), + "./", tr("All Files (*)")); - if ( !vg_exec_path.isEmpty() ) { /* user might have clicked Cancel */ - (( LeWidget* )m_itemList[VALKYRIE::VG_EXEC] )->setCurrValue( vg_exec_path ); + if ( !vg_exec.isEmpty() ) { // user might have clicked Cancel + (( LeWidget* )m_itemList[VALKYRIE::VG_EXEC] )->setCurrValue( vg_exec ); checkOption( VALKYRIE::VG_EXEC ); } - -#endif } -/* RM: allows user to specify which default log dir to use */ +/*! + Allows user to specify which default log dir to use +*/ void ValkyrieOptionsPage::getDfltLogDir() { - cerr << "TODO: ValkyrieOptionsPage::getDfltLogDir()" << endl; -#if 0 // TODO QString currdir = m_itemList[VALKYRIE::DFLT_LOGDIR]->currValue(); + QString dir_logsave = - QFileDialog::getExistingDirectory( currdir, this, - "get default log-save dir", - "Choose a directory", TRUE ); + QFileDialog::getExistingDirectory( this, + tr("Choose Directory"), + currdir, + QFileDialog::ShowDirsOnly ); - if ( !dir_logsave.isEmpty() ) { /* user might have clicked Cancel */ + if ( !dir_logsave.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::DFLT_LOGDIR] )->setCurrValue( dir_logsave ); checkOption( VALKYRIE::DFLT_LOGDIR ); } - -#endif } -/* RM: allows user to specify which default log dir to use */ +/*! + Allows user to specify which dir to run valgrind under +*/ void ValkyrieOptionsPage::getWorkingDir() { - cerr << "TODO: ValkyrieOptionsPage::getWorkingDir()" << endl; -#if 0 // TODO QString currdir = m_itemList[VALKYRIE::WORKING_DIR]->currValue(); + QString dir_working = - QFileDialog::getExistingDirectory( currdir, this, - "get default working dir", - "Choose a directory", TRUE ); - - if ( !dir_working.isEmpty() ) { /* user might have clicked Cancel */ + QFileDialog::getExistingDirectory( this, + tr("Choose Directory"), + currdir, + QFileDialog::ShowDirsOnly ); + + if ( !dir_working.isEmpty() ) { // user might have clicked Cancel (( LeWidget* )m_itemList[VALKYRIE::WORKING_DIR] )->setCurrValue( dir_working ); checkOption( VALKYRIE::WORKING_DIR ); } - -#endif } Modified: branches/valkyrie_qt4port/options/vk_options_dialog.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/vk_options_dialog.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -25,27 +25,17 @@ #include "help/help_context.h" #include "help/help_urls.h" +#include "mainwindow.h" +#include "objects/vk_objects.h" +#include "options/vk_options_dialog.h" +#include "options/vk_options_page.h" #include "utils/vk_config.h" +#include "utils/vk_messages.h" #include "utils/vk_utils.h" -#if 0 -#include "vk_utils.h" -#include "vk_objects.h" -#include "vk_messages.h" -#endif -#include "objects/vk_objects.h" -#include "options/vk_options_dialog.h" -//#include "options/vk_options_page.h" -#include "options/valkyrie_options_page.h" -#include "mainwindow.h" - -#include <iostream> - - - /***************************************************************************/ /*! Constructs a VkOptionsDialog @@ -86,7 +76,12 @@ QString itemName = obj->objectName(); itemName[0] = itemName[0].toUpper(); item->setText( itemName ); - + + QFont font = item->font(); + font.setBold( true ); + font.setPointSize( font.pointSize() * 1.2 ); + item->setFont( font ); + // insert into stack (takes ownership) optionPages->addWidget( page ); } @@ -268,7 +263,15 @@ */ void VkOptionsDialog::saveToGlobalConfig() { - vkConfig->saveToGlblConfigFile(); + int ok = vkQuery( this, 2, "Overwrite Global Config", + "<p>Are you <b>sure</b> you want to overwrite the global config ?</p>" + "<p><i>Note: Valkyrie will regenerate factory global settings<br>" + "if the global config file is removed:<br>" + "%s</i></p>", qPrintable( vkConfig->vkCfgGlblFilename() ) ); + + if ( ok == MsgBox::vkYes ) { + vkConfig->saveToGlblConfigFile(); + } } Modified: branches/valkyrie_qt4port/options/vk_options_page.cpp =================================================================== --- branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/options/vk_options_page.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -126,7 +126,7 @@ /*! applyEdits() - Called from OptionsWindow::apply(), accept() + Called from OptionsDialog::apply(), accept() */ bool VkOptionsPage::applyEdits() { Modified: branches/valkyrie_qt4port/utils/vk_config.cpp =================================================================== --- branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-11 21:54:47 UTC (rev 491) +++ branches/valkyrie_qt4port/utils/vk_config.cpp 2010-03-12 00:30:43 UTC (rev 492) @@ -214,7 +214,7 @@ // save to vkCfgProjectName, if exists if ( !vkCfgProjectFilename.isEmpty() && !vkCfgProjectFilename.isNull() ) { std::cerr << "VkConfig::sync(): in proj => save cfg to proj cfg file (" - << this->vkCfgProjectFilename.toLatin1().constData() << ")" << std::endl; + << qPrintable( vkCfgProjectFilename ) << ")" << std::endl; saveToProjConfigFile(); } } |