From: <sv...@va...> - 2010-01-13 22:07:30
|
Author: cerion Date: 2010-01-13 22:07:17 +0000 (Wed, 13 Jan 2010) New Revision: 465 Log: Help (handbook, context help, about) is with us again. Added: branches/valkyrie_qt4port/help/ branches/valkyrie_qt4port/help/help_about.cpp branches/valkyrie_qt4port/help/help_about.h branches/valkyrie_qt4port/help/help_context.cpp branches/valkyrie_qt4port/help/help_context.h branches/valkyrie_qt4port/help/help_handbook.cpp branches/valkyrie_qt4port/help/help_handbook.h branches/valkyrie_qt4port/help/help_urls.cpp branches/valkyrie_qt4port/help/help_urls.h branches/valkyrie_qt4port/icons/context_help.xpm Modified: branches/valkyrie_qt4port/icons.qrc branches/valkyrie_qt4port/mainwindow.cpp branches/valkyrie_qt4port/mainwindow.h branches/valkyrie_qt4port/objects/valgrind_object.cpp 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/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/utils/vk_config.cpp branches/valkyrie_qt4port/utils/vk_config.h branches/valkyrie_qt4port/valkyrie.pro Added: branches/valkyrie_qt4port/help/help_about.cpp =================================================================== --- branches/valkyrie_qt4port/help/help_about.cpp (rev 0) +++ branches/valkyrie_qt4port/help/help_about.cpp 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,125 @@ +/**************************************************************************** +** HelpAbout implementation +** - small tab dialog showing various information re license etc. +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "help/help_about.h" +#include "utils/vk_config.h" +#include "utils/vk_utils.h" + +#include <QFile> +#include <QLabel> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QPixmap> +#include <QPushButton> +#include <QTextStream> + +/*! + Constructs a HelpAbout dialog with the given \a parent and \a tabid. +*/ +HelpAbout::~HelpAbout() { } + +HelpAbout::HelpAbout( QWidget* parent, HELPABOUT::TabId tabid ) + : QDialog( parent ) +{ + setObjectName(QString::fromUtf8("HelpAbout")); + title = vkConfig->vkName + " Information"; + setWindowTitle( title ); + + // top layout + QVBoxLayout* vbox = new QVBoxLayout( this ); + vbox->setObjectName(QString::fromUtf8("vbox")); + + // widget for the top part + QWidget* hLayoutWidget = new QWidget( this ); + hLayoutWidget->setObjectName(QString::fromUtf8("hLayoutWidget")); + vbox->addWidget( hLayoutWidget ); + + // hbox for pic + appname + QHBoxLayout* hbox = new QHBoxLayout( hLayoutWidget ); + hbox->setObjectName(QString::fromUtf8("hbox")); + + // pic + QLabel* pic = new QLabel( this ); + pic->setPixmap( QPixmap( ":/vk_icons/icons/valkyrie.xpm" ) ); + pic->setFixedSize( pic->sizeHint() ); + hbox->addWidget( pic ); + + // app info + QLabel* appName = new QLabel( this ); + QString str = vkConfig->vkName + " " + vkConfig->vkVersion; + appName->setText( str ); + appName->setFont(QFont( "Times", 18, QFont::Bold) ); + appName->setFixedSize( appName->sizeHint() ); + hbox->addWidget( appName ); + + // push the pix+info over to the left + hbox->addStretch( 10 ); + + // tabwidget + tabParent = new QTabWidget( this ); + tabParent->setObjectName(QString::fromUtf8("tabParent")); + connect( tabParent, SIGNAL(currentChanged( int )), + this, SLOT(showTab( int )) ); + vbox->addWidget( tabParent ); + + // about_vk tab + aboutVk = new QTextBrowser( tabParent ); + aboutVk->setObjectName(QString::fromUtf8("aboutVk")); + str = "About " + vkConfig->vkName; + tabParent->insertTab( HELPABOUT::ABOUT_VK, aboutVk, str ); + + // license tab + license = new QTextBrowser( tabParent ); + license->setObjectName(QString::fromUtf8("license")); + tabParent->insertTab( HELPABOUT::LICENSE, license, "License Agreement" ); + + // support tab + support = new QTextBrowser( tabParent ); + support->setObjectName(QString::fromUtf8("support")); + tabParent->insertTab( HELPABOUT::SUPPORT, support, "Support" ); + + + QPushButton* okButt = new QPushButton( "Close", this); + okButt->setDefault( true ); + okButt->setFixedSize( okButt->sizeHint() ); + connect( okButt, SIGNAL(clicked() ), this, SLOT(accept())); + okButt->setFocus(); + vbox->addWidget( okButt, 0, Qt::AlignRight ); + + // setup text-browsers + license->setSource( vkConfig->vkDocPath + "about_gpl.html" ); + support->setSource( vkConfig->vkDocPath + "support.html" ); + // about_vk source needs version args updating: + QFile file( vkConfig->vkDocPath + "about_vk.html" ); + if ( file.open( QIODevice::ReadOnly ) ) { + QTextStream ts( &file ); + aboutVk->setText( ts.readAll().arg( QT_VERSION_STR ).arg( qVersion() ) ); + } + + // start up with the correct page loaded + tabParent->setCurrentIndex( tabid ); + // and start up at a reasonable size + resize( 600, 380 ); +} + +void HelpAbout::showTab( int idx ) +{ + setWindowTitle( title + " : " + tabParent->tabText( idx ) ); +} Added: branches/valkyrie_qt4port/help/help_about.h =================================================================== --- branches/valkyrie_qt4port/help/help_about.h (rev 0) +++ branches/valkyrie_qt4port/help/help_about.h 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,56 @@ +/**************************************************************************** +** HelpAbout definition +** - small tabbed dialog showing misc. info re license etc. +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef __VK_HELP_ABOUT_H +#define __VK_HELP_ABOUT_H + +#include "help/help_handbook.h" // VkTextBrowser + +#include <QDialog> +#include <QTabWidget> + +namespace HELPABOUT { +/*! + enum identification for available help page tabs +*/ + enum TabId { ABOUT_VK=0, LICENSE, SUPPORT, NUM_TABS }; +} + +// ============================================================ +class HelpAbout : public QDialog +{ + Q_OBJECT +public: + HelpAbout( QWidget* parent, HELPABOUT::TabId tabid ); + ~HelpAbout(); + +private slots: + void showTab( int ); + +private: + QString title; + + QTabWidget* tabParent; + QTextBrowser* aboutVk; + QTextBrowser* license; + QTextBrowser* support; +}; + +#endif Added: branches/valkyrie_qt4port/help/help_context.cpp =================================================================== --- branches/valkyrie_qt4port/help/help_context.cpp (rev 0) +++ branches/valkyrie_qt4port/help/help_context.cpp 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,333 @@ +/**************************************************************************** +** ContextHelp implementation +** - context-sensitive help +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include <QApplication> +#include <QDesktopWidget> +#include <QMouseEvent> + + +#include "help/help_context.h" +#include "help/help_handbook.h" +#include "utils/vk_utils.h" // VK_DEBUG + + +// There can be only one. +static ContextHelp* ctxt = 0; + + + +/*! + class ContextHelpAction +*/ +ContextHelpAction::~ContextHelpAction() +{ + if ( ctxt ) { + ctxt->actions.removeAll( this ); // remove widget from list +// TODO: check return value - num removed should only ever be 1. + } +} + + +ContextHelpAction::ContextHelpAction( QWidget* parent, HandBook* book ) + : QAction( parent ) +{ + setObjectName(QString::fromUtf8("ctxt_help_tb")); + + ContextHelp::setupSingleton(); + + ctxt->actions.append( this ); + ctxt->hbook = book; + + setIcon( QPixmap( QString::fromUtf8(":/vk_icons/icons/context_help.xpm") ) ); + setCheckable( true ); + setIconVisibleInMenu(true); +#if 0 + setAutoRaise( true ); + setFocusPolicy( Qt::NoFocus ); +#endif + this->setToolTip( "This is a <b>Context Help</b> button. Clicking on a widget will open the relevant manual help page" ); + + connect( this, SIGNAL( triggered( bool ) ), + this, SLOT( startListening( bool ) ) ); +} + + +/*! + Action triggered + - start global listen for a left mouse click on a widget +*/ +void ContextHelpAction::startListening( bool checked ) +{ + // if not already active && this button is on... + if ( !ctxt->listeningForEvent && checked ) { + QApplication::setOverrideCursor( Qt::WhatsThisCursor ); + ctxt->listeningForEvent = true; + qApp->installEventFilter( ctxt ); + } +} + + + + + +/*! + class ContextHelp +*/ +static void qContextHelpCleanup() +{ + if ( ctxt ) { + delete ctxt; + ctxt = 0; + } +} + + +ContextHelp::ContextHelp() + : QObject( 0 ) +{ + setObjectName(QString::fromUtf8("ctxt_help_tb")); + ctxt = this; + listeningForEvent = false; +} + + +ContextHelp::~ContextHelp() +{ + if ( listeningForEvent == true && qApp ) + QApplication::restoreOverrideCursor(); + + actions.clear(); + wdict.clear(); + + ctxt = 0; +} + + +/*! + removes the Context help associated with the widget. + this happens automatically if the widget is destroyed. +*/ +void ContextHelp::remove( QWidget* widget ) +{ + vk_assert( widget != NULL ); + + wdict.remove( widget ); +// TODO: check return value - num removed should only ever be 1. +} + + +bool ContextHelp::eventFilter( QObject* obj, QEvent* ev ) +{ + if ( listeningForEvent ) { + + if ( ev->type() == QEvent::MouseButtonPress && obj->isWidgetType() ) { + QWidget* widg = (QWidget*) obj; + if ( ( (QMouseEvent*)ev)->button() == Qt::RightButton ) + return false; // ignore right mouse button + + QString url; + while ( widg && url.isEmpty() ) { + if (widg->inherits("QMenuBar")) { + // If we're a qmenubar, allow event to pass on so menus work... + // TODO: find what menuitem we're sitting on, if any, and get that widget... + return false; + } + url = wdict.value( widg ); + if ( url.isEmpty() ) { + // pos += widg->pos(); + widg = widg->parentWidget(); // 0 if no parent + } + } + cancelHelpEvent(); + + if ( !widg || url.isEmpty() ) { +//TODO: vkMsg? + cerr << "No help found for this widget" << endl; + return true; + } + + showHelp( url ); + return true; + } + else if ( ev->type() == QEvent::MouseButtonRelease ) { + if ( ( (QMouseEvent*)ev)->button() == Qt::RightButton ) + return false; // ignore right mouse button + return !obj->isWidgetType(); + } + else if ( ev->type() == QEvent::MouseMove ) { + return !obj->isWidgetType(); + } + else if ( ev->type() == QEvent::KeyPress ) { + QKeyEvent* kev = (QKeyEvent*)ev; + if ( kev->key() == Qt::Key_Escape ) { + cancelHelpEvent(); + return true; + } + else if ( kev->key() == Qt::Key_Menu || + ( kev->key() == Qt::Key_F10 && + (kev->modifiers() & Qt::ShiftModifier) ) ) { +//TODO: test shift-F10. modifiers() may not be trustworthy. + + // don't react to these keys: they are used for context menus + return false; + } +#if 0 // TODO: how to do this in Qt4? + else if ( kev->state() == kev->stateAfter() && + kev->key() != Qt::Key_Meta ) { + // not a modifier key + cancelHelpEvent(); + } +#endif + } + else if ( ev->type() == QEvent::MouseButtonDblClick ) { + return true; + } + } + + return false; +} + + +void ContextHelp::setupSingleton() +{ + if ( !ctxt ) { + ctxt = new ContextHelp(); + + +//TODO: this really necessary? +// not better to setup a parent, so gets auto-deleted at app close? +// or just create and delete in main()? + + /* it is necessary to use a post routine, because the destructor + deletes pixmaps and other stuff that needs a working X + connection under X11. */ + qAddPostRoutine( qContextHelpCleanup ); + } +} + + +/*! + Cancel the context help + - reset actions, cursor, remove eventfilter +*/ +void ContextHelp::cancelHelpEvent() +{ + if ( listeningForEvent ) { + // set all actions off. + foreach( ContextHelpAction* act, ctxt->actions ) { + act->setChecked( false ); + } + + QApplication::restoreOverrideCursor(); + listeningForEvent = false; + qApp->removeEventFilter( this ); + } +} + + +/*! + Open help at url +*/ +void ContextHelp::showHelp( const QString &text ) +{ + cerr << "ContextHelp::showHelp: '" << text.toLatin1().constData() << "'" << endl; + + if ( text.isEmpty() ) + return; + + if ( !hbook->isVisible() ) { + + // find out where MainWindow is, and park up beside it + QWidget* mw = qApp->activeWindow(); + int scr = QApplication::desktop()->screenNumber( mw ); + QRect screen = QApplication::desktop()->screenGeometry( scr ); + + int x; + int hw = hbook->width(); + + // get the global co-ords of the top-left pixel of MainWin + QPoint pos = mw->mapToGlobal( QPoint( 0,0 ) ); + if ( hw < ( pos.x() - screen.x() ) ) + x = pos.x() - hw; + else + x = pos.x() + mw->width(); + + hbook->move( x, pos.y() ); + hbook->show(); + } + + hbook->raise(); + hbook->openUrl( text ); +} + + +/*! + Only of our registed widgets died: remove it from the list +*/ +void ContextHelp::cleanupWidget() +{ + const QObject* obj = sender(); + if ( !obj->isWidgetType() ) { // sanity check + cerr << "Error: ContextHelp::cleanupWidget(): " + << "signal received from non-widget: " + << qPrintable( obj->objectName() ) << endl; + } else { + remove( (QWidget*)obj ); + } +} + + +/*! + Add help url to widget +*/ +void ContextHelp::newItem( QWidget* widg, const QString& url ) +{ + // in case widg already in our lists, replace it. + if ( wdict.contains( widg ) ) { + cerr << "ContextHelp::newItem(): widg (" + << qPrintable( widg->objectName() ) << ") was registered to: '" + << qPrintable( wdict.value( widg ) ) << "'" << endl + << " - Replacing with: '" << qPrintable( url ) << "'" << endl; + wdict.remove( widg ); + } + + // add to our list + wdict.insert( widg, url ); + + // make sure to remove mappings that no longer exist. + connect( widg, SIGNAL(destroyed()), + this, SLOT(cleanupWidget()) ); +} + + +/*! + Static function: + - Initialise context help singleton if necessary + - Add help url to given widget +*/ +void ContextHelp::addHelp( QWidget* widg, const QString& url ) +{ + vk_assert( widg != NULL ); + if ( !url.isEmpty() ) { + setupSingleton(); + ctxt->newItem( widg, url ); + } +} + Added: branches/valkyrie_qt4port/help/help_context.h =================================================================== --- branches/valkyrie_qt4port/help/help_context.h (rev 0) +++ branches/valkyrie_qt4port/help/help_context.h 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,82 @@ +/**************************************************************************** +** ContextHelp definition +** - context-sensitive help button +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef __VK_HELP_CONTEXT_H +#define __VK_HELP_CONTEXT_H + +#include <QAction> +#include <QHash> +#include <QList> +#include <QString> +#include <QToolButton> +#include <QWidget> + + +// Forward decls +class HandBook; + + +// ============================================================ +class ContextHelpAction: public QAction +{ + Q_OBJECT +public: + ContextHelpAction( QWidget* parent, HandBook* book ); + ~ContextHelpAction(); + +public slots: + void startListening( bool checked ); +}; + + + + +// ============================================================ +class ContextHelp: public QObject +{ + Q_OBJECT + friend class ContextHelpAction; + +public: + ContextHelp(); + ~ContextHelp(); + static void addHelp( QWidget*, const QString&); + +private: + static void setupSingleton(); + + bool eventFilter( QObject*, QEvent* ); + void newItem( QWidget* widget, const QString& text ); + void showHelp( const QString& ); + void cancelHelpEvent(); + void remove( QWidget* ); + + HandBook* hbook; // ptr to the application-wide handbook + + QHash<QWidget*, QString> wdict; // mapping widg->url + QList<ContextHelpAction*> actions; // allows turning off all registered ctxt help actions + bool listeningForEvent; + +private slots: + void cleanupWidget(); +}; + + +#endif // #ifndef __VK_HELP_CONTEXT_H Added: branches/valkyrie_qt4port/help/help_handbook.cpp =================================================================== --- branches/valkyrie_qt4port/help/help_handbook.cpp (rev 0) +++ branches/valkyrie_qt4port/help/help_handbook.cpp 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,577 @@ +/**************************************************************************** +** HandBook implementation +** - context-sensitive help browser +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "help/help_handbook.h" +//#include "tb_handbook_icons.h" +#include "utils/vk_config.h" +//#include "vk_messages.h" +#include "utils/vk_utils.h" + + +#include "QApplication" +#include "QDockWidget" +#include "QFile" +#include "QFileDialog" +#include "QMenu" +#include "QPrinter" +#include "QProcess" +#include "QString" +#include "QStringList" +#include "QTextStream" +#include "QToolBar" + + + +/*! + class HandBook +*/ +HandBook::~HandBook() +{ + // save history + bookmarks + save(); +} + + +HandBook::HandBook( QWidget* parent ) //, const char* name ) + : QMainWindow( parent ) +//TODO: ? +//, name, WDestructiveClose ) +//? Qt::WA_DeleteOnClose +{ + setObjectName(QString::fromUtf8("handbook")); + + QString VkName = vkConfig->vkName; + VkName.replace( 0, VkName[0].toUpper() ); + + caption = VkName + " HandBook"; + this->setWindowTitle( caption ); + setWindowIcon( QPixmap( QString::fromUtf8(":/vk_icons/icons/tb_handbook_help.xpm") ) ); + + browser = new QTextBrowser( this ); + setCentralWidget( browser ); + + mkMenuToolBars(); + + browser->setOpenExternalLinks( true ); + browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + + // set the list of dirs to search when files are requested + QStringList paths; + paths << vkConfig->vkDocPath; + browser->setSearchPaths( paths ); + + connect( browser, SIGNAL( sourceChanged(const QUrl&) ), + this, SLOT( sourceChanged(const QUrl&) ) ); +// connect( browser, SIGNAL( highlighted(const QString&) ), +// statusBar(), SLOT( showMessage(const QString&)) ); + connect( bookmarkMenu, SIGNAL( hovered(QAction*) ), + this, SLOT( bookmarkHighlighted(QAction*)) ); + + + // default startup is with the index page loaded + QString home = vkConfig->vkDocPath + "/index.html"; + browser->setSource( home ); + +//TODO: vkErrors? hmm. in a constructor... + +//TODO: vkConfig + resize( 560, 600 ); + hide(); +} + + +void HandBook::historyChosen( QAction* act ) +{ + browser->setSource( act->text() ); +} + + +void HandBook::bookmarkChosen( QAction* act ) +{ + if ( !bookmarkMenu->actions().contains( act ) ) { +//TODO: shouldn't ever happen: vkError + return; + } + + QString url = act->data().toString(); +// browser->setSource( url ); +} + + +void HandBook::bookmarkHighlighted( QAction* act ) +{ + if ( !bookmarkMenu->actions().contains( act ) ) { + cerr << "Error: act not in bookmarks!" << endl; +//TODO: shouldn't ever happen: vkError + return; + } + if ( act->objectName() != QString::fromUtf8("handbook_actBookmark") ) { + // other actions besides bookmarks are in the menu -> ignore. + return; + } + + QString link = act->data().toString(); +//TODO: why doesn't this work?! +// appears _very_ briefly and gets cleared => flickers. + statusBar()->showMessage( link, 1000 ); +} + + + +void HandBook::addBookmark() +{ + QString url = browser->source().toString(); + QString title = browser->documentTitle(); + if ( browser->documentTitle().isNull() ) { + title = url; + } + + // just show the page title in the menu, but hold onto the url + QAction* actNew = new QAction( this ); + actNew->setObjectName( QString::fromUtf8("handbook_actBookmark") ); + actNew->setText( title ); + actNew->setData( url ); + bookmarkMenu->addAction( actNew ); + + // Don't let bookmarks grow endlessly + // - find first bookmark action + // - count how many actions from there + // - remove that first action if necessary + int nActsBefore=0; + QAction* actFirst; + foreach( actFirst, bookmarkMenu->actions() ) { + // skip non-bookmark actions + if ( actFirst->objectName() == QString::fromUtf8("handbook_actBookmark") ) { + break; + } + nActsBefore++; + } + if ( (bookmarkMenu->actions().count() - nActsBefore) > max_bookmarks ) { + bookmarkMenu->removeAction( actFirst ); + delete actFirst; + } +} + + +// the handbook is explicitly killed by MainWindow on exit. +void HandBook::closeEvent( QCloseEvent* ) +{ + hide(); +} + + +void HandBook::showYourself() +{ + if ( !isVisible() ) { + show(); + } else if ( isMinimized() ) { + showNormal(); + } else { + raise(); + } +} + + +/*! + Sets the name of the displayed document to url +*/ +void HandBook::openUrl( const QString& url ) +{ + browser->setSource( url ); +} + + +/*! + Open a user-specified html file +*/ +void HandBook::openFile() +{ + QString fn = QFileDialog::getOpenFileName( this, "Open File", vkConfig->vkDocPath, + "Html Files (*.html *.htm);;All Files (*)" ); + if ( !fn.isEmpty() ) { + browser->setSource( fn ); + } +} + + +/*! + source changed (not from pathCombo) + - update pathCombo +*/ +void HandBook::sourceChanged( const QUrl& url ) +{ + QString link = url.toString(); +// vkPrint("CHECKME: sourceChanged() link: '%s'", qPrintable( link ) ); + +//TODO: if link.isEmpty -> 404 + + if ( browser->documentTitle().isNull() ) + setWindowTitle( "VkHelp - " + link ); + else + setWindowTitle( "VkHelp - " + browser->documentTitle() ) ; + + if ( !link.isEmpty() && pathCombo ) { + + // pathCombo is not kept in-sync with history + int idx = pathCombo->findText( link, Qt::MatchFixedString ); // not case-sensitive + if ( idx != -1 ) { + pathCombo->setCurrentIndex( idx ); + } else { + // combobox + pathCombo->insertItem( 0, link ); + pathCombo->setCurrentIndex( 0 ); + if ( pathCombo->count() > max_history ) { + pathCombo->removeItem( max_history ); + } + } + + // history menu: if already in history, move to top. + bool found = false; + foreach( QAction* act, historyMenu->actions() ) { + if ( act->text() == link ) { + if ( found ) { + // shouldn't ever get here, but just in case. + historyMenu->removeAction( act ); + } + historyMenu->removeAction( act ); + historyMenu->insertAction( historyMenu->actions().first(), act ); + found = true; + } + } + if ( !found ) { + // not in history: prepend, and remove last if necessary + QAction* act = new QAction( this ); + act->setObjectName( QString::fromUtf8("handbook_actHistory") ); + act->setText( link ); + if ( ! historyMenu->actions().isEmpty() ) { + historyMenu->insertAction( historyMenu->actions().first(), act ); + } else { + historyMenu->addAction( act ); + } + if ( historyMenu->actions().count() > max_history ) { + QAction* act = historyMenu->actions().last(); + historyMenu->removeAction( act ); + delete act; + } + } + } +} + + +void HandBook::mkMenuToolBars() +{ + menuBar = new QMenuBar( this ); + menuBar->setObjectName(QString::fromUtf8("help_menubar")); + this->setMenuBar( menuBar ); + + // ------------------------------------------------------------ + // file menu + QMenu* fileMenu = new QMenu( menuBar ); + fileMenu->setObjectName( QString::fromUtf8("handbook_fileMenu") ); + fileMenu->setTitle( QApplication::translate("MainWindowClass", "&File", 0, QApplication::UnicodeUTF8) ); + menuBar->addAction( fileMenu->menuAction() ); + + QAction* actFile_Open = new QAction( this ); + actFile_Open->setObjectName( QString::fromUtf8("handbook_actFile_Open") ); + actFile_Open->setText( QApplication::translate("HandBook", "Open File", 0, QApplication::UnicodeUTF8) ); + connect( actFile_Open, SIGNAL( triggered() ), this, SLOT( openFile() ) ); + + QAction* actFile_Close = new QAction( this ); + actFile_Close->setObjectName( QString::fromUtf8("handbook_actFile_Close") ); + actFile_Close->setText( QApplication::translate("HandBook", "Close", 0, QApplication::UnicodeUTF8) ); + connect( actFile_Close, SIGNAL( triggered() ), this, SLOT( close() ) ); + + fileMenu->addAction( actFile_Open ); + fileMenu->addSeparator(); + fileMenu->addAction( actFile_Close ); + + // ------------------------------------------------------------ + // go menu + QMenu* goMenu = new QMenu( menuBar ); + goMenu->setObjectName( QString::fromUtf8("handbook_goMenu") ); + goMenu->setTitle( QApplication::translate("MainWindowClass", "&Go", 0, QApplication::UnicodeUTF8) ); + menuBar->addAction( goMenu->menuAction() ); + + QAction* actGo_Backward = new QAction( this ); + actGo_Backward->setObjectName( QString::fromUtf8("handbook_actGo_Backward") ); + actGo_Backward->setText( QApplication::translate("HandBook", "Backward", 0, QApplication::UnicodeUTF8) ); + actGo_Backward->setIcon( QPixmap( QString::fromUtf8(":/vk_icons/icons/tb_handbook_back.xpm") ) ); + connect( actGo_Backward, SIGNAL( triggered() ), browser, SLOT( backward() ) ); + + QAction* actGo_Forward = new QAction( this ); + actGo_Forward->setObjectName( QString::fromUtf8("handbook_actGo_Forward") ); + actGo_Forward->setText( QApplication::translate("HandBook", "Forward", 0, QApplication::UnicodeUTF8) ); + actGo_Forward->setIcon( QPixmap( QString::fromUtf8(":/vk_icons/icons/tb_handbook_forward.xpm") ) ); + connect( actGo_Forward, SIGNAL( triggered() ), browser, SLOT( forward() ) ); + + QAction* actGo_Home = new QAction( this ); + actGo_Home->setObjectName( QString::fromUtf8("handbook_actGo_Home") ); + actGo_Home->setText( QApplication::translate("HandBook", "Home", 0, QApplication::UnicodeUTF8) ); + actGo_Home->setIcon( QPixmap( QString::fromUtf8(":/vk_icons/icons/tb_handbook_home.xpm") ) ); + connect( actGo_Home, SIGNAL( triggered() ), browser, SLOT( home() ) ); + + QAction* actGo_Reload = new QAction( this ); + actGo_Reload->setObjectName( QString::fromUtf8("handbook_actGo_Reload") ); + actGo_Reload->setText( QApplication::translate("HandBook", "Reload", 0, QApplication::UnicodeUTF8) ); + actGo_Reload->setIcon( QPixmap( QString::fromUtf8(":/vk_icons/icons/tb_handbook_reload.xpm") ) ); + connect( actGo_Reload, SIGNAL( triggered() ), browser, SLOT( reload() ) ); + + goMenu->addAction( actGo_Backward ); + goMenu->addAction( actGo_Forward ); + goMenu->addAction( actGo_Home ); + // Dont add Reload here. + + actGo_Backward->setEnabled( false ); + actGo_Forward->setEnabled( false ); + connect( browser, SIGNAL( backwardAvailable( bool ) ), + actGo_Backward, SLOT( setEnabled( bool ) ) ); + connect( browser, SIGNAL( forwardAvailable( bool ) ), + actGo_Forward, SLOT( setEnabled( bool ) ) ); + + // ------------------------------------------------------------ + // history menu + historyMenu = new QMenu( menuBar ); + historyMenu->setObjectName( QString::fromUtf8("handbook_historyMenu") ); + historyMenu->setTitle( QApplication::translate("MainWindowClass", "History", 0, QApplication::UnicodeUTF8) ); + menuBar->addAction( historyMenu->menuAction() ); + connect( historyMenu, SIGNAL( triggered( QAction* ) ), + this, SLOT( historyChosen( QAction* ) ) ); + readHistory(); + + // ------------------------------------------------------------ + // bookmarks menu + bookmarkMenu = new QMenu( menuBar ); + bookmarkMenu->setObjectName( QString::fromUtf8("handbook_bookmarkMenu") ); + bookmarkMenu->setTitle( QApplication::translate("MainWindowClass", "Bookmark", 0, QApplication::UnicodeUTF8) ); + menuBar->addAction( bookmarkMenu->menuAction() ); + + QAction* actBM_AddBM = new QAction( this ); + actBM_AddBM->setObjectName( QString::fromUtf8("handbook_actBM_AddBM") ); + actBM_AddBM->setText( QApplication::translate("HandBook", "Add Bookmark", 0, QApplication::UnicodeUTF8) ); + connect( actBM_AddBM, SIGNAL( triggered() ), this, SLOT( addBookmark() ) ); + + bookmarkMenu->addAction( actBM_AddBM ); + bookmarkMenu->addSeparator(); + connect( bookmarkMenu, SIGNAL( triggered( QAction* ) ), + this, SLOT( bookmarkChosen( QAction* ) ) ); + readBookmarks(); + + + // ------------------------------------------------------------ + // dismiss button + QAction* act_dismiss = new QAction( this ); + act_dismiss->setObjectName( QString::fromUtf8("act_dismiss") ); + act_dismiss->setText( QApplication::translate("HandBook", "Dismiss", 0, QApplication::UnicodeUTF8) ); + connect( act_dismiss, SIGNAL( triggered() ), + this, SLOT( close() ) ); + + menuBar->addSeparator(); + menuBar->addAction( act_dismiss ); + + + // ------------------------------------------------------------ + // toolbar + QToolBar* toolbar = new QToolBar( this ); + toolbar->setObjectName( QString::fromUtf8("handbook_toolbar") ); + this->addToolBar( Qt::TopToolBarArea, toolbar ); + toolbar->setAllowedAreas( Qt::TopToolBarArea | Qt::BottomToolBarArea); + + toolbar->addAction( actGo_Backward ); + toolbar->addAction( actGo_Forward ); + toolbar->addAction( actGo_Home ); + toolbar->addAction( actGo_Reload ); + toolbar->addSeparator(); + + pathCombo = new QComboBox( toolbar ); + pathCombo->setEditable( true ); + pathCombo->addItem( vkConfig->vkDocPath ); + QSizePolicy sp = pathCombo->sizePolicy(); + sp.setHorizontalPolicy( QSizePolicy::MinimumExpanding ); + pathCombo->setSizePolicy( sp ); + connect( pathCombo, SIGNAL( activated(const QString &) ), + this, SLOT( openUrl(const QString &) ) ); + toolbar->addWidget( pathCombo ); + + + // ------------------------------------------------------------ + // Basic statusbar setup + statusBar()->setObjectName( QString::fromUtf8("helpStatusBar ") ); +//TODO: why disable? +// statusBar()->setSizeGripEnabled( false ); +} + + + +void HandBook::save() +{ + vk_assert( historyMenu->actions().count() <= max_history ); + +//TODO: do this via vkConfig! +#if 0 +//TODO: need to write to _global_ config, not project/temp config... + QStringList history; + foreach( QAction* act, historyMenu->actions() ) { + history << act->text(); + } + vkConfig->setValue( "handbook/history", history ); + + int nBookmarks = 0; + QStringList bookmarks; + foreach( QAction* act, historyMenu->actions() ) { + // skip non-bookmark actions + if ( act->objectName() == QString::fromUtf8("handbook_actBookmark") ) { + bookmarks << act->text() + vkConfig->vkSepChar + act->data().toString(); + nBookmarks++; + } + } + vkConfig->setValue( "handbook/bookmarks", bookmarks ); + + vk_assert( nBookmarks <= max_bookmarks ); + +#else + // save the history + QFile aFile( vkConfig->vkRcDir + "/help.history" ); + if ( aFile.open( QIODevice::WriteOnly ) ) { + QTextStream stream( &aFile ); + + foreach( QAction* act, historyMenu->actions() ) { + stream << act->text() << "\n"; + } + aFile.close(); + } + + // save the bookmarks + aFile.setFileName( vkConfig->vkRcDir + "/help.bookmarks" ); + if ( aFile.open( QIODevice::WriteOnly ) ) { + QTextStream stream( &aFile ); + + int nBookmarks=0; + foreach( QAction* act, bookmarkMenu->actions() ) { + // skip non-bookmark actions + if ( act->objectName() == QString::fromUtf8("handbook_actBookmark") ) { + stream << act->text() + << vkConfig->vkSepChar + << act->data().toString() << "\n"; + nBookmarks++; + } + } + aFile.close(); + + vk_assert( nBookmarks <= max_bookmarks ); + } +#endif +} + + +/*! + load the history from file into the menu +*/ +void HandBook::readHistory() +{ + bool ok = false; + max_history = vkConfig->value( "handbook/max_history", 20 ).toInt( &ok ); + if (!ok) cerr << "Error: bad value for config::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(); + int len = history.count() > max_history ? max_history : history.count(); + for ( int idx=0; idx < len; idx++ ) { + QString link = history.at( idx ); + + QAction* act = new QAction( this ); + act->setObjectName( QString::fromUtf8("handbook_actHistory") ); + act->setText( link ); + historyMenu->addAction( act ); + } +#else + QFile aFile( vkConfig->vkRcDir + "/help.history" ); + + if ( aFile.open( QIODevice::ReadOnly ) ) { + // read in max_history links + QTextStream stream( &aFile ); + for ( int idx=0; idx < max_history && !stream.atEnd(); idx++ ) { + QString link = stream.readLine(); + + QAction* act = new QAction( this ); + act->setObjectName( QString::fromUtf8("handbook_actHistory") ); + act->setText( link ); + historyMenu->addAction( act ); + } + aFile.close(); + } +#endif +} + + + +/*! + load the bookmarks from file into the menu +*/ +void HandBook::readBookmarks() +{ + bool ok = false; + max_bookmarks = vkConfig->value( "handbook/max_bookmarks", 20 ).toInt(&ok); + if (!ok) cerr << "Error: bad value for config::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(); + 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 ); + QString title = sl.first(); + QString url = sl.last(); + + // menu list + QAction* act = new QAction( this ); + act->setObjectName( QString::fromUtf8("handbook_actBookmark") ); + act->setText( title ); + act->setData( url ); + bookmarkMenu->addAction( act ); + } + +#else + QFile aFile( vkConfig->vkRcDir + "/help.bookmarks" ); + + if ( aFile.open( QIODevice::ReadOnly ) ) { + // read in max_bookmarks links + 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 ); + QString title = sl.first(); + QString url = sl.last(); + + // menu list + QAction* act = new QAction( this ); + act->setObjectName( QString::fromUtf8("handbook_actBookmark") ); + act->setText( title ); + act->setData( url ); + bookmarkMenu->addAction( act ); + } + aFile.close(); + } +#endif +} Added: branches/valkyrie_qt4port/help/help_handbook.h =================================================================== --- branches/valkyrie_qt4port/help/help_handbook.h (rev 0) +++ branches/valkyrie_qt4port/help/help_handbook.h 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,76 @@ +/**************************************************************************** +** HandBook definition +** - Context-sensitive help browser +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef __VK_HELP_HANDBOOK_H +#define __VK_HELP_HANDBOOK_H + +#include <QComboBox> +#include <QMainWindow> +#include <QMenu> +#include <QMenuBar> +#include <QStatusBar> +#include <QTextBrowser> + + + +// ============================================================ +class HandBook : public QMainWindow +{ + Q_OBJECT +public: + HandBook( QWidget* parent=0 ); + ~HandBook(); + +public slots: + void openUrl( const QString& url ); + void showYourself(); + +protected: + void closeEvent( QCloseEvent* ce ); + +private slots: + void sourceChanged(const QUrl& url); + void openFile(); + void historyChosen( QAction* act ); + void bookmarkChosen( QAction* act ); + void bookmarkHighlighted( QAction* act ); + void addBookmark(); + +private: + void mkMenuToolBars(); + void save(); + void readHistory(); + void readBookmarks(); + +private: + QString caption; + QTextBrowser* browser; + QComboBox* pathCombo; + QMenuBar* menuBar; + QStatusBar* helpStatusBar; + QMenu* bookmarkMenu; + QMenu* historyMenu; + + int max_history; + int max_bookmarks; +}; + + +#endif // #ifndef __VK_HELP_HANDBOOK_H Added: branches/valkyrie_qt4port/help/help_urls.cpp =================================================================== --- branches/valkyrie_qt4port/help/help_urls.cpp (rev 0) +++ branches/valkyrie_qt4port/help/help_urls.cpp 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,157 @@ +/**************************************************************************** +** URL strings definition +** - placed in one file in an endeavour to minimise +** what is probably going to be a maintenance nightmare. +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "help_urls.h" + + +// not every flag/option has context-sensitive help +const char* urlNone = ""; + + +// ============================================================ +// Valkyrie +namespace urlValkyrie { + + // Mainwindow + const char* menuBar = "mainwindow.html#menu_bar"; + const char* fileMenu = "mainwindow.html#file_menu"; + const char* toolMenu = "mainwindow.html#tools_menu"; + const char* optionsMenu = "mainwindow.html#options_menu"; + const char* runButton = "mainwindow.html#run_button"; + const char* stopButton = "mainwindow.html#stop_button"; + const char* helpMenu = "mainwindow.html#help_menu"; + const char* statusMsg = "mainwindow.status_msg.html"; + const char* flagsWidget = "mainwindow.flags_widget.html"; + + // options dialog + const char* optsDlg = "options_dialog.html"; + + // valkyrie's options page + const char* optsPage = "options_dialog.html#valkyrie"; + const char* toolTips = "options_dialog.html#tool_tips"; + const char* toolLabels = "options_dialog.html#tool_label"; + const char* browser = "options_dialog.html#browser"; + const char* logDir = "options_dialog.html#log_dir"; + const char* workingDir = "options_dialog.html#working_dir"; + const char* userFontGen = "options_dialog.html#user_font_general"; + const char* userFontTool = "options_dialog.html#user_font_tool"; + const char* palette = "options_dialog.html#palette"; + const char* srcLines = "options_dialog.html#src_lines"; + const char* srcEditor = "options_dialog.html#src_editor"; + const char* binary = "options_dialog.html#binary"; + const char* binFlags = "options_dialog.html#bin_flags"; + const char* vgDir = "options_dialog.html#valgrind"; + + // valgrind's options page: tab Suppressions + const char* coreTab = "options_valgrind.html#core_tab"; + const char* errorTab = "options_valgrind.html#error_tab"; + const char* suppsTab = "options_valgrind.html#supps_tab"; + + // MemcheckView toolbuttons + const char* openAllButton = ""; + const char* openOneButton = ""; + const char* srcPathButton = ""; + const char* loadLogButton = ""; + const char* mrgLogButton = ""; + const char* saveLogButton = ""; + const char* suppEdButton = ""; +} + + +// ============================================================ +// Valgrind core +namespace urlVgCore { + // valgrind's options page: tab Core + const char* mainTool = "vg-manual-core.html#tool_name"; + const char* verbosity = "vg-manual-core.html#verbosity"; + const char* traceChild = "vg-manual-core.html#trace_children"; + const char* silentChild = "vg-manual-core.html#silent_child"; + const char* trackFds = "vg-manual-core.html#track_fds"; + const char* timeStamp = "vg-manual-core.html#time_stamp"; + const char* xmlOutput = "vg-manual-core.html#xml_output"; + const char* xmlComment = "vg-manual-core.html#xml_user_comment"; + const char* freeGlibc = "vg-manual-core.html#free_glibc"; + const char* showEmWarns = "vg-manual-core.html#show_emwarns"; + const char* smcSupport = "vg-manual-core.html#smc_support"; + const char* simHints = "vg-manual-core.html#simulation_hints"; + const char* kernelVariant = "vg-manual-core.html#kernel_variant"; + + // valgrind's options page: tab Error Reporting + const char* logToFd = "vg-manual-core.html#log2fd"; + const char* logToFile = "vg-manual-core.html#log2file"; + const char* logToSocket = "vg-manual-core.html#log2socket"; + const char* autoDemangle = "vg-manual-core.html#auto_demangle"; + const char* numCallers = "vg-manual-core.html#num_callers"; + const char* errorLimit = "vg-manual-core.html#error_limit"; + const char* stackTraces = "vg-manual-core.html#stack_traces"; + const char* genSuppressions = "vg-manual-core.html#gen_supps"; + const char* startDebugger = "vg-manual-core.html#attach_debugger"; + const char* whichDebugger = "vg-manual-core.html#which_debugger"; + const char* inputFd = "vg-manual-core.html#input_fd"; + const char* maxSFrames = "vg-manual-core.html#max_frames"; + + // only used by Memcheck and Massif + const char* Alignment = "vg-manual-core.html#alignment"; +} + + +// ============================================================ +// Memcheck +namespace urlMemcheck { + const char* optsMC = "vg-manual-mc.html"; + const char* Leakcheck = "vg-manual-mc.html#leakcheck"; + const char* Showreach = "vg-manual-mc.html#showreach"; + //const char* UndefVal = "vg-manual-mc.html#undefvalerrs"; + const char* TrackOri = "vg-manual-mc.html#undefvalerrs"; + const char* Leakres = "vg-manual-mc.html#leakres"; + const char* Freelist = "vg-manual-mc.html#freelist"; + const char* gcc296 = "vg-manual-mc.html#gcc296"; + const char* Partial = "vg-manual-mc.html#partial"; +} + + +// ============================================================ +// Cachegrind +namespace urlCachegrind { + const char* optsCG = "vg-manual-cg.html"; + const char* Cacheopts = "vg-manual-cg.html#cg-manual.cgopts"; + const char* Pid = "vg-manual-cg.html#pid"; + const char* Sort = "vg-manual-cg.html#sort"; + const char* Show = "vg-manual-cg.html#show"; + const char* Threshold = "vg-manual-cg.html#threshold"; + const char* Auto = "vg-manual-cg.html#auto"; + const char* Context = "vg-manual-cg.html#context"; + const char* Include = "vg-manual-cg.html#include"; +} + + +// ============================================================ +// Massif +namespace urlMassif { + const char* optsMS = "vg-manual-ms.html"; + const char* Heap = "vg-manual-ms.html#heap"; + const char* HeapAdmin = "vg-manual-ms.html#heap-admin"; + const char* Stacks = "vg-manual-ms.html#stacks"; + const char* Depth = "vg-manual-ms.html#depth"; + const char* AllocFn = "vg-manual-ms.html#alloc-fn"; + const char* Format = "vg-manual-ms.html#format"; +} + Added: branches/valkyrie_qt4port/help/help_urls.h =================================================================== --- branches/valkyrie_qt4port/help/help_urls.h (rev 0) +++ branches/valkyrie_qt4port/help/help_urls.h 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,154 @@ +/**************************************************************************** +** URL strings definition +** - placed in one file in an endeavour to minimise +** what is probably going to be a maintenance nightmare. +** -------------------------------------------------------------------------- +** +** Copyright (C) 2000-2010, OpenWorks LLP. All rights reserved. +** <in...@op...> +** +** This file is part of Valkyrie, a front-end for Valgrind. +** +** This file may be used under the terms of the GNU General Public +** License version 2.0 as published by the Free Software Foundation +** and appearing in the file COPYING included in the packaging of +** this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#ifndef __VK_HELP_URLS_H +#define __VK_HELP_URLS_H + + +// not every flag/option has context-sensitive help +extern const char* urlNone; + + +// ============================================================ +// Valkyrie +namespace urlValkyrie { + // Mainwindow + extern const char* menuBar; + extern const char* fileMenu; + extern const char* toolMenu; + extern const char* optionsMenu; + extern const char* runButton; + extern const char* stopButton; + extern const char* helpMenu; + extern const char* statusMsg; + extern const char* flagsWidget; + // options dialog + extern const char* optsDlg; + // valkyrie's options page + extern const char* optsPage; + extern const char* toolTips; + extern const char* toolLabels; + extern const char* browser; + extern const char* logDir; + extern const char* workingDir; + extern const char* userFontGen; + extern const char* userFontTool; + extern const char* palette; + extern const char* srcLines; + extern const char* srcEditor; + extern const char* binary; + extern const char* binFlags; + extern const char* vgDir; + // valgrind's options page + extern const char* coreTab; + extern const char* errorTab; + extern const char* suppsTab; + // MemcheckView tool buttons + extern const char* openAllButton; + extern const char* openOneButton; + extern const char* srcPathButton; + extern const char* loadLogButton; + extern const char* mrgLogButton; + extern const char* saveLogButton; + extern const char* suppEdButton; +} + + +// ============================================================ +// Valgrind core +namespace urlVgCore { + // valgrind's options page: tab Core + extern const char* mainTool; + extern const char* verbosity; + extern const char* xmlOutput; + extern const char* xmlComment; + extern const char* traceChild; + extern const char* silentChild; + extern const char* trackFds; + extern const char* timeStamp; + extern const char* freeGlibc; + extern const char* showEmWarns; + extern const char* smcSupport; + extern const char* simHints; + extern const char* kernelVariant; + // valgrind's options page: tab Error Reporting + extern const char* genSuppressions; + extern const char* autoDemangle; + extern const char* errorLimit; + extern const char* stackTraces; + extern const char* numCallers; + extern const char* maxSFrames; + extern const char* startDebugger; + extern const char* whichDebugger; + extern const char* inputFd; + extern const char* logToFd; + extern const char* logToFile; + extern const char* logToSocket; + // only used by Memcheck and Massif + extern const char* Alignment; +} + + +// ============================================================ +// Memcheck +namespace urlMemcheck { + extern const char* optsMC; + extern const char* Partial; + extern const char* Freelist; + extern const char* Leakcheck; + extern const char* Leakres; + extern const char* Showreach; + //extern const char* UndefVal; + extern const char* TrackOri; + extern const char* gcc296; +} + + +// ============================================================ +// Cachegrind +namespace urlCachegrind { + extern const char* optsCG; + extern const char* Cacheopts; + extern const char* Pid; + extern const char* Sort; + extern const char* Show; + extern const char* Threshold; + extern const char* Auto; + extern const char* Context; + extern const char* Include; +} + + +// ============================================================ +// Massif +namespace urlMassif { + extern const char* optsMS; + extern const char* optsMassif; + extern const char* Heap; + extern const char* HeapAdmin; + extern const char* Stacks; + extern const char* Depth; + extern const char* AllocFn; + extern const char* Format; +} + + +#endif Added: branches/valkyrie_qt4port/icons/context_help.xpm =================================================================== --- branches/valkyrie_qt4port/icons/context_help.xpm (rev 0) +++ branches/valkyrie_qt4port/icons/context_help.xpm 2010-01-13 22:07:17 UTC (rev 465) @@ -0,0 +1,22 @@ +/* XPM */ +static const char* context_help_xpm[] = { + "16 16 3 1", + " c None", + "+ c #000000", + "* c #000080", + "+ ***** ", + "++ *** *** ", + "+++ *** ***", + "++++ ** **", + "+++++ ** **", + "++++++ * ***", + "+++++++ *** ", + "++++++++ *** ", + "+++++++++ *** ", + "+++++ *** ", + "++ +++ ", + "+ +++ *** ", + " +++ *** ", + " +++ ", + " +++ ", + " +++ "}; Modified: branches/valkyrie_qt4port/icons.qrc =================================================================== --- branches/valkyrie_qt4port/icons.qrc 2010-01-08 21:43:43 UTC (rev 464) +++ branches/valkyrie_qt4port/icons.qrc 2010-01-13 22:07:17 UTC (rev 465) @@ -27,5 +27,6 @@ <file>icons/valkyrie.xpm</file> <file>icons/vglogview_read.xpm</file> <file>icons/vglogview_write.xpm</file> + <file>icons/context_help.xpm</file> </qresource> </RCC> Modified: branches/valkyrie_qt4port/mainwindow.cpp =================================================================== --- branches/valkyrie_qt4port/mainwindow.cpp 2010-01-08 21:43:43 UTC (rev 464) +++ branches/valkyrie_qt4port/mainwindow.cpp 2010-01-13 22:07:17 UTC (rev 465) @@ -29,6 +29,9 @@ #include "toolview/memcheckview.h" #include "toolview/helgrindview.h" +#include "help/help_about.h" +#include "help/help_context.h" +#include "help/help_urls.h" #include "options/vk_option.h" #include "utils/vk_config.h" @@ -70,6 +73,9 @@ icon_vk.addPixmap( QPixmap( QString::fromUtf8(":/vk_icons/icons/valkyrie.xpm") ), QIcon::Normal, QIcon::Off ); setWindowIcon( icon_vk ); + // handbook: init before menubar / toolbar + handBook = new HandBook(); + // interface setup setupLayout(); setupActions(); @@ -95,6 +101,10 @@ vkConfig->setValue( "mainwindow/size", size() ); vkConfig->setValue( "mainwindow/pos", pos() ); vkConfig->sync(); + + // handbook has no parent, so have to delete it. + delete handBook; + handBook = 0; } @@ -265,7 +275,8 @@ menuBar = new QMenuBar( this ); menuBar->setObjectName( QString::fromUtf8("menuBar") ); menuBar->setGeometry( QRect(0, 0, 496, 25) ); - + this->setMenuBar( menuBar ); + menuFile = new QMenu( menuBar ); menuFile->setObjectName( QString::fromUtf8("menuFile") ); menuFile->setTitle( QApplication::translate("MainWindowClass", "&File", 0, QApplication::UnicodeUTF8) ); @@ -282,8 +293,10 @@ menuHelp->setObjectName( QString::fromUtf8("menuHelp") ); menuHelp->setTitle( QApplication::translate("MainWindowClass", "Help", 0, QApplication::UnicodeUTF8) ); - this->setMenuBar( menuBar ); + // application-wide context help button + ContextHelpAction* ctxtHlpAction = new ContextHelpAction( this, handBook ); + // ------------------------------------------------------------ // Add actions to menus menuBar->addAction( menuFile->menuAction() ); @@ -291,7 +304,10 @@ menuBar->addAction( menuProcess->menuAction() ); menuBar->addAction( menuTools->menuAction() ); menuBar->addAction( menuHelp->menuAction() ); - +//TODO: right justify + menuBar->addSeparator(); + menuBar->addAction( ctxtHlpAction ); + menuFile->addAction( actFile_NewProj ); menuFile->addAction( actFile_OpenProj ); menuFile->addSeparator(); @@ -348,9 +364,9 @@ // ------------------------------------------------------------ // Basic statusbar setup mainStatusBar = this->statusBar(); - mainStatusBar->setSizeGripEnabled( false ); mainStatusBar->setObjectName( QString::fromUtf8("mainStatusBar ") ); - mainStatusBar->setSizeGripEnabled( false ); +//TODO: why disable? +// mainStatusBar->setSizeGripEnabled( false ); statusLabel = new QLabel( mainStatusBar ); statusLabel->setObjectName( QString::fromUtf8("statusLabel ") ); @@ -613,7 +629,7 @@ */ void MainWindow::openHandBook() { - cerr << "TODO: MainWindow::openHandBook()" << endl; + handBook->showYourself(); } @@ -622,7 +638,8 @@ */ void MainWindow::openAboutVk() { - cerr << "TODO: MainWindow::openAboutVk()" << endl; + HelpAbout dlg( this, HELPABOUT::ABOUT_VK ); + dlg.exec(); } @@ -631,7 +648,8 @@ */ void MainWindow::openAboutLicense() { - cerr << "TODO: MainWindow::openAboutLicense()" << endl; + HelpAbout dlg( this, HELPABOUT::LICENSE ); + dlg.exec(); } @@ -640,5 +658,6 @@ */ void MainWindow::openAboutSupport() { - cerr << "TODO: MainWindow::openAboutSupport()" << endl; + HelpAbout dlg( this, HELPABOUT::SUPPORT ); + dlg.exec(); } Modified: branches/valkyrie_qt4port/mainwindow.h =================================================================== --- branches/valkyrie_qt4port/mainwindow.h 2010-01-08 21:43:43 UTC (rev 464) +++ branches/valkyrie_qt4port/mainwindow.h 2010-01-13 22:07:17 UTC (rev 465) @@ -29,6 +29,7 @@ #include <QToolButton> #include <QVBoxLayout> +#include "help/help_handbook.h" #include "objects/valkyrie_object.h" #include "options/vk_options_dialog.h" #include "toolview/toolview.h" @@ -76,6 +77,7 @@ Valkyrie* valkyrie; ToolViewStack* toolViewStack; QLabel* statusLabel; + HandBook* handBook; private: QAction* actFile_NewProj; Modified: branches/valkyrie_qt4port/objects/valgrind_object.cpp =================================================================== --- branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-01-08 21:43:43 UTC (rev 464) +++ branches/valkyrie_qt4port/objects/valgrind_object.cpp 2010-01-13 22:07:17 UTC (rev 465) @@ -20,13 +20,13 @@ #include <QDir> +#include "help/help_urls.h" #include "objects/valgrind_object.h" #include "options/valgrind_options_page.h" // createVkOptionsPage() #include "utils/vk_config.h" //#include "config.h" -//#include "html_urls.... [truncated message content] |