NOISSUE Various changes from multiauth that are unrelated to it

This commit is contained in:
Jan Dalheimer
2015-05-28 19:38:29 +02:00
committed by Petr Mrázek
parent 161dc66c2c
commit 3a8b238052
65 changed files with 2661 additions and 333 deletions

View File

@ -251,6 +251,8 @@ SET(MULTIMC_SOURCES
widgets/ServerStatus.h
widgets/VersionListView.cpp
widgets/VersionListView.h
widgets/ProgressWidget.h
widgets/ProgressWidget.cpp
# GUI - instance group view

View File

@ -383,6 +383,7 @@ namespace Ui {
#include "JavaCommon.h"
#include "InstancePageProvider.h"
#include "minecraft/SkinUtils.h"
#include "resources/Resource.h"
//#include "minecraft/LegacyInstance.h"
@ -1758,7 +1759,7 @@ void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session,
this->hide();
console = new ConsoleWindow(proc);
connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded()));
connect(console, &ConsoleWindow::isClosing, this, &MainWindow::instanceEnded);
proc->setHeader("MultiMC version: " + BuildConfig.printableVersionString() + "\n\n");
proc->arm();

View File

@ -40,6 +40,8 @@
#include "settings/Setting.h"
#include "trans/TranslationDownloader.h"
#include "resources/Resource.h"
#include "resources/IconResourceHandler.h"
#include "ftb/FTBPlugin.h"
@ -331,6 +333,37 @@ void MultiMC::initIcons()
{
ENV.m_icons->directoryChanged(value.toString());
});
Resource::registerTransformer([](const QVariantMap &map) -> QIcon
{
QIcon icon;
for (auto it = map.constBegin(); it != map.constEnd(); ++it)
{
icon.addFile(it.key(), QSize(it.value().toInt(), it.value().toInt()));
}
return icon;
});
Resource::registerTransformer([](const QVariantMap &map) -> QPixmap
{
QVariantList sizes = map.values();
if (sizes.isEmpty())
{
return QPixmap();
}
std::sort(sizes.begin(), sizes.end());
if (sizes.last().toInt() != -1) // only scalable available
{
return QPixmap(map.key(sizes.last()));
}
else
{
return QPixmap();
}
});
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))); });
}
@ -610,6 +643,7 @@ void MultiMC::installUpdates(const QString updateFilesDir, UpdateFlags flags)
void MultiMC::setIconTheme(const QString& name)
{
XdgIcon::setThemeName(name);
IconResourceHandler::setTheme(name);
}
QIcon MultiMC::getThemedIcon(const QString& name)

View File

@ -146,13 +146,10 @@ private slots:
private:
void initLogger();
void initIcons();
void initGlobalSettings(bool test_mode);
void initTranslations();
void initSSL();
void initSSL();
private:
friend class UpdateCheckerTest;

View File

