summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-07-12 23:02:52 +0200
committerPetr Mrázek <peterix@gmail.com>2014-07-12 23:31:06 +0200
commit4c0dc51110603cbe0e98228c703e26402094a3cc (patch)
treeb056d601ba2494e046752e5c94e3049182293515
parent5c4384235989b16d6931cc0cfa26dd192af68b96 (diff)
downloadMultiMC-4c0dc51110603cbe0e98228c703e26402094a3cc.tar
MultiMC-4c0dc51110603cbe0e98228c703e26402094a3cc.tar.gz
MultiMC-4c0dc51110603cbe0e98228c703e26402094a3cc.tar.lz
MultiMC-4c0dc51110603cbe0e98228c703e26402094a3cc.tar.xz
MultiMC-4c0dc51110603cbe0e98228c703e26402094a3cc.zip
Finish of the OtherLogs page, and (re)format page related files
-rw-r--r--.clang-format1
-rw-r--r--gui/pagedialog/PageDialog.cpp30
-rw-r--r--gui/pagedialog/PageDialog.h5
-rw-r--r--gui/pages/BasePage.h26
-rw-r--r--gui/pages/InstanceSettingsPage.cpp27
-rw-r--r--gui/pages/InstanceSettingsPage.h28
-rw-r--r--gui/pages/LegacyJarModPage.cpp26
-rw-r--r--gui/pages/LegacyJarModPage.h25
-rw-r--r--gui/pages/LegacyUpgradePage.cpp16
-rw-r--r--gui/pages/LegacyUpgradePage.h25
-rw-r--r--gui/pages/LogPage.cpp15
-rw-r--r--gui/pages/LogPage.h30
-rw-r--r--gui/pages/ModFolderPage.cpp41
-rw-r--r--gui/pages/ModFolderPage.h20
-rw-r--r--gui/pages/NotesPage.cpp15
-rw-r--r--gui/pages/NotesPage.h25
-rw-r--r--gui/pages/OtherLogsPage.cpp82
-rw-r--r--gui/pages/OtherLogsPage.h42
-rw-r--r--gui/pages/OtherLogsPage.ui9
-rw-r--r--gui/pages/ResourcePackPage.h4
-rw-r--r--gui/pages/ScreenshotsPage.cpp113
-rw-r--r--gui/pages/ScreenshotsPage.h35
-rw-r--r--gui/pages/VersionPage.cpp27
-rw-r--r--gui/pages/VersionPage.h20
-rw-r--r--gui/widgets/PageContainer.cpp13
-rw-r--r--gui/widgets/PageContainer.h8
-rw-r--r--gui/widgets/PageContainer_p.h18
-rw-r--r--logic/RecursiveFileSystemWatcher.cpp38
-rw-r--r--logic/RecursiveFileSystemWatcher.h8
-rw-r--r--resources/multimc/16x16/log.pngbin0 -> 630 bytes
-rw-r--r--resources/multimc/24x24/log.pngbin0 -> 1117 bytes
-rw-r--r--resources/multimc/32x32/log.pngbin0 -> 1460 bytes
-rw-r--r--resources/multimc/48x48/log.pngbin0 -> 2825 bytes
-rw-r--r--resources/multimc/64x64/log.pngbin0 -> 3686 bytes
-rw-r--r--resources/multimc/multimc.qrc7
35 files changed, 423 insertions, 356 deletions
diff --git a/.clang-format b/.clang-format
index 167a8fa7..4aec119c 100644
--- a/.clang-format
+++ b/.clang-format
@@ -9,6 +9,7 @@ NamespaceIndentation: None
BreakBeforeBraces: Allman
AllowShortIfStatementsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
ColumnLimit: 96
MaxEmptyLinesToKeep: 1
diff --git a/gui/pagedialog/PageDialog.cpp b/gui/pagedialog/PageDialog.cpp
index 4dd4a811..c0bcdf9f 100644
--- a/gui/pagedialog/PageDialog.cpp
+++ b/gui/pagedialog/PageDialog.cpp
@@ -14,18 +14,20 @@
*/
#include "PageDialog.h"
-#include "gui/Platform.h"
-#include "MultiMC.h"
-#include "logic/settings/SettingsObject.h"
-#include <gui/widgets/IconLabel.h>
-#include <gui/widgets/PageContainer.h>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
-#include <QtGui/QKeyEvent>
+#include <QKeyEvent>
+
+#include "MultiMC.h"
+#include "logic/settings/SettingsObject.h"
+#include "gui/Platform.h"
+#include "gui/widgets/IconLabel.h"
+#include "gui/widgets/PageContainer.h"
-PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWidget *parent) : QDialog(parent)
+PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWidget *parent)
+ : QDialog(parent)
{
MultiMCPlatform::fixWM_CLASS(this);
setWindowTitle(pageProvider->dialogTitle());
@@ -34,23 +36,25 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWid
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(m_container);
mainLayout->setSpacing(0);
- mainLayout->setContentsMargins(0,0,0,0);
+ mainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mainLayout);
-
+
QDialogButtonBox *buttons =
new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close);
buttons->button(QDialogButtonBox::Close)->setDefault(true);
m_container->addButtons(buttons);
connect(buttons->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));
- connect(buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()), m_container, SLOT(help()));
+ connect(buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()), m_container,
+ SLOT(help()));
- restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("PagedGeometry").toByteArray()));
+ restoreGeometry(
+ QByteArray::fromBase64(MMC->settings()->get("PagedGeometry").toByteArray()));
}
-void PageDialog::closeEvent(QCloseEvent * event)
+void PageDialog::closeEvent(QCloseEvent *event)
{
- if(m_container->requestClose(event))
+ if (m_container->requestClose(event))
{
MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
QDialog::closeEvent(event);
diff --git a/gui/pagedialog/PageDialog.h b/gui/pagedialog/PageDialog.h
index 097eac64..19d1b01f 100644
--- a/gui/pagedialog/PageDialog.h
+++ b/gui/pagedialog/PageDialog.h
@@ -14,8 +14,9 @@
*/
#pragma once
+
#include <QDialog>
-#include <gui/pages/BasePageProvider.h>
+#include "gui/pages/BasePageProvider.h"
class PageContainer;
class PageDialog : public QDialog
@@ -24,7 +25,7 @@ class PageDialog : public QDialog
public:
explicit PageDialog(BasePageProviderPtr pageProvider, QString defaultId = QString(),
QWidget *parent = 0);
- virtual ~PageDialog() {};
+ virtual ~PageDialog() {}
private
slots:
diff --git a/gui/pages/BasePage.h b/gui/pages/BasePage.h
index 26c0b9f7..2cc602b7 100644
--- a/gui/pages/BasePage.h
+++ b/gui/pages/BasePage.h
@@ -14,6 +14,7 @@
*/
#pragma once
+
#include <QString>
#include <QIcon>
#include <memory>
@@ -21,28 +22,15 @@
class BasePage
{
public:
- virtual ~BasePage(){}
+ virtual ~BasePage() {}
virtual QString id() const = 0;
virtual QString displayName() const = 0;
virtual QIcon icon() const = 0;
- virtual bool apply()
- {
- return true;
- }
- virtual bool shouldDisplay() const
- {
- return true;
- }
- virtual QString helpPage() const
- {
- return QString();
- }
- virtual void opened()
- {
- }
- virtual void closed()
- {
- }
+ virtual bool apply() { return true; }
+ virtual bool shouldDisplay() const { return true; }
+ virtual QString helpPage() const { return QString(); }
+ virtual void opened() {}
+ virtual void closed() {}
int stackIndex = -1;
int listIndex = -1;
};
diff --git a/gui/pages/InstanceSettingsPage.cpp b/gui/pages/InstanceSettingsPage.cpp
index 25fe46e5..34b1b401 100644
--- a/gui/pages/InstanceSettingsPage.cpp
+++ b/gui/pages/InstanceSettingsPage.cpp
@@ -1,27 +1,14 @@
#include "InstanceSettingsPage.h"
-#include <gui/dialogs/VersionSelectDialog.h>
-#include "logic/NagUtils.h"
-#include <logic/java/JavaVersionList.h>
-#include "MultiMC.h"
-#include <QDialog>
-#include <QFileDialog>
-#include <QMessageBox>
#include "ui_InstanceSettingsPage.h"
-QString InstanceSettingsPage::displayName() const
-{
- return tr("Settings");
-}
-
-QIcon InstanceSettingsPage::icon() const
-{
- return QIcon::fromTheme("settings");
-}
+#include <QFileDialog>
+#include <QDialog>
+#include <QMessageBox>
-QString InstanceSettingsPage::id() const
-{
- return "settings";
-}
+#include "gui/dialogs/VersionSelectDialog.h"
+#include "logic/NagUtils.h"
+#include "logic/java/JavaVersionList.h"
+#include "MultiMC.h"
InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
diff --git a/gui/pages/InstanceSettingsPage.h b/gui/pages/InstanceSettingsPage.h
index 7052040c..988862cf 100644
--- a/gui/pages/InstanceSettingsPage.h
+++ b/gui/pages/InstanceSettingsPage.h
@@ -14,11 +14,12 @@
*/
#pragma once
+
#include <QWidget>
-#include <logic/OneSixInstance.h>
-#include <logic/net/NetJob.h>
-#include <logic/java/JavaChecker.h>
+#include "logic/OneSixInstance.h"
+#include "logic/net/NetJob.h"
+#include "logic/java/JavaChecker.h"
#include "BasePage.h"
class JavaChecker;
@@ -34,11 +35,23 @@ class InstanceSettingsPage : public QWidget, public BasePage
public:
explicit InstanceSettingsPage(BaseInstance *inst, QWidget *parent = 0);
virtual ~InstanceSettingsPage();
- virtual QString displayName() const override;
- virtual QIcon icon() const override;
- virtual QString id() const override;
+ virtual QString displayName() const override
+ {
+ return tr("Settings");
+ }
+ virtual QIcon icon() const override
+ {
+ return QIcon::fromTheme("settings");
+ }
+ virtual QString id() const override
+ {
+ return "settings";
+ }
virtual bool apply();
- virtual QString helpPage() const override { return "Instance-settings"; }
+ virtual QString helpPage() const override
+ {
+ return "Instance-settings";
+ }
virtual bool shouldDisplay() const;
private slots:
void on_javaDetectBtn_clicked();
@@ -51,6 +64,7 @@ private slots:
void applySettings();
void loadSettings();
+
private:
Ui::InstanceSettingsPage *ui;
BaseInstance *m_instance;
diff --git a/gui/pages/LegacyJarModPage.cpp b/gui/pages/LegacyJarModPage.cpp
index 8acb2d50..16a2ff66 100644
--- a/gui/pages/LegacyJarModPage.cpp
+++ b/gui/pages/LegacyJarModPage.cpp
@@ -15,6 +15,13 @@
#include "LegacyJarModPage.h"
#include "ui_LegacyJarModPage.h"
+
+#include <QKeyEvent>
+#include <QFileDialog>
+#include <QKeyEvent>
+
+#include <pathutils.h>
+
#include "gui/dialogs/VersionSelectDialog.h"
#include "gui/dialogs/ProgressDialog.h"
#include "gui/dialogs/ModEditDialogCommon.h"
@@ -23,10 +30,6 @@
#include "logic/forge/ForgeVersion.h"
#include "logic/forge/ForgeVersionList.h"
#include "MultiMC.h"
-#include <pathutils.h>
-#include <QtGui/QKeyEvent>
-#include <QFileDialog>
-#include <QKeyEvent>
LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst)
@@ -49,26 +52,11 @@ LegacyJarModPage::~LegacyJarModPage()
delete ui;
}
-QString LegacyJarModPage::displayName() const
-{
- return tr("Jar Mods");
-}
-
bool LegacyJarModPage::shouldDisplay() const
{
return !m_inst->isRunning();
}
-QIcon LegacyJarModPage::icon() const
-{
- return QIcon::fromTheme("plugin-red");
-}
-
-QString LegacyJarModPage::id() const
-{
- return "jarmods";
-}
-
bool LegacyJarModPage::eventFilter(QObject *obj, QEvent *ev)
{
if (ev->type() != QEvent::KeyPress || obj != ui->jarModsTreeView)
diff --git a/gui/pages/LegacyJarModPage.h b/gui/pages/LegacyJarModPage.h
index 261d9020..1a72abf3 100644
--- a/gui/pages/LegacyJarModPage.h
+++ b/gui/pages/LegacyJarModPage.h
@@ -15,8 +15,9 @@
#pragma once
-#include <QDialog>
-#include <logic/net/NetJob.h>
+#include <QWidget>
+
+#include "logic/net/NetJob.h"
#include "BasePage.h"
class ModList;
@@ -34,10 +35,22 @@ public:
explicit LegacyJarModPage(LegacyInstance *inst, QWidget *parent = 0);
virtual ~LegacyJarModPage();
- virtual QString displayName() const;
- virtual QIcon icon() const;
- virtual QString id() const;
- virtual QString helpPage() const override { return "Legacy-jar-mods"; }
+ virtual QString displayName() const
+ {
+ return tr("Jar Mods");
+ }
+ virtual QIcon icon() const
+ {
+ return QIcon::fromTheme("plugin-red");
+ }
+ virtual QString id() const
+ {
+ return "jarmods";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Legacy-jar-mods";
+ }
virtual bool shouldDisplay() const;
private
diff --git a/gui/pages/LegacyUpgradePage.cpp b/gui/pages/LegacyUpgradePage.cpp
index bc800bc8..79478efb 100644
--- a/gui/pages/LegacyUpgradePage.cpp
+++ b/gui/pages/LegacyUpgradePage.cpp
@@ -1,21 +1,7 @@
#include "LegacyUpgradePage.h"
-#include <logic/LegacyInstance.h>
#include "ui_LegacyUpgradePage.h"
-QString LegacyUpgradePage::displayName() const
-{
- return tr("Upgrade");
-}
-
-QIcon LegacyUpgradePage::icon() const
-{
- return QIcon::fromTheme("checkupdate");
-}
-
-QString LegacyUpgradePage::id() const
-{
- return "upgrade";
-}
+#include "logic/LegacyInstance.h"
LegacyUpgradePage::LegacyUpgradePage(LegacyInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
diff --git a/gui/pages/LegacyUpgradePage.h b/gui/pages/LegacyUpgradePage.h
index c9eede72..4fd88b5b 100644
--- a/gui/pages/LegacyUpgradePage.h
+++ b/gui/pages/LegacyUpgradePage.h
@@ -14,10 +14,11 @@
*/
#pragma once
+
#include <QWidget>
-#include <logic/OneSixInstance.h>
-#include <logic/net/NetJob.h>
+#include "logic/OneSixInstance.h"
+#include "logic/net/NetJob.h"
#include "BasePage.h"
class EnabledItemFilter;
@@ -33,10 +34,22 @@ class LegacyUpgradePage : public QWidget, public BasePage
public:
explicit LegacyUpgradePage(LegacyInstance *inst, QWidget *parent = 0);
virtual ~LegacyUpgradePage();
- virtual QString displayName() const override;
- virtual QIcon icon() const override;
- virtual QString id() const override;
- virtual QString helpPage() const override { return "Legacy-upgrade"; }
+ virtual QString displayName() const override
+ {
+ return tr("Upgrade");
+ }
+ virtual QIcon icon() const override
+ {
+ return QIcon::fromTheme("checkupdate");
+ }
+ virtual QString id() const override
+ {
+ return "upgrade";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Legacy-upgrade";
+ }
virtual bool shouldDisplay() const;
private
slots:
diff --git a/gui/pages/LogPage.cpp b/gui/pages/LogPage.cpp
index a7a0171f..601c738f 100644
--- a/gui/pages/LogPage.cpp
+++ b/gui/pages/LogPage.cpp
@@ -7,21 +7,6 @@
#include "logic/MinecraftProcess.h"
#include "gui/GuiUtil.h"
-QString LogPage::displayName() const
-{
- return tr("Minecraft Log");
-}
-
-QIcon LogPage::icon() const
-{
- return QIcon::fromTheme("refresh");
-}
-
-QString LogPage::id() const
-{
- return "console";
-}
-
LogPage::LogPage(MinecraftProcess *proc, QWidget *parent)
: QWidget(parent), ui(new Ui::LogPage), m_process(proc)
{
diff --git a/gui/pages/LogPage.h b/gui/pages/LogPage.h
index 72ca09ec..be5b3a20 100644
--- a/gui/pages/LogPage.h
+++ b/gui/pages/LogPage.h
@@ -13,13 +13,13 @@
* limitations under the License.
*/
-
#pragma once
+
#include <QWidget>
-#include <logic/BaseInstance.h>
-#include <logic/net/NetJob.h>
-#include <logic/MinecraftProcess.h>
+#include "logic/BaseInstance.h"
+#include "logic/net/NetJob.h"
+#include "logic/MinecraftProcess.h"
#include "BasePage.h"
class EnabledItemFilter;
@@ -36,11 +36,23 @@ class LogPage : public QWidget, public BasePage
public:
explicit LogPage(MinecraftProcess *proc, QWidget *parent = 0);
virtual ~LogPage();
- virtual QString displayName() const override;
- virtual QIcon icon() const override;
- virtual QString id() const override;
+ virtual QString displayName() const override
+ {
+ return tr("Minecraft Log");
+ }
+ virtual QIcon icon() const override
+ {
+ return QIcon::fromTheme("log");
+ }
+ virtual QString id() const override
+ {
+ return "console";
+ }
virtual bool apply();
- virtual QString helpPage() const override { return "Minecraft-Log"; }
+ virtual QString helpPage() const override
+ {
+ return "Minecraft-Log";
+ }
virtual bool shouldDisplay() const;
private:
@@ -64,7 +76,7 @@ private slots:
void on_btnPaste_clicked();
void on_btnCopy_clicked();
void on_btnClear_clicked();
-
+
private:
Ui::LogPage *ui;
MinecraftProcess *m_process;
diff --git a/gui/pages/ModFolderPage.cpp b/gui/pages/ModFolderPage.cpp
index a01e215d..d94696ec 100644
--- a/gui/pages/ModFolderPage.cpp
+++ b/gui/pages/ModFolderPage.cpp
@@ -13,9 +13,9 @@
* limitations under the License.
*/
-#include "MultiMC.h"
+#include "ModFolderPage.h"
+#include "ui_ModFolderPage.h"
-#include <pathutils.h>
#include <QFileDialog>
#include <QMessageBox>
#include <QEvent>
@@ -23,33 +23,18 @@
#include <QDesktopServices>
#include <QAbstractItemModel>
-#include "ModFolderPage.h"
-#include "ui_ModFolderPage.h"
+#include <pathutils.h>
+#include "MultiMC.h"
#include "gui/dialogs/CustomMessageBox.h"
#include "gui/dialogs/ModEditDialogCommon.h"
-
#include "logic/ModList.h"
#include "logic/Mod.h"
-#include <logic/VersionFilterData.h>
-
-QString ModFolderPage::displayName() const
-{
- return m_displayName;
-}
-
-QIcon ModFolderPage::icon() const
-{
- return QIcon::fromTheme(m_iconName);
-}
-
-QString ModFolderPage::id() const
-{
- return m_id;
-}
+#include "logic/VersionFilterData.h"
-ModFolderPage::ModFolderPage(BaseInstance * inst, std::shared_ptr<ModList> mods, QString id, QString iconName,
- QString displayName, QString helpPage, QWidget *parent)
+ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods, QString id,
+ QString iconName, QString displayName, QString helpPage,
+ QWidget *parent)
: QWidget(parent), ui(new Ui::ModFolderPage)
{
ui->setupUi(this);
@@ -82,7 +67,7 @@ ModFolderPage::~ModFolderPage()
bool ModFolderPage::shouldDisplay() const
{
- if(m_inst)
+ if (m_inst)
return !m_inst->isRunning();
return true;
}
@@ -91,13 +76,13 @@ bool CoreModFolderPage::shouldDisplay() const
{
if (ModFolderPage::shouldDisplay())
{
- auto inst = dynamic_cast<OneSixInstance*>(m_inst);
- if(!inst)
+ auto inst = dynamic_cast<OneSixInstance *>(m_inst);
+ if (!inst)
return true;
auto version = inst->getFullVersion();
- if(!version)
+ if (!version)
return true;
- if(version->m_releaseTime < g_VersionFilterData.legacyCutoffDate)
+ if (version->m_releaseTime < g_VersionFilterData.legacyCutoffDate)
{
return true;
}
diff --git a/gui/pages/ModFolderPage.h b/gui/pages/ModFolderPage.h
index 2103ce26..4d72fb8b 100644
--- a/gui/pages/ModFolderPage.h
+++ b/gui/pages/ModFolderPage.h
@@ -14,10 +14,11 @@
*/
#pragma once
+
#include <QWidget>
-#include <logic/OneSixInstance.h>
-#include <logic/net/NetJob.h>
+#include "logic/OneSixInstance.h"
+#include "logic/net/NetJob.h"
#include "BasePage.h"
class EnabledItemFilter;
@@ -36,9 +37,18 @@ public:
QString iconName, QString displayName, QString helpPage = "",
QWidget *parent = 0);
virtual ~ModFolderPage();
- virtual QString displayName() const override;
- virtual QIcon icon() const override;
- virtual QString id() const override;
+ virtual QString displayName() const override
+ {
+ return m_displayName;
+ }
+ virtual QIcon icon() const override
+ {
+ return QIcon::fromTheme(m_iconName);
+ }
+ virtual QString id() const override
+ {
+ return m_id;
+ }
virtual QString helpPage() const override
{
return m_helpName;
diff --git a/gui/pages/NotesPage.cpp b/gui/pages/NotesPage.cpp
index d99014ff..a2558e3c 100644
--- a/gui/pages/NotesPage.cpp
+++ b/gui/pages/NotesPage.cpp
@@ -1,21 +1,6 @@
#include "NotesPage.h"
#include "ui_NotesPage.h"
-QString NotesPage::displayName() const
-{
- return tr("Notes");
-}
-
-QIcon NotesPage::icon() const
-{
- return QIcon::fromTheme("news");
-}
-
-QString NotesPage::id() const
-{
- return "notes";
-}
-
NotesPage::NotesPage(BaseInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::NotesPage), m_inst(inst)
{
diff --git a/gui/pages/NotesPage.h b/gui/pages/NotesPage.h
index ad0a7701..81338e57 100644
--- a/gui/pages/NotesPage.h
+++ b/gui/pages/NotesPage.h
@@ -14,10 +14,11 @@
*/
#pragma once
+
#include <QWidget>
-#include <logic/BaseInstance.h>
-#include <logic/net/NetJob.h>
+#include "logic/BaseInstance.h"
+#include "logic/net/NetJob.h"
#include "BasePage.h"
class EnabledItemFilter;
@@ -33,11 +34,23 @@ class NotesPage : public QWidget, public BasePage
public:
explicit NotesPage(BaseInstance *inst, QWidget *parent = 0);
virtual ~NotesPage();
- virtual QString displayName() const override;
- virtual QIcon icon() const override;
- virtual QString id() const override;
+ virtual QString displayName() const override
+ {
+ return tr("Notes");
+ }
+ virtual QIcon icon() const override
+ {
+ return QIcon::fromTheme("news");
+ }
+ virtual QString id() const override
+ {
+ return "notes";
+ }
virtual bool apply();
- virtual QString helpPage() const override { return "Notes"; }
+ virtual QString helpPage() const override
+ {
+ return "Notes";
+ }
private:
Ui::NotesPage *ui;
diff --git a/gui/pages/OtherLogsPage.cpp b/gui/pages/OtherLogsPage.cpp
index 3ea1f170..f20b9fef 100644
--- a/gui/pages/OtherLogsPage.cpp
+++ b/gui/pages/OtherLogsPage.cpp
@@ -1,3 +1,18 @@
+/* Copyright 2014 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.
+ */
+
#include "OtherLogsPage.h"
#include "ui_OtherLogsPage.h"
@@ -8,28 +23,18 @@
#include "logic/RecursiveFileSystemWatcher.h"
#include "logic/BaseInstance.h"
-OtherLogsPage::OtherLogsPage(BaseInstance *instance, QWidget *parent) :
- QWidget(parent),
- ui(new Ui::OtherLogsPage),
- m_instance(instance),
- m_watcher(new RecursiveFileSystemWatcher(this))
+OtherLogsPage::OtherLogsPage(BaseInstance *instance, QWidget *parent)
+ : QWidget(parent), ui(new Ui::OtherLogsPage), m_instance(instance),
+ m_watcher(new RecursiveFileSystemWatcher(this))
{
ui->setupUi(this);
- connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, [this]()
- {
- ui->selectLogBox->clear();
- ui->selectLogBox->addItems(m_watcher->files());
- ui->selectLogBox->addItem(tr("&Other"), true);
- if (m_currentFile.isNull())
- {
- ui->selectLogBox->setCurrentIndex(-1);
- }
- else
- {
- const int index = ui->selectLogBox->findText(m_currentFile);
- ui->selectLogBox->setCurrentIndex(-1);
- }
- });
+
+ m_watcher->setFileExpression(".*\\.log$");
+ m_watcher->setRootDir(QDir::current().absoluteFilePath(m_instance->minecraftRoot()));
+
+ connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, this,
+ &OtherLogsPage::populateSelectLogBox);
+ populateSelectLogBox();
}
OtherLogsPage::~OtherLogsPage()
@@ -46,6 +51,22 @@ void OtherLogsPage::closed()
m_watcher->disable();
}
+void OtherLogsPage::populateSelectLogBox()
+{
+ ui->selectLogBox->clear();
+ ui->selectLogBox->addItems(m_watcher->files());
+ ui->selectLogBox->addItem(tr("Other"), true);
+ if (m_currentFile.isNull())
+ {
+ ui->selectLogBox->setCurrentIndex(-1);
+ }
+ else
+ {
+ const int index = ui->selectLogBox->findText(m_currentFile);
+ ui->selectLogBox->setCurrentIndex(index);
+ }
+}
+
void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
{
QString file;
@@ -53,7 +74,8 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
{
if (ui->selectLogBox->itemData(index).isValid())
{
- file = QFileDialog::getOpenFileName(this, tr("Open log file"), m_instance->minecraftRoot(), tr("*.log;;*.txt;;*"));
+ file = QFileDialog::getOpenFileName(
+ this, tr("Open log file"), m_instance->minecraftRoot(), tr("*.log;;*.txt;;*"));
}
else
{
@@ -61,9 +83,10 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
}
}
- if (file.isEmpty() || !QFile::exists(file))
+ if (file.isEmpty() || !QFile::exists(m_instance->minecraftRoot() + "/" + file))
{
m_currentFile = QString();
+ ui->text->clear();
setControlsEnabled(false);
}
else
@@ -76,13 +99,14 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
void OtherLogsPage::on_btnReload_clicked()
{
- QFile file(m_currentFile);
+ QFile file(m_instance->minecraftRoot() + "/" + m_currentFile);
if (!file.open(QFile::ReadOnly))
{
setControlsEnabled(false);
ui->btnReload->setEnabled(true); // allow reload
m_currentFile = QString();
- QMessageBox::critical(this, tr("Error"), tr("Unable to open %1 for reading: %2").arg(m_currentFile, file.errorString()));
+ QMessageBox::critical(this, tr("Error"), tr("Unable to open %1 for reading: %2")
+ .arg(m_currentFile, file.errorString()));
}
else
{
@@ -100,15 +124,17 @@ void OtherLogsPage::on_btnCopy_clicked()
}
void OtherLogsPage::on_btnDelete_clicked()
{
- if (QMessageBox::question(this, tr("Delete"), tr("Do you really want to delete %1?").arg(m_currentFile), QMessageBox::Yes, QMessageBox::No)
- == QMessageBox::No)
+ if (QMessageBox::question(this, tr("Delete"),
+ tr("Do you really want to delete %1?").arg(m_currentFile),
+ QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
{
return;
}
- QFile file(m_currentFile);
+ QFile file(m_instance->minecraftRoot() + "/" + m_currentFile);
if (!file.remove())
{
- QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2").arg(m_currentFile, file.errorString()));
+ QMessageBox::critical(this, tr("Error"), tr("Unable to delete %1: %2")
+ .arg(m_currentFile, file.errorString()));
}
}
diff --git a/gui/pages/OtherLogsPage.h b/gui/pages/OtherLogsPage.h
index e89b3bce..5cabf03f 100644
--- a/gui/pages/OtherLogsPage.h
+++ b/gui/pages/OtherLogsPage.h
@@ -1,10 +1,26 @@
+/* Copyright 2014 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 <QWidget>
#include "BasePage.h"
-namespace Ui {
+namespace Ui
+{
class OtherLogsPage;
}
@@ -20,15 +36,27 @@ public:
explicit OtherLogsPage(BaseInstance *instance, QWidget *parent = 0);
~OtherLogsPage();
- QString id() const override { return "logs"; }
- QString displayName() const override { return tr("Other logs"); }
- QIcon icon() const override { return QIcon(); } // TODO
- QString helpPage() const override { return "Minecraft-Logs"; }
+ QString id() const override
+ {
+ return "logs";
+ }
+ QString displayName() const override
+ {
+ return tr("Other logs");
+ }
+ QIcon icon() const override
+ {
+ return QIcon::fromTheme("log");
+ }
+ QString helpPage() const override
+ {
+ return "Minecraft-Logs";
+ }
void opened() override;
void closed() override;
-private
-slots:
+private slots:
+ void populateSelectLogBox();
void on_selectLogBox_currentIndexChanged(const int index);
void on_btnReload_clicked();
void on_btnPaste_clicked();
diff --git a/gui/pages/OtherLogsPage.ui b/gui/pages/OtherLogsPage.ui
index 471c7d72..e6ce6397 100644
--- a/gui/pages/OtherLogsPage.ui
+++ b/gui/pages/OtherLogsPage.ui
@@ -39,7 +39,14 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QComboBox" name="selectLogBox"/>
+ <widget class="QComboBox" name="selectLogBox">
+ <property name="maximumSize">
+ <size>
+ <width>96</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
</item>
<item>
<widget class="QPushButton" name="btnReload">
diff --git a/gui/pages/ResourcePackPage.h b/gui/pages/ResourcePackPage.h
index b3c5df46..1a9039ff 100644
--- a/gui/pages/ResourcePackPage.h
+++ b/gui/pages/ResourcePackPage.h
@@ -5,8 +5,8 @@ class ResourcePackPage : public ModFolderPage
{
public:
explicit ResourcePackPage(BaseInstance *instance, QWidget *parent = 0)
- : ModFolderPage(instance, instance->resourcePackList(), "resourcepacks", "resourcepacks",
- tr("Resource packs"), "Resource-packs", parent)
+ : ModFolderPage(instance, instance->resourcePackList(), "resourcepacks",
+ "resourcepacks", tr("Resource packs"), "Resource-packs", parent)
{
}
diff --git a/gui/pages/ScreenshotsPage.cpp b/gui/pages/ScreenshotsPage.cpp
index 415aa576..004f797b 100644
--- a/gui/pages/ScreenshotsPage.cpp
+++ b/gui/pages/ScreenshotsPage.cpp
@@ -9,10 +9,11 @@
#include <QFileSystemModel>
#include <QStyledItemDelegate>
#include <QLineEdit>
-#include <QtGui/qevent.h>
-#include <QtGui/QPainter>
-#include <QtGui/QClipboard>
-#include <QtGui/QDesktopServices>
+#include <QEvent>
+#include <QPainter>
+#include <QClipboard>
+#include <QDesktopServices>
+#include <QKeyEvent>
#include <pathutils.h>
@@ -24,30 +25,25 @@
#include "logic/tasks/SequentialTask.h"
#include "logic/RWStorage.h"
+
typedef RWStorage<QString, QIcon> SharedIconCache;
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr;
class ThumbnailingResult : public QObject
{
Q_OBJECT
-public Q_SLOTS:
- inline void emitResultsReady(const QString &path)
- {
- emit resultsReady(path);
- }
- inline void emitResultsFailed(const QString &path)
- {
- emit resultsFailed(path);
- }
-Q_SIGNALS:
+public slots:
+ inline void emitResultsReady(const QString &path) { emit resultsReady(path); }
+ inline void emitResultsFailed(const QString &path) { emit resultsFailed(path); }
+signals:
void resultsReady(const QString &path);
void resultsFailed(const QString &path);
};
-class ThumbnailRunnable: public QRunnable
+class ThumbnailRunnable : public QRunnable
{
public:
- ThumbnailRunnable (QString path, SharedIconCachePtr cache)
+ ThumbnailRunnable(QString path, SharedIconCachePtr cache)
{
m_path = path;
m_cache = cache;
@@ -55,14 +51,14 @@ public:
void run()
{
QFileInfo info(m_path);
- if(info.isDir())
+ if (info.isDir())
return;
- if((info.suffix().compare("png", Qt::CaseInsensitive) != 0))
+ if ((info.suffix().compare("png", Qt::CaseInsensitive) != 0))
return;
int tries = 5;
- while(tries)
+ while (tries)
{
- if(!m_cache->stale(m_path))
+ if (!m_cache->stale(m_path))
return;
QImage image(m_path);
if (image.isNull())
@@ -72,19 +68,19 @@ public:
continue;
}
QImage small;
- if(image.width() > image.height())
+ if (image.width() > image.height())
small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
else
small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
auto smallSize = small.size();
- QPoint offset((256-small.width())/2, (256-small.height())/2);
- QImage square(QSize(256,256), QImage::Format_ARGB32);
+ QPoint offset((256 - small.width()) / 2, (256 - small.height()) / 2);
+ QImage square(QSize(256, 256), QImage::Format_ARGB32);
square.fill(Qt::transparent);
-
+
QPainter painter(&square);
painter.drawImage(offset, small);
painter.end();
-
+
QIcon icon(QPixmap::fromImage(square));
m_cache->add(m_path, icon);
m_resultEmitter.emitResultsReady(m_path);
@@ -97,12 +93,13 @@ public:
ThumbnailingResult m_resultEmitter;
};
-// this is about as elegant and well written as a bag of bricks with scribbles done by insane asylum patients.
+// this is about as elegant and well written as a bag of bricks with scribbles done by insane
+// asylum patients.
class FilterModel : public QIdentityProxyModel
{
Q_OBJECT
public:
- explicit FilterModel(QObject *parent = 0):QIdentityProxyModel(parent)
+ explicit FilterModel(QObject *parent = 0) : QIdentityProxyModel(parent)
{
m_thumbnailingPool.setMaxThreadCount(4);
m_thumbnailCache = std::make_shared<SharedIconCache>();
@@ -110,10 +107,7 @@ public:
connect(&watcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
// FIXME: the watched file set is not updated when files are removed
}
- virtual ~FilterModel()
- {
- m_thumbnailingPool.waitForDone(500);
- }
+ virtual ~FilterModel() { m_thumbnailingPool.waitForDone(500); }
virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const
{
auto model = sourceModel();
@@ -126,23 +120,24 @@ public:
}
if (role == Qt::DecorationRole)
{
- QVariant result = sourceModel()->data(mapToSource(proxyIndex), QFileSystemModel::FilePathRole);
+ QVariant result =
+ sourceModel()->data(mapToSource(proxyIndex), QFileSystemModel::FilePathRole);
QString filePath = result.toString();
QIcon temp;
- if(!watched.contains(filePath))
+ if (!watched.contains(filePath))
{
((QFileSystemWatcher &)watcher).addPath(filePath);
((QSet<QString> &)watched).insert(filePath);
}
- if(m_thumbnailCache->get(filePath, temp))
+ if (m_thumbnailCache->get(filePath, temp))
{
return temp;
}
- if(!m_failed.contains(filePath))
+ if (!m_failed.contains(filePath))
{
((FilterModel *)this)->thumbnailImage(filePath);
}
- return(m_thumbnailCache->get("placeholder"));
+ return (m_thumbnailCache->get("placeholder"));
}
return sourceModel()->data(mapToSource(proxyIndex), role);
}
@@ -162,24 +157,20 @@ public:
}
return model->setData(mapToSource(index), value.toString() + ".png", role);
}
+
private:
void thumbnailImage(QString path)
{
auto runnable = new ThumbnailRunnable(path, m_thumbnailCache);
- connect(&(runnable->m_resultEmitter),SIGNAL(resultsReady(QString)), SLOT(thumbnailReady(QString)));
- connect(&(runnable->m_resultEmitter),SIGNAL(resultsFailed(QString)), SLOT(thumbnailFailed(QString)));
+ connect(&(runnable->m_resultEmitter), SIGNAL(resultsReady(QString)),
+ SLOT(thumbnailReady(QString)));
+ connect(&(runnable->m_resultEmitter), SIGNAL(resultsFailed(QString)),
+ SLOT(thumbnailFailed(QString)));
((QThreadPool &)m_thumbnailingPool).start(runnable);
}
-private
-slots:
- void thumbnailReady(QString path)
- {
- emit layoutChanged();
- }
- void thumbnailFailed(QString path)
- {
- m_failed.insert(path);
- }
+private slots:
+ void thumbnailReady(QString path) { emit layoutChanged(); }
+ void thumbnailFailed(QString path) { m_failed.insert(path); }
void fileChanged(QString filepath)
{
m_thumbnailCache->setStale(filepath);
@@ -200,12 +191,8 @@ private:
class CenteredEditingDelegate : public QStyledItemDelegate
{
public:
- explicit CenteredEditingDelegate(QObject *parent = 0) : QStyledItemDelegate(parent)
- {
- }
- virtual ~CenteredEditingDelegate()
- {
- }
+ explicit CenteredEditingDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {}
+ virtual ~CenteredEditingDelegate() {}
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
@@ -221,21 +208,6 @@ public:
}
};
-QString ScreenshotsPage::displayName() const
-{
- return tr("Screenshots");
-}
-
-QIcon ScreenshotsPage::icon() const
-{
- return QIcon::fromTheme("screenshots");
-}
-
-QString ScreenshotsPage::id() const
-{
- return "screenshots";
-}
-
ScreenshotsPage::ScreenshotsPage(BaseInstance *instance, QWidget *parent)
: QWidget(parent), ui(new Ui::ScreenshotsPage)
{
@@ -341,7 +313,8 @@ void ScreenshotsPage::on_uploadBtn_clicked()
QDesktopServices::openUrl(link);
CustomMessageBox::selectable(
this, tr("Upload finished"),
- tr("The <a href=\"%1\">link to the uploaded album</a> has been opened in the default browser and placed in your clipboard.<br/>Delete hash: %2 (save "
+ tr("The <a href=\"%1\">link to the uploaded album</a> has been opened in the "
+ "default browser and placed in your clipboard.<br/>Delete hash: %2 (save "
"this if you want to be able to edit/delete the album)")
.arg(link, imgurAlbum->deleteHash()),
QMessageBox::Information)->exec();
diff --git a/gui/pages/ScreenshotsPage.h b/gui/pages/ScreenshotsPage.h
index 8b6d1e4d..19ae6cd8 100644
--- a/gui/pages/ScreenshotsPage.h
+++ b/gui/pages/ScreenshotsPage.h
@@ -14,11 +14,11 @@
*/
#pragma once
+
#include <QWidget>
-#include <logic/OneSixInstance.h>
+
+#include "logic/OneSixInstance.h"
#include "BasePage.h"
-#include <QIcon>
-#include <QEvent>
class QFileSystemModel;
class QIdentityProxyModel;
@@ -38,21 +38,32 @@ class ScreenshotsPage : public QWidget, public BasePage
public:
explicit ScreenshotsPage(BaseInstance *instance, QWidget *parent = 0);
virtual ~ScreenshotsPage();
-
+
virtual void opened() override;
-
+
enum
{
NothingDone = 0x42
};
-
+
virtual bool eventFilter(QObject *, QEvent *);
- virtual QString displayName() const override;
- virtual QIcon icon() const override;
- virtual QString id() const override;
- virtual QString helpPage() const override { return "Screenshots-management"; }
-private
-slots:
+ virtual QString displayName() const override
+ {
+ return tr("Screenshots");
+ }
+ virtual QIcon icon() const override
+ {
+ return QIcon::fromTheme("screenshots");
+ }
+ virtual QString id() const override
+ {
+ return "screenshots";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Screenshots-management";
+ }
+private slots:
void on_uploadBtn_clicked();
void on_deleteBtn_clicked();
void on_renameBtn_clicked();
diff --git a/gui/pages/VersionPage.cpp b/gui/pages/VersionPage.cpp
index 1ea6b262..6e29dd41 100644
--- a/gui/pages/VersionPage.cpp
+++ b/gui/pages/VersionPage.cpp
@@ -31,6 +31,12 @@
#include "gui/dialogs/ProgressDialog.h"
+#include <QAbstractItemModel>
+#include <QMessageBox>
+#include <QListView>
+#include <QString>
+#include <QUrl>
+
#include "logic/ModList.h"
#include "logic/minecraft/InstanceVersion.h"
#include "logic/EnabledItemFilter.h"
@@ -40,31 +46,14 @@
#include "logic/liteloader/LiteLoaderInstaller.h"
#include "logic/minecraft/VersionBuilder.h"
#include "logic/auth/MojangAccountList.h"
+#include "logic/Mod.h"
+#include "logic/icons/IconList.h"
-#include <QAbstractItemModel>
-#include <logic/Mod.h>
-#include <logic/icons/IconList.h>
-
-#include <QMessageBox>
-#include <QListView>
-#include <QString>
-#include <QUrl>
-
-QString VersionPage::displayName() const
-{
- return tr("Version");
-}
QIcon VersionPage::icon() const
{
return MMC->icons()->getIcon(m_inst->iconKey());
}
-
-QString VersionPage::id() const
-{
- return "version";
-}
-
bool VersionPage::shouldDisplay() const
{
return !m_inst->isRunning();
diff --git a/gui/pages/VersionPage.h b/gui/pages/VersionPage.h
index d80b2a2a..93fe7508 100644
--- a/gui/pages/VersionPage.h
+++ b/gui/pages/VersionPage.h
@@ -14,10 +14,11 @@
*/
#pragma once
+
#include <QWidget>
-#include <logic/OneSixInstance.h>
-#include <logic/net/NetJob.h>
+#include "logic/OneSixInstance.h"
+#include "logic/net/NetJob.h"
#include "BasePage.h"
class EnabledItemFilter;
@@ -33,10 +34,19 @@ class VersionPage : public QWidget, public BasePage
public:
explicit VersionPage(OneSixInstance *inst, QWidget *parent = 0);
virtual ~VersionPage();
- virtual QString displayName() const override;
+ virtual QString displayName() const override
+ {
+ return tr("Version");
+ }
virtual QIcon icon() const override;
- virtual QString id() const override;
- virtual QString helpPage() const override { return "Instance-version"; }
+ virtual QString id() const override
+ {
+ return "version";
+ }
+ virtual QString helpPage() const override
+ {
+ return "Instance-version";
+ }
virtual bool shouldDisplay() const;
private
slots:
diff --git a/gui/widgets/PageContainer.cpp b/gui/widgets/PageContainer.cpp
index d5df72ce..a68f94cd 100644
--- a/gui/widgets/PageContainer.cpp
+++ b/gui/widgets/PageContainer.cpp
@@ -14,12 +14,11 @@
*/
#include "PageContainer.h"
-#include "gui/Platform.h"
+
#include <QStackedLayout>
#include <QPushButton>
#include <QSortFilterProxyModel>
#include <QUrl>
-#include "MultiMC.h"
#include <QStyledItemDelegate>
#include <QListView>
#include <QLineEdit>
@@ -27,10 +26,12 @@
#include <QDialogButtonBox>
#include <QGridLayout>
#include <QDesktopServices>
-#include "logic/settings/SettingsObject.h"
+#include "MultiMC.h"
+#include "logic/settings/SettingsObject.h"
+#include "gui/widgets/IconLabel.h"
+#include "gui/Platform.h"
#include "PageContainer_p.h"
-#include <gui/widgets/IconLabel.h>
class PageEntryFilterModel : public QSortFilterProxyModel
{
@@ -197,5 +198,9 @@ bool PageContainer::requestClose(QCloseEvent *event)
if (!page->apply())
return false;
}
+ if (m_currentPage)
+ {
+ m_currentPage->closed();
+ }
return true;
}
diff --git a/gui/widgets/PageContainer.h b/gui/widgets/PageContainer.h
index c0f17e90..06498850 100644
--- a/gui/widgets/PageContainer.h
+++ b/gui/widgets/PageContainer.h
@@ -14,9 +14,11 @@
*/
#pragma once
+
#include <QWidget>
#include <QModelIndex>
-#include <gui/pages/BasePageProvider.h>
+
+#include "gui/pages/BasePageProvider.h"
class QLayout;
class IconLabel;
@@ -34,7 +36,7 @@ class PageContainer : public QWidget
public:
explicit PageContainer(BasePageProviderPtr pageProvider, QString defaultId = QString(),
QWidget *parent = 0);
- virtual ~PageContainer() {};
+ virtual ~PageContainer() {}
void addButtons(QWidget * buttons);
void addButtons(QLayout * buttons);
@@ -49,7 +51,7 @@ slots:
void help();
private:
- BasePage * m_currentPage;
+ BasePage * m_currentPage = 0;
QSortFilterProxyModel *m_proxyModel;
PageModel *m_model;
QStackedLayout *m_pageStack;
diff --git a/gui/widgets/PageContainer_p.h b/gui/widgets/PageContainer_p.h
index f10e8f2c..1f68776b 100644
--- a/gui/widgets/PageContainer_p.h
+++ b/gui/widgets/PageContainer_p.h
@@ -1,4 +1,20 @@
+/* Copyright 2014 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 <QListView>
#include <QStyledItemDelegate>
#include <QEvent>
@@ -30,7 +46,7 @@ public:
empty.fill(Qt::transparent);
m_emptyIcon = QIcon(empty);
}
- virtual ~PageModel() {};
+ virtual ~PageModel() {}
int rowCount(const QModelIndex &parent = QModelIndex()) const
{
diff --git a/logic/RecursiveFileSystemWatcher.cpp b/logic/RecursiveFileSystemWatcher.cpp
index 5cfa7e4e..39985699 100644
--- a/logic/RecursiveFileSystemWatcher.cpp
+++ b/logic/RecursiveFileSystemWatcher.cpp
@@ -1,13 +1,15 @@
#include "RecursiveFileSystemWatcher.h"
#include <QRegularExpression>
+#include <QDebug>
RecursiveFileSystemWatcher::RecursiveFileSystemWatcher(QObject *parent)
- : QObject(parent),
- m_watcher(new QFileSystemWatcher(this))
+ : QObject(parent), m_exp(".*"), m_watcher(new QFileSystemWatcher(this))
{
- connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &RecursiveFileSystemWatcher::fileChange);
- connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &RecursiveFileSystemWatcher::directoryChange);
+ connect(m_watcher, &QFileSystemWatcher::fileChanged, this,
+ &RecursiveFileSystemWatcher::fileChange);
+ connect(m_watcher, &QFileSystemWatcher::directoryChanged, this,
+ &RecursiveFileSystemWatcher::directoryChange);
}
void RecursiveFileSystemWatcher::setRootDir(const QDir &root)
@@ -34,12 +36,20 @@ void RecursiveFileSystemWatcher::setWatchFiles(const bool watchFiles)
void RecursiveFileSystemWatcher::enable()
{
+ if (m_isEnabled)
+ {
+ return;
+ }
Q_ASSERT(m_root != QDir::root());
addFilesToWatcherRecursive(m_root);
m_isEnabled = true;
}
void RecursiveFileSystemWatcher::disable()
{
+ if (!m_isEnabled)
+ {
+ return;
+ }
m_isEnabled = false;
m_watcher->removePaths(m_watcher->files());
m_watcher->removePaths(m_watcher->directories());
@@ -57,9 +67,9 @@ void RecursiveFileSystemWatcher::setFiles(const QStringList &files)
void RecursiveFileSystemWatcher::addFilesToWatcherRecursive(const QDir &dir)
{
m_watcher->addPath(dir.absolutePath());
- for (const QFileInfo &info : dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot))
+ for (const QString &directory : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
{
- addFilesToWatcherRecursive(info.absoluteDir());
+ addFilesToWatcherRecursive(dir.absoluteFilePath(directory));
}
if (m_watchFiles)
{
@@ -69,19 +79,19 @@ void RecursiveFileSystemWatcher::addFilesToWatcherRecursive(const QDir &dir)
}
}
}
-QStringList RecursiveFileSystemWatcher::scanRecursive(const QDir &dir)
+QStringList RecursiveFileSystemWatcher::scanRecursive(const QDir &directory)
{
QStringList ret;
QRegularExpression exp(m_exp);
- for (const QFileInfo &info : dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files))
+ for (const QString &dir : directory.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
{
- if (info.isFile() && exp.match(info.absoluteFilePath()).hasMatch())
- {
- ret.append(info.absoluteFilePath());
- }
- else if (info.isDir())
+ ret.append(scanRecursive(directory.absoluteFilePath(dir)));
+ }
+ for (const QString &file : directory.entryList(QDir::Files))
+ {
+ if (exp.match(file).hasMatch())
{
- ret.append(scanRecursive(info.absoluteDir()));
+ ret.append(m_root.relativeFilePath(directory.absoluteFilePath(file)));
}
}
return ret;
diff --git a/logic/RecursiveFileSystemWatcher.h b/logic/RecursiveFileSystemWatcher.h
index 54fc1d12..339172bb 100644
--- a/logic/RecursiveFileSystemWatcher.h
+++ b/logic/RecursiveFileSystemWatcher.h
@@ -25,8 +25,7 @@ signals:
void filesChanged();
void fileChanged(const QString &path);
-public
-slots:
+public slots:
void enable();
void disable();
@@ -39,13 +38,12 @@ private:
QFileSystemWatcher *m_watcher;
QStringList m_files;
- void setFiles(const QStringList &scanRecursive);
+ void setFiles(const QStringList &files);
void addFilesToWatcherRecursive(const QDir &dir);
QStringList scanRecursive(const QDir &dir);
-private
-slots:
+private slots:
void fileChange(const QString &path);
void directoryChange(const QString &path);
};
diff --git a/resources/multimc/16x16/log.png b/resources/multimc/16x16/log.png
new file mode 100644
index 00000000..efa2a0b5
--- /dev/null
+++ b/resources/multimc/16x16/log.png
Binary files differ
diff --git a/resources/multimc/24x24/log.png b/resources/multimc/24x24/log.png
new file mode 100644
index 00000000..fe302053
--- /dev/null
+++ b/resources/multimc/24x24/log.png
Binary files differ
diff --git a/resources/multimc/32x32/log.png b/resources/multimc/32x32/log.png
new file mode 100644
index 00000000..d620da12
--- /dev/null
+++ b/resources/multimc/32x32/log.png
Binary files differ
diff --git a/resources/multimc/48x48/log.png b/resources/multimc/48x48/log.png
new file mode 100644
index 00000000..45f60e6b
--- /dev/null
+++ b/resources/multimc/48x48/log.png
Binary files differ
diff --git a/resources/multimc/64x64/log.png b/resources/multimc/64x64/log.png
new file mode 100644
index 00000000..0f531cdf
--- /dev/null
+++ b/resources/multimc/64x64/log.png
Binary files differ
diff --git a/resources/multimc/multimc.qrc b/resources/multimc/multimc.qrc
index 5c49017b..0575bbf0 100644
--- a/resources/multimc/multimc.qrc
+++ b/resources/multimc/multimc.qrc
@@ -164,6 +164,13 @@
<file>24x24/noaccount.png</file>
<file>32x32/noaccount.png</file>
<file>48x48/noaccount.png</file>
+
+ <!-- Log file, LGPL, http://www.iconarchive.com/show/crystal-clear-icons-by-everaldo/Mimetype-text-icon.html -->
+ <file>16x16/log.png</file>
+ <file>24x24/log.png</file>
+ <file>32x32/log.png</file>
+ <file>48x48/log.png</file>
+ <file>64x64/log.png</file>
<!-- placeholder when loading screenshot images -->
<file>scalable/screenshot-placeholder.svg</file>