Source Code (Use browser search to find items of interest.)

Class Index

kdelibs'KHelpMenu (./kdelibs/kdeui/khelpmenu.h:122)

class KHelpMenu : public QObject
{
  Q_OBJECT

  public:
    enum MenuId
    {
      menuHelpContents = 0,
      menuWhatsThis = 1,
      menuAboutApp = 2,
      menuAboutKDE = 3,
      menuReportBug = 4
    };

    /**
     * Constructor.
     *
     * @param parent The parent of the dialog boxes. The boxes are modeless
     *        and will be centered with respect to the parent.
     * @param aboutAppText User definable string that is used in the
     *        application specific dialog box. Note: The help menu will
     *        not open this dialog box if you don't define a string. See
     *        @ref showAboutApplication for more information.
     * @param showWhatsThis Decides whether a "Whats this" entry will be
     *        added to the dialog.
     * 
     */
    KHelpMenu( QWidget *parent=0, const QString &aboutAppText=QString::null,
	       bool showWhatsThis=true );

    /**
     * Constructor.
     *
     * @param parent The parent of the dialog boxes. The boxes are modeless
     *        and will be centered with respect to the parent.
     * @param aboutData User and app data used in the About app dialog
     * @param showWhatsThis Decides whether a "Whats this" entry will be
     *        added to the dialog.
     * 
     */
    KHelpMenu( QWidget *parent, const KAboutData *aboutData,
	       bool showWhatsThis=true, KActionCollection *actions = 0 );

    /**
     * Destructor
     *
     * Destroys dialogs and the menu pointer retuned by @ref menu
     */
    ~KHelpMenu();

    /**
     * Returns a popup menu you can use in the menu bar or where you
     * need it.
     *
     * Note: This method will only create one instance of the menu. If
     * you call this method twice or more the same pointer is returned
     */
    QPopupMenu *menu();

  public slots:
    /**
     * Opens the help page for the application. The application name is
     * used as a key to determine what to display and the system will attempt
     * to open <appName>/index.html.
     */
    void appHelpActivated();

    /**
     * Activates What's This help for the application.
     */
    void contextHelpActivated();

    /**
     * Opens an application specific dialog box. The dialog box will display
     * the string that was defined in the constructor. If that string was 
     * empty the @ref showAboutApplication is emitted instead.
     */
    void aboutApplication();

    /**
     * Opens the standard "About KDE" dialog box.
     */
    void aboutKDE();

    /**
     * Opens the standard "Report Bugs" dialog box.
     */
    void reportBug();
    
  private slots:
    /**
     * Connected to the menu pointer (if created) to detect a delete
     * operation on the pointer. You should not delete the pointer in your
     * code yourself. Let the KHelpMenu destructor do the job.
     */
    void menuDestroyed();
    
    /**
     * Connected to the dialogs (about kde and bug report) to detect 
     * when they are closed (becomes hidden).
     */
    void dialogHidden();

    /**
     * This slot will delete a dialog (about kde or bug report) if the
     * dialog pointer is not zero and the the dialog is not visible. This
     * slot is activated by a one shot timer started in @ref dialogHidden
     */
    void timerExpired();

  signals:
    /**
     * This signal is emitted from the @ref aboutApplication if no 
     * "about application" string has been defined. The standard 
     * application specific dialog box that is normally activated in 
     * @ref aboutApp will not be displayed when this signal is emitted.
     */
    void showAboutApplication();

  private:
    QPopupMenu   *mMenu;
    KDialogBase  *mAboutApp;
    KAboutKDE    *mAboutKDE;
    KBugReport   *mBugReport;

    QString      mAboutAppText;
    QWidget      *mParent;

    bool         mShowWhatsThis;

    KHelpMenuPrivate *d;
};


kdelibs'KHelpMenu::KHelpMenu() (./kdelibs/kdeui/khelpmenu.cpp:57)

