forked from qt-creator/qt-creator
Help: inline .ui files
bookmarkdialog.ui topicchooser.ui Change-Id: Ic5c36db648a56546ecf12ce2cb31a593732e7990 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -49,7 +49,9 @@
|
|||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QLineEdit>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
@@ -81,12 +81,11 @@ Project {
|
|||||||
name: "Shared Sources"
|
name: "Shared Sources"
|
||||||
prefix: project.sharedSourcesDir + "/help/"
|
prefix: project.sharedSourcesDir + "/help/"
|
||||||
files: [
|
files: [
|
||||||
"bookmarkdialog.ui",
|
|
||||||
"bookmarkmanager.cpp", "bookmarkmanager.h",
|
"bookmarkmanager.cpp", "bookmarkmanager.h",
|
||||||
"contentwindow.cpp", "contentwindow.h",
|
"contentwindow.cpp", "contentwindow.h",
|
||||||
"helpicons.h",
|
"helpicons.h",
|
||||||
"indexwindow.cpp", "indexwindow.h",
|
"indexwindow.cpp", "indexwindow.h",
|
||||||
"topicchooser.cpp", "topicchooser.h", "topicchooser.ui",
|
"topicchooser.cpp", "topicchooser.h",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -74,9 +74,12 @@
|
|||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/tooltip/tooltip.h>
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QLabel>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@@ -53,8 +53,10 @@
|
|||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPrintDialog>
|
#include <QPrintDialog>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
using namespace Help::Internal;
|
using namespace Help::Internal;
|
||||||
|
|
||||||
|
@@ -20,10 +20,9 @@ add_qtc_library(shared_help STATIC
|
|||||||
"${CMAKE_CURRENT_BINARY_DIR}/"
|
"${CMAKE_CURRENT_BINARY_DIR}/"
|
||||||
"${CMAKE_CURRENT_LIST_DIR}"
|
"${CMAKE_CURRENT_LIST_DIR}"
|
||||||
SOURCES
|
SOURCES
|
||||||
bookmarkdialog.ui
|
|
||||||
bookmarkmanager.cpp bookmarkmanager.h
|
bookmarkmanager.cpp bookmarkmanager.h
|
||||||
contentwindow.cpp contentwindow.h
|
contentwindow.cpp contentwindow.h
|
||||||
helpicons.h
|
helpicons.h
|
||||||
indexwindow.cpp indexwindow.h
|
indexwindow.cpp indexwindow.h
|
||||||
topicchooser.cpp topicchooser.h topicchooser.ui
|
topicchooser.cpp topicchooser.h
|
||||||
)
|
)
|
||||||
|
@@ -1,147 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>BookmarkDialog</class>
|
|
||||||
<widget class="QDialog" name="BookmarkDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>450</width>
|
|
||||||
<height>135</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Add Bookmark</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Bookmark:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add in folder:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="bookmarkEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="bookmarkFolders"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
|
||||||
<item>
|
|
||||||
<widget class="QToolButton" name="toolButton">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>25</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>+</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTreeView" name="treeView">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Ignored">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="newFolderButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>New Folder</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>BookmarkDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>BookmarkDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
@@ -30,6 +30,7 @@
|
|||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
@@ -65,12 +66,8 @@ BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
|
|||||||
, bookmarkManager(manager)
|
, bookmarkManager(manager)
|
||||||
{
|
{
|
||||||
installEventFilter(this);
|
installEventFilter(this);
|
||||||
|
resize(450, 0);
|
||||||
ui.setupUi(this);
|
setWindowTitle(tr("Add Bookmark"));
|
||||||
ui.bookmarkEdit->setText(title);
|
|
||||||
ui.newFolderButton->setVisible(false);
|
|
||||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
|
|
||||||
ui.bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
|
||||||
|
|
||||||
proxyModel = new QSortFilterProxyModel(this);
|
proxyModel = new QSortFilterProxyModel(this);
|
||||||
proxyModel->setFilterKeyColumn(0);
|
proxyModel->setFilterKeyColumn(0);
|
||||||
@@ -78,30 +75,60 @@ BookmarkDialog::BookmarkDialog(BookmarkManager *manager, const QString &title,
|
|||||||
proxyModel->setFilterRole(Qt::UserRole + 10);
|
proxyModel->setFilterRole(Qt::UserRole + 10);
|
||||||
proxyModel->setSourceModel(bookmarkManager->treeBookmarkModel());
|
proxyModel->setSourceModel(bookmarkManager->treeBookmarkModel());
|
||||||
proxyModel->setFilterRegularExpression(QRegularExpression(QLatin1String("Folder")));
|
proxyModel->setFilterRegularExpression(QRegularExpression(QLatin1String("Folder")));
|
||||||
ui.treeView->setModel(proxyModel);
|
|
||||||
|
|
||||||
ui.treeView->expandAll();
|
m_bookmarkEdit = new QLineEdit(title);
|
||||||
ui.treeView->setVisible(false);
|
m_bookmarkFolders = new QComboBox;
|
||||||
ui.treeView->header()->setVisible(false);
|
m_bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
||||||
ui.treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
|
|
||||||
connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &BookmarkDialog::reject);
|
m_toolButton = new QToolButton;
|
||||||
connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &BookmarkDialog::addAccepted);
|
m_toolButton->setFixedSize(24, 24);
|
||||||
connect(ui.newFolderButton, &QPushButton::clicked, this, &BookmarkDialog::addNewFolder);
|
auto line = new QFrame;
|
||||||
connect(ui.toolButton, &QToolButton::clicked, this, &BookmarkDialog::toolButtonClicked);
|
line->setFrameShape(QFrame::HLine);
|
||||||
connect(ui.bookmarkEdit, &QLineEdit::textChanged, this, &BookmarkDialog::textChanged);
|
line->setFrameShadow(QFrame::Sunken);
|
||||||
|
line->setForegroundRole(QPalette::Midlight);
|
||||||
|
|
||||||
|
m_treeView = new QTreeView;
|
||||||
|
m_treeView->setModel(proxyModel);
|
||||||
|
m_treeView->expandAll();
|
||||||
|
m_treeView->header()->setVisible(false);
|
||||||
|
m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
QSizePolicy treeViewSP(QSizePolicy::Preferred, QSizePolicy::Ignored);
|
||||||
|
treeViewSP.setVerticalStretch(1);
|
||||||
|
m_treeView->setSizePolicy(treeViewSP);
|
||||||
|
|
||||||
|
m_newFolderButton = new QPushButton(tr("New Folder"));
|
||||||
|
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
Column {
|
||||||
|
Form {
|
||||||
|
tr("Bookmark:"), m_bookmarkEdit, br,
|
||||||
|
tr("Add in folder:"), m_bookmarkFolders, br,
|
||||||
|
},
|
||||||
|
Row { m_toolButton, line, },
|
||||||
|
m_treeView,
|
||||||
|
Row { m_newFolderButton, m_buttonBox, }
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
toggleExpanded();
|
||||||
|
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &BookmarkDialog::reject);
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &BookmarkDialog::addAccepted);
|
||||||
|
connect(m_newFolderButton, &QPushButton::clicked, this, &BookmarkDialog::addNewFolder);
|
||||||
|
connect(m_toolButton, &QToolButton::clicked, this, &BookmarkDialog::toggleExpanded);
|
||||||
|
connect(m_bookmarkEdit, &QLineEdit::textChanged, this, &BookmarkDialog::textChanged);
|
||||||
|
|
||||||
connect(bookmarkManager->treeBookmarkModel(),
|
connect(bookmarkManager->treeBookmarkModel(),
|
||||||
&QStandardItemModel::itemChanged,
|
&QStandardItemModel::itemChanged,
|
||||||
this, &BookmarkDialog::itemChanged);
|
this, &BookmarkDialog::itemChanged);
|
||||||
|
|
||||||
connect(ui.bookmarkFolders, &QComboBox::currentIndexChanged,
|
connect(m_bookmarkFolders, &QComboBox::currentIndexChanged,
|
||||||
this, &BookmarkDialog::selectBookmarkFolder);
|
this, &BookmarkDialog::selectBookmarkFolder);
|
||||||
|
|
||||||
connect(ui.treeView, &TreeView::customContextMenuRequested,
|
connect(m_treeView, &TreeView::customContextMenuRequested,
|
||||||
this, &BookmarkDialog::showContextMenu);
|
this, &BookmarkDialog::showContextMenu);
|
||||||
|
|
||||||
connect(ui.treeView->selectionModel(), &QItemSelectionModel::currentChanged,
|
connect(m_treeView->selectionModel(), &QItemSelectionModel::currentChanged,
|
||||||
this, &BookmarkDialog::currentChanged);
|
this, &BookmarkDialog::currentChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,20 +138,20 @@ BookmarkDialog::~BookmarkDialog()
|
|||||||
|
|
||||||
void BookmarkDialog::addAccepted()
|
void BookmarkDialog::addAccepted()
|
||||||
{
|
{
|
||||||
QItemSelectionModel *model = ui.treeView->selectionModel();
|
QItemSelectionModel *model = m_treeView->selectionModel();
|
||||||
const QModelIndexList &list = model->selection().indexes();
|
const QModelIndexList &list = model->selection().indexes();
|
||||||
|
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
if (!list.isEmpty())
|
if (!list.isEmpty())
|
||||||
index = proxyModel->mapToSource(list.at(0));
|
index = proxyModel->mapToSource(list.at(0));
|
||||||
|
|
||||||
bookmarkManager->addNewBookmark(index, ui.bookmarkEdit->text(), m_url);
|
bookmarkManager->addNewBookmark(index, m_bookmarkEdit->text(), m_url);
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkDialog::addNewFolder()
|
void BookmarkDialog::addNewFolder()
|
||||||
{
|
{
|
||||||
QItemSelectionModel *model = ui.treeView->selectionModel();
|
QItemSelectionModel *model = m_treeView->selectionModel();
|
||||||
const QModelIndexList &list = model->selection().indexes();
|
const QModelIndexList &list = model->selection().indexes();
|
||||||
|
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
@@ -134,32 +161,29 @@ void BookmarkDialog::addNewFolder()
|
|||||||
QModelIndex newFolder =
|
QModelIndex newFolder =
|
||||||
bookmarkManager->addNewFolder(proxyModel->mapToSource(index));
|
bookmarkManager->addNewFolder(proxyModel->mapToSource(index));
|
||||||
if (newFolder.isValid()) {
|
if (newFolder.isValid()) {
|
||||||
ui.treeView->expand(index);
|
m_treeView->expand(index);
|
||||||
const QModelIndex &index = proxyModel->mapFromSource(newFolder);
|
const QModelIndex &index = proxyModel->mapFromSource(newFolder);
|
||||||
model->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
|
model->setCurrentIndex(index, QItemSelectionModel::ClearAndSelect);
|
||||||
|
|
||||||
ui.bookmarkFolders->clear();
|
m_bookmarkFolders->clear();
|
||||||
ui.bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
m_bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
||||||
|
|
||||||
const QString &name = index.data().toString();
|
const QString &name = index.data().toString();
|
||||||
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(name));
|
m_bookmarkFolders->setCurrentIndex(m_bookmarkFolders->findText(name));
|
||||||
}
|
}
|
||||||
ui.treeView->setFocus();
|
m_treeView->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkDialog::toolButtonClicked()
|
void BookmarkDialog::toggleExpanded()
|
||||||
{
|
{
|
||||||
bool visible = !ui.treeView->isVisible();
|
const char expand[] = "+";
|
||||||
ui.treeView->setVisible(visible);
|
const char collapse[] = "-";
|
||||||
ui.newFolderButton->setVisible(visible);
|
const bool doCollapse = m_toolButton->text() != expand;
|
||||||
|
m_toolButton->setText(doCollapse ? expand : collapse);
|
||||||
if (visible) {
|
m_treeView->setVisible(!doCollapse);
|
||||||
resize(QSize(width(), 400));
|
m_newFolderButton->setVisible(!doCollapse);
|
||||||
ui.toolButton->setText(QLatin1String("-"));
|
for (int i = 0; i <= 1; ++i) // Hack: resize twice to avoid "jumping" of m_toolButton
|
||||||
} else {
|
resize(width(), (doCollapse ? 1 : 400));
|
||||||
resize(width(), minimumHeight());
|
|
||||||
ui.toolButton->setText(QLatin1String("+"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkDialog::itemChanged(QStandardItem *item)
|
void BookmarkDialog::itemChanged(QStandardItem *item)
|
||||||
@@ -171,27 +195,27 @@ void BookmarkDialog::itemChanged(QStandardItem *item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item->text() != oldText) {
|
if (item->text() != oldText) {
|
||||||
ui.bookmarkFolders->clear();
|
m_bookmarkFolders->clear();
|
||||||
ui.bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
m_bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
||||||
|
|
||||||
QString name = tr("Bookmarks");
|
QString name = tr("Bookmarks");
|
||||||
const QModelIndex& index = ui.treeView->currentIndex();
|
const QModelIndex& index = m_treeView->currentIndex();
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
name = index.data().toString();
|
name = index.data().toString();
|
||||||
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(name));
|
m_bookmarkFolders->setCurrentIndex(m_bookmarkFolders->findText(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkDialog::textChanged(const QString& string)
|
void BookmarkDialog::textChanged(const QString& string)
|
||||||
{
|
{
|
||||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!string.isEmpty());
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!string.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarkDialog::selectBookmarkFolder(int index)
|
void BookmarkDialog::selectBookmarkFolder(int index)
|
||||||
{
|
{
|
||||||
const QString folderName = ui.bookmarkFolders->itemText(index);
|
const QString folderName = m_bookmarkFolders->itemText(index);
|
||||||
if (folderName == tr("Bookmarks")) {
|
if (folderName == tr("Bookmarks")) {
|
||||||
ui.treeView->clearSelection();
|
m_treeView->clearSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +224,7 @@ void BookmarkDialog::selectBookmarkFolder(int index)
|
|||||||
Qt::MatchCaseSensitive | Qt::MatchRecursive, 0);
|
Qt::MatchCaseSensitive | Qt::MatchRecursive, 0);
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
const QModelIndex &index = model->indexFromItem(list.at(0));
|
const QModelIndex &index = model->indexFromItem(list.at(0));
|
||||||
QItemSelectionModel *model = ui.treeView->selectionModel();
|
QItemSelectionModel *model = m_treeView->selectionModel();
|
||||||
if (model) {
|
if (model) {
|
||||||
model->setCurrentIndex(proxyModel->mapFromSource(index),
|
model->setCurrentIndex(proxyModel->mapFromSource(index),
|
||||||
QItemSelectionModel::ClearAndSelect);
|
QItemSelectionModel::ClearAndSelect);
|
||||||
@@ -210,7 +234,7 @@ void BookmarkDialog::selectBookmarkFolder(int index)
|
|||||||
|
|
||||||
void BookmarkDialog::showContextMenu(const QPoint &point)
|
void BookmarkDialog::showContextMenu(const QPoint &point)
|
||||||
{
|
{
|
||||||
QModelIndex index = ui.treeView->indexAt(point);
|
QModelIndex index = m_treeView->indexAt(point);
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -219,26 +243,26 @@ void BookmarkDialog::showContextMenu(const QPoint &point)
|
|||||||
QAction *removeItem = menu.addAction(tr("Delete Folder"));
|
QAction *removeItem = menu.addAction(tr("Delete Folder"));
|
||||||
QAction *renameItem = menu.addAction(tr("Rename Folder"));
|
QAction *renameItem = menu.addAction(tr("Rename Folder"));
|
||||||
|
|
||||||
QAction *picked = menu.exec(ui.treeView->mapToGlobal(point));
|
QAction *picked = menu.exec(m_treeView->mapToGlobal(point));
|
||||||
if (!picked)
|
if (!picked)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QModelIndex &proxyIndex = proxyModel->mapToSource(index);
|
const QModelIndex &proxyIndex = proxyModel->mapToSource(index);
|
||||||
if (picked == removeItem) {
|
if (picked == removeItem) {
|
||||||
bookmarkManager->removeBookmarkItem(ui.treeView, proxyIndex);
|
bookmarkManager->removeBookmarkItem(m_treeView, proxyIndex);
|
||||||
ui.bookmarkFolders->clear();
|
m_bookmarkFolders->clear();
|
||||||
ui.bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
m_bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
||||||
|
|
||||||
QString name = tr("Bookmarks");
|
QString name = tr("Bookmarks");
|
||||||
index = ui.treeView->currentIndex();
|
index = m_treeView->currentIndex();
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
name = index.data().toString();
|
name = index.data().toString();
|
||||||
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(name));
|
m_bookmarkFolders->setCurrentIndex(m_bookmarkFolders->findText(name));
|
||||||
} else if (picked == renameItem) {
|
} else if (picked == renameItem) {
|
||||||
BookmarkModel *model = bookmarkManager->treeBookmarkModel();
|
BookmarkModel *model = bookmarkManager->treeBookmarkModel();
|
||||||
if (QStandardItem *item = model->itemFromIndex(proxyIndex)) {
|
if (QStandardItem *item = model->itemFromIndex(proxyIndex)) {
|
||||||
item->setEditable(true);
|
item->setEditable(true);
|
||||||
ui.treeView->edit(index);
|
m_treeView->edit(index);
|
||||||
item->setEditable(false);
|
item->setEditable(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,7 +273,7 @@ void BookmarkDialog::currentChanged(const QModelIndex ¤t)
|
|||||||
QString text = tr("Bookmarks");
|
QString text = tr("Bookmarks");
|
||||||
if (current.isValid())
|
if (current.isValid())
|
||||||
text = current.data().toString();
|
text = current.data().toString();
|
||||||
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(text));
|
m_bookmarkFolders->setCurrentIndex(m_bookmarkFolders->findText(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
|
bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
|
||||||
@@ -257,7 +281,7 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
|
|||||||
if (object == this && e->type() == QEvent::KeyPress) {
|
if (object == this && e->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
|
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
|
||||||
|
|
||||||
QModelIndex index = ui.treeView->currentIndex();
|
QModelIndex index = m_treeView->currentIndex();
|
||||||
switch (ke->key()) {
|
switch (ke->key()) {
|
||||||
case Qt::Key_F2: {
|
case Qt::Key_F2: {
|
||||||
const QModelIndex &source = proxyModel->mapToSource(index);
|
const QModelIndex &source = proxyModel->mapToSource(index);
|
||||||
@@ -265,23 +289,23 @@ bool BookmarkDialog::eventFilter(QObject *object, QEvent *e)
|
|||||||
bookmarkManager->treeBookmarkModel()->itemFromIndex(source);
|
bookmarkManager->treeBookmarkModel()->itemFromIndex(source);
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setEditable(true);
|
item->setEditable(true);
|
||||||
ui.treeView->edit(index);
|
m_treeView->edit(index);
|
||||||
item->setEditable(false);
|
item->setEditable(false);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case Qt::Key_Backspace:
|
case Qt::Key_Backspace:
|
||||||
case Qt::Key_Delete: {
|
case Qt::Key_Delete: {
|
||||||
bookmarkManager->removeBookmarkItem(ui.treeView,
|
bookmarkManager->removeBookmarkItem(m_treeView,
|
||||||
proxyModel->mapToSource(index));
|
proxyModel->mapToSource(index));
|
||||||
ui.bookmarkFolders->clear();
|
m_bookmarkFolders->clear();
|
||||||
ui.bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
m_bookmarkFolders->addItems(bookmarkManager->bookmarkFolders());
|
||||||
|
|
||||||
QString name = tr("Bookmarks");
|
QString name = tr("Bookmarks");
|
||||||
index = ui.treeView->currentIndex();
|
index = m_treeView->currentIndex();
|
||||||
if (index.isValid())
|
if (index.isValid())
|
||||||
name = index.data().toString();
|
name = index.data().toString();
|
||||||
ui.bookmarkFolders->setCurrentIndex(ui.bookmarkFolders->findText(name));
|
m_bookmarkFolders->setCurrentIndex(m_bookmarkFolders->findText(name));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_bookmarkdialog.h"
|
|
||||||
|
|
||||||
#include <utils/navigationtreeview.h>
|
#include <utils/navigationtreeview.h>
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@@ -42,8 +40,11 @@
|
|||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QComboBox;
|
||||||
|
class QDialogButtonBox;
|
||||||
class QEvent;
|
class QEvent;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
|
class QPushButton;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QToolButton;
|
class QToolButton;
|
||||||
class QStandardItem;
|
class QStandardItem;
|
||||||
@@ -67,7 +68,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void addAccepted();
|
void addAccepted();
|
||||||
void addNewFolder();
|
void addNewFolder();
|
||||||
void toolButtonClicked();
|
void toggleExpanded();
|
||||||
void itemChanged(QStandardItem *item);
|
void itemChanged(QStandardItem *item);
|
||||||
void textChanged(const QString& string);
|
void textChanged(const QString& string);
|
||||||
void selectBookmarkFolder(int index);
|
void selectBookmarkFolder(int index);
|
||||||
@@ -81,9 +82,15 @@ private:
|
|||||||
QString oldText;
|
QString oldText;
|
||||||
QStandardItem *renameItem;
|
QStandardItem *renameItem;
|
||||||
|
|
||||||
Ui::BookmarkDialog ui;
|
|
||||||
BookmarkManager *bookmarkManager;
|
BookmarkManager *bookmarkManager;
|
||||||
QSortFilterProxyModel *proxyModel;
|
QSortFilterProxyModel *proxyModel;
|
||||||
|
|
||||||
|
QLineEdit *m_bookmarkEdit;
|
||||||
|
QDialogButtonBox *m_buttonBox;
|
||||||
|
QComboBox *m_bookmarkFolders;
|
||||||
|
QPushButton *m_newFolderButton;
|
||||||
|
QTreeView *m_treeView;
|
||||||
|
QToolButton *m_toolButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TreeView : public Utils::NavigationTreeView
|
class TreeView : public Utils::NavigationTreeView
|
||||||
|
@@ -25,10 +25,15 @@
|
|||||||
|
|
||||||
#include "topicchooser.h"
|
#include "topicchooser.h"
|
||||||
|
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
#include <utils/fancylineedit.h>
|
||||||
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QListView>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
|
||||||
@@ -37,13 +42,8 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
|||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_filterModel(new QSortFilterProxyModel(this))
|
, m_filterModel(new QSortFilterProxyModel(this))
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
resize(400, 220);
|
||||||
|
setWindowTitle(tr("Choose Topic"));
|
||||||
setFocusProxy(ui.lineEdit);
|
|
||||||
ui.lineEdit->setFiltering(true);
|
|
||||||
ui.lineEdit->installEventFilter(this);
|
|
||||||
ui.lineEdit->setPlaceholderText(tr("Filter"));
|
|
||||||
ui.label->setText(tr("Choose a topic for <b>%1</b>:").arg(keyword));
|
|
||||||
|
|
||||||
QStandardItemModel *model = new QStandardItemModel(this);
|
QStandardItemModel *model = new QStandardItemModel(this);
|
||||||
m_filterModel->setSourceModel(model);
|
m_filterModel->setSourceModel(model);
|
||||||
@@ -57,20 +57,35 @@ TopicChooser::TopicChooser(QWidget *parent, const QString &keyword,
|
|||||||
model->appendRow(item);
|
model->appendRow(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.listWidget->setModel(m_filterModel);
|
m_lineEdit = new Utils::FancyLineEdit;
|
||||||
ui.listWidget->setUniformItemSizes(true);
|
m_lineEdit->setFiltering(true);
|
||||||
ui.listWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
m_lineEdit->installEventFilter(this);
|
||||||
|
setFocusProxy(m_lineEdit);
|
||||||
|
|
||||||
|
m_listWidget = new QListView;
|
||||||
|
m_listWidget->setModel(m_filterModel);
|
||||||
|
m_listWidget->setUniformItemSizes(true);
|
||||||
|
m_listWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
if (m_filterModel->rowCount() != 0)
|
if (m_filterModel->rowCount() != 0)
|
||||||
ui.listWidget->setCurrentIndex(m_filterModel->index(0, 0));
|
m_listWidget->setCurrentIndex(m_filterModel->index(0, 0));
|
||||||
|
|
||||||
connect(ui.buttonBox, &QDialogButtonBox::accepted,
|
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
Column {
|
||||||
|
tr("Choose a topic for <b>%1</b>:").arg(keyword),
|
||||||
|
m_lineEdit,
|
||||||
|
m_listWidget,
|
||||||
|
buttonBox,
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(buttonBox, &QDialogButtonBox::accepted,
|
||||||
this, &TopicChooser::acceptDialog);
|
this, &TopicChooser::acceptDialog);
|
||||||
connect(ui.buttonBox, &QDialogButtonBox::rejected,
|
connect(buttonBox, &QDialogButtonBox::rejected,
|
||||||
this, &TopicChooser::reject);
|
this, &TopicChooser::reject);
|
||||||
connect(ui.listWidget, &QListView::activated,
|
connect(m_listWidget, &QListView::activated,
|
||||||
this, &TopicChooser::activated);
|
this, &TopicChooser::activated);
|
||||||
connect(ui.lineEdit, &Utils::FancyLineEdit::filterChanged,
|
connect(m_lineEdit, &Utils::FancyLineEdit::filterChanged,
|
||||||
this, &TopicChooser::setFilter);
|
this, &TopicChooser::setFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,15 +98,15 @@ QUrl TopicChooser::link() const
|
|||||||
|
|
||||||
void TopicChooser::acceptDialog()
|
void TopicChooser::acceptDialog()
|
||||||
{
|
{
|
||||||
m_activedIndex = ui.listWidget->currentIndex();
|
m_activedIndex = m_listWidget->currentIndex();
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopicChooser::setFilter(const QString &pattern)
|
void TopicChooser::setFilter(const QString &pattern)
|
||||||
{
|
{
|
||||||
m_filterModel->setFilterFixedString(pattern);
|
m_filterModel->setFilterFixedString(pattern);
|
||||||
if (m_filterModel->rowCount() != 0 && !ui.listWidget->currentIndex().isValid())
|
if (m_filterModel->rowCount() != 0 && !m_listWidget->currentIndex().isValid())
|
||||||
ui.listWidget->setCurrentIndex(m_filterModel->index(0, 0));
|
m_listWidget->setCurrentIndex(m_filterModel->index(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopicChooser::activated(const QModelIndex &index)
|
void TopicChooser::activated(const QModelIndex &index)
|
||||||
@@ -102,7 +117,7 @@ void TopicChooser::activated(const QModelIndex &index)
|
|||||||
|
|
||||||
bool TopicChooser::eventFilter(QObject *object, QEvent *event)
|
bool TopicChooser::eventFilter(QObject *object, QEvent *event)
|
||||||
{
|
{
|
||||||
if (object == ui.lineEdit && event->type() == QEvent::KeyPress) {
|
if (object == m_lineEdit && event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
|
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
|
||||||
int dIndex = 0;
|
int dIndex = 0;
|
||||||
switch (ke->key()) {
|
switch (ke->key()) {
|
||||||
@@ -122,18 +137,18 @@ bool TopicChooser::eventFilter(QObject *object, QEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (dIndex != 0) {
|
if (dIndex != 0) {
|
||||||
QModelIndex idx = ui.listWidget->currentIndex();
|
QModelIndex idx = m_listWidget->currentIndex();
|
||||||
int newIndex = qMin(m_filterModel->rowCount(idx.parent()) - 1,
|
int newIndex = qMin(m_filterModel->rowCount(idx.parent()) - 1,
|
||||||
qMax(0, idx.row() + dIndex));
|
qMax(0, idx.row() + dIndex));
|
||||||
idx = m_filterModel->index(newIndex, idx.column(), idx.parent());
|
idx = m_filterModel->index(newIndex, idx.column(), idx.parent());
|
||||||
if (idx.isValid())
|
if (idx.isValid())
|
||||||
ui.listWidget->setCurrentIndex(idx);
|
m_listWidget->setCurrentIndex(idx);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (ui.lineEdit && event->type() == QEvent::FocusIn
|
} else if (m_lineEdit && event->type() == QEvent::FocusIn
|
||||||
&& static_cast<QFocusEvent *>(event)->reason() != Qt::MouseFocusReason) {
|
&& static_cast<QFocusEvent *>(event)->reason() != Qt::MouseFocusReason) {
|
||||||
ui.lineEdit->selectAll();
|
m_lineEdit->selectAll();
|
||||||
ui.lineEdit->setFocus();
|
m_lineEdit->setFocus();
|
||||||
}
|
}
|
||||||
return QDialog::eventFilter(object, event);
|
return QDialog::eventFilter(object, event);
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ui_topicchooser.h"
|
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
@@ -34,7 +32,12 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QSortFilterProxyModel)
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QListView;
|
||||||
|
class QSortFilterProxyModel;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils { class FancyLineEdit; }
|
||||||
|
|
||||||
class TopicChooser : public QDialog
|
class TopicChooser : public QDialog
|
||||||
{
|
{
|
||||||
@@ -52,9 +55,11 @@ private:
|
|||||||
void activated(const QModelIndex &index);
|
void activated(const QModelIndex &index);
|
||||||
bool eventFilter(QObject *object, QEvent *event) override;
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
|
|
||||||
Ui::TopicChooser ui;
|
|
||||||
QList<QUrl> m_links;
|
QList<QUrl> m_links;
|
||||||
|
|
||||||
QModelIndex m_activedIndex;
|
QModelIndex m_activedIndex;
|
||||||
QSortFilterProxyModel *m_filterModel;
|
QSortFilterProxyModel *m_filterModel;
|
||||||
|
|
||||||
|
Utils::FancyLineEdit *m_lineEdit;
|
||||||
|
QListView *m_listWidget;
|
||||||
};
|
};
|
||||||
|
@@ -1,54 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>TopicChooser</class>
|
|
||||||
<widget class="QDialog" name="TopicChooser">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>393</width>
|
|
||||||
<height>218</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Choose Topic</string>
|
|
||||||
</property>
|
|
||||||
<property name="sizeGripEnabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Topics</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>listWidget</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="Utils::FancyLineEdit" name="lineEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QListView" name="listWidget"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</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>
|
|
Reference in New Issue
Block a user