forked from qt-creator/qt-creator
Help: Inline docsettingspage UI
Change-Id: Ifd4b44ba248f1e4b696477eb127a102762d9fbd9 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -4,7 +4,7 @@ add_qtc_plugin(Help
|
|||||||
PLUGIN_DEPENDS Core ProjectExplorer
|
PLUGIN_DEPENDS Core ProjectExplorer
|
||||||
PLUGIN_RECOMMENDS TextEditor
|
PLUGIN_RECOMMENDS TextEditor
|
||||||
SOURCES
|
SOURCES
|
||||||
docsettingspage.cpp docsettingspage.h docsettingspage.ui
|
docsettingspage.cpp docsettingspage.h
|
||||||
filtersettingspage.cpp filtersettingspage.h
|
filtersettingspage.cpp filtersettingspage.h
|
||||||
generalsettingspage.cpp generalsettingspage.h generalsettingspage.ui
|
generalsettingspage.cpp generalsettingspage.h generalsettingspage.ui
|
||||||
help.qrc
|
help.qrc
|
||||||
|
|||||||
@@ -27,9 +27,10 @@
|
|||||||
|
|
||||||
#include "helpconstants.h"
|
#include "helpconstants.h"
|
||||||
#include "helpmanager.h"
|
#include "helpmanager.h"
|
||||||
#include "ui_docsettingspage.h"
|
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@@ -39,7 +40,12 @@
|
|||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
@@ -98,8 +104,6 @@ private:
|
|||||||
|
|
||||||
QList<QModelIndex> currentSelection() const;
|
QList<QModelIndex> currentSelection() const;
|
||||||
|
|
||||||
Ui::DocSettingsPage m_ui;
|
|
||||||
|
|
||||||
FilePath m_recentDialogPath;
|
FilePath m_recentDialogPath;
|
||||||
|
|
||||||
using NameSpaceToPathHash = QMultiHash<QString, QString>;
|
using NameSpaceToPathHash = QMultiHash<QString, QString>;
|
||||||
@@ -107,6 +111,7 @@ private:
|
|||||||
QHash<QString, bool> m_filesToRegisterUserManaged;
|
QHash<QString, bool> m_filesToRegisterUserManaged;
|
||||||
NameSpaceToPathHash m_filesToUnregister;
|
NameSpaceToPathHash m_filesToUnregister;
|
||||||
|
|
||||||
|
QListView *m_docsListView = nullptr;
|
||||||
QSortFilterProxyModel m_proxyModel;
|
QSortFilterProxyModel m_proxyModel;
|
||||||
DocModel m_model;
|
DocModel m_model;
|
||||||
};
|
};
|
||||||
@@ -165,7 +170,39 @@ using namespace Help::Internal;
|
|||||||
|
|
||||||
DocSettingsPageWidget::DocSettingsPageWidget()
|
DocSettingsPageWidget::DocSettingsPageWidget()
|
||||||
{
|
{
|
||||||
m_ui.setupUi(this);
|
auto groupBox = new QGroupBox(this);
|
||||||
|
|
||||||
|
auto filterLineEdit = new Utils::FancyLineEdit(groupBox);
|
||||||
|
m_docsListView = new QListView(groupBox);
|
||||||
|
m_docsListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
m_docsListView->setUniformItemSizes(true);
|
||||||
|
|
||||||
|
auto treeLayout = new QVBoxLayout();
|
||||||
|
treeLayout->addWidget(filterLineEdit);
|
||||||
|
treeLayout->addWidget(m_docsListView);
|
||||||
|
|
||||||
|
auto addButton = new QPushButton(groupBox);
|
||||||
|
auto removeButton = new QPushButton(groupBox);
|
||||||
|
|
||||||
|
auto buttonLayout = new QVBoxLayout();
|
||||||
|
buttonLayout->addWidget(addButton);
|
||||||
|
buttonLayout->addWidget(removeButton);
|
||||||
|
buttonLayout->addStretch(1);
|
||||||
|
|
||||||
|
auto horizontalLayout = new QHBoxLayout(groupBox);
|
||||||
|
horizontalLayout->addLayout(treeLayout);
|
||||||
|
horizontalLayout->addLayout(buttonLayout);
|
||||||
|
|
||||||
|
setLayout(new QVBoxLayout);
|
||||||
|
layout()->addWidget(groupBox);
|
||||||
|
|
||||||
|
setToolTip(QCoreApplication::translate("Help::Internal::DocSettingsPage",
|
||||||
|
"Add and remove compressed help files, .qch.",
|
||||||
|
nullptr));
|
||||||
|
groupBox->setTitle(
|
||||||
|
QCoreApplication::translate("Help::Internal::DocSettingsPage", "Registered Documentation"));
|
||||||
|
addButton->setText(QCoreApplication::translate("Help::Internal::DocSettingsPage", "Add..."));
|
||||||
|
removeButton->setText(QCoreApplication::translate("Help::Internal::DocSettingsPage", "Remove"));
|
||||||
|
|
||||||
const QStringList nameSpaces = HelpManager::registeredNamespaces();
|
const QStringList nameSpaces = HelpManager::registeredNamespaces();
|
||||||
const QSet<QString> userDocumentationPaths = HelpManager::userDocumentationPaths();
|
const QSet<QString> userDocumentationPaths = HelpManager::userDocumentationPaths();
|
||||||
@@ -183,29 +220,27 @@ DocSettingsPageWidget::DocSettingsPageWidget()
|
|||||||
m_model.setEntries(entries);
|
m_model.setEntries(entries);
|
||||||
|
|
||||||
m_proxyModel.setSourceModel(&m_model);
|
m_proxyModel.setSourceModel(&m_model);
|
||||||
m_ui.docsListView->setModel(&m_proxyModel);
|
m_docsListView->setModel(&m_proxyModel);
|
||||||
m_ui.filterLineEdit->setFiltering(true);
|
filterLineEdit->setFiltering(true);
|
||||||
connect(m_ui.filterLineEdit,
|
connect(filterLineEdit,
|
||||||
&QLineEdit::textChanged,
|
&QLineEdit::textChanged,
|
||||||
&m_proxyModel,
|
&m_proxyModel,
|
||||||
&QSortFilterProxyModel::setFilterFixedString);
|
&QSortFilterProxyModel::setFilterFixedString);
|
||||||
|
|
||||||
connect(m_ui.addButton,
|
connect(addButton, &QAbstractButton::clicked, this, &DocSettingsPageWidget::addDocumentation);
|
||||||
&QAbstractButton::clicked,
|
connect(removeButton, &QAbstractButton::clicked, this, [this]() {
|
||||||
this,
|
|
||||||
&DocSettingsPageWidget::addDocumentation);
|
|
||||||
connect(m_ui.removeButton, &QAbstractButton::clicked, this, [this]() {
|
|
||||||
removeDocumentation(currentSelection());
|
removeDocumentation(currentSelection());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_ui.docsListView->installEventFilter(this);
|
m_docsListView->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DocSettingsPageWidget::addDocumentation()
|
void DocSettingsPageWidget::addDocumentation()
|
||||||
{
|
{
|
||||||
const FilePaths files =
|
const FilePaths files = FileUtils::getOpenFilePaths(Core::ICore::dialogParent(),
|
||||||
FileUtils::getOpenFilePaths(m_ui.addButton->parentWidget(),
|
tr("Add Documentation"),
|
||||||
tr("Add Documentation"), m_recentDialogPath, tr("Qt Help Files (*.qch)"));
|
m_recentDialogPath,
|
||||||
|
tr("Qt Help Files (*.qch)"));
|
||||||
|
|
||||||
if (files.isEmpty())
|
if (files.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -266,8 +301,10 @@ void DocSettingsPageWidget::addDocumentation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!formatedFail.isEmpty()) {
|
if (!formatedFail.isEmpty()) {
|
||||||
QMessageBox::information(m_ui.addButton->parentWidget(), tr("Registration Failed"),
|
QMessageBox::information(Core::ICore::dialogParent(),
|
||||||
tr("Unable to register documentation.") + formatedFail, QMessageBox::Ok);
|
tr("Registration Failed"),
|
||||||
|
tr("Unable to register documentation.") + formatedFail,
|
||||||
|
QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +325,7 @@ void DocSettingsPageWidget::apply()
|
|||||||
|
|
||||||
bool DocSettingsPageWidget::eventFilter(QObject *object, QEvent *event)
|
bool DocSettingsPageWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
{
|
{
|
||||||
if (object != m_ui.docsListView)
|
if (object != m_docsListView)
|
||||||
return IOptionsPageWidget::eventFilter(object, event);
|
return IOptionsPageWidget::eventFilter(object, event);
|
||||||
|
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
@@ -327,13 +364,15 @@ void DocSettingsPageWidget::removeDocumentation(const QList<QModelIndex> &items)
|
|||||||
|
|
||||||
const int newlySelectedRow = qMax(itemsByDecreasingRow.last().row() - 1, 0);
|
const int newlySelectedRow = qMax(itemsByDecreasingRow.last().row() - 1, 0);
|
||||||
const QModelIndex index = m_proxyModel.mapFromSource(m_model.index(newlySelectedRow));
|
const QModelIndex index = m_proxyModel.mapFromSource(m_model.index(newlySelectedRow));
|
||||||
m_ui.docsListView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
|
m_docsListView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QModelIndex> DocSettingsPageWidget::currentSelection() const
|
QList<QModelIndex> DocSettingsPageWidget::currentSelection() const
|
||||||
{
|
{
|
||||||
return Utils::transform(m_ui.docsListView->selectionModel()->selectedRows(),
|
return Utils::transform(m_docsListView->selectionModel()->selectedRows(),
|
||||||
[this](const QModelIndex &index) { return m_proxyModel.mapToSource(index); });
|
[this](const QModelIndex &index) {
|
||||||
|
return m_proxyModel.mapToSource(index);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
DocSettingsPage::DocSettingsPage()
|
DocSettingsPage::DocSettingsPage()
|
||||||
|
|||||||
@@ -1,85 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Help::Internal::DocSettingsPage</class>
|
|
||||||
<widget class="QWidget" name="Help::Internal::DocSettingsPage">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Add and remove compressed help files, .qch.</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Registered Documentation</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::FancyLineEdit" name="filterLineEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListView" name="docsListView">
|
|
||||||
<property name="selectionMode">
|
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="uniformItemSizes">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="removeButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>Utils::FancyLineEdit</class>
|
|
||||||
<extends>QLineEdit</extends>
|
|
||||||
<header location="global">utils/fancylineedit.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -35,7 +35,7 @@ Project {
|
|||||||
Group {
|
Group {
|
||||||
name: "Sources"
|
name: "Sources"
|
||||||
files: [
|
files: [
|
||||||
"docsettingspage.cpp", "docsettingspage.h", "docsettingspage.ui",
|
"docsettingspage.cpp", "docsettingspage.h",
|
||||||
"filtersettingspage.cpp", "filtersettingspage.h",
|
"filtersettingspage.cpp", "filtersettingspage.h",
|
||||||
"generalsettingspage.cpp", "generalsettingspage.h", "generalsettingspage.ui",
|
"generalsettingspage.cpp", "generalsettingspage.h", "generalsettingspage.ui",
|
||||||
"help.qrc",
|
"help.qrc",
|
||||||
|
|||||||
Reference in New Issue
Block a user