1 /***************************************************************************
2 * Copyright (C) 2005 by Tarek Saidi *
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; version 2 of the License. *
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. *
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 ***************************************************************************/
24 LinkLabel::LinkLabel(QWidget *parent,const QString& text, int x, int y,Qt::WFlags f) : QLabel(parent,f){
25 QFont font(parentWidget()->font());
26 font.setUnderline(true);
29 palette.setColor(foregroundRole(),QColor(20,20,255));
31 setCursor(Qt::PointingHandCursor);
36 LinkLabel::~LinkLabel(){
39 QString LinkLabel::url(){
42 else if(text().contains("@"))
43 return QString("mailto:")+text();
48 void LinkLabel::mouseReleaseEvent(QMouseEvent* event){
49 if(event->button()==Qt::LeftButton){
55 void LinkLabel::setPos(int x,int y){
56 QFontMetrics fm(font());
57 setGeometry(x,y,fm.width(text()),fm.height());
60 void LinkLabel::setText(const QString& text){
61 QLabel::setText(text);
62 setPos(geometry().x(), geometry().y());