File indexing completed on 2022-11-23 10:29:25

0001 /*
0002  *  This file is part of the KDE libraries
0003  *  Copyright (c) 2013 Martin Klapetek <mklapetek@kde.org>
0004  *
0005  *  This library is free software; you can redistribute it and/or
0006  *  modify it under the terms of the GNU Library General Public
0007  *  License as published by the Free Software Foundation; either
0008  *  version 2 of the License, or (at your option) any later version.
0009  *
0010  *  This library is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  *  Library General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU Library General Public License
0016  *  along with this library; see the file COPYING.LIB.  If not, write to
0017  *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  *  Boston, MA 02110-1301, USA.
0019  **/
0020 
0021 #include <QApplication>
0022 #include <QTest>
0023 #include <QPrinter>
0024 #include <QPainter>
0025 
0026 #include "kprintpreview.h"
0027 
0028 int main(int argc, char **argv)
0029 {
0030     QApplication::setApplicationName(QStringLiteral("kprintpreview_text"));
0031     QApplication app(argc, argv);
0032 
0033     QPrinter printer;
0034     KPrintPreview *preview = new KPrintPreview(&printer);
0035 
0036     QPainter painter;
0037     painter.begin(&printer);
0038     // please don't use QStringLiteral since it can't be used with a concatenated string parameter on all platforms
0039     painter.drawText(printer.pageRect(), QLatin1String("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
0040                      "Nam malesuada massa dolor, sed sollicitudin turpis congue eu. Pellentesque ac risus felis. Etiam scelerisque "
0041                      "leo vitae mauris condimentum malesuada. Praesent tortor neque, egestas non elit vitae, accumsan mattis augue. "
0042                      "Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque ligula ligula, convallis ac felis in, "
0043                      "tincidunt pulvinar magna. Maecenas eu congue ipsum. Donec laoreet vulputate lorem, fermentum consectetur orci. "
0044                      "Suspendisse sed mauris sit amet mauris molestie ullamcorper. Vivamus aliquet consectetur est sit amet fringilla. "
0045                      "Nunc cursus risus velit, tempus imperdiet sapien tristique non. Pellentesque leo sapien, blandit et turpis eu, "
0046                      "placerat placerat odio. Vestibulum auctor nulla ut felis venenatis, eleifend venenatis quam feugiat."
0047 
0048                      "Duis magna enim, dignissim et convallis quis, ultrices quis nisi. Nulla nec rutrum tellus. Nunc in commodo orci. "
0049                      "Praesent tincidunt sem consequat neque tincidunt ullamcorper. Pellentesque sit amet dui vitae lectus fermentum "
0050                      "dignissim vel vel justo. Donec nec felis venenatis, hendrerit nunc vitae, iaculis leo. Duis vel purus pharetra, "
0051                      "laoreet nisl non, ultricies mauris. Etiam adipiscing eget magna quis bibendum."
0052 
0053                      "Curabitur felis nunc, lobortis nec tincidunt commodo, tempor id libero. Nulla sit amet ultrices erat. "
0054                      "Suspendisse tempus lorem lacus, a fermentum sem euismod vitae. Proin sed adipiscing leo, sit amet "
0055                      "vestibulum eros. Proin faucibus ut ante id facilisis. Nunc cursus ut purus sed ullamcorper. Donec "
0056                      "turpis risus, pretium sed dui sed, accumsan dictum arcu. Vestibulum cursus sit amet enim ac vestibulum. "
0057                      "Proin eget commodo enim. Nullam eu lacus nulla. Suspendisse malesuada tempor nulla, ac ullamcorper arcu. "
0058                      "Nunc facilisis laoreet fringilla. Aliquam bibendum lacinia quam in ultrices. Donec non iaculis augue. "
0059                      "Duis semper rhoncus arcu. Curabitur faucibus consectetur ultricies."));
0060 
0061     painter.end();
0062 
0063     preview->resize(600, 600);
0064     preview->show();
0065 
0066     return app.exec();
0067 }