Ticket #3014: mythvideo_remember.patch

File mythvideo_remember.patch, 1.9 KB (added by pasha@…, 13 years ago)

Patch to remember last position

  • globalsettings.cpp

     
    162162    return hsb;
    163163}
    164164
     165HostCheckBox *VideoTreeRemeber()
     166{
     167    HostCheckBox *gc = new HostCheckBox("VideoTreeRemember");
     168    gc->setLabel(QObject::tr("Video Tree remembers last selected position"));
     169    gc->setValue(false);
     170    gc->setHelpText(QObject::tr("If set then last position in the Video Tree"
     171                 "is remembered and item is selected when entering MythVideo"));
     172    return gc;
     173}
     174
    165175HostLineEdit *SearchListingsCommand()
    166176{
    167177    HostLineEdit *gc = new HostLineEdit("MovieListCommandLine");
     
    550560    general2->addChild(VideoNewBrowsable());
    551561    general2->addChild(VideoSortIgnoresCase());
    552562    general2->addChild(VideoDBFolderView());
     563    general2->addChild(VideoTreeRemeber());
    553564    general2->addChild(VideoImageCacheSize());
    554565    addChild(general2);
    555566
  • videotree.cpp

     
    233233    m_video_list->setCurrentVideoFilter(video_filter);
    234234
    235235    buildVideoList();
     236
     237    bool remember = gContext->GetNumSetting("VideoTreeRemember", 0);
     238
     239    if (remember)
     240    {
     241        QString routePath = gContext->GetSetting("VideoTreeLastActive", "");
     242        QStringList route = QStringList::split("\n", routePath);
     243        m_imp->video_tree_list->tryToSetCurrent(route);
     244        m_imp->video_tree_list->enter();
     245    }
     246
    236247}
    237248
    238249VideoTree::~VideoTree()
    239250{
     251    bool remember = gContext->GetNumSetting("VideoTreeRemember", 0);
     252
     253    if (remember)
     254    {
     255        QStringList path = m_imp->video_tree_list->getRouteToCurrent();
     256        QString routePath = path.join("\n");
     257        gContext->SaveSetting("VideoTreeLastActive", routePath);
     258    }
    240259}
    241260
    242261void VideoTree::keyPressEvent(QKeyEvent *e)