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

weld InputDialog

Change-Id: I821dcea904cad7cc6f9394bccf6560624d23729b
Reviewed-on: https://gerrit.libreoffice.org/50756Tested-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 d6f1c3de
......@@ -806,14 +806,14 @@ void SvxJavaParameterDlg::EditParameter()
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
{
ScopedVclPtrInstance< InputDialog > pParamEditDlg(CuiResId(RID_SVXSTR_JAVA_START_PARAM), this);
InputDialog aParamEditDlg(GetFrameWeld(), CuiResId(RID_SVXSTR_JAVA_START_PARAM));
OUString editableClassPath = m_pAssignedList->GetSelectedEntry();
pParamEditDlg->SetEntryText( editableClassPath );
pParamEditDlg->HideHelpBtn();
aParamEditDlg.SetEntryText(editableClassPath);
aParamEditDlg.HideHelpBtn();
if(!pParamEditDlg->Execute())
if (!aParamEditDlg.run())
return;
OUString editedClassPath = comphelper::string::strip( pParamEditDlg->GetEntryText(), ' ');
OUString editedClassPath = comphelper::string::strip(aParamEditDlg.GetEntryText(), ' ');
if ( !editedClassPath.isEmpty() && editableClassPath != editedClassPath )
{
......
......@@ -10,35 +10,24 @@
#ifndef INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX
#define INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX
#include <vcl/dialog.hxx>
#include <sfx2/dllapi.h>
#include <vcl/weld.hxx>
class Edit;
class FixedText;
class PushButton;
class Button;
class SFX2_DLLPUBLIC InputDialog : public ModalDialog
class SFX2_DLLPUBLIC InputDialog
{
public:
InputDialog (const OUString &labelText, vcl::Window *pParent);
OUString GetEntryText () const;
void SetEntryText( OUString const & sStr );
void HideHelpBtn();
virtual ~InputDialog() override;
virtual void dispose() override;
private:
std::unique_ptr<weld::Builder> m_xBuilder;
std::unique_ptr<weld::Dialog> m_xDialog;
std::unique_ptr<weld::Entry> m_xEntry;
std::unique_ptr<weld::Label> m_xLabel;
std::unique_ptr<weld::Button> m_xHelp;
DECL_LINK(ClickHdl, Button*, void);
private:
VclPtr<Edit> m_pEntry;
VclPtr<FixedText> m_pLabel;
VclPtr<PushButton> m_pOK;
VclPtr<PushButton> m_pCancel;
VclPtr<PushButton> m_pHelp;
public:
InputDialog(weld::Window* pParent, const OUString &rLabelText);
short run() { return m_xDialog->run(); }
OUString GetEntryText() const;
void SetEntryText(const OUString& rStr);
void HideHelpBtn();
};
#endif // INCLUDED_SFX2_SOURCE_INC_INPUTDLG_HXX
......
......@@ -286,6 +286,7 @@ public:
virtual OUString get_text() const = 0;
virtual void set_width_chars(int nChars) = 0;
virtual void select_region(int nStartPos, int nEndPos) = 0;
virtual void set_position(int nCursorPos) = 0;
void connect_changed(const Link<Entry&, void>& rLink) { m_aChangeHdl = rLink; }
......
......@@ -265,14 +265,14 @@ IMPL_LINK(TemplateLocalView, ContextMenuSelectHdl, Menu*, pMenu, bool)
break;
case MNI_RENAME:
{
ScopedVclPtrInstance< InputDialog > m_pTitleEditDlg( SfxResId(STR_RENAME_TEMPLATE), this);
InputDialog aTitleEditDlg(GetFrameWeld(), SfxResId(STR_RENAME_TEMPLATE));
OUString sOldTitle = maSelectedItem->getTitle();
m_pTitleEditDlg->SetEntryText( sOldTitle );
m_pTitleEditDlg->HideHelpBtn();
aTitleEditDlg.SetEntryText(sOldTitle);
aTitleEditDlg.HideHelpBtn();
if(!m_pTitleEditDlg->Execute())
if (!aTitleEditDlg.run())
break;
OUString sNewTitle = comphelper::string::strip( m_pTitleEditDlg->GetEntryText(), ' ');
OUString sNewTitle = comphelper::string::strip(aTitleEditDlg.GetEntryText(), ' ');
if ( !sNewTitle.isEmpty() && sNewTitle != sOldTitle )
{
......
......@@ -8,59 +8,33 @@
*/
#include <sfx2/inputdlg.hxx>
#include <sfx2/sfxresid.hxx>
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include <vcl/fixed.hxx>
InputDialog::InputDialog(const OUString &rLabelText, vcl::Window *pParent)
: ModalDialog(pParent, "InputDialog", "sfx/ui/inputdialog.ui")
{
get(m_pEntry, "entry");
get(m_pLabel, "label");
get(m_pOK, "ok");
get(m_pCancel, "cancel");
get(m_pHelp, "help");
m_pLabel->SetText(rLabelText);
m_pOK->SetClickHdl(LINK(this,InputDialog,ClickHdl));
m_pCancel->SetClickHdl(LINK(this,InputDialog,ClickHdl));
}
InputDialog::~InputDialog()
#include <vcl/svapp.hxx>
InputDialog::InputDialog(weld::Window* pParent, const OUString &rLabelText)
: m_xBuilder(Application::CreateBuilder(pParent, "sfx/ui/inputdialog.ui"))
, m_xDialog(m_xBuilder->weld_dialog("InputDialog"))
, m_xEntry(m_xBuilder->weld_entry("entry"))
, m_xLabel(m_xBuilder->weld_label("label"))
, m_xHelp(m_xBuilder->weld_button("help"))
{
disposeOnce();
}
void InputDialog::dispose()
{
m_pEntry.clear();
m_pLabel.clear();
m_pOK.clear();
m_pCancel.clear();
m_pHelp.clear();
ModalDialog::dispose();
m_xLabel->set_label(rLabelText);
}
void InputDialog::HideHelpBtn()
{
m_pHelp->Hide();
m_xHelp->hide();
}
OUString InputDialog::GetEntryText() const
{
return m_pEntry->GetText();
}
void InputDialog::SetEntryText( OUString const & sStr)
{
m_pEntry->SetText(sStr);
m_pEntry->SetCursorAtLast();
return m_xEntry->get_text();
}
IMPL_LINK(InputDialog,ClickHdl, Button*, pButton, void)
void InputDialog::SetEntryText(const OUString& rStr)
{
EndDialog(pButton == m_pOK ? RET_OK : RET_CANCEL);
m_xEntry->set_text(rStr);
m_xEntry->set_position(-1);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......
......@@ -1114,13 +1114,13 @@ void SfxTemplateManagerDlg::OnTemplateOpen ()
void SfxTemplateManagerDlg::OnCategoryNew()
{
ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW),this);
InputDialog dlg(GetFrameWeld(), SfxResId(STR_INPUT_NEW));
int ret = dlg->Execute();
int ret = dlg.run();
if (ret)
{
OUString aName = dlg->GetEntryText();
OUString aName = dlg.GetEntryText();
if(mpLocalView->createRegion(aName))
mpCBFolder->InsertEntry(aName);
......@@ -1137,14 +1137,14 @@ void SfxTemplateManagerDlg::OnCategoryNew()
void SfxTemplateManagerDlg::OnCategoryRename()
{
OUString sCategory = mpCBFolder->GetSelectedEntry();
ScopedVclPtrInstance< InputDialog > dlg(SfxResId(STR_INPUT_NEW),this);
InputDialog dlg(GetFrameWeld(), SfxResId(STR_INPUT_NEW));
dlg->SetEntryText(sCategory);
int ret = dlg->Execute();
dlg.SetEntryText(sCategory);
int ret = dlg.run();
if (ret)
{
OUString aName = dlg->GetEntryText();
OUString aName = dlg.GetEntryText();
if(mpLocalView->renameRegion(sCategory, aName))
{
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.19.0 -->
<!-- Generated with glade 3.20.2 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.0"/>
<requires lib="gtk+" version="3.20"/>
<object class="GtkDialog" id="InputDialog">
<property name="can_focus">False</property>
<property name="border_width">6</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">
......@@ -95,7 +98,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char"></property>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -112,8 +114,12 @@
</object>
</child>
<action-widgets>
<action-widget response="-11">help</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>
......@@ -782,6 +782,14 @@ public:
m_xEntry->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos));
}
virtual void set_position(int nCursorPos) override
{
if (nCursorPos < 0)
m_xEntry->SetCursorAtLast();
else
m_xEntry->SetSelection(Selection(nCursorPos, nCursorPos));
}
virtual ~SalInstanceEntry() override
{
m_xEntry->SetTextFilter(nullptr);
......
......@@ -1900,6 +1900,11 @@ public:
gtk_editable_select_region(GTK_EDITABLE(m_pEntry), nStartPos, nEndPos);
}
virtual void set_position(int nCursorPos) override
{
gtk_editable_set_position(GTK_EDITABLE(m_pEntry), nCursorPos);
}
virtual ~GtkInstanceEntry() override
{
g_signal_handler_disconnect(m_pEntry, m_nInsertTextSignalId);
......
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