diff --git a/src/gui-qml/resources/images/icons/remove.png b/src/gui-qml/resources/images/icons/remove.png new file mode 100644 index 000000000..4be7ffbe1 Binary files /dev/null and b/src/gui-qml/resources/images/icons/remove.png differ diff --git a/src/gui-qml/resources/images/icons/remove@2x.png b/src/gui-qml/resources/images/icons/remove@2x.png new file mode 100644 index 000000000..6195cd675 Binary files /dev/null and b/src/gui-qml/resources/images/icons/remove@2x.png differ diff --git a/src/gui-qml/resources/images/icons/remove@3x.png b/src/gui-qml/resources/images/icons/remove@3x.png new file mode 100644 index 000000000..eb1139ceb Binary files /dev/null and b/src/gui-qml/resources/images/icons/remove@3x.png differ diff --git a/src/gui-qml/resources/images/icons/remove@4x.png b/src/gui-qml/resources/images/icons/remove@4x.png new file mode 100644 index 000000000..81c84d991 Binary files /dev/null and b/src/gui-qml/resources/images/icons/remove@4x.png differ diff --git a/src/gui-qml/resources/resources.qrc b/src/gui-qml/resources/resources.qrc index 06fc8fb65..814d337ea 100644 --- a/src/gui-qml/resources/resources.qrc +++ b/src/gui-qml/resources/resources.qrc @@ -97,5 +97,9 @@ images/icons/cloud@2x.png images/icons/cloud@3x.png images/icons/cloud@4x.png + images/icons/remove.png + images/icons/remove@2x.png + images/icons/remove@3x.png + images/icons/remove@4x.png diff --git a/src/gui-qml/src/components/SearchEdit.qml b/src/gui-qml/src/components/SearchEdit.qml new file mode 100644 index 000000000..b67cad51e --- /dev/null +++ b/src/gui-qml/src/components/SearchEdit.qml @@ -0,0 +1,36 @@ +import Grabber 1.0 +import QtQuick 2.12 +import QtQuick.Controls 2.5 + +TextEdit { + id: root + + signal enterPressed() + property alias placeholderText: placeholder.text + + verticalAlignment: Text.AlignVCenter + font.pixelSize: 14 + + Keys.onEnterPressed: { + root.enterPressed() + event.accepted = true + } + Keys.onReturnPressed: { + root.enterPressed() + event.accepted = true + } + + Text { + id: placeholder + + anchors.fill: parent + verticalAlignment: Text.AlignVCenter + visible: !(parent.text.length || parent.inputMethodComposing) + font: parent.font + color: "#666" + } + + SyntaxHighlighterHelper { + quickDocument: root.textDocument + } +} diff --git a/src/gui-qml/src/components/SearchField.qml b/src/gui-qml/src/components/SearchField.qml index fe4e2f32f..86b5f49a1 100644 --- a/src/gui-qml/src/components/SearchField.qml +++ b/src/gui-qml/src/components/SearchField.qml @@ -8,7 +8,8 @@ FocusScope { signal enterPressed() property alias text: textInput.text - property alias placeholderText: placeholder.text + property alias placeholderText: textInput.placeholderText + property bool isOpen: false activeFocusOnTab: true @@ -20,39 +21,28 @@ FocusScope { color: Qt.rgba(1, 1, 1, 0.6) radius: 12 - TextEdit { + SearchEdit { id: textInput anchors.fill: parent clip: true anchors.leftMargin: 12 anchors.rightMargin: 12 - verticalAlignment: Text.AlignVCenter - font.pixelSize: 14 focus: true - Keys.onEnterPressed: { - root.enterPressed() - event.accepted = true - } - Keys.onReturnPressed: { - root.enterPressed() - event.accepted = true - } - - Text { - id: placeholder - - anchors.fill: parent - verticalAlignment: Text.AlignVCenter - visible: !(parent.text.length || textInput.inputMethodComposing) - font: parent.font - color: "#666" - } + onEnterPressed: root.enterPressed() } - SyntaxHighlighterHelper { - quickDocument: textInput.textDocument + ToolButton { + icon.source: root.isOpen + ? "/images/icons/remove.png" + : "/images/icons/add.png" + onClicked: root.isOpen = !root.isOpen + flat: true + height: 34 + width: 34 + anchors.right: editbg.right + anchors.verticalCenter: editbg.verticalCenter } } } diff --git a/src/gui-qml/src/components/SearchScreen.qml b/src/gui-qml/src/components/SearchScreen.qml index cca13e9a4..834b4b3aa 100644 --- a/src/gui-qml/src/components/SearchScreen.qml +++ b/src/gui-qml/src/components/SearchScreen.qml @@ -21,7 +21,7 @@ Page { if (tag) { textFieldSearch.text = tag } - backend.search(site, textFieldSearch.text, page) + backend.search(site, textFieldSearch.text, page, textFieldPostFiltering.text) } header: ToolBar { @@ -66,6 +66,23 @@ Page { spacing: 0 anchors.fill: parent + Rectangle { + Layout.fillWidth: true + border.width: 1 + border.color: "#666" + height: 40 + visible: textFieldSearch.isOpen + + SearchEdit { + id: textFieldPostFiltering + placeholderText: "Post-filters" + anchors.fill: parent + anchors.margins: 8 + + onEnterPressed: searchTab.load() + } + } + ResultsView { results: searchTab.results thumbnailHeightToWidthRatio: gSettings.resultsLayoutType.value === "flow" ? 0 : gSettings.resultsHeightToWidthRatio.value diff --git a/src/gui-qml/src/main-screen.cpp b/src/gui-qml/src/main-screen.cpp index 7c9bfaa85..ed3336a48 100644 --- a/src/gui-qml/src/main-screen.cpp +++ b/src/gui-qml/src/main-screen.cpp @@ -53,13 +53,13 @@ void MainScreen::refreshSources() emit sourcesChanged(); } -void MainScreen::search(const QString &siteUrl, const QString &query, int pageNumber) +void MainScreen::search(const QString &siteUrl, const QString &query, int pageNumber, const QString &postFilter) { m_query = query; emit queryChanged(); Site *site = m_profile->getSites().value(siteUrl); - Page *page = new Page(m_profile, site, m_profile->getSites().values(), query.split(' '), pageNumber, IMAGES_PER_PAGE, {}, false, this); + Page *page = new Page(m_profile, site, m_profile->getSites().values(), query.split(' '), pageNumber, IMAGES_PER_PAGE, postFilter.split(' '), false, this); QEventLoop loop; QObject::connect(page, &Page::finishedLoading, &loop, &QEventLoop::quit); diff --git a/src/gui-qml/src/main-screen.h b/src/gui-qml/src/main-screen.h index 856628394..76fd88c90 100644 --- a/src/gui-qml/src/main-screen.h +++ b/src/gui-qml/src/main-screen.h @@ -33,7 +33,7 @@ class MainScreen : public QObject QString settingsFileName() const; public slots: - void search(const QString &site, const QString &query, int page); + void search(const QString &site, const QString &query, int page, const QString &postFilter); void newLog(const QString &message); void downloadImage(const QSharedPointer &image); QString addSite(const QString &type, const QString &host, bool https); diff --git a/src/gui-qml/src/qml.qrc b/src/gui-qml/src/qml.qrc index d01de42cb..362a46f07 100644 --- a/src/gui-qml/src/qml.qrc +++ b/src/gui-qml/src/qml.qrc @@ -35,5 +35,6 @@ components/settings/items/RadioSetting.qml components/ResultsView.qml components/settings/pages/SourcesSettingsPage.qml + components/SearchEdit.qml