• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

kwhatsthismanager.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE Libraries
00002  *  Copyright (C) 2004 Peter Rockai (mornfall) <mornfall@danill.sk>
00003  *
00004  *  This library is free software; you can redistribute it and/or
00005  *  modify it under the terms of the GNU Library General Public
00006  *  License as published by the Free Software Foundation; either
00007  *  version 2 of the License, or (at your option) any later version.
00008  *
00009  *  This library is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  *  Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this library; see the file COPYING.LIB.  If not, write to
00016  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  *  Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include "kwhatsthismanager_p.h"
00021 #include <kdebug.h>
00022 
00023 #include <QtCore/QVariant>
00024 #include <QtGui/QApplication>
00025 #include <QtGui/QWhatsThis>
00026 #include <QtGui/QWhatsThisClickedEvent>
00027 
00028 #include <klocale.h>
00029 #include <ktoolinvocation.h>
00030 
00031 KWhatsThisManager *KWhatsThisManager::s_instance = 0;
00032 
00033 QString KWhatsThisManager::text() const
00034 {
00035   QString txt = i18n ("<b>Not Defined</b><br/>There is no \"What's This\""
00036           " help assigned to this widget. If you want to help us to"
00037           " describe the widget, you are welcome to <a href=\"submit"
00038           "-whatsthis\">send us your own \"What's This\" help</a> for it.");
00039   return txt;
00040 }
00041 
00042 void KWhatsThisManager::clicked( const QString& href, QWidget *widget )
00043 {
00044   if ( href == "submit-whatsthis" ) {
00045     QString body;
00046     body.append( QString( "Widget text: '%1'\n" ).arg( widget->property( "text" ).toString() ) );
00047 
00048     QString dsc = QString( "current --> %1" ).arg( widget->objectName() );
00049     dsc.append( QString( " (%1)\n" ).arg( widget->metaObject()->className() ) );
00050 
00051     QWidget *w;
00052     for ( w = widget; w && w != widget->topLevelWidget(); w = w->parentWidget() ) {
00053       dsc.append( w->objectName() );
00054       dsc.append( QString( " (%1)\n" ).arg( w->metaObject()->className() ) );
00055     }
00056 
00057     w = widget->topLevelWidget();
00058 
00059     if ( w ) {
00060       dsc.append( "toplevel --> " );
00061       dsc.append( w->objectName() );
00062       dsc.append( QString( " (%1)\n" ).arg( w->metaObject()->className() ) );
00063     }
00064 
00065     body.append( dsc );
00066 
00067     QString subject( "What's This submission: " );
00068     subject.append( qApp->argv()[ 0 ] );
00069 
00070     body.append( "\nPlease type in your what's this help between these lines: "
00071                  "\n--%-----------------------------------------------------------------------\n"
00072                  "\n--%-----------------------------------------------------------------------" );
00073 
00074     KToolInvocation::invokeMailer( "quality-whatsthis@kde.org", "", "", subject, body );
00075   }
00076 }
00077 
00078 void KWhatsThisManager::init()
00079 {
00080   if ( s_instance )
00081     return;
00082 
00083   s_instance = new KWhatsThisManager;
00084 }
00085 
00086 KWhatsThisManager::KWhatsThisManager()
00087 {
00088   // go away...
00089   qApp->installEventFilter( this );
00090 }
00091 
00092 bool KWhatsThisManager::eventFilter( QObject *object, QEvent *event )
00093 {
00094     if ( event->type() == QEvent::WhatsThis ) {
00095         QHelpEvent *he = static_cast<QHelpEvent* >(event);
00096         QWidget *widget = qobject_cast<QWidget*>( object );
00097         if ( widget ) {
00098             QHelpEvent queryEvent(QEvent::QueryWhatsThis, he->pos(), he->globalPos());
00099             const bool sentEvent = QApplication::sendEvent(widget, &queryEvent);
00100             if (!sentEvent || !queryEvent.isAccepted()) {
00101                 // No whats-this defined by the widget (at this position): show fallback one
00102                 QWhatsThis::showText(he->globalPos(), text(), widget);
00103                 return true;
00104             }
00105         }
00106     } else if ( event->type() == QEvent::WhatsThisClicked ) {
00107         QWhatsThisClickedEvent *wte = static_cast<QWhatsThisClickedEvent* >(event);
00108         QWidget *widget = qobject_cast<QWidget*>( object );
00109         if ( widget ) {
00110             clicked( wte->href(), widget );
00111             return true;
00112         }
00113     }
00114 
00115     return false;
00116 }
00117 
00118 #include "kwhatsthismanager_p.moc"
00119 

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal