1
/* This file is part of the KDE Libraries
2
* Copyright (C) 2004 Peter Rockai (mornfall) <mornfall@danill.sk>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Library General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public License
15
* along with this library; see the file COPYING.LIB. If not, write to
16
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
* Boston, MA 02110-1301, USA.
20
#include <QApplication>
23
#include <QWhatsThisClickedEvent>
26
#include <ktoolinvocation.h>
28
#include "kwhatsthismanager_p.h"
30
KWhatsThisManager *KWhatsThisManager::s_instance = 0;
32
QString KWhatsThisManager::text() const
34
QString txt = i18n ("<b>Not Defined</b><br>There is no \"What's This\""
35
" help assigned to this widget. If you want to help us to"
36
" describe the widget, you are welcome to <a href=\"submit"
37
"-whatsthis\">send us your own \"What's This\" help</a> for it.");
41
void KWhatsThisManager::clicked( const QString& href, QWidget *widget )
43
if ( href == "submit-whatsthis" ) {
45
body.append( QString( "Widget text: '%1'\n" ).arg( widget->property( "text" ).toString() ) );
47
QString dsc = QString( "current --> %1" ).arg( widget->objectName() );
48
dsc.append( QString( " (%1)\n" ).arg( widget->metaObject()->className() ) );
51
for ( w = widget; w && w != widget->topLevelWidget(); w = w->parentWidget() ) {
52
dsc.append( w->objectName() );
53
dsc.append( QString( " (%1)\n" ).arg( w->metaObject()->className() ) );
56
w = widget->topLevelWidget();
59
dsc.append( "toplevel --> " );
60
dsc.append( w->objectName() );
61
dsc.append( QString( " (%1)\n" ).arg( w->metaObject()->className() ) );
66
QString subject( "What's This submission: " );
67
subject.append( qApp->argv()[ 0 ] );
69
body.append( "\nPlease type in your what's this help between these lines: "
70
"\n--%-----------------------------------------------------------------------\n"
71
"\n--%-----------------------------------------------------------------------" );
73
KToolInvocation::invokeMailer( "quality-whatsthis@kde.org", "", "", subject, body );
77
void KWhatsThisManager::init()
82
s_instance = new KWhatsThisManager;
85
KWhatsThisManager::KWhatsThisManager()
88
qApp->installEventFilter( this );
91
bool KWhatsThisManager::eventFilter( QObject *object, QEvent *event )
93
if ( event->type() == QEvent::ChildAdded ) {
95
QChildEvent *childEvent = (QChildEvent*)event;
96
if ( childEvent->added() && childEvent->child()->isWidgetType() ) {
98
QWidget *widget = (QWidget *)(childEvent->child());
99
if ( widget->whatsThis().isEmpty() ) {
100
widget->setWhatsThis( text() );
103
} else if ( event->type() == QEvent::WhatsThisClicked ) {
104
QWhatsThisClickedEvent *wte = (QWhatsThisClickedEvent*)event;
105
QWidget *widget = qobject_cast<QWidget*>( object );
107
clicked( wte->href(), widget );
115
#include "kwhatsthismanager_p.moc"