Add support for pool retrieval
This commit is contained in:
		
					parent
					
						
							
								ca5ee8b192
							
						
					
				
			
			
				commit
				
					
						8570cd6d80
					
				
			
		
					 2 changed files with 51 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -5,7 +5,7 @@
 | 
			
		|||
    <text>Main Toolbar</text>
 | 
			
		||||
      <Action name="connect" />
 | 
			
		||||
      <Action name="fetch" />
 | 
			
		||||
      <Action name="batchDownload" />
 | 
			
		||||
      <Action name="find" />
 | 
			
		||||
      <Action name="poolDownload" />
 | 
			
		||||
      <Action name="tagDisplay" />
 | 
			
		||||
      <ActionList name="dynamicActionlist" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,6 +35,7 @@
 | 
			
		|||
#include <KLocalizedString>
 | 
			
		||||
#include <KDeclarative/KDeclarative>
 | 
			
		||||
#include <KConfigDialog>
 | 
			
		||||
#include <KToggleAction>
 | 
			
		||||
 | 
			
		||||
#include "libdanbooru/danbooruservice.h"
 | 
			
		||||
#include "libdanbooru/danboorupost.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -109,10 +110,10 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
			
		|||
    dockWidget->setWidget(m_tableView);
 | 
			
		||||
    dockWidget->setObjectName("PoolView");
 | 
			
		||||
    // Prevent the use of winId() when detached, leads to QQuickWidget bugs
 | 
			
		||||
    dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
 | 
			
		||||
    dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
 | 
			
		||||
    addDockWidget(Qt::BottomDockWidgetArea, dockWidget);
 | 
			
		||||
    dockWidget->show();
 | 
			
		||||
    m_tableView->show();
 | 
			
		||||
    m_tableView->hide();
 | 
			
		||||
    dockWidget->hide();
 | 
			
		||||
 | 
			
		||||
    // then, setup our actions
 | 
			
		||||
    setupActions();
 | 
			
		||||
| 
						 | 
				
			
			@ -135,7 +136,12 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        actionCollection()->action(QLatin1String("fetch"))->setEnabled(true);
 | 
			
		||||
        actionCollection()->action(QLatin1String("find"))->setEnabled(true);
 | 
			
		||||
        actionCollection()->action(QLatin1String("poolDownload"))->setEnabled(true);
 | 
			
		||||
 | 
			
		||||
        m_view->rootObject()->setProperty("poolMode", QVariant(false));
 | 
			
		||||
        m_connectWidget->hide();
 | 
			
		||||
        m_service->setPostTags(QStringList());
 | 
			
		||||
        m_service->getPostList();
 | 
			
		||||
 | 
			
		||||
    });
 | 
			
		||||
| 
						 | 
				
			
			@ -161,6 +167,11 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
 | 
			
		|||
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    connect(dockWidget, &QDockWidget::visibilityChanged, [this](bool visible) {
 | 
			
		||||
        actionCollection()->action(QLatin1String("poolDownload"))->setChecked(visible);
 | 
			
		||||
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DanbooruMainWindow::~DanbooruMainWindow()
 | 
			
		||||
| 
						 | 
				
			
			@ -188,19 +199,51 @@ void DanbooruMainWindow::setupActions()
 | 
			
		|||
 | 
			
		||||
    QAction *fetchAction = new QAction(QIcon::fromTheme(QLatin1String("download")),
 | 
			
		||||
                                       i18n("Download"), this);
 | 
			
		||||
    QAction *findAction = new QAction(QIcon::fromTheme(QLatin1String("edit-find")),
 | 
			
		||||
                                      i18n("Search"), this);
 | 
			
		||||
    KToggleAction *poolAction = new KToggleAction(QIcon::fromTheme(QLatin1String("image-x-generic")),
 | 
			
		||||
                                                  i18n("Pools"), this);
 | 
			
		||||
 | 
			
		||||
    fetchAction->setEnabled(false);
 | 
			
		||||
    findAction->setEnabled(false);
 | 
			
		||||
    poolAction->setEnabled(false);
 | 
			
		||||
 | 
			
		||||
    actionCollection()->addAction(QLatin1String("connect"), connectAction);
 | 
			
		||||
    actionCollection()->addAction(QLatin1String("fetch"), fetchAction);
 | 
			
		||||
    actionCollection()->addAction(QLatin1String("find"), findAction);
 | 
			
		||||
    actionCollection()->addAction(QLatin1String("poolDownload"), poolAction);
 | 
			
		||||
 | 
			
		||||
    actionCollection()->setDefaultShortcut(connectAction, KStandardShortcut::Open);
 | 
			
		||||
    actionCollection()->setDefaultShortcut(fetchAction, KStandardShortcut::Find);
 | 
			
		||||
    actionCollection()->setDefaultShortcut(findAction, KStandardShortcut::Find);
 | 
			
		||||
    // actionCollection()->removeAction(actionCollection()->action("help_contents"));
 | 
			
		||||
 | 
			
		||||
    KStandardAction::quit(qApp, SLOT(quit()), actionCollection());
 | 
			
		||||
    KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
 | 
			
		||||
 | 
			
		||||
    connect(connectAction, &QAction::triggered, this, &DanbooruMainWindow::connectToBoard);
 | 
			
		||||
    connect(fetchAction, &QAction::triggered, this, &DanbooruMainWindow::downloadPosts);
 | 
			
		||||
    connect(poolAction, &KToggleAction::toggled, [this](bool checked) {
 | 
			
		||||
        if (!m_service) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        QDockWidget* dockWidget = findChild<QDockWidget*>(QLatin1String("PoolView"));
 | 
			
		||||
 | 
			
		||||
        if (checked) {
 | 
			
		||||
 | 
			
		||||
            if (m_poolModel->rowCount() == 0) {
 | 
			
		||||
                m_service->getPoolList();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            dockWidget->show();
 | 
			
		||||
            m_tableView->show();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        } else {
 | 
			
		||||
            dockWidget->hide();
 | 
			
		||||
            m_tableView->hide();
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -224,7 +267,9 @@ void DanbooruMainWindow::downloadPosts()
 | 
			
		|||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    m_service->getPoolList();
 | 
			
		||||
    m_service->setPostTags(QStringList());
 | 
			
		||||
    m_view->rootObject()->setProperty("poolMode", QVariant(false));
 | 
			
		||||
    m_service->getPostList();
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue