Skip to content

Commit c324468

Browse files
author
Rens
committed
add shortcuts for manual reload of devmodules , add safety copy to mac
1 parent 85789d7 commit c324468

File tree

9 files changed

+71
-7
lines changed

9 files changed

+71
-7
lines changed

Desktop/analysis/analyses.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,13 @@ void Analyses::rescanAnalysisEntriesOfDynamicModule(Modules::DynamicModule * mod
351351
removeAnalysisById(size_t(id));
352352
}
353353

354+
void Analyses::reloadQmlAnalysesDynamicModule(Modules::DynamicModule * module)
355+
{
356+
for(auto idAnalysis : _analysisMap)
357+
if(idAnalysis.second->dynamicModule() == module)
358+
idAnalysis.second->analysisQMLFileChanged();
359+
}
360+
354361
void Analyses::refreshAllAnalyses()
355362
{
356363
for(auto idAnalysis : _analysisMap)

Desktop/analysis/analyses.h

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public slots:
124124
void refreshAnalysesOfDynamicModule(Modules::DynamicModule * module);
125125
void replaceAnalysesOfDynamicModule(Modules::DynamicModule * oldModule, Modules::DynamicModule * newModule);
126126
void rescanAnalysisEntriesOfDynamicModule(Modules::DynamicModule * module);
127+
void reloadQmlAnalysesDynamicModule(Modules::DynamicModule * module);
127128
void setChangedAnalysisTitle();
128129
void analysisTitleChangedInResults(int id, QString title);
129130
void setCurrentFormPrevH(double currentFormPrevH);

Desktop/components/JASP/Widgets/MainWindow.qml

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ Window
109109
Shortcut { onActivated: mainWindow.undo(); sequences: ["Ctrl+Z", Qt.Key_Undo]; context: Qt.ApplicationShortcut; }
110110
Shortcut { onActivated: mainWindow.redo(); sequences: ["Ctrl+Shift+Z", "Ctrl-Y", Qt.Key_Redo]; context: Qt.ApplicationShortcut; }
111111

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

113117
RibbonBar
114118
{

Desktop/components/JASP/Widgets/ModulesMenu.qml

+18-1
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,28 @@ FocusScope
265265
anchors
266266
{
267267
left : parent.left
268-
right : minusButton.left
268+
right : refreshButton.left
269269
verticalCenter : parent.verticalCenter
270270
}
271271
}
272272

273+
274+
MenuButton
275+
{
276+
z: 1
277+
id: refreshButton
278+
visible: !isBundled && !isSpecial
279+
iconSource: jaspTheme.iconPath + "/redo.svg"
280+
width: visible ? height : 0
281+
onClicked: dynamicModules.refreshDeveloperModule();
282+
toolTip: qsTr("Refresh developer module ") + displayText
283+
anchors
284+
{
285+
right : minusButton.left
286+
verticalCenter : parent.verticalCenter
287+
}
288+
}
289+
273290
MenuButton
274291
{
275292
z: 1

Desktop/mainwindow.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ void MainWindow::makeConnections()
557557

558558
connect(_dynamicModules, &DynamicModules::dynamicModuleUnloadBegin, _analyses, &Analyses::removeAnalysesOfDynamicModule );
559559
connect(_dynamicModules, &DynamicModules::dynamicModuleChanged, _analyses, &Analyses::refreshAnalysesOfDynamicModule );
560+
connect(_dynamicModules, &DynamicModules::dynamicModuleQmlChanged, _analyses, &Analyses::reloadQmlAnalysesDynamicModule );
560561
connect(_dynamicModules, &DynamicModules::dynamicModuleReplaced, _analyses, &Analyses::replaceAnalysesOfDynamicModule, Qt::DirectConnection);
561562
connect(_dynamicModules, &DynamicModules::descriptionReloaded, _analyses, &Analyses::rescanAnalysisEntriesOfDynamicModule, Qt::QueuedConnection);
562563
connect(_dynamicModules, &DynamicModules::reloadHelpPage, _helpModel, &HelpModel::reloadPage );

Desktop/modules/dynamicmodule.cpp

+20-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
#ifdef __APPLE__
4242
#include "otoolstuff.h"
43+
#include <filesystem>
4344
#endif
4445

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

118120
_developmentModuleName = _name;
119121

120-
#ifdef __APPLE__
121-
_moduleLibraryFixer(libpath.toStdString(), true, true, true);
122-
#endif
123-
124122
loadDescriptionFromFolder(_modulePackage);
125123
setInstalled(true);
126124
}
@@ -942,5 +940,23 @@ stringset DynamicModule::requiredModules() const
942940
return out;
943941
}
944942

