Esempio n. 1
0
void LiteEditorWidget::zoomOut(int range)
{
    emit requestFontZoom(-range*10);
}
Esempio n. 2
0
DocumentBrowser::DocumentBrowser(LiteApi::IApplication *app, QObject *parent) :
    LiteApi::IDocumentBrowser(parent),
    m_liteApp(app),
    m_extension(new Extension)
{
    m_widget = new QWidget;

    m_htmlWidget = app->htmlWidgetManager()->createByName(this,"QTextBrowser");

    m_toolBar = new QToolBar;
    m_toolBar->setIconSize(LiteApi::getToolBarIconSize());

    m_backwardAct = new QAction(QIcon("icon:images/backward.png"),tr("Back"),this);
    m_forwardAct = new QAction(QIcon("icon:images/forward.png"),tr("Forward"),this);
    m_reloadUrlAct = new QAction(QIcon("icon:images/reload.png"),tr("Reload"),this);
    m_toolBar->addAction(m_backwardAct);
    m_toolBar->addAction(m_forwardAct);

    LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Document");

    m_increaseFontSize = new QAction(tr("Increase Font Size"),this);
    actionContext->regAction(m_increaseFontSize,"IncreaseFontSize","Ctrl++;Ctrl+=");

    m_decreaseFontSize = new QAction(tr("Decrease Font Size"),this);
    actionContext->regAction(m_decreaseFontSize,"DecreaseFontSize","Ctrl+-");

    m_resetFontSize = new QAction(tr("Reset Font Size"),this);
    actionContext->regAction(m_resetFontSize,"ResizeFontSize","Ctrl+0");

    m_urlComboBox = new QComboBox;
    m_urlComboBox->setEditable(true);
    m_urlComboBox->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);

    m_toolBar->addSeparator();
    m_toolBar->addWidget(m_urlComboBox);
    m_toolBar->addAction(m_reloadUrlAct);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);

    mainLayout->addWidget(m_toolBar);
    mainLayout->addWidget(m_htmlWidget->widget());
    m_widget->setLayout(mainLayout);

    m_widget->addAction(m_increaseFontSize);
    m_widget->addAction(m_decreaseFontSize);
    m_widget->addAction(m_resetFontSize);

    connect(m_increaseFontSize,SIGNAL(triggered()),this,SLOT(increaseFontSize()));
    connect(m_decreaseFontSize,SIGNAL(triggered()),this,SLOT(decreaseFontSize()));
    connect(m_resetFontSize,SIGNAL(triggered()),this,SLOT(resetFontSize()));
    connect(m_htmlWidget,SIGNAL(linkHovered(QUrl)),this,SIGNAL(linkHovered(QUrl)));
    connect(m_htmlWidget,SIGNAL(linkClicked(QUrl)),this,SLOT(linkClicked(QUrl)));
    connect(m_htmlWidget,SIGNAL(loadFinished(bool)),this,SIGNAL(documentLoaded()));
    connect(m_backwardAct,SIGNAL(triggered()),this,SLOT(backward()));
    connect(m_forwardAct,SIGNAL(triggered()),this,SLOT(forward()));
    connect(m_reloadUrlAct,SIGNAL(triggered()),this,SLOT(reloadUrl()));
    connect(m_urlComboBox,SIGNAL(activated(QString)),this,SLOT(activatedUrl(QString)));
    connect(this,SIGNAL(backwardAvailable(bool)),m_backwardAct,SLOT(setEnabled(bool)));
    connect(this,SIGNAL(forwardAvailable(bool)),m_forwardAct,SLOT(setEnabled(bool)));

    m_extension->addObject("LiteApi.IDocumentBrowser",this);
    m_extension->addObject("LiteApi.IHtmlWidget",m_htmlWidget);
    m_extension->addObject("LiteApi.QTextBrowser",m_htmlWidget->widget());
    m_htmlWidget->installEventFilter(m_liteApp->editorManager());

    requestFontZoom(0);

    QPalette p = m_htmlWidget->widget()->palette();
    p.setBrush(QPalette::Highlight,Qt::yellow);
    p.setColor(QPalette::HighlightedText,Qt::black);
    m_htmlWidget->widget()->setPalette(p);

    emit backwardAvailable(false);
    emit forwardAvailable(false);
}