Ticket #3334: importicons-libmyth-29092007.diff

File importicons-libmyth-29092007.diff, 6.0 KB (added by Matthew Wire <devel@…>, 17 years ago)

libmyth changes for import icons

  • libs/libmyth/mythdialogs.cpp

     
    614614    return popup.ExecPopup();
    615615}
    616616
    617 MythProgressDialog::MythProgressDialog(const QString &message, int totalSteps)
     617MythProgressDialog::MythProgressDialog(const QString &message, int totalSteps,
     618                                         bool cancelButton, const QObject *target, const char *slot)
    618619                  : MythDialog(gContext->GetMainWindow(), "progress", false)
    619620{
    620621    int screenwidth, screenheight;
     
    642643    vbox->setFrameShadow(QFrame::Raised);
    643644    vbox->setMargin((int)(15 * wmult));
    644645
    645     QLabel *msglabel = new QLabel(vbox);
     646    msglabel = new QLabel(vbox);
    646647    msglabel->setBackgroundOrigin(ParentOrigin);
    647648    msglabel->setText(message);
     649    vbox->setStretchFactor(msglabel, 5);
    648650
    649     progress = new QProgressBar(totalSteps, vbox);
     651    QHBox *hbox = new QHBox(vbox);
     652    hbox->setSpacing(5);
     653   
     654    progress = new QProgressBar(totalSteps, hbox);
    650655    progress->setBackgroundOrigin(ParentOrigin);
    651     progress->setProgress(0);
    652656
     657    if (cancelButton && slot && target)
     658    {
     659        MythPushButton *button = new MythPushButton("Cancel", hbox, 0);
     660        connect(button, SIGNAL(pressed()), target, slot);
     661    }
     662
    653663    setTotalSteps(totalSteps);
    654664
    655665    if (class LCD * lcddev = LCD::Get())
     
    697707    }
    698708}
    699709
     710void MythProgressDialog::setLabel(QString newlabel)
     711{
     712    msglabel->setText(newlabel);
     713}
     714
    700715void MythProgressDialog::keyPressEvent(QKeyEvent *e)
    701716{
    702717    bool handled = false;
     
    718733void MythProgressDialog::setTotalSteps(int totalSteps)
    719734{
    720735    m_totalSteps = totalSteps;
     736    progress->setTotalSteps(totalSteps);
    721737    steps = totalSteps / 1000;
    722738    if (steps == 0)
    723739        steps = 1;
    724740}
    725741
    726 MythBusyDialog::MythBusyDialog(const QString &title)
    727     : MythProgressDialog(title, 0), timer(NULL)
     742MythProgressDialog::~MythProgressDialog()
    728743{
     744    if (LCD *lcddev = LCD::Get())
     745        lcddev->switchToTime();
    729746}
    730747
     748
     749MythBusyDialog::MythBusyDialog(const QString &title,
     750                               bool cancelButton, const QObject *target, const char *slot)
     751    : MythProgressDialog(title, 0,
     752                         cancelButton, target, slot),
     753                         timer(NULL)
     754{
     755}
     756
    731757MythBusyDialog::~MythBusyDialog()
    732758{
    733759    if (timer)
  • libs/libmyth/settings.h

     
    409409    void setSelectionMode(MythListBox::SelectionMode mode);
    410410    void setCurrentItem(int i) { if (widget) widget->setCurrentItem(i); }
    411411    void setCurrentItem(const QString& str)  { if (widget) widget->setCurrentItem(str); }
     412    int currentItem() { if (widget) return widget->currentItem();
     413                         else return -1; }
    412414
    413415    virtual void setEnabled(bool b);
    414416
     
    668670                       allow_single_step, special_value_text) { }
    669671};
    670672
     673class MPUBLIC TransListBoxSetting :
     674    public ListBoxSetting, public TransientStorage
     675{
     676  public:
     677    TransListBoxSetting() : ListBoxSetting(this), TransientStorage() { }
     678};
     679
     680
    671681///////////////////////////////////////////////////////////////////////////////
    672682
    673683class MPUBLIC HostSlider : public SliderSetting, public HostDBStorage
  • libs/libmyth/mythdialogs.h

     
    187187*/
    188188class MPUBLIC MythProgressDialog: public MythDialog
    189189{
     190    Q_OBJECT   
    190191  public:
    191192    /** Create a progress bar dialog.
    192193       
    193194        \param message the title string to appear in the progress dialog.
    194195        \param totalSteps the total number of steps
     196        \param cancelButton display cancel button
     197        \param target target for pressed signal
     198        \param slot slot for pressed signal
    195199     */
    196     MythProgressDialog(const QString& message, int totalSteps);
     200    MythProgressDialog(const QString& message, int totalSteps = 0,
     201                       bool cancelButton = false,
     202                       const QObject * target = NULL,
     203                       const char * slot = NULL);
     204   
     205    ~MythProgressDialog();
    197206
     207
    198208    /* \brief Close the dialog.
    199209
    200210        This will close the dialog and return the LCD to the Time screen
    201211    */
    202212    void Close(void);
     213
     214    void keyPressEvent(QKeyEvent *);
     215   
     216  public slots:
    203217    /* \brief Update the progress bar. 
    204218
    205219       This will move the progress bar the percentage-completed as
     
    209223       The LCD is updated as well.
    210224    */
    211225    void setProgress(int curprogress);
     226    void setLabel(QString newlabel);
     227   
     228  signals:
     229    void pressed();
    212230
    213     void keyPressEvent(QKeyEvent *);
    214 
    215231  protected:
    216232    QProgressBar *progress;
     233    QLabel *msglabel;
    217234
    218235  private:
    219236    void setTotalSteps(int totalSteps);
     
    238255        the widget to indicate progress every 100msec;
    239256
    240257        \param title the title to appear in the progress bar dialog
     258        \cancelButton display cancel button
     259        \param target target for pressed signal
     260        \param slot slot for pressed signal
    241261    */
    242     MythBusyDialog(const QString &title);
     262    MythBusyDialog(const QString &title,
     263                   bool cancelButton = false,
     264                   const QObject * target = NULL,
     265                   const char * slot = NULL);
    243266
    244267    ~MythBusyDialog();
    245268
  • libs/libmyth/mythwidgets.h

     
    375375    virtual void keyPressEvent(QKeyEvent* e);
    376376
    377377    void setHelpText(QString help) { helptext = help; }
     378   
     379    int currentItem() { return QListBox::currentItem(); }
    378380
    379381  protected:
    380382    void focusInEvent(QFocusEvent *e);