943+
QString DynamicModule::patchLibPathHelperFunc(QString libpath) {
944+
#ifdef __APPLE__
945+
//we copy everything because we need to patch and resign it all
946+
auto path = std::filesystem::temp_directory_path() / Settings::value(Settings::DIRECT_DEVMOD_NAME).toString().toStdString();
947+
std::filesystem::remove_all(path);
948+
std::filesystem::copy(libpath.toStdString(), path, std::filesystem::copy_options::recursive);
949+
_moduleLibraryFixer(path, true, true, true);
950+
return tq(path.generic_string());
951+
#else
952+
return libpath;
953+
#endif
954+
955+
}
956+
945957

946958
}
959+
960+
961+
962+

Desktop/modules/dynamicmodule.h

+2
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ public slots:
259259

260260
static std::string _developmentModuleName;
261261
static const std::string _moduleDirPostfix;
262+
263+
QString patchLibPathHelperFunc(QString libpath);
262264
};
263265

264266

Desktop/modules/dynamicmodules.cpp

+16-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "modules/upgrader/changeincompatible.h"
3737
#include "modules/description/description.h"
3838
#include "modules/description/entrybase.h"
39+
#include "engine/enginesync.h"
3940

4041
namespace Modules
4142
{
@@ -527,10 +528,23 @@ void DynamicModules::uninstallJASPDeveloperModule()
527528
uninstallModule(developmentModuleName());
528529
}
529530

531+
void DynamicModules::refreshDeveloperModule(bool R, bool Qml)
532+
{
533+
if(_modules.count(developmentModuleName())) {
534+
EngineSync::singleton()->killModuleEngine(_modules[developmentModuleName()]);
535+
if(R && Qml)
536+
installJASPDeveloperModule();
537+
else if(R)
538+
emit dynamicModuleChanged(_modules[developmentModuleName()]);
539+
else if(Qml)
540+
emit dynamicModuleQmlChanged(_modules[developmentModuleName()]);
541+
}
542+
}
543+
530544
void DynamicModules::installJASPDeveloperModule()
531545
{
532-
bool directLibpathEnabled = PreferencesModel::prefs()->directLibpathEnabled();
533-
QString modulePath = directLibpathEnabled ? PreferencesModel::prefs()->directLibpathFolder() : Settings::value(Settings::DEVELOPER_FOLDER).toString();
546+
bool directLibpathEnabled = Settings::value(Settings::DIRECT_LIBPATH_ENABLED).toBool();
547+
QString modulePath = directLibpathEnabled ? Settings::value(Settings::DIRECT_LIBPATH_FOLDER).toString() : Settings::value(Settings::DEVELOPER_FOLDER).toString();
534548
if(modulePath == "")
535549
{
536550
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."));

Desktop/modules/dynamicmodules.h

+2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public slots:
120120
void setDevelopersModuleInstallButtonEnabled(bool developersModuleInstallButtonEnabled);
121121
void setDataLoaded(bool dataLoaded);
122122
void uninstallJASPDeveloperModule();
123+
void refreshDeveloperModule(bool R = true, bool Qml = true);
123124

124125
QStringList requiredModulesLibPaths(QString moduleName);
125126

@@ -129,6 +130,7 @@ public slots:
129130
void dynamicModuleAdded( Modules::DynamicModule * dynamicModule);
130131
void dynamicModuleUnloadBegin( Modules::DynamicModule * dynamicModule);
131132
void dynamicModuleChanged( Modules::DynamicModule * dynamicModule);
133+
void dynamicModuleQmlChanged( Modules::DynamicModule * dynamicModule);
132134
void descriptionReloaded( Modules::DynamicModule * dynamicModule);
133135
void loadModuleTranslationFile( Modules::DynamicModule * dynamicModule);
134136
void dynamicModuleReplaced( Modules::DynamicModule * oldMod, Modules::DynamicModule * newMod);

0 commit comments

Comments
 (0)