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