summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/envelp/labfmt.cxx67
-rw-r--r--sw/source/ui/envelp/labfmt.hxx24
-rw-r--r--sw/uiconfig/swriter/ui/savelabeldialog.ui26
3 files changed, 58 insertions, 59 deletions
diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index 82a5b754f9c7..90672ac0fd10 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -574,10 +574,10 @@ IMPL_LINK_NOARG(SwLabFormatPage, SaveHdl, Button*, void)
aRec.m_nPWidth = static_cast< long >(GETFLDVAL(*m_pPWidthField ));
aRec.m_nPHeight = static_cast< long >(GETFLDVAL(*m_pPHeightField));
aRec.m_bCont = aItem.m_bCont;
- ScopedVclPtrInstance< SwSaveLabelDlg > pSaveDlg(this, aRec);
- pSaveDlg->SetLabel(aItem.m_aLstMake, aItem.m_aLstType);
- pSaveDlg->Execute();
- if(pSaveDlg->GetLabel(aItem))
+ SwSaveLabelDlg aSaveDlg(this, aRec);
+ aSaveDlg.SetLabel(aItem.m_aLstMake, aItem.m_aLstType);
+ aSaveDlg.run();
+ if (aSaveDlg.GetLabel(aItem))
{
bModified = false;
const std::vector<OUString>& rMan = GetParentSwLabDlg()->GetLabelsConfig().GetManufacturers();
@@ -592,60 +592,47 @@ IMPL_LINK_NOARG(SwLabFormatPage, SaveHdl, Button*, void)
}
SwSaveLabelDlg::SwSaveLabelDlg(SwLabFormatPage* pParent, SwLabRec& rRec)
- : ModalDialog(pParent, "SaveLabelDialog",
- "modules/swriter/ui/savelabeldialog.ui")
+ : GenericDialogController(pParent->GetFrameWeld(), "modules/swriter/ui/savelabeldialog.ui", "SaveLabelDialog")
, bSuccess(false)
, pLabPage(pParent)
, rLabRec(rRec)
+ , m_xMakeCB(m_xBuilder->weld_combo_box_text("brand"))
+ , m_xTypeED(m_xBuilder->weld_entry("type"))
+ , m_xOKPB(m_xBuilder->weld_button("ok"))
{
- get(m_pMakeCB, "brand");
- get(m_pTypeED, "type");
- get(m_pOKPB, "ok");
-
- m_pOKPB->SetClickHdl(LINK(this, SwSaveLabelDlg, OkHdl));
- Link<Edit&,void> aLk(LINK(this, SwSaveLabelDlg, ModifyHdl));
- m_pMakeCB->SetModifyHdl(aLk);
- m_pTypeED->SetModifyHdl(aLk);
+ m_xOKPB->connect_clicked(LINK(this, SwSaveLabelDlg, OkHdl));
+ m_xMakeCB->connect_changed(LINK(this, SwSaveLabelDlg, ModifyComboHdl));
+ m_xTypeED->connect_changed(LINK(this, SwSaveLabelDlg, ModifyEntryHdl));
SwLabelConfig& rCfg = pLabPage->GetParentSwLabDlg()->GetLabelsConfig();
const std::vector<OUString>& rMan = rCfg.GetManufacturers();
for (const auto & i : rMan)
{
- m_pMakeCB->InsertEntry(i);
+ m_xMakeCB->append_text(i);
}
}
SwSaveLabelDlg::~SwSaveLabelDlg()
{
- disposeOnce();
-}
-
-void SwSaveLabelDlg::dispose()
-{
- m_pMakeCB.clear();
- m_pTypeED.clear();
- m_pOKPB.clear();
- pLabPage.clear();
- ModalDialog::dispose();
}
-IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl, Button*, void)
+IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl, weld::Button&, void)
{
SwLabelConfig& rCfg = pLabPage->GetParentSwLabDlg()->GetLabelsConfig();
- OUString sMake(m_pMakeCB->GetText());
- OUString sType(m_pTypeED->GetText());
+ OUString sMake(m_xMakeCB->get_active_text());
+ OUString sType(m_xTypeED->get_text());
if(rCfg.HasLabel(sMake, sType))
{
if ( rCfg.IsPredefinedLabel(sMake, sType) )
{
SAL_WARN( "sw.envelp", "label is predefined and cannot be overwritten" );
- std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/cannotsavelabeldialog.ui"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "modules/swriter/ui/cannotsavelabeldialog.ui"));
std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("CannotSaveLabelDialog"));
xBox->run();
return;
}
- std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/swriter/ui/querysavelabeldialog.ui"));
+ std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "modules/swriter/ui/querysavelabeldialog.ui"));
std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("QuerySaveLabelDialog"));
xQuery->set_primary_text(xQuery->get_primary_text().
replaceAll("%1", sMake).replaceAll("%2", sType));
@@ -658,20 +645,30 @@ IMPL_LINK_NOARG(SwSaveLabelDlg, OkHdl, Button*, void)
rLabRec.m_aType = sType;
rCfg.SaveLabel(sMake, sType, rLabRec);
bSuccess = true;
- EndDialog(RET_OK);
+ m_xDialog->response(RET_OK);
+}
+
+void SwSaveLabelDlg::Modify()
+{
+ m_xOKPB->set_sensitive(!m_xMakeCB->get_active_text().isEmpty() && !m_xTypeED->get_text().isEmpty());
+}
+
+IMPL_LINK_NOARG(SwSaveLabelDlg, ModifyComboHdl, weld::ComboBoxText&, void)
+{
+ Modify();
}
-IMPL_LINK_NOARG(SwSaveLabelDlg, ModifyHdl, Edit&, void)
+IMPL_LINK_NOARG(SwSaveLabelDlg, ModifyEntryHdl, weld::Entry&, void)
{
- m_pOKPB->Enable(!m_pMakeCB->GetText().isEmpty() && !m_pTypeED->GetText().isEmpty());
+ Modify();
}
bool SwSaveLabelDlg::GetLabel(SwLabItem& rItem)
{
if(bSuccess)
{
- rItem.m_aMake = m_pMakeCB->GetText();
- rItem.m_aType = m_pTypeED->GetText();
+ rItem.m_aMake = m_xMakeCB->get_active_text();
+ rItem.m_aType = m_xTypeED->get_text();
rItem.m_lHDist = rLabRec.m_nHDist;
rItem.m_lVDist = rLabRec.m_nVDist;
rItem.m_lWidth = rLabRec.m_nWidth;
diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx
index 0aa1059e2b8a..08007cf05818 100644
--- a/sw/source/ui/envelp/labfmt.hxx
+++ b/sw/source/ui/envelp/labfmt.hxx
@@ -22,6 +22,8 @@
#include "swuilabimp.hxx"
#include <labimg.hxx>
#include <vcl/idle.hxx>
+#include <vcl/weld.hxx>
+
class SwLabFormatPage;
class SwLabPreview : public vcl::Window
@@ -108,28 +110,30 @@ public:
SwLabDlg* GetParentSwLabDlg() {return static_cast<SwLabDlg*>(GetParentDialog());}
};
-class SwSaveLabelDlg : public ModalDialog
+class SwSaveLabelDlg : public weld::GenericDialogController
{
- VclPtr<ComboBox> m_pMakeCB;
- VclPtr<Edit> m_pTypeED;
- VclPtr<OKButton> m_pOKPB;
-
bool bSuccess;
VclPtr<SwLabFormatPage> pLabPage;
SwLabRec& rLabRec;
- DECL_LINK(OkHdl, Button*, void);
- DECL_LINK(ModifyHdl, Edit&, void);
+ std::unique_ptr<weld::ComboBoxText> m_xMakeCB;
+ std::unique_ptr<weld::Entry> m_xTypeED;
+ std::unique_ptr<weld::Button> m_xOKPB;
+
+ DECL_LINK(OkHdl, weld::Button&, void);
+ DECL_LINK(ModifyEntryHdl, weld::Entry&, void);
+ DECL_LINK(ModifyComboHdl, weld::ComboBoxText&, void);
+
+ void Modify();
public:
SwSaveLabelDlg(SwLabFormatPage* pParent, SwLabRec& rRec);
virtual ~SwSaveLabelDlg() override;
- virtual void dispose() override;
void SetLabel(const OUString& rMake, const OUString& rType)
{
- m_pMakeCB->SetText(rMake);
- m_pTypeED->SetText(rType);
+ m_xMakeCB->set_entry_text(rMake);
+ m_xTypeED->set_text(rType);
}
bool GetLabel(SwLabItem& rItem);
};
diff --git a/sw/uiconfig/swriter/ui/savelabeldialog.ui b/sw/uiconfig/swriter/ui/savelabeldialog.ui
index 1a6201bff2a8..4e1406b09333 100644
--- a/sw/uiconfig/swriter/ui/savelabeldialog.ui
+++ b/sw/uiconfig/swriter/ui/savelabeldialog.ui
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.4 -->
<interface domain="sw">
- <!-- interface-requires gtk+ 3.0 -->
+ <requires lib="gtk+" version="3.0"/>
<object class="GtkDialog" id="SaveLabelDialog">
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="title" translatable="yes" context="savelabeldialog|SaveLabelDialog">Save Label Format</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">
@@ -57,6 +61,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
+ <property name="secondary">True</property>
</packing>
</child>
</object>
@@ -91,30 +96,26 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="savelabeldialog|label2">Brand</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes" context="savelabeldialog|label3">T_ype</property>
<property name="use_underline">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -126,8 +127,6 @@
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
<child>
@@ -136,19 +135,15 @@
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="has_entry">True</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
<child internal-child="entry">
<object class="GtkEntry" id="comboboxtext-entry">
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
</packing>
</child>
</object>
@@ -179,5 +174,8 @@
<action-widget response="-6">cancel</action-widget>
<action-widget response="-11">help</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>