@ -13,7 +13,6 @@ int main_gui(MultiMC &app)
mainWin.checkInstancePathForProblems();
return app.exec();
}
int main(int argc, char *argv[])
{
// initialize Qt

View File

@ -47,7 +47,7 @@
#include <minecraft/MinecraftVersion.h>
#include <minecraft/MinecraftVersionList.h>
#include "icons/IconList.h"
#include "Exception.h"
QIcon VersionPage::icon() const
{
@ -118,7 +118,7 @@ bool VersionPage::reloadMinecraftProfile()
m_inst->reloadProfile();
return true;
}
catch (MMCError &e)
catch (Exception &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
return false;
@ -199,7 +199,7 @@ void VersionPage::on_resetOrderBtn_clicked()
{
m_version->resetOrder();
}
catch (MMCError &e)
catch (Exception &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
}
@ -212,7 +212,7 @@ void VersionPage::on_moveUpBtn_clicked()
{
m_version->move(currentRow(), MinecraftProfile::MoveUp);
}
catch (MMCError &e)
catch (Exception &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
}
@ -225,7 +225,7 @@ void VersionPage::on_moveDownBtn_clicked()
{
m_version->move(currentRow(), MinecraftProfile::MoveDown);
}
catch (MMCError &e)
catch (Exception &e)
{
QMessageBox::critical(this, tr("Error"), e.cause());
}

View File

@ -21,7 +21,7 @@
#include "pages/BasePage.h"
#include "auth/MojangAccountList.h"
#include <MultiMC.h>
#include "MultiMC.h"
namespace Ui
{

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -35,6 +35,9 @@ Size=64
[256x256]
Size=256
[150x150]
Size=150
[scalable]
Size=48
Type=Scalable

View File

@ -207,6 +207,13 @@
<file>48x48/log.png</file>
<file>64x64/log.png</file>
<!-- Hour glass, CC-BY, http://findicons.com/icon/84653/hourglass?id=360551 -->
<file>16x16/hourglass.png</file>
<file>22x22/hourglass.png</file>
<file>32x32/hourglass.png</file>
<file>48x48/hourglass.png</file>
<file>150x150/hourglass.png</file>
<!-- placeholder when loading screenshot images -->
<file>scalable/screenshot-placeholder.svg</file>
</qresource>

View File

@ -0,0 +1,74 @@
// Licensed under the Apache-2.0 license. See README.md for details.
#include "ProgressWidget.h"
#include <QProgressBar>
#include <QLabel>
#include <QVBoxLayout>
#include <QEventLoop>
#include "tasks/Task.h"
ProgressWidget::ProgressWidget(QWidget *parent)
: QWidget(parent)
{
m_label = new QLabel(this);
m_label->setWordWrap(true);
m_bar = new QProgressBar(this);
m_bar->setMinimum(0);
m_bar->setMaximum(100);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(m_label);
layout->addWidget(m_bar);
layout->addStretch();
setLayout(layout);
}
void ProgressWidget::start(std::shared_ptr<Task> task)
{
if (m_task)
{
disconnect(m_task.get(), 0, this, 0);
}
m_task = task;
connect(m_task.get(), &Task::finished, this, &ProgressWidget::handleTaskFinish);
connect(m_task.get(), &Task::status, this, &ProgressWidget::handleTaskStatus);
connect(m_task.get(), &Task::progress, this, &ProgressWidget::handleTaskProgress);
connect(m_task.get(), &Task::destroyed, this, &ProgressWidget::taskDestroyed);
if (!m_task->isRunning())
{
QMetaObject::invokeMethod(m_task.get(), "start", Qt::QueuedConnection);
}
}
bool ProgressWidget::exec(std::shared_ptr<Task> task)
{
QEventLoop loop;
connect(task.get(), &Task::finished, &loop, &QEventLoop::quit);
start(task);
if (task->isRunning())
{
loop.exec();
}
return task->successful();
}
void ProgressWidget::handleTaskFinish()
{
if (!m_task->successful())
{
m_label->setText(m_task->failReason());
}
}
void ProgressWidget::handleTaskStatus(const QString &status)
{
m_label->setText(status);
}
void ProgressWidget::handleTaskProgress(qint64 current, qint64 total)
{
m_bar->setMaximum(total);
m_bar->setValue(current);
}
void ProgressWidget::taskDestroyed()
{
m_task = nullptr;
}

View File

@ -0,0 +1,32 @@
// Licensed under the Apache-2.0 license. See README.md for details.
#pragma once
#include <QWidget>
#include <memory>
class Task;
class QProgressBar;
class QLabel;
class ProgressWidget : public QWidget
{
Q_OBJECT
public:
explicit ProgressWidget(QWidget *parent = nullptr);
public slots:
void start(std::shared_ptr<Task> task);
bool exec(std::shared_ptr<Task> task);
private slots:
void handleTaskFinish();
void handleTaskStatus(const QString &status);
void handleTaskProgress(qint64 current, qint64 total);
void taskDestroyed();
private:
QLabel *m_label;
QProgressBar *m_bar;
std::shared_ptr<Task> m_task;
};