Exemple #1
0
void RDButtonDialog::setColorData()
{
  QColor new_color=QColorDialog::getColor(edit_color,this,"edit_color_dialog");
  if(new_color.isValid()) {
    edit_color=new_color;
    QPalette p=QPalette(edit_color,backgroundColor());
    p.setColor(QColorGroup::ButtonText,RDGetTextColor(edit_color));
    edit_color_button->setPalette(p);
  }
}
Exemple #2
0
int RDButtonDialog::exec(RDPanelButton *button,bool hookmode,
			 const QString &username,const QString &passwd)
{
  edit_button=button;
  edit_hookmode=hookmode;
  edit_user_name=username;
  edit_user_password=passwd;
  edit_cart=edit_button->cart();
  edit_color=edit_button->defaultColor();
  QPalette p=QPalette(edit_color,backgroundColor());
  p.setColor(QColorGroup::ButtonText,RDGetTextColor(edit_color));
  edit_color_button->setPalette(p);
  edit_label_edit->setText(edit_button->text());
  DisplayCart(edit_cart);
  return QDialog::exec();
}
void RDPanelButton::WriteKeycap(int secs)
{
    QString text=button_text;
    QPixmap *pix=new QPixmap(size().width(),size().height());
    QPainter *p=new QPainter(pix);
    if(button_state) {
        if(button_flash) {
            if(button_flash_state) {
                p->fillRect(0,0,size().width(),size().height(),button_color);
                p->setPen(RDGetTextColor(button_color));
            }
            else {
                p->fillRect(0,0,size().width(),size().height(),button_default_color);
                p->setPen(RDGetTextColor(button_default_color));
            }
        }
        else {
            p->fillRect(0,0,size().width(),size().height(),button_color);
            p->setPen(RDGetTextColor(button_color));
        }
    }
    else {
        p->fillRect(0,0,size().width(),size().height(),button_color);
        p->setPen(RDGetTextColor(button_color));
    }

    //
    // Button Title
    //
    QFont font("helvetica",13,QFont::Normal);
    font.setPixelSize(13);
    QFontMetrics m(font);
    p->setFont(font);
    p->drawText(RDPANEL_BUTTON_MARGIN,m.lineSpacing(),
                GetNextLine(&text,m,size().width()-3*RDPANEL_BUTTON_MARGIN));
    p->drawText(RDPANEL_BUTTON_MARGIN,2*m.lineSpacing(),
                GetNextLine(&text,m,size().width()-3*RDPANEL_BUTTON_MARGIN));
    p->drawText(RDPANEL_BUTTON_MARGIN,3*m.lineSpacing(),
                GetNextLine(&text,m,size().width()-3*RDPANEL_BUTTON_MARGIN));

    //
    // Time Field & Output Text
    //
    if(!button_text.isEmpty()) {
        if(secs<0) {
            QFont out_font("helvetica",13,QFont::Normal);
            out_font.setPixelSize(13);
            p->setFont(out_font);
            if(button_pause_when_finished) {
                p->drawText(RDPANEL_BUTTON_MARGIN,size().height()-RDPANEL_BUTTON_MARGIN,"Finished");
            }
            else {
                if(button_active_length>=0) {
                    p->drawText(RDPANEL_BUTTON_MARGIN,size().height()-
                                RDPANEL_BUTTON_MARGIN,
                                RDGetTimeLength(button_active_length+1000,true,false));
                }
                else {
                    p->drawText(RDPANEL_BUTTON_MARGIN,size().height()-
                                RDPANEL_BUTTON_MARGIN,tr("No Audio"));
                }
            }
        }
        else {
            if(secs>8) {
                p->drawText(RDPANEL_BUTTON_MARGIN,size().height()-RDPANEL_BUTTON_MARGIN,
                            RDGetTimeLength(1000*(secs+1),true,false));
            }
            else {
                QFont out_font("helvetica",18,QFont::Bold);
                out_font.setPixelSize(18);
                p->setFont(out_font);
                QString secstr=QString().sprintf(":%d",secs+1);
                p->drawText(RDPANEL_BUTTON_MARGIN,size().height()-RDPANEL_BUTTON_MARGIN,secstr);
            }
            QFont out_font("helvetica",18,QFont::Bold);
            out_font.setPixelSize(18);
            p->setFont(out_font);
            QFontMetrics om(out_font);
            p->drawText(size().width()-om.width(button_output_text)-
                        RDPANEL_BUTTON_MARGIN,
                        size().height()-RDPANEL_BUTTON_MARGIN,button_output_text);
        }
    }
    p->end();
    setPixmap(*pix);
    delete p;
    delete pix;
}