Kaydet (Commit) 4329d9d8 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld SfxViewVersionDialog_Impl

Change-Id: I5486df92b4e1d0ad5be18a35e72a7a6dbcc3b715
Reviewed-on: https://gerrit.libreoffice.org/52334Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 5672627a
......@@ -565,6 +565,7 @@ public:
virtual OUString get_text() const = 0;
virtual Selection get_selection() const = 0;
virtual void set_selection(const Selection&) = 0;
virtual void set_editable(bool bEditable) = 0;
};
class VCL_DLLPUBLIC Expander : virtual public Container
......
......@@ -391,8 +391,8 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
{
SfxVersionInfo aInfo;
aInfo.aAuthor = SvtUserOptions().GetFullName();
VclPtrInstance< SfxViewVersionDialog_Impl > pDlg(this, aInfo, true);
short nRet = pDlg->Execute();
SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), aInfo, true);
short nRet = aDlg.run();
if ( nRet == RET_OK )
{
SfxStringItem aComment( SID_DOCINFO_COMMENTS, aInfo.aComment );
......@@ -423,8 +423,8 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
else if (pButton == m_pViewButton && pEntry)
{
SfxVersionInfo* pInfo = static_cast<SfxVersionInfo*>(pEntry->GetUserData());
VclPtrInstance<SfxViewVersionDialog_Impl> pDlg(this, *pInfo, false);
pDlg->Execute();
SfxViewVersionDialog_Impl aDlg(GetFrameWeld(), *pInfo, false);
aDlg.run();
}
else if (pEntry && pButton == m_pCompareButton)
{
......@@ -451,65 +451,48 @@ IMPL_LINK( SfxVersionDialog, ButtonHdl_Impl, Button*, pButton, void )
}
}
SfxViewVersionDialog_Impl::SfxViewVersionDialog_Impl(vcl::Window *pParent, SfxVersionInfo& rInfo, bool bEdit)
: SfxModalDialog(pParent, "VersionCommentDialog", "sfx/ui/versioncommentdialog.ui")
SfxViewVersionDialog_Impl::SfxViewVersionDialog_Impl(weld::Window *pParent, SfxVersionInfo& rInfo, bool bEdit)
: GenericDialogController(pParent, "sfx/ui/versioncommentdialog.ui", "VersionCommentDialog")
, m_rInfo(rInfo)
, m_xDateTimeText(m_xBuilder->weld_label("timestamp"))
, m_xSavedByText(m_xBuilder->weld_label("author"))
, m_xEdit(m_xBuilder->weld_text_view("textview"))
, m_xOKButton(m_xBuilder->weld_button("ok"))
, m_xCancelButton(m_xBuilder->weld_button("cancel"))
, m_xCloseButton(m_xBuilder->weld_button("close"))
{
get(m_pDateTimeText, "timestamp");
get(m_pSavedByText, "author");
get(m_pEdit, "textview");
get(m_pOKButton, "ok");
get(m_pCancelButton, "cancel");
get(m_pCloseButton, "close");
OUString sAuthor = rInfo.aAuthor.isEmpty() ? SfxResId(STR_NO_NAME_SET) : rInfo.aAuthor;
const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
m_pDateTimeText->SetText(m_pDateTimeText->GetText() + formatTime(rInfo.aCreationDate, rLocaleWrapper));
m_pSavedByText->SetText(m_pSavedByText->GetText() + sAuthor);
m_pEdit->SetText(rInfo.aComment);
m_pEdit->set_height_request(7 * m_pEdit->GetTextHeight());
m_pEdit->set_width_request(40 * m_pEdit->approximate_char_width());
m_pOKButton->SetClickHdl(LINK(this, SfxViewVersionDialog_Impl, ButtonHdl));
m_xDateTimeText->set_label(m_xDateTimeText->get_label() + formatTime(rInfo.aCreationDate, rLocaleWrapper));
m_xSavedByText->set_label(m_xSavedByText->get_label() + sAuthor);
m_xEdit->set_text(rInfo.aComment);
m_xEdit->set_size_request(40 * m_xEdit->get_approximate_digit_width(),
7 * m_xEdit->get_text_height());
m_xOKButton->connect_clicked(LINK(this, SfxViewVersionDialog_Impl, ButtonHdl));
if (!bEdit)
{
m_pOKButton->Hide();
m_pCancelButton->Hide();
m_pEdit->SetReadOnly();
SetText(SfxResId(STR_VIEWVERSIONCOMMENT));
m_pCloseButton->GrabFocus();
m_xOKButton->hide();
m_xCancelButton->hide();
m_xEdit->set_editable(false);
m_xDialog->set_title(SfxResId(STR_VIEWVERSIONCOMMENT));
m_xCloseButton->grab_focus();
}
else
{
m_pDateTimeText->Hide();
m_pCloseButton->Hide();
m_pEdit->GrabFocus();
m_xDateTimeText->hide();
m_xCloseButton->hide();
m_xEdit->grab_focus();
}
}
SfxViewVersionDialog_Impl::~SfxViewVersionDialog_Impl()
{
disposeOnce();
}
void SfxViewVersionDialog_Impl::dispose()
{
m_pDateTimeText.clear();
m_pSavedByText.clear();
m_pEdit.clear();
m_pOKButton.clear();
m_pCancelButton.clear();
m_pCloseButton.clear();
SfxModalDialog::dispose();
}
IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, Button*, pButton, void)
IMPL_LINK(SfxViewVersionDialog_Impl, ButtonHdl, weld::Button&, rButton, void)
{
assert(pButton == m_pOKButton);
(void)pButton;
m_rInfo.aComment = m_pEdit->GetText();
EndDialog(RET_OK);
assert(&rButton == m_xOKButton.get());
(void)rButton;
m_rInfo.aComment = m_xEdit->get_text();
m_xDialog->response(RET_OK);
}
SfxCmisVersionsDialog::SfxCmisVersionsDialog ( SfxViewFrame* pVwFrame )
......
......@@ -26,6 +26,7 @@
#include <svtools/svtabbx.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
#include <vcl/weld.hxx>
class SfxViewFrame;
struct SfxVersionInfo;
......@@ -70,22 +71,22 @@ public:
bool IsSaveVersionOnClose() const { return m_bIsSaveVersionOnClose; }
};
class SfxViewVersionDialog_Impl : public SfxModalDialog
class SfxViewVersionDialog_Impl : public weld::GenericDialogController
{
VclPtr<FixedText> m_pDateTimeText;
VclPtr<FixedText> m_pSavedByText;
VclPtr<VclMultiLineEdit> m_pEdit;
VclPtr<OKButton> m_pOKButton;
VclPtr<CancelButton> m_pCancelButton;
VclPtr<CloseButton> m_pCloseButton;
private:
SfxVersionInfo& m_rInfo;
DECL_LINK(ButtonHdl, Button*, void);
std::unique_ptr<weld::Label> m_xDateTimeText;
std::unique_ptr<weld::Label> m_xSavedByText;
std::unique_ptr<weld::TextView> m_xEdit;
std::unique_ptr<weld::Button> m_xOKButton;
std::unique_ptr<weld::Button> m_xCancelButton;
std::unique_ptr<weld::Button> m_xCloseButton;
DECL_LINK(ButtonHdl, weld::Button&, void);
public:
SfxViewVersionDialog_Impl(vcl::Window *pParent, SfxVersionInfo& rInfo, bool bEdit);
virtual ~SfxViewVersionDialog_Impl() override;
virtual void dispose() override;
SfxViewVersionDialog_Impl(weld::Window *pParent, SfxVersionInfo& rInfo, bool bEdit);
};
class SfxCmisVersionsDialog : public SfxModalDialog
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="VersionCommentDialog">
......@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="versioncommentdialog|VersionCommentDialog">Insert Version Comment</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">
......@@ -97,8 +100,8 @@
<object class="GtkLabel" id="timestamp">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="versioncommentdialog|timestamp">Date and time: </property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -109,8 +112,8 @@
<object class="GtkLabel" id="author">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="versioncommentdialog|author">Saved by: </property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -153,5 +156,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
......@@ -1284,6 +1284,11 @@ public:
{
m_xTextView->SetSelection(rSelection);
}
virtual void set_editable(bool bEditable) override
{
m_xTextView->SetReadOnly(!bEditable);
}
};
class SalInstanceExpander : public SalInstanceContainer, public virtual weld::Expander
......
......@@ -3010,6 +3010,10 @@ public:
gtk_text_view_scroll_mark_onscreen(m_pTextView, mark);
}
virtual void set_editable(bool bEditable) override
{
gtk_text_view_set_editable(m_pTextView, bEditable);
}
};
static MouseEventModifiers ImplGetMouseButtonMode(sal_uInt16 nButton, sal_uInt16 nCode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment