Skip to content

Commit

Permalink
add shortcuts for manual reload of devmodules , add safety copy to mac
Browse files Browse the repository at this point in the history
  • Loading branch information
Rens committed Oct 15, 2024
1 parent 85789d7 commit c324468
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 7 deletions.
7 changes: 7 additions & 0 deletions Desktop/analysis/analyses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,13 @@ void Analyses::rescanAnalysisEntriesOfDynamicModule(Modules::DynamicModule * mod
removeAnalysisById(size_t(id));
}

void Analyses::reloadQmlAnalysesDynamicModule(Modules::DynamicModule * module)
{
for(auto idAnalysis : _analysisMap)
if(idAnalysis.second->dynamicModule() == module)
idAnalysis.second->analysisQMLFileChanged();
}

void Analyses::refreshAllAnalyses()
{
for(auto idAnalysis : _analysisMap)
Expand Down
1 change: 1 addition & 0 deletions Desktop/analysis/analyses.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public slots:
void refreshAnalysesOfDynamicModule(Modules::DynamicModule * module);
void replaceAnalysesOfDynamicModule(Modules::DynamicModule * oldModule, Modules::DynamicModule * newModule);
void rescanAnalysisEntriesOfDynamicModule(Modules::DynamicModule * module);
void reloadQmlAnalysesDynamicModule(Modules::DynamicModule * module);
void setChangedAnalysisTitle();
void analysisTitleChangedInResults(int id, QString title);
void setCurrentFormPrevH(double currentFormPrevH);
Expand Down
4 changes: 4 additions & 0 deletions Desktop/components/JASP/Widgets/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ Window
Shortcut { onActivated: mainWindow.undo(); sequences: ["Ctrl+Z", Qt.Key_Undo]; context: Qt.ApplicationShortcut; }
Shortcut { onActivated: mainWindow.redo(); sequences: ["Ctrl+Shift+Z", "Ctrl-Y", Qt.Key_Redo]; context: Qt.ApplicationShortcut; }

Shortcut { onActivated: { dynamicModules.refreshDeveloperModule(false, true);} sequences: ["Ctrl+Shift+U"]; context: Qt.ApplicationShortcut; }
Shortcut { onActivated: { dynamicModules.refreshDeveloperModule(true, false);} sequences: ["Ctrl+Shift+R"]; context: Qt.ApplicationShortcut; }
Shortcut { onActivated: { dynamicModules.refreshDeveloperModule(true, true);} sequences: ["Ctrl+Shift+D"]; context: Qt.ApplicationShortcut; }


RibbonBar
{
Expand Down
19 changes: 18 additions & 1 deletion Desktop/components/JASP/Widgets/ModulesMenu.qml
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,28 @@ FocusScope
anchors
{
left : parent.left
right : minusButton.left
right : refreshButton.left
verticalCenter : parent.verticalCenter
}
}


MenuButton
{
z: 1
id: refreshButton
visible: !isBundled && !isSpecial
iconSource: jaspTheme.iconPath + "/redo.svg"
width: visible ? height : 0
onClicked: dynamicModules.refreshDeveloperModule();
toolTip: qsTr("Refresh developer module ") + displayText
anchors
{
right : minusButton.left
verticalCenter : parent.verticalCenter
}
}

MenuButton
{
z: 1
Expand Down
1 change: 1 addition & 0 deletions Desktop/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ void MainWindow::makeConnections()

connect(_dynamicModules, &DynamicModules::dynamicModuleUnloadBegin, _analyses, &Analyses::removeAnalysesOfDynamicModule );
connect(_dynamicModules, &DynamicModules::dynamicModuleChanged, _analyses, &Analyses::refreshAnalysesOfDynamicModule );
connect(_dynamicModules, &DynamicModules::dynamicModuleQmlChanged, _analyses, &Analyses::reloadQmlAnalysesDynamicModule );
connect(_dynamicModules, &DynamicModules::dynamicModuleReplaced, _analyses, &Analyses::replaceAnalysesOfDynamicModule, Qt::DirectConnection);
connect(_dynamicModules, &DynamicModules::descriptionReloaded, _analyses, &Analyses::rescanAnalysisEntriesOfDynamicModule, Qt::QueuedConnection);
connect(_dynamicModules, &DynamicModules::reloadHelpPage, _helpModel, &HelpModel::reloadPage );
Expand Down
24 changes: 20 additions & 4 deletions Desktop/modules/dynamicmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#ifdef __APPLE__
#include "otoolstuff.h"
#include <filesystem>
#endif

namespace Modules
Expand Down Expand Up @@ -107,6 +108,7 @@ DynamicModule::DynamicModule(QObject * parent) : QObject(parent), _isDeveloperMo
///This constructor is meant specifically for the development module from a libpath *it*!
DynamicModule::DynamicModule(QObject * parent, QString libpath) : QObject(parent), _isDeveloperMod(true), _isLibpathDevMod(true)
{
libpath = patchLibPathHelperFunc(libpath);
_modulePackage = fq(libpath + "/" + Settings::value(Settings::DIRECT_DEVMOD_NAME).toString() + "/");
_moduleFolder = QFileInfo(libpath + "/");
_name = extractPackageNameFromFolder(_modulePackage);
Expand All @@ -117,10 +119,6 @@ DynamicModule::DynamicModule(QObject * parent, QString libpath) : QObject(parent

_developmentModuleName = _name;

#ifdef __APPLE__
_moduleLibraryFixer(libpath.toStdString(), true, true, true);
#endif

loadDescriptionFromFolder(_modulePackage);
setInstalled(true);
}
Expand Down Expand Up @@ -942,5 +940,23 @@ stringset DynamicModule::requiredModules() const
return out;
}

QString DynamicModule::patchLibPathHelperFunc(QString libpath) {
#ifdef __APPLE__
//we copy everything because we need to patch and resign it all
auto path = std::filesystem::temp_directory_path() / Settings::value(Settings::DIRECT_DEVMOD_NAME).toString().toStdString();
std::filesystem::remove_all(path);
std::filesystem::copy(libpath.toStdString(), path, std::filesystem::copy_options::recursive);
_moduleLibraryFixer(path, true, true, true);
return tq(path.generic_string());
#else
return libpath;
#endif

}


}




2 changes: 2 additions & 0 deletions Desktop/modules/dynamicmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ public slots:

static std::string _developmentModuleName;
static const std::string _moduleDirPostfix;

QString patchLibPathHelperFunc(QString libpath);
};


