From kde-core-devel Sun Mar 30 16:14:12 2003 From: Tim Jansen Date: Sun, 30 Mar 2003 16:14:12 +0000 To: kde-core-devel Subject: [PATCH] WhatsThis links in KActiveLabels X-MARC-Message: https://marc.info/?l=kde-core-devel&m=104904098011169 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_Ufxh+4aCWol23p4" --Boundary-00=_Ufxh+4aCWol23p4 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi... I would like to add the attached patch to kdelibs/kdeui/kactivelabel.*. It adds "What'sThis"/Tooltip link support to KActiveLabel. When the users click on such a label a tooltip appears, usually with additional information. In order to create such a link just include a More Information in the text of the KActiveLabel. Here's a screenshot: http://www.tjansen.de/krfb/whatsthis.png The purpose is to create more structure for the instructions in a dialog or wizard. Especially Desktop Sharing suffers from having far too much text in the dialogs, but the information is still needed sometimes. Making the texts shorter and labeling the information increases the probability that the user actually reads them... bye... --Boundary-00=_Ufxh+4aCWol23p4 Content-Type: text/x-diff; charset="us-ascii"; name="kactivelabel-whatsthis.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kactivelabel-whatsthis.patch" Index: kdeui/kactivelabel.cpp =================================================================== RCS file: /home/kde/kdelibs/kdeui/kactivelabel.cpp,v retrieving revision 1.5 diff -u -3 -p -r1.5 kactivelabel.cpp --- kdeui/kactivelabel.cpp 29 Mar 2002 04:53:01 -0000 1.5 +++ kdeui/kactivelabel.cpp 30 Mar 2003 16:03:41 -0000 @@ -17,10 +17,13 @@ Boston, MA 02111-1307, USA. */ +#include "kactivelabel.h" + #include +#include +#include #include -#include "kactivelabel.h" KActiveLabel::KActiveLabel(QWidget * parent, const char * name) : QTextBrowser(parent, name) @@ -62,6 +65,12 @@ void KActiveLabel::paletteChanged() void KActiveLabel::openLink(const QString & link) { + QRegExp whatsthis("whatsthis:/*([^/].*)"); + if (whatsthis.exactMatch(link)) { + QWhatsThis::display(whatsthis.cap(1)); + return; + } + QStringList args; args << "exec" << link; kapp->kdeinitExec("kfmclient", args); Index: kdeui/kactivelabel.h =================================================================== RCS file: /home/kde/kdelibs/kdeui/kactivelabel.h,v retrieving revision 1.5 diff -u -3 -p -r1.5 kactivelabel.h --- kdeui/kactivelabel.h 1 Aug 2002 11:39:36 -0000 1.5 +++ kdeui/kactivelabel.h 30 Mar 2003 16:03:41 -0000 @@ -26,6 +26,8 @@ class KActiveLabelPrivate; /** * Label with support for selection and clickable links. + * @ref openLink() the actions that will be taken when the user + * clicks on a link. * * @author Waldo Bastian (bastian@kde.org) * @version $Id: kactivelabel.h,v 1.5 2002/08/01 11:39:36 pfeiffer Exp $ @@ -57,7 +59,11 @@ public: public slots: /** - * Opens @p link. + * Opens @p link in the default browser. + * + * If @p link starts with the text "whatsthis:" a @ref QWhatsThis + * box will appear and the display the rest of the text. The WhatsThis + * functionality is available since KDE 3.2. */ virtual void openLink(const QString & link); --Boundary-00=_Ufxh+4aCWol23p4--