diff options
-rw-r--r-- | cui/source/dialogs/about.cxx | 27 | ||||
-rw-r--r-- | cui/source/inc/about.hxx | 3 | ||||
-rw-r--r-- | cui/uiconfig/ui/aboutdialog.ui | 16 |
3 files changed, 45 insertions, 1 deletions
diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx index ec5d6b98930b..e96fb2a50ee1 100644 --- a/cui/source/dialogs/about.cxx +++ b/cui/source/dialogs/about.cxx @@ -37,6 +37,11 @@ #include <sfx2/app.hxx> //SfxApplication::loadBrandSvg #include <strings.hrc> +#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp> +#include <com/sun/star/datatransfer/clipboard/SystemClipboard.hpp> +#include <vcl/textview.hxx> +#include <tools/diagnose_ex.h> + #include <config_feature_opencl.h> #if HAVE_FEATURE_OPENCL #include <opencl/openclwrapper.hxx> @@ -52,6 +57,7 @@ AboutDialog::AboutDialog(weld::Window *pParent) m_pWebsiteButton(m_xBuilder->weld_link_button("btnWebsite")), m_pReleaseNotesButton(m_xBuilder->weld_link_button("btnReleaseNotes")), m_pCloseButton(m_xBuilder->weld_button("btnClose")), + m_pCopyButton(m_xBuilder->weld_button("btnCopyVersion")), m_pBrandImage(m_xBuilder->weld_image("imBrand")), m_pAboutImage(m_xBuilder->weld_image("imAbout")), m_pVersionLabel(m_xBuilder->weld_label("lbVersion")), @@ -101,6 +107,7 @@ AboutDialog::AboutDialog(weld::Window *pParent) m_pReleaseNotesButton->set_uri(sURL); //Handler + m_pCopyButton->connect_clicked(LINK(this, AboutDialog, HandleClick)); m_pCloseButton->grab_focus(); } @@ -241,4 +248,24 @@ OUString AboutDialog::GetCopyrightString() { return aCopyrightString; } +IMPL_LINK_NOARG(AboutDialog, HandleClick, weld::Button &, void) { + css::uno::Reference<css::datatransfer::clipboard::XClipboard> xClipboard = + css::datatransfer::clipboard::SystemClipboard::create( + comphelper::getProcessComponentContext()); + + if (xClipboard.is()) { + css::uno::Reference<css::datatransfer::XTransferable> xDataObj( + new TETextDataObject(m_pVersionLabel->get_label())); + try { + xClipboard->setContents(xDataObj, nullptr); + + css::uno::Reference<css::datatransfer::clipboard::XFlushableClipboard> + xFlushableClipboard(xClipboard, css::uno::UNO_QUERY); + if (xFlushableClipboard.is()) + xFlushableClipboard->flushClipboard(); + } catch (const css::uno::Exception &) { + TOOLS_WARN_EXCEPTION("cui.dialogs", "Caught exception trying to copy"); + } + } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/about.hxx b/cui/source/inc/about.hxx index ab03768a27df..bd90143a83e6 100644 --- a/cui/source/inc/about.hxx +++ b/cui/source/inc/about.hxx @@ -29,6 +29,7 @@ private: std::unique_ptr<weld::LinkButton> m_pWebsiteButton; std::unique_ptr<weld::LinkButton> m_pReleaseNotesButton; std::unique_ptr<weld::Button> m_pCloseButton; + std::unique_ptr<weld::Button> m_pCopyButton; std::unique_ptr<weld::Image> m_pBrandImage; std::unique_ptr<weld::Image> m_pAboutImage; @@ -41,6 +42,8 @@ private: static OUString GetLocaleString(); static bool IsStringValidGitHash(const OUString& hash); + DECL_LINK(HandleClick, weld::Button&, void); + public: AboutDialog(weld::Window* pParent); virtual ~AboutDialog() override; diff --git a/cui/uiconfig/ui/aboutdialog.ui b/cui/uiconfig/ui/aboutdialog.ui index e1a1c1a18b71..d61aea94cf88 100644 --- a/cui/uiconfig/ui/aboutdialog.ui +++ b/cui/uiconfig/ui/aboutdialog.ui @@ -25,6 +25,21 @@ <property name="hexpand">True</property> <property name="layout_style">end</property> <child> + <object class="GtkButton" id="btnCopyVersion"> + <property name="label" translatable="yes" context="aboutdialog|copy">Copy _Version Info</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + <property name="secondary">True</property> + </packing> + </child> + <child> <object class="GtkButton" id="btnClose"> <property name="label">gtk-close</property> <property name="visible">True</property> @@ -136,7 +151,6 @@ CPU threads Locale: Calc:</property> <property name="wrap">True</property> - <property name="selectable">True</property> <property name="max_width_chars">50</property> <property name="xalign">0</property> </object> |