void BrowserApplication::loadSettings()
{
    QSettings settings;
    settings.beginGroup(QLatin1String("websettings"));

    QWebEngineSettings *defaultSettings = QWebEngineSettings::globalSettings();
    QWebEngineProfile *defaultProfile = QWebEngineProfile::defaultProfile();

    QString standardFontFamily = defaultSettings->fontFamily(QWebEngineSettings::StandardFont);
    int standardFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFontSize);
    QFont standardFont = QFont(standardFontFamily, standardFontSize);
    standardFont = qvariant_cast<QFont>(settings.value(QLatin1String("standardFont"), standardFont));
    defaultSettings->setFontFamily(QWebEngineSettings::StandardFont, standardFont.family());
    defaultSettings->setFontSize(QWebEngineSettings::DefaultFontSize, standardFont.pointSize());

    QString fixedFontFamily = defaultSettings->fontFamily(QWebEngineSettings::FixedFont);
    int fixedFontSize = defaultSettings->fontSize(QWebEngineSettings::DefaultFixedFontSize);
    QFont fixedFont = QFont(fixedFontFamily, fixedFontSize);
    fixedFont = qvariant_cast<QFont>(settings.value(QLatin1String("fixedFont"), fixedFont));
    defaultSettings->setFontFamily(QWebEngineSettings::FixedFont, fixedFont.family());
    defaultSettings->setFontSize(QWebEngineSettings::DefaultFixedFontSize, fixedFont.pointSize());

    defaultSettings->setAttribute(QWebEngineSettings::JavascriptEnabled, settings.value(QLatin1String("enableJavascript"), true).toBool());
    defaultSettings->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled, settings.value(QLatin1String("enableScrollAnimator"), true).toBool());

    defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, settings.value(QLatin1String("enablePlugins"), true).toBool());

    defaultSettings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);

    if (! sawStyleSheetCommandLineOption) {
        m_stylesheetFilename = settings.value(QLatin1String("userStyleSheetFile")).toString();
        m_stylesheetRules = settings.value(QLatin1String("userStyleSheetRules")).toString();
        emit reloadStyleSheet();
    }
    if (! m_stylesheetFilename.isEmpty()) {
        m_fileSystemWatcher->addPath(m_stylesheetFilename);
        connect(m_fileSystemWatcher, &QFileSystemWatcher::fileChanged,
                this, &BrowserApplication::reloadStylesheet);
    }

    defaultProfile->setHttpUserAgent(settings.value(QLatin1String("httpUserAgent")).toString());
    defaultProfile->setHttpAcceptLanguage(settings.value(QLatin1String("httpAcceptLanguage")).toString());

    settings.endGroup();

    settings.beginGroup(QLatin1String("proxy"));
    QNetworkProxy proxy;
    if (settings.value(QLatin1String("enabled"), false).toBool()) {
        if (settings.value(QLatin1String("type"), 0).toInt() == 0)
            proxy = QNetworkProxy::Socks5Proxy;
        else
            proxy = QNetworkProxy::HttpProxy;
        proxy.setHostName(settings.value(QLatin1String("hostName")).toString());
        proxy.setPort(settings.value(QLatin1String("port"), 1080).toInt());
        proxy.setUser(settings.value(QLatin1String("userName")).toString());
        proxy.setPassword(settings.value(QLatin1String("password")).toString());
    }
    QNetworkProxy::setApplicationProxy(proxy);
    settings.endGroup();
}
Exemple #2
0
void DockPanel::onDockModeChanged(Dock::DockMode, Dock::DockMode)
{
    reloadStyleSheet();

    m_pluginLayout->setLayoutSpacing(m_dockModeData->getAppletsItemSpacing());
    m_pluginLayout->setFixedHeight(m_pluginLayout->sizeHint().height());
    QHBoxLayout *mLayout = qobject_cast<QHBoxLayout *>(layout());
    if (m_dockModeData->getDockMode() == Dock::FashionMode) {
        mLayout->setAlignment(m_pluginLayout, Qt::AlignTop);
    }
    else {
        mLayout->setAlignment(m_pluginLayout, Qt::AlignVCenter);
    }
}
Exemple #3
0
DockPanel::DockPanel(QWidget *parent)
    : QLabel(parent)
{
    setObjectName("Panel");

    initGlobalPreview();
    initShowHideAnimation();
    initHideStateManager();
    initPluginLayout();
    initAppLayout();

    initMainLayout();

    setMinimumHeight(m_dockModeData->getDockHeight());  //set height for border-image calculate
    reloadStyleSheet();

    connect(m_dockModeData, &DockModeData::dockModeChanged, this, &DockPanel::onDockModeChanged);
    connect(PanelMenu::instance(), &PanelMenu::menuItemInvoked, [=] {
        //To ensure that dock will not hide at changing the hide-mode to keepshowing
        m_menuItemInvoked = true;
    });
}