summaryrefslogtreecommitdiff
path: root/core/applets/clipboardapplet/clipboard.cpp
Unidiff
Diffstat (limited to 'core/applets/clipboardapplet/clipboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/clipboardapplet/clipboard.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/core/applets/clipboardapplet/clipboard.cpp b/core/applets/clipboardapplet/clipboard.cpp
index 57a4088..a32e98b 100644
--- a/core/applets/clipboardapplet/clipboard.cpp
+++ b/core/applets/clipboardapplet/clipboard.cpp
@@ -1,70 +1,68 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "clipboard.h" 21#include "clipboard.h"
22 22
23#include <opie2/otaskbarapplet.h> 23#include <opie2/otaskbarapplet.h>
24#include <qpe/resource.h> 24#include <opie2/oresource.h>
25
25#include <qpe/applnk.h> 26#include <qpe/applnk.h>
26 27
27#include <qpainter.h> 28#include <qpainter.h>
28#include <qpopupmenu.h> 29#include <qpopupmenu.h>
29#include <qwindowsystem_qws.h> 30#include <qwindowsystem_qws.h>
30#include <qapplication.h> 31#include <qapplication.h>
31#include <qclipboard.h> 32#include <qclipboard.h>
32#include <qtimer.h> 33#include <qtimer.h>
33 34
34//=========================================================================== 35//===========================================================================
35 36
36 37
37using namespace Opie::Ui; 38using namespace Opie::Ui;
38ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name ) 39ClipboardApplet::ClipboardApplet( QWidget *parent, const char *name ) : QWidget( parent, name )
39{ 40{
40 setFixedWidth ( AppLnk::smallIconSize() ); 41 setFixedWidth ( AppLnk::smallIconSize() );
41 setFixedHeight ( AppLnk::smallIconSize() ); 42 setFixedHeight ( AppLnk::smallIconSize() );
42 43
43 QImage img = Resource::loadImage( "paste"); 44 m_clipboardPixmap = Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon );
44 img = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
45
46 m_clipboardPixmap.convertFromImage( img );
47 45
48 m_timer = new QTimer ( this ); 46 m_timer = new QTimer ( this );
49 47
50 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged()), this, SLOT( newData())); 48 connect ( QApplication::clipboard ( ), SIGNAL( dataChanged()), this, SLOT( newData()));
51 connect ( m_timer, SIGNAL( timeout()), this, SLOT( newData())); 49 connect ( m_timer, SIGNAL( timeout()), this, SLOT( newData()));
52 connect ( qApp, SIGNAL( aboutToQuit()), this, SLOT( shutdown())); 50 connect ( qApp, SIGNAL( aboutToQuit()), this, SLOT( shutdown()));
53 51
54 m_menu = 0; 52 m_menu = 0;
55 m_dirty = true; 53 m_dirty = true;
56 m_lasttext = QString::null; 54 m_lasttext = QString::null;
57 55
58 m_timer-> start ( 0, true ); 56 m_timer-> start ( 0, true );
59} 57}
60 58
61ClipboardApplet::~ClipboardApplet ( ) 59ClipboardApplet::~ClipboardApplet ( )
62{ 60{
63} 61}
64 62
65int ClipboardApplet::position() 63int ClipboardApplet::position()
66{ 64{
67 return 6; 65 return 6;
68} 66}
69 67
70void ClipboardApplet::shutdown ( ) 68void ClipboardApplet::shutdown ( )
@@ -75,51 +73,51 @@ void ClipboardApplet::shutdown ( )
75 m_timer-> stop ( ); 73 m_timer-> stop ( );
76} 74}
77 75
78void ClipboardApplet::mousePressEvent ( QMouseEvent *) 76void ClipboardApplet::mousePressEvent ( QMouseEvent *)
79{ 77{
80 if ( m_dirty ) { 78 if ( m_dirty ) {
81 delete m_menu; 79 delete m_menu;
82 80
83 m_menu = new QPopupMenu ( this ); 81 m_menu = new QPopupMenu ( this );
84 m_menu-> setCheckable ( true ); 82 m_menu-> setCheckable ( true );
85 83
86 if ( m_history. count ( )) { 84 if ( m_history. count ( )) {
87 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) { 85 for ( unsigned int i = 0; i < m_history. count ( ); i++ ) {
88 QString str = m_history [i]; 86 QString str = m_history [i];
89 87
90 if ( str. length ( ) > 20 ) 88 if ( str. length ( ) > 20 )
91 str = str. left ( 20 ) + "..."; 89 str = str. left ( 20 ) + "...";
92 90
93 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i ); 91 m_menu-> insertItem ( QString ( "%1: %2" ). arg ( i + 1 ). arg ( str ), i );
94 m_menu-> setItemChecked ( i, false ); 92 m_menu-> setItemChecked ( i, false );
95 } 93 }
96 m_menu-> setItemChecked ( m_history. count ( ) - 1, true ); 94 m_menu-> setItemChecked ( m_history. count ( ) - 1, true );
97 m_menu-> insertSeparator ( ); 95 m_menu-> insertSeparator ( );
98 } 96 }
99 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "cut" )), tr( "Cut" ), 100 ); 97 m_menu-> insertItem ( Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ), tr( "Cut" ), 100 );
100 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "copy" )), tr( "Copy" ), 101 ); 98 m_menu-> insertItem ( Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ), tr( "Copy" ), 101 );
101 m_menu-> insertItem ( QIconSet ( Resource::loadPixmap ( "paste" )), tr( "Paste" ), 102 ); 99 m_menu-> insertItem ( Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ), tr( "Paste" ), 102 );
102 100
103 connect ( m_menu, SIGNAL( activated(int)), this, SLOT( action(int))); 101 connect ( m_menu, SIGNAL( activated(int)), this, SLOT( action(int)));
104 102
105 m_dirty = false; 103 m_dirty = false;
106 } 104 }
107 QPoint p = mapToGlobal ( QPoint ( 0, 0 )); 105 QPoint p = mapToGlobal ( QPoint ( 0, 0 ));
108 QSize s = m_menu-> sizeHint ( ); 106 QSize s = m_menu-> sizeHint ( );
109 107
110 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ))); 108 m_menu-> popup ( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( )));
111} 109}
112 110
113void ClipboardApplet::action(int id) 111void ClipboardApplet::action(int id)
114{ 112{
115 ushort unicode = 0; 113 ushort unicode = 0;
116 int scan = 0; 114 int scan = 0;
117 115
118 switch ( id ) { 116 switch ( id ) {
119 case 100: 117 case 100:
120 unicode = 'X' - '@'; 118 unicode = 'X' - '@';
121 scan = Key_X; // Cut 119 scan = Key_X; // Cut
122 break; 120 break;
123 case 101: 121 case 101:
124 unicode = 'C' - '@'; 122 unicode = 'C' - '@';
125 scan = Key_C; // Copy 123 scan = Key_C; // Copy