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

Adding a FramelessButton widget

parent 1d8566a3
......@@ -118,7 +118,6 @@ INCLUDE_DIRECTORIES(
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
#Add GUI stuff if required
IF (NOT WITH_GUI)
LIST (APPEND VLMC_SRCS Main/main.cpp Renderer/ConsoleRenderer.cpp )
LIST (APPEND VLMC_HDRS Renderer/ConsoleRenderer.h)
......@@ -132,6 +131,7 @@ IF (NOT WITH_GUI)
${LIBVLCCORE_LIBRARY}
)
#Add GUI stuff if required
ELSE(NOT WITH_GUI)
LIST( APPEND VLMC_SRCS
Commands/KeyboardShortcutHelper.cpp
......@@ -185,6 +185,7 @@ ELSE(NOT WITH_GUI)
Gui/timeline/TracksScene.cpp
Gui/timeline/TracksView.cpp
Gui/widgets/ElidableLabel.cpp
Gui/widgets/FramelessButton.cpp
Gui/widgets/TrackControls.cpp
Gui/wizard/GeneralPage.cpp
Gui/wizard/OpenPage.cpp
......@@ -245,6 +246,7 @@ ELSE(NOT WITH_GUI)
Gui/timeline/TracksView.h
Gui/UndoStack.h
Gui/widgets/ElidableLabel.h
Gui/widgets/FramelessButton.h
Gui/widgets/TrackControls.h
Gui/wizard/GeneralPage.h
Gui/wizard/OpenPage.h
......
/*****************************************************************************
* FrameLessButton.cpp: A frameless QPushButton
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@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.
*****************************************************************************/
/*
* Taken from VLC's source code.
*/
#include "FramelessButton.h"
#include <QPainter>
FramelessButton::FramelessButton( QWidget *parent )
: QPushButton( parent )
{
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
}
void
FramelessButton::paintEvent( QPaintEvent* )
{
QPainter painter( this );
QPixmap pix = icon().pixmap( size() );
QPoint pos( ( width() - pix.width() ) / 2, ( height() - pix.height() ) / 2 );
painter.drawPixmap( QRect( pos.x(), pos.y(), pix.width(), pix.height() ), pix );
}
QSize
FramelessButton::sizeHint() const
{
return iconSize();
}
/*****************************************************************************
* FrameLessButton.h: A frameless QPushButton
*****************************************************************************
* Copyright (C) 2008-2010 VideoLAN
*
* Authors: Hugo Beauzée-Luyssen <beauze.h@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 FRAMELESSBUTTON_H
#define FRAMELESSBUTTON_H
#include <QPushButton>
class FramelessButton : public QPushButton
{
Q_OBJECT
public:
FramelessButton( QWidget *parent = NULL );
QSize sizeHint() const;
protected:
virtual void paintEvent( QPaintEvent *event );
};
#endif // FRAMELESSBUTTON_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