Qt3support--
[kdenetwork.git] / kget / docking.cpp
blobe3bfe7deb0d8691bf923534db3564bd55acfdcd0
1 /***************************************************************************
2 * docking.cpp
3 * -------------------
5 * Revision : $Id$
6 * begin : Tue Jan 29 2002
7 * copyright : (C) 2002 by Patrick Charbonnier
8 * : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss
9 * email : pch@freeshell.org
11 ****************************************************************************/
13 /***************************************************************************
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 ***************************************************************************/
27 #include <qtooltip.h>
28 //Added by qt3to4:
29 #include <QDragEnterEvent>
30 #include <QMouseEvent>
31 #include <QDropEvent>
33 #include <kaboutdata.h>
34 #include <kapplication.h>
35 #include <kiconloader.h>
36 #include <klocale.h>
37 #include <kmenu.h>
38 #include <kurldrag.h>
40 #include "kmainwidget.h"
41 #include "settings.h"
42 #include "docking.h"
45 DockWidget::DockWidget(KMainWidget * _parent):KSystemTray(_parent)
47 parent = _parent;
49 setPixmap( loadIcon( "kget_dock" ));
51 // popup menu for right mouse button
52 KMenu *popupMenu = contextMenu();
53 parent->action("drop_target")->plug(popupMenu);
54 parent->action("konqueror_integration")->plug(popupMenu);
55 popupMenu->insertSeparator();
56 parent->m_paPreferences->plug(popupMenu);
58 // Enable dropping
59 setAcceptDrops(true);
61 dtip = new DynamicTip( this );
62 dtip->setStatus( kapp->aboutData()->shortDescription() );
67 DockWidget::~DockWidget()
69 delete dtip;
70 dtip = 0;
74 void DockWidget::dragEnterEvent(QDragEnterEvent * event)
76 event->accept(KURLDrag::canDecode(event)
77 || Q3TextDrag::canDecode(event));
81 void DockWidget::dropEvent(QDropEvent * event)
83 KURL::List list;
84 QString str;
86 if (KURLDrag::decode(event, list)) {
87 parent->addTransfers(list);
88 } else if (Q3TextDrag::decode(event, str)) {
89 parent->addTransfer(str);
94 void DockWidget::mousePressEvent(QMouseEvent * e)
96 if (e->button() == Qt::MidButton) {
97 parent->slotPasteTransfer();
98 } else {
99 KSystemTray::mousePressEvent(e);
104 void DockWidget::updateToolTip( const QString& _status )
106 dtip->setStatus( _status );
110 void DockWidget::changeIcon( const QString& icon )
112 setPixmap( loadIcon( icon ));
116 DynamicTip::DynamicTip( QWidget * parent )
117 : QToolTip( parent )
119 // no explicit initialization needed
123 void DynamicTip::setStatus( const QString & _status )
125 status = _status;
128 void DynamicTip::maybeTip( const QPoint & _pos )
130 QRect r( parentWidget()->rect() );
131 tip( r, status );
134 #include "docking.moc"