Skip to content

Commit

Permalink
Merge pull request #12 from bob-ross27/feature/v0.2.2
Browse files Browse the repository at this point in the history
v0.2.2
  • Loading branch information
mchaptel authored May 18, 2021
2 parents 4fb8497 + 63e033c commit aee1c67
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 37 deletions.
52 changes: 38 additions & 14 deletions packages/ExtensionStore/github_scrubber.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,26 +934,30 @@ LocalExtensionList.prototype.install = function (extension) {

/**
* Remove the installation from the hard drive
* @param {Extension} extension - The extension to be removed locally.
* @returns {boolean} the success of the uninstallation.
*/
LocalExtensionList.prototype.uninstall = function (extension) {
if (!this.isInstalled(extension)) return true // extension isn't installed
var localExtension = this.extensions[extension.id];

var files = localExtension.package.localFiles;
for (var i in files) {
this.log.debug("removing file " + files[i])
var file = new File(files[i])
if (file.exists) file.remove();

// remove containing folder if all files were removed
var folder = files[i].slice(0, files[i].lastIndexOf("/") + 1);
if (listFiles(folder).length == 0) (new Dir(folder)).rmdirs();
}
// Remove packages recursively as they have a parent directory.
if (extension.package.isPackage) {
var folder = new Dir(this.installFolder + "packages/" + extension.name.replace(" ", ""));
this.log.debug("removing folder " + folder.path)
this.log.debug("removing folder " + folder.path);
if (folder.exists) folder.rmdirs();
}
// Otherwise remove all script files (.js, .ui, .png etc.)
else {
var files = localExtension.package.localFiles;
for (var i in files) {
this.log.debug("removing file " + files[i]);
var file = new File(files[i]);
if (file.exists) file.remove();
}
}

// Update the extension list accordingly.
this.removeFromList(extension);

return true;
Expand Down Expand Up @@ -1140,6 +1144,7 @@ ExtensionDownloader.prototype.downloadFiles = function () {
progress.title = "Installing extension "+this.extension.name;
progress.setLabelText( "Downloading files..." );
progress.setRange( 0, files.length );
progress.modal = true;

progress.show();

Expand Down Expand Up @@ -1289,15 +1294,33 @@ CURL.prototype.get = function (command, wait) {
CURL.prototype.runCommand = function (bin, command, wait, test){
if (typeof test === 'undefined') var test = false; // test will not print the output, just the errors

var loop = new QEventLoop();

var p = new QProcess();
p["finished(int,QProcess::ExitStatus)"].connect(this, function () {
loop.exit();
});

// Use a timer to kill the QProcess after the wait period.
var timer = new QTimer();
timer.singleShot = true;
timer["timeout"].connect(this, function() {
if (loop.isRunning()) {
p.kill();
loop.exit();
throw new Error("Timeout updating extension.");
}
});

// The toonboom bundled curl doesn't seem to be equiped for ssh so we have to use unsafe mode
if (bin.indexOf("bin_3rdParty") != -1) command = ["-k"].concat(command);
command = ["-s", "-S"].concat(command);

// Start the process and enter an event loop until the QProcessx exits.
this.log.debug("starting process :" + bin + " " + command.join(" "));
p.start(bin, command);

p.waitForFinished(wait);
timer.start(wait);
loop.exec();

var readOut = p.readAllStandardOutput();
var output = new QTextStream(readOut).readAll();
Expand Down Expand Up @@ -1374,6 +1397,7 @@ function Logger(name) {
// by default will only output errors and log
this.LEVEL = { "ERROR": 0, "LOG": 1, "DEBUG": 2 };
if (typeof Logger.level === 'undefined') Logger.level = this.LEVEL.LOG;
if (MessageLog.isDebug()) Logger.level = this.LEVEL.DEBUG;
}


Expand Down Expand Up @@ -1503,7 +1527,7 @@ function recursiveFileCopy(folder, destination) {
var command = ["/E", "/TEE", "/MOV", folder, destination];
} else {
var bin = "cp";
var command = ["-Rv", folder + "/*", destination];
var command = ["-Rv", folder + "/.", destination];
}

log.debug("starting process :"+bin+" "+command);
Expand Down
57 changes: 42 additions & 15 deletions packages/ExtensionStore/store.ui
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@
<x>0</x>
<y>0</y>
<width>513</width>
<height>303</height>
<height>266</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
Expand Down Expand Up @@ -769,23 +769,50 @@
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QPushButton" name="loadStoreButton">
<property name="minimumSize">
<size>
<width>80</width>
<height>30</height>
</size>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="loadStoreButton">
<property name="minimumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Load Store</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="updateLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Please Wait - Updating Extension List...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="text">
<string>Load Store</string>
<property name="margin">
<number>5</number>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="updateProgress">
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
</widget>
</item>
Expand Down
36 changes: 30 additions & 6 deletions packages/ExtensionStore/storeui.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ function StoreUI(){
this.storeDescriptionPanel = this.storeFrame.storeSplitter.widget(1);
this.extensionsList = this.storeListPanel.extensionsList;

// disable store frame until store is loaded
// Hide the store and the loading UI elements.
this.storeFrame.hide();
this.setUpdateProgressUIState(false);

var logo = storelib.currentFolder+"/logo.png"
var logoPixmap = new QPixmap(logo);
Expand Down Expand Up @@ -94,13 +95,29 @@ StoreUI.prototype.show = function(){
this.ui.show()
}

/**
* Show widgets responsible for showing progress to the user when loading the
* store and retrieving extensions.
* @param {boolean} visible - Determine whether the progress state should be enabled or disabled.
*/
StoreUI.prototype.setUpdateProgressUIState = function(visible){
if (visible === true) {
this.aboutFrame.loadStoreButton.hide();
this.aboutFrame.updateLabel.show();
this.aboutFrame.updateProgress.show();
}
else{
this.aboutFrame.loadStoreButton.show();
this.aboutFrame.updateLabel.hide();
this.aboutFrame.updateProgress.hide();
}
}


/**
* Loads the store
*/
StoreUI.prototype.loadStore = function(){
this.storeFrame.show();
this.aboutFrame.hide();

// setup the store widget sizes
this.extensionsList.setColumnWidth(0, UiLoader.dpiScale(220));
Expand All @@ -118,9 +135,12 @@ StoreUI.prototype.loadStore = function(){
storeFrame.storeSplitter.setSizes([storeFrame.width / 2, storeFrame.width / 2]);
this.storeFrameState = storeFrame.storeSplitter.saveState();
storeFrame.storeSplitter.setSizes([storeFrame.storeSplitter.width, 0]);

// expensive loading operation, maybe we could show a progress bar here somehow
// (instead of doing it one line, do it seller by seller then extension by extension and update progress?)

// Show progress dialog to give user indication that the list of extensions is being
// updated.
this.setUpdateProgressUIState(true);

// Update list of available operations.
var extensions = this.store.extensions;

// saving the list of extensions so we can pinpoint the new ones at next startup and highlight them
Expand All @@ -137,6 +157,10 @@ StoreUI.prototype.loadStore = function(){
this.localList.saveData("newExtensions", newExtensions);

this.updateExtensionsList();

// Show the fully loaded store.
this.storeFrame.show();
this.aboutFrame.hide();
}


Expand Down
4 changes: 2 additions & 2 deletions packages/ExtensionStore/tbpackage.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ExtensionStore",
"version": "0.2.1",
"version": "0.2.2",
"compatibility": "Harmony Premium 16",
"description": "Changelog: fix bug when checking for updates during the first connexion.",
"description": "Changelog: Added loading UI. Enabled additional debug mode. Fixed file copy syntax on MacOS / Linux.",
"isPackage": "true",
"repository": "https://github.com/mchaptel/ExtensionStore/",
"files": [
Expand Down

0 comments on commit aee1c67

Please sign in to comment.