• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • kdeui
  • widgets
ktextbrowser.cpp
Go to the documentation of this file.
1/* This file is part of the KDE Libraries
2 * Copyright (C) 1999-2000 Espen Sand (espen@kde.org)
3 * Copyright (C) 2006 Urs Wolfer <uwolfer at fwo.ch>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "ktextbrowser.h"
22
23#include <QtGui/QAction>
24#include <QtGui/QMenu>
25#include <QtGui/QKeyEvent>
26#include <QtGui/QTextBrowser>
27#include <QtGui/QWhatsThis>
28
29#include <kcursor.h>
30#include <kglobalsettings.h>
31#include <kicon.h>
32#include <kicontheme.h>
33#include <kurl.h>
34#include <ktoolinvocation.h>
35
36class KTextBrowser::Private
37{
38 public:
39 Private()
40 : notifyClick( false )
41 {
42 }
43
44 ~Private()
45 {
46 }
47
48 bool notifyClick;
49};
50
51KTextBrowser::KTextBrowser( QWidget *parent, bool notifyClick )
52 : QTextBrowser( parent ), d( new Private )
53{
54 d->notifyClick = notifyClick;
55}
56
57KTextBrowser::~KTextBrowser()
58{
59 delete d;
60}
61
62
63void KTextBrowser::setNotifyClick( bool notifyClick )
64{
65 d->notifyClick = notifyClick;
66}
67
68
69bool KTextBrowser::isNotifyClick() const
70{
71 return d->notifyClick;
72}
73
74
75void KTextBrowser::setSource( const QUrl& name )
76{
77 QString strName = name.toString();
78 if ( strName.isNull() )
79 return;
80
81 QRegExp whatsthis( "whatsthis:/*([^/].*)" );
82 if ( !d->notifyClick && whatsthis.exactMatch( strName ) ) {
83 QWhatsThis::showText( QCursor::pos(), whatsthis.cap( 1 ) );
84 } else if ( strName.indexOf( '@' ) > -1 ) {
85 if ( !d->notifyClick ) {
86 KToolInvocation::invokeMailer( KUrl( strName ) );
87 } else {
88 emit mailClick( QString(), strName );
89 }
90 } else {
91 if ( !d->notifyClick ) {
92 KToolInvocation::invokeBrowser( strName );
93 } else {
94 emit urlClick( strName );
95 }
96 }
97}
98
99
100void KTextBrowser::keyPressEvent( QKeyEvent *event )
101{
102 if ( event->key() == Qt::Key_Escape )
103 event->ignore();
104 else if ( event->key() == Qt::Key_F1 )
105 event->ignore();
106 else
107 QTextBrowser::keyPressEvent( event );
108}
109
110void KTextBrowser::wheelEvent( QWheelEvent *event )
111{
112 if ( KGlobalSettings::wheelMouseZooms() )
113 QTextBrowser::wheelEvent( event );
114 else // thanks, we don't want to zoom, so skip QTextEdit's impl.
115 QAbstractScrollArea::wheelEvent( event );
116}
117
118void KTextBrowser::contextMenuEvent( QContextMenuEvent *event )
119{
120 QMenu *popup = createStandardContextMenu(event->pos());
121 if (popup) {
122 KIconTheme::assignIconsToContextMenu( isReadOnly() ? KIconTheme::ReadOnlyText
123 : KIconTheme::TextEditor,
124 popup->actions() );
125
126 popup->exec( event->globalPos() );
127 delete popup;
128 }
129}
130
131#include "ktextbrowser.moc"
KGlobalSettings::wheelMouseZooms
static bool wheelMouseZooms()
Typically, QScrollView derived classes can be scrolled fast by holding down the Ctrl-button during wh...
Definition: kglobalsettings.cpp:707
KIconTheme::ReadOnlyText
@ ReadOnlyText
Definition: kicontheme.h:203
KIconTheme::TextEditor
@ TextEditor
Definition: kicontheme.h:202
KIconTheme::assignIconsToContextMenu
static void assignIconsToContextMenu(ContextMenus type, QList< QAction * > actions)
Assigns standard icons to the various standard text edit context menus.
Definition: kicontheme.cpp:599
KTextBrowser::urlClick
void urlClick(const QString &url)
Emitted if mailClick() is not emitted and the widget has been configured to emit the signal.
KTextBrowser::keyPressEvent
virtual void keyPressEvent(QKeyEvent *event)
Makes sure Key_Escape is ignored.
Definition: ktextbrowser.cpp:100
KTextBrowser::setNotifyClick
void setNotifyClick(bool notifyClick)
Decide whether a click on a link should be handled internally or if a signal should be emitted.
Definition: ktextbrowser.cpp:63
KTextBrowser::setSource
void setSource(const QUrl &name)
Reimplemented to NOT set the source but to do the special handling of links being clicked.
Definition: ktextbrowser.cpp:75
KTextBrowser::isNotifyClick
bool isNotifyClick() const
Returns whether a click on a link should be handled internally or if a signal should be emitted.
Definition: ktextbrowser.cpp:69
KTextBrowser::wheelEvent
virtual void wheelEvent(QWheelEvent *event)
Reimplemented to support Qt2 behavior (Ctrl-Wheel = fast scroll)
Definition: ktextbrowser.cpp:110
KTextBrowser::mailClick
void mailClick(const QString &name, const QString &address)
Emitted when a mail link has been activated and the widget has been configured to emit the signal.
KTextBrowser::KTextBrowser
KTextBrowser(QWidget *parent=0, bool notifyClick=false)
Creates a new text browser.
Definition: ktextbrowser.cpp:51
KTextBrowser::contextMenuEvent
virtual void contextMenuEvent(QContextMenuEvent *event)
Re-implemented for internal reasons.
Definition: ktextbrowser.cpp:118
KTextBrowser::~KTextBrowser
~KTextBrowser()
Destroys the text browser.
Definition: ktextbrowser.cpp:57
KToolInvocation::invokeMailer
static void invokeMailer(const KUrl &mailtoURL, const QByteArray &startup_id=QByteArray(), bool allowAttachments=false)
KToolInvocation::invokeBrowser
static void invokeBrowser(const QString &url, const QByteArray &startup_id=QByteArray())
KUrl
QMenu
QTextBrowser
QUrl
QWidget
kcursor.h
kglobalsettings.h
kicon.h
kicontheme.h
ktextbrowser.h
ktoolinvocation.h
kurl.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal