Finish of the OtherLogs page, and (re)format page related files
This commit is contained in:
parent
5c43842359
commit
4c0dc51110
@ -9,6 +9,7 @@ NamespaceIndentation: None
|
|||||||
|
|
||||||
BreakBeforeBraces: Allman
|
BreakBeforeBraces: Allman
|
||||||
AllowShortIfStatementsOnASingleLine: false
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: None
|
||||||
ColumnLimit: 96
|
ColumnLimit: 96
|
||||||
MaxEmptyLinesToKeep: 1
|
MaxEmptyLinesToKeep: 1
|
||||||
|
|
||||||
|
@ -14,18 +14,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PageDialog.h"
|
#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 <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWidget *parent) : QDialog(parent)
|
#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)
|
||||||
{
|
{
|
||||||
MultiMCPlatform::fixWM_CLASS(this);
|
MultiMCPlatform::fixWM_CLASS(this);
|
||||||
setWindowTitle(pageProvider->dialogTitle());
|
setWindowTitle(pageProvider->dialogTitle());
|
||||||
@ -34,7 +36,7 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWid
|
|||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addWidget(m_container);
|
mainLayout->addWidget(m_container);
|
||||||
mainLayout->setSpacing(0);
|
mainLayout->setSpacing(0);
|
||||||
mainLayout->setContentsMargins(0,0,0,0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
QDialogButtonBox *buttons =
|
QDialogButtonBox *buttons =
|
||||||
@ -43,14 +45,16 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QString defaultId, QWid
|
|||||||
m_container->addButtons(buttons);
|
m_container->addButtons(buttons);
|
||||||
|
|
||||||
connect(buttons->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));
|
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());
|
MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
|
||||||
QDialog::closeEvent(event);
|
QDialog::closeEvent(event);
|
||||||
|
@ -14,8 +14,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <gui/pages/BasePageProvider.h>
|
#include "gui/pages/BasePageProvider.h"
|
||||||
|
|
||||||
class PageContainer;
|
class PageContainer;
|
||||||
class PageDialog : public QDialog
|
class PageDialog : public QDialog
|
||||||
@ -24,7 +25,7 @@ class PageDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit PageDialog(BasePageProviderPtr pageProvider, QString defaultId = QString(),
|
explicit PageDialog(BasePageProviderPtr pageProvider, QString defaultId = QString(),
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
virtual ~PageDialog() {};
|
virtual ~PageDialog() {}
|
||||||
|
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -21,28 +22,15 @@
|
|||||||
class BasePage
|
class BasePage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~BasePage(){}
|
virtual ~BasePage() {}
|
||||||
virtual QString id() const = 0;
|
virtual QString id() const = 0;
|
||||||
virtual QString displayName() const = 0;
|
virtual QString displayName() const = 0;
|
||||||
virtual QIcon icon() const = 0;
|
virtual QIcon icon() const = 0;
|
||||||
virtual bool apply()
|
virtual bool apply() { return true; }
|
||||||
{
|
virtual bool shouldDisplay() const { return true; }
|
||||||
return true;
|
virtual QString helpPage() const { return QString(); }
|
||||||
}
|
virtual void opened() {}
|
||||||
virtual bool shouldDisplay() const
|
virtual void closed() {}
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual QString helpPage() const
|
|
||||||
{
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
virtual void opened()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
virtual void closed()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
int stackIndex = -1;
|
int stackIndex = -1;
|
||||||
int listIndex = -1;
|
int listIndex = -1;
|
||||||
};
|
};
|
||||||
|
@ -1,27 +1,14 @@
|
|||||||
#include "InstanceSettingsPage.h"
|
#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"
|
#include "ui_InstanceSettingsPage.h"
|
||||||
|
|
||||||
QString InstanceSettingsPage::displayName() const
|
#include <QFileDialog>
|
||||||
{
|
#include <QDialog>
|
||||||
return tr("Settings");
|
#include <QMessageBox>
|
||||||
}
|
|
||||||
|
|
||||||
QIcon InstanceSettingsPage::icon() const
|
#include "gui/dialogs/VersionSelectDialog.h"
|
||||||
{
|
#include "logic/NagUtils.h"
|
||||||
return QIcon::fromTheme("settings");
|
#include "logic/java/JavaVersionList.h"
|
||||||
}
|
#include "MultiMC.h"
|
||||||
|
|
||||||
QString InstanceSettingsPage::id() const
|
|
||||||
{
|
|
||||||
return "settings";
|
|
||||||
}
|
|
||||||
|
|
||||||
InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
|
InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
|
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
|
||||||
|
@ -14,11 +14,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <logic/OneSixInstance.h>
|
#include "logic/OneSixInstance.h"
|
||||||
#include <logic/net/NetJob.h>
|
#include "logic/net/NetJob.h"
|
||||||
#include <logic/java/JavaChecker.h>
|
#include "logic/java/JavaChecker.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
class JavaChecker;
|
class JavaChecker;
|
||||||
@ -34,11 +35,23 @@ class InstanceSettingsPage : public QWidget, public BasePage
|
|||||||
public:
|
public:
|
||||||
explicit InstanceSettingsPage(BaseInstance *inst, QWidget *parent = 0);
|
explicit InstanceSettingsPage(BaseInstance *inst, QWidget *parent = 0);
|
||||||
virtual ~InstanceSettingsPage();
|
virtual ~InstanceSettingsPage();
|
||||||
virtual QString displayName() const override;
|
virtual QString displayName() const override
|
||||||
virtual QIcon icon() const override;
|
{
|
||||||
virtual QString id() 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 bool apply();
|
||||||
virtual QString helpPage() const override { return "Instance-settings"; }
|
virtual QString helpPage() const override
|
||||||
|
{
|
||||||
|
return "Instance-settings";
|
||||||
|
}
|
||||||
virtual bool shouldDisplay() const;
|
virtual bool shouldDisplay() const;
|
||||||
private slots:
|
private slots:
|
||||||
void on_javaDetectBtn_clicked();
|
void on_javaDetectBtn_clicked();
|
||||||
@ -51,6 +64,7 @@ private slots:
|
|||||||
|
|
||||||
void applySettings();
|
void applySettings();
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::InstanceSettingsPage *ui;
|
Ui::InstanceSettingsPage *ui;
|
||||||
BaseInstance *m_instance;
|
BaseInstance *m_instance;
|
||||||
|
@ -15,6 +15,13 @@
|
|||||||
|
|
||||||
#include "LegacyJarModPage.h"
|
#include "LegacyJarModPage.h"
|
||||||
#include "ui_LegacyJarModPage.h"
|
#include "ui_LegacyJarModPage.h"
|
||||||
|
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
#include <pathutils.h>
|
||||||
|
|
||||||
#include "gui/dialogs/VersionSelectDialog.h"
|
#include "gui/dialogs/VersionSelectDialog.h"
|
||||||
#include "gui/dialogs/ProgressDialog.h"
|
#include "gui/dialogs/ProgressDialog.h"
|
||||||
#include "gui/dialogs/ModEditDialogCommon.h"
|
#include "gui/dialogs/ModEditDialogCommon.h"
|
||||||
@ -23,10 +30,6 @@
|
|||||||
#include "logic/forge/ForgeVersion.h"
|
#include "logic/forge/ForgeVersion.h"
|
||||||
#include "logic/forge/ForgeVersionList.h"
|
#include "logic/forge/ForgeVersionList.h"
|
||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include <pathutils.h>
|
|
||||||
#include <QtGui/QKeyEvent>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QKeyEvent>
|
|
||||||
|
|
||||||
LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent)
|
LegacyJarModPage::LegacyJarModPage(LegacyInstance *inst, QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst)
|
: QWidget(parent), ui(new Ui::LegacyJarModPage), m_inst(inst)
|
||||||
@ -49,26 +52,11 @@ LegacyJarModPage::~LegacyJarModPage()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LegacyJarModPage::displayName() const
|
|
||||||
{
|
|
||||||
return tr("Jar Mods");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LegacyJarModPage::shouldDisplay() const
|
bool LegacyJarModPage::shouldDisplay() const
|
||||||
{
|
{
|
||||||
return !m_inst->isRunning();
|
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)
|
bool LegacyJarModPage::eventFilter(QObject *obj, QEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->type() != QEvent::KeyPress || obj != ui->jarModsTreeView)
|
if (ev->type() != QEvent::KeyPress || obj != ui->jarModsTreeView)
|
||||||
|
@ -15,8 +15,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QWidget>
|
||||||
#include <logic/net/NetJob.h>
|
|
||||||
|
#include "logic/net/NetJob.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
class ModList;
|
class ModList;
|
||||||
@ -34,10 +35,22 @@ public:
|
|||||||
explicit LegacyJarModPage(LegacyInstance *inst, QWidget *parent = 0);
|
explicit LegacyJarModPage(LegacyInstance *inst, QWidget *parent = 0);
|
||||||
virtual ~LegacyJarModPage();
|
virtual ~LegacyJarModPage();
|
||||||
|
|
||||||
virtual QString displayName() const;
|
virtual QString displayName() const
|
||||||
virtual QIcon icon() const;
|
{
|
||||||
virtual QString id() const;
|
return tr("Jar Mods");
|
||||||
virtual QString helpPage() const override { return "Legacy-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;
|
virtual bool shouldDisplay() const;
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -1,21 +1,7 @@
|
|||||||
#include "LegacyUpgradePage.h"
|
#include "LegacyUpgradePage.h"
|
||||||
#include <logic/LegacyInstance.h>
|
|
||||||
#include "ui_LegacyUpgradePage.h"
|
#include "ui_LegacyUpgradePage.h"
|
||||||
|
|
||||||
QString LegacyUpgradePage::displayName() const
|
#include "logic/LegacyInstance.h"
|
||||||
{
|
|
||||||
return tr("Upgrade");
|
|
||||||
}
|
|
||||||
|
|
||||||
QIcon LegacyUpgradePage::icon() const
|
|
||||||
{
|
|
||||||
return QIcon::fromTheme("checkupdate");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString LegacyUpgradePage::id() const
|
|
||||||
{
|
|
||||||
return "upgrade";
|
|
||||||
}
|
|
||||||
|
|
||||||
LegacyUpgradePage::LegacyUpgradePage(LegacyInstance *inst, QWidget *parent)
|
LegacyUpgradePage::LegacyUpgradePage(LegacyInstance *inst, QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
|
: QWidget(parent), ui(new Ui::LegacyUpgradePage), m_inst(inst)
|
||||||
|
@ -14,10 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <logic/OneSixInstance.h>
|
#include "logic/OneSixInstance.h"
|
||||||
#include <logic/net/NetJob.h>
|
#include "logic/net/NetJob.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
class EnabledItemFilter;
|
class EnabledItemFilter;
|
||||||
@ -33,10 +34,22 @@ class LegacyUpgradePage : public QWidget, public BasePage
|
|||||||
public:
|
public:
|
||||||
explicit LegacyUpgradePage(LegacyInstance *inst, QWidget *parent = 0);
|
explicit LegacyUpgradePage(LegacyInstance *inst, QWidget *parent = 0);
|
||||||
virtual ~LegacyUpgradePage();
|
virtual ~LegacyUpgradePage();
|
||||||
virtual QString displayName() const override;
|
virtual QString displayName() const override
|
||||||
virtual QIcon icon() const override;
|
{
|
||||||
virtual QString id() const override;
|
return tr("Upgrade");
|
||||||
virtual QString helpPage() const override { return "Legacy-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;
|
virtual bool shouldDisplay() const;
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
|
@ -7,21 +7,6 @@
|
|||||||
#include "logic/MinecraftProcess.h"
|
#include "logic/MinecraftProcess.h"
|
||||||
#include "gui/GuiUtil.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)
|
LogPage::LogPage(MinecraftProcess *proc, QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::LogPage), m_process(proc)
|
: QWidget(parent), ui(new Ui::LogPage), m_process(proc)
|
||||||
{
|
{
|
||||||
|
@ -13,13 +13,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <logic/BaseInstance.h>
|
#include "logic/BaseInstance.h"
|
||||||
#include <logic/net/NetJob.h>
|
#include "logic/net/NetJob.h"
|
||||||
#include <logic/MinecraftProcess.h>
|
#include "logic/MinecraftProcess.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
class EnabledItemFilter;
|
class EnabledItemFilter;
|
||||||
@ -36,11 +36,23 @@ class LogPage : public QWidget, public BasePage
|
|||||||
public:
|
public:
|
||||||
explicit LogPage(MinecraftProcess *proc, QWidget *parent = 0);
|
explicit LogPage(MinecraftProcess *proc, QWidget *parent = 0);
|
||||||
virtual ~LogPage();
|
virtual ~LogPage();
|
||||||
virtual QString displayName() const override;
|
virtual QString displayName() const override
|
||||||
virtual QIcon icon() const override;
|
{
|
||||||
virtual QString id() 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 bool apply();
|
||||||
virtual QString helpPage() const override { return "Minecraft-Log"; }
|
virtual QString helpPage() const override
|
||||||
|
{
|
||||||
|
return "Minecraft-Log";
|
||||||
|
}
|
||||||
virtual bool shouldDisplay() const;
|
virtual bool shouldDisplay() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MultiMC.h"
|
#include "ModFolderPage.h"
|
||||||
|
#include "ui_ModFolderPage.h"
|
||||||
|
|
||||||
#include <pathutils.h>
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
@ -23,33 +23,18 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
#include "ModFolderPage.h"
|
#include <pathutils.h>
|
||||||
#include "ui_ModFolderPage.h"
|
|
||||||
|
|
||||||
|
#include "MultiMC.h"
|
||||||
#include "gui/dialogs/CustomMessageBox.h"
|
#include "gui/dialogs/CustomMessageBox.h"
|
||||||
#include "gui/dialogs/ModEditDialogCommon.h"
|
#include "gui/dialogs/ModEditDialogCommon.h"
|
||||||
|
|
||||||
#include "logic/ModList.h"
|
#include "logic/ModList.h"
|
||||||
#include "logic/Mod.h"
|
#include "logic/Mod.h"
|
||||||
#include <logic/VersionFilterData.h>
|
#include "logic/VersionFilterData.h"
|
||||||
|
|
||||||
QString ModFolderPage::displayName() const
|
ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<ModList> mods, QString id,
|
||||||
{
|
QString iconName, QString displayName, QString helpPage,
|
||||||
return m_displayName;
|
QWidget *parent)
|
||||||
}
|
|
||||||
|
|
||||||
QIcon ModFolderPage::icon() const
|
|
||||||
{
|
|
||||||
return QIcon::fromTheme(m_iconName);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ModFolderPage::id() const
|
|
||||||
{
|
|
||||||
return m_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
: QWidget(parent), ui(new Ui::ModFolderPage)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -82,7 +67,7 @@ ModFolderPage::~ModFolderPage()
|
|||||||
|
|
||||||
bool ModFolderPage::shouldDisplay() const
|
bool ModFolderPage::shouldDisplay() const
|
||||||
{
|
{
|
||||||
if(m_inst)
|
if (m_inst)
|
||||||
return !m_inst->isRunning();
|
return !m_inst->isRunning();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -91,13 +76,13 @@ bool CoreModFolderPage::shouldDisplay() const
|
|||||||
{
|
{
|
||||||
if (ModFolderPage::shouldDisplay())
|
if (ModFolderPage::shouldDisplay())
|
||||||
{
|
{
|
||||||
auto inst = dynamic_cast<OneSixInstance*>(m_inst);
|
auto inst = dynamic_cast<OneSixInstance *>(m_inst);
|
||||||
if(!inst)
|
if (!inst)
|
||||||
return true;
|
return true;
|
||||||
auto version = inst->getFullVersion();
|
auto version = inst->getFullVersion();
|
||||||
if(!version)
|
if (!version)
|
||||||
return true;
|
return true;
|
||||||
if(version->m_releaseTime < g_VersionFilterData.legacyCutoffDate)
|
if (version->m_releaseTime < g_VersionFilterData.legacyCutoffDate)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <logic/OneSixInstance.h>
|
#include "logic/OneSixInstance.h"
|
||||||
#include <logic/net/NetJob.h>
|
#include "logic/net/NetJob.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
class EnabledItemFilter;
|
class EnabledItemFilter;
|
||||||
@ -36,9 +37,18 @@ public:
|
|||||||
QString iconName, QString displayName, QString helpPage = "",
|
QString iconName, QString displayName, QString helpPage = "",
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
virtual ~ModFolderPage();
|
virtual ~ModFolderPage();
|
||||||
virtual QString displayName() const override;
|
virtual QString displayName() const override
|
||||||
virtual QIcon icon() const override;
|
{
|
||||||
virtual QString id() 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
|
virtual QString helpPage() const override
|
||||||
{
|
{
|
||||||
return m_helpName;
|
return m_helpName;
|
||||||
|
@ -1,21 +1,6 @@
|
|||||||
#include "NotesPage.h"
|
#include "NotesPage.h"
|
||||||
#include "ui_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)
|
NotesPage::NotesPage(BaseInstance *inst, QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::NotesPage), m_inst(inst)
|
: QWidget(parent), ui(new Ui::NotesPage), m_inst(inst)
|
||||||
{
|
{
|
||||||
|
@ -14,10 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <logic/BaseInstance.h>
|
#include "logic/BaseInstance.h"
|
||||||
#include <logic/net/NetJob.h>
|
#include "logic/net/NetJob.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
class EnabledItemFilter;
|
class EnabledItemFilter;
|
||||||
@ -33,11 +34,23 @@ class NotesPage : public QWidget, public BasePage
|
|||||||
public:
|
public:
|
||||||
explicit NotesPage(BaseInstance *inst, QWidget *parent = 0);
|
explicit NotesPage(BaseInstance *inst, QWidget *parent = 0);
|
||||||
virtual ~NotesPage();
|
virtual ~NotesPage();
|
||||||
virtual QString displayName() const override;
|
virtual QString displayName() const override
|
||||||
virtual QIcon icon() const override;
|
{
|
||||||
virtual QString id() 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 bool apply();
|
||||||
virtual QString helpPage() const override { return "Notes"; }
|
virtual QString helpPage() const override
|
||||||
|
{
|
||||||
|
return "Notes";
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NotesPage *ui;
|
Ui::NotesPage *ui;
|
||||||
|
@ -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 "OtherLogsPage.h"
|
||||||
#include "ui_OtherLogsPage.h"
|
#include "ui_OtherLogsPage.h"
|
||||||
|
|
||||||
@ -8,28 +23,18 @@
|
|||||||
#include "logic/RecursiveFileSystemWatcher.h"
|
#include "logic/RecursiveFileSystemWatcher.h"
|
||||||
#include "logic/BaseInstance.h"
|
#include "logic/BaseInstance.h"
|
||||||
|
|
||||||
OtherLogsPage::OtherLogsPage(BaseInstance *instance, QWidget *parent) :
|
OtherLogsPage::OtherLogsPage(BaseInstance *instance, QWidget *parent)
|
||||||
QWidget(parent),
|
: QWidget(parent), ui(new Ui::OtherLogsPage), m_instance(instance),
|
||||||
ui(new Ui::OtherLogsPage),
|
m_watcher(new RecursiveFileSystemWatcher(this))
|
||||||
m_instance(instance),
|
|
||||||
m_watcher(new RecursiveFileSystemWatcher(this))
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, [this]()
|
|
||||||
{
|
m_watcher->setFileExpression(".*\\.log$");
|
||||||
ui->selectLogBox->clear();
|
m_watcher->setRootDir(QDir::current().absoluteFilePath(m_instance->minecraftRoot()));
|
||||||
ui->selectLogBox->addItems(m_watcher->files());
|
|
||||||
ui->selectLogBox->addItem(tr("&Other"), true);
|
connect(m_watcher, &RecursiveFileSystemWatcher::filesChanged, this,
|
||||||
if (m_currentFile.isNull())
|
&OtherLogsPage::populateSelectLogBox);
|
||||||
{
|
populateSelectLogBox();
|
||||||
ui->selectLogBox->setCurrentIndex(-1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const int index = ui->selectLogBox->findText(m_currentFile);
|
|
||||||
ui->selectLogBox->setCurrentIndex(-1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OtherLogsPage::~OtherLogsPage()
|
OtherLogsPage::~OtherLogsPage()
|
||||||
@ -46,6 +51,22 @@ void OtherLogsPage::closed()
|
|||||||
m_watcher->disable();
|
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)
|
void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
|
||||||
{
|
{
|
||||||
QString file;
|
QString file;
|
||||||
@ -53,7 +74,8 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
|
|||||||
{
|
{
|
||||||
if (ui->selectLogBox->itemData(index).isValid())
|
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
|
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();
|
m_currentFile = QString();
|
||||||
|
ui->text->clear();
|
||||||
setControlsEnabled(false);
|
setControlsEnabled(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -76,13 +99,14 @@ void OtherLogsPage::on_selectLogBox_currentIndexChanged(const int index)
|
|||||||
|
|
||||||
void OtherLogsPage::on_btnReload_clicked()
|
void OtherLogsPage::on_btnReload_clicked()
|
||||||
{
|
{
|
||||||
QFile file(m_currentFile);
|
QFile file(m_instance->minecraftRoot() + "/" + m_currentFile);
|
||||||
if (!file.open(QFile::ReadOnly))
|
if (!file.open(QFile::ReadOnly))
|
||||||
{
|
{
|
||||||
setControlsEnabled(false);
|
setControlsEnabled(false);
|
||||||
ui->btnReload->setEnabled(true); // allow reload
|
ui->btnReload->setEnabled(true); // allow reload
|
||||||
m_currentFile = QString();
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -100,15 +124,17 @@ void OtherLogsPage::on_btnCopy_clicked()
|
|||||||
}
|
}
|
||||||
void OtherLogsPage::on_btnDelete_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)
|
if (QMessageBox::question(this, tr("Delete"),
|
||||||
== QMessageBox::No)
|
tr("Do you really want to delete %1?").arg(m_currentFile),
|
||||||
|
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QFile file(m_currentFile);
|
QFile file(m_instance->minecraftRoot() + "/" + m_currentFile);
|
||||||
if (!file.remove())
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class OtherLogsPage;
|
class OtherLogsPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,15 +36,27 @@ public:
|
|||||||
explicit OtherLogsPage(BaseInstance *instance, QWidget *parent = 0);
|
explicit OtherLogsPage(BaseInstance *instance, QWidget *parent = 0);
|
||||||
~OtherLogsPage();
|
~OtherLogsPage();
|
||||||
|
|
||||||
QString id() const override { return "logs"; }
|
QString id() const override
|
||||||
QString displayName() const override { return tr("Other logs"); }
|
{
|
||||||
QIcon icon() const override { return QIcon(); } // TODO
|
return "logs";
|
||||||
QString helpPage() const override { return "Minecraft-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 opened() override;
|
||||||
void closed() override;
|
void closed() override;
|
||||||
|
|
||||||
private
|
private slots:
|
||||||
slots:
|
void populateSelectLogBox();
|
||||||
void on_selectLogBox_currentIndexChanged(const int index);
|
void on_selectLogBox_currentIndexChanged(const int index);
|
||||||
void on_btnReload_clicked();
|
void on_btnReload_clicked();
|
||||||
void on_btnPaste_clicked();
|
void on_btnPaste_clicked();
|
||||||
|
@ -39,7 +39,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<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>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnReload">
|
<widget class="QPushButton" name="btnReload">
|
||||||
|
@ -5,8 +5,8 @@ class ResourcePackPage : public ModFolderPage
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit ResourcePackPage(BaseInstance *instance, QWidget *parent = 0)
|
explicit ResourcePackPage(BaseInstance *instance, QWidget *parent = 0)
|
||||||
: ModFolderPage(instance, instance->resourcePackList(), "resourcepacks", "resourcepacks",
|
: ModFolderPage(instance, instance->resourcePackList(), "resourcepacks",
|
||||||
tr("Resource packs"), "Resource-packs", parent)
|
"resourcepacks", tr("Resource packs"), "Resource-packs", parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,11 @@
|
|||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QtGui/qevent.h>
|
#include <QEvent>
|
||||||
#include <QtGui/QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui/QClipboard>
|
#include <QClipboard>
|
||||||
#include <QtGui/QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
#include <pathutils.h>
|
#include <pathutils.h>
|
||||||
|
|
||||||
@ -24,30 +25,25 @@
|
|||||||
#include "logic/tasks/SequentialTask.h"
|
#include "logic/tasks/SequentialTask.h"
|
||||||
|
|
||||||
#include "logic/RWStorage.h"
|
#include "logic/RWStorage.h"
|
||||||
|
|
||||||
typedef RWStorage<QString, QIcon> SharedIconCache;
|
typedef RWStorage<QString, QIcon> SharedIconCache;
|
||||||
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr;
|
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr;
|
||||||
|
|
||||||
class ThumbnailingResult : public QObject
|
class ThumbnailingResult : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public Q_SLOTS:
|
public slots:
|
||||||
inline void emitResultsReady(const QString &path)
|
inline void emitResultsReady(const QString &path) { emit resultsReady(path); }
|
||||||
{
|
inline void emitResultsFailed(const QString &path) { emit resultsFailed(path); }
|
||||||
emit resultsReady(path);
|
signals:
|
||||||
}
|
|
||||||
inline void emitResultsFailed(const QString &path)
|
|
||||||
{
|
|
||||||
emit resultsFailed(path);
|
|
||||||
}
|
|
||||||
Q_SIGNALS:
|
|
||||||
void resultsReady(const QString &path);
|
void resultsReady(const QString &path);
|
||||||
void resultsFailed(const QString &path);
|
void resultsFailed(const QString &path);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ThumbnailRunnable: public QRunnable
|
class ThumbnailRunnable : public QRunnable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThumbnailRunnable (QString path, SharedIconCachePtr cache)
|
ThumbnailRunnable(QString path, SharedIconCachePtr cache)
|
||||||
{
|
{
|
||||||
m_path = path;
|
m_path = path;
|
||||||
m_cache = cache;
|
m_cache = cache;
|
||||||
@ -55,14 +51,14 @@ public:
|
|||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
QFileInfo info(m_path);
|
QFileInfo info(m_path);
|
||||||
if(info.isDir())
|
if (info.isDir())
|
||||||
return;
|
return;
|
||||||
if((info.suffix().compare("png", Qt::CaseInsensitive) != 0))
|
if ((info.suffix().compare("png", Qt::CaseInsensitive) != 0))
|
||||||
return;
|
return;
|
||||||
int tries = 5;
|
int tries = 5;
|
||||||
while(tries)
|
while (tries)
|
||||||
{
|
{
|
||||||
if(!m_cache->stale(m_path))
|
if (!m_cache->stale(m_path))
|
||||||
return;
|
return;
|
||||||
QImage image(m_path);
|
QImage image(m_path);
|
||||||
if (image.isNull())
|
if (image.isNull())
|
||||||
@ -72,13 +68,13 @@ public:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QImage small;
|
QImage small;
|
||||||
if(image.width() > image.height())
|
if (image.width() > image.height())
|
||||||
small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
|
small = image.scaledToWidth(512).scaledToWidth(256, Qt::SmoothTransformation);
|
||||||
else
|
else
|
||||||
small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
|
small = image.scaledToHeight(512).scaledToHeight(256, Qt::SmoothTransformation);
|
||||||
auto smallSize = small.size();
|
auto smallSize = small.size();
|
||||||
QPoint offset((256-small.width())/2, (256-small.height())/2);
|
QPoint offset((256 - small.width()) / 2, (256 - small.height()) / 2);
|
||||||
QImage square(QSize(256,256), QImage::Format_ARGB32);
|
QImage square(QSize(256, 256), QImage::Format_ARGB32);
|
||||||
square.fill(Qt::transparent);
|
square.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter painter(&square);
|
QPainter painter(&square);
|
||||||
@ -97,12 +93,13 @@ public:
|
|||||||
ThumbnailingResult m_resultEmitter;
|
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
|
class FilterModel : public QIdentityProxyModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit FilterModel(QObject *parent = 0):QIdentityProxyModel(parent)
|
explicit FilterModel(QObject *parent = 0) : QIdentityProxyModel(parent)
|
||||||
{
|
{
|
||||||
m_thumbnailingPool.setMaxThreadCount(4);
|
m_thumbnailingPool.setMaxThreadCount(4);
|
||||||
m_thumbnailCache = std::make_shared<SharedIconCache>();
|
m_thumbnailCache = std::make_shared<SharedIconCache>();
|
||||||
@ -110,10 +107,7 @@ public:
|
|||||||
connect(&watcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
|
connect(&watcher, SIGNAL(fileChanged(QString)), SLOT(fileChanged(QString)));
|
||||||
// FIXME: the watched file set is not updated when files are removed
|
// FIXME: the watched file set is not updated when files are removed
|
||||||
}
|
}
|
||||||
virtual ~FilterModel()
|
virtual ~FilterModel() { m_thumbnailingPool.waitForDone(500); }
|
||||||
{
|
|
||||||
m_thumbnailingPool.waitForDone(500);
|
|
||||||
}
|
|
||||||
virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const
|
virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const
|
||||||
{
|
{
|
||||||
auto model = sourceModel();
|
auto model = sourceModel();
|
||||||
@ -126,23 +120,24 @@ public:
|
|||||||
}
|
}
|
||||||
if (role == Qt::DecorationRole)
|
if (role == Qt::DecorationRole)
|
||||||
{
|
{
|
||||||
QVariant result = sourceModel()->data(mapToSource(proxyIndex), QFileSystemModel::FilePathRole);
|
QVariant result =
|
||||||
|
sourceModel()->data(mapToSource(proxyIndex), QFileSystemModel::FilePathRole);
|
||||||
QString filePath = result.toString();
|
QString filePath = result.toString();
|
||||||
QIcon temp;
|
QIcon temp;
|
||||||
if(!watched.contains(filePath))
|
if (!watched.contains(filePath))
|
||||||
{
|
{
|
||||||
((QFileSystemWatcher &)watcher).addPath(filePath);
|
((QFileSystemWatcher &)watcher).addPath(filePath);
|
||||||
((QSet<QString> &)watched).insert(filePath);
|
((QSet<QString> &)watched).insert(filePath);
|
||||||
}
|
}
|
||||||
if(m_thumbnailCache->get(filePath, temp))
|
if (m_thumbnailCache->get(filePath, temp))
|
||||||
{
|
{
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
if(!m_failed.contains(filePath))
|
if (!m_failed.contains(filePath))
|
||||||
{
|
{
|
||||||
((FilterModel *)this)->thumbnailImage(filePath);
|
((FilterModel *)this)->thumbnailImage(filePath);
|
||||||
}
|
}
|
||||||
return(m_thumbnailCache->get("placeholder"));
|
return (m_thumbnailCache->get("placeholder"));
|
||||||
}
|
}
|
||||||
return sourceModel()->data(mapToSource(proxyIndex), role);
|
return sourceModel()->data(mapToSource(proxyIndex), role);
|
||||||
}
|
}
|
||||||
@ -162,24 +157,20 @@ public:
|
|||||||
}
|
}
|
||||||
return model->setData(mapToSource(index), value.toString() + ".png", role);
|
return model->setData(mapToSource(index), value.toString() + ".png", role);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void thumbnailImage(QString path)
|
void thumbnailImage(QString path)
|
||||||
{
|
{
|
||||||
auto runnable = new ThumbnailRunnable(path, m_thumbnailCache);
|
auto runnable = new ThumbnailRunnable(path, m_thumbnailCache);
|
||||||
connect(&(runnable->m_resultEmitter),SIGNAL(resultsReady(QString)), SLOT(thumbnailReady(QString)));
|
connect(&(runnable->m_resultEmitter), SIGNAL(resultsReady(QString)),
|
||||||
connect(&(runnable->m_resultEmitter),SIGNAL(resultsFailed(QString)), SLOT(thumbnailFailed(QString)));
|
SLOT(thumbnailReady(QString)));
|
||||||
|
connect(&(runnable->m_resultEmitter), SIGNAL(resultsFailed(QString)),
|
||||||
|
SLOT(thumbnailFailed(QString)));
|
||||||
((QThreadPool &)m_thumbnailingPool).start(runnable);
|
((QThreadPool &)m_thumbnailingPool).start(runnable);
|
||||||
}
|
}
|
||||||
private
|
private slots:
|
||||||
slots:
|
void thumbnailReady(QString path) { emit layoutChanged(); }
|
||||||
void thumbnailReady(QString path)
|
void thumbnailFailed(QString path) { m_failed.insert(path); }
|
||||||
{
|
|
||||||
emit layoutChanged();
|
|
||||||
}
|
|
||||||
void thumbnailFailed(QString path)
|
|
||||||
{
|
|
||||||
m_failed.insert(path);
|
|
||||||
}
|
|
||||||
void fileChanged(QString filepath)
|
void fileChanged(QString filepath)
|
||||||
{
|
{
|
||||||
m_thumbnailCache->setStale(filepath);
|
m_thumbnailCache->setStale(filepath);
|
||||||
@ -200,12 +191,8 @@ private:
|
|||||||
class CenteredEditingDelegate : public QStyledItemDelegate
|
class CenteredEditingDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CenteredEditingDelegate(QObject *parent = 0) : QStyledItemDelegate(parent)
|
explicit CenteredEditingDelegate(QObject *parent = 0) : QStyledItemDelegate(parent) {}
|
||||||
{
|
virtual ~CenteredEditingDelegate() {}
|
||||||
}
|
|
||||||
virtual ~CenteredEditingDelegate()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||||
const QModelIndex &index) const
|
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)
|
ScreenshotsPage::ScreenshotsPage(BaseInstance *instance, QWidget *parent)
|
||||||
: QWidget(parent), ui(new Ui::ScreenshotsPage)
|
: QWidget(parent), ui(new Ui::ScreenshotsPage)
|
||||||
{
|
{
|
||||||
@ -341,7 +313,8 @@ void ScreenshotsPage::on_uploadBtn_clicked()
|
|||||||
QDesktopServices::openUrl(link);
|
QDesktopServices::openUrl(link);
|
||||||
CustomMessageBox::selectable(
|
CustomMessageBox::selectable(
|
||||||
this, tr("Upload finished"),
|
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)")
|
"this if you want to be able to edit/delete the album)")
|
||||||
.arg(link, imgurAlbum->deleteHash()),
|
.arg(link, imgurAlbum->deleteHash()),
|
||||||
QMessageBox::Information)->exec();
|
QMessageBox::Information)->exec();
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <logic/OneSixInstance.h>
|
|
||||||
|
#include "logic/OneSixInstance.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
#include <QIcon>
|
|
||||||
#include <QEvent>
|
|
||||||
|
|
||||||
class QFileSystemModel;
|
class QFileSystemModel;
|
||||||
class QIdentityProxyModel;
|
class QIdentityProxyModel;
|
||||||
@ -47,12 +47,23 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual bool eventFilter(QObject *, QEvent *);
|
virtual bool eventFilter(QObject *, QEvent *);
|
||||||
virtual QString displayName() const override;
|
virtual QString displayName() const override
|
||||||
virtual QIcon icon() const override;
|
{
|
||||||
virtual QString id() const override;
|
return tr("Screenshots");
|
||||||
virtual QString helpPage() const override { return "Screenshots-management"; }
|
}
|
||||||
private
|
virtual QIcon icon() const override
|
||||||
slots:
|
{
|
||||||
|
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_uploadBtn_clicked();
|
||||||
void on_deleteBtn_clicked();
|
void on_deleteBtn_clicked();
|
||||||
void on_renameBtn_clicked();
|
void on_renameBtn_clicked();
|
||||||
|
@ -31,6 +31,12 @@
|
|||||||
|
|
||||||
#include "gui/dialogs/ProgressDialog.h"
|
#include "gui/dialogs/ProgressDialog.h"
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QString>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
#include "logic/ModList.h"
|
#include "logic/ModList.h"
|
||||||
#include "logic/minecraft/InstanceVersion.h"
|
#include "logic/minecraft/InstanceVersion.h"
|
||||||
#include "logic/EnabledItemFilter.h"
|
#include "logic/EnabledItemFilter.h"
|
||||||
@ -40,31 +46,14 @@
|
|||||||
#include "logic/liteloader/LiteLoaderInstaller.h"
|
#include "logic/liteloader/LiteLoaderInstaller.h"
|
||||||
#include "logic/minecraft/VersionBuilder.h"
|
#include "logic/minecraft/VersionBuilder.h"
|
||||||
#include "logic/auth/MojangAccountList.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
|
QIcon VersionPage::icon() const
|
||||||
{
|
{
|
||||||
return MMC->icons()->getIcon(m_inst->iconKey());
|
return MMC->icons()->getIcon(m_inst->iconKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VersionPage::id() const
|
|
||||||
{
|
|
||||||
return "version";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool VersionPage::shouldDisplay() const
|
bool VersionPage::shouldDisplay() const
|
||||||
{
|
{
|
||||||
return !m_inst->isRunning();
|
return !m_inst->isRunning();
|
||||||
|
@ -14,10 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include <logic/OneSixInstance.h>
|
#include "logic/OneSixInstance.h"
|
||||||
#include <logic/net/NetJob.h>
|
#include "logic/net/NetJob.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
|
|
||||||
class EnabledItemFilter;
|
class EnabledItemFilter;
|
||||||
@ -33,10 +34,19 @@ class VersionPage : public QWidget, public BasePage
|
|||||||
public:
|
public:
|
||||||
explicit VersionPage(OneSixInstance *inst, QWidget *parent = 0);
|
explicit VersionPage(OneSixInstance *inst, QWidget *parent = 0);
|
||||||
virtual ~VersionPage();
|
virtual ~VersionPage();
|
||||||
virtual QString displayName() const override;
|
virtual QString displayName() const override
|
||||||
|
{
|
||||||
|
return tr("Version");
|
||||||
|
}
|
||||||
virtual QIcon icon() const override;
|
virtual QIcon icon() const override;
|
||||||
virtual QString id() const override;
|
virtual QString id() const override
|
||||||
virtual QString helpPage() const override { return "Instance-version"; }
|
{
|
||||||
|
return "version";
|
||||||
|
}
|
||||||
|
virtual QString helpPage() const override
|
||||||
|
{
|
||||||
|
return "Instance-version";
|
||||||
|
}
|
||||||
virtual bool shouldDisplay() const;
|
virtual bool shouldDisplay() const;
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
|
@ -14,12 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "PageContainer.h"
|
#include "PageContainer.h"
|
||||||
#include "gui/Platform.h"
|
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include "MultiMC.h"
|
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
@ -27,10 +26,12 @@
|
|||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QDesktopServices>
|
#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 "PageContainer_p.h"
|
||||||
#include <gui/widgets/IconLabel.h>
|
|
||||||
|
|
||||||
class PageEntryFilterModel : public QSortFilterProxyModel
|
class PageEntryFilterModel : public QSortFilterProxyModel
|
||||||
{
|
{
|
||||||
@ -197,5 +198,9 @@ bool PageContainer::requestClose(QCloseEvent *event)
|
|||||||
if (!page->apply())
|
if (!page->apply())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (m_currentPage)
|
||||||
|
{
|
||||||
|
m_currentPage->closed();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <gui/pages/BasePageProvider.h>
|
|
||||||
|
#include "gui/pages/BasePageProvider.h"
|
||||||
|
|
||||||
class QLayout;
|
class QLayout;
|
||||||
class IconLabel;
|
class IconLabel;
|
||||||
@ -34,7 +36,7 @@ class PageContainer : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit PageContainer(BasePageProviderPtr pageProvider, QString defaultId = QString(),
|
explicit PageContainer(BasePageProviderPtr pageProvider, QString defaultId = QString(),
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
virtual ~PageContainer() {};
|
virtual ~PageContainer() {}
|
||||||
|
|
||||||
void addButtons(QWidget * buttons);
|
void addButtons(QWidget * buttons);
|
||||||
void addButtons(QLayout * buttons);
|
void addButtons(QLayout * buttons);
|
||||||
@ -49,7 +51,7 @@ slots:
|
|||||||
void help();
|
void help();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BasePage * m_currentPage;
|
BasePage * m_currentPage = 0;
|
||||||
QSortFilterProxyModel *m_proxyModel;
|
QSortFilterProxyModel *m_proxyModel;
|
||||||
PageModel *m_model;
|
PageModel *m_model;
|
||||||
QStackedLayout *m_pageStack;
|
QStackedLayout *m_pageStack;
|
||||||
|
@ -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
|
#pragma once
|
||||||
|
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
@ -30,7 +46,7 @@ public:
|
|||||||
empty.fill(Qt::transparent);
|
empty.fill(Qt::transparent);
|
||||||
m_emptyIcon = QIcon(empty);
|
m_emptyIcon = QIcon(empty);
|
||||||
}
|
}
|
||||||
virtual ~PageModel() {};
|
virtual ~PageModel() {}
|
||||||
|
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const
|
int rowCount(const QModelIndex &parent = QModelIndex()) const
|
||||||
{
|
{
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
#include "RecursiveFileSystemWatcher.h"
|
#include "RecursiveFileSystemWatcher.h"
|
||||||
|
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
RecursiveFileSystemWatcher::RecursiveFileSystemWatcher(QObject *parent)
|
RecursiveFileSystemWatcher::RecursiveFileSystemWatcher(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent), m_exp(".*"), m_watcher(new QFileSystemWatcher(this))
|
||||||
m_watcher(new QFileSystemWatcher(this))
|
|
||||||
{
|
{
|
||||||
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, &RecursiveFileSystemWatcher::fileChange);
|
connect(m_watcher, &QFileSystemWatcher::fileChanged, this,
|
||||||
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, &RecursiveFileSystemWatcher::directoryChange);
|
&RecursiveFileSystemWatcher::fileChange);
|
||||||
|
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this,
|
||||||
|
&RecursiveFileSystemWatcher::directoryChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RecursiveFileSystemWatcher::setRootDir(const QDir &root)
|
void RecursiveFileSystemWatcher::setRootDir(const QDir &root)
|
||||||
@ -34,12 +36,20 @@ void RecursiveFileSystemWatcher::setWatchFiles(const bool watchFiles)
|
|||||||
|
|
||||||
void RecursiveFileSystemWatcher::enable()
|
void RecursiveFileSystemWatcher::enable()
|
||||||
{
|
{
|
||||||
|
if (m_isEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Q_ASSERT(m_root != QDir::root());
|
Q_ASSERT(m_root != QDir::root());
|
||||||
addFilesToWatcherRecursive(m_root);
|
addFilesToWatcherRecursive(m_root);
|
||||||
m_isEnabled = true;
|
m_isEnabled = true;
|
||||||
}
|
}
|
||||||
void RecursiveFileSystemWatcher::disable()
|
void RecursiveFileSystemWatcher::disable()
|
||||||
{
|
{
|
||||||
|
if (!m_isEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_isEnabled = false;
|
m_isEnabled = false;
|
||||||
m_watcher->removePaths(m_watcher->files());
|
m_watcher->removePaths(m_watcher->files());
|
||||||
m_watcher->removePaths(m_watcher->directories());
|
m_watcher->removePaths(m_watcher->directories());
|
||||||
@ -57,9 +67,9 @@ void RecursiveFileSystemWatcher::setFiles(const QStringList &files)
|
|||||||
void RecursiveFileSystemWatcher::addFilesToWatcherRecursive(const QDir &dir)
|
void RecursiveFileSystemWatcher::addFilesToWatcherRecursive(const QDir &dir)
|
||||||
{
|
{
|
||||||
m_watcher->addPath(dir.absolutePath());
|
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)
|
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;
|
QStringList ret;
|
||||||
QRegularExpression exp(m_exp);
|
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(scanRecursive(directory.absoluteFilePath(dir)));
|
||||||
|
}
|
||||||
|
for (const QString &file : directory.entryList(QDir::Files))
|
||||||
|
{
|
||||||
|
if (exp.match(file).hasMatch())
|
||||||
{
|
{
|
||||||
ret.append(info.absoluteFilePath());
|
ret.append(m_root.relativeFilePath(directory.absoluteFilePath(file)));
|
||||||
}
|
|
||||||
else if (info.isDir())
|
|
||||||
{
|
|
||||||
ret.append(scanRecursive(info.absoluteDir()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -25,8 +25,7 @@ signals:
|
|||||||
void filesChanged();
|
void filesChanged();
|
||||||
void fileChanged(const QString &path);
|
void fileChanged(const QString &path);
|
||||||
|
|
||||||
public
|
public slots:
|
||||||
slots:
|
|
||||||
void enable();
|
void enable();
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
@ -39,13 +38,12 @@ private:
|
|||||||
QFileSystemWatcher *m_watcher;
|
QFileSystemWatcher *m_watcher;
|
||||||
|
|
||||||
QStringList m_files;
|
QStringList m_files;
|
||||||
void setFiles(const QStringList &scanRecursive);
|
void setFiles(const QStringList &files);
|
||||||
|
|
||||||
void addFilesToWatcherRecursive(const QDir &dir);
|
void addFilesToWatcherRecursive(const QDir &dir);
|
||||||
QStringList scanRecursive(const QDir &dir);
|
QStringList scanRecursive(const QDir &dir);
|
||||||
|
|
||||||
private
|
private slots:
|
||||||
slots:
|
|
||||||
void fileChange(const QString &path);
|
void fileChange(const QString &path);
|
||||||
void directoryChange(const QString &path);
|
void directoryChange(const QString &path);
|
||||||
};
|
};
|
||||||
|
BIN
resources/multimc/16x16/log.png
Normal file
BIN
resources/multimc/16x16/log.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 630 B |
BIN
resources/multimc/24x24/log.png
Normal file
BIN
resources/multimc/24x24/log.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
resources/multimc/32x32/log.png
Normal file
BIN
resources/multimc/32x32/log.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
resources/multimc/48x48/log.png
Normal file
BIN
resources/multimc/48x48/log.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
resources/multimc/64x64/log.png
Normal file
BIN
resources/multimc/64x64/log.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
@ -165,6 +165,13 @@
|
|||||||
<file>32x32/noaccount.png</file>
|
<file>32x32/noaccount.png</file>
|
||||||
<file>48x48/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 -->
|
<!-- placeholder when loading screenshot images -->
|
||||||
<file>scalable/screenshot-placeholder.svg</file>
|
<file>scalable/screenshot-placeholder.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
Loading…
Reference in New Issue
Block a user