Esempio n. 1
0
void HelpWidget::addViewer(HelpViewer *viewer)
{
    m_viewerStack->addWidget(viewer);
    viewer->setFocus(Qt::OtherFocusReason);
    viewer->setActionVisible(HelpViewer::Action::NewPage, m_style == ModeWidget);
    viewer->setActionVisible(HelpViewer::Action::ExternalWindow, m_style != ExternalWindow);
    connect(viewer, &HelpViewer::sourceChanged, this, [viewer, this](const QUrl &url) {
        if (currentViewer() == viewer) {
            m_addBookmarkAction->setEnabled(isBookmarkable(url));
            emit sourceChanged(url);
        }
    });
    connect(viewer, &HelpViewer::forwardAvailable, this, [viewer, this](bool available) {
        if (currentViewer() == viewer)
            m_forwardAction->setEnabled(available);
    });
    connect(viewer, &HelpViewer::backwardAvailable, this, [viewer, this](bool available) {
        if (currentViewer() == viewer)
            m_backAction->setEnabled(available);
    });
    connect(viewer, &HelpViewer::printRequested, this, [viewer, this]() {
        print(viewer);
    });
    if (m_style == ExternalWindow)
        connect(viewer, &HelpViewer::titleChanged, this, &HelpWidget::updateWindowTitle);

    connect(viewer, &HelpViewer::loadFinished, this, &HelpWidget::highlightSearchTerms);
    connect(viewer, &HelpViewer::newPageRequested, [](const QUrl &url) {
        OpenPagesManager::instance().createPage(url);
    });
    connect(viewer, &HelpViewer::externalPageRequested, this, &openUrlInWindow);

    updateCloseButton();
}
Esempio n. 2
0
// slot
void WSearchLineEdit::restoreSearch(const QString& text) {
    if(text.isNull()) {
        // disable
        setEnabled(false);
        blockSignals(true);
        setText("- - -");
        blockSignals(false);
        return;
    }
    setEnabled(true);
    qDebug() << "WSearchLineEdit::restoreSearch(" << text << ")";
    blockSignals(true);
    setText(text);
    blockSignals(false);
    if (text == "") {
        m_place = true;
        showPlaceholder();
    } else {
        QPalette pal = palette();
        pal.setColor(foregroundRole(), m_fgc);
        setPalette(pal);
        m_place = false;
    }
    updateCloseButton(text);
}
Esempio n. 3
0
LineEdit::LineEdit(QWidget* parent)
    : QLineEdit(parent)
    , m_clearButton(new QToolButton(this))
{
    m_clearButton->setObjectName("clearButton");

    QIcon icon;
    QString iconNameDirected = QString("edit-clear-locationbar-").append(
                (layoutDirection() == Qt::LeftToRight) ? "rtl" : "ltr");
    icon = QIcon::fromTheme(iconNameDirected);
    if (icon.isNull()) {
        icon = QIcon::fromTheme("edit-clear");
        if (icon.isNull()) {
            icon = filePath()->icon("actions", iconNameDirected, false);
        }
    }

    m_clearButton->setIcon(icon);
    m_clearButton->setCursor(Qt::ArrowCursor);
    m_clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
    m_clearButton->hide();
    connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear()));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(updateCloseButton(QString)));
    int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
    setStyleSheet(QString("QLineEdit { padding-right: %1px; } ")
                  .arg(m_clearButton->sizeHint().width() + frameWidth + 1));
    QSize msz = minimumSizeHint();
    setMinimumSize(qMax(msz.width(), m_clearButton->sizeHint().height() + frameWidth * 2 + 2),
                   qMax(msz.height(), m_clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
Esempio n. 4
0
void HelpWidget::removeViewerAt(int index)
{
    QWidget *viewerWidget = m_viewerStack->widget(index);
    QTC_ASSERT(viewerWidget, return);
    m_viewerStack->removeWidget(viewerWidget);
    // do not delete, that is done in the model
    // delete viewerWidget;
    if (m_viewerStack->currentWidget())
        setCurrentViewer(qobject_cast<HelpViewer *>(m_viewerStack->currentWidget()));
    updateCloseButton();
}
Esempio n. 5
0
QSearchLineEdit::QSearchLineEdit(QWidget* parent,
                                 const QString &clearIconFileName,
                                 const QString &optionsIconFileName,
                                 const QString &cancelIconFileName)
    : QLineEdit(parent)
{
    maybeFound = true;

    cancelPointer = 0;
    cancelButtonIcon = cancelIconFileName;

    searchStarted = false;
    sPbar = 0;
    stopButton = 0;

    QSize msz = minimumSizeHint();

    QPixmap optionsPixmap(optionsIconFileName.isEmpty() ? ":/images/search.png" : optionsIconFileName);
    optionsPixmap = optionsPixmap.scaledToHeight(fontMetrics().height() , Qt::SmoothTransformation);
    optionButton = new QToolButton(this);
    optionButton->setIcon(QIcon(optionsPixmap));
    optionButton->setIconSize(optionsPixmap.size());
    optionButton->setCursor(Qt::ArrowCursor);
    optionButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");

    clearButton = new QToolButton(this);
    QString defaultClearIcon = ":/images/clear-left.png";
    if (layoutDirection() == Qt::RightToLeft) {
        defaultClearIcon = ":/images/clear-right.png";
    }
    QPixmap clearPixmap(clearIconFileName.isEmpty() ? defaultClearIcon : clearIconFileName);
    clearPixmap = clearPixmap.scaledToHeight(fontMetrics().height() /*msz.height()*/, Qt::SmoothTransformation);
    clearButton->setIcon(QIcon(clearPixmap));
    clearButton->setIconSize(clearPixmap.size());
    clearButton->setCursor(Qt::ArrowCursor);
    clearButton->hide();



    connect(clearButton, SIGNAL(clicked()), this, SIGNAL(clearButtonPressed()));
    connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
    connect(clearButton, SIGNAL(clicked()), this, SLOT(resetNotFound()));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(updateCloseButton(QString)));

    setMinimumSize(qMax(msz.width(), optionButton->sizeHint().width() + clearButton->sizeHint().width()),
                   qMax(qMax(msz.height(), optionButton->sizeHint().height()), clearButton->sizeHint().height()));
    setStyleSheet(QString("QLineEdit { padding-left: %1px; padding-right: %2px; } ").arg(clearButton->sizeHint().width()).arg(optionButton->sizeHint().width()));
    clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
}