diff options
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/view/printer.cxx | 47 | ||||
-rw-r--r-- | sfx2/source/view/viewprn.cxx | 43 | ||||
-rw-r--r-- | sfx2/uiconfig/ui/printeroptionsdialog.ui | 11 |
3 files changed, 42 insertions, 59 deletions
diff --git a/sfx2/source/view/printer.cxx b/sfx2/source/view/printer.cxx index ee1b6e7f7edd..4b8ef5bd1cc9 100644 --- a/sfx2/source/view/printer.cxx +++ b/sfx2/source/view/printer.cxx @@ -190,50 +190,38 @@ void SfxPrinter::SetOptions( const SfxItemSet &rNewOptions ) } -SfxPrintOptionsDialog::SfxPrintOptionsDialog(vcl::Window *pParent, - SfxViewShell *pViewShell, - const SfxItemSet *pSet) - - : ModalDialog(pParent, "PrinterOptionsDialog", - "sfx/ui/printeroptionsdialog.ui") +SfxPrintOptionsDialog::SfxPrintOptionsDialog(weld::Window *pParent, + SfxViewShell *pViewShell, + const SfxItemSet *pSet) + : GenericDialogController(pParent, "sfx/ui/printeroptionsdialog.ui", "PrinterOptionsDialog") , pDlgImpl(new SfxPrintOptDlg_Impl) , pViewSh(pViewShell) , pOptions(pSet->Clone()) + , m_xHelpBtn(m_xBuilder->weld_widget("help")) + , m_xContainer(m_xDialog->weld_content_area()) { - VclContainer *pVBox = get_content_area(); - // Insert TabPage - pPage.reset(pViewSh->CreatePrintOptionsPage(pVBox, *pOptions)); + pPage.reset(pViewSh->CreatePrintOptionsPage(m_xContainer.get(), *pOptions)); DBG_ASSERT( pPage, "CreatePrintOptions != SFX_VIEW_HAS_PRINTOPTIONS" ); if( pPage ) { pPage->Reset( pOptions.get() ); - SetHelpId( pPage->GetHelpId() ); - pPage->Show(); + m_xDialog->set_help_id(pPage->GetHelpId()); } } SfxPrintOptionsDialog::~SfxPrintOptionsDialog() { - disposeOnce(); -} - -void SfxPrintOptionsDialog::dispose() -{ - pDlgImpl.reset(); pPage.disposeAndClear(); - pOptions.reset(); - ModalDialog::dispose(); } - -short SfxPrintOptionsDialog::Execute() +short SfxPrintOptionsDialog::execute() { if( ! pPage ) return RET_CANCEL; - short nRet = ModalDialog::Execute(); + short nRet = m_xDialog->run(); if ( nRet == RET_OK ) pPage->FillItemSet( pOptions.get() ); else @@ -241,24 +229,15 @@ short SfxPrintOptionsDialog::Execute() return nRet; } - -bool SfxPrintOptionsDialog::EventNotify( NotifyEvent& rNEvt ) +IMPL_LINK_NOARG(SfxPrintOptionsDialog, HelpRequestHdl, weld::Widget&, bool) { - if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT ) - { - if ( rNEvt.GetKeyEvent()->GetKeyCode().GetCode() == KEY_F1 && pDlgImpl->mbHelpDisabled ) - return true; // help disabled -> <F1> does nothing - } - - return ModalDialog::EventNotify( rNEvt ); + return !pDlgImpl->mbHelpDisabled; } - void SfxPrintOptionsDialog::DisableHelp() { pDlgImpl->mbHelpDisabled = true; - - get<HelpButton>("help")->Disable(); + m_xHelpBtn->set_sensitive(false); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index 44cc9d509045..19534cb129e1 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -407,38 +407,36 @@ class SfxDialogExecutor_Impl { private: SfxViewShell* _pViewSh; - VclPtr<PrinterSetupDialog> _pSetupParent; + PrinterSetupDialog& _rSetupParent; std::unique_ptr<SfxItemSet> _pOptions; bool _bHelpDisabled; - DECL_LINK( Execute, Button*, void ); + DECL_LINK( Execute, weld::Button&, void ); public: - SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog* pParent ); + SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog& rParent ); - Link<Button*, void> GetLink() const { return LINK(const_cast<SfxDialogExecutor_Impl*>(this), SfxDialogExecutor_Impl, Execute); } + Link<weld::Button&, void> GetLink() const { return LINK(const_cast<SfxDialogExecutor_Impl*>(this), SfxDialogExecutor_Impl, Execute); } const SfxItemSet* GetOptions() const { return _pOptions.get(); } void DisableHelp() { _bHelpDisabled = true; } }; -SfxDialogExecutor_Impl::SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog* pParent ) : +SfxDialogExecutor_Impl::SfxDialogExecutor_Impl( SfxViewShell* pViewSh, PrinterSetupDialog& rParent ) : _pViewSh ( pViewSh ), - _pSetupParent ( pParent ), + _rSetupParent ( rParent ), _pOptions ( nullptr ), _bHelpDisabled ( false ) { } -IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute, Button*, void) +IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute, weld::Button&, void) { // Options noted locally if ( !_pOptions ) { - DBG_ASSERT( _pSetupParent, "no dialog parent" ); - if( _pSetupParent ) - _pOptions = static_cast<SfxPrinter*>( _pSetupParent->GetPrinter() )->GetOptions().Clone(); + _pOptions = static_cast<SfxPrinter*>( _rSetupParent.GetPrinter() )->GetOptions().Clone(); } assert(_pOptions); @@ -446,13 +444,12 @@ IMPL_LINK_NOARG(SfxDialogExecutor_Impl, Execute, Button*, void) return; // Create Dialog - VclPtrInstance<SfxPrintOptionsDialog> pDlg( static_cast<vcl::Window*>(_pSetupParent), - _pViewSh, _pOptions.get() ); - if ( _bHelpDisabled ) - pDlg->DisableHelp(); - if ( pDlg->Execute() == RET_OK ) + SfxPrintOptionsDialog aDlg(_rSetupParent.GetFrameWeld(), _pViewSh, _pOptions.get() ); + if (_bHelpDisabled) + aDlg.DisableHelp(); + if (aDlg.execute() == RET_OK) { - _pOptions = pDlg->GetOptions().Clone(); + _pOptions = aDlg.GetOptions().Clone(); } } @@ -824,20 +821,20 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) VclPtr<SfxPrinter> pDlgPrinter = pPrinter->Clone(); // execute PrinterSetupDialog - VclPtrInstance<PrinterSetupDialog> pPrintSetupDlg( GetWindow() ); + PrinterSetupDialog aPrintSetupDlg(GetFrameWeld()); std::unique_ptr<SfxDialogExecutor_Impl> pExecutor; if (pImpl->m_bHasPrintOptions && HasPrintOptionsPage()) { // additional controls for dialog - pExecutor.reset( new SfxDialogExecutor_Impl( this, pPrintSetupDlg ) ); + pExecutor.reset( new SfxDialogExecutor_Impl( this, aPrintSetupDlg ) ); if ( bPrintOnHelp ) pExecutor->DisableHelp(); - pPrintSetupDlg->SetOptionsHdl( pExecutor->GetLink() ); + aPrintSetupDlg.SetOptionsHdl( pExecutor->GetLink() ); } - pPrintSetupDlg->SetPrinter( pDlgPrinter ); - nDialogRet = pPrintSetupDlg->Execute(); + aPrintSetupDlg.SetPrinter( pDlgPrinter ); + nDialogRet = aPrintSetupDlg.execute(); if ( pExecutor && pExecutor->GetOptions() ) { @@ -851,8 +848,6 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) } } - pPrintSetupDlg.disposeAndClear(); - // no recording of PrinterSetup except printer name (is printer dependent) rReq.Ignore(); @@ -897,7 +892,7 @@ sal_uInt16 SfxViewShell::SetPrinter( SfxPrinter* /*pNewPrinter*/, SfxPrinterChan VclPtr<SfxTabPage> SfxViewShell::CreatePrintOptionsPage ( - TabPageParent /*pParent*/, + weld::Container* /*pPage*/, const SfxItemSet& /*rOptions*/ ) { diff --git a/sfx2/uiconfig/ui/printeroptionsdialog.ui b/sfx2/uiconfig/ui/printeroptionsdialog.ui index b041fffe0efc..f502002486f2 100644 --- a/sfx2/uiconfig/ui/printeroptionsdialog.ui +++ b/sfx2/uiconfig/ui/printeroptionsdialog.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.4 --> <interface domain="sfx"> <requires lib="gtk+" version="3.18"/> <object class="GtkDialog" id="PrinterOptionsDialog"> @@ -7,6 +7,9 @@ <property name="border_width">6</property> <property name="title" translatable="yes" context="printeroptionsdialog|PrinterOptionsDialog">Printer Options</property> <property name="resizable">False</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"> @@ -22,6 +25,8 @@ <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="has_default">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> </object> @@ -36,6 +41,7 @@ <property name="label">gtk-cancel</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="can_default">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> </object> @@ -78,5 +84,8 @@ <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> </interface> |