Ticket #10092: mythfrontendsetup-07-02-2012.diff

File mythfrontendsetup-07-02-2012.diff, 16.8 KB (added by Xavier Hervy <xavier.hervy@…>, 12 years ago)

Video General Setting with MythUI with default-wide theme but should be usable with default too as I use relative positionning

  • mythtv/programs/mythfrontend/main.cpp

    diff --git a/mythtv/programs/mythfrontend/main.cpp b/mythtv/programs/mythfrontend/main.cpp
    index 259e020..c2a1d48 100644
    a b  
    1 #include <unistd.h>
    21#include <fcntl.h>
    32#include <signal.h>
    43#include <cerrno>
    using namespace std; 
    7574#include "mythversion.h"
    7675#include "taskqueue.h"
    7776
     77
     78#include "standardsettings.h"
     79
    7880// Video
    7981#include "cleanup.h"
    8082#include "globals.h"
    namespace 
    138140
    139141            if (passwordValid)
    140142            {
    141                 VideoGeneralSettings settings;
    142                 settings.exec();
     143                MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
     144                StandardSettingDialog *ssd = new StandardSettingDialog(mainStack, "videogeneralsettings");
     145
     146                if (ssd->Create())
     147                {
     148                    ssd->loadSettings(new VideoGeneralSettings());
     149                    mainStack->AddScreen(ssd);
     150                }
     151                else
     152                    delete ssd;
    143153            }
    144154            else
    145155            {
  • mythtv/programs/mythfrontend/mythfrontend.pro

    diff --git a/mythtv/programs/mythfrontend/mythfrontend.pro b/mythtv/programs/mythfrontend/mythfrontend.pro
    index 7c71469..dde9b2d 100644
    a b HEADERS += videoplayercommand.h videopopups.h 
    3939HEADERS += videofilter.h                videolist.h
    4040HEADERS += videoplayersettings.h        videodlg.h
    4141HEADERS += videoglobalsettings.h        upnpscanner.h
    42 HEADERS += commandlineparser.h
     42HEADERS += commandlineparser.h          standardsettings.h
    4343
    4444SOURCES += main.cpp playbackbox.cpp viewscheduled.cpp audiogeneralsettings.cpp
    4545SOURCES += globalsettings.cpp manualschedule.cpp programrecpriority.cpp
    SOURCES += videoplayercommand.cpp videopopups.cpp 
    6060SOURCES += videofilter.cpp              videolist.cpp
    6161SOURCES += videoplayersettings.cpp      videodlg.cpp
    6262SOURCES += videoglobalsettings.cpp      upnpscanner.cpp
    63 SOURCES += commandlineparser.cpp
     63SOURCES += commandlineparser.cpp        standardsettings.cpp
    6464
    6565HEADERS += serviceHosts/frontendServiceHost.h
    6666HEADERS += services/frontend.h
  • mythtv/programs/mythfrontend/videoglobalsettings.cpp

    diff --git a/mythtv/programs/mythfrontend/videoglobalsettings.cpp b/mythtv/programs/mythfrontend/videoglobalsettings.cpp
    index 0365bfc..55bd18d 100644
    a b  
    99#include "videodlg.h"
    1010#include "videoglobalsettings.h"
    1111
     12#include "mythlogging.h"
     13
    1214namespace
    1315{
    1416// General Settings
    15 HostComboBox *VideoDefaultParentalLevel()
     17HostComboBoxSetting *VideoDefaultParentalLevel()
    1618{
    17     HostComboBox *gc = new HostComboBox("VideoDefaultParentalLevel");
     19    HostComboBoxSetting *gc = new HostComboBoxSetting("VideoDefaultParentalLevel");
    1820    gc->setLabel(QObject::tr("Starting Parental Level"));
    1921    gc->addSelection(QObject::tr("4 - Highest"),
    2022                     QString::number(ParentalLevel::plHigh));
    const char *password_clue = 
    3335    QT_TRANSLATE_NOOP("QObject", "Setting this value to all numbers will make your life "
    3436                "much easier.");
    3537
    36 HostLineEdit *VideoAdminPassword()
     38HostTextEditSetting *VideoAdminPassword()
    3739{
    38     HostLineEdit *gc = new HostLineEdit("VideoAdminPassword");
     40    HostTextEditSetting *gc = new HostTextEditSetting("VideoAdminPassword");
    3941    gc->setLabel(QObject::tr("Parental Level 4 PIN"));
    4042    gc->setHelpText(QString("%1 %2")
    4143        .arg(QObject::tr("This PIN is used to enter Parental Control "
    HostLineEdit *VideoAdminPassword() 
    4446    return gc;
    4547}
    4648
    47 HostLineEdit *VideoAdminPasswordThree()
     49HostTextEditSetting *VideoAdminPasswordThree()
    4850{
    49     HostLineEdit *gc = new HostLineEdit("VideoAdminPasswordThree");
     51    HostTextEditSetting *gc = new HostTextEditSetting("VideoAdminPasswordThree");
    5052    gc->setLabel(QObject::tr("Parental Level 3 PIN"));
    5153    gc->setHelpText(QString("%1 %2")
    5254        .arg(QObject::tr("This PIN is used to enter Parental Control Level 3."))
    HostLineEdit *VideoAdminPasswordThree() 
    5456    return gc;
    5557}
    5658
    57 HostLineEdit *VideoAdminPasswordTwo()
     59HostTextEditSetting *VideoAdminPasswordTwo()
    5860{
    59     HostLineEdit *gc = new HostLineEdit("VideoAdminPasswordTwo");
     61    HostTextEditSetting *gc = new HostTextEditSetting("VideoAdminPasswordTwo");
    6062    gc->setLabel(QObject::tr("Parental Level 2 PIN"));
    6163    gc->setHelpText(QString("%1 %2")
    6264        .arg(QObject::tr("This PIN is used to enter Parental Control Level 2."))
    HostLineEdit *VideoAdminPasswordTwo() 
    6466    return gc;
    6567}
    6668
    67 HostCheckBox *VideoAggressivePC()
     69HostCheckBoxSetting *VideoAggressivePC()
    6870{
    69     HostCheckBox *gc = new HostCheckBox("VideoAggressivePC");
     71    HostCheckBoxSetting *gc = new HostCheckBoxSetting("VideoAggressivePC");
    7072    gc->setLabel(QObject::tr("Aggressive Parental Control"));
    7173    gc->setValue(false);
    7274    gc->setHelpText(QObject::tr("If set, you will not be able to return "
    HostCheckBox *VideoAggressivePC() 
    7678    return gc;
    7779}
    7880
    79 HostLineEdit *VideoStartupDirectory()
     81HostTextEditSetting *VideoStartupDirectory()
    8082{
    81     HostLineEdit *gc = new HostLineEdit("VideoStartupDir");
     83    HostTextEditSetting *gc = new HostTextEditSetting("VideoStartupDir");
    8284    gc->setLabel(QObject::tr("Directories that hold videos"));
    8385    gc->setValue(DEFAULT_VIDEOSTARTUP_DIR);
    8486    gc->setHelpText(QObject::tr("Multiple directories can be separated by ':'. "
    HostLineEdit *VideoStartupDirectory() 
    8789    return gc;
    8890}
    8991
    90 HostLineEdit *VideoArtworkDirectory()
     92HostTextEditSetting *VideoArtworkDirectory()
    9193{
    92     HostLineEdit *gc = new HostLineEdit("VideoArtworkDir");
     94    HostTextEditSetting *gc = new HostTextEditSetting("VideoArtworkDir");
    9395    gc->setLabel(QObject::tr("Directory that holds movie posters"));
    9496    gc->setValue(GetConfDir() + "/Video/Artwork");
    9597    gc->setHelpText(QObject::tr("This directory must exist, and the user "
    HostLineEdit *VideoArtworkDirectory() 
    98100    return gc;
    99101}
    100102
    101 HostLineEdit *VideoScreenshotDirectory()
     103HostTextEditSetting *VideoScreenshotDirectory()
    102104{
    103     HostLineEdit *gc = new HostLineEdit("mythvideo.screenshotDir");
     105    HostTextEditSetting *gc = new HostTextEditSetting("mythvideo.screenshotDir");
    104106    gc->setLabel(QObject::tr("Directory that holds movie screenshots"));
    105107    gc->setValue(GetConfDir() + "/Video/Screenshots");
    106108    gc->setHelpText(QObject::tr("This directory must exist, and the user "
    HostLineEdit *VideoScreenshotDirectory() 
    109111    return gc;
    110112}
    111113
    112 HostLineEdit *VideoBannerDirectory()
     114HostTextEditSetting *VideoBannerDirectory()
    113115{
    114     HostLineEdit *gc = new HostLineEdit("mythvideo.bannerDir");
     116    HostTextEditSetting *gc = new HostTextEditSetting("mythvideo.bannerDir");
    115117    gc->setLabel(QObject::tr("Directory that holds movie/TV Banners"));
    116118    gc->setValue(GetConfDir() + "/Video/Banners");
    117119    gc->setHelpText(QObject::tr("This directory must exist, and the user "
    HostLineEdit *VideoBannerDirectory() 
    120122    return gc;
    121123}
    122124
    123 HostLineEdit *VideoFanartDirectory()
     125HostTextEditSetting *VideoFanartDirectory()
    124126{
    125     HostLineEdit *gc = new HostLineEdit("mythvideo.fanartDir");
     127    HostTextEditSetting *gc = new HostTextEditSetting("mythvideo.fanartDir");
    126128    gc->setLabel(QObject::tr("Directory that holds movie fanart"));
    127129    gc->setValue(GetConfDir() + "/Video/Fanart");
    128130    gc->setHelpText(QObject::tr("This directory must exist, and the user "
    HostLineEdit *VideoFanartDirectory() 
    131133    return gc;
    132134}
    133135
    134 HostLineEdit *TrailerDirectory()
     136HostTextEditSetting *TrailerDirectory()
    135137{
    136     HostLineEdit *gc = new HostLineEdit("mythvideo.TrailersDir");
     138    HostTextEditSetting *gc = new HostTextEditSetting("mythvideo.TrailersDir");
    137139    gc->setLabel(QObject::tr("Directory that holds movie trailers"));
    138140    gc->setValue(GetConfDir() + "/Video/Trailers");
    139141    gc->setHelpText(QObject::tr("This directory must exist, and the user "
    HostLineEdit *TrailerDirectory() 
    148150
    149151// General Settings
    150152
    151 HostComboBox *SetOnInsertDVD()
     153HostComboBoxSetting *SetOnInsertDVD()
    152154{
    153     HostComboBox *gc = new HostComboBox("DVDOnInsertDVD");
     155    HostComboBoxSetting *gc = new HostComboBoxSetting("DVDOnInsertDVD");
    154156    gc->setLabel(QObject::tr("On DVD insertion"));
    155157    gc->addSelection(QObject::tr("Display mythdvd menu"),"1");
    156158    gc->addSelection(QObject::tr("Do nothing"),"0");
    HostComboBox *SetOnInsertDVD() 
    160162    return gc;
    161163}
    162164
    163 HostCheckBox *VideoTreeRemember()
     165HostCheckBoxSetting *VideoTreeRemember()
    164166{
    165     HostCheckBox *gc = new HostCheckBox("mythvideo.VideoTreeRemember");
     167    HostCheckBoxSetting *gc = new HostCheckBoxSetting("mythvideo.VideoTreeRemember");
    166168    gc->setLabel(QObject::tr("Video Tree remembers last selected position"));
    167169    gc->setValue(false);
    168170    gc->setHelpText(QObject::tr("If set, the current position in the Video "
    HostCheckBox *VideoTreeRemember() 
    170172    return gc;
    171173}
    172174
    173 struct ConfigPage
    174 {
    175     typedef std::vector<ConfigurationGroup *> PageList;
    176 
    177   protected:
    178     ConfigPage(PageList &pl) : m_pl(pl)
    179     {
    180     }
    181 
    182     void Add(ConfigurationGroup *page)
    183     {
    184         m_pl.push_back(page);
    185     }
    186 
    187   private:
    188     ConfigPage(const ConfigPage &);
    189     ConfigPage &operator=(const ConfigPage &);
    190 
    191   private:
    192     PageList &m_pl;
    193 };
    194 
    195 struct VConfigPage : public ConfigPage
    196 {
    197     VConfigPage(PageList &pl, bool luselabel = true, bool luseframe  = true,
    198                 bool lzeroMargin = false, bool lzeroSpace = false) :
    199         ConfigPage(pl)
    200     {
    201         m_vc_page = new VerticalConfigurationGroup(luselabel, luseframe,
    202                                                    lzeroMargin, lzeroSpace);
    203         Add(m_vc_page);
    204     }
    205175
    206     VerticalConfigurationGroup *operator->()
    207     {
    208         return m_vc_page;
    209     }
    210176
    211   private:
    212     VerticalConfigurationGroup *m_vc_page;
    213 };
    214177
    215 class RatingsToPL : public TriggeredConfigurationGroup
     178HostCheckBoxSetting *RatingsToPL()
    216179{
    217   public:
    218     RatingsToPL() : TriggeredConfigurationGroup(false)
     180    HostCheckBoxSetting *r2pl =
     181            new HostCheckBoxSetting("mythvideo.ParentalLevelFromRating");
     182    r2pl->setLabel(QObject::tr("Enable automatic Parental Level from "
     183                               "rating"));
     184    r2pl->setValue(false);
     185    r2pl->setHelpText(QObject::tr("If enabled, searches will automatically "
     186                                  "set the Parental Level to the one "
     187                                  "matching the rating below."));
     188
     189    typedef std::map<ParentalLevel::Level, QString> r2pl_map;
     190    r2pl_map r2pl_defaults;
     191    r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plLowest,
     192            QObject::tr("G", "PL 1 default search string.")));
     193    r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plLow,
     194            QObject::tr("PG", "PL 2 default search string.")));
     195    r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plMedium,
     196            QObject::tr("PG-13", "PL3 default search string.")));
     197    r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plHigh,
     198            QObject::tr("R:NC-17", "PL4 default search string.")));
     199
     200    for (ParentalLevel pl(ParentalLevel::plLowest);
     201         pl.GetLevel() <= ParentalLevel::plHigh && pl.good(); ++pl)
    219202    {
    220         HostCheckBox *r2pl =
    221                 new HostCheckBox("mythvideo.ParentalLevelFromRating");
    222         r2pl->setLabel(QObject::tr("Enable automatic Parental Level from "
    223                                    "rating"));
    224         r2pl->setValue(false);
    225         r2pl->setHelpText(QObject::tr("If enabled, searches will automatically "
    226                                       "set the Parental Level to the one "
    227                                       "matching the rating below."));
    228         addChild(r2pl);
    229         setTrigger(r2pl);
    230 
    231         typedef std::map<ParentalLevel::Level, QString> r2pl_map;
    232         r2pl_map r2pl_defaults;
    233         r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plLowest,
    234                 tr("G", "PL 1 default search string.")));
    235         r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plLow,
    236                 tr("PG", "PL 2 default search string.")));
    237         r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plMedium,
    238                 tr("PG-13", "PL3 default search string.")));
    239         r2pl_defaults.insert(r2pl_map::value_type(ParentalLevel::plHigh,
    240                 tr("R:NC-17", "PL4 default search string.")));
    241 
    242         VerticalConfigurationGroup *vcg = new VerticalConfigurationGroup(true);
    243 
    244         for (ParentalLevel pl(ParentalLevel::plLowest);
    245              pl.GetLevel() <= ParentalLevel::plHigh && pl.good(); ++pl)
     203        HostTextEditSetting *hle = new HostTextEditSetting(QString("mythvideo.AutoR2PL%1")
     204                                             .arg(pl.GetLevel()));
     205        hle->setLabel(QObject::tr("Level %1").arg(pl.GetLevel()));
     206        hle->setHelpText(QObject::tr("Ratings containing these strings "
     207                                     "(separated by :) will be assigned "
     208                                     "to Parental Level %1.")
     209                         .arg(pl.GetLevel()));
     210
     211        r2pl_map::const_iterator def_setting =
     212                r2pl_defaults.find(pl.GetLevel());
     213        if (def_setting != r2pl_defaults.end())
    246214        {
    247             HostLineEdit *hle = new HostLineEdit(QString("mythvideo.AutoR2PL%1")
    248                                                  .arg(pl.GetLevel()));
    249             hle->setLabel(QObject::tr("Level %1").arg(pl.GetLevel()));
    250             hle->setHelpText(QObject::tr("Ratings containing these strings "
    251                                          "(separated by :) will be assigned "
    252                                          "to Parental Level %1.")
    253                              .arg(pl.GetLevel()));
    254 
    255             r2pl_map::const_iterator def_setting =
    256                     r2pl_defaults.find(pl.GetLevel());
    257             if (def_setting != r2pl_defaults.end())
    258             {
    259                 hle->setValue(def_setting->second);
    260             }
    261 
    262             vcg->addChild(hle);
     215            hle->setValue(def_setting->second);
    263216        }
    264217
    265         addTarget("0", new VerticalConfigurationGroup(true));
    266         addTarget("1", vcg);
     218        r2pl->addTargetedChild("1", hle);
    267219    }
    268 };
    269220
    270 } // namespace
     221    return r2pl;
     222}
     223
     224}
    271225
    272226VideoGeneralSettings::VideoGeneralSettings()
     227    :GroupSetting()
    273228{
    274     ConfigPage::PageList pages;
    275 
    276     VConfigPage page1(pages, false);
    277     page1->addChild(VideoStartupDirectory());
    278     page1->addChild(TrailerDirectory());
    279     page1->addChild(VideoArtworkDirectory());
    280     page1->addChild(VideoScreenshotDirectory());
    281     page1->addChild(VideoBannerDirectory());
    282     page1->addChild(VideoFanartDirectory());
    283 
    284     VConfigPage page2(pages, false);
    285     page2->addChild(SetOnInsertDVD());
    286     page2->addChild(VideoTreeRemember());
    287 
    288     // page 3
    289     VerticalConfigurationGroup *pctrl =
    290             new VerticalConfigurationGroup(true, false);
     229    setLabel(QObject::tr("General settings"));
     230
     231    setHelpText(QObject::tr("TODO add a descrition for this group of settings"));
     232   
     233
     234    addChild(VideoStartupDirectory());
     235    addChild(TrailerDirectory());
     236    addChild(VideoArtworkDirectory());
     237    addChild(VideoScreenshotDirectory());
     238    addChild(VideoBannerDirectory());
     239    addChild(VideoFanartDirectory());
     240
     241    addChild(SetOnInsertDVD());
     242    addChild(VideoTreeRemember());
     243
     244    GroupSetting *pctrl =
     245            new GroupSetting();
    291246    pctrl->setLabel(QObject::tr("Parental Control Settings"));
     247
     248    pctrl->setHelpText(QObject::tr("TODO add a description for this group of setting"));
    292249    pctrl->addChild(VideoDefaultParentalLevel());
    293250    pctrl->addChild(VideoAdminPassword());
    294251    pctrl->addChild(VideoAdminPasswordThree());
    295252    pctrl->addChild(VideoAdminPasswordTwo());
    296253    pctrl->addChild(VideoAggressivePC());
    297     VConfigPage page3(pages, false);
    298     page3->addChild(pctrl);
    299254
    300     VConfigPage page4(pages, false);
    301     page4->addChild(new RatingsToPL());
     255    addChild(pctrl);
     256
     257    addChild(RatingsToPL());
    302258
    303     int page_num = 1;
    304     for (ConfigPage::PageList::const_iterator p = pages.begin();
    305          p != pages.end(); ++p, ++page_num)
    306     {
    307         (*p)->setLabel(QObject::tr("General Settings (%1/%2)").arg(page_num)
    308                        .arg(pages.size()));
    309         addChild(*p);
    310     }
    311259}
     260
  • mythtv/programs/mythfrontend/videoglobalsettings.h

    diff --git a/mythtv/programs/mythfrontend/videoglobalsettings.h b/mythtv/programs/mythfrontend/videoglobalsettings.h
    index 9f621e6..de155db 100644
    a b  
    33
    44#include "settings.h"
    55
    6 class VideoGeneralSettings : public ConfigurationWizard
     6#include "standardsettings.h"
     7
     8class VideoGeneralSettings : public GroupSetting
    79{
    810  public:
    911    VideoGeneralSettings();