Skip to content

TagSpaces is an offline, open source, document manager with tagging support

refactoring menu, adding global shortcur for saving files

uggrockdf753af8be71
diff --git a/data/electron/electron.api.js b/data/electron/electron.api.js
index 66a2ce818..163224a16 100644
--- a/data/electron/electron.api.js
+++ b/data/electron/electron.api.js
@@ -80,50 +80,22 @@ define(function(require, exports, module) {
{
label: $.i18n.t("ns.common:createFile"),
accelerator: '',
- click: function() {
- if (!TSCORE.currentPath) {
- TSCORE.showAlertDialog("ns.common:alertOpenLocatioFirst");
- } else {
- TSCORE.UI.createTXTFile();
- }
- }
+ click: TSCORE.UI.createTXTFile
},
{
label: $.i18n.t("ns.common:createMarkdown"),
accelerator: '',
- click: function() {
- if (!TSCORE.currentPath) {
- TSCORE.showAlertDialog("ns.common:alertOpenLocatioFirst");
- } else {
- TSCORE.UI.createMDFile();
- }
- }
+ click: TSCORE.UI.createMDFile
},
{
label: $.i18n.t("ns.common:createRichTextFile"),
accelerator: '',
- click: function() {
- if (!TSCORE.currentPath) {
- TSCORE.showAlertDialog("ns.common:alertOpenLocatioFirst");
- } else {
- TSCORE.UI.createHTMLFile();
- }
- }
+ click: TSCORE.UI.createHTMLFile
},
{
label: $.i18n.t("ns.common:createAudioFile"),
accelerator: '',
- click: function() {
- if (!TSCORE.currentPath) {
- TSCORE.showAlertDialog("ns.common:alertOpenLocatioFirst");
- } else {
- if (TSCORE.PRO) {
- TSCORE.UI.showAudioRecordingDialog();
- } else {
- TSCORE.showAlertDialog("You need the PRO version in order to use this functionality.");
- }
- }
- }
+ click: TSCORE.UI.showAudioRecordingDialog
},
{
type: 'separator'
@@ -142,6 +114,18 @@ define(function(require, exports, module) {
{
type: 'separator'
},
+ {
+ label: $.i18n.t("ns.common:saveFile"),
+ accelerator: 'CmdOrCtrl+S',
+ click: function() {
+ if (TSCORE.FileOpener.isFileEdited) {
+ TSCORE.FileOpener.saveFile();
+ }
+ }
+ },
+ {
+ type: 'separator'
+ },
{
label: $.i18n.t("ns.common:exitApp"),
accelerator: '',
@@ -149,10 +133,8 @@ define(function(require, exports, module) {
if (!TSCORE.currentPath) {
TSCORE.showAlertDialog("Not open current directory !");
} else {
- //TSCORE.Config.Settings.firstRun = true;
TSCORE.Config.saveSettings();
ipcRenderer.send('quit-application', 'Bye, bye...');
- //window.close();
}
}
}
@@ -388,10 +370,14 @@ define(function(require, exports, module) {
Menu.setApplicationMenu(menu);
ipcRenderer.on("new-file", function(event, arg) {
- if (!TSCORE.currentPath) {
- TSCORE.showAlertDialog($.i18n.t("ns.common:alertOpenLocatioFirst"));
- } else {
+ if (arg === "text") {
TSCORE.UI.createTXTFile();
+ } else if (arg === "html") {
+ TSCORE.UI.createHTMLFile();
+ } else if (arg === "markdown") {
+ TSCORE.UI.createMDFile();
+ } else if (arg === "audio") {
+ TSCORE.UI.showAudioRecordingDialog();
}
});
@@ -411,17 +397,9 @@ define(function(require, exports, module) {
}
});
- ipcRenderer.on("play", function(event, arg) {
- console.debug(arg);
- });
-
ipcRenderer.on("play-pause", function(event, arg) {
console.debug(arg);
});
-
- ipcRenderer.on("showing-tagspaces", function(event, arg) {
- TSCORE.UI.openNewInstance();
- });
}
// Brings the TagSpaces window on top of the windows
diff --git a/data/js/core.ui.js b/data/js/core.ui.js
index 7902795b5..f0f36c9b4 100644
--- a/data/js/core.ui.js
+++ b/data/js/core.ui.js
@@ -906,14 +906,21 @@ define(function(require, exports) {
}
function showAudioRecordingDialog() {
- //require("webaudiorecording");
- $('#audioRecordingDialog').modal({
- backdrop: 'static',
- show: true
- });
- $('#audioRecordingDialog').draggable({
- handle: ".modal-header"
- });
+ if (!TSCORE.currentPath) {
+ TSCORE.showAlertDialog($.i18n.t("ns.common:alertOpenLocatioFirst"));
+ return;
+ }
+ if (TSCORE.PRO) {
+ $('#audioRecordingDialog').modal({
+ backdrop: 'static',
+ show: true
+ });
+ $('#audioRecordingDialog').draggable({
+ handle: ".modal-header"
+ });
+ } else {
+ TSCORE.showAlertDialog("You need the PRO version in order to use this functionality.");
+ }
}
function showLicenseDialog() {
@@ -1096,16 +1103,28 @@ define(function(require, exports) {
}
function createHTMLFile() {
+ if (!TSCORE.currentPath) {
+ TSCORE.showAlertDialog($.i18n.t("ns.common:alertOpenLocatioFirst"));
+ return;
+ }
var filePath = TSCORE.currentPath + TSCORE.dirSeparator + TSCORE.TagUtils.beginTagContainer + TSCORE.TagUtils.formatDateTime4Tag(new Date(), true) + TSCORE.TagUtils.endTagContainer + '.html';
createNewTextFile(filePath, TSCORE.Config.getNewHTMLFileContent());
}
function createMDFile() {
+ if (!TSCORE.currentPath) {
+ TSCORE.showAlertDialog($.i18n.t("ns.common:alertOpenLocatioFirst"));
+ return;
+ }
var filePath = TSCORE.currentPath + TSCORE.dirSeparator + TSCORE.TagUtils.beginTagContainer + TSCORE.TagUtils.formatDateTime4Tag(new Date(), true) + TSCORE.TagUtils.endTagContainer + '.md';
createNewTextFile(filePath, TSCORE.Config.getNewMDFileContent());
}
function createTXTFile() {
+ if (!TSCORE.currentPath) {
+ TSCORE.showAlertDialog($.i18n.t("ns.common:alertOpenLocatioFirst"));
+ return;
+ }
var filePath = TSCORE.currentPath + TSCORE.dirSeparator + TSCORE.TagUtils.beginTagContainer + TSCORE.TagUtils.formatDateTime4Tag(new Date(), true) + TSCORE.TagUtils.endTagContainer + '.txt';
createNewTextFile(filePath, TSCORE.Config.getNewTextFileContent());
}