Add a ON/OFF style checkbox for linux builds when NOT run under KDE.
This commit is contained in:
committed by
craig.p.drummond
parent
85a53da377
commit
f969fb4345
@@ -135,6 +135,7 @@ SET( CANTATA_SRCS
|
||||
widgets/coverwidget.cpp
|
||||
widgets/icon.cpp
|
||||
widgets/volumecontrol.cpp
|
||||
widgets/onoffbutton.cpp
|
||||
lyrics/lyricspage.cpp
|
||||
lyrics/lyricsettings.cpp
|
||||
lyrics/ultimatelyricsprovider.cpp
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
icons, and use alternatives.
|
||||
13. Use a random icon that matches the repeat icon better.
|
||||
14. Draw the consume icon in code, so that it matches random and repeat better.
|
||||
15. Add a ON/OFF style checkbox for linux builds when NOT run under KDE.
|
||||
|
||||
0.8.3.1
|
||||
-------
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="overwrite">
|
||||
<widget class="OnOffButton" name="overwrite">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -325,6 +325,11 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CapacityBar</class>
|
||||
<extends>QProgressBar</extends>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="fixVariousArtists"/>
|
||||
<widget class="OnOffButton" name="fixVariousArtists"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="BuddyLabel" name="autoScanLabel">
|
||||
@@ -73,7 +73,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="autoScan"/>
|
||||
<widget class="OnOffButton" name="autoScan"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="BuddyLabel" name="useCacheLabel">
|
||||
@@ -86,7 +86,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="useCache"/>
|
||||
<widget class="OnOffButton" name="useCache"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -110,7 +110,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="asciiOnly">
|
||||
<widget class="OnOffButton" name="asciiOnly">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -127,7 +127,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="replaceSpaces">
|
||||
<widget class="OnOffButton" name="replaceSpaces">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -144,7 +144,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="ignoreThe">
|
||||
<widget class="OnOffButton" name="ignoreThe">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -188,7 +188,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="vfatSafe">
|
||||
<widget class="OnOffButton" name="vfatSafe">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -229,7 +229,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="transcoderWhenDifferent"/>
|
||||
<widget class="OnOffButton" name="transcoderWhenDifferent"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -255,6 +255,11 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="ignoreThe">
|
||||
<widget class="OnOffButton" name="ignoreThe">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -83,7 +83,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="replaceSpaces">
|
||||
<widget class="OnOffButton" name="replaceSpaces">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -100,7 +100,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="asciiOnly">
|
||||
<widget class="OnOffButton" name="asciiOnly">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -117,7 +117,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="vfatSafe">
|
||||
<widget class="OnOffButton" name="vfatSafe">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -170,6 +170,11 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
|
||||
@@ -152,7 +152,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="exactCheck"/>
|
||||
<widget class="OnOffButton" name="exactCheck"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="BuddyLabel" name="label_9">
|
||||
@@ -214,6 +214,11 @@
|
||||
<zorder>typeCombo</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "externalsettings.h"
|
||||
#include "settings.h"
|
||||
#include <QtGui/QCheckBox>
|
||||
#include "onoffbutton.h"
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
ExternalSettings::ExternalSettings(QWidget *p)
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="systemTrayCheckBox">
|
||||
<widget class="OnOffButton" name="systemTrayCheckBox">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@@ -51,7 +51,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="systemTrayPopup">
|
||||
<widget class="OnOffButton" name="systemTrayPopup">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -68,7 +68,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="mpris">
|
||||
<widget class="OnOffButton" name="mpris">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -85,7 +85,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="dockManager">
|
||||
<widget class="OnOffButton" name="dockManager">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -94,6 +94,11 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BuddyLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="enableHttp">
|
||||
<widget class="OnOffButton" name="enableHttp">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -44,7 +44,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="alwaysUseHttp">
|
||||
<widget class="OnOffButton" name="alwaysUseHttp">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -128,6 +128,11 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>LineEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "localize.h"
|
||||
#include "musiclibraryitemalbum.h"
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QCheckBox>
|
||||
#include "onoffbutton.h"
|
||||
|
||||
static void addImageSizes(QComboBox *box)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="libraryArtistImage">
|
||||
<widget class="OnOffButton" name="libraryArtistImage">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -86,7 +86,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="libraryYear">
|
||||
<widget class="OnOffButton" name="libraryYear">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -224,7 +224,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="playListsStartClosed">
|
||||
<widget class="OnOffButton" name="playListsStartClosed">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -290,7 +290,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="lyricsBgnd">
|
||||
<widget class="OnOffButton" name="lyricsBgnd">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -314,7 +314,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="playQueueScroll"/>
|
||||
<widget class="OnOffButton" name="playQueueScroll"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="BuddyLabel" name="playQueueGroupedLabel">
|
||||
@@ -351,7 +351,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="playQueueAutoExpand">
|
||||
<widget class="OnOffButton" name="playQueueAutoExpand">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -368,7 +368,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="playQueueStartClosed">
|
||||
<widget class="OnOffButton" name="playQueueStartClosed">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -394,7 +394,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="groupSingle">
|
||||
<widget class="OnOffButton" name="groupSingle">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -424,7 +424,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="showDeleteAction">
|
||||
<widget class="OnOffButton" name="showDeleteAction">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -441,7 +441,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="storeCoversInMpdDir"/>
|
||||
<widget class="OnOffButton" name="storeCoversInMpdDir"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="BuddyLabel" name="label_4">
|
||||
@@ -454,7 +454,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="storeLyricsInMpdDir">
|
||||
<widget class="OnOffButton" name="storeLyricsInMpdDir">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -471,7 +471,7 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="forceSingleClick">
|
||||
<widget class="OnOffButton" name="forceSingleClick">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -521,6 +521,11 @@ When the image is displayed, it will be cropped (either top/bottom, or left/righ
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BuddyLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="stopOnExit"/>
|
||||
<widget class="OnOffButton" name="stopOnExit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="BuddyLabel" name="stopDynamizerOnExitLabel">
|
||||
@@ -54,7 +54,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="stopDynamizerOnExit">
|
||||
<widget class="OnOffButton" name="stopDynamizerOnExit">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@@ -68,6 +68,11 @@
|
||||
<extends>QLabel</extends>
|
||||
<header>buddylabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>OnOffButton</class>
|
||||
<extends>QCheckBox</extends>
|
||||
<header>onoffbutton.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>stopFadeDuration</tabstop>
|
||||
|
||||
137
widgets/onoffbutton.cpp
Normal file
137
widgets/onoffbutton.cpp
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Cantata
|
||||
*
|
||||
* Copyright (c) 2011-2012 Craig Drummond <craig.p.drummond@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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
|
||||
#include "onoffbutton.h"
|
||||
#include "localize.h"
|
||||
#include <QtGui/QFontMetrics>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPainterPath>
|
||||
#include <QtGui/QLinearGradient>
|
||||
|
||||
static QString onText;
|
||||
static QString offText;
|
||||
static QSize fixedSize;
|
||||
static const int constBorderSize=4;
|
||||
static bool useCheckBox=!qgetenv("KDE_FULL_SESSION").isEmpty();
|
||||
|
||||
OnOffButton::OnOffButton(QWidget *p)
|
||||
: QCheckBox(p)
|
||||
{
|
||||
if (!useCheckBox) {
|
||||
QFont f(font());
|
||||
f.setPointSize(f.pointSize()*0.9);
|
||||
setFont(f);
|
||||
if (onText.isEmpty()) {
|
||||
onText=i18n("ON");
|
||||
offText=i18n("OFF");
|
||||
QFontMetrics fm(f);
|
||||
int onWidth=fm.width(onText);
|
||||
int offWidth=fm.width(offText);
|
||||
int fontHeight=fm.height();
|
||||
fixedSize=QSize((qMax(onWidth, offWidth)+(constBorderSize*2))*2, fontHeight+(2*constBorderSize));
|
||||
}
|
||||
setCheckable(true);
|
||||
setFixedSize(fixedSize);
|
||||
}
|
||||
}
|
||||
|
||||
QSize OnOffButton::sizeHint() const
|
||||
{
|
||||
return useCheckBox ? QCheckBox::sizeHint() : fixedSize;
|
||||
}
|
||||
|
||||
bool OnOffButton::hitButton(const QPoint &pos) const
|
||||
{
|
||||
return useCheckBox ? QCheckBox::hitButton(pos) : true;
|
||||
}
|
||||
|
||||
static QPainterPath buildPath(const QRectF &r, double radius)
|
||||
{
|
||||
QPainterPath path;
|
||||
double diameter(radius*2);
|
||||
|
||||
path.moveTo(r.x()+r.width(), r.y()+r.height()-radius);
|
||||
path.arcTo(r.x()+r.width()-diameter, r.y(), diameter, diameter, 0, 90);
|
||||
path.arcTo(r.x(), r.y(), diameter, diameter, 90, 90);
|
||||
path.arcTo(r.x(), r.y()+r.height()-diameter, diameter, diameter, 180, 90);
|
||||
path.arcTo(r.x()+r.width()-diameter, r.y()+r.height()-diameter, diameter, diameter, 270, 90);
|
||||
return path;
|
||||
}
|
||||
|
||||
void OnOffButton::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
if (useCheckBox) {
|
||||
QCheckBox::paintEvent(e);
|
||||
return;
|
||||
}
|
||||
|
||||
QPainter p(this);
|
||||
const QPalette &pal=palette();
|
||||
bool isOn=isChecked();
|
||||
bool isActive=isEnabled() && QPalette::Active==pal.currentColorGroup();
|
||||
QRect borderRect=rect().adjusted(1, 1, -2, -2);
|
||||
QRect borderInnder=borderRect.adjusted(1, 1, -1, -1);
|
||||
QRect onRect=QRect(borderRect.x(), borderRect.y(), borderRect.width()/2, borderRect.height());
|
||||
QRect offRect=QRect(borderRect.x()+(borderRect.width()/2)+1, borderRect.y(), borderRect.width()/2, borderRect.height());
|
||||
QPainterPath border=buildPath(borderRect, 3.0);
|
||||
QPainterPath inner=buildPath(borderInnder, 2.0);
|
||||
QPainterPath slider=buildPath(isOn ? offRect : onRect, 3.0);
|
||||
QPainterPath sliderInner=buildPath((isOn ? offRect : onRect).adjusted(1, 1, -1, -1), 2.0);
|
||||
QLinearGradient grad(borderRect.topLeft(), borderRect.bottomLeft());
|
||||
QColor bgndCol=isOn && isActive ? pal.highlight().color() : pal.mid().color();
|
||||
grad.setColorAt(0, bgndCol.lighter(110));
|
||||
grad.setColorAt(1, bgndCol.lighter(120));
|
||||
p.fillPath(border, grad);
|
||||
QColor col(bgndCol.darker(105));
|
||||
col.setAlphaF(0.2);
|
||||
p.setPen(col);
|
||||
p.drawPath(inner);
|
||||
p.setPen(pal.mid().color());
|
||||
p.drawPath(border);
|
||||
//p.setPen(pal.light().color());
|
||||
//p.drawText((isOn ? onRect : offRect).adjusted(1, 1, 1, 1), isOn ? onText : offText, QTextOption(Qt::AlignHCenter|Qt::AlignVCenter));
|
||||
QColor textcol(isOn && isActive ? pal.highlightedText().color() : pal.text().color());
|
||||
if (isActive && !isOn && textcol.red()<64 && textcol.green()<64 && textcol.blue()<64) {
|
||||
col=Qt::white;
|
||||
col.setAlphaF(0.4);
|
||||
p.setPen(col);
|
||||
p.drawText(offRect.adjusted(1, 1, 1, 1), offText, QTextOption(Qt::AlignHCenter|Qt::AlignVCenter));
|
||||
}
|
||||
p.setPen(textcol);
|
||||
p.drawText(isOn ? onRect : offRect, isOn ? onText : offText, QTextOption(Qt::AlignHCenter|Qt::AlignVCenter));
|
||||
|
||||
grad.setColorAt(0, pal.mid().color().lighter(150));
|
||||
grad.setColorAt(1, pal.mid().color().darker(90));
|
||||
p.fillPath(slider, grad);
|
||||
col=QColor(pal.mid().color().lighter(170));
|
||||
col.setAlphaF(0.2);
|
||||
p.setPen(col);
|
||||
p.drawPath(sliderInner);
|
||||
p.setPen(pal.mid().color());
|
||||
p.drawPath(slider);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
48
widgets/onoffbutton.h
Normal file
48
widgets/onoffbutton.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Cantata
|
||||
*
|
||||
* Copyright (c) 2011-2012 Craig Drummond <craig.p.drummond@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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef ONOFF_BUTTON_H
|
||||
#define ONOFF_BUTTON_H
|
||||
|
||||
#include <QtGui/QCheckBox>
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
typedef QCheckBox OnOffButton;
|
||||
#else
|
||||
class OnOffButton : public QCheckBox
|
||||
{
|
||||
public:
|
||||
OnOffButton(QWidget *p);
|
||||
virtual ~OnOffButton() {
|
||||
}
|
||||
|
||||
QSize sizeHint() const;
|
||||
bool hitButton(const QPoint &pos) const;
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user