summaryrefslogtreecommitdiff
path: root/vcl/source/window
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-10-05 11:09:20 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-10-06 08:01:55 +0200
commit93c833e848a4406f36bcb7925928554bb104aa32 (patch)
treeeabab31b2ebcb49e7bbefbf7bfa363faa52ff900 /vcl/source/window
parent729f24a9e3639051e6b066cb1fc68fbd1ef4db16 (diff)
Use idle to update preview in print dlg
Otherwise UI blocks while the preview is being updated Change-Id: I98c536b83a31e9ea3f72effc8a602ee190a81e68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103951 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'vcl/source/window')
-rw-r--r--vcl/source/window/printdlg.cxx48
1 files changed, 34 insertions, 14 deletions
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index e9d35f96dd72..d68b4decc335 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -578,6 +578,8 @@ PrintDialog::PrintDialog(weld::Window* i_pWindow, const std::shared_ptr<PrinterC
, mbCollateAlwaysOff(false)
, mbShowLayoutFrame( true )
, mbSingleJobs( false )
+ , maUpdatePreviewIdle("Print Dialog Update Preview Idle")
+ , maUpdatePreviewNoCacheIdle("Print Dialog Update Preview (no cache) Idle")
{
// save printbutton text, gets exchanged occasionally with print to file
maPrintText = mxOKButton->get_label();
@@ -651,6 +653,11 @@ PrintDialog::PrintDialog(weld::Window* i_pWindow, const std::shared_ptr<PrinterC
maNupLandscapeSize = Size( aNupSize.Height(), aNupSize.Width() );
}
+ maUpdatePreviewIdle.SetPriority(TaskPriority::POST_PAINT);
+ maUpdatePreviewIdle.SetInvokeHandler(LINK( this, PrintDialog, updatePreviewIdle));
+ maUpdatePreviewNoCacheIdle.SetPriority(TaskPriority::POST_PAINT);
+ maUpdatePreviewNoCacheIdle.SetInvokeHandler(LINK(this, PrintDialog, updatePreviewNoCacheIdle));
+
initFromMultiPageSetup( maPController->getMultipage() );
// setup optional UI options set by application
@@ -895,6 +902,16 @@ void PrintDialog::setPreviewText()
mxNumPagesText->set_label( aNewText );
}
+IMPL_LINK_NOARG(PrintDialog, updatePreviewIdle, Timer*, void)
+{
+ preparePreview(true);
+}
+
+IMPL_LINK_NOARG(PrintDialog, updatePreviewNoCacheIdle, Timer*, void)
+{
+ preparePreview(false);
+}
+
void PrintDialog::preparePreview( bool i_bMayUseCache )
{
VclPtr<Printer> aPrt( maPController->getPrinter() );
@@ -1138,7 +1155,10 @@ void PrintDialog::updateNup( bool i_bMayUseCache )
mxNupOrder->setValues( aMPS.nOrder, nCols, nRows );
- preparePreview( i_bMayUseCache );
+ if (i_bMayUseCache)
+ maUpdatePreviewIdle.Start();
+ else
+ maUpdatePreviewNoCacheIdle.Start();
}
void PrintDialog::updateNupFromPages( bool i_bMayUseCache )
@@ -1794,7 +1814,7 @@ IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
}
else if ( &rButton == mxPreviewBox.get() )
{
- preparePreview( true );
+ maUpdatePreviewIdle.Start();
}
else if( &rButton == mxForwardBtn.get() )
{
@@ -1823,7 +1843,7 @@ IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
checkOptionalControlDependencies();
// update preview and page settings
- preparePreview(false);
+ maUpdatePreviewNoCacheIdle.Start();
}
if( mxBrochureBtn->get_active() )
{
@@ -1854,7 +1874,7 @@ IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
maPController->setReversePrint( bChecked );
maPController->setValue( "PrintReverse",
makeAny( bChecked ) );
- preparePreview( true );
+ maUpdatePreviewIdle.Start();
}
else if( &rButton == mxBorderCB.get() )
{
@@ -1894,7 +1914,7 @@ IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
setupPaperSidesBox();
// tdf#63905 don't use cache: page size may change
- preparePreview(false);
+ maUpdatePreviewNoCacheIdle.Start();
}
checkControlDependencies();
}
@@ -1918,7 +1938,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
mxOKButton->set_label(maPrintText);
updatePrinterText();
setPaperSizes();
- preparePreview(true);
+ maUpdatePreviewIdle.Start();
}
else // print to file
{
@@ -1929,7 +1949,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
setPaperSizes();
updateOrientationBox();
- preparePreview( true );
+ maUpdatePreviewIdle.Start();
}
setupPaperSidesBox();
@@ -1973,7 +1993,7 @@ IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
checkPaperSize( aPaperSize );
maPController->setPaperSizeFromUser( aPaperSize );
- preparePreview(true);
+ maUpdatePreviewIdle.Start();
}
}
@@ -2005,7 +2025,7 @@ IMPL_LINK_NOARG(PrintDialog, ActivateHdl, weld::Entry&, bool)
if (nNewCurPage != mnCurPage)
{
mnCurPage = nNewCurPage;
- preparePreview(true);
+ maUpdatePreviewIdle.Start();
}
return true;
}
@@ -2039,7 +2059,7 @@ IMPL_LINK( PrintDialog, UIOption_CheckHdl, weld::ToggleButton&, i_rBox, void )
checkOptionalControlDependencies();
// update preview and page settings
- preparePreview(false);
+ maUpdatePreviewNoCacheIdle.Start();
}
}
@@ -2070,7 +2090,7 @@ IMPL_LINK( PrintDialog, UIOption_RadioHdl, weld::ToggleButton&, i_rBtn, void )
mxPageRangeEdit->grab_focus();
// update preview and page settings
- preparePreview(false);
+ maUpdatePreviewNoCacheIdle.Start();
}
IMPL_LINK( PrintDialog, UIOption_SelectHdl, weld::ComboBox&, i_rBox, void )
@@ -2095,7 +2115,7 @@ IMPL_LINK( PrintDialog, UIOption_SelectHdl, weld::ComboBox&, i_rBox, void )
checkOptionalControlDependencies();
// update preview and page settings
- preparePreview(false);
+ maUpdatePreviewNoCacheIdle.Start();
}
IMPL_LINK( PrintDialog, UIOption_SpinModifyHdl, weld::SpinButton&, i_rBox, void )
@@ -2111,7 +2131,7 @@ IMPL_LINK( PrintDialog, UIOption_SpinModifyHdl, weld::SpinButton&, i_rBox, void
checkOptionalControlDependencies();
// update preview and page settings
- preparePreview(false);
+ maUpdatePreviewNoCacheIdle.Start();
}
}
@@ -2128,7 +2148,7 @@ IMPL_LINK( PrintDialog, UIOption_EntryModifyHdl, weld::Entry&, i_rBox, void )
checkOptionalControlDependencies();
// update preview and page settings
- preparePreview(false);
+ maUpdatePreviewNoCacheIdle.Start();
}
}