~ubuntu-branches/ubuntu/karmic/basket/karmic

« back to all changes in this revision

Viewing changes to src/linklabel.h

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Tallon
  • Date: 2004-10-23 02:21:16 UTC
  • Revision ID: james.westby@ubuntu.com-20041023022116-i8hjksw6mn85ideq
Tags: upstream-0.4.0d
Import upstream version 0.4.0d

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2003 by S�bastien Lao�t                                 *
 
3
 *   sebastient.laout@tuxfamily.org                                        *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program 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         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 
19
 ***************************************************************************/
 
20
 
 
21
#ifndef LINKLABEL_H
 
22
#define LINKLABEL_H
 
23
 
 
24
class QString;
 
25
class KURL;
 
26
class QColor;
 
27
class QLabel;
 
28
class QBoxLayout;
 
29
class QSpacerItem;
 
30
class QPushButton;
 
31
class QCheckBox;
 
32
class QComboBox;
 
33
class KColorButton;
 
34
 
 
35
class IconSizeCombo;
 
36
 
 
37
#include <qframe.h>
 
38
#include <kapplication.h>
 
39
 
 
40
/**Store the style of links
 
41
  *@author S�bastien Lao�t
 
42
  */
 
43
class LinkLook
 
44
{
 
45
  public:
 
46
        LinkLook( bool underline = true, bool italic = false, bool bold = false, bool hoverUnder = true,
 
47
                  QColor color = QColor("blue"), QColor hoverColor = QColor("red"),
 
48
                  bool showIcon = true, int iconSize = 16, bool onTopIcon = false );
 
49
        void setLook( bool underline = true, bool italic = false, bool bold = false, bool hoverUnder = true,
 
50
                      QColor color = QColor("blue"), QColor hoverColor = QColor("red"),
 
51
                      bool showIcon = true, int iconSize = 16, bool onTopIcon = false );
 
52
        inline bool   underline()  { return m_underline;  }
 
53
        inline bool   italic()     { return m_italic;     }
 
54
        inline bool   bold()       { return m_bold;       }
 
55
        inline bool   hoverUnder() { return m_hoverUnder; }
 
56
        inline QColor color()      { return m_color;      }
 
57
        inline QColor hoverColor() { return m_hoverColor; }
 
58
        inline bool   showIcon()   { return m_showIcon;   }
 
59
        inline int    iconSize()   { return m_iconSize;   }
 
60
        inline bool   onTopIcon()  { return m_onTopIcon;  }
 
61
  private:
 
62
        bool   m_underline;
 
63
        bool   m_italic;
 
64
        bool   m_bold;
 
65
        bool   m_hoverUnder;
 
66
        QColor m_color;
 
67
        QColor m_hoverColor;
 
68
        bool   m_showIcon;
 
69
        int    m_iconSize;
 
70
        bool   m_onTopIcon;
 
71
  public:
 
72
        /* Global Looks */
 
73
        static LinkLook *localLook;
 
74
        static LinkLook *urlLook;
 
75
        static LinkLook *noUrlLook;
 
76
        /* Static method to get a LinkLook from an URL */
 
77
        static LinkLook* lookForURL(const KURL &url); // Item::ContentType type,
 
78
};
 
79
 
 
80
/**Used to represent links with icon and specific look
 
81
  *Note : This label will appear blank while LinkLook willn't be set
 
82
  *@author S�bastien Lao�t
 
83
  */
 
84
class LinkLabel : public QFrame
 
85
{
 
86
  Q_OBJECT
 
87
  public:
 
88
        LinkLabel(int hAlign, int vAlign, QWidget *parent = 0, const char *name = 0, WFlags f = 0);
 
89
        LinkLabel(const QString &title, const QString &icon, LinkLook *look, int hAlign, int vAlign,
 
90
                  QWidget *parent = 0, const char *name = 0, WFlags f = 0);
 
91
        ~LinkLabel();
 
92
  private:
 
93
        void initLabel(int hAlign, int vAlign);
 
94
  public:
 
95
        void setLink(const QString &title, const QString &icon, LinkLook *look = 0);
 
96
        void setLook(LinkLook *look);
 
97
        void setAlign(int hAlign, int vAlign);
 
98
  protected:
 
99
        void enterEvent(QEvent*);
 
100
        void leaveEvent(QEvent*);
 
101
  public:
 
102
        void setPaletteBackgroundColor(const QColor &color);
 
103
 
 
104
        QBoxLayout  *m_layout;
 
105
        QLabel      *m_icon;
 
106
        QLabel      *m_title;
 
107
        QSpacerItem *m_spacer1;
 
108
        QSpacerItem *m_spacer2;
 
109
 
 
110
        LinkLook    *m_look;
 
111
        int          m_hAlign;
 
112
        int          m_vAlign;
 
113
};
 
114
 
 
115
class LinkLookEditWidget : public QWidget
 
116
{
 
117
  Q_OBJECT
 
118
  public:
 
119
        LinkLookEditWidget(LinkLook *look, QWidget *parent = 0, const char *name = 0, WFlags fl = 0);
 
120
        ~LinkLookEditWidget();
 
121
        void saveChanges();
 
122
  private slots:
 
123
        void slotShowIcon(bool show);
 
124
  protected:
 
125
        LinkLook      *m_look;
 
126
        QPushButton   *m_underline;
 
127
        QPushButton   *m_italic;
 
128
        QPushButton   *m_bold;
 
129
        KColorButton  *m_color;
 
130
        KColorButton  *m_hoverColor;
 
131
        QCheckBox     *m_hoverUnder;
 
132
        QCheckBox     *m_showIcon;
 
133
        QWidget       *m_iconProperties;
 
134
        QComboBox     *m_onTopIcon;
 
135
        IconSizeCombo *m_iconSize;
 
136
};
 
137
 
 
138
#endif // LINKLABEL_H