mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-01-12 07:35:55 +01:00
2021-09-12 Fred Gleason <fredg@paravelsystems.com>
* Added an 'RDBiPushButton' widget. * Modified the behavior of the buttons in the 'Edit Cart' dialog in rdlibrary(1) to grey-out when there is no cut selected. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
@@ -67,6 +67,7 @@ dist_librd_la_SOURCES = dbversion.h\
|
||||
rdaudioinfo.cpp rdaudioinfo.h\
|
||||
rdaudiosettings.cpp rdaudiosettings.h\
|
||||
rdaudiostore.cpp rdaudiostore.h\
|
||||
rdbipushbutton.cpp rdbipushbutton.h\
|
||||
rdbusybar.cpp rdbusybar.h\
|
||||
rdbusydialog.cpp rdbusydialog.h\
|
||||
rdbutton_dialog.cpp rdbutton_dialog.h\
|
||||
@@ -301,6 +302,7 @@ nodist_librd_la_SOURCES = moc_rdadd_cart.cpp\
|
||||
moc_rdaudioimport.cpp\
|
||||
moc_rdaudioinfo.cpp\
|
||||
moc_rdaudiostore.cpp\
|
||||
moc_rdbipushbutton.cpp\
|
||||
moc_rdbusybar.cpp\
|
||||
moc_rdbusydialog.cpp\
|
||||
moc_rdbutton_dialog.cpp\
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# lib.pro
|
||||
# librd.pro
|
||||
#
|
||||
# The lib/ QMake project file for Rivendell.
|
||||
#
|
||||
@@ -44,6 +44,7 @@ SOURCES += rdapplication.cpp
|
||||
SOURCES += rdaudio_exists.cpp
|
||||
SOURCES += rdaudio_port.cpp
|
||||
SOURCES += rdaudiosettings.cpp
|
||||
SOURCES += rdbipushbutton.cpp
|
||||
SOURCES += rdbusybar.cpp
|
||||
SOURCES += rdbusydialog.cpp
|
||||
SOURCES += rdbutton_dialog.cpp
|
||||
@@ -228,6 +229,7 @@ HEADERS += rdapplication.h
|
||||
HEADERS += rdaudio_exists.h
|
||||
HEADERS += rdaudio_port.h
|
||||
HEADERS += rdaudiosettings.h
|
||||
HEADERS += rdbipushbutton.h
|
||||
HEADERS += rdbusybar.h
|
||||
HEADERS += rdbusydialog.h
|
||||
HEADERS += rdbutton_dialog.h
|
||||
|
||||
98
lib/rdbipushbutton.cpp
Normal file
98
lib/rdbipushbutton.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
// rdbipushbutton.cpp
|
||||
//
|
||||
// QPushButton with a two-part legend
|
||||
//
|
||||
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
// version 2 as published by the Free Software Foundation.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <QEvent>
|
||||
#include <QPainter>
|
||||
|
||||
#include "rdbipushbutton.h"
|
||||
|
||||
RDBiPushButton::RDBiPushButton(QWidget *parent,RDConfig *c)
|
||||
: QPushButton(parent), RDFontEngine(font(),c)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RDBiPushButton::RDBiPushButton(const QString &top_text,
|
||||
const QString &bottom_text,QWidget *parent,
|
||||
RDConfig *c)
|
||||
: QPushButton(parent), RDFontEngine(font(),c)
|
||||
{
|
||||
d_top_text=top_text;
|
||||
d_bottom_text=bottom_text;
|
||||
}
|
||||
|
||||
|
||||
QString RDBiPushButton::topText() const
|
||||
{
|
||||
return d_top_text;
|
||||
}
|
||||
|
||||
|
||||
void RDBiPushButton::setTopText(const QString &str)
|
||||
{
|
||||
d_top_text=str;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
QString RDBiPushButton::bottomText() const
|
||||
{
|
||||
return d_bottom_text;
|
||||
}
|
||||
|
||||
|
||||
void RDBiPushButton::setBottomText(const QString &str)
|
||||
{
|
||||
d_bottom_text=str;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void RDBiPushButton::changeEvent(QEvent *e)
|
||||
{
|
||||
if(e->type()==QEvent::EnabledChange) {
|
||||
update();
|
||||
e->accept();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RDBiPushButton::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
int w=size().width();
|
||||
int h=size().height();
|
||||
QFontMetrics *m=buttonFontMetrics();
|
||||
|
||||
QPushButton::paintEvent(e);
|
||||
|
||||
QPainter *p=new QPainter(this);
|
||||
if(isEnabled()) {
|
||||
p->setPen(palette().color(QPalette::Inactive,QPalette::ButtonText));
|
||||
}
|
||||
else {
|
||||
p->setPen(palette().color(QPalette::Disabled,QPalette::ButtonText));
|
||||
}
|
||||
p->setFont(buttonFont());
|
||||
p->drawText((w-m->width(d_top_text))/2,h/2-5,d_top_text);
|
||||
p->drawLine(10,h/2,w-10,h/2);
|
||||
p->drawText((w-m->width(d_bottom_text))/2,h/2+m->height(),d_bottom_text);
|
||||
p->end();
|
||||
delete p;
|
||||
}
|
||||
50
lib/rdbipushbutton.h
Normal file
50
lib/rdbipushbutton.h
Normal file
@@ -0,0 +1,50 @@
|
||||
// rdbipushbutton.h
|
||||
//
|
||||
// QPushButton with a two-part legend
|
||||
//
|
||||
// (C) Copyright 2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Library General Public License
|
||||
// version 2 as published by the Free Software Foundation.
|
||||
//
|
||||
// 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef RDBIPUSHBUTTON_H
|
||||
#define RDBIPUSHBUTTON_H
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
#include <rdfontengine.h>
|
||||
|
||||
class RDBiPushButton : public QPushButton, public RDFontEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RDBiPushButton(QWidget *parent,RDConfig *c=NULL);
|
||||
RDBiPushButton(const QString &top_text,const QString &bottom_text,
|
||||
QWidget *parent,RDConfig *c=NULL);
|
||||
QString topText() const;
|
||||
void setTopText(const QString &str);
|
||||
QString bottomText() const;
|
||||
void setBottomText(const QString &str);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
private:
|
||||
QString d_top_text;
|
||||
QString d_bottom_text;
|
||||
};
|
||||
|
||||
|
||||
#endif // RDBIPUSHBUTTON_H
|
||||
Reference in New Issue
Block a user