kdeui Library API Documentation

kwhatsthismanager.cpp

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., 59 Temple Place - Suite 330, 00017 * Boston, MA 02111-1307, USA. 00018 */ 00019 #include "kwhatsthismanager_p.h" 00020 #include "qwhatsthis.h" 00021 #include <qvariant.h> 00022 #include <kdebug.h> 00023 #include <qtextedit.h> 00024 #include <klocale.h> 00025 #include <kapplication.h> 00026 00027 KWhatsThisManager *KWhatsThisManager::s_instance = 0; 00028 00029 class KWhatsThisUndefined : public QWhatsThis 00030 { 00031 public: 00032 KWhatsThisUndefined (QWidget *); 00033 QString text (const QPoint &); 00034 public slots: 00035 bool clicked (const QString &); 00036 protected: 00037 QWidget *m_widget; 00038 }; 00039 00040 KWhatsThisUndefined::KWhatsThisUndefined (QWidget *w) 00041 : QWhatsThis (w) 00042 { 00043 m_widget = w; 00044 } 00045 00046 QString KWhatsThisUndefined::text (const QPoint &) 00047 { 00048 if (!m_widget) 00049 return ""; 00050 QString txt = i18n ("<b>Not Defined</b><br>There is no \"What's This\"" 00051 " help assigned to this widget. If you want to help us and " 00052 " describe the widget, you are welcome to <a href=\"submit" 00053 "-whatsthis\">send us \"What's This\" help</a> for it."); 00054 QString parent; 00055 if (m_widget -> parentWidget ()) 00056 parent = QWhatsThis::textFor (m_widget -> parentWidget ()); 00057 if (parent != txt) 00058 if (! parent . isEmpty ()) 00059 return parent; 00060 return txt; 00061 } 00062 00063 bool KWhatsThisUndefined::clicked (const QString& href) 00064 { 00065 if (href == "submit-whatsthis") { 00066 QWidget *w = m_widget; 00067 QString body; 00068 body . append ("Widget text: '" + (m_widget -> property ("text") . toString ()) + "'\n"); 00069 QString dsc = QString ("current --> ") + m_widget -> name (); 00070 dsc . append (QString (" (") + m_widget -> className () + ")\n"); 00071 for (w = m_widget; w && w != m_widget -> topLevelWidget (); w = w -> parentWidget ()) { 00072 dsc . append (w -> name ()); 00073 dsc . append (QString (" (") + w -> className () + ")\n"); 00074 } 00075 w = m_widget -> topLevelWidget (); 00076 if (w) { 00077 dsc . append ("toplevel --> "); 00078 dsc . append (w -> name ()); 00079 dsc . append (QString (" (") + w -> className () + ")\n"); 00080 } 00081 body . append (dsc); 00082 QString subj ("What's This submission: "); 00083 subj . append (qApp -> argv () [0]); 00084 body . append ("\nPlease type in your what's this help between these lines: " 00085 "\n--%-----------------------------------------------------------------------\n" 00086 "\n--%-----------------------------------------------------------------------"); 00087 kapp -> invokeMailer ("quality-whatsthis@kde.org", "", "", subj, body); 00088 } 00089 return TRUE; 00090 } 00091 00092 void KWhatsThisManager::init () 00093 { 00094 if (s_instance) 00095 return; 00096 s_instance = new KWhatsThisManager; 00097 } 00098 00099 KWhatsThisManager::KWhatsThisManager () 00100 { 00101 // go away... 00102 // qApp -> installEventFilter (this); 00103 } 00104 00105 bool KWhatsThisManager::eventFilter (QObject * /*o*/, QEvent *e) 00106 { 00107 if (e -> type () == QEvent::ChildInserted) { 00108 QChildEvent *ce = (QChildEvent *)e; 00109 // kdDebug () << "new qobject:" << ce -> child () << endl; 00110 if (ce -> child () -> isWidgetType ()) { 00111 QWidget *w = (QWidget *) (ce -> child ()); 00112 // kdDebug () << "new qwidget:" << w << endl; 00113 if (QWhatsThis::textFor (w) . isEmpty ()) 00114 new KWhatsThisUndefined (w); 00115 } 00116 } 00117 return false; 00118 } 00119 00120 #include "kwhatsthismanager_p.moc" 00121
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Apr 12 22:56:33 2005 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003