VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/include/QIRichLabel.h@ 3943

Last change on this file since 3943 was 3943, checked in by vboxsync, 18 years ago

2142: GUI should download Additions:

  1. QIMessageBox was changed to use QIRichLabel instead of QLabel for the text displaying purposes.
  2. QIRichLabel was updated to allow user to copy the link contained in the label text through the context menu.
  3. All the Additions Downloader’s messages were updated according the described requirements (including the new one messages and the protocol http:// displaying before the image path).
  4. The progress bar is now appears just after the code decides it is necessary to download additions.
  5. Some minor bug-fixes ( bonus :) ).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 4.5 KB
Line 
1/** @file
2 *
3 * VBox frontends: Qt GUI ("VirtualBox"):
4 * innotek Qt extensions: QIRichLabel class declaration
5 */
6
7/*
8 * Copyright (C) 2006-2007 innotek GmbH
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License as published by the Free Software Foundation,
14 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
15 * distribution. VirtualBox OSE is distributed in the hope that it will
16 * be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * If you received this file as part of a commercial VirtualBox
19 * distribution, then only the terms of your commercial VirtualBox
20 * license agreement apply instead of the previous paragraph.
21 */
22
23/*
24 * This class is based on the original QLabel implementation.
25 */
26
27#ifndef __QIRichLabel_h__
28#define __QIRichLabel_h__
29
30#include "qframe.h"
31
32class QSimpleRichText;
33class QLabelPrivate;
34class QAction;
35class QPopupMenu;
36
37class QIRichLabel : public QFrame
38{
39 Q_OBJECT
40 Q_PROPERTY( QString text READ text WRITE setText )
41 Q_PROPERTY( TextFormat textFormat READ textFormat WRITE setTextFormat )
42 Q_PROPERTY( QPixmap pixmap READ pixmap WRITE setPixmap )
43 Q_PROPERTY( bool scaledContents READ hasScaledContents WRITE setScaledContents )
44 Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
45 Q_PROPERTY( int indent READ indent WRITE setIndent )
46 Q_OVERRIDE( BackgroundMode backgroundMode DESIGNABLE true )
47
48public:
49 QIRichLabel (QWidget *parent, const char* name=0, WFlags f=0);
50 QIRichLabel (const QString &text, QWidget *parent, const char* name=0,
51 WFlags f=0);
52 QIRichLabel (QWidget *buddy, const QString &,
53 QWidget *parent, const char* name=0, WFlags f=0 );
54 ~QIRichLabel();
55
56 QString text() const { return ltext; }
57 QPixmap *pixmap() const { return lpixmap; }
58 QPicture *picture() const { return lpicture; }
59 QMovie *movie() const;
60
61 TextFormat textFormat() const;
62 void setTextFormat( TextFormat );
63
64 int alignment() const { return align; }
65 virtual void setAlignment( int );
66 int indent() const { return extraMargin; }
67 void setIndent( int );
68
69 bool autoResize() const { return autoresize; }
70 virtual void setAutoResize( bool );
71 bool hasScaledContents() const;
72 void setScaledContents( bool );
73 QSize sizeHint() const;
74 QSize minimumSizeHint() const;
75 virtual void setBuddy( QWidget * );
76 QWidget *buddy() const;
77 int heightForWidth(int) const;
78
79 void setFont( const QFont &f );
80 void setFixedHeight (int);
81
82 void setMaxHeightMode (bool);
83
84public slots:
85 virtual void setText( const QString &);
86 virtual void setPixmap( const QPixmap & );
87 virtual void setPicture( const QPicture & );
88 virtual void setMovie( const QMovie & );
89 virtual void setNum( int );
90 virtual void setNum( double );
91 void clear();
92
93protected slots:
94 void putToClipBoard();
95
96protected:
97 void drawContents ( QPainter * );
98 void fontChange ( const QFont & );
99 void mouseMoveEvent (QMouseEvent *);
100 void mousePressEvent (QMouseEvent *);
101 void resizeEvent ( QResizeEvent* );
102 void focusInEvent ( QFocusEvent* );
103 void keyPressEvent ( QKeyEvent* );
104 void contextMenuEvent (QContextMenuEvent*);
105
106signals:
107 void clickedOnLink (const QString&);
108
109private slots:
110 void acceleratorSlot();
111 void buddyDied();
112 void movieUpdated(const QRect&);
113 void movieResized(const QSize&);
114
115private:
116 void init();
117 void clearContents();
118 void updateLabel (QSize oldSizeHint);
119 QString compressText (int paneWidth = -1) const;
120 QSize sizeForWidth (int w) const;
121
122 QString ltext;
123 QPixmap *lpixmap;
124 QPicture *lpicture;
125 QMovie *lmovie;
126 QPopupMenu *popupMenu;
127 QString popupBuffer;
128 QWidget *lbuddy;
129 ushort align;
130 short extraMargin;
131 uint autoresize:1;
132 uint scaledcontents :1;
133 uint baseheight;
134 TextFormat textformat;
135 QAccel *accel;
136 QLabelPrivate *d;
137 QSimpleRichText *doc;
138 bool mMaxHeightMode;
139
140 friend class QTipLabel;
141
142 QIRichLabel( const QIRichLabel & );
143 QIRichLabel &operator=( const QIRichLabel & );
144};
145
146#endif // __QIRichLabel_h__
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette