@@ -33,6 +33,7 @@ ui_*.py | |||||
source/digitalpeakmeter.py | source/digitalpeakmeter.py | ||||
source/ledbutton.py | source/ledbutton.py | ||||
source/paramspinbox.py | source/paramspinbox.py | ||||
source/pixmapbutton.py | |||||
source/pixmapdial.py | source/pixmapdial.py | ||||
source/pixmapkeyboard.py | source/pixmapkeyboard.py | ||||
source/resources_rc.py | source/resources_rc.py | ||||
@@ -81,7 +81,7 @@ source/ui_%.py: resources/ui/%.ui | |||||
# ----------------------------------------------------------------------------------------------------------------------------------------- | # ----------------------------------------------------------------------------------------------------------------------------------------- | ||||
# Widgets | # Widgets | ||||
WIDGETS = source/digitalpeakmeter.py source/ledbutton.py source/paramspinbox.py source/pixmapdial.py source/pixmapkeyboard.py | |||||
WIDGETS = source/digitalpeakmeter.py source/ledbutton.py source/paramspinbox.py source/pixmapbutton.py source/pixmapdial.py source/pixmapkeyboard.py | |||||
WIDGETS: $(WIDGETS) | WIDGETS: $(WIDGETS) | ||||
@@ -38,8 +38,8 @@ | |||||
<file>bitmaps/carla_about.png</file> | <file>bitmaps/carla_about.png</file> | ||||
<file>bitmaps/button_close.png</file> | <file>bitmaps/button_close.png</file> | ||||
<file>bitmaps/button_close_down.png</file> | |||||
<file>bitmaps/button_close_hover.png</file> | <file>bitmaps/button_close_hover.png</file> | ||||
<file>bitmaps/button_close_pressed.png</file> | |||||
<file>bitmaps/button_down.png</file> | <file>bitmaps/button_down.png</file> | ||||
<file>bitmaps/button_down_hover.png</file> | <file>bitmaps/button_down_hover.png</file> | ||||
<file>bitmaps/button_edit.png</file> | <file>bitmaps/button_edit.png</file> | ||||
@@ -6,8 +6,8 @@ | |||||
<rect> | <rect> | ||||
<x>0</x> | <x>0</x> | ||||
<y>0</y> | <y>0</y> | ||||
<width>557</width> | |||||
<height>28</height> | |||||
<width>538</width> | |||||
<height>30</height> | |||||
</rect> | </rect> | ||||
</property> | </property> | ||||
<property name="windowTitle"> | <property name="windowTitle"> | ||||
@@ -15,7 +15,7 @@ | |||||
</property> | </property> | ||||
<layout class="QHBoxLayout" name="horizontalLayout"> | <layout class="QHBoxLayout" name="horizontalLayout"> | ||||
<property name="spacing"> | <property name="spacing"> | ||||
<number>1</number> | |||||
<number>2</number> | |||||
</property> | </property> | ||||
<property name="leftMargin"> | <property name="leftMargin"> | ||||
<number>0</number> | <number>0</number> | ||||
@@ -30,7 +30,7 @@ | |||||
<number>2</number> | <number>2</number> | ||||
</property> | </property> | ||||
<item> | <item> | ||||
<widget class="QPushButton" name="b_enable"> | |||||
<widget class="PixmapButton" name="b_enable"> | |||||
<property name="minimumSize"> | <property name="minimumSize"> | ||||
<size> | <size> | ||||
<width>24</width> | <width>24</width> | ||||
@@ -46,10 +46,6 @@ | |||||
<property name="text"> | <property name="text"> | ||||
<string/> | <string/> | ||||
</property> | </property> | ||||
<property name="icon"> | |||||
<iconset resource="../resources.qrc"> | |||||
<normaloff>:/bitmaps/led-big_on.png</normaloff>:/bitmaps/led-big_on.png</iconset> | |||||
</property> | |||||
<property name="iconSize"> | <property name="iconSize"> | ||||
<size> | <size> | ||||
<width>24</width> | <width>24</width> | ||||
@@ -65,7 +61,7 @@ | |||||
</widget> | </widget> | ||||
</item> | </item> | ||||
<item> | <item> | ||||
<widget class="QPushButton" name="b_gui"> | |||||
<widget class="PixmapButton" name="b_gui"> | |||||
<property name="minimumSize"> | <property name="minimumSize"> | ||||
<size> | <size> | ||||
<width>24</width> | <width>24</width> | ||||
@@ -83,7 +79,7 @@ | |||||
</property> | </property> | ||||
<property name="icon"> | <property name="icon"> | ||||
<iconset resource="../resources.qrc"> | <iconset resource="../resources.qrc"> | ||||
<normaloff>:/bitmaps/button_gui_down.png</normaloff>:/bitmaps/button_gui_down.png</iconset> | |||||
<normaloff>:/bitmaps/button_gui.png</normaloff>:/bitmaps/button_gui.png</iconset> | |||||
</property> | </property> | ||||
<property name="iconSize"> | <property name="iconSize"> | ||||
<size> | <size> | ||||
@@ -100,7 +96,7 @@ | |||||
</widget> | </widget> | ||||
</item> | </item> | ||||
<item> | <item> | ||||
<widget class="QPushButton" name="b_edit"> | |||||
<widget class="PixmapButton" name="b_edit"> | |||||
<property name="minimumSize"> | <property name="minimumSize"> | ||||
<size> | <size> | ||||
<width>24</width> | <width>24</width> | ||||
@@ -118,7 +114,7 @@ | |||||
</property> | </property> | ||||
<property name="icon"> | <property name="icon"> | ||||
<iconset resource="../resources.qrc"> | <iconset resource="../resources.qrc"> | ||||
<normaloff>:/bitmaps/button_edit_down.png</normaloff>:/bitmaps/button_edit_down.png</iconset> | |||||
<normaloff>:/bitmaps/button_edit.png</normaloff>:/bitmaps/button_edit.png</iconset> | |||||
</property> | </property> | ||||
<property name="iconSize"> | <property name="iconSize"> | ||||
<size> | <size> | ||||
@@ -287,7 +283,7 @@ | |||||
<number>0</number> | <number>0</number> | ||||
</property> | </property> | ||||
<item row="0" column="0"> | <item row="0" column="0"> | ||||
<widget class="QPushButton" name="b_up"> | |||||
<widget class="PixmapButton" name="b_up"> | |||||
<property name="minimumSize"> | <property name="minimumSize"> | ||||
<size> | <size> | ||||
<width>12</width> | <width>12</width> | ||||
@@ -310,7 +306,7 @@ | |||||
</widget> | </widget> | ||||
</item> | </item> | ||||
<item row="0" column="1"> | <item row="0" column="1"> | ||||
<widget class="QPushButton" name="b_close"> | |||||
<widget class="PixmapButton" name="b_close"> | |||||
<property name="minimumSize"> | <property name="minimumSize"> | ||||
<size> | <size> | ||||
<width>12</width> | <width>12</width> | ||||
@@ -328,7 +324,7 @@ | |||||
</property> | </property> | ||||
<property name="icon"> | <property name="icon"> | ||||
<iconset resource="../resources.qrc"> | <iconset resource="../resources.qrc"> | ||||
<normaloff>:/bitmaps/button_close_pressed.png</normaloff>:/bitmaps/button_close_pressed.png</iconset> | |||||
<normaloff>:/bitmaps/button_close.png</normaloff>:/bitmaps/button_close.png</iconset> | |||||
</property> | </property> | ||||
<property name="iconSize"> | <property name="iconSize"> | ||||
<size> | <size> | ||||
@@ -342,7 +338,7 @@ | |||||
</widget> | </widget> | ||||
</item> | </item> | ||||
<item row="1" column="0"> | <item row="1" column="0"> | ||||
<widget class="QPushButton" name="b_down"> | |||||
<widget class="PixmapButton" name="b_down"> | |||||
<property name="minimumSize"> | <property name="minimumSize"> | ||||
<size> | <size> | ||||
<width>12</width> | <width>12</width> | ||||
@@ -365,7 +361,7 @@ | |||||
</widget> | </widget> | ||||
</item> | </item> | ||||
<item row="1" column="1"> | <item row="1" column="1"> | ||||
<widget class="QPushButton" name="b_restore"> | |||||
<widget class="PixmapButton" name="b_restore"> | |||||
<property name="minimumSize"> | <property name="minimumSize"> | ||||
<size> | <size> | ||||
<width>12</width> | <width>12</width> | ||||
@@ -403,6 +399,11 @@ | |||||
<extends>QPushButton</extends> | <extends>QPushButton</extends> | ||||
<header>ledbutton.h</header> | <header>ledbutton.h</header> | ||||
</customwidget> | </customwidget> | ||||
<customwidget> | |||||
<class>PixmapButton</class> | |||||
<extends>QPushButton</extends> | |||||
<header>pixmapbutton.h</header> | |||||
</customwidget> | |||||
</customwidgets> | </customwidgets> | ||||
<resources> | <resources> | ||||
<include location="../resources.qrc"/> | <include location="../resources.qrc"/> | ||||
@@ -2154,8 +2154,19 @@ class PluginWidget(QFrame): | |||||
#else: | #else: | ||||
#self.setWidgetColor(PALETTE_COLOR_NONE) | #self.setWidgetColor(PALETTE_COLOR_NONE) | ||||
#self.ui.led_enable.setColor(self.ui.led_enable.BIG_RED) | |||||
#self.ui.led_enable.setChecked(False) | |||||
self.ui.b_enable.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png") | |||||
self.ui.b_gui.setPixmaps(":/bitmaps/button_gui.png", ":/bitmaps/button_gui_down.png", ":/bitmaps/button_gui_hover.png") | |||||
self.ui.b_edit.setPixmaps(":/bitmaps/button_edit.png", ":/bitmaps/button_edit_down.png", ":/bitmaps/button_edit_hover.png") | |||||
self.ui.b_up.setPixmaps(":/bitmaps/button_up.png", ":/bitmaps/button_up.png", ":/bitmaps/button_up_hover.png") | |||||
self.ui.b_down.setPixmaps(":/bitmaps/button_down.png", ":/bitmaps/button_down.png", ":/bitmaps/button_down_hover.png") | |||||
self.ui.b_restore.setPixmaps(":/bitmaps/button_restore.png", ":/bitmaps/button_restore.png", ":/bitmaps/button_restore_hover.png") | |||||
self.ui.b_close.setPixmaps(":/bitmaps/button_close.png", ":/bitmaps/button_close_down.png", ":/bitmaps/button_close_hover.png") | |||||
# TODO | |||||
self.ui.b_up.setEnabled(False) | |||||
self.ui.b_down.setEnabled(False) | |||||
self.ui.b_restore.setEnabled(False) | |||||
self.ui.led_control.setColor(self.ui.led_control.YELLOW) | self.ui.led_control.setColor(self.ui.led_control.YELLOW) | ||||
self.ui.led_control.setEnabled(False) | self.ui.led_control.setEnabled(False) | ||||
@@ -1,7 +1,7 @@ | |||||
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||
# Pixmap Button, a custom Qt4 widget | |||||
# LED Button, a custom Qt4 widget | |||||
# Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com> | # Copyright (C) 2011-2013 Filipe Coelho <falktx@falktx.com> | ||||
# | # | ||||
# This program is free software; you can redistribute it and/or | # This program is free software; you can redistribute it and/or | ||||
@@ -0,0 +1,82 @@ | |||||
#!/usr/bin/env python3 | |||||
# -*- coding: utf-8 -*- | |||||
# Pixmap Button, a custom Qt4 widget | |||||
# Copyright (C) 2013 Filipe Coelho <falktx@falktx.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 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. | |||||
# | |||||
# For a full copy of the GNU General Public License see the GPL.txt file | |||||
# ------------------------------------------------------------------------------------------------------------ | |||||
# Imports (Global) | |||||
from PyQt4.QtCore import QRectF | |||||
from PyQt4.QtGui import QPainter, QPixmap, QPushButton | |||||
# ------------------------------------------------------------------------------------------------------------ | |||||
# Widget Class | |||||
class PixmapButton(QPushButton): | |||||
STATE_NULL = 0 | |||||
STATE_NORMAL = 1 | |||||
STATE_DOWN = 2 | |||||
STATE_HOVER = 3 | |||||
def __init__(self, parent): | |||||
QPushButton.__init__(self, parent) | |||||
self.fPixmapNormal = QPixmap() | |||||
self.fPixmapDown = QPixmap() | |||||
self.fPixmapHover = QPixmap() | |||||
self.fPixmapRect = QRectF(0, 0, 0, 0) | |||||
self.fIsHovered = False | |||||
self.setText("") | |||||
def setPixmaps(self, normal, down, hover): | |||||
self.fPixmapNormal.load(normal) | |||||
self.fPixmapDown.load(down) | |||||
self.fPixmapHover.load(hover) | |||||
self.setPixmapSize(self.fPixmapNormal.width()) | |||||
def setPixmapSize(self, size): | |||||
self.fPixmapRect = QRectF(0, 0, size, size) | |||||
self.setMinimumWidth(size) | |||||
self.setMaximumWidth(size) | |||||
self.setMinimumHeight(size) | |||||
self.setMaximumHeight(size) | |||||
def enterEvent(self, event): | |||||
self.fIsHovered = True | |||||
QPushButton.enterEvent(self, event) | |||||
def leaveEvent(self, event): | |||||
self.fIsHovered = False | |||||
QPushButton.leaveEvent(self, event) | |||||
def paintEvent(self, event): | |||||
painter = QPainter(self) | |||||
if not self.isEnabled(): | |||||
painter.setOpacity(0.2) | |||||
painter.drawPixmap(self.fPixmapRect, self.fPixmapNormal, self.fPixmapRect) | |||||
elif self.isChecked() or self.isDown(): | |||||
painter.drawPixmap(self.fPixmapRect, self.fPixmapDown, self.fPixmapRect) | |||||
elif self.fIsHovered: | |||||
painter.drawPixmap(self.fPixmapRect, self.fPixmapHover, self.fPixmapRect) | |||||
else: | |||||
painter.drawPixmap(self.fPixmapRect, self.fPixmapNormal, self.fPixmapRect) | |||||
event.accept() |