Commit 58f10ba0 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Merging ClickableLabel and ElidableLabel into new ExtendedLabel widget.

parent 681f7848
......@@ -152,7 +152,6 @@ ELSE(NOT WITH_GUI)
Commands/KeyboardShortcutHelper.cpp
Gui/About.cpp
Gui/AudioSpectrumDrawer.cpp
Gui/ClickableLabel.cpp
Gui/ClipProperty.cpp
Gui/DockWidgetManager.cpp
Gui/IntroDialog.cpp
......@@ -202,7 +201,7 @@ ELSE(NOT WITH_GUI)
Gui/timeline/TracksRuler.cpp
Gui/timeline/TracksScene.cpp
Gui/timeline/TracksView.cpp
Gui/widgets/ElidableLabel.cpp
Gui/widgets/ExtendedLabel.cpp
Gui/widgets/FramelessButton.cpp
Gui/widgets/NotificationZone.cpp
Gui/widgets/SearchLineEdit.cpp
......@@ -219,7 +218,6 @@ ELSE(NOT WITH_GUI)
LIST( APPEND VLMC_HDRS
Commands/KeyboardShortcutHelper.h
Gui/About.h
Gui/ClickableLabel.h
Gui/ClipProperty.h
Gui/DockWidgetManager.h
Gui/IntroDialog.h
......@@ -272,7 +270,7 @@ ELSE(NOT WITH_GUI)
Gui/timeline/TracksRuler.h
Gui/timeline/TracksScene.h
Gui/timeline/TracksView.h
Gui/widgets/ElidableLabel.h
Gui/widgets/ExtendedLabel.h
Gui/widgets/FramelessButton.h
Gui/widgets/NotificationZone.h
Gui/widgets/SearchLineEdit.h
......
/*****************************************************************************
* ClickableLabel.cpp
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "ClickableLabel.h"
ClickableLabel::ClickableLabel( QWidget* parent ) : QLabel( parent )
{
}
void ClickableLabel::mousePressEvent( QMouseEvent* ev )
{
emit clicked( this, ev );
}
/*****************************************************************************
* ClickableLabel.h
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Geoffroy Lacarriere <geoffroylaca@gmail.com>
* Thomas Boquet <thomas.boquet@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef CLICKABLELABEL_H
#define CLICKABLELABEL_H
#include <QLabel>
class ClickableLabel : public QLabel
{
Q_OBJECT
public:
ClickableLabel( QWidget* parent = NULL );
void mousePressEvent( QMouseEvent* ev );
signals:
void clicked( QWidget* sender, QMouseEvent* ev );
};
#endif // CLICKABLELABEL_H
......@@ -201,7 +201,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="ClickableLabel" name="delLabel">
<widget class="ExtendedLabel" name="delLabel">
<property name="text">
<string/>
</property>
......@@ -211,7 +211,7 @@
</widget>
</item>
<item>
<widget class="ClickableLabel" name="arrow">
<widget class="ExtendedLabel" name="arrow">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -241,9 +241,9 @@
</widget>
<customwidgets>
<customwidget>
<class>ClickableLabel</class>
<class>ExtendedLabel</class>
<extends>QLabel</extends>
<header>ClickableLabel.h</header>
<header>ExtendedLabel.h</header>
</customwidget>
</customwidgets>
<resources>
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>312</width>
<height>182</height>
<height>201</height>
</rect>
</property>
<property name="windowTitle">
......@@ -214,7 +214,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="ElidableLabel" name="pathValueLabel">
<widget class="ExtendedLabel" name="pathValueLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -263,9 +263,9 @@
</widget>
<customwidgets>
<customwidget>
<class>ElidableLabel</class>
<class>ExtendedLabel</class>
<extends>QLabel</extends>
<header>ElidableLabel.h</header>
<header>ExtendedLabel.h</header>
</customwidget>
</customwidgets>
<resources/>
......
/*****************************************************************************
* ElidableLabel.cpp: Provide a QLabel with elidable text in it.
* ExtendedLabel.cpp: Provide a QLabel with elidable text in it.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
......@@ -20,16 +20,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "ElidableLabel.h"
#include "ExtendedLabel.h"
#include <QResizeEvent>
ElidableLabel::ElidableLabel( QWidget *parent ) : QLabel( parent ),
ExtendedLabel::ExtendedLabel( QWidget *parent ) : QLabel( parent ),
m_elideMode( Qt::ElideMiddle )
{
}
ElidableLabel::ElidableLabel( const QString &text, QWidget *parent ) :
ExtendedLabel::ExtendedLabel( const QString &text, QWidget *parent ) :
QLabel( text, parent ),
m_elideMode( Qt::ElideMiddle ),
m_text( text )
......@@ -38,7 +38,7 @@ ElidableLabel::ElidableLabel( const QString &text, QWidget *parent ) :
}
void
ElidableLabel::resizeEvent( QResizeEvent *event )
ExtendedLabel::resizeEvent( QResizeEvent *event )
{
QFontMetrics fm( fontMetrics() );
QString str = fm.elidedText( m_text, m_elideMode, event->size().width() );
......@@ -47,37 +47,53 @@ ElidableLabel::resizeEvent( QResizeEvent *event )
}
Qt::TextElideMode
ElidableLabel::elideMode() const
ExtendedLabel::elideMode() const
{
return m_elideMode;
}
void
ElidableLabel::setElideMode( Qt::TextElideMode mode )
ExtendedLabel::setElideMode( Qt::TextElideMode mode )
{
m_elideMode = mode;
}
QSize
ElidableLabel::minimumSizeHint() const
ExtendedLabel::minimumSizeHint() const
{
if ( pixmap() != NULL )
return QLabel::sizeHint();
const QFontMetrics &fm = fontMetrics();
QSize size( fm.width("..."), fm.height() );
return size;
}
QSize
ElidableLabel::sizeHint() const
ExtendedLabel::sizeHint() const
{
if ( pixmap() != NULL )
return QLabel::sizeHint();
const QFontMetrics& fm = fontMetrics();
QSize size( fm.width( m_text ), fm.height());
return size;
}
void
ElidableLabel::setText( const QString &text )
ExtendedLabel::setText( const QString &text )
{
m_text = text;
setToolTip( text );
QLabel::setText( text );
}
void
ExtendedLabel::mousePressEvent( QMouseEvent* ev )
{
emit clicked( this, ev );
}
void
ExtendedLabel::mouseDoubleClickEvent( QMouseEvent * )
{
emit doubleClicked();
}
/*****************************************************************************
* ElidableLabel.h: Provide a QLabel with elidable text in it.
* ExtendedLabel.h: Provide a QLabel with elidable text in it.
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
......@@ -25,13 +25,13 @@
#include <QLabel>
class ElidableLabel : public QLabel
class ExtendedLabel : public QLabel
{
Q_OBJECT
public:
ElidableLabel( QWidget* parent );
ElidableLabel( const QString& text, QWidget* parent );
ExtendedLabel( QWidget* parent );
ExtendedLabel( const QString& text, QWidget* parent );
Qt::TextElideMode elideMode() const;
void setElideMode( Qt::TextElideMode mode );
virtual QSize minimumSizeHint() const;
......@@ -40,10 +40,16 @@ class ElidableLabel : public QLabel
protected:
virtual void resizeEvent( QResizeEvent *event );
virtual void mousePressEvent( QMouseEvent *ev );
virtual void mouseDoubleClickEvent( QMouseEvent *ev );
private:
Qt::TextElideMode m_elideMode;
QString m_text;
signals:
void clicked( QWidget* sender, QMouseEvent* ev );
void doubleClicked();
};
#endif // ELIDABLELABEL_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment