~ubuntu-branches/ubuntu/oneiric/xca/oneiric

« back to all changes in this revision

Viewing changes to widgets/clicklabel.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Tino Keitel
  • Date: 2009-09-14 20:55:44 UTC
  • Revision ID: james.westby@ubuntu.com-20090914205544-l4qsm2tjimhd62vo
Tags: upstream-0.7.0
ImportĀ upstreamĀ versionĀ 0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* vi: set sw=4 ts=4:
 
2
 *
 
3
 * Copyright (C) 2001 - 2007 Christian Hohnstaedt.
 
4
 *
 
5
 * All rights reserved.
 
6
 */
 
7
 
 
8
#include "clicklabel.h"
 
9
 
 
10
#include <qtooltip.h>
 
11
#include <qpalette.h>
 
12
#include <qcolor.h>
 
13
 
 
14
ClickLabel::ClickLabel(QWidget *parent)
 
15
        :QLabel(parent)
 
16
{
 
17
        QFont fnt( font() );
 
18
        fnt.setBold(true);
 
19
        setFont( fnt );
 
20
        setFrameShape( QLabel::Panel );
 
21
        setFrameShadow( QLabel::Sunken );
 
22
        setAlignment( Qt::AlignCenter );
 
23
        setToolTip( tr("Double click for details") );
 
24
 
 
25
        setAutoFillBackground(true);
 
26
        QPalette pal = palette();
 
27
        QColor col = QColor(0xff, 0xff, 0xff);
 
28
        pal.setColor(QPalette::Normal, QPalette::Window, col );
 
29
        pal.setColor(QPalette::Inactive, QPalette::Window, col );
 
30
        setPalette( pal );
 
31
}
 
32
 
 
33
void ClickLabel::mouseDoubleClickEvent ( QMouseEvent * e )
 
34
{
 
35
        QWidget::mouseDoubleClickEvent(e);
 
36
        emit doubleClicked(text());
 
37
}
 
38
 
 
39
void ClickLabel::setColor(const QColor &col)
 
40
{
 
41
        QPalette pal = palette();
 
42
        pal.setColor(QPalette::Normal, QPalette::WindowText, col );
 
43
        pal.setColor(QPalette::Inactive, QPalette::WindowText, col );
 
44
        setPalette( pal );
 
45
}
 
46
 
 
47
void ClickLabel::setRed()
 
48
{
 
49
        setColor( QColor( 192, 32, 32) );
 
50
}
 
51
 
 
52
void ClickLabel::setGreen()
 
53
{
 
54
        setColor( QColor( 32, 192, 32) );
 
55
}
 
56
 
 
57
void ClickLabel::disableToolTip()
 
58
{
 
59
        setToolTip(QString());
 
60
}
 
61
 
 
62
 
 
63
CopyLabel::CopyLabel(QWidget *parent)
 
64
        :QLabel(parent)
 
65
{
 
66
#if QT_VERSION >= 0x040200
 
67
        setTextInteractionFlags(
 
68
                        Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
 
69
#endif
 
70
}
 
71