NOISSUE re/move some dead code and unused build system parts
This commit is contained in:
@ -86,12 +86,6 @@ SET(MULTIMC_SOURCES
|
||||
BuildConfig.h
|
||||
${PROJECT_BINARY_DIR}/BuildConfig.cpp
|
||||
|
||||
# Resource handlers and transformers
|
||||
handlers/IconResourceHandler.cpp
|
||||
handlers/IconResourceHandler.h
|
||||
handlers/WebResourceHandler.cpp
|
||||
handlers/WebResourceHandler.h
|
||||
|
||||
# GUI - general utilities
|
||||
GuiUtil.h
|
||||
GuiUtil.cpp
|
||||
|
@ -62,7 +62,6 @@
|
||||
#include <net/CacheDownload.h>
|
||||
#include <news/NewsChecker.h>
|
||||
#include <notifications/NotificationChecker.h>
|
||||
#include <resources/Resource.h>
|
||||
#include <tools/BaseProfiler.h>
|
||||
#include <updater/DownloadTask.h>
|
||||
#include <updater/UpdateChecker.h>
|
||||
|
@ -45,9 +45,6 @@
|
||||
#include "settings/Setting.h"
|
||||
|
||||
#include "trans/TranslationDownloader.h"
|
||||
#include "resources/Resource.h"
|
||||
#include "handlers/IconResourceHandler.h"
|
||||
#include "handlers/WebResourceHandler.h"
|
||||
|
||||
#include "minecraft/ftb/FTBPlugin.h"
|
||||
|
||||
@ -347,19 +344,6 @@ void MultiMC::initIcons()
|
||||
{
|
||||
m_icons->directoryChanged(value.toString());
|
||||
});
|
||||
|
||||
//FIXME: none of this should be here.
|
||||
Resource::registerHandler<WebResourceHandler>("web");
|
||||
Resource::registerHandler<IconResourceHandler>("icon");
|
||||
|
||||
Resource::registerTransformer([](const QByteArray &data) -> QPixmap
|
||||
{
|
||||
return QPixmap::fromImage(QImage::fromData(data));
|
||||
});
|
||||
Resource::registerTransformer([](const QByteArray &data) -> QIcon
|
||||
{
|
||||
return QIcon(QPixmap::fromImage(QImage::fromData(data)));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -912,7 +896,6 @@ FAILED:
|
||||
void MultiMC::setIconTheme(const QString& name)
|
||||
{
|
||||
XdgIcon::setThemeName(name);
|
||||
IconResourceHandler::setTheme(name);
|
||||
}
|
||||
|
||||
QIcon MultiMC::getThemedIcon(const QString& name)
|
||||
|
@ -1,37 +0,0 @@
|
||||
#include "IconResourceHandler.h"
|
||||
#include <xdgicon.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
QList<std::weak_ptr<IconResourceHandler>> IconResourceHandler::m_iconHandlers;
|
||||
|
||||
IconResourceHandler::IconResourceHandler(const QString &key)
|
||||
: m_key(key)
|
||||
{
|
||||
}
|
||||
|
||||
void IconResourceHandler::setTheme(const QString &theme)
|
||||
{
|
||||
// notify everyone
|
||||
for (auto handler : m_iconHandlers)
|
||||
{
|
||||
std::shared_ptr<IconResourceHandler> ptr = handler.lock();
|
||||
if (ptr)
|
||||
{
|
||||
ptr->setResult(ptr->get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IconResourceHandler::init(std::shared_ptr<ResourceHandler> &ptr)
|
||||
{
|
||||
m_iconHandlers.append(std::dynamic_pointer_cast<IconResourceHandler>(ptr));
|
||||
// we always have a result, so lets report it now!
|
||||
setResult(get());
|
||||
}
|
||||
|
||||
QVariant IconResourceHandler::get() const
|
||||
{
|
||||
return XdgIcon::fromTheme(m_key);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <resources/ResourceHandler.h>
|
||||
|
||||
class IconResourceHandler : public ResourceHandler
|
||||
{
|
||||
public:
|
||||
explicit IconResourceHandler(const QString &key);
|
||||
|
||||
/// Sets the current theme and notifies all IconResourceHandlers of the change
|
||||
static void setTheme(const QString &theme);
|
||||
|
||||
private:
|
||||
// we need to keep track of all IconResourceHandlers so that we can update them if the theme changes
|
||||
void init(std::shared_ptr<ResourceHandler> &ptr) override;
|
||||
static QList<std::weak_ptr<IconResourceHandler>> m_iconHandlers;
|
||||
|
||||
QString m_key;
|
||||
|
||||
// the workhorse, returns QVariantMap (filename => size) for m_key/m_theme
|
||||
QVariant get() const;
|
||||
};
|
@ -1,68 +0,0 @@
|
||||
#include "WebResourceHandler.h"
|
||||
|
||||
#include "net/CacheDownload.h"
|
||||
#include "net/HttpMetaCache.h"
|
||||
#include "net/NetJob.h"
|
||||
#include "FileSystem.h"
|
||||
#include "Env.h"
|
||||
|
||||
//FIXME: wrong. needs to be done elsewhere.
|
||||
QMap<QString, NetJob *> WebResourceHandler::m_activeDownloads;
|
||||
|
||||
WebResourceHandler::WebResourceHandler(const QString &url)
|
||||
: QObject(), m_url(url)
|
||||
{
|
||||
MetaEntryPtr entry = ENV.metacache()->resolveEntry("icons", url);
|
||||
if (!entry->isStale())
|
||||
{
|
||||
setResultFromFile(entry->getFullPath());
|
||||
}
|
||||
else if (m_activeDownloads.contains(url))
|
||||
{
|
||||
NetJob *job = m_activeDownloads.value(url);
|
||||
connect(job, &NetJob::succeeded, this, &WebResourceHandler::succeeded);
|
||||
connect(job, &NetJob::failed, this, [job, this]() {setFailure(job->failReason());});
|
||||
connect(job, &NetJob::progress, this, &WebResourceHandler::progress);
|
||||
}
|
||||
else
|
||||
{
|
||||
NetJob *job = new NetJob("Icon download");
|
||||
job->addNetAction(CacheDownload::make(QUrl(url), entry));
|
||||
connect(job, &NetJob::succeeded, this, &WebResourceHandler::succeeded);
|
||||
connect(job, &NetJob::failed, this, [job, this]() {setFailure(job->failReason());});
|
||||
connect(job, &NetJob::progress, this, &WebResourceHandler::progress);
|
||||
connect(job, &NetJob::finished, job, [job](){m_activeDownloads.remove(m_activeDownloads.key(job));job->deleteLater();});
|
||||
m_activeDownloads.insert(url, job);
|
||||
job->start();
|
||||
}
|
||||
}
|
||||
|
||||
void WebResourceHandler::succeeded()
|
||||
{
|
||||
MetaEntryPtr entry = ENV.metacache()->resolveEntry("icons", m_url);
|
||||
setResultFromFile(entry->getFullPath());
|
||||
m_activeDownloads.remove(m_activeDownloads.key(qobject_cast<NetJob *>(sender())));
|
||||
}
|
||||
void WebResourceHandler::progress(qint64 current, qint64 total)
|
||||
{
|
||||
if (total == 0)
|
||||
{
|
||||
setProgress(101);
|
||||
}
|
||||
else
|
||||
{
|
||||
setProgress(current / total);
|
||||
}
|
||||
}
|
||||
|
||||
void WebResourceHandler::setResultFromFile(const QString &file)
|
||||
{
|
||||
try
|
||||
{
|
||||
setResult(FS::read(file));
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
setFailure(e.cause());
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <resources/ResourceHandler.h>
|
||||
|
||||
class NetJob;
|
||||
|
||||
class WebResourceHandler : public QObject, public ResourceHandler
|
||||
{
|
||||
public:
|
||||
explicit WebResourceHandler(const QString &url);
|
||||
|
||||
private slots:
|
||||
void succeeded();
|
||||
void progress(qint64 current, qint64 total);
|
||||
|
||||
private:
|
||||
static QMap<QString, NetJob *> m_activeDownloads;
|
||||
|
||||
QString m_url;
|
||||
|
||||
void setResultFromFile(const QString &file);
|
||||
};
|
Reference in New Issue
Block a user