summaryrefslogtreecommitdiff
path: root/cui/source/options/optgdlg.cxx
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2019-11-15 12:14:31 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2019-11-16 13:00:51 +0100
commitae71570ee7db0a4a9d237424ed2cc3204e86f136 (patch)
tree4adc7fc61b3d98fa873414f566a20d89cc99a301 /cui/source/options/optgdlg.cxx
parent03feda2465c7a18d6bac5781510ace2eabc40379 (diff)
tdf#44462: add a link to Windows Default apps settings applet
Add "Windows Default apps" button to Options->General to run system applet to control file associations, in accordance to recommendation from MS [1]. On Windows 10, though, the call to LaunchAdvancedAssociationUI would only bring a system-modal infobanner suggesting the user to go to Settings > Apps > Default apps, as documented at [2]. Since this is what MS considers the correct way to manage application associations, the infobanner should be enough. [1] https://docs.microsoft.com/en-us/windows/win32/shell/default-programs [2] https://docs.microsoft.com/en-us/windows/win32/api/shobjidl/nf-shobjidl-iapplicationassociationregistrationui-launchadvancedassociationui Change-Id: I79cccdd00afac998c028b8e151db66bbd75be985 Reviewed-on: https://gerrit.libreoffice.org/82777 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'cui/source/options/optgdlg.cxx')
-rw-r--r--cui/source/options/optgdlg.cxx39
1 files changed, 39 insertions, 0 deletions
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 3079b2c92c2c..597d75358d1c 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -81,6 +81,12 @@
#include <svtools/restartdialog.hxx>
#include <svtools/imgdef.hxx>
+#if defined(_WIN32)
+#include <o3tl/char16_t2wchar_t.hxx>
+#include <prewin.h>
+#include <shobjidl.h>
+#include <postwin.h>
+#endif
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::beans;
@@ -248,6 +254,10 @@ OfaMiscTabPage::OfaMiscTabPage(weld::Container* pPage, weld::DialogController* p
#else
, m_xQuickLaunchCB(m_xBuilder->weld_check_button("quicklaunch"))
#endif
+#if defined(_WIN32)
+ , m_xFileAssocFrame(m_xBuilder->weld_widget("fileassoc"))
+ , m_xFileAssocBtn(m_xBuilder->weld_button("assocfiles"))
+#endif
{
if (!lcl_HasSystemFilePicker())
m_xFileDlgFrame->hide();
@@ -273,6 +283,11 @@ OfaMiscTabPage::OfaMiscTabPage(weld::Container* pPage, weld::DialogController* p
m_xQuickStarterFrame->hide();
#endif
+#if defined(_WIN32)
+ m_xFileAssocFrame->show();
+ m_xFileAssocBtn->connect_clicked(LINK(this, OfaMiscTabPage, FileAssocClick));
+#endif
+
m_aStrDateInfo = m_xToYearFT->get_label();
m_xYearValueField->connect_value_changed( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
@@ -427,6 +442,30 @@ IMPL_LINK_NOARG( OfaMiscTabPage, TwoFigureHdl, weld::SpinButton&, void )
m_xToYearFT->set_label( aOutput );
}
+#if defined(_WIN32)
+IMPL_LINK_NOARG(OfaMiscTabPage, FileAssocClick, weld::Button&, void)
+{
+ const bool bUninit = SUCCEEDED(CoInitialize(nullptr));
+ IApplicationAssociationRegistrationUI* pIf = nullptr;
+ HRESULT res = CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI, 0,
+ CLSCTX_INPROC_SERVER, IID_IApplicationAssociationRegistrationUI,
+ reinterpret_cast<LPVOID*>(&pIf));
+
+ if (SUCCEEDED(res) && pIf)
+ {
+ // LaunchAdvancedAssociationUI only works for applications registered under
+ // Software\RegisteredApplications. See scp2/source/ooo/registryitem_ooo.scp
+ const OUString expanded = Translate::ExpandVariables("%PRODUCTNAME %PRODUCTVERSION");
+ // This will only show "To change your default apps, go to Settings > Apps > Default apps"
+ // on Win10; this is expected. At least this will self-document it to users.
+ pIf->LaunchAdvancedAssociationUI(o3tl::toW(expanded.getStr()));
+ pIf->Release();
+ }
+ if (bUninit)
+ CoUninitialize();
+}
+#endif
+
class CanvasSettings
{
public: