diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-04 09:31:26 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-04 14:22:38 +0200 |
commit | d4e61b53fbdfa3b21f8cce981f6f98a6a1bf89b6 (patch) | |
tree | 5e234cd4ae0783ac57fdf95b53eb4af2235918fd /chart2 | |
parent | 54204d53eb4854715500edc064123e8d687381b2 (diff) |
weld SchTitleDlg
Change-Id: Ie4537b9b6d856178ae378473fda4a1b27a1ed0b5
Reviewed-on: https://gerrit.libreoffice.org/61356
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/dialogs/dlg_InsertTitle.cxx | 8 | ||||
-rw-r--r-- | chart2/source/controller/dialogs/res_Titles.cxx | 94 | ||||
-rw-r--r-- | chart2/source/controller/inc/dlg_InsertTitle.hxx | 8 | ||||
-rw-r--r-- | chart2/source/controller/inc/res_Titles.hxx | 32 | ||||
-rw-r--r-- | chart2/source/controller/main/ChartController_Insert.cxx | 6 | ||||
-rw-r--r-- | chart2/uiconfig/ui/inserttitledlg.ui | 29 |
6 files changed, 158 insertions, 19 deletions
diff --git a/chart2/source/controller/dialogs/dlg_InsertTitle.cxx b/chart2/source/controller/dialogs/dlg_InsertTitle.cxx index 149555cac30e..c0d44e5cba9f 100644 --- a/chart2/source/controller/dialogs/dlg_InsertTitle.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertTitle.cxx @@ -24,11 +24,11 @@ namespace chart { -SchTitleDlg::SchTitleDlg(vcl::Window* pWindow, const TitleDialogData& rInput ) - : ModalDialog(pWindow, "InsertTitleDialog", "modules/schart/ui/inserttitledlg.ui") - , m_xTitleResources(new TitleResources(*this, true)) +SchTitleDlg::SchTitleDlg(weld::Window* pWindow, const TitleDialogData& rInput) + : GenericDialogController(pWindow, "modules/schart/ui/inserttitledlg.ui", "InsertTitleDialog") + , m_xTitleResources(new SchTitleResources(*m_xBuilder, true)) { - SetText( ObjectNameProvider::getName(OBJECTTYPE_TITLE, true)); + m_xDialog->set_title(ObjectNameProvider::getName(OBJECTTYPE_TITLE, true)); m_xTitleResources->writeToResources( rInput ); } diff --git a/chart2/source/controller/dialogs/res_Titles.cxx b/chart2/source/controller/dialogs/res_Titles.cxx index 2ba28666fcbf..7feec41cc2d8 100644 --- a/chart2/source/controller/dialogs/res_Titles.cxx +++ b/chart2/source/controller/dialogs/res_Titles.cxx @@ -148,6 +148,100 @@ void TitleResources::readFromResources( TitleDialogData& rOutput ) rOutput.aTextList[6] = m_pEd_SecondaryYAxis->GetText(); } +SchTitleResources::SchTitleResources(weld::Builder& rBuilder, bool bShowSecondaryAxesTitle) + : m_xFT_Main(rBuilder.weld_label("labelMainTitle")) + , m_xFT_Sub(rBuilder.weld_label("labelSubTitle")) + , m_xEd_Main(rBuilder.weld_entry("maintitle")) + , m_xEd_Sub(rBuilder.weld_entry("subtitle")) + , m_xFT_XAxis(rBuilder.weld_label("labelPrimaryXaxis")) + , m_xFT_YAxis(rBuilder.weld_label("labelPrimaryYaxis")) + , m_xFT_ZAxis(rBuilder.weld_label("labelPrimaryZaxis")) + , m_xEd_XAxis(rBuilder.weld_entry("primaryXaxis")) + , m_xEd_YAxis(rBuilder.weld_entry("primaryYaxis")) + , m_xEd_ZAxis(rBuilder.weld_entry("primaryZaxis")) + , m_xFT_SecondaryXAxis(rBuilder.weld_label("labelSecondaryXAxis")) + , m_xFT_SecondaryYAxis(rBuilder.weld_label("labelSecondaryYAxis")) + , m_xEd_SecondaryXAxis(rBuilder.weld_entry("secondaryXaxis")) + , m_xEd_SecondaryYAxis(rBuilder.weld_entry("secondaryYaxis")) +{ + m_xFT_SecondaryXAxis->show(bShowSecondaryAxesTitle); + m_xFT_SecondaryYAxis->show(bShowSecondaryAxesTitle); + m_xEd_SecondaryXAxis->show(bShowSecondaryAxesTitle); + m_xEd_SecondaryYAxis->show(bShowSecondaryAxesTitle); +} + +SchTitleResources::~SchTitleResources() +{ +} + +bool SchTitleResources::IsModified() +{ + return m_xEd_Main->get_value_changed_from_saved() + || m_xEd_Sub->get_value_changed_from_saved() + || m_xEd_XAxis->get_value_changed_from_saved() + || m_xEd_YAxis->get_value_changed_from_saved() + || m_xEd_ZAxis->get_value_changed_from_saved() + || m_xEd_SecondaryXAxis->get_value_changed_from_saved() + || m_xEd_SecondaryYAxis->get_value_changed_from_saved(); +} + +void SchTitleResources::ClearModifyFlag() +{ + m_xEd_Main->save_value(); + m_xEd_Sub->save_value(); + m_xEd_XAxis->save_value(); + m_xEd_YAxis->save_value(); + m_xEd_ZAxis->save_value(); + m_xEd_SecondaryXAxis->save_value(); + m_xEd_SecondaryYAxis->save_value(); +} + +void SchTitleResources::writeToResources( const TitleDialogData& rInput ) +{ + m_xFT_Main->set_sensitive( rInput.aPossibilityList[0] ); + m_xFT_Sub->set_sensitive( rInput.aPossibilityList[1] ); + m_xFT_XAxis->set_sensitive( rInput.aPossibilityList[2] ); + m_xFT_YAxis->set_sensitive( rInput.aPossibilityList[3] ); + m_xFT_ZAxis->set_sensitive( rInput.aPossibilityList[4] ); + m_xFT_SecondaryXAxis->set_sensitive( rInput.aPossibilityList[5] ); + m_xFT_SecondaryYAxis->set_sensitive( rInput.aPossibilityList[6] ); + + m_xEd_Main->set_sensitive( rInput.aPossibilityList[0] ); + m_xEd_Sub->set_sensitive( rInput.aPossibilityList[1] ); + m_xEd_XAxis->set_sensitive( rInput.aPossibilityList[2] ); + m_xEd_YAxis->set_sensitive( rInput.aPossibilityList[3] ); + m_xEd_ZAxis->set_sensitive( rInput.aPossibilityList[4] ); + m_xEd_SecondaryXAxis->set_sensitive( rInput.aPossibilityList[5] ); + m_xEd_SecondaryYAxis->set_sensitive( rInput.aPossibilityList[6] ); + + m_xEd_Main->set_text(rInput.aTextList[0]); + m_xEd_Sub->set_text(rInput.aTextList[1]); + m_xEd_XAxis->set_text(rInput.aTextList[2]); + m_xEd_YAxis->set_text(rInput.aTextList[3]); + m_xEd_ZAxis->set_text(rInput.aTextList[4]); + m_xEd_SecondaryXAxis->set_text(rInput.aTextList[5]); + m_xEd_SecondaryYAxis->set_text(rInput.aTextList[6]); +} + +void SchTitleResources::readFromResources( TitleDialogData& rOutput ) +{ + rOutput.aExistenceList[0] = !m_xEd_Main->get_text().isEmpty(); + rOutput.aExistenceList[1] = !m_xEd_Sub->get_text().isEmpty(); + rOutput.aExistenceList[2] = !m_xEd_XAxis->get_text().isEmpty(); + rOutput.aExistenceList[3] = !m_xEd_YAxis->get_text().isEmpty(); + rOutput.aExistenceList[4] = !m_xEd_ZAxis->get_text().isEmpty(); + rOutput.aExistenceList[5] = !m_xEd_SecondaryXAxis->get_text().isEmpty(); + rOutput.aExistenceList[6] = !m_xEd_SecondaryYAxis->get_text().isEmpty(); + + rOutput.aTextList[0] = m_xEd_Main->get_text(); + rOutput.aTextList[1] = m_xEd_Sub->get_text(); + rOutput.aTextList[2] = m_xEd_XAxis->get_text(); + rOutput.aTextList[3] = m_xEd_YAxis->get_text(); + rOutput.aTextList[4] = m_xEd_ZAxis->get_text(); + rOutput.aTextList[5] = m_xEd_SecondaryXAxis->get_text(); + rOutput.aTextList[6] = m_xEd_SecondaryYAxis->get_text(); +} + } //namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/dlg_InsertTitle.hxx b/chart2/source/controller/inc/dlg_InsertTitle.hxx index d93c7b0381e5..f9786fec244f 100644 --- a/chart2/source/controller/inc/dlg_InsertTitle.hxx +++ b/chart2/source/controller/inc/dlg_InsertTitle.hxx @@ -20,18 +20,18 @@ #define INCLUDED_CHART2_SOURCE_CONTROLLER_INC_DLG_INSERTTITLE_HXX #include "res_Titles.hxx" -#include <vcl/dialog.hxx> +#include <vcl/weld.hxx> #include <memory> namespace chart { -class SchTitleDlg : public ModalDialog +class SchTitleDlg : public weld::GenericDialogController { private: - std::unique_ptr< TitleResources > m_xTitleResources; + std::unique_ptr<SchTitleResources> m_xTitleResources; public: - SchTitleDlg( vcl::Window* pParent, const TitleDialogData& rInput ); + SchTitleDlg(weld::Window* pParent, const TitleDialogData& rInput); void getResult( TitleDialogData& rOutput ); }; diff --git a/chart2/source/controller/inc/res_Titles.hxx b/chart2/source/controller/inc/res_Titles.hxx index a5b93310e36d..8ba85b7ddb9a 100644 --- a/chart2/source/controller/inc/res_Titles.hxx +++ b/chart2/source/controller/inc/res_Titles.hxx @@ -21,6 +21,7 @@ #include "TitleDialogData.hxx" #include <vcl/fixed.hxx> +#include <vcl/weld.hxx> class VclBuilderContainer; class Edit; @@ -60,6 +61,37 @@ private: VclPtr<Edit> m_pEd_SecondaryYAxis; }; +class SchTitleResources final +{ +public: + SchTitleResources(weld::Builder& rBuilder, bool bShowSecondaryAxesTitle); + ~SchTitleResources(); + + void writeToResources( const TitleDialogData& rInput ); + void readFromResources( TitleDialogData& rOutput ); + + bool IsModified(); + void ClearModifyFlag(); + +private: + std::unique_ptr<weld::Label> m_xFT_Main; + std::unique_ptr<weld::Label> m_xFT_Sub; + std::unique_ptr<weld::Entry> m_xEd_Main; + std::unique_ptr<weld::Entry> m_xEd_Sub; + + std::unique_ptr<weld::Label> m_xFT_XAxis; + std::unique_ptr<weld::Label> m_xFT_YAxis; + std::unique_ptr<weld::Label> m_xFT_ZAxis; + std::unique_ptr<weld::Entry> m_xEd_XAxis; + std::unique_ptr<weld::Entry> m_xEd_YAxis; + std::unique_ptr<weld::Entry> m_xEd_ZAxis; + + std::unique_ptr<weld::Label> m_xFT_SecondaryXAxis; + std::unique_ptr<weld::Label> m_xFT_SecondaryYAxis; + std::unique_ptr<weld::Entry> m_xEd_SecondaryXAxis; + std::unique_ptr<weld::Entry> m_xEd_SecondaryYAxis; +}; + } //namespace chart #endif diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 929c50f2322a..e24800d71b3f 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -172,13 +172,13 @@ void ChartController::executeDispatch_InsertTitles() aDialogInput.readFromModel( getModel() ); SolarMutexGuard aGuard; - ScopedVclPtrInstance< SchTitleDlg > aDlg( GetChartWindow(), aDialogInput ); - if( aDlg->Execute() == RET_OK ) + SchTitleDlg aDlg(GetChartFrame(), aDialogInput); + if (aDlg.run() == RET_OK) { // lock controllers till end of block ControllerLockGuardUNO aCLGuard( getModel() ); TitleDialogData aDialogOutput(impl_createReferenceSizeProvider()); - aDlg->getResult( aDialogOutput ); + aDlg.getResult(aDialogOutput); bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput ); if( bChanged ) aUndoGuard.commit(); diff --git a/chart2/uiconfig/ui/inserttitledlg.ui b/chart2/uiconfig/ui/inserttitledlg.ui index 7ecc0050ff4e..3457aeb027a4 100644 --- a/chart2/uiconfig/ui/inserttitledlg.ui +++ b/chart2/uiconfig/ui/inserttitledlg.ui @@ -1,12 +1,18 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.22.1 --> <interface domain="chart"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="InsertTitleDialog"> <property name="can_focus">False</property> <property name="border_width">6</property> <property name="title" translatable="yes" context="inserttitledlg|InsertTitleDialog">Titles</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> + <placeholder/> + </child> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> <property name="can_focus">False</property> @@ -85,10 +91,10 @@ <object class="GtkLabel" id="labelMainTitle"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="inserttitledlg|labelMainTitle">_Title</property> <property name="use_underline">True</property> <property name="mnemonic_widget">maintitle</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -99,10 +105,10 @@ <object class="GtkLabel" id="labelSubTitle"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="inserttitledlg|labelSubTitle">_Subtitle</property> <property name="use_underline">True</property> <property name="mnemonic_widget">subtitle</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -114,6 +120,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> @@ -125,6 +132,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> @@ -160,10 +168,10 @@ <object class="GtkLabel" id="labelPrimaryXaxis"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="inserttitledlg|labelPrimaryXaxis">_X axis</property> <property name="use_underline">True</property> <property name="mnemonic_widget">primaryXaxis</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -174,10 +182,10 @@ <object class="GtkLabel" id="labelPrimaryYaxis"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="inserttitledlg|labelPrimaryYaxis">_Y axis</property> <property name="use_underline">True</property> <property name="mnemonic_widget">primaryYaxis</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -188,10 +196,10 @@ <object class="GtkLabel" id="labelPrimaryZaxis"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="inserttitledlg|labelPrimaryZaxis">_Z axis</property> <property name="use_underline">True</property> <property name="mnemonic_widget">primaryZaxis</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -203,6 +211,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> @@ -214,6 +223,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> @@ -225,6 +235,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> @@ -274,10 +285,10 @@ <object class="GtkLabel" id="labelSecondaryXAxis"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="inserttitledlg|labelSecondaryXAxis">X _axis</property> <property name="use_underline">True</property> <property name="mnemonic_widget">secondaryXaxis</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -288,10 +299,10 @@ <object class="GtkLabel" id="labelSecondaryYAxis"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="inserttitledlg|labelSecondaryYAxis">Y ax_is</property> <property name="use_underline">True</property> <property name="mnemonic_widget">secondaryYaxis</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -303,6 +314,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> @@ -314,6 +326,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> |