KHelpMenu::KHelpMenu( QWidget *parent, const QString &aboutAppText,
		      bool showWhatsThis )
  : QObject(parent), mMenu(0), mAboutApp(0), mAboutKDE(0), mBugReport(0),
    d(new KHelpMenuPrivate)
{
  mParent = parent;
  mAboutAppText = aboutAppText;
  mShowWhatsThis = showWhatsThis;
}


kdelibs'KHelpMenu::KHelpMenu() (./kdelibs/kdeui/khelpmenu.cpp:67)

KHelpMenu::KHelpMenu( QWidget *parent, const KAboutData *aboutData,
		      bool showWhatsThis, KActionCollection *actions )
  : QObject(parent), mMenu(0), mAboutApp(0), mAboutKDE(0), mBugReport(0),
    d(new KHelpMenuPrivate)
{
  mParent = parent;
  mShowWhatsThis = showWhatsThis;

  d->mAboutData = aboutData;
  if (aboutData)
  {
    mAboutAppText = aboutData->programName() + " " + aboutData->version() +
                    "\n" + aboutData->shortDescription();

    if (!aboutData->homepage().isNull())
      mAboutAppText += "\n" + aboutData->homepage();

    QValueList<KAboutPerson>::ConstIterator it;
    for (it = aboutData->authors().begin();
         it != aboutData->authors().end(); ++it)
    {
      mAboutAppText += "\n" + (*it).name() + " <"+(*it).emailAddress()+">";
    }

    if (!aboutData->copyrightStatement().isNull())
      mAboutAppText += "\n" + aboutData->copyrightStatement();
    mAboutAppText += "\n";
  }
  else
    mAboutAppText = QString::null;

    if (actions)
    {
        KStdAction::helpContents(this, SLOT(appHelpActivated()), actions);
        if (showWhatsThis)
            KStdAction::whatsThis(this, SLOT(contextHelpActivated()), actions);
        KStdAction::reportBug(this, SLOT(reportBug()), actions);
        KStdAction::aboutApp(this, SLOT(aboutApplication()), actions);
        KStdAction::aboutKDE(this, SLOT(aboutKDE()), actions);
    }
}


kdelibs'KHelpMenu::~KHelpMenu() (./kdelibs/kdeui/khelpmenu.cpp:109)

KHelpMenu::~KHelpMenu()
{
  delete mMenu;
  delete mAboutApp;
  delete mAboutKDE;
  delete mBugReport;
  delete d;
}



kdelibs'KHelpMenu::menu() (./kdelibs/kdeui/khelpmenu.cpp:119)

QPopupMenu* KHelpMenu::menu()
{
  if( mMenu == 0 )
  {
    //
    // 1999-12-02 Espen Sand:
    // I use hardcoded menu id's here. Reason is to stay backward
    // compatible.
    //
    mMenu = new QPopupMenu();
    connect( mMenu, SIGNAL(destroyed()), this, SLOT(menuDestroyed()));

    mMenu->insertItem( BarIcon( "contents", KIcon::SizeSmall),
		       i18n( "&Contents" ),menuHelpContents );
    mMenu->connectItem( menuHelpContents, this, SLOT(appHelpActivated()) );
    mMenu->setAccel( KStdAccel::key(KStdAccel::Help), menuHelpContents );

    if( mShowWhatsThis == true )
    {
      QToolButton* wtb = QWhatsThis::whatsThisButton(0);
      mMenu->insertItem( wtb->iconSet(),i18n( "What's &This" ), menuWhatsThis);
      mMenu->connectItem( menuWhatsThis, this, SLOT(contextHelpActivated()) );
      delete wtb;
      mMenu->setAccel( SHIFT + Key_F1, menuWhatsThis );
    }

    mMenu->insertSeparator();

    mMenu->insertItem( i18n( "&Report Bug..." ), menuReportBug );
    mMenu->connectItem( menuReportBug, this, SLOT(reportBug()) );

    mMenu->insertSeparator();

    mMenu->insertItem( kapp->miniIcon(),
      i18n( "&About" ) + ' ' + QString::fromLatin1(kapp->name()) + 
      QString::fromLatin1("..."), menuAboutApp );
    mMenu->connectItem( menuAboutApp, this, SLOT( aboutApplication() ) );

    mMenu->insertItem( i18n( "About &KDE..." ), menuAboutKDE );
    mMenu->connectItem( menuAboutKDE, this, SLOT( aboutKDE() ) );
  }

  return( mMenu );
}




