Ticket #1288: switch_for_overriding_RunFrontendInWindow.patch

File switch_for_overriding_RunFrontendInWindow.patch, 4.3 KB (added by visit0r, 18 years ago)

the patch

  • libs/libmyth/mythcontext.h

     
    348348                                 double defaultval = 0.0);
    349349
    350350    void SetSetting(const QString &key, const QString &newValue);
    351 
     351    void OverrideSettingForSession(const QString &key, const QString &newValue);
    352352    QFont GetBigFont();
    353353    QFont GetMediumFont();
    354354    QFont GetSmallFont();
     
    427427    bool useSettingsCache;
    428428    QMutex cacheLock;
    429429    QMap <QString, QString> settingsCache;
     430    /// The settings that are overridden for this session.
     431    QMap <QString, QString> overriddenSettings;
     432    QMutex overriddenSettingsLock;
    430433
    431434    QMutex locationLock;
    432435    QValueList <QString> currentLocation;
  • libs/libmyth/mythcontext.cpp

     
    17661766    bool found = false;
    17671767    QString value;
    17681768
     1769    overriddenSettingsLock.lock();
     1770    if (overriddenSettings.contains(key)) {
     1771        value = overriddenSettings[key];
     1772        overriddenSettingsLock.unlock();
     1773        return value;
     1774    }
     1775    overriddenSettingsLock.unlock();
     1776
    17691777    if (useSettingsCache)
    17701778    {
    17711779        cacheLock.lock();
     
    22912299    ClearSettingsCache(key, newValue);
    22922300}
    22932301
     2302/** \fn MythContext::OverrideSettingForSession()
     2303 *  \brief Overrides the given setting for the execution time of the process.
     2304 *
     2305 * This allows defining settings for the session only, without touching the
     2306 * settings in the data base.
     2307 */
     2308void MythContext::OverrideSettingForSession(const QString &key,
     2309                                            const QString &value)
     2310{
     2311    overriddenSettingsLock.lock();
     2312    overriddenSettings[key] = value;
     2313    overriddenSettingsLock.unlock();
     2314}
     2315
     2316
    22942317bool MythContext::SendReceiveStringList(QStringList &strlist, bool quickTimeout, bool block)
    22952318{
    22962319    d->serverSockLock.lock();
  • programs/mythfrontend/main.cpp

     
    761761    QString binname = finfo.baseName();
    762762
    763763    bool ResetSettings = false;
    764 
     764    bool OverrideRunFrontendInWindow = false;
     765    int RunFrontendInWindow = 0;
    765766    if (binname != "mythfrontend")
    766767        pluginname = binname;
    767768
     
    820821        {
    821822            ResetSettings = true;
    822823        }
     824        else if (!strcmp(a.argv()[argpos],"-w") ||
     825                 !strcmp(a.argv()[argpos],"--windowed"))
     826        {
     827            OverrideRunFrontendInWindow = true;
     828            RunFrontendInWindow = 1;
     829        }
     830        else if (!strcmp(a.argv()[argpos],"-nw") ||
     831                 !strcmp(a.argv()[argpos],"--no-windowed"))
     832        {
     833            OverrideRunFrontendInWindow = true;
     834            RunFrontendInWindow = 0;
     835        }
    823836        else if (!strcmp(a.argv()[argpos],"-geometry") ||
    824837                 !strcmp(a.argv()[argpos],"--geometry"))
    825838        {
     
    859872                    "--geometry WxH+X+Y             Override window size and position\n" <<
    860873                    "-l or --logfile filename       Writes STDERR and STDOUT messages to filename" << endl <<
    861874                    "-r or --reset                  Resets frontend appearance settings and language" << endl <<
    862                     "-v or --verbose debug-level    Use '-v help' for level info" << endl <<
     875                    "-v or --verbose debug-level    Use '-v help' for level info" << endl <<
     876                    "Override 'RunFrontendInWindow' setting:" << endl <<
     877                    "-w/--windowed                  Run in windowed mode" << endl <<
     878                    "-nw or --no-windowed           Run in non-windowed mode " << endl <<
    863879
    864880                    "--version                      Version information" << endl <<
    865881                    "<plugin>                       Initialize and run this plugin" << endl <<
     
    933949                .arg(geometry));
    934950    }
    935951
     952    if (OverrideRunFrontendInWindow) {
     953        QString setting;
     954        setting.setNum(RunFrontendInWindow);
     955        gContext->OverrideSettingForSession("RunFrontendInWindow", setting);
     956    }
     957
    936958    // Create priveleged thread, then drop privs
    937959    pthread_t priv_thread;
    938960