KTimerDialog::KTimerDialog(int msec, TimerStyle style, QWidget *parent, const char *name, bool modal, const QString &caption, int buttonMask,
                           ButtonCode defaultButton, bool separator, const KGuiItem &user1, const KGuiItem &user2, const KGuiItem &user3)
    : KDialogBase(parent, name, modal, caption, buttonMask, defaultButton, separator, user1, user2, user3)
{
    totalTimer = new QTimer(this);
    updateTimer = new QTimer(this);
    msecTotal = msecRemaining = msec;
    updateInterval = 1000;
    tStyle = style;
    KWin::setIcons(winId(), DesktopIcon("randr"), SmallIcon("randr"));
    // default to cancelling the dialog on timeout
    if(buttonMask & Cancel)
        buttonOnTimeout = Cancel;

    connect(totalTimer, SIGNAL(timeout()), SLOT(slotInternalTimeout()));
    connect(updateTimer, SIGNAL(timeout()), SLOT(slotUpdateTime()));

    // create the widgets
    mainWidget = new QVBox(this, "mainWidget");
    timerWidget = new QHBox(mainWidget, "timerWidget");
    timerLabel = new QLabel(timerWidget);
    timerProgress = new QProgressBar(timerWidget);
    timerProgress->setTotalSteps(msecTotal);
    timerProgress->setPercentageVisible(false);

    KDialogBase::setMainWidget(mainWidget);

    slotUpdateTime(false);
}
Exemple #2
0
VCClock::VCClock(QWidget* parent, Doc* doc)
    : VCWidget(parent, doc)
    , m_clocktype(Clock)
    , m_scheduleIndex(-1)
    , m_hh(0)
    , m_mm(0)
    , m_ss(0)
    , m_targetTime(0)
    , m_currentTime(0)
    , m_isPaused(true)
{
    /* Set the class name "VCClock" as the object name as well */
    setObjectName(VCClock::staticMetaObject.className());

    setType(VCWidget::LabelWidget);
    setCaption("");
    resize(QSize(150, 50));
    QFont font = qApp->font();
    font.setBold(true);
    font.setPixelSize(28);
    setFont(font);

    connect(doc, SIGNAL(modeChanged(Doc::Mode)),
            this, SLOT(slotModeChanged(Doc::Mode)));

    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(slotUpdateTime()));
    timer->start(1000);
}
KTimerDialog::KTimerDialog( int msec, TimerStyle style, QWidget *parent,
                 const char *name, bool modal,
                 const QString &caption,
                 int buttonMask, ButtonCode defaultButton,
                 bool separator,
                 const KGuiItem &user1,
                 const KGuiItem &user2,
                 const KGuiItem &user3 )
    : KDialog( parent )
{
    setObjectName( name );
    setModal( modal );
    setCaption( caption );
    setButtons( (ButtonCodes)buttonMask );
    setDefaultButton( defaultButton );
    showButtonSeparator( separator );
    setButtonGuiItem( User1, user1 );
    setButtonGuiItem( User2, user2 );
    setButtonGuiItem( User3, user3 );

    totalTimer = new QTimer( this );
    totalTimer->setSingleShot( true );
    updateTimer = new QTimer( this );
    updateTimer->setSingleShot( false );
    msecTotal = msecRemaining = msec;
    updateInterval = 1000;
    tStyle = style;
	KWindowSystem::setIcons( winId(), DesktopIcon("randr"), SmallIcon("randr") );
    // default to canceling the dialog on timeout
    if ( buttonMask & Cancel )
        buttonOnTimeout = Cancel;

    connect( totalTimer, SIGNAL( timeout() ), SLOT( slotInternalTimeout() ) );
    connect( updateTimer, SIGNAL( timeout() ), SLOT( slotUpdateTime() ) );

    // create the widgets
    mainWidget = new KVBox( this );
    timerWidget = new KHBox( mainWidget );
    timerLabel = new QLabel( timerWidget );
    timerProgress = new QProgressBar( timerWidget );
    timerProgress->setRange( 0, msecTotal );
    timerProgress->setTextVisible( false );

    KDialog::setMainWidget( mainWidget );

    slotUpdateTime( false );
}