From f8b6b713710def006eb022c71f304cb6bed73cc2 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Mar 2024 21:34:55 +0300 Subject: [PATCH] [PDF] Add settings for units --- apps/pdfeditor/main/app/controller/Main.js | 9 ++-- .../pdfeditor/main/app/view/FileMenuPanels.js | 41 +++++++++++++++++-- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/apps/pdfeditor/main/app/controller/Main.js b/apps/pdfeditor/main/app/controller/Main.js index 1ab60e57d8..c1a3f6ec32 100644 --- a/apps/pdfeditor/main/app/controller/Main.js +++ b/apps/pdfeditor/main/app/controller/Main.js @@ -1417,10 +1417,11 @@ define([ } callback && callback(); this.onPdfModeApply(); - this.getApplication().getController('Toolbar').applyMode(); - this.getApplication().getController('Viewport').applyEditorMode(); - this.getApplication().getController('DocumentHolder').applyEditorMode(); - + var app = this.getApplication(); + app.getController('Toolbar').applyMode(); + app.getController('Viewport').applyEditorMode(); + app.getController('DocumentHolder').applyEditorMode(); + app.getController('LeftMenu').leftMenu.getMenu('file').applyMode(); }, onPdfModeApply: function() { diff --git a/apps/pdfeditor/main/app/view/FileMenuPanels.js b/apps/pdfeditor/main/app/view/FileMenuPanels.js index bbb229c969..e4c12aa51b 100644 --- a/apps/pdfeditor/main/app/view/FileMenuPanels.js +++ b/apps/pdfeditor/main/app/view/FileMenuPanels.js @@ -361,6 +361,10 @@ define([ '
', '
', '', + '', + '', + '', + '', '', '', '
', @@ -569,6 +573,23 @@ define([ }); this.cmbFontRender.on('selected', _.bind(this.onFontRenderSelected, this)); + this.cmbUnit = new Common.UI.ComboBox({ + el : $markup.findById('#fms-cmb-unit'), + style : 'width: 160px;', + editable : false, + menuCls : 'menu-aligned', + menuStyle : 'min-width:100%;', + cls : 'input-group-nr', + data : [ + { value: Common.Utils.Metric.c_MetricUnits['cm'], displayValue: this.txtCm }, + { value: Common.Utils.Metric.c_MetricUnits['pt'], displayValue: this.txtPt }, + { value: Common.Utils.Metric.c_MetricUnits['inch'], displayValue: this.txtInch } + ], + dataHint: '2', + dataHintDirection: 'bottom', + dataHintOffset: 'big' + }); + this.cmbTheme = new Common.UI.ComboBox({ el : $markup.findById('#fms-cmb-theme'), style : 'width: 160px;', @@ -663,9 +684,9 @@ define([ this.mode = mode; var fast_coauth = Common.Utils.InternalSettings.get("pdfe-settings-coauthmode"), - canPDFSave = (mode.isPDFAnnotate || mode.isPDFEdit) && !mode.isOffline; + canPDFSave = (mode.isPDFAnnotate || mode.isPDFEdit) && mode.canSaveToFile && !mode.isOffline; - $('tr.edit', this.el)[mode.isEdit?'show':'hide'](); + $('tr.edit', this.el)[mode.isPDFEdit?'show':'hide'](); $('tr.autosave', this.el)[mode.isEdit && canPDFSave && (mode.canChangeCoAuthoring || !fast_coauth) ? 'show' : 'hide'](); $('tr.forcesave', this.el)[mode.canForcesave && canPDFSave ? 'show' : 'hide'](); $('tr.editsave',this.el)[(mode.isEdit || mode.canForcesave) && canPDFSave ? 'show' : 'hide'](); @@ -726,6 +747,11 @@ define([ item && value && item.set('checked', !!value); item && value && this.cmbFontRender.cmpEl.find('#' + item.get('id') + ' a').addClass('checked'); + value = Common.Utils.InternalSettings.get("pdfe-settings-unit"); + item = this.cmbUnit.store.findWhere({value: value}); + this.cmbUnit.setValue(item ? parseInt(item.get('value')) : Common.Utils.Metric.getDefaultMetric()); + this._oldUnits = this.cmbUnit.getValue(); + value = Common.Utils.InternalSettings.get("pdfe-settings-autosave"); this.chAutosave.setValue(value == 1); @@ -776,6 +802,8 @@ define([ if (this.mode.canForcesave) Common.localStorage.setItem("pdfe-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0); + Common.localStorage.setItem("pdfe-settings-unit", this.cmbUnit.getValue()); + var isRtlChanged = this.chRTL.$el.is(':visible') && Common.localStorage.getBool("ui-rtl", Common.Locale.isCurrentLanguageRtl()) !== this.chRTL.isChecked(); Common.localStorage.setBool("ui-rtl", this.chRTL.isChecked()); Common.localStorage.setBool("pdfe-settings-quick-print-button", this.chQuickPrint.isChecked()); @@ -784,6 +812,8 @@ define([ if (this.menu) { this.menu.fireEvent('settings:apply', [this.menu]); + if (this._oldUnits !== this.cmbUnit.getValue()) + Common.NotificationCenter.trigger('settings:unitschanged', this); } if (isRtlChanged) { @@ -859,7 +889,12 @@ define([ txtWorkspaceSettingChange: 'Workspace setting (RTL interface) change', txtRestartEditor: 'Please restart document editor so that your workspace settings can take effect', txtLastUsed: 'Last used', - txtScreenReader: 'Turn on screen reader support' + txtScreenReader: 'Turn on screen reader support', + strUnit: 'Unit of Measurement', + txtInch: 'Inch', + txtCm: 'Centimeter', + txtPt: 'Point' + }, PDFE.Views.FileMenuPanels.Settings || {})); PDFE.Views.FileMenuPanels.CreateNew = Common.UI.BaseView.extend(_.extend({