Ticket #817: clock.3.diff

File clock.3.diff, 6.2 KB (added by Ben Levitt, 18 years ago)
  • themes/G.A.N.T./ui.xml

     
    12231223      </textarea>
    12241224    </container>
    12251225
     1226    <container name="clock">
     1227      <textarea name="clocktext" drawoder="0">
     1228        <area>625,8,175,40</area>
     1229        <font>title</font>
     1230        <value>h:mm AP</value>
     1231      </textarea>
     1232    </container>
     1233
    12261234    <container name="selector">
    12271235      <area>0,50,800,310</area>
    12281236      <listarea name="toptitles" draworder="2">
  • themes/blue/ui.xml

     
    774774      </textarea>
    775775    </container>
    776776   
     777    <container name="clock">
     778      <textarea name="clocktext" drawoder="0">
     779        <area>645,4,155,40</area>
     780        <font>title</font>
     781        <value>h:mm AP</value>
     782      </textarea>
     783    </container>
     784
    777785    <container name="cur_group">
    778786      <context>0</context> 
    779787      <area>20,10,280,35</area>
  • programs/mythfrontend/playbackbox.cpp

     
    252252    generatePreviewPixmap = gContext->GetNumSetting("GeneratePreviewPixmaps");
    253253    dateformat = gContext->GetSetting("DateFormat", "ddd MMMM d");
    254254    timeformat = gContext->GetSetting("TimeFormat", "h:mm AP");
     255    showClock = gContext->GetNumSetting("ShowClock", 0);
    255256
    256257    nvp = NULL;
    257258    timer = new QTimer(this);
     
    265266    timer->start(500);
    266267    gContext->addListener(this);
    267268
     269    if (showClock)
     270    {
     271        LayerSet *container = theme->GetSet("clock");
     272        if (container)
     273        {
     274            UITextType *text = (UITextType*) container->GetType("clocktext");
     275            if (text)
     276            {
     277                clockRect = text->getScreenArea();
     278                clockformat = text->GetDefaultText();
     279                clockTimer = new QTimer(this);
     280                connect(clockTimer, SIGNAL(timeout()), this, SLOT(updateClock()));
     281                clockTimer->start(100);
     282            }
     283            else
     284            {
     285                showClock = FALSE;
     286            }
     287        }
     288        else
     289        {
     290            showClock = FALSE;
     291        }
     292    }
     293
    268294    freeSpaceTimer = new QTimer(this);
    269295    connect(freeSpaceTimer, SIGNAL(timeout()), this,
    270296            SLOT(setUpdateFreeSpace()));
     
    489515    setPaletteBackgroundPixmap(myBackground);
    490516}
    491517 
     518void PlaybackBox::updateClock(void)
     519{
     520    LayerSet *container = theme->GetSet("clock");
     521    if (container)
     522    {
     523        UITextType *text = (UITextType*) container->GetType("clocktext");       
     524        if (text)
     525        {
     526            QPainter tmp(this);
     527            QPixmap pix(clockRect.size());
     528            pix.fill(this, clockRect.topLeft());
     529            tmp.drawPixmap(clockRect.topLeft(), pix);
     530
     531            QDateTime now = QDateTime::currentDateTime();
     532
     533            if (clockformat.contains('s'))
     534            {
     535                clockTimer->start(1000);
     536            }
     537            else
     538            {
     539                QDateTime nextMin = QDateTime(now.date(), QTime(now.time().hour(),
     540                                              now.time().minute())).addSecs(60);
     541                clockTimer->start(1000*(now.secsTo(nextMin)) + 500);
     542            }
     543
     544            QString timeStr = now.toString(clockformat);
     545            text->SetText(timeStr);
     546
     547            if(type != Delete)
     548            {
     549                text->Draw(&tmp, 0, 0);
     550            }
     551            else
     552            {
     553                text->Draw(&tmp, 0, 1);
     554            }
     555            tmp.end();
     556        }
     557    }
     558}
     559
    492560void PlaybackBox::paintEvent(QPaintEvent *e)
    493561{
    494562    if (e->erased())
     
    522590        updateVideo(&p);
    523591    }
    524592
     593    if (showClock && r.intersects(clockRect))
     594    {
     595        clockTimer->start(100);
     596    }
     597
    525598    skipCnt--;
    526599    if (skipCnt < 0)
    527600    {
     
    19031976    state = kKilling; // stop preview playback and don't restart it
    19041977    playingSomething = true;
    19051978
     1979    if (showClock)
     1980        clockTimer->stop();
     1981
    19061982    tv->setLastProgram(lastProgram);
    19071983
    19081984    if (tv->Playback(tvrec))
     
    19442020
    19452021    lastProgram = new ProgramInfo(*tvrec);
    19462022
     2023    if (showClock)
     2024        clockTimer->start(100);
     2025
    19472026    playingSomething = false;
    19482027    state = kStarting; // restart playback preview
    19492028    setEnabled(true);
  • programs/mythfrontend/globalsettings.cpp

     
    361361    return gc;
    362362}
    363363
     364static HostCheckBox *PBBShowClock()
     365{
     366    HostCheckBox *gc = new HostCheckBox("ShowClock");
     367    gc->setLabel(QObject::tr("Show clock"));
     368    gc->setValue(false);
     369    gc->setHelpText(QObject::tr("Show the current time in the Recorded "
     370                    "Programs screen."));
     371    return gc;
     372}
     373
    364374static HostCheckBox *SmartForward()
    365375{
    366376    HostCheckBox *gc = new HostCheckBox("SmartForward");
     
    30333043    pbox->addChild(PlaybackPreviewLowCPU());
    30343044    pbox->addChild(PBBStartInTitle());
    30353045    pbox->addChild(PBBShowGroupSummary());
     3046    pbox->addChild(PBBShowClock());
    30363047    addChild(pbox);
    30373048
    30383049    VerticalConfigurationGroup* pbox2 = new VerticalConfigurationGroup(false);
  • programs/mythfrontend/playbackbox.h

     
    4343 
    4444  protected slots:
    4545    void timeout(void);
     46    void updateClock(void);
    4647
    4748    void cursorLeft();
    4849    void cursorRight();
     
    259260    QString dateformat;
    260261    QString timeformat;
    261262
     263    bool showClock;
     264    QTimer *clockTimer;
     265    QString clockformat;
     266
    262267    void grayOut(QPainter *);
    263268    void updateBackground(void);
    264269    void updateVideo(QPainter *);
     
    287292    QRect usageRect;
    288293    QRect videoRect;
    289294    QRect curGroupRect;
     295    QRect clockRect;
    290296
    291297    QTimer *fillListTimer;
    292298    int listsize;