Exemplo n.º 1
0
void FindMacroHandler::changeEditor(Core::IEditor *editor)
{
    if (!isRecording() || !editor || !editor->widget())
        return;

    Aggregation::Aggregate *aggregate = Aggregation::Aggregate::parentAggregate(editor->widget());
    if (aggregate) {
        Core::IFindSupport *currentFind = aggregate->component<Core::IFindSupport>();
        if (currentFind) {
            MacroTextFind *macroFind = qobject_cast<MacroTextFind *>(currentFind);
            if (macroFind)
                return;

            aggregate->remove(currentFind);
            macroFind = new MacroTextFind(currentFind);
            aggregate->add(macroFind);

            // Connect all signals
            connect(macroFind, &MacroTextFind::allReplaced,
                    this, &FindMacroHandler::replaceAll);
            connect(macroFind, &MacroTextFind::incrementalFound,
                    this, &FindMacroHandler::findIncremental);
            connect(macroFind, &MacroTextFind::incrementalSearchReseted,
                    this, &FindMacroHandler::resetIncrementalSearch);
            connect(macroFind, &MacroTextFind::replaced,
                    this, &FindMacroHandler::replace);
            connect(macroFind, &MacroTextFind::stepFound,
                    this, &FindMacroHandler::findStep);
            connect(macroFind, &MacroTextFind::stepReplaced,
                    this, &FindMacroHandler::replaceStep);
        }
    }
}
Exemplo n.º 2
0
void tst_Aggregate::queryAll()
{
    Aggregation::Aggregate aggregation;
    QObject *aggObject = &aggregation;
    Interface1 *component1 = new Interface1;
    Interface11 *component11 = new Interface11;
    Interface2 *component2 = new Interface2;
    aggregation.add(component1);
    aggregation.add(component11);
    aggregation.add(component2);
    QCOMPARE(Aggregation::query_all<Interface1>(&aggregation), QList<Interface1 *>() << component1 << component11);
    QCOMPARE(Aggregation::query_all<Interface11>(&aggregation), QList<Interface11 *>() << component11);
    QCOMPARE(Aggregation::query_all<Interface2>(&aggregation), QList<Interface2 *>() << component2);
    QCOMPARE(Aggregation::query_all<Interface3>(&aggregation), QList<Interface3 *>());

    QCOMPARE(Aggregation::query_all<Interface1>(aggObject), QList<Interface1 *>() << component1 << component11);
    QCOMPARE(Aggregation::query_all<Interface11>(aggObject), QList<Interface11 *>() << component11);
    QCOMPARE(Aggregation::query_all<Interface2>(aggObject), QList<Interface2 *>() << component2);
    QCOMPARE(Aggregation::query_all<Interface3>(aggObject), QList<Interface3 *>());

    QCOMPARE(Aggregation::query_all<Interface1>(component1), QList<Interface1 *>() << component1 << component11);
    QCOMPARE(Aggregation::query_all<Interface11>(component1), QList<Interface11 *>() << component11);
    QCOMPARE(Aggregation::query_all<Interface2>(component1), QList<Interface2 *>() << component2);
    QCOMPARE(Aggregation::query_all<Interface3>(component1), QList<Interface3 *>());

    QCOMPARE(Aggregation::query_all<Interface1>(component11), QList<Interface1 *>() << component1 << component11);
    QCOMPARE(Aggregation::query_all<Interface11>(component11), QList<Interface11 *>() << component11);
    QCOMPARE(Aggregation::query_all<Interface2>(component11), QList<Interface2 *>() << component2);
    QCOMPARE(Aggregation::query_all<Interface3>(component11), QList<Interface3 *>());

    QCOMPARE(Aggregation::query_all<Interface1>(component2), QList<Interface1 *>() << component1 << component11);
    QCOMPARE(Aggregation::query_all<Interface11>(component2), QList<Interface11 *>() << component11);
    QCOMPARE(Aggregation::query_all<Interface2>(component2), QList<Interface2 *>() << component2);
    QCOMPARE(Aggregation::query_all<Interface3>(component2), QList<Interface3 *>());
}
void OutputPane::createNewOutputWindow(RunControl *rc)
{
    connect(rc, SIGNAL(started()),
            this, SLOT(runControlStarted()));
    connect(rc, SIGNAL(finished()),
            this, SLOT(runControlFinished()));

    // First look if we can reuse a tab
    bool found = false;
    for (int i = 0; i < m_tabWidget->count(); ++i) {
        RunControl *old = runControlForTab(i);
        if (old->sameRunConfiguration(rc) && !old->isRunning()) {
            // Reuse this tab
            delete old;
            m_outputWindows.remove(old);
            OutputWindow *ow = static_cast<OutputWindow *>(m_tabWidget->widget(i));
            ow->grayOutOldContent();
            ow->verticalScrollBar()->setValue(ow->verticalScrollBar()->maximum());
            ow->setFormatter(rc->createOutputFormatter(ow));
            m_outputWindows.insert(rc, ow);
            found = true;
            break;
        }
    }
    if (!found) {
        OutputWindow *ow = new OutputWindow(m_tabWidget);
        ow->setFormatter(rc->createOutputFormatter(ow));
        Aggregation::Aggregate *agg = new Aggregation::Aggregate;
        agg->add(ow);
        agg->add(new Find::BaseTextFind(ow));
        m_outputWindows.insert(rc, ow);
        m_tabWidget->addTab(ow, rc->displayName());
    }
}
Exemplo n.º 4
0
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
{
    // check for backends
    typedef std::function<HelpViewer *()> ViewerFactory;
    typedef QPair<QByteArray, ViewerFactory>  ViewerFactoryItem; // id -> factory
    QVector<ViewerFactoryItem> factories;
#ifndef QT_NO_WEBKIT
    factories.append(qMakePair(QByteArray("qtwebkit"), []() { return new QtWebKitHelpViewer(); }));
#endif
#ifdef QTC_WEBENGINE_HELPVIEWER
    factories.append(qMakePair(QByteArray("qtwebengine"), []() { return new WebEngineHelpViewer(); }));
#endif
    factories.append(qMakePair(QByteArray("textbrowser"), []() { return new TextBrowserHelpViewer(); }));

#ifdef QTC_MAC_NATIVE_HELPVIEWER
    // default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
     factories.prepend(qMakePair(QByteArray("native"), []() { return new MacWebKitHelpViewer(); }));
#else
     factories.append(qMakePair(QByteArray("native"), []() { return new MacWebKitHelpViewer(); }));
#endif
#endif

    HelpViewer *viewer = nullptr;

    // check requested backend
    const QByteArray backend = qgetenv("QTC_HELPVIEWER_BACKEND");
    if (!backend.isEmpty()) {
        const int pos = Utils::indexOf(factories, [backend](const ViewerFactoryItem &item) {
            return backend == item.first;
        });
        if (pos == -1) {
            qWarning("Help viewer backend \"%s\" not found, using default.", backend.constData());
        } else {
            viewer  = factories.at(pos).second();
        }
    }

    if (!viewer)
        viewer = factories.first().second();
    QTC_ASSERT(viewer, return nullptr);

    // initialize font
    viewer->setViewerFont(LocalHelpManager::fallbackFont());
    connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged,
            viewer, &HelpViewer::setViewerFont);

    // initialize zoom
    viewer->setScale(zoom);

    // add find support
    Aggregation::Aggregate *agg = new Aggregation::Aggregate();
    agg->add(viewer);
    agg->add(new HelpViewerFindSupport(viewer));

    return viewer;
}
Exemplo n.º 5
0
Internal::OutputWindowPlainTextEdit *VcsOutputWindowPrivate::widget()
{
    if (!m_widget) {
        m_widget = new Internal::OutputWindowPlainTextEdit();
        Aggregation::Aggregate *agg = new Aggregation::Aggregate;
        agg->add(m_widget);
        agg->add(new Core::BaseTextFind(m_widget));
    }
    return m_widget;
}
Exemplo n.º 6
0
void tst_Aggregate::parentAggregate()
{
    Aggregation::Aggregate aggregation;
    Interface1 *component1 = new Interface1;
    Interface11 *component11 = new Interface11;
    QObject *component2 = new QObject;
    aggregation.add(component1);
    aggregation.add(component11);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(&aggregation), &aggregation);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component1), &aggregation);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component11), &aggregation);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component2), (Aggregation::Aggregate *)0);
}
Exemplo n.º 7
0
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
{
    // check for backends
    typedef std::function<HelpViewer *()> ViewerFactory;
    QHash<QString, ViewerFactory> factories; // id -> factory
#ifdef QTC_MAC_NATIVE_HELPVIEWER
    factories.insert(QLatin1String("native"), []() { return new MacWebKitHelpViewer(); });
#endif
#ifndef QT_NO_WEBKIT
    factories.insert(QLatin1String("qtwebkit"), []() { return new QtWebKitHelpViewer(); });
#endif
    factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });

    ViewerFactory factory;
    // check requested backend
    const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
    if (!backend.isEmpty()) {
        factory = factories.value(backend);
        if (!factory)
            qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
    }
    // default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
    if (!factory)
        factory = factories.value(QLatin1String("native"));
