diff options
author | Justin Luth <jluth@mail.com> | 2023-07-15 15:42:18 -0400 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-07-18 19:23:42 +0200 |
commit | 09d3e887b41a36bd0852ac004c6744f447361ac6 (patch) | |
tree | c5af4f93bf0152beef89a34d72a3b7f3cdac47c6 /cui | |
parent | 79113484cacb630f93f87c483b6c5d97c47b8728 (diff) |
tdf#68565 autosave: add option to store backup in document's folder
Creating a backup copy became the default in LO 7.6.
Allow the user to choose whether to store this previous version
of the file beside the original file (in the same folder).
The historical (and still the default) action
is to store it in a special backup folder instead.
The problem with the backup folder is that it overwrites files
that happen to have the same name (because the originals
reside in different directories), which is not uncommon.
Adding this option allows the user to overcome that limitation.
However, I do not want this new option to become the default,
because it effectively doubles the number of documents
stored in the document folder.
I think that is very messy, and previous versioning is best
left to dedicated backup tools - which would not appreciate
doubling the number of documents they preserve.
Plus I've worked with enough novice users to know that people are easily
confused when multiple documents have (essentially) the same name.
Change-Id: I503f656af91807019587e3d7b0d82b661f1eb437
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154489
Tested-by: Jenkins
Reviewed-by: Justin Luth <jluth@mail.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/options/optsave.cxx | 23 | ||||
-rw-r--r-- | cui/source/options/optsave.hxx | 2 | ||||
-rw-r--r-- | cui/uiconfig/ui/optsavepage.ui | 26 |
3 files changed, 48 insertions, 3 deletions
diff --git a/cui/source/options/optsave.cxx b/cui/source/options/optsave.cxx index 743c6015b1d5..b60fe8da2594 100644 --- a/cui/source/options/optsave.cxx +++ b/cui/source/options/optsave.cxx @@ -84,6 +84,7 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p , m_xLoadDocPrinterCB(m_xBuilder->weld_check_button("load_docprinter")) , m_xDocInfoCB(m_xBuilder->weld_check_button("docinfo")) , m_xBackupCB(m_xBuilder->weld_check_button("backup")) + , m_xBackupIntoDocumentFolderCB(m_xBuilder->weld_check_button("backupintodocumentfolder")) , m_xAutoSaveCB(m_xBuilder->weld_check_button("autosave")) , m_xAutoSaveEdit(m_xBuilder->weld_spin_button("autosave_spin")) , m_xMinuteFT(m_xBuilder->weld_label("autosave_mins")) @@ -123,6 +124,7 @@ SvxSaveTabPage::SvxSaveTabPage(weld::Container* pPage, weld::DialogController* p m_xDocTypeLB->append(OUString::number(APP_MATH), aFilterClassesNode.getNodeValue("com.sun.star.formula.FormulaProperties/DisplayName").get<OUString>()); m_xAutoSaveCB->connect_toggled( LINK( this, SvxSaveTabPage, AutoClickHdl_Impl ) ); + m_xBackupCB->connect_toggled(LINK(this, SvxSaveTabPage, BackupClickHdl_Impl)); SvtModuleOptions aModuleOpt; if ( !aModuleOpt.IsModuleInstalled( SvtModuleOptions::EModule::MATH ) ) @@ -215,6 +217,7 @@ void SvxSaveTabPage::DetectHiddenControls() { // hide controls of "Backup" m_xBackupCB->hide(); + m_xBackupIntoDocumentFolderCB->hide(); } if ( aOptionsDlgOpt.IsOptionHidden( u"AutoSave", CFG_PAGE_AND_GROUP ) ) @@ -266,6 +269,14 @@ bool SvxSaveTabPage::FillItemSet( SfxItemSet* rSet ) bModified = true; } + if (m_xBackupIntoDocumentFolderCB->get_sensitive() + && m_xBackupIntoDocumentFolderCB->get_state_changed_from_saved()) + { + rSet->Put( + SfxBoolItem(SID_ATTR_BACKUP_BESIDE_ORIGINAL, m_xBackupIntoDocumentFolderCB->get_active())); + bModified = true; + } + if ( m_xAutoSaveCB->get_state_changed_from_saved() ) { rSet->Put( SfxBoolItem( SID_ATTR_AUTOSAVE, @@ -475,6 +486,12 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) m_xBackupCB->set_active(officecfg::Office::Common::Save::Document::CreateBackup::get()); m_xBackupCB->set_sensitive(!officecfg::Office::Common::Save::Document::CreateBackup::isReadOnly()); + m_xBackupIntoDocumentFolderCB->set_active( + officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::get()); + m_xBackupIntoDocumentFolderCB->set_sensitive( + !officecfg::Office::Common::Save::Document::BackupIntoDocumentFolder::isReadOnly() + && m_xBackupCB->get_active()); + m_xAutoSaveCB->set_active(officecfg::Office::Recovery::AutoSave::Enabled::get()); m_xAutoSaveCB->set_sensitive(!officecfg::Office::Recovery::AutoSave::Enabled::isReadOnly()); @@ -503,6 +520,7 @@ void SvxSaveTabPage::Reset( const SfxItemSet* ) m_xDocInfoCB->save_state(); m_xBackupCB->save_state(); + m_xBackupIntoDocumentFolderCB->save_state(); m_xWarnAlienFormatCB->save_state(); m_xAutoSaveCB->save_state(); m_xAutoSaveEdit->save_value(); @@ -533,6 +551,11 @@ IMPL_LINK(SvxSaveTabPage, AutoClickHdl_Impl, weld::Toggleable&, rBox, void) } } +IMPL_LINK_NOARG(SvxSaveTabPage, BackupClickHdl_Impl, weld::Toggleable&, void) +{ + m_xBackupIntoDocumentFolderCB->set_sensitive(m_xBackupCB->get_active()); +} + static OUString lcl_ExtracUIName(const Sequence<PropertyValue> &rProperties, std::u16string_view rExtension) { OUString sName; diff --git a/cui/source/options/optsave.hxx b/cui/source/options/optsave.hxx index 1bc047985330..a4cb7630892a 100644 --- a/cui/source/options/optsave.hxx +++ b/cui/source/options/optsave.hxx @@ -46,6 +46,7 @@ private: std::unique_ptr<weld::CheckButton> m_xLoadDocPrinterCB; std::unique_ptr<weld::CheckButton> m_xDocInfoCB; std::unique_ptr<weld::CheckButton> m_xBackupCB; + std::unique_ptr<weld::CheckButton> m_xBackupIntoDocumentFolderCB; std::unique_ptr<weld::CheckButton> m_xAutoSaveCB; std::unique_ptr<weld::SpinButton> m_xAutoSaveEdit; std::unique_ptr<weld::Label> m_xMinuteFT; @@ -61,6 +62,7 @@ private: std::unique_ptr<weld::Label> m_xODFWarningFT; DECL_LINK( AutoClickHdl_Impl, weld::Toggleable&, void ); + DECL_LINK(BackupClickHdl_Impl, weld::Toggleable&, void); DECL_LINK( FilterHdl_Impl, weld::ComboBox&, void ); DECL_LINK(ODFVersionHdl_Impl, weld::ComboBox&, void ); diff --git a/cui/uiconfig/ui/optsavepage.ui b/cui/uiconfig/ui/optsavepage.ui index 5e93c38a5856..8ccb0c2948a1 100644 --- a/cui/uiconfig/ui/optsavepage.ui +++ b/cui/uiconfig/ui/optsavepage.ui @@ -185,7 +185,7 @@ <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">False</property> - <property name="margin-start">12</property> + <property name="margin-start">18</property> <property name="use_underline">True</property> <property name="draw_indicator">True</property> <child internal-child="accessible"> @@ -215,7 +215,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">4</property> + <property name="top_attach">5</property> </packing> </child> <child> @@ -253,7 +253,7 @@ </object> <packing> <property name="left_attach">0</property> - <property name="top_attach">5</property> + <property name="top_attach">6</property> </packing> </child> <child> @@ -275,6 +275,26 @@ <property name="top_attach">3</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="backupintodocumentfolder"> + <property name="label" translatable="yes" context="optsavepage|backupintodocumentfolder">Place backup in same folder as document</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="margin-start">18</property> + <property name="use_underline">True</property> + <property name="draw_indicator">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="backupintodocumentfolder-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="optsavepage|backupintodocumentfolder">Specifies if the backup copy should be stored in the same folder as the original document. If not selected, the backup copy is stored in the folder specified in Tools - Options - %PRODUCTNAME - Paths - Backups.</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">4</property> + </packing> + </child> </object> </child> <child type="label"> |