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::QuickWidgets
 | 
			
		||||
                      KF5::CoreAddons
 | 
			
		||||
                      KF5::TextWidgets
 | 
			
		||||
                      KF5::IconThemes
 | 
			
		||||
                      KF5::Completion
 | 
			
		||||
                      KF5::I18n
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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,10 +55,23 @@ 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());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -202,7 +202,11 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
			
		|||
        QDockWidget *searchDockWidget = findChild<QDockWidget *>(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);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,12 +6,12 @@
 | 
			
		|||
   <rect>
 | 
			
		||||
    <x>0</x>
 | 
			
		||||
    <y>0</y>
 | 
			
		||||
    <width>387</width>
 | 
			
		||||
    <height>45</height>
 | 
			
		||||
    <width>371</width>
 | 
			
		||||
    <height>160</height>
 | 
			
		||||
   </rect>
 | 
			
		||||
  </property>
 | 
			
		||||
  <property name="sizePolicy">
 | 
			
		||||
   <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
 | 
			
		||||
   <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
 | 
			
		||||
    <horstretch>0</horstretch>
 | 
			
		||||
    <verstretch>0</verstretch>
 | 
			
		||||
   </sizepolicy>
 | 
			
		||||
| 
						 | 
				
			
			@ -19,21 +19,76 @@
 | 
			
		|||
  <property name="windowTitle">
 | 
			
		||||
   <string/>
 | 
			
		||||
  </property>
 | 
			
		||||
  <layout class="QHBoxLayout" name="horizontalLayout">
 | 
			
		||||
   <item>
 | 
			
		||||
  <layout class="QGridLayout" name="gridLayout">
 | 
			
		||||
   <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">
 | 
			
		||||
     <property name="text">
 | 
			
		||||
      <string/>
 | 
			
		||||
     </property>
 | 
			
		||||
     <property name="icon">
 | 
			
		||||
      <iconset theme="dialog-close"/>
 | 
			
		||||
      <iconset theme="dialog-close">
 | 
			
		||||
       <normaloff>.</normaloff>.</iconset>
 | 
			
		||||
     </property>
 | 
			
		||||
     <property name="flat">
 | 
			
		||||
      <bool>true</bool>
 | 
			
		||||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </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">
 | 
			
		||||
     <property name="sizePolicy">
 | 
			
		||||
      <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
 | 
			
		||||
| 
						 | 
				
			
			@ -46,7 +101,20 @@
 | 
			
		|||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </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">
 | 
			
		||||
     <property name="sizePolicy">
 | 
			
		||||
      <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
 | 
			
		||||
| 
						 | 
				
			
			@ -62,16 +130,14 @@
 | 
			
		|||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </item>
 | 
			
		||||
   <item>
 | 
			
		||||
    <widget class="QPushButton" name="searchButton">
 | 
			
		||||
     <property name="text">
 | 
			
		||||
      <string>Search</string>
 | 
			
		||||
     </property>
 | 
			
		||||
    </widget>
 | 
			
		||||
   </item>
 | 
			
		||||
  </layout>
 | 
			
		||||
 </widget>
 | 
			
		||||
 <customwidgets>
 | 
			
		||||
  <customwidget>
 | 
			
		||||
   <class>KPluralHandlingSpinBox</class>
 | 
			
		||||
   <extends>QSpinBox</extends>
 | 
			
		||||
   <header>kpluralhandlingspinbox.h</header>
 | 
			
		||||
  </customwidget>
 | 
			
		||||
  <customwidget>
 | 
			
		||||
   <class>KLineEdit</class>
 | 
			
		||||
   <extends>QLineEdit</extends>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue