Handle tagging (optional) in the main window
The include may be off but at the moment KFileMetaData is borked..
This commit is contained in:
parent
4955cc93bd
commit
a35b9520e5
2 changed files with 20 additions and 6 deletions
|
@ -45,6 +45,10 @@
|
|||
#include <KIO/FileCopyJob>
|
||||
#include <KIO/MimetypeJob>
|
||||
|
||||
#ifdef WITH_KFILEMETADATA
|
||||
#include <KFileMetaData/kfilemetadata/usermetadata.h>
|
||||
#endif
|
||||
|
||||
// Own
|
||||
|
||||
#include "libdanbooru/danbooruservice.h"
|
||||
|
@ -212,8 +216,8 @@ DanbooruMainWindow::DanbooruMainWindow(QWidget *parent)
|
|||
|
||||
});
|
||||
|
||||
connect(m_view->rootObject(), SIGNAL(downloadRequested(const QUrl&)), this,
|
||||
SLOT(slotHandleDownload(const QUrl&)));
|
||||
connect(m_view->rootObject(), SIGNAL(downloadRequested(const QUrl&, QVariant)), this,
|
||||
SLOT(slotHandleDownload(const QUrl&, QVariant)));
|
||||
|
||||
connect(m_tagWidget, &QListView::doubleClicked, this, &DanbooruMainWindow::searchTag);
|
||||
|
||||
|
@ -457,7 +461,10 @@ void DanbooruMainWindow::optionsPreferences()
|
|||
dialog->show();
|
||||
}
|
||||
|
||||
void DanbooruMainWindow::slotHandleDownload(const QUrl &url) {
|
||||
void DanbooruMainWindow::slotHandleDownload(const QUrl &url, const QVariant tags) {
|
||||
|
||||
|
||||
QStringList tagList = tags.toStringList();
|
||||
|
||||
QFileDialog saveDialog(this);
|
||||
saveDialog.setFileMode(QFileDialog::AnyFile);
|
||||
|
@ -487,11 +494,18 @@ void DanbooruMainWindow::slotHandleDownload(const QUrl &url) {
|
|||
|
||||
KIO::FileCopyJob *job = KIO::file_copy(url, localFile, -1, KIO::DefaultFlags);
|
||||
|
||||
connect(job, &KIO::Job::result, [this](KJob *job) {
|
||||
connect(job, &KIO::Job::result, [this, localFile, tagList](KJob *job) {
|
||||
|
||||
if (job->error()) {
|
||||
return;
|
||||
}
|
||||
// TODO: Tagging
|
||||
|
||||
#ifdef WITH_KFILEMETADATA
|
||||
qDebug() << "Local file" << localFile.toLocalFile();
|
||||
KFileMetaData::UserMetaData meta(localFile.toLocalFile());
|
||||
meta.setTags(tagList);
|
||||
#endif
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ private Q_SLOTS:
|
|||
void downloadPosts();
|
||||
void optionsPreferences();
|
||||
void loadSettings();
|
||||
void slotHandleDownload(const QUrl &url);
|
||||
void slotHandleDownload(const QUrl &url, QVariant tags);
|
||||
void searchTag(const QModelIndex &index);
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue