[vlmc-devel] commit: Adding a FramelessButton widget ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Thu Jul 8 16:44:07 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Thu Jul  8 15:40:18 2010 +0200| [ea4c79f38e2f91711bf7c7120445bcb029613fb8] | committer: Hugo Beauzée-Luyssen 

Adding a FramelessButton widget

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=ea4c79f38e2f91711bf7c7120445bcb029613fb8
---

 src/CMakeLists.txt                  |    4 ++-
 src/Gui/widgets/FramelessButton.cpp |   50 +++++++++++++++++++++++++++++++++++
 src/Gui/widgets/FramelessButton.h   |   38 ++++++++++++++++++++++++++
 3 files changed, 91 insertions(+), 1 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5d3915c..fed2814 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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
diff --git a/src/Gui/widgets/FramelessButton.cpp b/src/Gui/widgets/FramelessButton.cpp
new file mode 100644
index 0000000..45f499a
--- /dev/null
+++ b/src/Gui/widgets/FramelessButton.cpp
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * FrameLessButton.cpp: A frameless QPushButton
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at 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();
+}
diff --git a/src/Gui/widgets/FramelessButton.h b/src/Gui/widgets/FramelessButton.h
new file mode 100644
index 0000000..622646c
--- /dev/null
+++ b/src/Gui/widgets/FramelessButton.h
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * FrameLessButton.h: A frameless QPushButton
+ *****************************************************************************
+ * Copyright (C) 2008-2010 VideoLAN
+ *
+ * Authors: Hugo Beauzée-Luyssen <beauze.h at 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



More information about the Vlmc-devel mailing list