globals--, fmt string fix, foreeach++, better names++, close fds, tray icon activates/closes

This commit is contained in:
Mathias Panzenböck
2014-02-16 04:37:11 +01:00
parent f2a566cc06
commit cfa17f8947
24 changed files with 208 additions and 206 deletions

View File

@ -4,7 +4,7 @@
//Modified here (and in .h) to not have default arguments for 2 and 3.
//This caused an error with a development version of g++ on a Mandrake system
//in Sweden.
FlashButton::FlashButton( QString text, QWidget* parent, QString name )
FlashButton::FlashButton( QString text, QString name, QWidget* parent )
:QPushButton( text, parent )
{
this->setObjectName(name);
@ -47,41 +47,38 @@ FlashRadioArray::FlashRadioArray( const QStringList &names, bool horizontal, QWi
:QWidget( parent )
{
if (horizontal) {
LMain = new QHBoxLayout( this);
LMain->setMargin(5);
LMain->setSpacing(5);
mainLayout = new QHBoxLayout( this);
mainLayout->setMargin(5);
mainLayout->setSpacing(5);
} else {
LMain = new QVBoxLayout( this);
LMain->setMargin(5);
LMain->setSpacing(5);
mainLayout = new QVBoxLayout( this);
mainLayout->setMargin(5);
mainLayout->setSpacing(5);
}
// TODO: fix memleak
int count = names.size();
int i = 0;
Buttons = new FlashButton*[count];
foreach (const QString &name, names) {
Buttons[i] = new FlashButton( name, this, "" );
FlashButton *button = new FlashButton( name, QString::null, this );
buttons.append(button);
//when any of the buttons is clicked, it calls the same function on this.
connect( Buttons[i], SIGNAL( clicked() ), this, SLOT( clicked() ));
LMain->addWidget(Buttons[i]);
++i;
connect( button, SIGNAL( clicked() ), this, SLOT( clicked() ));
mainLayout->addWidget(button);
}
Count = count;
State = 0;
if (count > 0) {
Buttons[0]->setDown( true );
state = 0;
if (!buttons.isEmpty()) {
buttons[0]->setDown( true );
}
}
int FlashRadioArray::getState()
{
return State;
return state;
}
void FlashRadioArray::flash( int index )
{
Buttons[index]->flash();
if (index < buttons.size()) {
buttons[index]->flash();
}
}
void FlashRadioArray::clicked()
@ -89,15 +86,16 @@ void FlashRadioArray::clicked()
//go through each button. If it wasn't the button that was just clicked,
//then make sure that it is up. If it WAS the button that was clicked,
//remember that index as the new state.
for (int i = 0; i < Count; i++)
{
if ( Buttons[i] != sender() )
Buttons[i]->setDown( false );
else
{
State = i;
Buttons[i]->setDown( true );
int i = 0;
foreach (FlashButton *button, buttons) {
if ( button != sender() ) {
button->setDown( false );
}
else {
state = i;
button->setDown( true );
}
++ i;
}
emit changed( State );
emit changed( state );
}