Support width and height when looking for posts
The UI needs to be improved, though.
This commit is contained in:
parent
76330d4416
commit
23d33dd5c8
6 changed files with 124 additions and 20 deletions
|
@ -42,6 +42,7 @@ target_link_libraries(danbooru_client PUBLIC
|
||||||
Qt5::Qml
|
Qt5::Qml
|
||||||
Qt5::QuickWidgets
|
Qt5::QuickWidgets
|
||||||
KF5::CoreAddons
|
KF5::CoreAddons
|
||||||
|
KF5::TextWidgets
|
||||||
KF5::IconThemes
|
KF5::IconThemes
|
||||||
KF5::Completion
|
KF5::Completion
|
||||||
KF5::I18n
|
KF5::I18n
|
||||||
|
|
|
@ -31,6 +31,12 @@ DanbooruSearchWidget::DanbooruSearchWidget(QWidget *parent): QWidget(parent)
|
||||||
|
|
||||||
tagLineEdit->setPlaceholderText(i18n("Type search tags."));
|
tagLineEdit->setPlaceholderText(i18n("Type search tags."));
|
||||||
tagLineEdit->setToolTip(i18n("Type search tags. An empty string searches all posts."));
|
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(searchButton, &QPushButton::clicked, this, &DanbooruSearchWidget::accept);
|
||||||
connect(tagLineEdit, &QLineEdit::returnPressed, this, &DanbooruSearchWidget::accept);
|
connect(tagLineEdit, &QLineEdit::returnPressed, this, &DanbooruSearchWidget::accept);
|
||||||
|
@ -49,10 +55,23 @@ QStringList DanbooruSearchWidget::selectedTags() const
|
||||||
return m_tags;
|
return m_tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int DanbooruSearchWidget::selectedWidth() const
|
||||||
|
{
|
||||||
|
return m_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int DanbooruSearchWidget::selectedHeight() const
|
||||||
|
{
|
||||||
|
return m_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DanbooruSearchWidget::accept()
|
void DanbooruSearchWidget::accept()
|
||||||
{
|
{
|
||||||
|
|
||||||
m_tags = tagLineEdit->text().split(QStringLiteral(","));
|
m_tags = tagLineEdit->text().split(QStringLiteral(","));
|
||||||
|
m_width = widthSpinBox->value();
|
||||||
|
m_height = heightSpinBox->value();
|
||||||
Q_EMIT(accepted());
|
Q_EMIT(accepted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,13 @@ public:
|
||||||
explicit DanbooruSearchWidget(QWidget *parent = 0);
|
explicit DanbooruSearchWidget(QWidget *parent = 0);
|
||||||
~DanbooruSearchWidget();
|
~DanbooruSearchWidget();
|
||||||
QStringList selectedTags() const;
|
QStringList selectedTags() const;
|
||||||
|
unsigned int selectedWidth() const;
|
||||||
|
unsigned int selectedHeight() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList m_tags;
|
QStringList m_tags;
|
||||||
|
unsigned int m_width;
|
||||||
|
unsigned int m_height;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void accept();
|
void accept();
|
||||||
|
|
|
@ -202,7 +202,11 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
||||||
QDockWidget *searchDockWidget = findChild<QDockWidget *>(QStringLiteral("SearchView"));
|
QDockWidget *searchDockWidget = findChild<QDockWidget *>(QStringLiteral("SearchView"));
|
||||||
searchDockWidget->hide();
|
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();
|
clearModels();
|
||||||
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
m_view->rootObject()->setProperty("poolMode", QVariant(false));
|
||||||
m_service->setPostTags(tags);
|
m_service->setPostTags(tags);
|
||||||
|
|
||||||
|
if (minimumWidth > 0) {
|
||||||
|
m_service->setMinimumWidth(minimumWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minimumHeight > 0) {
|
||||||
|
m_service->setMinimumHeight(minimumHeight);
|
||||||
|
}
|
||||||
|
|
||||||
if (relatedTags) {
|
if (relatedTags) {
|
||||||
m_service->getRelatedTags(tags);
|
m_service->getRelatedTags(tags);
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,8 @@ private:
|
||||||
void setupDockWidgets();
|
void setupDockWidgets();
|
||||||
void setupConnections();
|
void setupConnections();
|
||||||
void clearModels();
|
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:
|
private Q_SLOTS:
|
||||||
void connectToBoard();
|
void connectToBoard();
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>387</width>
|
<width>371</width>
|
||||||
<height>45</height>
|
<height>160</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -19,21 +19,76 @@
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="1" column="3">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>37</width>
|
||||||
|
<height>29</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLabel" name="heightLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Minimum height:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="widthLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Minimum width:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="closeButton">
|
<widget class="QPushButton" name="closeButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="dialog-close"/>
|
<iconset theme="dialog-close">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="3">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>37</width>
|
||||||
|
<height>29</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="KPluralHandlingSpinBox" name="heightSpinBox">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>16834</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="KPluralHandlingSpinBox" name="widthSpinBox">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>16834</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="tagLabel">
|
<widget class="QLabel" name="tagLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||||
|
@ -46,7 +101,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="3" column="4">
|
||||||
|
<widget class="QPushButton" name="searchButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Search</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2" colspan="3">
|
||||||
<widget class="KLineEdit" name="tagLineEdit">
|
<widget class="KLineEdit" name="tagLineEdit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
|
@ -62,16 +130,14 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="searchButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Search</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>KPluralHandlingSpinBox</class>
|
||||||
|
<extends>QSpinBox</extends>
|
||||||
|
<header>kpluralhandlingspinbox.h</header>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>KLineEdit</class>
|
<class>KLineEdit</class>
|
||||||
<extends>QLineEdit</extends>
|
<extends>QLineEdit</extends>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue