diff options
author | Ryan Cao <70191398+ryanccn@users.noreply.github.com> | 2022-05-28 21:15:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-28 21:15:00 +0800 |
commit | 2be8100e7cb625f3e6356a68f20291c5aa327c02 (patch) | |
tree | eaf364705154e0457a1bde40dff8b2c8d843c8e5 /launcher/tasks/Task.h | |
parent | 6d0ea13f97570f837f11022e3ef0fbfb6d0482f5 (diff) | |
parent | 3ff26d5cfe293c635655d35e96d093ef0b383dc2 (diff) | |
download | PrismLauncher-2be8100e7cb625f3e6356a68f20291c5aa327c02.tar.gz PrismLauncher-2be8100e7cb625f3e6356a68f20291c5aa327c02.tar.bz2 PrismLauncher-2be8100e7cb625f3e6356a68f20291c5aa327c02.zip |
Merge branch 'develop' into global-jvm-args
Diffstat (limited to 'launcher/tasks/Task.h')
-rw-r--r-- | launcher/tasks/Task.h | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/launcher/tasks/Task.h b/launcher/tasks/Task.h index 344a024e..f7765c3d 100644 --- a/launcher/tasks/Task.h +++ b/launcher/tasks/Task.h @@ -1,24 +1,40 @@ -/* Copyright 2013-2021 MultiMC Contributors +// SPDX-License-Identifier: GPL-3.0-only +/* + * PolyMC - Minecraft Launcher + * Copyright (c) 2022 flowln <flowlnlnln@gmail.com> * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2013-2021 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #pragma once -#include <QObject> -#include <QString> -#include <QStringList> - #include "QObjectPtr.h" class Task : public QObject { @@ -52,6 +68,8 @@ class Task : public QObject { virtual bool canAbort() const { return false; } + auto getState() const -> State { return m_state; } + QString getStatus() { return m_status; } virtual auto getStepStatus() const -> QString { return m_status; } @@ -68,15 +86,16 @@ class Task : public QObject { signals: void started(); - virtual void progress(qint64 current, qint64 total); + void progress(qint64 current, qint64 total); void finished(); void succeeded(); + void aborted(); void failed(QString reason); void status(QString status); public slots: virtual void start(); - virtual bool abort() { return false; }; + virtual bool abort() { if(canAbort()) emitAborted(); return canAbort(); }; protected: virtual void executeTask() = 0; @@ -84,13 +103,13 @@ class Task : public QObject { protected slots: virtual void emitSucceeded(); virtual void emitAborted(); - virtual void emitFailed(QString reason); + virtual void emitFailed(QString reason = ""); public slots: void setStatus(const QString& status); void setProgress(qint64 current, qint64 total); - private: + protected: State m_state = State::Inactive; QStringList m_Warnings; QString m_failReason = ""; |