Kaydet (Commit) 40f1cfa6 authored tarafından Caolán McNamara's avatar Caolán McNamara

weld GotoLineDialog

Change-Id: Ibf040e9b48a5545550e1ee830852a75ca82262e7
Reviewed-on: https://gerrit.libreoffice.org/52695Tested-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 49eb02f0
......@@ -1010,13 +1010,15 @@ void ModulWindow::ExecuteCommand (SfxRequest& rReq)
break;
case SID_GOTOLINE:
{
ScopedVclPtrInstance< GotoLineDialog > aGotoDlg(this);
if (aGotoDlg->Execute())
if (sal_Int32 const nLine = aGotoDlg->GetLineNumber())
GotoLineDialog aGotoDlg(GetFrameWeld());
if (aGotoDlg.run() == RET_OK)
{
if (sal_Int32 const nLine = aGotoDlg.GetLineNumber())
{
TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0));
GetEditView()->SetSelection(aSel);
}
}
break;
}
}
......
......@@ -392,39 +392,30 @@ NewObjectDialog::NewObjectDialog(weld::Window * pParent, ObjectMode eMode, bool
}
// GotoLineDialog
GotoLineDialog::GotoLineDialog(vcl::Window * pParent )
: ModalDialog(pParent, "GotoLineDialog",
"modules/BasicIDE/ui/gotolinedialog.ui")
GotoLineDialog::GotoLineDialog(weld::Window* pParent )
: GenericDialogController(pParent, "modules/BasicIDE/ui/gotolinedialog.ui", "GotoLineDialog")
, m_xEdit(m_xBuilder->weld_entry("entry"))
, m_xOKButton(m_xBuilder->weld_button("ok"))
{
get(m_pEdit, "entry");
get(m_pOKButton, "ok");
m_pEdit->GrabFocus();
m_pOKButton->SetClickHdl(LINK(this, GotoLineDialog, OkButtonHandler));
m_xEdit->grab_focus();
m_xOKButton->connect_clicked(LINK(this, GotoLineDialog, OkButtonHandler));
}
GotoLineDialog::~GotoLineDialog()
{
disposeOnce();
}
void GotoLineDialog::dispose()
{
m_pEdit.clear();
m_pOKButton.clear();
ModalDialog::dispose();
}
sal_Int32 GotoLineDialog::GetLineNumber() const
{
return m_pEdit->GetText().toInt32();
return m_xEdit->get_text().toInt32();
}
IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, Button*, void)
IMPL_LINK_NOARG(GotoLineDialog, OkButtonHandler, weld::Button&, void)
{
if ( GetLineNumber() )
EndDialog(1);
if (GetLineNumber())
m_xDialog->response(RET_OK);
else
m_pEdit->SetText(m_pEdit->GetText(), Selection(0, m_pEdit->GetText().getLength()));
m_xEdit->select_region(0, -1);
}
// ExportDialog
......
......@@ -60,15 +60,14 @@ public:
}
};
class GotoLineDialog : public ModalDialog
class GotoLineDialog : public weld::GenericDialogController
{
VclPtr<Edit> m_pEdit;
VclPtr<OKButton> m_pOKButton;
DECL_LINK(OkButtonHandler, Button*, void);
std::unique_ptr<weld::Entry> m_xEdit;
std::unique_ptr<weld::Button> m_xOKButton;
DECL_LINK(OkButtonHandler, weld::Button&, void);
public:
explicit GotoLineDialog(vcl::Window * pParent);
explicit GotoLineDialog(weld::Window* pParent);
virtual ~GotoLineDialog() override;
virtual void dispose() override;
sal_Int32 GetLineNumber() const;
};
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.20.4 -->
<interface domain="basctl">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="GotoLineDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="gotolinedialog|GotoLineDialog">Go to Line</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">
......@@ -81,10 +84,10 @@
<object class="GtkLabel" id="area">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes" context="gotolinedialog|area">_Line number:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">entry</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -96,6 +99,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="activates_default">True</property>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -114,6 +118,10 @@
<action-widgets>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
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