[Libreoffice-commits] core.git: vcl/inc vcl/source
Samuel Mehrbrodt (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 6 06:02:38 UTC 2020
vcl/inc/printdlg.hxx | 6 +++++
vcl/source/window/printdlg.cxx | 48 +++++++++++++++++++++++++++++------------
2 files changed, 40 insertions(+), 14 deletions(-)
New commits:
commit 93c833e848a4406f36bcb7925928554bb104aa32
Author: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Mon Oct 5 11:09:20 2020 +0200
Commit: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Tue Oct 6 08:01:55 2020 +0200
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 at cib.de>
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 7c6c1005fd12..3e337057d042 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -22,6 +22,7 @@
#include <vcl/bitmapex.hxx>
#include <vcl/gdimtf.hxx>
+#include <vcl/idle.hxx>
#include <vcl/print.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
@@ -222,6 +223,11 @@ namespace vcl
Paper mePaper;
+ Idle maUpdatePreviewIdle;
+ DECL_LINK(updatePreviewIdle, Timer*, void);
+ Idle maUpdatePreviewNoCacheIdle;
+ DECL_LINK(updatePreviewNoCacheIdle, Timer*, void);
+
DECL_LINK( ClickHdl, weld::Button&, void );
DECL_LINK( SelectHdl, weld::ComboBox&, void );
DECL_LINK( ActivateHdl, weld::Entry&, bool );
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();
}
}
More information about the Libreoffice-commits
mailing list