[vlc-commits] qt: remove obsolete custom native buttons
Pierre Lamot
git at videolan.org
Tue Dec 17 15:37:44 CET 2019
vlc | branch: master | Pierre Lamot <pierre at videolabs.io> | Fri Dec 6 15:21:08 2019 +0100| [19250fac35573985a4ce471830f9c426e0772bb3] | committer: Jean-Baptiste Kempf
qt: remove obsolete custom native buttons
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=19250fac35573985a4ce471830f9c426e0772bb3
---
modules/gui/qt/Makefile.am | 11 +-
modules/gui/qt/util/buttons/BrowseButton.cpp | 88 -------
modules/gui/qt/util/buttons/BrowseButton.hpp | 51 ----
modules/gui/qt/util/buttons/DeckButtonsLayout.cpp | 288 ----------------------
modules/gui/qt/util/buttons/DeckButtonsLayout.hpp | 60 -----
modules/gui/qt/util/buttons/RoundButton.cpp | 90 -------
modules/gui/qt/util/buttons/RoundButton.hpp | 42 ----
po/POTFILES.in | 6 -
8 files changed, 1 insertion(+), 635 deletions(-)
diff --git a/modules/gui/qt/Makefile.am b/modules/gui/qt/Makefile.am
index aaf9c17f15..8baccd60cb 100644
--- a/modules/gui/qt/Makefile.am
+++ b/modules/gui/qt/Makefile.am
@@ -188,12 +188,6 @@ libqt_plugin_la_SOURCES = \
gui/qt/util/soutchain.cpp gui/qt/util/soutchain.hpp \
gui/qt/util/qt_dirs.cpp gui/qt/util/qt_dirs.hpp \
gui/qt/util/validators.cpp gui/qt/util/validators.hpp \
- gui/qt/util/buttons/BrowseButton.cpp \
- gui/qt/util/buttons/BrowseButton.hpp \
- gui/qt/util/buttons/DeckButtonsLayout.cpp \
- gui/qt/util/buttons/DeckButtonsLayout.hpp \
- gui/qt/util/buttons/RoundButton.cpp \
- gui/qt/util/buttons/RoundButton.hpp \
gui/qt/util/qvlcframe.cpp \
gui/qt/util/qvlcframe.hpp \
gui/qt/util/qvlcapp.hpp \
@@ -309,10 +303,7 @@ nodist_libqt_plugin_la_SOURCES = \
gui/qt/util/searchlineedit.moc.cpp \
gui/qt/util/qvlcapp.moc.cpp \
gui/qt/util/vlctick.moc.cpp \
- gui/qt/util/validators.moc.cpp \
- gui/qt/util/buttons/RoundButton.moc.cpp \
- gui/qt/util/buttons/DeckButtonsLayout.moc.cpp \
- gui/qt/util/buttons/BrowseButton.moc.cpp
+ gui/qt/util/validators.moc.cpp
if HAVE_WIN32
nodist_libqt_plugin_la_SOURCES += gui/qt/main_interface_win32.moc.cpp
diff --git a/modules/gui/qt/util/buttons/BrowseButton.cpp b/modules/gui/qt/util/buttons/BrowseButton.cpp
deleted file mode 100644
index 0dda6ff9b7..0000000000
--- a/modules/gui/qt/util/buttons/BrowseButton.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*****************************************************************************
- * Copyright © 2011 VideoLAN
- *
- * Authors: Filipe Azevedo, aka PasNox
- *
- * 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 "BrowseButton.hpp"
-
-#include <QPainter>
-#include <QStyleOptionToolButton>
-
-BrowseButton::BrowseButton( QWidget* parent, BrowseButton::Type type )
- : RoundButton( parent )
-{
- setIconSize( QSize( 16, 16 ) );
- setType( type );
-}
-
-BrowseButton::Type BrowseButton::type() const
-{
- return mType;
-}
-
-void BrowseButton::setType( BrowseButton::Type type )
-{
- //FIXME
- switch ( type ) {
- case BrowseButton::Backward:
- setIcon( QIcon::fromTheme( "media-seek-backward" ) );
- break;
- case BrowseButton::Forward:
- setIcon( QIcon::fromTheme( "media-seek-forward" ) );
- break;
- }
-
- mType = type;
-}
-
-QSize BrowseButton::sizeHint() const
-{
- return QSize( 50, 26 );
-}
-
-void BrowseButton::paintEvent( QPaintEvent* event )
-{
- /*RoundButton::paintEvent( event );
- return;*/
-
- Q_UNUSED( event );
-
- const int corner = 5;
- const int margin = 5;
- QPainter painter( this );
- QStyleOptionToolButton option;
-
- initStyleOption( &option );
- painter.setRenderHint( QPainter::Antialiasing );
-
- painter.setPen( QPen( pen( &option ), 1 ) );
- painter.setBrush( brush( &option ) );
- painter.drawRoundedRect( rect().adjusted( 1, 1, -1, -1 ), corner, corner );
-
- switch ( mType ) {
- case BrowseButton::Backward:
- option.rect = option.rect.adjusted( 0, 0, -height() +margin, 0 );
- break;
- case BrowseButton::Forward:
- option.rect = option.rect.adjusted( height() -margin, 0, 0, 0 );
- break;
- }
-
- style()->drawControl( QStyle::CE_ToolButtonLabel, &option, &painter, this );
-}
-
diff --git a/modules/gui/qt/util/buttons/BrowseButton.hpp b/modules/gui/qt/util/buttons/BrowseButton.hpp
deleted file mode 100644
index 52f8dd8c3c..0000000000
--- a/modules/gui/qt/util/buttons/BrowseButton.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*****************************************************************************
- * Copyright © 2011 VideoLAN
- *
- * Authors: Filipe Azevedo, aka PasNox
- *
- * 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 BROWSEBUTTON_H
-#define BROWSEBUTTON_H
-
-#include "RoundButton.hpp"
-
-class BrowseButton : public RoundButton
-{
- Q_OBJECT
-
-public:
- enum Type {
- Backward = 0,
- Forward = 1
- };
-
- BrowseButton( QWidget* parent = 0, BrowseButton::Type type = BrowseButton::Forward );
-
- virtual QSize sizeHint() const;
-
- BrowseButton::Type type() const;
-
-public slots:
- void setType( BrowseButton::Type type );
-
-protected:
- BrowseButton::Type mType;
-
- virtual void paintEvent( QPaintEvent* event );
-};
-
-#endif // BROWSEBUTTON_H
diff --git a/modules/gui/qt/util/buttons/DeckButtonsLayout.cpp b/modules/gui/qt/util/buttons/DeckButtonsLayout.cpp
deleted file mode 100644
index a05ab9ed11..0000000000
--- a/modules/gui/qt/util/buttons/DeckButtonsLayout.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/*****************************************************************************
- * Copyright © 2011 VideoLAN
- *
- * Authors: Filipe Azevedo, aka PasNox
- *
- * 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 "DeckButtonsLayout.hpp"
-
-DeckButtonsLayout::DeckButtonsLayout( QWidget* parent )
- : QLayout( parent )
-{
- backwardItem = 0;
- goItem = 0;
- forwardItem = 0;
-
- setContentsMargins( 0, 0, 0, 0 );
- setSpacing( 0 );
-
- setBackwardButton( 0 );
- setRoundButton( 0 );
- setForwardButton( 0 );
-}
-
-DeckButtonsLayout::~DeckButtonsLayout()
-{
- delete backwardItem;
- delete goItem;
- delete forwardItem;
-}
-
-QSize DeckButtonsLayout::sizeHint() const
-{
- const int bbw = backwardButton ? backwardButton->sizeHint().width() : 0;
- const int fbw = forwardButton ? forwardButton->sizeHint().width() : 0;
- const int gbw = bbw +fbw == 0 ? ( RoundButton ? RoundButton->sizeHint().width() : 0 ) : bbw +fbw;
- int left; int top; int right; int bottom;
- QSize sh = QSize( gbw, 0 );
-
- getContentsMargins( &left, &top, &right, &bottom );
-
- sh.setHeight( qMax( sh.height(), backwardButton ? backwardButton->sizeHint().height() : 0 ) );
- sh.setHeight( qMax( sh.height(), RoundButton ? RoundButton->sizeHint().height() : 0 ) );
- sh.setHeight( qMax( sh.height(), forwardButton ? forwardButton->sizeHint().height() : 0 ) );
-
- sh.rwidth() += left +right;
- sh.rheight() += top +bottom;
-
- return sh;
-}
-
-int DeckButtonsLayout::count() const
-{
- return 3;
-}
-
-void DeckButtonsLayout::setGeometry( const QRect& _r )
-{
- QLayout::setGeometry( _r );
-
- int left; int top; int right; int bottom;
- getContentsMargins( &left, &top, &right, &bottom );
-
- const QRect r = _r.adjusted( left, top, right, bottom );
- const QAbstractButton* button = backwardButton ? backwardButton : forwardButton;
- qreal factor = 1;
-
- if ( !button ) {
- if ( RoundButton ) {
- const int min = qMin( r.height(), r.width() );
- QRect rect = QRect( QPoint(), QSize( min, min ) );
-
- rect.moveCenter( r.center() );
- RoundButton->setGeometry( rect );
- }
-
- return;
- }
- else if ( backwardButton && forwardButton ) {
- factor = (qreal)r.width() /(qreal)( button->sizeHint().width() *2 );
- }
- else if ( RoundButton ) {
- factor = (qreal)r.width() /(qreal)( button->sizeHint().width() +( RoundButton->sizeHint().width() /2 ) );
- }
- else {
- factor = (qreal)r.width() /(qreal)( button->sizeHint().width() );
- }
-
- if ( RoundButton ) {
- int height = (qreal)RoundButton->sizeHint().height() *factor;
-
- while ( height > r.height() ) {
- factor -= 0.1;
- height = (qreal)RoundButton->sizeHint().height() *factor;
- }
-
- QRect rect( QPoint(), QSize( height, height ) );
- rect.moveCenter( r.center() );
-
- if ( backwardButton && forwardButton ) {
- // nothing to do
- }
- else if ( backwardButton ) {
- rect.moveRight( r.right() );
- }
- else if ( forwardButton ) {
- rect.moveLeft( r.left() );
- }
-
- RoundButton->setGeometry( rect );
- }
- else {
- int height = (qreal)button->sizeHint().height() *factor;
-
- while ( height > r.height() ) {
- factor -= 0.1;
- height = (qreal)button->sizeHint().height() *factor;
- }
- }
-
- const QSize bs = QSize( (qreal)button->sizeHint().width() *factor, (qreal)button->sizeHint().height() *factor );
-
- if ( backwardButton ) {
- QRect gr = RoundButton ? QRect( QPoint(), RoundButton->size() ) : r;
- QRect rect = QRect( QPoint(), bs );
-
- if ( RoundButton ) {
- gr.moveTopLeft( RoundButton->pos() );
- }
-
- rect.moveCenter( gr.center() );
- rect.moveRight( gr.center().x() +1 );
-
- backwardButton->setGeometry( rect );
- }
-
- if ( forwardButton ) {
- QRect gr = RoundButton ? QRect( QPoint(), RoundButton->size() ) : r;
- QRect rect = QRect( QPoint(), bs );
-
- if ( RoundButton ) {
- gr.moveTopLeft( RoundButton->pos() );
- }
-
- rect.moveCenter( gr.center() );
- rect.moveLeft( gr.center().x() );
-
- forwardButton->setGeometry( rect );
- }
-
- if ( RoundButton ) {
- RoundButton->raise();
- }
-}
-
-void DeckButtonsLayout::addItem( QLayoutItem* item )
-{
- Q_UNUSED( item );
-}
-
-QLayoutItem* DeckButtonsLayout::itemAt( int index ) const
-{
- switch ( index ) {
- case 0:
- return backwardItem;
- case 1:
- return goItem;
- case 2:
- return forwardItem;
- }
-
- return 0;
-}
-
-QLayoutItem* DeckButtonsLayout::takeAt( int index )
-{
- QLayoutItem* item = itemAt( index );
-
- switch ( index ) {
- case 0: {
- backwardItem = 0;
-
- if ( backwardButton ) {
- backwardButton->setParent( 0 );
- }
-
- backwardButton = 0;
- break;
- }
- case 1: {
- goItem = 0;
-
- if ( RoundButton ) {
- RoundButton->setParent( 0 );
- }
-
- RoundButton = 0;
- break;
- }
- case 2: {
- forwardItem = 0;
-
- if ( forwardButton ) {
- forwardButton->setParent( 0 );
- }
-
- forwardButton = 0;
- break;
- }
- }
-
- update();
-
- return item;
-}
-
-void DeckButtonsLayout::setBackwardButton( QAbstractButton* button )
-{
- if ( backwardButton && button == backwardButton ) {
- return;
- }
-
- if ( backwardItem ) {
- delete takeAt( 0 );
- }
-
- if ( button ) {
- addChildWidget( button );
- }
-
- backwardItem = new QWidgetItem( button );
- backwardButton = button;
-
- update();
-}
-
-void DeckButtonsLayout::setRoundButton( QAbstractButton* button )
-{
- if ( RoundButton && button == RoundButton ) {
- return;
- }
-
- if ( goItem ) {
- delete takeAt( 1 );
- }
-
- if ( button ) {
- addChildWidget( button );
- }
-
- goItem = new QWidgetItem( button );
- RoundButton = button;
-
- update();
-}
-
-void DeckButtonsLayout::setForwardButton( QAbstractButton* button )
-{
- if ( forwardButton && button == forwardButton ) {
- return;
- }
-
- if ( forwardItem ) {
- delete takeAt( 2 );
- }
-
- if ( button ) {
- addChildWidget( button );
- }
-
- forwardItem = new QWidgetItem( button );
- forwardButton = button;
-
- update();
-}
diff --git a/modules/gui/qt/util/buttons/DeckButtonsLayout.hpp b/modules/gui/qt/util/buttons/DeckButtonsLayout.hpp
deleted file mode 100644
index 962a78ed1f..0000000000
--- a/modules/gui/qt/util/buttons/DeckButtonsLayout.hpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*****************************************************************************
- * Copyright © 2011 VideoLAN
- *
- * Authors: Filipe Azevedo, aka PasNox
- *
- * 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 DECKBUTTONLAYOUT_H
-#define DECKBUTTONLAYOUT_H
-
-#include <QLayout>
-#include <QPointer>
-#include <QAbstractButton>
-
-class QWidget;
-class QAbstractButton;
-
-class DeckButtonsLayout : public QLayout
-{
- Q_OBJECT
-
-public:
- DeckButtonsLayout( QWidget* parent = 0 );
- virtual ~DeckButtonsLayout();
-
- virtual QSize sizeHint() const;
- virtual int count() const;
-
- void setBackwardButton( QAbstractButton* button );
- void setRoundButton( QAbstractButton* button );
- void setForwardButton( QAbstractButton* button );
-
-protected:
- QWidgetItem* backwardItem;
- QWidgetItem* goItem;
- QWidgetItem* forwardItem;
- QPointer<QAbstractButton> backwardButton;
- QPointer<QAbstractButton> RoundButton;
- QPointer<QAbstractButton> forwardButton;
-
- virtual void setGeometry( const QRect& r );
- virtual void addItem( QLayoutItem* item );
- virtual QLayoutItem* itemAt( int index ) const;
- virtual QLayoutItem* takeAt( int index );
-};
-
-#endif // DECKBUTTONLAYOUT_H
diff --git a/modules/gui/qt/util/buttons/RoundButton.cpp b/modules/gui/qt/util/buttons/RoundButton.cpp
deleted file mode 100644
index 1c4239c1fa..0000000000
--- a/modules/gui/qt/util/buttons/RoundButton.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************************
- * Copyright © 2011 VideoLAN
- *
- * Authors: Filipe Azevedo, aka PasNox
- *
- * 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 "RoundButton.hpp"
-
-#include <QPainter>
-#include <QStyleOptionToolButton>
-
-RoundButton::RoundButton( QWidget* parent )
- : QToolButton( parent )
-{
- setIconSize( QSize( 24, 24 ) );
- setIcon( QIcon::fromTheme( "media-playback-start" ) );
-}
-
-QSize RoundButton::sizeHint() const
-{
- return QSize( 38, 38 );
-}
-
-QBrush RoundButton::pen( QStyleOptionToolButton* option ) const
-{
- const bool over = option->state & QStyle::State_MouseOver;
- return QBrush( over ? QColor( 61, 165, 225 ) : QColor( 109, 106, 102 ) );
-}
-
-QBrush RoundButton::brush( QStyleOptionToolButton* option ) const
-{
- const bool over = option->state & QStyle::State_MouseOver;
- const bool pressed = option->state & QStyle::State_Sunken;
- QColor g1 = QColor( 219, 217, 215 );
- QColor g2 = QColor( 205, 202, 199 );
- QColor g3 = QColor( 187, 183, 180 );
-
- if ( pressed ) {
- g1 = g1.darker( 120 );
- g2 = g2.darker( 120 );
- g3 = g3.darker( 120 );
- }
- else if ( over ) {
- g1 = g1.lighter( 110 );
- g2 = g2.lighter( 110 );
- g3 = g3.lighter( 110 );
- }
-
- QLinearGradient gradient( 0, 0, 0, height() );
- gradient.setColorAt( 0.0, g1 );
- gradient.setColorAt( 0.40, g2 );
- gradient.setColorAt( 1.0, g3 );
-
- return QBrush( gradient );
-}
-
-void RoundButton::paintEvent( QPaintEvent* event )
-{
- /*QToolButton::paintEvent( event );
- return;*/
-
- Q_UNUSED( event );
-
- QPainter painter( this );
- QStyleOptionToolButton option;
-
- initStyleOption( &option );
- painter.setRenderHint( QPainter::Antialiasing );
-
- painter.setPen( QPen( pen( &option ), 1.5 ) );
- painter.setBrush( brush( &option ) );
- painter.drawEllipse( rect().adjusted( 1, 1, -1, -1 ) );
-
- style()->drawControl( QStyle::CE_ToolButtonLabel, &option, &painter, this );
-}
-
diff --git a/modules/gui/qt/util/buttons/RoundButton.hpp b/modules/gui/qt/util/buttons/RoundButton.hpp
deleted file mode 100644
index 7a1b3e923d..0000000000
--- a/modules/gui/qt/util/buttons/RoundButton.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*****************************************************************************
- * Copyright © 2011 VideoLAN
- *
- * Authors: Filipe Azevedo, aka PasNox
- *
- * 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 ROUNDBUTTON_H
-#define ROUNDBUTTON_H
-
-#include <QToolButton>
-
-class RoundButton : public QToolButton
-{
- Q_OBJECT
-
-public:
- RoundButton( QWidget* parent = 0 );
-
- virtual QSize sizeHint() const;
-
-protected:
- QBrush pen( QStyleOptionToolButton* option ) const;
- QBrush brush( QStyleOptionToolButton* option ) const;
-
- virtual void paintEvent( QPaintEvent* event );
-};
-
-#endif // ROUNDBUTTON_H
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7b51cf3166..ebe17f7c5b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -763,12 +763,6 @@ modules/gui/qt/recents.cpp
modules/gui/qt/recents.hpp
modules/gui/qt/util/animators.cpp
modules/gui/qt/util/animators.hpp
-modules/gui/qt/util/buttons/BrowseButton.cpp
-modules/gui/qt/util/buttons/BrowseButton.hpp
-modules/gui/qt/util/buttons/DeckButtonsLayout.cpp
-modules/gui/qt/util/buttons/DeckButtonsLayout.hpp
-modules/gui/qt/util/buttons/RoundButton.cpp
-modules/gui/qt/util/buttons/RoundButton.hpp
modules/gui/qt/util/customwidgets.cpp
modules/gui/qt/util/customwidgets.hpp
modules/gui/qt/util/imagehelper.cpp
More information about the vlc-commits
mailing list