mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-05-20 15:02:27 +02:00
2021-06-15 Fred Gleason <fredg@paravelsystems.com>
* Refactored the 'StartButton' widget in rdairplay(1) to be more idiomatic. Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
a0023dbc1e
commit
d4cb5ce4e4
@ -21893,3 +21893,6 @@
|
||||
2021-06-14 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Made the sound panel resizeable in rdairplay(1).
|
||||
* Make the sound panel resizeable in rdpanel(1).
|
||||
2021-06-15 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Refactored the 'StartButton' widget in rdairplay(1) to be more
|
||||
idiomatic.
|
||||
|
@ -42,33 +42,36 @@ StartButton::StartButton(bool allow_pause,QWidget *parent)
|
||||
// Create Palettes
|
||||
//
|
||||
start_stop_color=
|
||||
QPalette(QColor(BUTTON_STOPPED_BACKGROUND_COLOR),palette().color(QPalette::Background));
|
||||
QPalette(QColor(BUTTON_STOPPED_BACKGROUND_COLOR),
|
||||
palette().color(QPalette::Background));
|
||||
start_play_color=
|
||||
QPalette(QColor(BUTTON_PLAY_BACKGROUND_COLOR),palette().color(QPalette::Background));
|
||||
QPalette(QColor(BUTTON_PLAY_BACKGROUND_COLOR),
|
||||
palette().color(QPalette::Background));
|
||||
start_play_color.
|
||||
setColor(QPalette::ButtonText,QColor(BUTTON_PLAY_TEXT_COLOR));
|
||||
start_pause_color=
|
||||
QPalette(QColor(BUTTON_PAUSE_BACKGROUND_COLOR),palette().color(QPalette::Background));
|
||||
QPalette(QColor(BUTTON_PAUSE_BACKGROUND_COLOR),
|
||||
palette().color(QPalette::Background));
|
||||
start_pause_color.
|
||||
setColor(QPalette::ButtonText,QColor(BUTTON_PAUSE_TEXT_COLOR));
|
||||
|
||||
start_from_color=
|
||||
QPalette(QColor(BUTTON_FROM_BACKGROUND_COLOR),palette().color(QPalette::Background));
|
||||
start_from_color=QPalette(QColor(BUTTON_FROM_BACKGROUND_COLOR),
|
||||
palette().color(QPalette::Background));
|
||||
start_from_color.
|
||||
setColor(QPalette::ButtonText,QColor(BUTTON_FROM_TEXT_COLOR));
|
||||
|
||||
start_to_color=
|
||||
QPalette(QColor(BUTTON_TO_BACKGROUND_COLOR),palette().color(QPalette::Background));
|
||||
start_to_color=QPalette(QColor(BUTTON_TO_BACKGROUND_COLOR),
|
||||
palette().color(QPalette::Background));
|
||||
start_to_color.
|
||||
setColor(QPalette::ButtonText,QColor(BUTTON_TO_TEXT_COLOR));
|
||||
|
||||
start_disabled_color=
|
||||
QPalette(QColor(BUTTON_DISABLED_BACKGROUND_COLOR),palette().color(QPalette::Background));
|
||||
start_disabled_color=QPalette(QColor(BUTTON_DISABLED_BACKGROUND_COLOR),
|
||||
palette().color(QPalette::Background));
|
||||
start_disabled_color.
|
||||
setColor(QPalette::ButtonText,QColor(BUTTON_DISABLED_TEXT_COLOR));
|
||||
|
||||
start_error_color=
|
||||
QPalette(QColor(BUTTON_ERROR_BACKGROUND_COLOR),palette().color(QPalette::Background));
|
||||
start_error_color=QPalette(QColor(BUTTON_ERROR_BACKGROUND_COLOR),
|
||||
palette().color(QPalette::Background));
|
||||
start_error_color.
|
||||
setColor(QPalette::ButtonText,QColor(BUTTON_ERROR_TEXT_COLOR));
|
||||
|
||||
@ -77,24 +80,17 @@ StartButton::StartButton(bool allow_pause,QWidget *parent)
|
||||
}
|
||||
|
||||
|
||||
void StartButton::setTime(QString str)
|
||||
{
|
||||
start_time=QTime();
|
||||
Resize(geometry().x(),geometry().y(),geometry().width(),geometry().height());
|
||||
}
|
||||
|
||||
|
||||
void StartButton::setTime(QTime time)
|
||||
void StartButton::setTime(const QTime &time)
|
||||
{
|
||||
start_time=time;
|
||||
Resize(geometry().x(),geometry().y(),geometry().width(),geometry().height());
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void StartButton::setPort(QString port)
|
||||
void StartButton::setPort(const QString &port)
|
||||
{
|
||||
start_port=port;
|
||||
Resize(geometry().x(),geometry().y(),geometry().width(),geometry().height());
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +170,7 @@ void StartButton::setMode(Mode mode,RDCart::Type cart_type)
|
||||
start_title=ERROR_MODE_TITLE;
|
||||
break;
|
||||
}
|
||||
Resize(geometry().x(),geometry().y(),geometry().width(),geometry().height());
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@ -184,27 +180,14 @@ void StartButton::setTimeMode(RDAirPlayConf::TimeMode mode)
|
||||
return;
|
||||
}
|
||||
start_time_mode=mode;
|
||||
Resize(geometry().x(),geometry().y(),geometry().width(),geometry().height());
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void StartButton::setGeometry(int x,int y,int w,int h)
|
||||
void StartButton::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
Resize(x,y,w,h);
|
||||
QPushButton::setGeometry(x,y,w,h);
|
||||
}
|
||||
|
||||
|
||||
void StartButton::setGeometry(QRect rect)
|
||||
{
|
||||
setGeometry(rect.x(),rect.y(),rect.width(),rect.height());
|
||||
}
|
||||
|
||||
|
||||
void StartButton::Resize(int x,int y,int w,int h)
|
||||
{
|
||||
w-=2;
|
||||
h-=2;
|
||||
int w=size().width()-2;
|
||||
int h=size().width()-2;
|
||||
QPixmap *pix=new QPixmap(w,h);
|
||||
QPainter *p=new QPainter();
|
||||
p->begin(pix);
|
||||
@ -235,8 +218,10 @@ void StartButton::Resize(int x,int y,int w,int h)
|
||||
p->drawText(15,70,start_port);
|
||||
}
|
||||
p->end();
|
||||
setIcon(*pix);
|
||||
setIconSize(QSize(w-2,h-2));
|
||||
delete p;
|
||||
|
||||
p=new QPainter(this);
|
||||
p->drawPixmap(1,1,w,w,*pix,0,0,pix->size().width(),pix->size().height());
|
||||
delete p;
|
||||
delete pix;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// The Start Button for RDAirPlay Rivendell
|
||||
//
|
||||
// (C) Copyright 2002-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2002-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 General Public License version 2 as
|
||||
@ -31,19 +31,16 @@ class StartButton : public RDPushButton
|
||||
enum Mode {Stop=0,Play=1,Pause=2,AddFrom=3,AddTo=4,DeleteFrom=5,
|
||||
MoveFrom=6,MoveTo=7,CopyFrom=8,CopyTo=9,Disabled=10,Error=11};
|
||||
StartButton(bool allow_pause=false,QWidget *parent=0);
|
||||
void setTime(QString);
|
||||
void setTime(QTime);
|
||||
void setPort(QString port);
|
||||
StartButton::Mode mode() const;
|
||||
void setTime(const QTime &time);
|
||||
void setPort(const QString &port);
|
||||
Mode mode() const;
|
||||
void setMode(Mode mode,RDCart::Type cart_type);
|
||||
void setTimeMode(RDAirPlayConf::TimeMode mode);
|
||||
|
||||
public slots:
|
||||
void setGeometry(int x,int y,int w,int h);
|
||||
void setGeometry(QRect rect);
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
private:
|
||||
void Resize(int x,int y,int w,int h);
|
||||
StartButton::Mode start_mode;
|
||||
QFont start_label_font;
|
||||
QFont start_counter_font;
|
||||
|
Loading…
x
Reference in New Issue
Block a user