#endif
    if (!factory)
        factory = factories.value(QLatin1String("qtwebkit"));
    if (!factory)
        factory = factories.value(QLatin1String("textbrowser"));

    QTC_ASSERT(factory, return 0);
    HelpViewer *viewer = factory();

    // initialize font
    viewer->setViewerFont(LocalHelpManager::fallbackFont());
    connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged,
            viewer, &HelpViewer::setViewerFont);

    // initialize zoom
    viewer->setScale(zoom);

    // add find support
    Aggregation::Aggregate *agg = new Aggregation::Aggregate();
    agg->add(viewer);
    agg->add(new HelpViewerFindSupport(viewer));

    return viewer;
}
Exemplo n.º 8
0
QWidget *TreeViewFind::createSearchableWrapper(QTreeView *treeView, FetchOption option)
{
    QWidget *widget = new QWidget;
    QVBoxLayout *vbox = new QVBoxLayout(widget);
    vbox->setMargin(0);
    vbox->setSpacing(0);
    vbox->addWidget(treeView);
    vbox->addWidget(new Core::FindToolBarPlaceHolder(widget));

    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
    agg->add(treeView);
    agg->add(new TreeViewFind(treeView, Qt::DisplayRole, option));

    return widget;
}
Exemplo n.º 9
0
bool ImageViewerPlugin::initialize(const QStringList &arguments, QString *errorMessage)
{
    Q_UNUSED(arguments)

    Core::ICore *core = Core::ICore::instance();
    if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":/imageviewer/ImageViewer.mimetypes.xml"), errorMessage))
        return false;

    d_ptr->factory = new ImageViewerFactory(this);
    Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
    aggregate->add(d_ptr->factory);

    addAutoReleasedObject(d_ptr->factory);
    return true;
}
Exemplo n.º 10
0
MessageOutputWindow::MessageOutputWindow()
{
    m_widget = new Core::OutputWindow(Core::Context(Core::Constants::C_GENERAL_OUTPUT_PANE));
    m_widget->setReadOnly(true);
    // Let selected text be colored as if the text edit was editable,
    // otherwise the highlight for searching is too light
    QPalette p = m_widget->palette();
    QColor activeHighlight = p.color(QPalette::Active, QPalette::Highlight);
    p.setColor(QPalette::Highlight, activeHighlight);
    QColor activeHighlightedText = p.color(QPalette::Active, QPalette::HighlightedText);
    p.setColor(QPalette::HighlightedText, activeHighlightedText);
    m_widget->setPalette(p);
    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
    agg->add(m_widget);
    agg->add(new Core::BaseTextFind(m_widget));
}
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
{
    m_outputWindow = new OutputWindow();
    m_outputWindow->setWindowTitle(tr("Compile Output"));
    m_outputWindow->setWindowIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_WINDOW)));
    m_outputWindow->setReadOnly(true);
    m_outputWindow->setUndoRedoEnabled(false);

    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
    agg->add(m_outputWindow);
    agg->add(new Find::BaseTextFind(m_outputWindow));

    qRegisterMetaType<QTextCharFormat>("QTextCharFormat");

    m_handler = new ShowOutputTaskHandler(this);
    ExtensionSystem::PluginManager::instance()->addObject(m_handler);
}
Exemplo n.º 12
0
QFrame *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, ColorOption lightColored, FetchOption option)
{
    QFrame *widget = new QFrame;
    widget->setFrameStyle(QFrame::NoFrame);
    QVBoxLayout *vbox = new QVBoxLayout(widget);
    vbox->setMargin(0);
    vbox->setSpacing(0);
    vbox->addWidget(treeView);
    auto placeHolder = new FindToolBarPlaceHolder(widget);
    placeHolder->setLightColored(lightColored);
    vbox->addWidget(placeHolder);

    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
    agg->add(treeView);
    agg->add(new ItemViewFind(treeView, Qt::DisplayRole, option));

    return widget;
}
Exemplo n.º 13
0
OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) :
    Core::OutputWindow(Core::Context(C_VCS_OUTPUT_PANE), parent),
    m_defaultFormat(currentCharFormat()),
    m_errorFormat(m_defaultFormat),
    m_warningFormat(m_defaultFormat),
    m_commandFormat(m_defaultFormat),
    m_messageFormat(m_defaultFormat)
{
    using Utils::Theme;
    setReadOnly(true);
    setUndoRedoEnabled(false);
    setFrameStyle(QFrame::NoFrame);
    m_errorFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_ErrorMessageTextColor));
    m_warningFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_WarningMessageTextColor));
    m_commandFormat.setFontWeight(QFont::Bold);
    m_messageFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_MessageOutput));
    m_formatter = new Utils::OutputFormatter;
    m_formatter->setPlainTextEdit(this);
    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
    agg->add(this);
    agg->add(new Core::BaseTextFind(this));
}
Exemplo n.º 14
0
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
{
    Core::Context context(Constants::C_COMPILE_OUTPUT);
    m_outputWindow = new Core::OutputWindow(context);
    m_outputWindow->setWindowTitle(tr("Compile Output"));
    m_outputWindow->setWindowIcon(QIcon(QLatin1String(Constants::ICON_WINDOW)));
    m_outputWindow->setReadOnly(true);
    m_outputWindow->setUndoRedoEnabled(false);
    m_outputWindow->setMaxLineCount(MAX_LINECOUNT);

    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
    agg->add(m_outputWindow);
    agg->add(new Find::BaseTextFind(m_outputWindow));

    qRegisterMetaType<QTextCharFormat>("QTextCharFormat");

    m_handler = new ShowOutputTaskHandler(this);
    ExtensionSystem::PluginManager::instance()->addObject(m_handler);
    connect(ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
            this, SLOT(updateWordWrapMode()));
    updateWordWrapMode();
}
void tst_Aggregate::parentAggregate()
{
    Aggregation::Aggregate aggregation;
    Aggregation::Aggregate aggregation2;
    Interface1 *component1 = new Interface1;
    Interface11 *component11 = new Interface11;
    QObject *component2 = new QObject;
    aggregation.add(component1);
    aggregation.add(component11);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(&aggregation), &aggregation);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component1), &aggregation);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component11), &aggregation);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component2), (Aggregation::Aggregate *)0);
    // test reparenting a component to another aggregate (should warn but not work)
    aggregation2.add(component11);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component11), &aggregation);
    // test adding an aggregate to an aggregate (should warn but not work)
    aggregation.add(&aggregation2);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(&aggregation2), &aggregation2);
    // test removing an object from an aggregation.
    aggregation.remove(component11);
    QCOMPARE(Aggregation::Aggregate::parentAggregate(component11), (Aggregation::Aggregate *)0);
}
void DocumentEditorPlugin::initializeEditor(DocumentEdit *editor)
{
    DocumentEditorInterface *editorInterface = new DocumentEditorInterface(editor);
    //QObject::connect(editor, SIGNAL(modificationChanged(bool)), editorInterface, SIGNAL(changed()));
    editor->setEditorInterface(editorInterface);

    Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
    m_context << uidm->uniqueIdentifier(Constants::C_DOCUMENTEDITOR);
//    if (!m_undoAction) {
//        m_undoAction      = registerNewAction(QLatin1String(Core::Constants::UNDO),
//                                              this, SLOT(undoAction()),
//                                              tr("&Undo"));
//        m_redoAction      = registerNewAction(QLatin1String(Core::Constants::REDO),
//                                              this, SLOT(redoAction()),
//                                              tr("&Redo"));
//        m_copyAction      = registerNewAction(QLatin1String(Core::Constants::COPY),
//                                              this, SLOT(copyAction()));
//        m_selectAllAction = registerNewAction(QLatin1String(Core::Constants::SELECTALL),
//                                              this, SLOT(selectAllAction()));
//    }

    // Font settings
    //TextEditor::TextEditorSettings *settings = TextEditor::TextEditorSettings::instance();
    //editor->setFontSettings(settings->fontSettings());
    //connect(settings, SIGNAL(fontSettingsChanged(TextEditor::FontSettings)),
    //        editor, SLOT(setFontSettings(TextEditor::FontSettings)));

    //QObject::connect(editor, SIGNAL(undoAvailable(bool)), this, SLOT(updateActions()));
    //QObject::connect(editor, SIGNAL(redoAvailable(bool)), this, SLOT(updateActions()));
    //QObject::connect(editor, SIGNAL(copyAvailable(bool)), this, SLOT(updateActions()));

    Aggregation::Aggregate *aggregate = new Aggregation::Aggregate;
    //DocumentEditorFind *DocumentEditorFind = new DocumentEditorFind(editor);
    //aggregate->add(binEditorFind);
    aggregate->add(editor);
}
Exemplo n.º 17
0
void tst_Aggregate::queryAggregation()
{
    Aggregation::Aggregate aggregation;
    QObject *aggObject = &aggregation;
    QObject *component1 = new Interface11;
    QObject *component2 = new Interface2;
    aggregation.add(component1);
    aggregation.add(component2);
    QCOMPARE(Aggregation::query<Interface1>(&aggregation), component1);
    QCOMPARE(Aggregation::query<Interface2>(&aggregation), component2);
    QCOMPARE(Aggregation::query<Interface11>(&aggregation), component1);
    QCOMPARE(Aggregation::query<Interface3>(&aggregation), (Interface3 *)0);

    QCOMPARE(Aggregation::query<Interface1>(aggObject), component1);
    QCOMPARE(Aggregation::query<Interface2>(aggObject), component2);
    QCOMPARE(Aggregation::query<Interface11>(aggObject), component1);
    QCOMPARE(Aggregation::query<Interface3>(aggObject), (Interface3 *)0);

    QCOMPARE(Aggregation::query<Interface1>(component1), component1);
    QCOMPARE(Aggregation::query<Interface2>(component1), component2);
    QCOMPARE(Aggregation::query<Interface11>(component1), component1);
    QCOMPARE(Aggregation::query<Interface3>(component1), (Interface3 *)0);

    QCOMPARE(Aggregation::query<Interface1>(component2), component1);
    QCOMPARE(Aggregation::query<Interface2>(component2), component2);
    QCOMPARE(Aggregation::query<Interface11>(component2), component1);
    QCOMPARE(Aggregation::query<Interface3>(component2), (Interface3 *)0);

    // components that don't belong to an aggregation should be query-able to itself only
    QObject *component3 = new Interface3;
    QCOMPARE(Aggregation::query<Interface1>(component3), (Interface1 *)0);
    QCOMPARE(Aggregation::query<Interface2>(component3), (Interface2 *)0);
    QCOMPARE(Aggregation::query<Interface11>(component3), (Interface11 *)0);
    QCOMPARE(Aggregation::query<Interface3>(component3), component3);
    delete component3;
}
Exemplo n.º 18
0
Console::Console()
{
    m_consoleItemModel = new ConsoleItemModel(this);

    m_consoleWidget = new QWidget;
    m_consoleWidget->setWindowTitle(displayName());
    m_consoleWidget->setEnabled(true);

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

    m_consoleView = new ConsoleView(m_consoleItemModel, m_consoleWidget);
    auto proxyModel = new ConsoleProxyModel(this);
    proxyModel->setSourceModel(m_consoleItemModel);
    connect(m_consoleItemModel,
            &ConsoleItemModel::selectEditableRow,
            proxyModel,
            &ConsoleProxyModel::selectEditableRow);

    //Scroll to bottom when rows matching current filter settings are inserted
    //Not connecting rowsRemoved as the only way to remove rows is to clear the
    //model which will automatically reset the view.
    connect(m_consoleItemModel, &QAbstractItemModel::rowsInserted,
            proxyModel, &ConsoleProxyModel::onRowsInserted);
    m_consoleView->setModel(proxyModel);

    connect(proxyModel, &ConsoleProxyModel::setCurrentIndex,
            m_consoleView->selectionModel(), &QItemSelectionModel::setCurrentIndex);
    connect(proxyModel, &ConsoleProxyModel::scrollToBottom,
            m_consoleView, &ConsoleView::onScrollToBottom);

    auto itemDelegate = new ConsoleItemDelegate(m_consoleItemModel, this);
    connect(m_consoleView->selectionModel(), &QItemSelectionModel::currentChanged,
            itemDelegate, &ConsoleItemDelegate::currentChanged);
    m_consoleView->setItemDelegate(itemDelegate);

    Aggregation::Aggregate *aggregate = new Aggregation::Aggregate();
    aggregate->add(m_consoleView);
    aggregate->add(new Core::ItemViewFind(m_consoleView));

    vbox->addWidget(m_consoleView);
    vbox->addWidget(new Core::FindToolBarPlaceHolder(m_consoleWidget));

    m_showDebugButton = new QToolButton(m_consoleWidget);
    m_showDebugButton->setAutoRaise(true);

    m_showDebugButtonAction = new Utils::SavedAction(this);
    m_showDebugButtonAction->setDefaultValue(true);
    m_showDebugButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_LOG));
    m_showDebugButtonAction->setToolTip(tr("Show debug, log, and info messages."));
    m_showDebugButtonAction->setCheckable(true);
    m_showDebugButtonAction->setChecked(true);
    m_showDebugButtonAction->setIcon(Utils::Icons::INFO_TOOLBAR.icon());
    connect(m_showDebugButtonAction, &Utils::SavedAction::toggled,
            proxyModel, &ConsoleProxyModel::setShowLogs);
    m_showDebugButton->setDefaultAction(m_showDebugButtonAction);

    m_showWarningButton = new QToolButton(m_consoleWidget);
    m_showWarningButton->setAutoRaise(true);

    m_showWarningButtonAction = new Utils::SavedAction(this);
    m_showWarningButtonAction->setDefaultValue(true);
    m_showWarningButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_WARNING));
    m_showWarningButtonAction->setToolTip(tr("Show warning messages."));
    m_showWarningButtonAction->setCheckable(true);
    m_showWarningButtonAction->setChecked(true);
    m_showWarningButtonAction->setIcon(Utils::Icons::WARNING_TOOLBAR.icon());
    connect(m_showWarningButtonAction, &Utils::SavedAction::toggled,
            proxyModel, &ConsoleProxyModel::setShowWarnings);
    m_showWarningButton->setDefaultAction(m_showWarningButtonAction);

    m_showErrorButton = new QToolButton(m_consoleWidget);
    m_showErrorButton->setAutoRaise(true);

    m_showErrorButtonAction = new Utils::SavedAction(this);
    m_showErrorButtonAction->setDefaultValue(true);
    m_showErrorButtonAction->setSettingsKey(QLatin1String(CONSOLE), QLatin1String(SHOW_ERROR));
    m_showErrorButtonAction->setToolTip(tr("Show error messages."));
    m_showErrorButtonAction->setCheckable(true);
    m_showErrorButtonAction->setChecked(true);
    m_showErrorButtonAction->setIcon(Utils::Icons::CRITICAL_TOOLBAR.icon());
    connect(m_showErrorButtonAction, &Utils::SavedAction::toggled,
            proxyModel, &ConsoleProxyModel::setShowErrors);
    m_showErrorButton->setDefaultAction(m_showErrorButtonAction);

    m_spacer = new QWidget(m_consoleWidget);
    m_spacer->setMinimumWidth(30);

    m_statusLabel = new QLabel(m_consoleWidget);

    readSettings();
    connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
            this, &Console::writeSettings);
}
Exemplo n.º 19
0
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
{
    // check for backends
    typedef std::function<HelpViewer *()> ViewerFactory;
    QHash<QString, ViewerFactory> factories; // id -> factory
#ifdef QTC_MAC_NATIVE_HELPVIEWER
    factories.insert(QLatin1String("native"), []() { return new MacWebKitHelpViewer(); });
#endif
#ifndef QT_NO_WEBKIT
    factories.insert(QLatin1String("qtwebkit"), []() { return new QtWebKitHelpViewer(); });
#endif
    factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });

    ViewerFactory factory;
    // TODO: Visual Studio < 2013 has a bug in std::function's operator bool, which in this case
    // leads to succeeding boolean checks on factory which should not succeed.
    // So we may not check against "if (!factory)"
    bool factoryFound = false;

    // check requested backend
    const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
    if (!backend.isEmpty()) {
        if (!factories.contains(backend)) {
            qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
        } else {
            factory = factories.value(backend);
            factoryFound = true;
        }
    }
    // default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
    if (!factoryFound && factories.contains(QLatin1String("native"))) {
        factory = factories.value(QLatin1String("native"));
        factoryFound = true;
    }
#endif
    if (!factoryFound && factories.contains(QLatin1String("qtwebkit"))) {
        factory = factories.value(QLatin1String("qtwebkit"));
        factoryFound = true;
    }
    if (!factoryFound && factories.contains(QLatin1String("textbrowser"))) {
        factory = factories.value(QLatin1String("textbrowser"));
        factoryFound = true;
    }
    QTC_ASSERT(factoryFound, return 0);
    HelpViewer *viewer = factory();

    // initialize font
    QVariant fontSetting = LocalHelpManager::engineFontSettings();
    if (fontSetting.isValid())
        viewer->setViewerFont(fontSetting.value<QFont>());

    // initialize zoom
    viewer->setScale(zoom);

    // add find support
    Aggregation::Aggregate *agg = new Aggregation::Aggregate();
    agg->add(viewer);
    agg->add(new HelpViewerFindSupport(viewer));

    return viewer;
}