Expand Down
18 changes: 16 additions & 2 deletions Desktop/modules/dynamicmodules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "modules/upgrader/changeincompatible.h"
#include "modules/description/description.h"
#include "modules/description/entrybase.h"
#include "engine/enginesync.h"

namespace Modules
{
Expand Down Expand Up @@ -527,10 +528,23 @@ void DynamicModules::uninstallJASPDeveloperModule()
uninstallModule(developmentModuleName());
}

void DynamicModules::refreshDeveloperModule(bool R, bool Qml)
{
if(_modules.count(developmentModuleName())) {
EngineSync::singleton()->killModuleEngine(_modules[developmentModuleName()]);
if(R && Qml)
installJASPDeveloperModule();
else if(R)
emit dynamicModuleChanged(_modules[developmentModuleName()]);
else if(Qml)
emit dynamicModuleQmlChanged(_modules[developmentModuleName()]);
}
}

void DynamicModules::installJASPDeveloperModule()
{
bool directLibpathEnabled = PreferencesModel::prefs()->directLibpathEnabled();
QString modulePath = directLibpathEnabled ? PreferencesModel::prefs()->directLibpathFolder() : Settings::value(Settings::DEVELOPER_FOLDER).toString();
bool directLibpathEnabled = Settings::value(Settings::DIRECT_LIBPATH_ENABLED).toBool();
QString modulePath = directLibpathEnabled ? Settings::value(Settings::DIRECT_LIBPATH_FOLDER).toString() : Settings::value(Settings::DEVELOPER_FOLDER).toString();
if(modulePath == "")
{
MessageForwarder::showWarning(tr("Select a folder"), tr("To install a development module you need to select the folder you want to watch and load, you can do this under the filemenu, Preferences->Advanced."));
Expand Down
2 changes: 2 additions & 0 deletions Desktop/modules/dynamicmodules.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public slots:
void setDevelopersModuleInstallButtonEnabled(bool developersModuleInstallButtonEnabled);
void setDataLoaded(bool dataLoaded);
void uninstallJASPDeveloperModule();
void refreshDeveloperModule(bool R = true, bool Qml = true);

QStringList requiredModulesLibPaths(QString moduleName);

Expand All @@ -129,6 +130,7 @@ public slots:
void dynamicModuleAdded( Modules::DynamicModule * dynamicModule);
void dynamicModuleUnloadBegin( Modules::DynamicModule * dynamicModule);
void dynamicModuleChanged( Modules::DynamicModule * dynamicModule);
void dynamicModuleQmlChanged( Modules::DynamicModule * dynamicModule);
void descriptionReloaded( Modules::DynamicModule * dynamicModule);
void loadModuleTranslationFile( Modules::DynamicModule * dynamicModule);
void dynamicModuleReplaced( Modules::DynamicModule * oldMod, Modules::DynamicModule * newMod);
Expand Down

0 comments on commit c324468

Please sign in to comment.