Skip to content

Commit

Permalink
Version 6.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jun 14, 2018
2 parents 2e07d6f + ffeb479 commit 060cda7
Show file tree
Hide file tree
Showing 59 changed files with 1,201 additions and 1,015 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endif()
project(Grabber)
set(USE_SSL 1)

add_definitions(-DVERSION="6.0.2")
add_definitions(-DVERSION="6.0.3")
add_definitions(-DPROJECT_WEBSITE_URL="https://bionus.github.io/imgbrd-grabber/")
add_definitions(-DPROJECT_GITHUB_URL="https://github.com/Bionus/imgbrd-grabber")
add_definitions(-DSOURCE_ISSUES_URL="https://raw.githubusercontent.com/wiki/Bionus/imgbrd-grabber/SourceIssues.md")
Expand Down
32 changes: 16 additions & 16 deletions gui/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ void mainWindow::parseArgs(const QStringList &args, const QMap<QString, QString>
{
// Load an IGL file
QFileInfo info(args[0]);
if (info.suffix() == QStringLiteral("igl"))
if (info.suffix() == QLatin1String("igl"))
{
loadLinkList(info.absoluteFilePath());
m_forcedTab = m_tabs.size() + 1;
Expand Down Expand Up @@ -1240,7 +1240,7 @@ void mainWindow::getAll(bool all)
}
else
{
for (const DownloadQueryImage &batch : m_batchs)
for (const DownloadQueryImage &batch : qAsConst(m_batchs))
{
if (batch.values.value("file_url").isEmpty())
{
Expand Down Expand Up @@ -1314,7 +1314,7 @@ void mainWindow::getAllLogin()

m_getAllLogins.clear();
QQueue<Site*> logins;
for (Downloader *downloader : m_downloaders)
for (Downloader *downloader : qAsConst(m_downloaders))
{
for (Site *site : downloader->getSites())
{
Expand Down Expand Up @@ -1435,7 +1435,7 @@ void mainWindow::getAllGetPages()

int max = 0;
int packSize = 0;
for (Downloader *downloader : m_downloaders)
for (Downloader *downloader : qAsConst(m_downloaders))
{
downloader->getImages();
max += downloader->pagesCount();
Expand Down Expand Up @@ -1516,7 +1516,7 @@ void mainWindow::getAllImages()
m_progressDialog->clearImages();
m_progressDialog->setText(tr("Preparing images, please wait..."));
m_progressDialog->setCount(m_getAllRemaining.count());
for (const BatchDownloadImage &download : m_getAllRemaining)
for (const BatchDownloadImage &download : qAsConst(m_getAllRemaining))
{
int siteId = download.siteId(m_groupBatchs);
QSharedPointer<Image> img = download.image;
Expand Down Expand Up @@ -1771,7 +1771,7 @@ void mainWindow::getAllPerformTags()
log(QStringLiteral("Tags received"), Logger::Info);

const BatchDownloadImage *downloadPtr = Q_NULLPTR;
for (const BatchDownloadImage &i : m_getAllDownloading)
for (const BatchDownloadImage &i : qAsConst(m_getAllDownloading))
if (i.image.data() == sender())
downloadPtr = &i;
if (downloadPtr == Q_NULLPTR)
Expand Down Expand Up @@ -1877,7 +1877,7 @@ void mainWindow::getAllGetImageSaved(QSharedPointer<Image> img, QMap<QString, Im

// Find related download query
const BatchDownloadImage *downloadPtr = Q_NULLPTR;
for (const BatchDownloadImage &i : m_getAllDownloading)
for (const BatchDownloadImage &i : qAsConst(m_getAllDownloading))
if (i.image == img)
downloadPtr = &i;
if (downloadPtr == Q_NULLPTR)
Expand Down Expand Up @@ -1911,7 +1911,7 @@ void mainWindow::getAllGetImageSaved(QSharedPointer<Image> img, QMap<QString, Im
isDriveFull = storage.isValid() && (storage.bytesAvailable() < img->fileSize() || storage.bytesAvailable() < 20 * 1024 * 1024);
QString rootPath = storage.rootPath();
#ifdef Q_OS_WIN
drive = QString("%1 (%2)").arg(storage.name(), rootPath.endsWith("/") ? rootPath.left(rootPath.length() - 1) : rootPath);
drive = QStringLiteral("%1 (%2)").arg(storage.name(), rootPath.endsWith("/") ? rootPath.left(rootPath.length() - 1) : rootPath);
#else
drive = rootPath;
#endif
Expand Down Expand Up @@ -1951,12 +1951,12 @@ void mainWindow::getAllCancel()
{
log(QStringLiteral("Cancelling downloads..."), Logger::Info);
m_progressDialog->cancel();
for (const BatchDownloadImage &download : m_getAllDownloading)
for (const BatchDownloadImage &download : qAsConst(m_getAllDownloading))
{
download.image->abortTags();
download.image->abortImage();
}
for (Downloader *downloader : m_downloaders)
for (Downloader *downloader : qAsConst(m_downloaders))
{
downloader->cancel();
}
Expand All @@ -1970,7 +1970,7 @@ void mainWindow::getAllSkip()
log(QStringLiteral("Skipping downloads..."), Logger::Info);

int count = m_getAllDownloading.count();
for (const BatchDownloadImage &download : m_getAllDownloading)
for (const BatchDownloadImage &download : qAsConst(m_getAllDownloading))
{
download.image->abortTags();
download.image->abortImage();
Expand Down Expand Up @@ -2085,7 +2085,7 @@ void mainWindow::getAllPause()
if (m_progressDialog->isPaused())
{
log(QStringLiteral("Pausing downloads..."), Logger::Info);
for (const auto &download : m_getAllDownloading)
for (const auto &download : qAsConst(m_getAllDownloading))
{
download.image->abortTags();
download.image->abortImage();
Expand All @@ -2095,7 +2095,7 @@ void mainWindow::getAllPause()
else
{
log(QStringLiteral("Recovery of downloads..."), Logger::Info);
for (const auto &download : m_getAllDownloading)
for (const auto &download : qAsConst(m_getAllDownloading))
{
getAllGetImage(download, download.siteId(m_groupBatchs));
}
Expand Down Expand Up @@ -2138,7 +2138,7 @@ void mainWindow::on_buttonSaveLinkList_clicked()
{ return; }

save = QDir::toNativeSeparators(save);
m_settings->setValue("linksLastDir", save.section(QDir::toNativeSeparators("/"), 0, -2));
m_settings->setValue("linksLastDir", save.section(QDir::separator(), 0, -2));

if (saveLinkList(save))
{ QMessageBox::information(this, tr("Save link list"), tr("Link list saved successfully!")); }
Expand Down Expand Up @@ -2172,11 +2172,11 @@ bool mainWindow::loadLinkList(const QString &filename)
log(tr("Loading %n download(s)", "", newBatchs.count() + newGroupBatchs.count()), Logger::Info);

m_allow = false;
for (const auto &queryImage : newBatchs)
for (const auto &queryImage : qAsConst(newBatchs))
{
batchAddUnique(queryImage, false);
}
for (auto queryGroup : newGroupBatchs)
for (auto queryGroup : qAsConst(newGroupBatchs))
{
ui->tableBatchGroups->setRowCount(ui->tableBatchGroups->rowCount() + 1);
QString last = queryGroup.unk;
Expand Down
2 changes: 2 additions & 0 deletions gui/src/settings/filenamewindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "settings/filenamewindow.h"
#include <QDesktopServices>
#include <QRegExp>
#include <QRegularExpression>
#include <ui_filenamewindow.h>
#include "models/filename.h"
#include "models/image.h"
Expand Down
24 changes: 11 additions & 13 deletions gui/src/sources/sitewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SiteWindow::SiteWindow(Profile *profile, QWidget *parent)
ui->checkBox->setChecked(true);

m_sources = profile->getSources().values();
for (Source *source : m_sources)
for (Source *source : qAsConst(m_sources))
{
ui->comboBox->addItem(QIcon(source->getPath() + "/icon.png"), source->getName());
}
Expand Down Expand Up @@ -64,7 +64,7 @@ void SiteWindow::accept()
}

Source *src = nullptr;
for (Source *source : m_sources)
for (Source *source : qAsConst(m_sources))
{
if (source->getName() == ui->comboBox->currentText())
{
Expand All @@ -77,21 +77,19 @@ void SiteWindow::accept()

void SiteWindow::finish(Source *src)
{
if (ui->checkBox->isChecked())
if (src == nullptr)
{
error(this, tr("Unable to guess site's type. Are you sure about the url?"));
ui->comboBox->setDisabled(false);
ui->checkBox->setChecked(false);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
ui->progressBar->hide();

if (src == nullptr)
{
error(this, tr("Unable to guess site's type. Are you sure about the url?"));
ui->comboBox->setDisabled(false);
ui->checkBox->setChecked(false);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
ui->progressBar->hide();
return;
}
return;
}

if (ui->checkBox->isChecked())
{ ui->progressBar->hide(); }

// Remove unnecessary prefix
bool ssl = false;
if (m_url.startsWith("http://"))
Expand Down
2 changes: 1 addition & 1 deletion gui/src/sources/sourcessettingswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void SourcesSettingsWindow::loginTested(Site*, Site::LoginResult result)

void SourcesSettingsWindow::setLoginStatus(const QString &msg)
{
QString italic = QString("<i>%1</li>").arg(msg);
QString italic = QStringLiteral("<i>%1</li>").arg(msg);
ui->labelTestCredentials->setText(italic);
ui->labelTestLogin->setText(italic);
}
Expand Down
3 changes: 2 additions & 1 deletion gui/src/sources/sourceswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void sourcesWindow::checkUpdate()
{
bool oneChecked = false;
bool oneUnchecked = false;
for (QCheckBox *check : m_checks)
for (QCheckBox *check : qAsConst(m_checks))
{
if (check->isChecked())
{ oneChecked = true; }
Expand Down Expand Up @@ -438,6 +438,7 @@ void sourcesWindow::editPreset()
void sourcesWindow::savePreset()
{
const QList<Site*> &selectedSites = selected();

QStringList sel;
sel.reserve(selectedSites.count());
for (Site *site : selectedSites)
Expand Down
2 changes: 1 addition & 1 deletion gui/src/tabs/favorites-tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void favoritesTab::getAll()
int imageCount = page->imagesCount();
int total = imageCount > 0 ? qMax(currentCount, imageCount) : (highLimit > 0 ? highLimit : currentCount);
int perPage = highLimit > 0 ? (imageCount > 0 ? qMin(highLimit, imageCount) : highLimit) : currentCount;
if (perPage == 0 && total == 0)
if ((perPage == 0 && total == 0) || (currentCount == 0 && imageCount <= 0))
continue;

QString search = m_currentTags + " " + m_settings->value("add").toString().toLower().trimmed();
Expand Down
4 changes: 2 additions & 2 deletions gui/src/tabs/pool-tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ QList<Site*> poolTab::loadSites() const

void poolTab::write(QJsonObject &json) const
{
json["type"] = QString("pool");
json["type"] = QStringLiteral("pool");
json["pool"] = ui->spinPool->value();
json["site"] = ui->comboSites->currentText();
json["tags"] = QJsonArray::fromStringList(m_search->toPlainText().split(' ', QString::SkipEmptyParts));
Expand Down Expand Up @@ -158,7 +158,7 @@ void poolTab::getAll()
int imageCount = page->imagesCount();
int total = imageCount > 0 ? qMax(currentCount, imageCount) : (highLimit > 0 ? highLimit : currentCount);
int perPage = highLimit > 0 ? (imageCount > 0 ? qMin(highLimit, imageCount) : highLimit) : currentCount;
if (perPage == 0 && total == 0)
if ((perPage == 0 && total == 0) || (currentCount == 0 && imageCount <= 0))
return;

QString search = "pool:"+QString::number(ui->spinPool->value())+" "+m_search->toPlainText()+" "+m_settings->value("add").toString().trimmed();
Expand Down
18 changes: 9 additions & 9 deletions gui/src/tabs/search-tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@ void searchTab::finishedLoading(Page* page)
m_images.append(imgs);

int maxPage = page->pagesCount();
if (maxPage < m_pagemax || m_pagemax == -1)
if (maxPage > m_pagemax || m_pagemax == -1)
m_pagemax = maxPage;
ui_buttonNextPage->setEnabled(maxPage > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1 || (page->imagesCount() == 0 && page->images().count() > 0));
ui_buttonLastPage->setEnabled(maxPage > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1);
ui_buttonNextPage->setEnabled(m_pagemax > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1 || (page->imagesCount() == 0 && page->images().count() > 0));
ui_buttonLastPage->setEnabled(m_pagemax > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1);

addResultsPage(page, imgs, merged);

Expand Down Expand Up @@ -472,10 +472,10 @@ void searchTab::finishedLoadingTags(Page *page)
}

int maxPage = page->pagesCount();
if (maxPage < m_pagemax || m_pagemax == -1)
if (maxPage > m_pagemax || m_pagemax == -1)
m_pagemax = maxPage;
ui_buttonNextPage->setEnabled(maxPage > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1 || (page->imagesCount() == 0 && page->images().count() > 0));
ui_buttonLastPage->setEnabled(maxPage > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1);
ui_buttonNextPage->setEnabled(m_pagemax > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1 || (page->imagesCount() == 0 && page->images().count() > 0));
ui_buttonLastPage->setEnabled(m_pagemax > ui_spinPage->value() || page->imagesCount() == -1 || page->pagesCount() == -1);

// Update image and page count
QList<QSharedPointer<Image>> imgs;
Expand Down Expand Up @@ -602,7 +602,7 @@ double getImageKnownTagProportion(const QSharedPointer<Image> &img)
int known = 0;
for (const Tag &tag : img->tags())
{
if (tag.type().name() != QStringLiteral("unknown"))
if (tag.type().name() != QLatin1String("unknown"))
known++;
}

Expand Down Expand Up @@ -957,7 +957,7 @@ void searchTab::contextSaveImageAs(int position)
if (!path.isEmpty())
{
path = QDir::toNativeSeparators(path);
m_settings->setValue("Zoom/lastDir", path.section(QDir::toNativeSeparators("/"), 0, -2));
m_settings->setValue("Zoom/lastDir", path.section(QDir::separator(), 0, -2));

if (!tmpPath.isEmpty())
{ QFile::rename(tmpPath, path); }
Expand Down Expand Up @@ -1426,7 +1426,7 @@ bool searchTab::validateImage(const QSharedPointer<Image> &img, QString &error)
QStringList detected = PostFilter::blacklisted(img->tokens(m_profile), m_profile->getBlacklist());
if (!detected.isEmpty() && m_settings->value("hideblacklisted", false).toBool())
{
error = QString("Image #%1 ignored. Reason: %2.").arg(img->id()).arg("\""+detected.join(", ")+"\"");
error = QStringLiteral("Image #%1 ignored. Reason: %2.").arg(img->id()).arg("\""+detected.join(", ")+"\"");
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions gui/src/tabs/tag-tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void tagTab::load()

void tagTab::write(QJsonObject &json) const
{
json["type"] = QString("tag");
json["type"] = QStringLiteral("tag");
json["tags"] = QJsonArray::fromStringList(m_search->toPlainText().split(' ', QString::SkipEmptyParts));
json["page"] = ui->spinPage->value();
json["perpage"] = ui->spinImagesPerPage->value();
Expand Down Expand Up @@ -213,7 +213,7 @@ void tagTab::getAll()
int imageCount = page->imagesCount();
int total = imageCount > 0 ? qMax(currentCount, imageCount) : (highLimit > 0 ? highLimit : currentCount);
int perPage = highLimit > 0 ? (imageCount > 0 ? qMin(highLimit, imageCount) : highLimit) : currentCount;
if (perPage == 0 && total == 0)
if ((perPage == 0 && total == 0) || (currentCount == 0 && imageCount <= 0))
continue;

QString search = page->search().join(' ');
Expand Down
2 changes: 1 addition & 1 deletion gui/src/tag-context-menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void TagContextMenu::copyAllTagsToClipboard()
{
QStringList tags;
tags.reserve(m_allTags.count());
for (const Tag &tag : m_allTags)
for (const Tag &tag : qAsConst(m_allTags))
tags.append(tag.text());

QApplication::clipboard()->setText(tags.join(' '));
Expand Down
2 changes: 1 addition & 1 deletion gui/src/utils/md5-fix/md5-fix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void md5Fix::on_buttonStart_clicked()
{
pos += 4;
reg.replace(regx.cap(0), "(.+)");
if (regx.cap(1) == "md5")
if (regx.cap(1) == QLatin1String("md5"))
{ id = cur; }
cur++;
}
Expand Down
2 changes: 1 addition & 1 deletion gui/src/utils/rename-existing/rename-existing-1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void RenameExisting1::on_buttonContinue_clicked()
{
pos += regx.matchedLength();
reg.replace(regx.cap(0), QStringLiteral("(.+)"));
if (regx.cap(1) == QStringLiteral("md5"))
if (regx.cap(1) == QLatin1String("md5"))
{ id = cur; }
cur++;
}
Expand Down
8 changes: 4 additions & 4 deletions gui/src/viewer/zoom-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void ZoomWindow::go()
m_resizeTimer = timer;

QString pos = m_settings->value("tagsposition", "top").toString();
if (pos == QStringLiteral("auto"))
if (pos == QLatin1String("auto"))
{
if (!m_image->size().isEmpty())
{
Expand All @@ -165,7 +165,7 @@ void ZoomWindow::go()
{ pos = QStringLiteral("top"); }
}

if (pos == QStringLiteral("top"))
if (pos == QLatin1String("top"))
{
ui->widgetLeft->hide();
m_labelTagsTop->show();
Expand Down Expand Up @@ -265,7 +265,7 @@ void ZoomWindow::openUrl(const QString &url)
{ emit linkClicked(url); }
void ZoomWindow::openPool(const QString &url)
{
if (url.startsWith(QStringLiteral("pool:")))
if (url.startsWith(QLatin1String("pool:")))
{ emit poolClicked(url.rightRef(url.length() - 5).toInt(), m_image->parentSite()->url()); }
else
{
Expand Down Expand Up @@ -687,7 +687,7 @@ void ZoomWindow::draw()
if (m_image->isVideo())
return;

QString fn = m_url.section('/', -1).toLower();
QString fn = m_url.section('/', -1).section('?', 0, 0).toLower();

// We need a filename to display animations, so we get it if we're not already loading from a file
QString filename;
Expand Down
Loading

0 comments on commit 060cda7

Please sign in to comment.