From 65faabeed48584c461ca21d784c3f1d46f67f832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 18 Mar 2013 23:00:46 +0100 Subject: Connect instance list to model. --- libmultimc/include/instancelist.h | 41 ++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/instancelist.h b/libmultimc/include/instancelist.h index d4e7556a..3eef8bdc 100644 --- a/libmultimc/include/instancelist.h +++ b/libmultimc/include/instancelist.h @@ -17,16 +17,14 @@ #define INSTANCELIST_H #include - #include -#include "siglist.h" - +#include "instance.h" #include "libmmc_config.h" class Instance; -class LIBMULTIMC_EXPORT InstanceList : public QObject, public SigList< QSharedPointer > +class LIBMULTIMC_EXPORT InstanceList : public QObject { Q_OBJECT public: @@ -46,14 +44,43 @@ public: QString instDir() const { return m_instDir; } /*! - * \brief Loads the instance list. + * \brief Loads the instance list. Triggers notifications. */ InstListError loadList(); - DEFINE_SIGLIST_SIGNALS(QSharedPointer); - SETUP_SIGLIST_SIGNALS(QSharedPointer); + /*! + * \brief Get the instance at index + */ + InstancePtr at(int i) const + { + return m_instances.at(i); + }; + + /*! + * \brief Get the count of loaded instances + */ + int count() const + { + return m_instances.count(); + }; + + /// Clear all instances. Triggers notifications. + void clear(); + + /// Add an instance. Triggers notifications, returns the new index + int add(InstancePtr t); + + /// Get an instance by ID + InstancePtr getInstanceById (QString id); + +signals: + void instanceAdded(int index); + void instanceChanged(int index); + void invalidated(); + protected: QString m_instDir; + QList< InstancePtr > m_instances; }; #endif // INSTANCELIST_H -- cgit v1.2.3 From 7e222c3e8f4d1c007edafc31e75e7712813dd64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 18 Mar 2013 23:35:54 +0100 Subject: Loading instance groups and exposing them to the model --- libmultimc/include/instance.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libmultimc/include') diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h index c41e6718..9334dff8 100644 --- a/libmultimc/include/instance.h +++ b/libmultimc/include/instance.h @@ -65,6 +65,9 @@ class LIBMULTIMC_EXPORT Instance : public QObject //! The instance's notes. Q_PROPERTY(QString notes READ notes WRITE setNotes) + //! The instance's group. + Q_PROPERTY(QString group READ group WRITE setGroup) + /*! * Whether or not the instance's minecraft.jar needs to be rebuilt. * If this is true, when the instance launches, its jar mods will be @@ -181,6 +184,9 @@ public: virtual QString notes() const { return settings().get("notes").toString(); } virtual void setNotes(QString val) { settings().set("notes", val); } + virtual QString group() const { return m_group; } + virtual void setGroup(QString val) { m_group = val; } + virtual bool shouldRebuild() const { return settings().get("NeedsRebuild").toBool(); } virtual void setShouldRebuild(bool val) { settings().set("NeedsRebuild", val); } @@ -279,6 +285,7 @@ public: private: QString m_rootDir; + QString m_group; SettingsObject *m_settings; }; -- cgit v1.2.3 From 7d7e4034f48b578c87a4651075c2b73dc236181b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 19 Mar 2013 06:24:34 +0100 Subject: Property change propagation, changing instance groups, icon preview --- libmultimc/include/instance.h | 29 +++++++++++++++++++++++++---- libmultimc/include/instancelist.h | 3 +++ 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/instance.h b/libmultimc/include/instance.h index 9334dff8..258a0dab 100644 --- a/libmultimc/include/instance.h +++ b/libmultimc/include/instance.h @@ -176,16 +176,28 @@ public: //// General Info //// virtual QString name() { return settings().get("name").toString(); } - virtual void setName(QString val) { settings().set("name", val); } + virtual void setName(QString val) + { + settings().set("name", val); + emit propertiesChanged(this); + } virtual QString iconKey() const { return settings().get("iconKey").toString(); } - virtual void setIconKey(QString val) { settings().set("iconKey", val); } + virtual void setIconKey(QString val) + { + settings().set("iconKey", val); + emit propertiesChanged(this); + } virtual QString notes() const { return settings().get("notes").toString(); } virtual void setNotes(QString val) { settings().set("notes", val); } virtual QString group() const { return m_group; } - virtual void setGroup(QString val) { m_group = val; } + virtual void setGroup(QString val) + { + m_group = val; + emit propertiesChanged(this); + } virtual bool shouldRebuild() const { return settings().get("NeedsRebuild").toBool(); } virtual void setShouldRebuild(bool val) { settings().set("NeedsRebuild", val); } @@ -208,7 +220,10 @@ public: virtual qint64 lastLaunch() { return settings().get("lastLaunchTime").value(); } virtual void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch()) - { settings().set("lastLaunchTime", val); } + { + settings().set("lastLaunchTime", val); + emit propertiesChanged(this); + } ////// Directories ////// @@ -283,6 +298,12 @@ public: */ virtual SettingsObject &settings() const; +signals: + /*! + * \brief Signal emitted when properties relevant to the instance view change + */ + void propertiesChanged(Instance * inst); + private: QString m_rootDir; QString m_group; diff --git a/libmultimc/include/instancelist.h b/libmultimc/include/instancelist.h index 3eef8bdc..a0d8788a 100644 --- a/libmultimc/include/instancelist.h +++ b/libmultimc/include/instancelist.h @@ -78,6 +78,9 @@ signals: void instanceChanged(int index); void invalidated(); +private slots: + void propertiesChanged(Instance * inst); + protected: QString m_instDir; QList< InstancePtr > m_instances; -- cgit v1.2.3 From f4c9cb8c1d395422b7e4f1c27ac92b6df08a39bb Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Mon, 25 Feb 2013 22:47:03 +0100 Subject: refactor indendation, fix a bug in MinecraftProcess & fix a bug in InstanceLauncher --- libmultimc/include/minecraftprocess.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/minecraftprocess.h b/libmultimc/include/minecraftprocess.h index 8986f7ad..d6b9f612 100644 --- a/libmultimc/include/minecraftprocess.h +++ b/libmultimc/include/minecraftprocess.h @@ -85,7 +85,7 @@ protected: QStringList m_arguments; void genArgs(); - void log(QString text); + void log(QString text, ConsoleWindow::WriteMode mode = ConsoleWindow::MULTIMC); protected slots: void finish(int, QProcess::ExitStatus status); -- cgit v1.2.3 From e4f86893a899ee86cfa6d238f891bec04977c966 Mon Sep 17 00:00:00 2001 From: Orochimarufan Date: Fri, 22 Mar 2013 14:40:55 +0100 Subject: fix merge issues, make console window work again --- libmultimc/include/minecraftprocess.h | 132 ++++++++++++++++++++-------------- 1 file changed, 77 insertions(+), 55 deletions(-) (limited to 'libmultimc/include') diff --git a/libmultimc/include/minecraftprocess.h b/libmultimc/include/minecraftprocess.h index d6b9f612..f6272183 100644 --- a/libmultimc/include/minecraftprocess.h +++ b/libmultimc/include/minecraftprocess.h @@ -6,7 +6,7 @@ * 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 + * 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, @@ -23,74 +23,96 @@ #include "libmmc_config.h" +/** + * @brief the MessageLevel Enum + * defines what level a message is + */ +namespace MessageLevel { +enum LIBMULTIMC_EXPORT Enum { + MultiMC, /**< MultiMC Messages */ + Debug, /**< Debug Messages */ + Info, /**< Info Messages */ + Message, /**< Standard Messages */ + Warning, /**< Warnings */ + Error, /**< Errors */ + Fatal /**< Fatal Errors */ +}; +} + /** * @file data/minecraftprocess.h * @brief The MinecraftProcess class */ class LIBMULTIMC_EXPORT MinecraftProcess : public QProcess { - Q_OBJECT + Q_OBJECT public: - /** - * @brief MinecraftProcess constructor - * @param inst the Instance pointer to launch - * @param user the minecraft username - * @param session the minecraft session id - * @param console the instance console window - */ - MinecraftProcess(InstancePtr inst, QString user, QString session); - - /** - * @brief launch minecraft - */ - void launch(); - - /** - * @brief extract the instance icon - * @param inst the instance - * @param destination the destination path - */ - static inline void extractIcon(InstancePtr inst, QString destination); - - /** - * @brief extract the MultiMC launcher.jar - * @param destination the destination path - */ - static inline void extractLauncher(QString destination); - - /** - * @brief prepare the launch by extracting icon and launcher - * @param inst the instance - */ - static void prepare(InstancePtr inst); - - /** - * @brief split a string into argv items like a shell would do - * @param args the argument string - * @return a QStringList containing all arguments - */ - static QStringList splitArgs(QString args); + /** + * @brief MinecraftProcess constructor + * @param inst the Instance pointer to launch + * @param user the minecraft username + * @param session the minecraft session id + * @param console the instance console window + */ + MinecraftProcess(InstancePtr inst, QString user, QString session); + + /** + * @brief launch minecraft + */ + void launch(); + + /** + * @brief extract the instance icon + * @param inst the instance + * @param destination the destination path + */ + static inline void extractIcon(InstancePtr inst, QString destination); + + /** + * @brief extract the MultiMC launcher.jar + * @param destination the destination path + */ + static inline void extractLauncher(QString destination); + + /** + * @brief prepare the launch by extracting icon and launcher + * @param inst the instance + */ + static void prepare(InstancePtr inst); + + /** + * @brief split a string into argv items like a shell would do + * @param args the argument string + * @return a QStringList containing all arguments + */ + static QStringList splitArgs(QString args); signals: - /** - * @brief emitted when mc has finished and the PostLaunchCommand was run - */ - void ended(); + /** + * @brief emitted when mc has finished and the PostLaunchCommand was run + */ + void ended(); + + /** + * @brief emitted when we want to log something + * @param text the text to log + * @param level the level to log at + */ + void log(QString text, MessageLevel::Enum level=MessageLevel::MultiMC); protected: - InstancePtr m_instance; - QString m_user; - QString m_session; - QProcess m_prepostlaunchprocess; - QStringList m_arguments; + InstancePtr m_instance; + QString m_user; + QString m_session; + QProcess m_prepostlaunchprocess; + QStringList m_arguments; - void genArgs(); - void log(QString text, ConsoleWindow::WriteMode mode = ConsoleWindow::MULTIMC); + void genArgs(); protected slots: - void finish(int, QProcess::ExitStatus status); - void on_stdErr(); - void on_stdOut(); + void finish(int, QProcess::ExitStatus status); + void on_stdErr(); + void on_stdOut(); }; -- cgit v1.2.3 From d24c4823ef8e144a3ffefc208c5a15e86b0b31b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 26 Mar 2013 14:34:34 +0100 Subject: Filter console output, no more sea of red when there's nothing to report. --- libmultimc/include/minecraftprocess.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libmultimc/include') diff --git a/libmultimc/include/minecraftprocess.h b/libmultimc/include/minecraftprocess.h index f6272183..ac4d6be2 100644 --- a/libmultimc/include/minecraftprocess.h +++ b/libmultimc/include/minecraftprocess.h @@ -104,6 +104,8 @@ protected: InstancePtr m_instance; QString m_user; QString m_session; + QString m_err_leftover; + QString m_out_leftover; QProcess m_prepostlaunchprocess; QStringList m_arguments; -- cgit v1.2.3