Ticket #3916: mythflix.cpp.browseMenu.diff

File mythflix.cpp.browseMenu.diff, 2.7 KB (added by Britney Fransen <britney.fransen@…>, 17 years ago)
  • .cpp

    old new  
    5858        dir.mkdir(fileprefix);
    5959   
    6060    // Initialize variables
    61 
     61        zoom = QString("-z %1").arg(gContext->GetNumSetting("WebBrowserZoomLevel",200));
     62    browser = gContext->GetSetting("WebBrowserCommand",
     63                                   gContext->GetInstallPrefix() +
     64                                      "/bin/mythbrowser");
     65        expectingPopup = false;
    6266    m_InColumn     = 0;
    6367    m_UISites      = 0;
    6468    m_UIArticles   = 0;
     
    398402            cursorRight();
    399403        else if(action == "SELECT")
    400404            slotViewArticle();
     405        else if (action == "MENU")
     406            displayOptions();             
    401407        else
    402408            handled = false;
    403409    }
     
    510516    }
    511517}
    512518
     519void MythFlix::slotShowNetFlixPage()
     520{
     521        if (expectingPopup)
     522        slotCancelPopup();
     523   
     524    UIListBtnTypeItem *articleUIItem = m_UIArticles->GetItemCurrent();
     525        if (articleUIItem && articleUIItem->getData())
     526    {
     527        NewsArticle *article = (NewsArticle*) articleUIItem->getData();
     528        if(article)
     529        {
     530                        QString cmdUrl(article->articleURL());
     531                        cmdUrl.replace('\'', "%27");
     532       
     533                        QString cmd = QString("%1 %2 '%3'")
     534                                 .arg(browser)
     535                                 .arg(zoom)
     536                                 .arg(cmdUrl);
     537                        VERBOSE(VB_GENERAL, QString("MythFlixBrowse: Opening Neflix site: (%1)").arg(cmd));
     538                        myth_system(cmd);
     539        }
     540    }
     541}
     542
    513543void MythFlix::slotSiteSelected(UIListBtnTypeItem *item)
    514544{
    515545    if (!item || !item->getData())
     
    561591    }
    562592}
    563593
     594void MythFlix::displayOptions()
     595{
     596
     597    popup = new MythPopupBox(gContext->GetMainWindow(), "menu popup");
     598
     599    QLabel *label = popup->addLabel(tr("Browse Options"),
     600                                  MythPopupBox::Large, false);
     601    label->setAlignment(Qt::AlignCenter | Qt::WordBreak);
     602
     603    QButton *topButton = popup->addButton(tr("Add To Queue"), this,
     604                     SLOT(slotViewArticle()));
     605                     
     606    popup->addButton(tr("Show NetFlix Page"), this,
     607                     SLOT(slotShowNetFlixPage()));
     608
     609    popup->addButton(tr("Cancel"), this, SLOT(slotCancelPopup()));
     610
     611    popup->ShowPopup(this, SLOT(slotCancelPopup()));
     612
     613    topButton->setFocus();
     614
     615    expectingPopup = true;
     616
     617}
     618
     619void MythFlix::slotCancelPopup(void)
     620{
     621    popup->hide();
     622    expectingPopup = false;
     623
     624    delete popup;
     625    popup = NULL;
     626
     627    setActiveWindow();
     628}
     629
     630
    564631// Execute an external command and return results in string
    565632//   probably should make this routing async vs polling like this
    566633//   but it would require a lot more code restructuring