flashing buttons use system highlight color and changed a few names

This commit is contained in:
Mathias Panzenböck
2014-02-18 00:02:28 +01:00
parent 0b08d3e6b3
commit 22da0125f7
2 changed files with 16 additions and 35 deletions

View File

@ -5,22 +5,17 @@
//This caused an error with a development version of g++ on a Mandrake system //This caused an error with a development version of g++ on a Mandrake system
//in Sweden. //in Sweden.
FlashButton::FlashButton( QString text, QString name, QWidget* parent ) FlashButton::FlashButton( QString text, QString name, QWidget* parent )
:QPushButton( text, parent ) : QPushButton( text, parent )
{ {
this->setObjectName(name); this->setObjectName(name);
//record the base palette for posterity. //record the base palette for posterity.
Normal = palette(); flashPalette = normalPalette = palette();
//define the palette the button will have when it flashes. //define the palette the button will have when it flashes.
QPalette cg = this->palette(); flashPalette.setCurrentColorGroup(QPalette::Inactive);
cg.setCurrentColorGroup(QPalette::Inactive); flashPalette.setColor(QPalette::Button, flashPalette.color(QPalette::Highlight));
cg.setColor(QPalette::Button, HIGHLIGHT); flashPalette.setColor(QPalette::ButtonText, flashPalette.color(QPalette::HighlightedText));
cg.setColor(QPalette::Light, HIGHLIGHT.light(150)); flashing = false;
cg.setColor(QPalette::Midlight, HIGHLIGHT.light(125));
cg.setColor(QPalette::Dark, HIGHLIGHT.dark(200));
cg.setColor(QPalette::Mid, HIGHLIGHT.dark(150));
Flash = cg;
isflash=false;
setAutoDefault( false ); setAutoDefault( false );
setFocusPolicy(Qt::NoFocus); setFocusPolicy(Qt::NoFocus);
@ -29,22 +24,22 @@ FlashButton::FlashButton( QString text, QString name, QWidget* parent )
void FlashButton::flash() void FlashButton::flash()
{ {
emit( flashed( !isflash ) ); emit( flashed( !flashing ) );
if (isflash) if (flashing)
{ {
setPalette( Normal ); setPalette( normalPalette );
isflash = false; flashing = false;
} }
else else
{ {
setPalette( Flash ); setPalette( flashPalette );
isflash = true; flashing = true;
} }
} }
FlashRadioArray::FlashRadioArray( const QStringList &names, bool horizontal, QWidget* parent) FlashRadioArray::FlashRadioArray( const QStringList &names, bool horizontal, QWidget* parent)
:QWidget( parent ) : QWidget( parent )
{ {
if (horizontal) { if (horizontal) {
mainLayout = new QHBoxLayout( this); mainLayout = new QHBoxLayout( this);

View File

@ -1,20 +1,6 @@
#ifndef QJOYPAD_FLASH_H #ifndef QJOYPAD_FLASH_H
#define QJOYPAD_FLASH_H #define QJOYPAD_FLASH_H
//The color the buttons flash! Feel free to change this.
//The three numbers are all you need to touch, and they
//represent the red, green, and blue values of the color,
//respectively.
#define HIGHLIGHT QColor( 0,0,255 )
//--- --- --- --- End of editable code.
#include <QPushButton> #include <QPushButton>
#include <QPalette> #include <QPalette>
#include <QBoxLayout> #include <QBoxLayout>
@ -39,11 +25,11 @@ class FlashButton : public QPushButton
void flashed( bool on ); void flashed( bool on );
private: private:
//is this currently "flashed" (ie, colored blue)? //is this currently "flashed" (ie, colored blue)?
bool isflash; bool flashing;
//the normal, unflashed palette //the normal, unflashed palette
QPalette Normal; QPalette normalPalette;
//the colorful flashed palette //the colorful flashed palette
QPalette Flash; QPalette flashPalette;
}; };
//An array of flashing mutually-exclusive toggle buttons. //An array of flashing mutually-exclusive toggle buttons.