⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 webcoresettings.cpp

📁 手机浏览器源码程序,功能强大
💻 CPP
字号:
/*
 * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
 * Portions Copyright (c) 2005 Nokia Corporation, Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "WebCoreSettings.h"

#include "KWQKHTMLPart.h"
#include "KWQKHTMLSettings.h"
#include "WebCoreBridge.h"


/*
Apple code caches NSStrings etc to this class. We don't do it for now. -antti
*/

EXPORT_C CWebCoreSettings* CWebCoreSettings::NewL()
    {
    CWebCoreSettings* self = new (ELeave) CWebCoreSettings();
    CleanupStack::PushL(self);
    self->ConstructL();
    CleanupStack::Pop(self);
    return self;
    }

CWebCoreSettings::CWebCoreSettings() { }

void CWebCoreSettings::ConstructL()
    {
#ifndef __OOM__
    iSettings = new (ELeave) KHTMLSettings();
#else
    iSettings = new KHTMLSettings();
#endif
    }


EXPORT_C CWebCoreSettings::~CWebCoreSettings()
    {
    delete iSettings;
    }

void CWebCoreSettings::UpdateAllViews()
    {
    for (QPtrListIterator<KWQKHTMLPart> it(KWQKHTMLPart::instances()); it.current(); ++it) {
        KWQKHTMLPart *part = it.current();
        if (part->settings() == iSettings) {
            part->bridge()->Client().SetNeedsReapplyStyles();
            // possible performance hit. check if this function needs to
            // be called everytime when a settings is changed.
            // part->bridge()->ReapplyStylesForDeviceType( EWebCoreDeviceScreen );
            }
        }
    }

EXPORT_C void CWebCoreSettings::SetMinimumFontSize(TInt aSize)
    {
    iSettings->setMinFontSize(aSize);
    UpdateAllViews();
    }

EXPORT_C TInt CWebCoreSettings::MinimumFontSize() const
    {
    return iSettings->minFontSize();
    }

EXPORT_C void CWebCoreSettings::SetMinimumLogicalFontSize(TInt aSize)
    {
    iSettings->setMinLogicalFontSize(aSize);
    UpdateAllViews();
    }

EXPORT_C TInt CWebCoreSettings::MinimumLogicalFontSize()  const
    {
    return iSettings->minLogicalFontSize();
    }

EXPORT_C void CWebCoreSettings::SetDefaultFontSize(TInt aSize)
    {
    iSettings->setMediumFontSize(aSize);
    UpdateAllViews();
    }

EXPORT_C TInt CWebCoreSettings::DefaultFontSize() const
    {
    return iSettings->mediumFontSize();
    }

EXPORT_C void CWebCoreSettings::SetDefaultFixedFontSize(TInt aSize)
    {
    iSettings->setMediumFixedFontSize(aSize);
    UpdateAllViews();
    }

EXPORT_C TInt CWebCoreSettings::DefaultFixedFontSize() const
    {
    return iSettings->mediumFixedFontSize();
    }


EXPORT_C void CWebCoreSettings::SetJavaEnabled(TBool aEnabled)
    {
    iSettings->setIsJavaEnabled(aEnabled);
    UpdateAllViews();
    }

EXPORT_C TBool CWebCoreSettings::JavaEnabled() const
    {
    return iSettings->isJavaEnabled();
    }

EXPORT_C void CWebCoreSettings::SetPluginsEnabled(TBool aEnabled)
    {
    iSettings->setArePluginsEnabled(aEnabled);
    UpdateAllViews();
    }

EXPORT_C TBool CWebCoreSettings::PluginsEnabled() const
    {
    return iSettings->isPluginsEnabled();
    }

EXPORT_C void CWebCoreSettings::SetJavaScriptEnabled(TBool aEnabled)
    {
    iSettings->setIsJavaScriptEnabled(aEnabled);
    UpdateAllViews();
    }

EXPORT_C TBool CWebCoreSettings::JavaScriptEnabled() const
    {
    return iSettings->isJavaScriptEnabled();
    }

EXPORT_C void CWebCoreSettings::SetJavaScriptCanOpenWindowsAutomatically(TBool aEnabled)
    {
    iSettings->setJavaScriptCanOpenWindowsAutomatically(aEnabled);
    UpdateAllViews();
    }

EXPORT_C TBool CWebCoreSettings::JavaScriptCanOpenWindowsAutomatically() const
    {
    return iSettings->JavaScriptCanOpenWindowsAutomatically();
    }

EXPORT_C void CWebCoreSettings::SetWillLoadImagesAutomatically(TBool aEnabled)
    {
    iSettings->setAutoLoadImages(aEnabled);
    UpdateAllViews();
    }

EXPORT_C TBool CWebCoreSettings::WillLoadImagesAutomatically() const
    {
    return iSettings->autoLoadImages();
    }

EXPORT_C void CWebCoreSettings::SetShouldPrintBackgrounds(TBool aEnabled)
    {
    iSettings->setShouldPrintBackgrounds(aEnabled);
    UpdateAllViews();
    }

EXPORT_C TBool CWebCoreSettings::ShouldPrintBackgrounds() const
    {
    return iSettings->shouldPrintBackgrounds();
    }

EXPORT_C void CWebCoreSettings:: SetUserStyleSheetLocation(const TDesC& aLocation)
    {
    iSettings->setUserStyleSheet(QString::FromDes(aLocation));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::UserStyleSheetLocation() const
    {
    return iSettings->userStyleSheet().Des();
    }

EXPORT_C void CWebCoreSettings::SetDefaultTextEncoding(const TDesC& aEncoding)
    {
    iSettings->setEncoding(QString::FromDes(aEncoding));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::DefaultTextEncoding() const
    {
    return iSettings->encoding().Des();
    }

EXPORT_C void CWebCoreSettings::SetStandardFontFamily(const TDesC& aFamily)
    {
    iSettings->setStdFontName(QString::FromDes(aFamily));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::StandardFontFamily() const
    {
    return iSettings->stdFontName().Des();
    }

EXPORT_C void CWebCoreSettings::SetFixedFontFamily(const TDesC& aFamily)
    {
    iSettings->setFixedFontName(QString::FromDes(aFamily));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::FixedFontFamily() const
    {
    return iSettings->fixedFontName().Des();
    }

EXPORT_C void CWebCoreSettings::SetSerifFontFamily(const TDesC& aFamily)
    {
    iSettings->setSerifFontName(QString::FromDes(aFamily));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::SerifFontFamily() const
    {
    return iSettings->serifFontName().Des();
    }

EXPORT_C void CWebCoreSettings::SetSansSerifFontFamily(const TDesC& aFamily)
    {
    iSettings->setSansSerifFontName(QString::FromDes(aFamily));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::SansSerifFontFamily() const
    {
    return iSettings->sansSerifFontName().Des();
    }

EXPORT_C void CWebCoreSettings::SetCursiveFontFamily(const TDesC& aFamily)
    {
    iSettings->setCursiveFontName(QString::FromDes(aFamily));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::CursiveFontFamily() const
    {
    return iSettings->cursiveFontName().Des();
    }

EXPORT_C void CWebCoreSettings::SetFantasyFontFamily(const TDesC& aFamily)
    {
    iSettings->setFantasyFontName(QString::FromDes(aFamily));
    UpdateAllViews();
    }

EXPORT_C TPtrC CWebCoreSettings::FantasyFontFamily() const
    {
    return iSettings->fantasyFontName().Des();
    }

KHTMLSettings *CWebCoreSettings::Settings() const
{
    return iSettings;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -