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

convert save defaults to .ui format

Change-Id: I7843598761cf95b04d9c3741cd8b0612b9b059ce
üst ddca0400
...@@ -657,10 +657,19 @@ enum VclButtonsType ...@@ -657,10 +657,19 @@ enum VclButtonsType
VCL_BUTTONS_OK_CANCEL VCL_BUTTONS_OK_CANCEL
}; };
enum VclMessageType
{
VCL_MESSAGE_INFO,
VCL_MESSAGE_WARNING,
VCL_MESSAGE_QUESTION,
VCL_MESSAGE_ERROR
};
class VCL_DLLPUBLIC MessageDialog : public Dialog class VCL_DLLPUBLIC MessageDialog : public Dialog
{ {
private: private:
VclButtonsType m_eType; VclButtonsType m_eButtonsType;
VclMessageType m_eMessageType;
VclGrid* m_pGrid; VclGrid* m_pGrid;
FixedImage* m_pImage; FixedImage* m_pImage;
VclMultiLineEdit* m_pPrimaryMessage; VclMultiLineEdit* m_pPrimaryMessage;
......
...@@ -27,6 +27,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\ ...@@ -27,6 +27,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\
starmath/uiconfig/smath/ui/alignmentdialog \ starmath/uiconfig/smath/ui/alignmentdialog \
starmath/uiconfig/smath/ui/catalogdialog \ starmath/uiconfig/smath/ui/catalogdialog \
starmath/uiconfig/smath/ui/printeroptions \ starmath/uiconfig/smath/ui/printeroptions \
starmath/uiconfig/smath/ui/savedefaultsdialog \
starmath/uiconfig/smath/ui/spacingdialog \ starmath/uiconfig/smath/ui/spacingdialog \
)) ))
......
...@@ -90,7 +90,6 @@ ...@@ -90,7 +90,6 @@
#define RID_MATH_TOOLBOX (RID_APP_START + 50) #define RID_MATH_TOOLBOX (RID_APP_START + 50)
#define RID_DEFAULTSAVEQUERY (RID_APP_START + 102)
#define RID_NOMATHTYPEFACEWARNING (RID_APP_START + 204) #define RID_NOMATHTYPEFACEWARNING (RID_APP_START + 204)
#define RID_OBJECTNAME (RID_APP_START + 501) #define RID_OBJECTNAME (RID_APP_START + 501)
// free // free
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <svl/stritem.hxx> #include <svl/stritem.hxx>
#include <sfx2/app.hxx> #include <sfx2/app.hxx>
#include <vcl/builder.hxx> #include <vcl/builder.hxx>
#include <vcl/layout.hxx>
#include <vcl/msgbox.hxx> #include <vcl/msgbox.hxx>
#include <svtools/ctrltool.hxx> #include <svtools/ctrltool.hxx>
#include <sfx2/printer.hxx> #include <sfx2/printer.hxx>
...@@ -421,22 +422,25 @@ void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt ) ...@@ -421,22 +422,25 @@ void SmFontDialog::DataChanged( const DataChangedEvent& rDCEvt )
ModalDialog::DataChanged( 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*/ ) IMPL_LINK( SmFontSizeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
{ {
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); if (SaveDefaultsQuery(this).Execute() == RET_YES)
if (pQueryBox->Execute() == RET_YES)
{ {
SmModule *pp = SM_MOD(); SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt ); WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt );
} }
delete pQueryBox;
return 0; return 0;
} }
...@@ -546,16 +550,13 @@ IMPL_LINK( SmFontTypeDialog, MenuSelectHdl, Menu *, pMenu ) ...@@ -546,16 +550,13 @@ IMPL_LINK( SmFontTypeDialog, MenuSelectHdl, Menu *, pMenu )
IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) IMPL_LINK_INLINE_START( SmFontTypeDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
{ {
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); if (SaveDefaultsQuery(this).Execute() == RET_YES)
if (pQueryBox->Execute() == RET_YES)
{ {
SmModule *pp = SM_MOD(); SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt ); WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt, true ); pp->GetConfig()->SetStandardFormat( aFmt, true );
} }
delete pQueryBox;
return 0; return 0;
} }
IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton ) IMPL_LINK_INLINE_END( SmFontTypeDialog, DefaultButtonClickHdl, Button *, pButton )
...@@ -755,16 +756,13 @@ IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu ) ...@@ -755,16 +756,13 @@ IMPL_LINK( SmDistanceDialog, MenuSelectHdl, Menu *, pMenu )
IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
{ {
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); if (SaveDefaultsQuery(this).Execute() == RET_YES)
if (pQueryBox->Execute() == RET_YES)
{ {
SmModule *pp = SM_MOD(); SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt ); WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt );
} }
delete pQueryBox;
return 0; return 0;
} }
...@@ -1044,27 +1042,18 @@ void SmDistanceDialog::WriteTo(SmFormat &rFormat) /*const*/ ...@@ -1044,27 +1042,18 @@ void SmDistanceDialog::WriteTo(SmFormat &rFormat) /*const*/
rFormat.RequestApplyChanges(); rFormat.RequestApplyChanges();
} }
/**************************************************************************/
IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ ) IMPL_LINK( SmAlignDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
{ {
QueryBox *pQueryBox = new QueryBox(this, SmResId(RID_DEFAULTSAVEQUERY)); if (SaveDefaultsQuery(this).Execute() == RET_YES)
if (pQueryBox->Execute() == RET_YES)
{ {
SmModule *pp = SM_MOD(); SmModule *pp = SM_MOD();
SmFormat aFmt( pp->GetConfig()->GetStandardFormat() ); SmFormat aFmt( pp->GetConfig()->GetStandardFormat() );
WriteTo( aFmt ); WriteTo( aFmt );
pp->GetConfig()->SetStandardFormat( aFmt ); pp->GetConfig()->SetStandardFormat( aFmt );
} }
delete pQueryBox;
return 0; return 0;
} }
SmAlignDialog::SmAlignDialog(Window * pParent) SmAlignDialog::SmAlignDialog(Window * pParent)
: ModalDialog(pParent, "AlignmentDialog", : ModalDialog(pParent, "AlignmentDialog",
"modules/smath/ui/alignmentdialog.ui") "modules/smath/ui/alignmentdialog.ui")
......
...@@ -793,13 +793,6 @@ WarningBox RID_NOMATHTYPEFACEWARNING ...@@ -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." ; 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 String RID_FONTREGULAR
{ {
Text [ en-US ] = "Standard" ; Text [ en-US ] = "Standard" ;
......
<?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>
...@@ -1672,7 +1672,8 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue) ...@@ -1672,7 +1672,8 @@ bool VclSizeGroup::set_property(const OString &rKey, const OString &rValue)
MessageDialog::MessageDialog(Window* pParent, WinBits nStyle) MessageDialog::MessageDialog(Window* pParent, WinBits nStyle)
: Dialog(pParent, nStyle) : Dialog(pParent, nStyle)
, m_eType(VCL_BUTTONS_NONE) , m_eButtonsType(VCL_BUTTONS_NONE)
, m_eMessageType(VCL_MESSAGE_INFO)
, m_pGrid(NULL) , m_pGrid(NULL)
, m_pImage(NULL) , m_pImage(NULL)
, m_pPrimaryMessage(NULL) , m_pPrimaryMessage(NULL)
...@@ -1683,7 +1684,8 @@ MessageDialog::MessageDialog(Window* pParent, WinBits nStyle) ...@@ -1683,7 +1684,8 @@ MessageDialog::MessageDialog(Window* pParent, WinBits nStyle)
MessageDialog::MessageDialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription) MessageDialog::MessageDialog(Window* pParent, const OString& rID, const OUString& rUIXMLDescription)
: Dialog(pParent, rID, rUIXMLDescription, WINDOW_MESSBOX) : 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_pGrid(NULL)
, m_pImage(NULL) , m_pImage(NULL)
, m_pPrimaryMessage(NULL) , m_pPrimaryMessage(NULL)
...@@ -1767,7 +1769,21 @@ short MessageDialog::Execute() ...@@ -1767,7 +1769,21 @@ short MessageDialog::Execute()
m_pGrid->set_column_spacing(12); m_pGrid->set_column_spacing(12);
m_pImage = new FixedImage(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK); 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_left_attach(0);
m_pImage->set_grid_top_attach(0); m_pImage->set_grid_top_attach(0);
m_pImage->set_valign(VCL_ALIGN_START); m_pImage->set_valign(VCL_ALIGN_START);
...@@ -1800,7 +1816,7 @@ short MessageDialog::Execute() ...@@ -1800,7 +1816,7 @@ short MessageDialog::Execute()
VclButtonBox *pButtonBox = get_action_area(); VclButtonBox *pButtonBox = get_action_area();
assert(pButtonBox); assert(pButtonBox);
PushButton *pBtn; PushButton *pBtn;
switch (m_eType) switch (m_eButtonsType)
{ {
case VCL_BUTTONS_NONE: case VCL_BUTTONS_NONE:
break; break;
...@@ -1874,6 +1890,23 @@ bool MessageDialog::set_property(const OString &rKey, const OString &rValue) ...@@ -1874,6 +1890,23 @@ bool MessageDialog::set_property(const OString &rKey, const OString &rValue)
set_primary_text(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); set_primary_text(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8));
else if (rKey == "secondary-text") else if (rKey == "secondary-text")
set_secondary_text(OStringToOUString(rValue, RTL_TEXTENCODING_UTF8)); 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") else if (rKey == "buttons")
{ {
VclButtonsType eMode = VCL_BUTTONS_NONE; VclButtonsType eMode = VCL_BUTTONS_NONE;
...@@ -1893,7 +1926,7 @@ bool MessageDialog::set_property(const OString &rKey, const OString &rValue) ...@@ -1893,7 +1926,7 @@ bool MessageDialog::set_property(const OString &rKey, const OString &rValue)
{ {
SAL_WARN("vcl.layout", "unknown buttons type mode" << rValue.getStr()); SAL_WARN("vcl.layout", "unknown buttons type mode" << rValue.getStr());
} }
m_eType = eMode; m_eButtonsType = eMode;
} }
else else
return Dialog::set_property(rKey, rValue); return Dialog::set_property(rKey, rValue);
......
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