kdelibs'KHelpMenu::appHelpActivated() (./kdelibs/kdeui/khelpmenu.cpp:166)

void KHelpMenu::appHelpActivated()
{
  kapp->invokeHTMLHelp( QString::fromLatin1(kapp->name()) + 
			QString::fromLatin1("/index.html"), 
			QString::fromLatin1("") );
}



kdelibs'KHelpMenu::aboutApplication() (./kdelibs/kdeui/khelpmenu.cpp:174)

void KHelpMenu::aboutApplication()
{
  if( mAboutAppText.isNull() == true || mAboutAppText.isEmpty() == true )
  {
    emit showAboutApplication();
  }
  else
  {
    if( mAboutApp == 0 )
    {
      mAboutApp = new KDialogBase( QString::null, // Caption is defined below
				   KDialogBase::Yes, KDialogBase::Yes,
				   KDialogBase::Yes, mParent, "about",
				   false, true, i18n("&OK") );
      connect( mAboutApp, SIGNAL(hidden()), this, SLOT( dialogHidden()) );
      
      QHBox *hbox = new QHBox( mAboutApp );
      mAboutApp->setMainWidget( hbox );
      hbox->setSpacing(KDialog::spacingHint()*3);
      hbox->setMargin(KDialog::marginHint()*1);

      QLabel *label1 = new QLabel(hbox);
      label1->setPixmap( kapp->icon() );
      QLabel *label2 = new QLabel(hbox);
      label2->setText( mAboutAppText );

      mAboutApp->setPlainCaption( i18n("About %1").arg(kapp->caption()) );
      mAboutApp->disableResize();
    }

    mAboutApp->show();
  }
}



kdelibs'KHelpMenu::aboutKDE() (./kdelibs/kdeui/khelpmenu.cpp:209)

void KHelpMenu::aboutKDE()
{
  if( mAboutKDE == 0 )
  {
    mAboutKDE = new KAboutKDE( mParent, "aboutkde", false );
    connect( mAboutKDE, SIGNAL(hidden()), this, SLOT( dialogHidden()) );
  }    
  mAboutKDE->show();
}



kdelibs'KHelpMenu::reportBug() (./kdelibs/kdeui/khelpmenu.cpp:220)

void KHelpMenu::reportBug()
{
  if( mBugReport == 0 )
  {
    mBugReport = new KBugReport( mParent, false );
    connect( mBugReport, SIGNAL(hidden()),this,SLOT( dialogHidden()) );
  }
  mBugReport->show();
}



kdelibs'KHelpMenu::dialogHidden() (./kdelibs/kdeui/khelpmenu.cpp:231)

void KHelpMenu::dialogHidden()
{
  QTimer::singleShot( 0, this, SLOT(timerExpired()) );
}



kdelibs'KHelpMenu::timerExpired() (./kdelibs/kdeui/khelpmenu.cpp:237)

void KHelpMenu::timerExpired()
{
  if( mAboutKDE != 0 && mAboutKDE->isVisible() == false )
  {
    delete mAboutKDE; mAboutKDE = 0;
  }

  if( mBugReport != 0 && mBugReport->isVisible() == false )
  {
    delete mBugReport; mBugReport = 0;
  }

  if( mAboutApp != 0 && mAboutApp->isVisible() == false )
  {
    delete mAboutApp; mAboutApp = 0;
  }
}



kdelibs'KHelpMenu::menuDestroyed() (./kdelibs/kdeui/khelpmenu.cpp:256)

void KHelpMenu::menuDestroyed()
{
  mMenu = 0;
}



kdelibs'KHelpMenu::contextHelpActivated() (./kdelibs/kdeui/khelpmenu.cpp:262)

void KHelpMenu::contextHelpActivated()
{
  QWhatsThis::enterWhatsThisMode();
}