diff options
-rw-r--r-- | include/vcl/layout.hxx | 11 | ||||
-rw-r--r-- | starmath/UIConfig_smath.mk | 1 | ||||
-rw-r--r-- | starmath/inc/starmath.hrc | 1 | ||||
-rw-r--r-- | starmath/source/dialog.cxx | 39 | ||||
-rw-r--r-- | starmath/source/smres.src | 7 | ||||
-rw-r--r-- | starmath/uiconfig/smath/ui/savedefaultsdialog.ui | 34 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 43 |
7 files changed, 97 insertions, 39 deletions
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index 2b8fa8abb574..ede844e7d8df 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -657,10 +657,19 @@ enum VclButtonsType VCL_BUTTONS_OK_CANCEL }; +enum VclMessageType +{ + VCL_MESSAGE_INFO, + VCL_MESSAGE_WARNING, + VCL_MESSAGE_QUESTION, + VCL_MESSAGE_ERROR +}; + class VCL_DLLPUBLIC MessageDialog : public Dialog { private: - VclButtonsType m_eType; + VclButtonsType m_eButtonsType; + VclMessageType m_eMessageType; VclGrid* m_pGrid; FixedImage* m_pImage; VclMultiLineEdit* m_pPrimaryMessage; diff --git a/starmath/UIConfig_smath.mk b/starmath/UIConfig_smath.mk index d72ae83e9f77..d64abe8a1e37 100644 --- a/starmath/UIConfig_smath.mk +++ b/starmath/UIConfig_smath.mk @@ -27,6 +27,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\ starmath/uiconfig/smath/ui/alignmentdialog \ starmath/uiconfig/smath/ui/catalogdialog \ starmath/uiconfig/smath/ui/printeroptions \ + starmath/uiconfig/smath/ui/savedefaultsdialog \ starmath/uiconfig/smath/ui/spacingdialog \ )) diff --git a/starmath/inc/starmath.hrc b/starmath/inc/starmath.hrc index 7cb9f4f188b9..f233fa4b1b53 100644 --- a/starmath/inc/starmath.hrc +++ b/starmath/inc/starmath.hrc @@ -90,7 +90,6 @@ #define RID_MATH_TOOLBOX (RID_APP_START + 50) -#define RID_DEFAULTSAVEQUERY (RID_APP_START + 102) #define RID_NOMATHTYPEFACEWARNING (RID_APP_START + 204) #define RID_OBJECTNAME (RID_APP_START + 501) // free diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index 149cf100f7d2..86e23408929a 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -24,6 +24,7 @@ #include <svl/stritem.hxx> #include <sfx2/app.hxx> #include <vcl/builder.hxx> +#include <vcl/layout.hxx> #include <vcl/msgbox.hxx> #include <svtools/ctrltool.hxx> #include <sfx2/printer.hxx> @@ -421,22 +422,25 @@ void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt ) ModalDialog::DataChanged( rDCEvt ); } -/**************************************************************************/ - +class SaveDefaultsQuery : public MessageDialog +{ +public: + SaveDefaultsQuery(Window *pParent) + : MessageDialog(pParent, "SaveDefaultsDialog", + "modules/smath/ui/savedefaultsdialog.ui") + { + } +}; IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) { - QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); - - if (pQueryBox->Execute() == RET_YES) + if (SaveDefaultsQuery(this).Execute() == RET_YES) { SmModule *pp = SM_MOD(); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); WriteTo( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt ); } - - delete pQueryBox; return 0; } @@ -546,16 +550,13 @@ IMPL_LINK( SmFontTypeDialog, MenuSelectHdl, Menu *, pMenu ) IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) { - QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); - if (pQueryBox->Execute() == RET_YES) + if (SaveDefaultsQuery(this).Execute() == RET_YES) { SmModule *pp = SM_MOD(); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); WriteTo( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt, true ); } - - delete pQueryBox; return 0; } IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton ) @@ -755,16 +756,13 @@ IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu ) IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) { - QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); - - if (pQueryBox->Execute() == RET_YES) + if (SaveDefaultsQuery(this).Execute() == RET_YES) { SmModule *pp = SM_MOD(); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); WriteTo( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt ); } - delete pQueryBox; return 0; } @@ -1044,27 +1042,18 @@ void SmDistanceDialog::WriteTo(SmFormat &rFormat) /*const*/ rFormat.RequestApplyChanges(); } - -/**************************************************************************/ - - IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) { - QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); - - if (pQueryBox->Execute() == RET_YES) + if (SaveDefaultsQuery(this).Execute() == RET_YES) { SmModule *pp = SM_MOD(); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); WriteTo( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt ); } - - delete pQueryBox; return 0; } - SmAlignDialog::SmAlignDialog(Window * pParent) : ModalDialog(pParent, "AlignmentDialog", "modules/smath/ui/alignmentdialog.ui") diff --git a/starmath/source/smres.src b/starmath/source/smres.src index 805b2905e4ef..f5c36b4cd36c 100644 --- a/starmath/source/smres.src +++ b/starmath/source/smres.src @@ -793,13 +793,6 @@ WarningBox RID_NOMATHTYPEFACEWARNING Message [ en-US ] = "The 'StarMath' font has not been installed.\nWithout this font %PRODUCTNAME Math cannot function correctly.\nPlease install this font and restart %PRODUCTNAME Math." ; }; -QueryBox RID_DEFAULTSAVEQUERY -{ - Buttons = WB_YES_NO ; - DefButton = WB_DEF_YES ; - Message [ en-US ] = "Should the changes be saved as defaults?\n\nThese changes will apply for all new formulas." ; -}; - String RID_FONTREGULAR { Text [ en-US ] = "Standard" ; diff --git a/starmath/uiconfig/smath/ui/savedefaultsdialog.ui b/starmath/uiconfig/smath/ui/savedefaultsdialog.ui new file mode 100644 index 000000000000..bcf710850e66 --- /dev/null +++ b/starmath/uiconfig/smath/ui/savedefaultsdialog.ui @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <!-- interface-requires gtk+ 3.0 --> + <object class="GtkMessageDialog" id="SaveDefaultsDialog"> + <property name="can_focus">False</property> + <property name="border_width">12</property> + <property name="title" translatable="yes">Save defaults</property> + <property name="type_hint">dialog</property> + <property name="skip_taskbar_hint">True</property> + <property name="message_type">question</property> + <property name="buttons">yes-no</property> + <property name="text" translatable="yes">Should the changes be saved as defaults?</property> + <property name="secondary_text" translatable="yes">These changes will apply for all new formulas.</property> + <child internal-child="vbox"> + <object class="GtkBox" id="messagedialog-vbox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">24</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="messagedialog-action_area"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index a4760992ee9c..dfd1098c2d2f 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -1672,7 +1672,8 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue) MessageDialog::MessageDialog(Window* pParent, WinBits nStyle) : Dialog(pParent, nStyle) - , m_eType(VCL_BUTTONS_NONE) + , m_eButtonsType(VCL_BUTTONS_NONE) + , m_eMessageType(VCL_MESSAGE_INFO) , m_pGrid(NULL) , m_pImage(NULL) , m_pPrimaryMessage(NULL) @@ -1683,7 +1684,8 @@ MessageDialog::MessageDialog(Window* pParent, WinBits nStyle) MessageDialog::MessageDialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) : Dialog(pParent, rID, rUIXMLDescription, WINDOW_MESSBOX) - , m_eType(VCL_BUTTONS_NONE) + , m_eButtonsType(VCL_BUTTONS_NONE) + , m_eMessageType(VCL_MESSAGE_INFO) , m_pGrid(NULL) , m_pImage(NULL) , m_pPrimaryMessage(NULL) @@ -1767,7 +1769,21 @@ short MessageDialog::Execute() m_pGrid->set_column_spacing(12); m_pImage = new FixedImage(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK); - m_pImage->SetImage(WarningBox::GetStandardImage()); + switch (m_eMessageType) + { + case VCL_MESSAGE_INFO: + m_pImage->SetImage(InfoBox::GetStandardImage()); + break; + case VCL_MESSAGE_WARNING: + m_pImage->SetImage(WarningBox::GetStandardImage()); + break; + case VCL_MESSAGE_QUESTION: + m_pImage->SetImage(QueryBox::GetStandardImage()); + break; + case VCL_MESSAGE_ERROR: + m_pImage->SetImage(ErrorBox::GetStandardImage()); + break; + } m_pImage->set_grid_left_attach(0); m_pImage->set_grid_top_attach(0); m_pImage->set_valign(VCL_ALIGN_START); @@ -1800,7 +1816,7 @@ short MessageDialog::Execute() VclButtonBox *pButtonBox = get_action_area(); assert(pButtonBox); PushButton *pBtn; - switch (m_eType) + switch (m_eButtonsType) { case VCL_BUTTONS_NONE: break; @@ -1874,6 +1890,23 @@ bool MessageDialog::set_property(const OString &rKey, const OString &rValue) set_primary_text(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); else if (rKey == "secondary-text") set_secondary_text(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); + else if (rKey == "message-type") + { + VclMessageType eMode = VCL_MESSAGE_INFO; + if (rValue.equals("info")) + eMode = VCL_MESSAGE_INFO; + else if (rValue.equals("warning")) + eMode = VCL_MESSAGE_WARNING; + else if (rValue.equals("question")) + eMode = VCL_MESSAGE_QUESTION; + else if (rValue.equals("error")) + eMode = VCL_MESSAGE_ERROR; + else + { + SAL_WARN("vcl.layout", "unknown message type mode" << rValue.getStr()); + } + m_eMessageType = eMode; + } else if (rKey == "buttons") { VclButtonsType eMode = VCL_BUTTONS_NONE; @@ -1893,7 +1926,7 @@ bool MessageDialog::set_property(const OString &rKey, const OString &rValue) { SAL_WARN("vcl.layout", "unknown buttons type mode" << rValue.getStr()); } - m_eType = eMode; + m_eButtonsType = eMode; } else return Dialog::set_property(rKey, rValue); |