summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-03-02 21:11:10 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-03-03 18:50:05 +0100
commit301514183d471cfeb085673eb4563f8c310162b7 (patch)
tree6a35a4334aad350d979991fb75cf91fee42bdc17 /sfx2
parent64d51760cc41bf033a6b69258f6f4a376878d17a (diff)
weld license dialog
Change-Id: Icfd921923cf6396db4cc5ecabd7b65d0b4c9aef7 Reviewed-on: https://gerrit.libreoffice.org/50648 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appserv.cxx101
-rw-r--r--sfx2/uiconfig/ui/licensedialog.ui16
2 files changed, 73 insertions, 44 deletions
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index dc89048452e8..4b5c0080dc28 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -271,26 +271,69 @@ static void showDocument( const char* pBaseName )
namespace
{
- class LicenseDialog : public ModalDialog
+ Reference<XFrame> GetRequestFrame(SfxRequest& rReq)
{
- private:
- DECL_LINK(ShowHdl, Button*, void);
- public:
- explicit LicenseDialog();
- };
+ const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
+ const SfxPoolItem* pItem = nullptr;
+ Reference <XFrame> xFrame;
+ if (pArgs && pArgs->GetItemState(SID_FILLFRAME, false, &pItem) == SfxItemState::SET)
+ {
+ OSL_ENSURE( dynamic_cast< const SfxUnoFrameItem *>( pItem ) != nullptr, "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
+ xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
+ }
+ return xFrame;
+ }
- LicenseDialog::LicenseDialog()
- : ModalDialog(nullptr, "LicenseDialog", "sfx/ui/licensedialog.ui")
+ weld::Window* getFrameWeld(const Reference<XFrame>& rFrame)
{
- get<PushButton>("show")->SetClickHdl(LINK(this, LicenseDialog, ShowHdl));
+ if (rFrame.is())
+ {
+ try
+ {
+ Reference< awt::XWindow > xContainerWindow(rFrame->getContainerWindow(), UNO_SET_THROW);
+ VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow(xContainerWindow);
+ if (pWindow)
+ return pWindow->GetFrameWeld();
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ SAL_WARN( "sfx.appl", "no parent for dialogs" );
+ return nullptr;
}
- IMPL_LINK_NOARG(LicenseDialog, ShowHdl, Button*, void)
+ weld::Window* GetRequestFrameWeld(SfxRequest& rReq)
{
- EndDialog(RET_OK);
- showDocument("LICENSE");
+ return getFrameWeld(GetRequestFrame(rReq));
}
+ class LicenseDialog
+ {
+ private:
+ std::unique_ptr<weld::Builder> m_xBuilder;
+ std::unique_ptr<weld::Dialog> m_xDialog;
+ std::unique_ptr<weld::Label> m_xLabel;
+ public:
+ LicenseDialog(weld::Window* pParent)
+ : m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/licensedialog.ui"))
+ , m_xDialog(m_xBuilder->weld_dialog("LicenseDialog"))
+ , m_xLabel(m_xBuilder->weld_label("label"))
+ {
+ m_xLabel->set_label(Translate::GetReadStringHook()(m_xLabel->get_label()));
+ }
+
+ short run()
+ {
+ short nRet = m_xDialog->run();
+ if (nRet == RET_OK)
+ showDocument("LICENSE");
+ return nRet;
+ }
+ };
+
class SafeModeQueryDialog : public ModalDialog
{
private:
@@ -412,12 +455,7 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
SID_CONFIG, pStringItem->GetValue() ) );
}
- Reference< XFrame > xFrame;
- const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- const SfxUnoFrameItem* pFrameItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pIntSet, SID_FILLFRAME, false);
- if ( pFrameItem )
- xFrame = pFrameItem->GetFrame();
-
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
ScopedVclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateCustomizeTabDialog(
&aSet, xFrame ));
@@ -524,8 +562,8 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
}
case SID_SHOW_LICENSE:
{
- ScopedVclPtrInstance< LicenseDialog > aDialog;
- aDialog->Execute();
+ LicenseDialog aDialog(GetRequestFrameWeld(rReq));
+ aDialog.run();
break;
}
@@ -1307,14 +1345,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
const SfxStringItem* pURLItem = rReq.GetArg<SfxStringItem>(SID_OPTIONS_PAGEURL);
if ( pURLItem )
sPageURL = pURLItem->GetValue();
- const SfxItemSet* pArgs = rReq.GetInternalArgs_Impl();
- const SfxPoolItem* pItem = nullptr;
- Reference < XFrame > xFrame;
- if ( pArgs && pArgs->GetItemState( SID_FILLFRAME, false, &pItem ) == SfxItemState::SET )
- {
- OSL_ENSURE( dynamic_cast< const SfxUnoFrameItem *>( pItem ) != nullptr, "SfxApplication::OfaExec_Impl: XFrames are to be transported via SfxUnoFrameItem by now!" );
- xFrame = static_cast< const SfxUnoFrameItem*>( pItem )->GetFrame();
- }
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
if ( pFact )
{
@@ -1455,12 +1486,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
}
}
- Reference< XFrame > xFrame;
- const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- const SfxUnoFrameItem* pFrameItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pIntSet, SID_FILLFRAME, false);
- if (pFrameItem)
- xFrame = pFrameItem->GetFrame();
-
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
rReq.SetReturnValue(SfxStringItem(rReq.GetSlot(), ChooseMacro(xLimitToModel, xFrame, bChooseOnly)));
rReq.Done();
}
@@ -1487,12 +1513,7 @@ void SfxApplication::OfaExec_Impl( SfxRequest& rReq )
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
SAL_INFO("sfx.appl", "SfxApplication::OfaExec_Impl: case ScriptOrg");
- Reference< XFrame > xFrame;
- const SfxItemSet* pIntSet = rReq.GetInternalArgs_Impl();
- const SfxUnoFrameItem* pFrameItem = SfxItemSet::GetItem<SfxUnoFrameItem>(pIntSet, SID_FILLFRAME, false);
- if ( pFrameItem )
- xFrame = pFrameItem->GetFrame();
-
+ Reference <XFrame> xFrame(GetRequestFrame(rReq));
if ( !xFrame.is() )
{
const SfxViewFrame* pViewFrame = SfxViewFrame::Current();
diff --git a/sfx2/uiconfig/ui/licensedialog.ui b/sfx2/uiconfig/ui/licensedialog.ui
index 73ae86471ddc..7d34353c1008 100644
--- a/sfx2/uiconfig/ui/licensedialog.ui
+++ b/sfx2/uiconfig/ui/licensedialog.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.20.2 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.0"/>
<object class="GtkDialog" id="LicenseDialog">
@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="licensedialog|LicenseDialog">Licensing and Legal information</property>
<property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="default_width">0</property>
+ <property name="default_height">0</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
@@ -18,12 +21,11 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="show">
+ <object class="GtkButton" id="ok">
<property name="label" translatable="yes" context="licensedialog|show">_Show License</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
- <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
</object>
@@ -39,6 +41,9 @@
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
@@ -83,8 +88,11 @@ This product was created by %OOOVENDOR, based on OpenOffice.org, which is Copyri
</object>
</child>
<action-widgets>
- <action-widget response="0">show</action-widget>
+ <action-widget response="-5">ok</action-widget>
<action-widget response="-7">close</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>