summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-04-20 13:05:24 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-04-23 12:33:44 +0200
commitc0af8057188c0e95831f9e6d1ef96a424da6f9b2 (patch)
tree6509c67d0cfcc42e3b107004167f2efcccda43cd /svtools
parent27e26fc4286f66ab1bf4c807d86b8f3254c5c68b (diff)
weld SfxPrintOptionsDialog
and SwMMResultPrintDialog Change-Id: Icded6a26a3a151293bea0c9173334cf634283e89 Reviewed-on: https://gerrit.libreoffice.org/53299 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/dialogs/prnsetup.cxx173
-rw-r--r--svtools/uiconfig/ui/printersetupdialog.ui22
2 files changed, 90 insertions, 105 deletions
diff --git a/svtools/source/dialogs/prnsetup.cxx b/svtools/source/dialogs/prnsetup.cxx
index d7a8b06a7900..3d97febb7d30 100644
--- a/svtools/source/dialogs/prnsetup.cxx
+++ b/svtools/source/dialogs/prnsetup.cxx
@@ -20,11 +20,11 @@
#include <svtools/prnsetup.hxx>
#include <svtools/strings.hrc>
#include <svtools/svtresid.hxx>
+#include <vcl/svapp.hxx>
#include <vcl/print.hxx>
-
void ImplFillPrnDlgListBox( const Printer* pPrinter,
- ListBox* pBox, PushButton* pPropBtn )
+ weld::ComboBoxText* pBox, weld::Button* pPropBtn )
{
ImplFreePrnDlgListBox( pBox );
@@ -33,29 +33,29 @@ void ImplFillPrnDlgListBox( const Printer* pPrinter,
if ( nCount )
{
for( unsigned int i = 0; i < nCount; i++ )
- pBox->InsertEntry( rPrinters[i] );
- pBox->SelectEntry( pPrinter->GetName() );
+ pBox->append_text( rPrinters[i] );
+ pBox->set_active( pPrinter->GetName() );
}
- pBox->Enable( nCount != 0 );
- pPropBtn->Show( pPrinter->HasSupport( PrinterSupport::SetupDialog ) );
+ pBox->set_sensitive(nCount != 0);
+ pPropBtn->show( pPrinter->HasSupport( PrinterSupport::SetupDialog ) );
}
-void ImplFreePrnDlgListBox( ListBox* pBox, bool bClear )
+void ImplFreePrnDlgListBox( weld::ComboBoxText* pBox, bool bClear )
{
if ( bClear )
- pBox->Clear();
+ pBox->clear();
}
-Printer* ImplPrnDlgListBoxSelect( ListBox const * pBox, PushButton* pPropBtn,
+Printer* ImplPrnDlgListBoxSelect( const weld::ComboBoxText* pBox, weld::Button* pPropBtn,
Printer const * pPrinter, Printer* pTempPrinterIn )
{
VclPtr<Printer> pTempPrinter( pTempPrinterIn );
- if ( pBox->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ if ( pBox->get_active() != -1 )
{
- const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectedEntry(), true );
+ const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->get_active_text(), true );
if( pInfo)
{
if ( !pTempPrinter )
@@ -76,13 +76,13 @@ Printer* ImplPrnDlgListBoxSelect( ListBox const * pBox, PushButton* pPropBtn,
}
}
- pPropBtn->Enable( pTempPrinter->HasSupport( PrinterSupport::SetupDialog ) );
+ pPropBtn->set_sensitive(pTempPrinter->HasSupport(PrinterSupport::SetupDialog));
}
else
- pPropBtn->Disable();
+ pPropBtn->set_sensitive(false);
}
else
- pPropBtn->Disable();
+ pPropBtn->set_sensitive(false);
return pTempPrinter;
}
@@ -107,11 +107,11 @@ Printer* ImplPrnDlgUpdatePrinter( Printer const * pPrinter, Printer* pTempPrinte
}
-void ImplPrnDlgUpdateQueueInfo( ListBox const * pBox, QueueInfo& rInfo )
+void ImplPrnDlgUpdateQueueInfo( const weld::ComboBoxText* pBox, QueueInfo& rInfo )
{
- if ( pBox->GetSelectedEntryPos() != LISTBOX_ENTRY_NOTFOUND )
+ if ( pBox->get_active() != -1 )
{
- const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->GetSelectedEntry(), true );
+ const QueueInfo* pInfo = Printer::GetQueueInfo( pBox->get_active_text(), true );
if( pInfo )
rInfo = *pInfo;
}
@@ -207,147 +207,128 @@ OUString ImplPrnDlgGetStatusText( const QueueInfo& rInfo )
return aStr;
}
-
-PrinterSetupDialog::PrinterSetupDialog(vcl::Window* pParent)
- : ModalDialog(pParent, "PrinterSetupDialog",
- "svt/ui/printersetupdialog.ui")
+PrinterSetupDialog::PrinterSetupDialog(weld::Window* pParent)
+ : GenericDialogController(pParent, "svt/ui/printersetupdialog.ui", "PrinterSetupDialog")
+ , m_xLbName(m_xBuilder->weld_combo_box_text("name"))
+ , m_xBtnProperties(m_xBuilder->weld_button("properties"))
+ , m_xBtnOptions(m_xBuilder->weld_button("options"))
+ , m_xFiStatus(m_xBuilder->weld_label("status"))
+ , m_xFiType(m_xBuilder->weld_label("type"))
+ , m_xFiLocation(m_xBuilder->weld_label("location"))
+ , m_xFiComment(m_xBuilder->weld_label("comment"))
{
- get(m_pLbName, "name");
- m_pLbName->SetStyle(m_pLbName->GetStyle() | WB_SORT);
- get(m_pBtnProperties, "properties");
- get(m_pBtnOptions, "options");
- get(m_pFiStatus, "status");
- get(m_pFiType, "type");
- get(m_pFiLocation, "location");
- get(m_pFiComment, "comment");
+ m_xLbName->make_sorted();
// show options button only if link is set
- m_pBtnOptions->Hide();
+ m_xBtnOptions->hide();
mpPrinter = nullptr;
mpTempPrinter = nullptr;
maStatusTimer.SetTimeout( IMPL_PRINTDLG_STATUS_UPDATE );
maStatusTimer.SetInvokeHandler( LINK( this, PrinterSetupDialog, ImplStatusHdl ) );
- m_pBtnProperties->SetClickHdl( LINK( this, PrinterSetupDialog, ImplPropertiesHdl ) );
- m_pLbName->SetSelectHdl( LINK( this, PrinterSetupDialog, ImplChangePrinterHdl ) );
+ m_xBtnProperties->connect_clicked( LINK( this, PrinterSetupDialog, ImplPropertiesHdl ) );
+ m_xLbName->connect_changed( LINK( this, PrinterSetupDialog, ImplChangePrinterHdl ) );
+ m_xDialog->connect_focus_in( LINK( this, PrinterSetupDialog, ImplGetFocusHdl ) );
+ Application::AddEventListener(LINK( this, PrinterSetupDialog, ImplDataChangedHdl ) );
}
-
PrinterSetupDialog::~PrinterSetupDialog()
{
- disposeOnce();
-}
-
-void PrinterSetupDialog::dispose()
-{
- ImplFreePrnDlgListBox(m_pLbName, false);
- m_pLbName.clear();
- m_pBtnProperties.clear();
- m_pBtnOptions.clear();
- m_pFiStatus.clear();
- m_pFiType.clear();
- m_pFiLocation.clear();
- m_pFiComment.clear();
- mpTempPrinter.disposeAndClear();
- mpPrinter.clear();
- ModalDialog::dispose();
+ Application::RemoveEventListener(LINK( this, PrinterSetupDialog, ImplDataChangedHdl ) );
+ ImplFreePrnDlgListBox(m_xLbName.get(), false);
}
-void PrinterSetupDialog::SetOptionsHdl( const Link<Button*,void>& rLink )
+void PrinterSetupDialog::SetOptionsHdl(const Link<weld::Button&, void>& rLink)
{
- m_pBtnOptions->SetClickHdl( rLink );
- m_pBtnOptions->Show( rLink.IsSet() );
+ m_xBtnOptions->connect_clicked(rLink);
+ m_xBtnOptions->show(rLink.IsSet());
}
void PrinterSetupDialog::ImplSetInfo()
{
- const QueueInfo* pInfo = Printer::GetQueueInfo(m_pLbName->GetSelectedEntry(), true);
+ const QueueInfo* pInfo = Printer::GetQueueInfo(m_xLbName->get_active_text(), true);
if ( pInfo )
{
- m_pFiType->SetText( pInfo->GetDriver() );
- m_pFiLocation->SetText( pInfo->GetLocation() );
- m_pFiComment->SetText( pInfo->GetComment() );
- m_pFiStatus->SetText( ImplPrnDlgGetStatusText( *pInfo ) );
+ m_xFiType->set_label( pInfo->GetDriver() );
+ m_xFiLocation->set_label( pInfo->GetLocation() );
+ m_xFiComment->set_label( pInfo->GetComment() );
+ m_xFiStatus->set_label( ImplPrnDlgGetStatusText( *pInfo ) );
}
else
{
OUString aTempStr;
- m_pFiType->SetText( aTempStr );
- m_pFiLocation->SetText( aTempStr );
- m_pFiComment->SetText( aTempStr );
- m_pFiStatus->SetText( aTempStr );
+ m_xFiType->set_label( aTempStr );
+ m_xFiLocation->set_label( aTempStr );
+ m_xFiComment->set_label( aTempStr );
+ m_xFiStatus->set_label( aTempStr );
}
}
-
IMPL_LINK_NOARG(PrinterSetupDialog, ImplStatusHdl, Timer *, void)
{
QueueInfo aInfo;
- ImplPrnDlgUpdateQueueInfo(m_pLbName, aInfo);
- m_pFiStatus->SetText( ImplPrnDlgGetStatusText( aInfo ) );
+ ImplPrnDlgUpdateQueueInfo(m_xLbName.get(), aInfo);
+ m_xFiStatus->set_label( ImplPrnDlgGetStatusText( aInfo ) );
}
-IMPL_LINK_NOARG(PrinterSetupDialog, ImplPropertiesHdl, Button*, void)
+IMPL_LINK_NOARG(PrinterSetupDialog, ImplPropertiesHdl, weld::Button&, void)
{
if ( !mpTempPrinter )
mpTempPrinter = VclPtr<Printer>::Create( mpPrinter->GetJobSetup() );
- mpTempPrinter->Setup( this );
+ mpTempPrinter->Setup(m_xDialog.get());
}
-
-IMPL_LINK_NOARG(PrinterSetupDialog, ImplChangePrinterHdl, ListBox&, void)
+IMPL_LINK_NOARG(PrinterSetupDialog, ImplChangePrinterHdl, weld::ComboBoxText&, void)
{
- mpTempPrinter = ImplPrnDlgListBoxSelect(m_pLbName, m_pBtnProperties,
- mpPrinter, mpTempPrinter );
+ mpTempPrinter = ImplPrnDlgListBoxSelect(m_xLbName.get(), m_xBtnProperties.get(),
+ mpPrinter, mpTempPrinter);
ImplSetInfo();
}
-
-bool PrinterSetupDialog::EventNotify( NotifyEvent& rNEvt )
+IMPL_LINK(PrinterSetupDialog, ImplGetFocusHdl, weld::Widget&, rWidget, void)
{
- if ( (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS) && IsReallyVisible() )
- ImplStatusHdl( &maStatusTimer );
-
- return ModalDialog::EventNotify( rNEvt );
+ if (rWidget.is_visible())
+ ImplStatusHdl(&maStatusTimer);
}
-
-void PrinterSetupDialog::DataChanged( const DataChangedEvent& rDCEvt )
+IMPL_LINK(PrinterSetupDialog, ImplDataChangedHdl, VclSimpleEvent&, rEvt, void)
{
- if ( rDCEvt.GetType() == DataChangedEventType::PRINTER )
- {
- mpTempPrinter = ImplPrnDlgUpdatePrinter( mpPrinter, mpTempPrinter );
- Printer* pPrn;
- if ( mpTempPrinter )
- pPrn = mpTempPrinter;
- else
- pPrn = mpPrinter;
- ImplFillPrnDlgListBox(pPrn, m_pLbName, m_pBtnProperties);
- ImplSetInfo();
- }
-
- ModalDialog::DataChanged( rDCEvt );
+ VclEventId nEvent = rEvt.GetId();
+ if (nEvent != VclEventId::ApplicationDataChanged)
+ return;
+
+ DataChangedEvent* pData = static_cast<DataChangedEvent*>(static_cast<VclWindowEvent&>(rEvt).GetData());
+ if (!pData || pData->GetType() != DataChangedEventType::PRINTER)
+ return;
+
+ mpTempPrinter = ImplPrnDlgUpdatePrinter(mpPrinter, mpTempPrinter);
+ Printer* pPrn;
+ if (mpTempPrinter)
+ pPrn = mpTempPrinter;
+ else
+ pPrn = mpPrinter;
+ ImplFillPrnDlgListBox(pPrn, m_xLbName.get(), m_xBtnProperties.get());
+ ImplSetInfo();
}
-
-short PrinterSetupDialog::Execute()
+short PrinterSetupDialog::execute()
{
if ( !mpPrinter || mpPrinter->IsPrinting() || mpPrinter->IsJobActive() )
{
- SAL_WARN( "svtools.dialogs", "PrinterSetupDialog::Execute() - No Printer or printer is printing" );
+ SAL_WARN( "svtools.dialogs", "PrinterSetupDialog::execute() - No Printer or printer is printing" );
return RET_CANCEL;
}
Printer::updatePrinters();
- ImplFillPrnDlgListBox(mpPrinter, m_pLbName, m_pBtnProperties);
+ ImplFillPrnDlgListBox(mpPrinter, m_xLbName.get(), m_xBtnProperties.get());
ImplSetInfo();
maStatusTimer.Start();
// start dialog
- short nRet = ModalDialog::Execute();
+ short nRet = m_xDialog->run();
// update data if the dialog was terminated with OK
if ( nRet == RET_OK )
diff --git a/svtools/uiconfig/ui/printersetupdialog.ui b/svtools/uiconfig/ui/printersetupdialog.ui
index 0ccfccdbfc02..354d7a7e441d 100644
--- a/svtools/uiconfig/ui/printersetupdialog.ui
+++ b/svtools/uiconfig/ui/printersetupdialog.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="svt">
<requires lib="gtk+" version="3.18"/>
<object class="GtkDialog" id="PrinterSetupDialog">
@@ -7,6 +7,9 @@
<property name="border_width">6</property>
<property name="title" translatable="yes" context="printersetupdialog|PrinterSetupDialog">Printer Setup</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">
@@ -43,7 +46,6 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
- <property name="secondary">True</property>
</packing>
</child>
<child>
@@ -107,10 +109,10 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes" context="printersetupdialog|label2">Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">name</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -121,8 +123,8 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes" context="printersetupdialog|label3">Status:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -133,8 +135,8 @@
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes" context="printersetupdialog|label4">Type:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -145,8 +147,8 @@
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes" context="printersetupdialog|label5">Location:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -157,8 +159,8 @@
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes" context="printersetupdialog|label6">Comment:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -226,7 +228,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBox" id="name">
+ <object class="GtkComboBoxText" id="name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
@@ -261,9 +263,11 @@
</child>
<action-widgets>
<action-widget response="-11">help</action-widget>
- <action-widget response="0">options</action-widget>
<action-widget response="-5">ok</action-widget>
<action-widget response="-6">cancel</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>