1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/* This file is part of the KDE Libraries
* Copyright (C) 2004 Peter Rockai (mornfall) <mornfall@danill.sk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kwhatsthismanager_p.h"
#include "qwhatsthis.h"
#include <qvariant.h>
#include <kdebug.h>
#include <qtextedit.h>
#include <klocale.h>
#include <kapplication.h>
KWhatsThisManager *KWhatsThisManager::s_instance = 0;
class KWhatsThisUndefined : public QWhatsThis
{
public:
KWhatsThisUndefined (QWidget *);
QString text (const QPoint &);
public slots:
bool clicked (const QString &);
protected:
QWidget *m_widget;
};
KWhatsThisUndefined::KWhatsThisUndefined (QWidget *w)
: QWhatsThis (w)
{
m_widget = w;
}
QString KWhatsThisUndefined::text (const QPoint &)
{
if (!m_widget)
return "";
QString txt = i18n ("<b>Not Defined</b><br>There is no \"What's This?\""
" help assigned to this widget. If you want to help us to "
" describe the widget, you are welcome to <a href=\"submit"
"-whatsthis\">send us your own \"What's This?\" help</a> for it.");
QString parent;
if (m_widget -> parentWidget ())
parent = QWhatsThis::textFor (m_widget -> parentWidget ());
if (parent != txt)
if (! parent . isEmpty ())
return parent;
return txt;
}
bool KWhatsThisUndefined::clicked (const QString& href)
{
if (href == "submit-whatsthis") {
QWidget *w = m_widget;
QString body;
body . append ("Widget text: '" + (m_widget -> property ("text") . toString ()) + "'\n");
QString dsc = QString ("current --> ") + m_widget -> name ();
dsc . append (QString (" (") + m_widget -> className () + ")\n");
for (w = m_widget; w && w != m_widget -> topLevelWidget (); w = w -> parentWidget ()) {
dsc . append (w -> name ());
dsc . append (QString (" (") + w -> className () + ")\n");
}
w = m_widget -> topLevelWidget ();
if (w) {
dsc . append ("toplevel --> ");
dsc . append (w -> name ());
dsc . append (QString (" (") + w -> className () + ")\n");
}
body . append (dsc);
QString subj ("What's This submission: ");
subj . append (qApp -> argv () [0]);
body . append ("\nPlease type in your what's this help between these lines: "
"\n--%-----------------------------------------------------------------------\n"
"\n--%-----------------------------------------------------------------------");
kapp -> invokeMailer ("quality-whatsthis@kde.org", "", "", subj, body);
}
return TRUE;
}
void KWhatsThisManager::init ()
{
if (s_instance)
return;
s_instance = new KWhatsThisManager;
}
KWhatsThisManager::KWhatsThisManager ()
{
// go away...
// qApp -> installEventFilter (this);
}
bool KWhatsThisManager::eventFilter (QObject * /*o*/, QEvent *e)
{
if (e -> type () == QEvent::ChildInserted) {
QChildEvent *ce = (QChildEvent *)e;
// kdDebug () << "new qobject:" << ce -> child () << endl;
if (ce -> child () -> isWidgetType ()) {
QWidget *w = (QWidget *) (ce -> child ());
// kdDebug () << "new qwidget:" << w << endl;
if (QWhatsThis::textFor (w) . isEmpty ())
new KWhatsThisUndefined (w);
}
}
return false;
}
#include "kwhatsthismanager_p.moc"
|