-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75ff165
commit 089155b
Showing
45 changed files
with
514 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
// Unit Include | ||
#include "controller.h" | ||
|
||
// libfp Includes | ||
#include <fp/fp-install.h> | ||
|
||
// Project Includes | ||
#include "launcher/fe-install.h" | ||
|
||
//=============================================================================================================== | ||
// Controller | ||
//=============================================================================================================== | ||
|
||
//-Constructor------------------------------------------------------------- | ||
//Public: | ||
Controller::Controller() | ||
{ | ||
// Setup properties | ||
mImportProperties.setHasLinkPermissions(testForLinkPermissions()); | ||
mImportProperties.bindableIsLauncherPresent().setBinding([this]{ return mLauncher.value(); }); | ||
mImportProperties.bindableIsLauncherValid().setBinding([this]{ return mLauncher.value() && mLauncher->isValid(); }); | ||
mImportProperties.bindableIsFlashpointPresent().setBinding([this]{ return mFlashpoint.value(); }); | ||
mImportProperties.bindableIsFlashpointValid().setBinding([this]{ return mFlashpoint.value() && mFlashpoint->isValid(); }); | ||
mImportProperties.bindableIsFlashpointTargetSeries().setBinding([this]{ return mFlashpoint.value() && mFlashpoint->isValid() && installMatchesTargetSeries(*mFlashpoint.value()); }); | ||
mImportProperties.bindableImageModeOrder().setBinding([this]{ | ||
/* Even though technically we only need the launcher, check for both installs to prevent the selection | ||
* from moving until its section is available | ||
*/ | ||
static QList<Fe::ImageMode> defOrder{Fe::ImageMode::Link, Fe::ImageMode::Reference, Fe::ImageMode::Copy}; | ||
bool def = !(mLauncher.value() && mLauncher->isValid() && mFlashpoint.value() && mFlashpoint->isValid()); | ||
auto order = def ? defOrder : mLauncher->preferredImageModeOrder(); | ||
if(!mImportProperties.hasLinkPermissions()) | ||
order.removeAll(Fe::ImageMode::Link); | ||
|
||
return order; | ||
}); | ||
mImportProperties.bindableIsImageDownloadable().setBinding([this]{ | ||
return mFlashpoint.value() && mFlashpoint->isValid() && mFlashpoint->preferences().onDemandImages; | ||
} ); | ||
mImportProperties.bindableLauncherInfo().setBinding([this]{ return (mLauncher.value() && mLauncher->isValid()) ? mLauncher->name() + ' ' + mLauncher->versionString() : QString(); }); | ||
mImportProperties.bindableLauncherInfo().setBinding([this]{ return (mFlashpoint.value() && mFlashpoint->isValid()) ? mFlashpoint->versionInfo()->fullString() : QString(); }); | ||
} | ||
|
||
//-Class Functions------------------------------------------------------------- | ||
//Private: | ||
bool Controller::testForLinkPermissions() | ||
{ | ||
QTemporaryDir testLinkDir; | ||
if(testLinkDir.isValid()) | ||
{ | ||
QFile testLinkTarget(testLinkDir.filePath(u"linktarget.tmp"_s)); | ||
|
||
if(testLinkTarget.open(QIODevice::WriteOnly)) | ||
{ | ||
testLinkTarget.close(); | ||
std::error_code symlinkError; | ||
std::filesystem::create_symlink(testLinkTarget.fileName().toStdString(), testLinkDir.filePath(u"testlink.tmp"_s).toStdString(), symlinkError); | ||
|
||
if(!symlinkError) | ||
return true; | ||
} | ||
} | ||
|
||
// Default | ||
return false; | ||
} | ||
|
||
bool Controller::installMatchesTargetSeries(const Fp::Install& fpInstall) | ||
{ | ||
Qx::VersionNumber fpVersion = fpInstall.versionInfo()->version(); | ||
return TARGET_FP_VERSION_PREFIX.isPrefixOf(fpVersion) || | ||
TARGET_FP_VERSION_PREFIX.normalized() == fpVersion; // Accounts for if FP doesn't use a trailing zero for major releases | ||
} | ||
|
||
|
||
//-Instance Functions------------------------------------------------------------- | ||
//Public: | ||
|
||
//-Signals & Slots------------------------------------------------------------- | ||
//Public slots: | ||
void Controller::updateInstallPath(const QString& installPath, ImportProperties::Install type) | ||
{ | ||
QString cleanPath = QDir::cleanPath(installPath); | ||
|
||
using enum ImportProperties::Install; | ||
switch(type) | ||
{ | ||
case Launcher: | ||
{ | ||
std::shared_ptr<Fe::Install> launcher; | ||
if(cleanPath.isEmpty()) | ||
launcher = nullptr; | ||
else | ||
{ | ||
launcher = Fe::Install::acquireMatch(cleanPath); | ||
if(!launcher->isValid()) | ||
NOTIFY | ||
} | ||
|
||
if(!launcher || !launcher->isValid()) | ||
invalidateInstall(install, true); // MIGHT NOT NEED DUE TO SUBSCRIBE AS IN NOTEPAD++ | ||
|
||
mLauncher = launcher; | ||
break; | ||
} | ||
case Flashpoint: | ||
{ | ||
std::shared_ptr<Fp::Install> flashpoint; | ||
if(cleanPath.isEmpty()) | ||
flashpoint = nullptr; | ||
else | ||
{ | ||
flashpoint = std::make_shared<Fp::Install>(cleanPath, true); | ||
if(!flashpoint->isValid()) | ||
NOTIFY | ||
} | ||
|
||
if(!flashpoint || !flashpoint->isValid()) | ||
invalidateInstall(install, true); // MIGHT NOT NEED DUE TO SUBSCRIBE AS IN NOTEPAD++ | ||
|
||
mFlashpoint = flashpoint; // Update target series property | ||
if(!mImportProperties.isFlashpointTargetSeries()) | ||
QMessageBox::warning(this, QApplication::applicationName(), MSG_FP_VER_NOT_TARGET); | ||
} | ||
} | ||
|
||
refreshEnableStates(); | ||
|
||
if(mFrontendInstall && mFlashpointInstall) | ||
gatherInstallInfo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#ifndef CONTROLLER_H | ||
#define CONTROLLER_H | ||
|
||
// Qt Includes | ||
#include <QObject> | ||
#include <QProperty> | ||
|
||
// Qx Includes | ||
#include <qx/core/qx-versionnumber.h> | ||
|
||
// Project Includes | ||
#include "kernel/import-properties.h" | ||
#include "project_vars.h" | ||
|
||
namespace Fe { class Install; } | ||
namespace Fp { class Install; } | ||
|
||
class Controller : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_OBJECT_BINDABLE_PROPERTY(Controller, std::shared_ptr<Fe::Install>, mLauncher); | ||
Q_OBJECT_BINDABLE_PROPERTY(Controller, std::shared_ptr<Fp::Install>, mFlashpoint); | ||
|
||
//-Class Variables--------------------------------------------------------------- | ||
// Flashpoint version check | ||
static inline const Qx::VersionNumber TARGET_FP_VERSION_PREFIX = Qx::VersionNumber::fromString(PROJECT_TARGET_FP_VER_PFX_STR); | ||
|
||
//-Instance Variables------------------------------------------------------------- | ||
private: | ||
ImportProperties mImportProperties; | ||
|
||
//-Constructor------------------------------------------------------------- | ||
public: | ||
Controller(); | ||
|
||
//-Class Functions------------------------------------------------------------- | ||
private: | ||
bool testForLinkPermissions(); | ||
bool installMatchesTargetSeries(const Fp::Install& fpInstall); | ||
|
||
//-Instance Functions------------------------------------------------------------- | ||
private: | ||
|
||
public: | ||
|
||
//-Signals & Slots------------------------------------------------------------- | ||
public slots: | ||
void updateInstallPath(const QString& installPath, ImportProperties::Install type); | ||
}; | ||
|
||
#endif // CONTROLLER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Unit Include | ||
#include "import-properties.h" | ||
|
||
//=============================================================================================================== | ||
// ImportProperties | ||
//=============================================================================================================== | ||
|
||
//-Constructor------------------------------------------------------------- | ||
//Public: | ||
ImportProperties::ImportProperties() : | ||
mHasLinkPerms(false) | ||
{} | ||
|
||
//-Instance Functions------------------------------------------------------------- | ||
//Public: | ||
void ImportProperties::setHasLinkPermissions(bool perms) { mHasLinkPerms = perms; } | ||
bool ImportProperties::hasLinkPermissions() const { return mHasLinkPerms; } | ||
|
||
QBindable<bool> ImportProperties::bindableIsLauncherPresent() { return &mLauncherPresent; } | ||
bool ImportProperties::isLauncherPresent() const { return mLauncherPresent; } | ||
|
||
QBindable<bool> ImportProperties::bindableIsLauncherValid() { return &mLauncherValid; } | ||
bool ImportProperties::isLauncherValid() const { return mLauncherValid; } | ||
|
||
QBindable<bool> ImportProperties::bindableIsFlashpointPresent() { return &mFlashpointPresent; } | ||
bool ImportProperties::isFlashpointPresent() const { return mFlashpointPresent; } | ||
|
||
QBindable<bool> ImportProperties::bindableIsFlashpointValid() { return &mFlashpointValid; } | ||
bool ImportProperties::isFlashpointValid() const { return mFlashpointValid; } | ||
|
||
QBindable<bool> ImportProperties::bindableIsFlashpointTargetSeries() { return &mFlashpointTargetSeries; } | ||
bool ImportProperties::isFlashpointTargetSeries() const { return mFlashpointTargetSeries; } | ||
|
||
QBindable<QList<Fe::ImageMode>> ImportProperties::bindableImageModeOrder() { return &mImageModeOrder; } | ||
const QBindable<bool> ImportProperties::bindableIsImageModeOrder() const { return &mImageModeOrder; } | ||
QList<Fe::ImageMode> ImportProperties::imageModeOrder() const { return mImageModeOrder; } | ||
|
||
QBindable<bool> ImportProperties::bindableIsImageDownloadable() { return &mImageDownloadable; } | ||
bool ImportProperties::isImageDownloadable() const { return mImageDownloadable; } | ||
|
||
QBindable<QString> ImportProperties::bindableLauncherInfo() { return &mLauncherInfo; } | ||
QString ImportProperties::launcherInfo() const { return mLauncherInfo; } | ||
|
||
QBindable<QString> ImportProperties::bindableFlashpointInfo() { return &mFlashpointInfo; } | ||
QString ImportProperties::flashpointInfo() const { return mFlashpointInfo; } |
Oops, something went wrong.