Qt: removed qt-4.3 workaround

git-svn-id: trunk@22869 -
This commit is contained in:
zeljko 2009-11-30 09:21:42 +00:00
parent 45f8f39a9e
commit 3a5dfa739f
2 changed files with 58 additions and 69 deletions

View File

@ -132,13 +132,6 @@ begin
RegisterComponents('Dialogs',[TPrinterSetupDialog,TPrintDialog,TPageSetupDialog]); RegisterComponents('Dialogs',[TPrinterSetupDialog,TPrintDialog,TPageSetupDialog]);
end; end;
initialization initialization
{$I printersdlgs.lrs} {$I printersdlgs.lrs}
{$IFDEF LCLQt}
finalization
if QtPrnDlg<>nil then
QPrintDialog_destroy(QtPrnDlg);
{$ENDIF}
end. end.

View File

@ -4,14 +4,6 @@
const const
SExecute = 'Execute'; SExecute = 'Execute';
{TODO: WE HAVE PROBLEM WITH QPrintDialog size (second call resizes it
to screen width) if QPrintDialog is
destroyed each time, so that's the reason why we have
QtPrnDlg variable and finalization in PrintersDlgs
This is probably qt 4.3 bug.}
var
QtPrnDlg: QPrintDialogH = nil;
{ TPageSetupDialog } { TPageSetupDialog }
function TPageSetupDialog.Execute: Boolean; function TPageSetupDialog.Execute: Boolean;
@ -52,6 +44,7 @@ end;
function TPrintDialog.Execute: Boolean; function TPrintDialog.Execute: Boolean;
var var
QtPrnDlg: QPrintDialogH;
PrnOptions: QAbstractPrintDialogPrintDialogOptions; PrnOptions: QAbstractPrintDialogPrintDialogOptions;
Str: WideString; Str: WideString;
i: Integer; i: Integer;
@ -61,73 +54,76 @@ begin
if not Assigned(Printer) then Exit; if not Assigned(Printer) then Exit;
if Printer.Printers.Count <= 0 then Exit; if Printer.Printers.Count <= 0 then Exit;
if QtPrnDlg = nil then QtPrnDlg := QPrintDialog_create(QtDefaultPrinter.Handle, nil);
QtPrnDlg := QPrintDialog_create(QtDefaultPrinter.Handle, nil); try
if Title <> '' then if Title <> '' then
Str := UTF8Decode(Title) Str := UTF8Decode(Title)
else else
Str := UTF8Decode(DefaultTitle); Str := UTF8Decode(DefaultTitle);
QWidget_setWindowTitle(QtPrnDlg, @Str); QWidget_setWindowTitle(QtPrnDlg, @Str);
if (Width > 0) and (Height > 0) then if (Width > 0) and (Height > 0) then
QWidget_setBaseSize(QtPrnDlg, Width, Height); QWidget_setBaseSize(QtPrnDlg, Width, Height);
{By default, full page printing is disabled. In this case, the origin of {By default, full page printing is disabled. In this case, the origin of
the QPrinter's coordinate system coincides with the top-left corner the QPrinter's coordinate system coincides with the top-left corner
of the printable area. If full page printing is enabled, the origin of of the printable area. If full page printing is enabled, the origin of
the QPrinter's coordinate system coincides with the top-left corner of the QPrinter's coordinate system coincides with the top-left corner of
the paper itself. In this case, the device metrics will report the the paper itself. In this case, the device metrics will report the
exact same dimensions as indicated by PageSize. It may not be exact same dimensions as indicated by PageSize. It may not be
possible to print on the entire physical page because of the printer's possible to print on the entire physical page because of the printer's
margins, so the application must account for the margins itself. margins, so the application must account for the margins itself.
We can set this property from QtLCL OsPrinters too. We can set this property from QtLCL OsPrinters too.
QtDefaultPrinter.FullPage := True; QtDefaultPrinter.FullPage := True;
THIS IS FIXED IN Qt-4.4, so PageRect returns correct dimensions !} THIS IS FIXED IN Qt-4.4, so PageRect returns correct dimensions !}
QAbstractPrintDialog_setMinMax(QtPrnDlg, MinPage, MaxPage); QAbstractPrintDialog_setMinMax(QtPrnDlg, MinPage, MaxPage);
QAbstractPrintDialog_setFromTo(QtPrnDlg, FromPage, ToPage); QAbstractPrintDialog_setFromTo(QtPrnDlg, FromPage, ToPage);
PrnOptions := QAbstractPrintDialogPrintCollateCopies PrnOptions := QAbstractPrintDialogPrintCollateCopies
or QAbstractPrintDialogPrintShowPageSize; or QAbstractPrintDialogPrintShowPageSize;
if (poPrintToFile in Options) then if (poPrintToFile in Options) then
PrnOptions := PrnOptions or QAbstractPrintDialogPrintToFile; PrnOptions := PrnOptions or QAbstractPrintDialogPrintToFile;
if (poSelection in Options) then if (poSelection in Options) then
PrnOptions := PrnOptions or QAbstractPrintDialogPrintSelection; PrnOptions := PrnOptions or QAbstractPrintDialogPrintSelection;
if (poPageNums) in Options then if (poPageNums) in Options then
PrnOptions := PrnOptions or QAbstractPrintDialogPrintPageRange; PrnOptions := PrnOptions or QAbstractPrintDialogPrintPageRange;
{this function does not have effect on Darwin} {this function does not have effect on Darwin}
QAbstractPrintDialog_setEnabledOptions(QtPrnDlg, PrnOptions); QAbstractPrintDialog_setEnabledOptions(QtPrnDlg, PrnOptions);
QtDefaultPrinter.numCopies := Copies; QtDefaultPrinter.numCopies := Copies;
if PrintToFile then if PrintToFile then
QtDefaultPrinter.OutputFormat := QPrinterPdfFormat; QtDefaultPrinter.OutputFormat := QPrinterPdfFormat;
Result := QPrintDialog_exec(QtPrnDlg) = Ord(QDialogAccepted); Result := QPrintDialog_exec(QtPrnDlg) = Ord(QDialogAccepted);
if Result then if Result then
begin begin
Collate := QtDefaultPrinter.Collate; Collate := QtDefaultPrinter.Collate;
MinPage := QAbstractPrintDialog_minPage(QtPrnDlg); MinPage := QAbstractPrintDialog_minPage(QtPrnDlg);
MaxPage := QAbstractPrintDialog_maxPage(QtPrnDlg); MaxPage := QAbstractPrintDialog_maxPage(QtPrnDlg);
FromPage := QtDefaultPrinter.fromPage; FromPage := QtDefaultPrinter.fromPage;
ToPage := QtDefaultPrinter.toPage; ToPage := QtDefaultPrinter.toPage;
PrintToFile := QtDefaultPrinter.OutputFormat <> QPrinterNativeFormat; PrintToFile := QtDefaultPrinter.OutputFormat <> QPrinterNativeFormat;
Copies := QtDefaultPrinter.numCopies; Copies := QtDefaultPrinter.numCopies;
case QtDefaultPrinter.PrintRange of case QtDefaultPrinter.PrintRange of
QPrinterAllPages: PrintRange := prAllPages; QPrinterAllPages: PrintRange := prAllPages;
QPrinterSelection: PrintRange := prSelection; QPrinterSelection: PrintRange := prSelection;
QPrinterPageRange: PrintRange := prPageNums; QPrinterPageRange: PrintRange := prPageNums;
else else
PrintRange := prCurrentPage; PrintRange := prCurrentPage;
end;
end; end;
finally
QPrintDialog_destroy(QtPrnDlg);
end; end;
end; end;