diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6fb6e25..1a2d0e9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -42,6 +42,7 @@ target_link_libraries(danbooru_client PUBLIC Qt5::Qml Qt5::QuickWidgets KF5::CoreAddons + KF5::TextWidgets KF5::IconThemes KF5::Completion KF5::I18n diff --git a/src/danboorusearchwidget.cpp b/src/danboorusearchwidget.cpp index c2334ca..fbf384c 100644 --- a/src/danboorusearchwidget.cpp +++ b/src/danboorusearchwidget.cpp @@ -31,6 +31,12 @@ DanbooruSearchWidget::DanbooruSearchWidget(QWidget *parent): QWidget(parent) tagLineEdit->setPlaceholderText(i18n("Type search tags.")); tagLineEdit->setToolTip(i18n("Type search tags. An empty string searches all posts.")); + widthSpinBox->setSuffix(ki18np(" pixel", " pixels")); + heightSpinBox->setSuffix(ki18np(" pixel", " pixels")); + + widthSpinBox->setValue(0); + heightSpinBox->setValue(0); + connect(searchButton, &QPushButton::clicked, this, &DanbooruSearchWidget::accept); connect(tagLineEdit, &QLineEdit::returnPressed, this, &DanbooruSearchWidget::accept); @@ -49,11 +55,24 @@ QStringList DanbooruSearchWidget::selectedTags() const return m_tags; } +unsigned int DanbooruSearchWidget::selectedWidth() const +{ + return m_width; +} + +unsigned int DanbooruSearchWidget::selectedHeight() const +{ + return m_height; +} + + void DanbooruSearchWidget::accept() { m_tags = tagLineEdit->text().split(QStringLiteral(",")); + m_width = widthSpinBox->value(); + m_height = heightSpinBox->value(); Q_EMIT(accepted()); } -} // namespace Danbooru \ No newline at end of file +} // namespace Danbooru diff --git a/src/danboorusearchwidget.h b/src/danboorusearchwidget.h index badf374..e83d0df 100644 --- a/src/danboorusearchwidget.h +++ b/src/danboorusearchwidget.h @@ -34,9 +34,13 @@ public: explicit DanbooruSearchWidget(QWidget *parent = 0); ~DanbooruSearchWidget(); QStringList selectedTags() const; + unsigned int selectedWidth() const; + unsigned int selectedHeight() const; private: QStringList m_tags; + unsigned int m_width; + unsigned int m_height; private Q_SLOTS: void accept(); @@ -49,4 +53,4 @@ Q_SIGNALS: } // namespace Danbooru -#endif \ No newline at end of file +#endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6f71299..392cf02 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -202,7 +202,11 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent) QDockWidget *searchDockWidget = findChild(QStringLiteral("SearchView")); searchDockWidget->hide(); - handlePostDownload(m_searchWidget->selectedTags(), true /* relatedTags */); + handlePostDownload(m_searchWidget->selectedTags(), + true /* relatedTags */, + m_searchWidget->selectedWidth() /* minimumWidth */, + m_searchWidget->selectedHeight() /* minimumHeight */ + ); }); @@ -584,12 +588,21 @@ void DanbooruMainWindow::clearModels() } -void DanbooruMainWindow::handlePostDownload(const QStringList &tags, bool relatedTags) +void DanbooruMainWindow::handlePostDownload(const QStringList &tags, bool relatedTags, + unsigned int minimumWidth, unsigned int minimumHeight) { clearModels(); m_view->rootObject()->setProperty("poolMode", QVariant(false)); m_service->setPostTags(tags); + if (minimumWidth > 0) { + m_service->setMinimumWidth(minimumWidth); + } + + if (minimumHeight > 0) { + m_service->setMinimumHeight(minimumHeight); + } + if (relatedTags) { m_service->getRelatedTags(tags); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 8792c8f..2270704 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -90,7 +90,8 @@ private: void setupDockWidgets(); void setupConnections(); void clearModels(); - void handlePostDownload(const QStringList &tags = QStringList(), bool relatedTags = false); + void handlePostDownload(const QStringList &tags = QStringList(), bool relatedTags = false, + unsigned int minimumWidth = 0, unsigned int minimumHeight = 0); private Q_SLOTS: void connectToBoard(); diff --git a/src/ui/searchwidget.ui b/src/ui/searchwidget.ui index 9dcb5c9..38a9577 100644 --- a/src/ui/searchwidget.ui +++ b/src/ui/searchwidget.ui @@ -6,12 +6,12 @@ 0 0 - 387 - 45 + 371 + 160 - + 0 0 @@ -19,21 +19,76 @@ - - + + + + + Qt::Horizontal + + + + 37 + 29 + + + + + + + + Minimum height: + + + + + + + Minimum width: + + + + - + + .. true - + + + + Qt::Horizontal + + + + 37 + 29 + + + + + + + + 16834 + + + + + + + 16834 + + + + @@ -46,7 +101,20 @@ - + + + + + 0 + 0 + + + + Search + + + + @@ -62,16 +130,14 @@ - - - - Search - - - + + KPluralHandlingSpinBox + QSpinBox +
kpluralhandlingspinbox.h
+
KLineEdit QLineEdit