forked from qt-creator/qt-creator
Core: Inline urllocatorfilter.ui
Change-Id: I083bbd17cc0dc7134372f8712ee30fdb31232601 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -119,7 +119,7 @@ add_qtc_plugin(Core
|
||||
locator/locatorwidget.cpp locator/locatorwidget.h
|
||||
locator/opendocumentsfilter.cpp locator/opendocumentsfilter.h
|
||||
locator/spotlightlocatorfilter.h locator/spotlightlocatorfilter.cpp
|
||||
locator/urllocatorfilter.cpp locator/urllocatorfilter.h locator/urllocatorfilter.ui
|
||||
locator/urllocatorfilter.cpp locator/urllocatorfilter.h
|
||||
loggingviewer.cpp loggingviewer.h
|
||||
loggingmanager.cpp loggingmanager.h
|
||||
mainwindow.cpp mainwindow.h
|
||||
|
||||
@@ -371,8 +371,7 @@ Project {
|
||||
"spotlightlocatorfilter.h",
|
||||
"spotlightlocatorfilter.cpp",
|
||||
"urllocatorfilter.cpp",
|
||||
"urllocatorfilter.h",
|
||||
"urllocatorfilter.ui"
|
||||
"urllocatorfilter.h"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QHash>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
|
||||
@@ -26,12 +26,19 @@
|
||||
#include "urllocatorfilter.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <QMutexLocker>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
|
||||
using namespace Utils;
|
||||
@@ -43,83 +50,119 @@ UrlFilterOptions::UrlFilterOptions(UrlLocatorFilter *filter, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_filter(filter)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
setWindowTitle(ILocatorFilter::msgConfigureDialogTitle());
|
||||
m_ui.prefixLabel->setText(Core::ILocatorFilter::msgPrefixLabel());
|
||||
m_ui.prefixLabel->setToolTip(Core::ILocatorFilter::msgPrefixToolTip());
|
||||
m_ui.includeByDefault->setText(Core::ILocatorFilter::msgIncludeByDefault());
|
||||
m_ui.includeByDefault->setToolTip(Core::ILocatorFilter::msgIncludeByDefaultToolTip());
|
||||
m_ui.shortcutEdit->setText(m_filter->shortcutString());
|
||||
m_ui.includeByDefault->setChecked(m_filter->isIncludedByDefault());
|
||||
m_ui.nameEdit->setText(filter->displayName());
|
||||
m_ui.nameEdit->selectAll();
|
||||
m_ui.nameLabel->setVisible(filter->isCustomFilter());
|
||||
m_ui.nameEdit->setVisible(filter->isCustomFilter());
|
||||
m_ui.listWidget->setToolTip(
|
||||
tr("Add \"%1\" placeholder for the query string.\nDouble-click to edit item."));
|
||||
resize(600, 400);
|
||||
|
||||
auto nameLabel = new QLabel(tr("Name:"));
|
||||
nameLabel->setVisible(filter->isCustomFilter());
|
||||
|
||||
nameEdit = new QLineEdit;
|
||||
nameEdit->setText(filter->displayName());
|
||||
nameEdit->selectAll();
|
||||
nameEdit->setVisible(filter->isCustomFilter());
|
||||
|
||||
listWidget = new QListWidget;
|
||||
listWidget->setDragDropMode(QAbstractItemView::InternalMove);
|
||||
listWidget->setToolTip(
|
||||
tr("Add \"%1\" placeholder for the query string.\nDouble-click to edit item."));
|
||||
const QStringList remoteUrls = m_filter->remoteUrls();
|
||||
for (const QString &url : remoteUrls) {
|
||||
auto item = new QListWidgetItem(url);
|
||||
m_ui.listWidget->addItem(item);
|
||||
listWidget->addItem(item);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
}
|
||||
|
||||
connect(m_ui.add, &QPushButton::clicked, this, &UrlFilterOptions::addNewItem);
|
||||
connect(m_ui.remove, &QPushButton::clicked, this, &UrlFilterOptions::removeItem);
|
||||
connect(m_ui.moveUp, &QPushButton::clicked, this, &UrlFilterOptions::moveItemUp);
|
||||
connect(m_ui.moveDown, &QPushButton::clicked, this, &UrlFilterOptions::moveItemDown);
|
||||
connect(m_ui.listWidget,
|
||||
auto add = new QPushButton(tr("Add"));
|
||||
remove = new QPushButton(tr("Remove"));
|
||||
moveUp = new QPushButton(tr("Move Up"));
|
||||
moveDown = new QPushButton(tr("Move Down"));
|
||||
|
||||
auto prefixLabel = new QLabel;
|
||||
prefixLabel->setText(Core::ILocatorFilter::msgPrefixLabel());
|
||||
prefixLabel->setToolTip(Core::ILocatorFilter::msgPrefixToolTip());
|
||||
|
||||
shortcutEdit = new QLineEdit;
|
||||
shortcutEdit->setText(m_filter->shortcutString());
|
||||
|
||||
includeByDefault = new QCheckBox;
|
||||
includeByDefault->setText(Core::ILocatorFilter::msgIncludeByDefault());
|
||||
includeByDefault->setToolTip(Core::ILocatorFilter::msgIncludeByDefaultToolTip());
|
||||
includeByDefault->setChecked(m_filter->isIncludedByDefault());
|
||||
|
||||
auto buttonBox = new QDialogButtonBox;
|
||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
|
||||
|
||||
using namespace Layouting;
|
||||
static const Break br;
|
||||
static const Stretch st;
|
||||
|
||||
Column buttons { add, remove, moveUp, moveDown, st };
|
||||
|
||||
Grid {
|
||||
nameLabel, nameEdit, br,
|
||||
Column { tr("URLs:"), st }, Row { listWidget, buttons}, br,
|
||||
prefixLabel, Row { shortcutEdit, includeByDefault, st }, br,
|
||||
Span(2, buttonBox)
|
||||
}.attachTo(this);
|
||||
|
||||
connect(add, &QPushButton::clicked, this, &UrlFilterOptions::addNewItem);
|
||||
connect(remove, &QPushButton::clicked, this, &UrlFilterOptions::removeItem);
|
||||
connect(moveUp, &QPushButton::clicked, this, &UrlFilterOptions::moveItemUp);
|
||||
connect(moveDown, &QPushButton::clicked, this, &UrlFilterOptions::moveItemDown);
|
||||
connect(listWidget,
|
||||
&QListWidget::currentItemChanged,
|
||||
this,
|
||||
&UrlFilterOptions::updateActionButtons);
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||
|
||||
updateActionButtons();
|
||||
}
|
||||
|
||||
void UrlFilterOptions::addNewItem()
|
||||
{
|
||||
QListWidgetItem *item = new QListWidgetItem("https://www.example.com/search?query=%1");
|
||||
m_ui.listWidget->addItem(item);
|
||||
listWidget->addItem(item);
|
||||
item->setSelected(true);
|
||||
item->setFlags(item->flags() | Qt::ItemIsEditable);
|
||||
m_ui.listWidget->setCurrentItem(item);
|
||||
m_ui.listWidget->editItem(item);
|
||||
listWidget->setCurrentItem(item);
|
||||
listWidget->editItem(item);
|
||||
}
|
||||
|
||||
void UrlFilterOptions::removeItem()
|
||||
{
|
||||
if (QListWidgetItem *item = m_ui.listWidget->currentItem()) {
|
||||
m_ui.listWidget->removeItemWidget(item);
|
||||
if (QListWidgetItem *item = listWidget->currentItem()) {
|
||||
listWidget->removeItemWidget(item);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
void UrlFilterOptions::moveItemUp()
|
||||
{
|
||||
const int row = m_ui.listWidget->currentRow();
|
||||
const int row = listWidget->currentRow();
|
||||
if (row > 0) {
|
||||
QListWidgetItem *item = m_ui.listWidget->takeItem(row);
|
||||
m_ui.listWidget->insertItem(row - 1, item);
|
||||
m_ui.listWidget->setCurrentRow(row - 1);
|
||||
QListWidgetItem *item = listWidget->takeItem(row);
|
||||
listWidget->insertItem(row - 1, item);
|
||||
listWidget->setCurrentRow(row - 1);
|
||||
}
|
||||
}
|
||||
|
||||
void UrlFilterOptions::moveItemDown()
|
||||
{
|
||||
const int row = m_ui.listWidget->currentRow();
|
||||
if (row >= 0 && row < m_ui.listWidget->count() - 1) {
|
||||
QListWidgetItem *item = m_ui.listWidget->takeItem(row);
|
||||
m_ui.listWidget->insertItem(row + 1, item);
|
||||
m_ui.listWidget->setCurrentRow(row + 1);
|
||||
const int row = listWidget->currentRow();
|
||||
if (row >= 0 && row < listWidget->count() - 1) {
|
||||
QListWidgetItem *item = listWidget->takeItem(row);
|
||||
listWidget->insertItem(row + 1, item);
|
||||
listWidget->setCurrentRow(row + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void UrlFilterOptions::updateActionButtons()
|
||||
{
|
||||
m_ui.remove->setEnabled(m_ui.listWidget->currentItem());
|
||||
const int row = m_ui.listWidget->currentRow();
|
||||
m_ui.moveUp->setEnabled(row > 0);
|
||||
m_ui.moveDown->setEnabled(row >= 0 && row < m_ui.listWidget->count() - 1);
|
||||
remove->setEnabled(listWidget->currentItem());
|
||||
const int row = listWidget->currentRow();
|
||||
moveUp->setEnabled(row > 0);
|
||||
moveDown->setEnabled(row >= 0 && row < listWidget->count() - 1);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
@@ -230,12 +273,12 @@ bool UrlLocatorFilter::openConfigDialog(QWidget *parent, bool &needsRefresh)
|
||||
if (optionsDialog.exec() == QDialog::Accepted) {
|
||||
QMutexLocker lock(&m_mutex);
|
||||
m_remoteUrls.clear();
|
||||
setIncludedByDefault(optionsDialog.m_ui.includeByDefault->isChecked());
|
||||
setShortcutString(optionsDialog.m_ui.shortcutEdit->text().trimmed());
|
||||
for (int i = 0; i < optionsDialog.m_ui.listWidget->count(); ++i)
|
||||
m_remoteUrls.append(optionsDialog.m_ui.listWidget->item(i)->text());
|
||||
setIncludedByDefault(optionsDialog.includeByDefault->isChecked());
|
||||
setShortcutString(optionsDialog.shortcutEdit->text().trimmed());
|
||||
for (int i = 0; i < optionsDialog.listWidget->count(); ++i)
|
||||
m_remoteUrls.append(optionsDialog.listWidget->item(i)->text());
|
||||
if (isCustomFilter())
|
||||
setDisplayName(optionsDialog.m_ui.nameEdit->text());
|
||||
setDisplayName(optionsDialog.nameEdit->text());
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -25,14 +25,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_urllocatorfilter.h"
|
||||
|
||||
#include "ilocatorfilter.h"
|
||||
|
||||
#include <coreplugin/core_global.h>
|
||||
|
||||
#include <QMutex>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QLineEdit;
|
||||
class QListWidget;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CORE_EXPORT UrlLocatorFilter final : public Core::ILocatorFilter
|
||||
@@ -87,7 +92,13 @@ private:
|
||||
void updateActionButtons();
|
||||
|
||||
UrlLocatorFilter *m_filter = nullptr;
|
||||
Ui::UrlFilterOptions m_ui;
|
||||
QLineEdit *nameEdit;
|
||||
QListWidget *listWidget;
|
||||
QPushButton *remove;
|
||||
QPushButton *moveUp;
|
||||
QPushButton *moveDown;
|
||||
QLineEdit *shortcutEdit;
|
||||
QCheckBox *includeByDefault;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Core::Internal::UrlFilterOptions</class>
|
||||
<widget class="QDialog" name="Core::Internal::UrlFilterOptions">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Filter Configuration</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="nameLabel">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="nameEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>URLs:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<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>
|
||||
<item row="1" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="dragDropMode">
|
||||
<enum>QAbstractItemView::InternalMove</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="add">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="remove">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="moveUp">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Move Up</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="moveDown">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>21</width>
|
||||
<height>21</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Move Down</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="prefixLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Prefix:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>shortcutEdit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="shortcutEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="includeByDefault">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Include by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<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>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Core::Internal::UrlFilterOptions</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>Core::Internal::UrlFilterOptions</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>
|
||||
Reference in New Issue
Block a user