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;
@ -60,74 +53,77 @@ 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);
if Title <> '' then QtPrnDlg := QPrintDialog_create(QtDefaultPrinter.Handle, nil);
Str := UTF8Decode(Title) try
else
Str := UTF8Decode(DefaultTitle);
QWidget_setWindowTitle(QtPrnDlg, @Str); if Title <> '' then
Str := UTF8Decode(Title)
if (Width > 0) and (Height > 0) then else
QWidget_setBaseSize(QtPrnDlg, Width, Height); Str := UTF8Decode(DefaultTitle);
{By default, full page printing is disabled. In this case, the origin of QWidget_setWindowTitle(QtPrnDlg, @Str);
the QPrinter's coordinate system coincides with the top-left corner
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 paper itself. In this case, the device metrics will report the
exact same dimensions as indicated by PageSize. It may not be
possible to print on the entire physical page because of the printer's
margins, so the application must account for the margins itself.
We can set this property from QtLCL OsPrinters too.
QtDefaultPrinter.FullPage := True;
THIS IS FIXED IN Qt-4.4, so PageRect returns correct dimensions !}
QAbstractPrintDialog_setMinMax(QtPrnDlg, MinPage, MaxPage); if (Width > 0) and (Height > 0) then
QAbstractPrintDialog_setFromTo(QtPrnDlg, FromPage, ToPage); QWidget_setBaseSize(QtPrnDlg, Width, Height);
PrnOptions := QAbstractPrintDialogPrintCollateCopies {By default, full page printing is disabled. In this case, the origin of
or QAbstractPrintDialogPrintShowPageSize; the QPrinter's coordinate system coincides with the top-left corner
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 paper itself. In this case, the device metrics will report the
exact same dimensions as indicated by PageSize. It may not be
possible to print on the entire physical page because of the printer's
margins, so the application must account for the margins itself.
We can set this property from QtLCL OsPrinters too.
QtDefaultPrinter.FullPage := True;
THIS IS FIXED IN Qt-4.4, so PageRect returns correct dimensions !}
if (poPrintToFile in Options) then QAbstractPrintDialog_setMinMax(QtPrnDlg, MinPage, MaxPage);
PrnOptions := PrnOptions or QAbstractPrintDialogPrintToFile; QAbstractPrintDialog_setFromTo(QtPrnDlg, FromPage, ToPage);
if (poSelection in Options) then PrnOptions := QAbstractPrintDialogPrintCollateCopies
PrnOptions := PrnOptions or QAbstractPrintDialogPrintSelection; or QAbstractPrintDialogPrintShowPageSize;
if (poPageNums) in Options then if (poPrintToFile in Options) then
PrnOptions := PrnOptions or QAbstractPrintDialogPrintPageRange; PrnOptions := PrnOptions or QAbstractPrintDialogPrintToFile;
{this function does not have effect on Darwin} if (poSelection in Options) then
QAbstractPrintDialog_setEnabledOptions(QtPrnDlg, PrnOptions); PrnOptions := PrnOptions or QAbstractPrintDialogPrintSelection;
QtDefaultPrinter.numCopies := Copies; if (poPageNums) in Options then
PrnOptions := PrnOptions or QAbstractPrintDialogPrintPageRange;
if PrintToFile then {this function does not have effect on Darwin}
QtDefaultPrinter.OutputFormat := QPrinterPdfFormat; QAbstractPrintDialog_setEnabledOptions(QtPrnDlg, PrnOptions);
Result := QPrintDialog_exec(QtPrnDlg) = Ord(QDialogAccepted); QtDefaultPrinter.numCopies := Copies;
if Result then if PrintToFile then
begin QtDefaultPrinter.OutputFormat := QPrinterPdfFormat;
Collate := QtDefaultPrinter.Collate;
MinPage := QAbstractPrintDialog_minPage(QtPrnDlg); Result := QPrintDialog_exec(QtPrnDlg) = Ord(QDialogAccepted);
MaxPage := QAbstractPrintDialog_maxPage(QtPrnDlg);
FromPage := QtDefaultPrinter.fromPage; if Result then
ToPage := QtDefaultPrinter.toPage; begin
PrintToFile := QtDefaultPrinter.OutputFormat <> QPrinterNativeFormat; Collate := QtDefaultPrinter.Collate;
Copies := QtDefaultPrinter.numCopies; MinPage := QAbstractPrintDialog_minPage(QtPrnDlg);
MaxPage := QAbstractPrintDialog_maxPage(QtPrnDlg);
case QtDefaultPrinter.PrintRange of FromPage := QtDefaultPrinter.fromPage;
QPrinterAllPages: PrintRange := prAllPages; ToPage := QtDefaultPrinter.toPage;
QPrinterSelection: PrintRange := prSelection; PrintToFile := QtDefaultPrinter.OutputFormat <> QPrinterNativeFormat;
QPrinterPageRange: PrintRange := prPageNums; Copies := QtDefaultPrinter.numCopies;
else
PrintRange := prCurrentPage; case QtDefaultPrinter.PrintRange of
QPrinterAllPages: PrintRange := prAllPages;
QPrinterSelection: PrintRange := prSelection;
QPrinterPageRange: PrintRange := prPageNums;
else
PrintRange := prCurrentPage;
end;
end; end;
finally
QPrintDialog_destroy(QtPrnDlg);
end; end;
end; end;