[qet] [3746] port to Qt5 : print to post script is disabled (Qt don' t support anymore post script) |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 3746
Author: blacksun
Date: 2015-02-21 20:48:31 +0100 (Sat, 21 Feb 2015)
Log Message:
-----------
port to Qt5 : print to post script is disabled (Qt don't support anymore post script)
Modified Paths:
--------------
branches/Qt5/qelectrotech.pro
branches/Qt5/sources/bordertitleblock.cpp
branches/Qt5/sources/diagram.cpp
branches/Qt5/sources/diagramprintdialog.cpp
branches/Qt5/sources/diagramprintdialog.h
branches/Qt5/sources/diagramview.cpp
branches/Qt5/sources/elementscollectioncache.cpp
branches/Qt5/sources/elementspanel.cpp
branches/Qt5/sources/elementspanelwidget.cpp
branches/Qt5/sources/exportproperties.cpp
branches/Qt5/sources/qetapp.cpp
branches/Qt5/sources/qetapp.h
branches/Qt5/sources/qetdiagrameditor.cpp
branches/Qt5/sources/qetprintpreviewdialog.cpp
branches/Qt5/sources/qetprintpreviewdialog.h
branches/Qt5/sources/qetproject.cpp
Modified: branches/Qt5/qelectrotech.pro
===================================================================
--- branches/Qt5/qelectrotech.pro 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/qelectrotech.pro 2015-02-21 19:48:31 UTC (rev 3746)
@@ -103,7 +103,7 @@
TRANSLATIONS += lang/qet_en.ts lang/qet_es.ts lang/qet_fr.ts lang/qet_ru.ts lang/qet_pt.ts lang/qet_cs.ts lang/qet_pl.ts lang/qet_de.ts lang/qet_ro.ts lang/qet_it.ts lang/qet_el.ts lang/qet_nl.ts lang/qet_be.ts
# Modules Qt utilises par l'application
-QT += xml svg network sql widgets
+QT += xml svg network sql widgets printsupport
# UI DESIGNER FILES AND GENERATION SOURCES FILES
FORMS += $$files(sources/richtext/*.ui) \
Modified: branches/Qt5/sources/bordertitleblock.cpp
===================================================================
--- branches/Qt5/sources/bordertitleblock.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/bordertitleblock.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -680,7 +680,7 @@
QChar last_digit(string.at(string.count() - 1));
if (last_digit != 'Z') {
// incremente le dernier digit
- last_digit = last_digit.toAscii() + 1;
+ last_digit = last_digit.toLatin1() + 1;
return(first_digits + QString(last_digit));
} else {
return(incrementLetters(first_digits) + "A");
Modified: branches/Qt5/sources/diagram.cpp
===================================================================
--- branches/Qt5/sources/diagram.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/diagram.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -59,7 +59,7 @@
setProject(project);
qgi_manager_ = new QGIManager(this);
setBackgroundBrush(Qt::white);
- conductor_setter_ = new QGraphicsLineItem(0, 0);
+ conductor_setter_ = new QGraphicsLineItem(0);
conductor_setter_ -> setZValue(1000000);
QPen t;
t.setColor(Qt::black);
Modified: branches/Qt5/sources/diagramprintdialog.cpp
===================================================================
--- branches/Qt5/sources/diagramprintdialog.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/diagramprintdialog.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -24,6 +24,9 @@
#include "qeticons.h"
#include "qetmessagebox.h"
+#include <QPrinter>
+#include <QPrintDialog>
+
/**
Constructeur
@param project Schema a imprimer
@@ -125,13 +128,19 @@
print_dialog.setWindowTitle(tr("Options d'impression", "window title"));
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintShowPageSize);
if (print_dialog.exec() == QDialog::Rejected) return;
- } else if (pdf_choice_ -> isChecked()) {
+ }
+ else
+ {
printer_ -> setOutputFormat(QPrinter::PdfFormat);
printer_ -> setOutputFileName(filepath_field_ -> text());
- } else {
- printer_ -> setOutputFormat(QPrinter::PostScriptFormat);
- printer_ -> setOutputFileName(filepath_field_ -> text());
}
+ //@TODO remove code below
+ //post script isn't suported anymore in Qt5
+// else
+// {
+// printer_ -> setOutputFormat(QPrinter::PostScriptFormat);
+// printer_ -> setOutputFileName(filepath_field_ -> text());
+// }
loadPageSetupForCurrentPrinter();
// Apercu avant impression
@@ -609,8 +618,10 @@
return(printer -> printerName().replace(" ", "_"));
} else if (printer_format == QPrinter::PdfFormat) {
return("QET_PDF_Printing");
- } else if (printer_format == QPrinter::PostScriptFormat) {
- return("QET_PS_Printing");
}
+ //@TODO remove code below
+// else if (printer_format == QPrinter::PostScriptFormat) {
+// return("QET_PS_Printing");
+// }
return(QString());
}
Modified: branches/Qt5/sources/diagramprintdialog.h
===================================================================
--- branches/Qt5/sources/diagramprintdialog.h 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/diagramprintdialog.h 2015-02-21 19:48:31 UTC (rev 3746)
@@ -18,9 +18,13 @@
#ifndef DIAGRAM_PRINT_DIALOG_H
#define DIAGRAM_PRINT_DIALOG_H
#include <QtWidgets>
+
#include "qetproject.h"
#include "diagram.h"
#include "exportproperties.h"
+
+class QPrinter;
+
/**
This class implements both the dialog allowing users to configure the printing
of a project file and the printing itself.
Modified: branches/Qt5/sources/diagramview.cpp
===================================================================
--- branches/Qt5/sources/diagramview.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/diagramview.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -1115,7 +1115,7 @@
@param e Evenement decrivant la demande de menu contextuel
*/
void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
- if (QGraphicsItem *qgi = scene -> itemAt(mapToScene(e -> pos()))) {
+ if (QGraphicsItem *qgi = scene -> itemAt(mapToScene(e -> pos()), transform())) {
if (!qgi -> isSelected()) scene -> clearSelection();
qgi -> setSelected(true);
}
Modified: branches/Qt5/sources/elementscollectioncache.cpp
===================================================================
--- branches/Qt5/sources/elementscollectioncache.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/elementscollectioncache.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -96,7 +96,7 @@
@return True if the format change was accepted, false otherwise.
*/
bool ElementsCollectionCache::setPixmapStorageFormat(const QString &format) {
- if (QImageWriter::supportedImageFormats().contains(format.toAscii())) {
+ if (QImageWriter::supportedImageFormats().contains(format.toLatin1())) {
pixmap_storage_format_= format;
return(true);
}
Modified: branches/Qt5/sources/elementspanel.cpp
===================================================================
--- branches/Qt5/sources/elementspanel.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/elementspanel.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -287,10 +287,10 @@
mimeData -> setText(location_string);
if (selected_item -> isCategory() || selected_item -> isCollection()) {
- mimeData -> setData("application/x-qet-category-uri", location_string.toAscii());
+ mimeData -> setData("application/x-qet-category-uri", location_string.toLatin1());
drag -> setPixmap(QET::Icons::Folder.pixmap(22, 22));
} else if (selected_item -> isElement()) {
- mimeData -> setData("application/x-qet-element-uri", location_string.toAscii());
+ mimeData -> setData("application/x-qet-element-uri", location_string.toLatin1());
// element temporaire pour fournir un apercu
int elmt_creation_state;
@@ -335,7 +335,7 @@
QMimeData *mime_data = new QMimeData();
mime_data -> setText(location_string);
- mime_data -> setData("application/x-qet-titleblock-uri", location_string.toAscii());
+ mime_data -> setData("application/x-qet-titleblock-uri", location_string.toLatin1());
QDrag *drag = new QDrag(this);
drag -> setMimeData(mime_data);
Modified: branches/Qt5/sources/elementspanelwidget.cpp
===================================================================
--- branches/Qt5/sources/elementspanelwidget.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/elementspanelwidget.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -92,12 +92,13 @@
filter_toolbar -> addWidget(filter_label);
filter_toolbar -> addWidget(filter_textfield);
+ //@TODO remove the commented code below
// ajoute une petite marge a la droite du champ pour filtrer lorsque le style CleanLooks est utilise
- if (qobject_cast<QCleanlooksStyle *>(QApplication::style())) {
- int l, t, r, b;
- filter_toolbar -> getContentsMargins(&l, &t, &r, &b);
- filter_toolbar -> setContentsMargins (l, t, r + 4, b);
- }
+// if (qobject_cast<QCleanlooksStyle *>(QApplication::style())) {
+// int l, t, r, b;
+// filter_toolbar -> getContentsMargins(&l, &t, &r, &b);
+// filter_toolbar -> setContentsMargins (l, t, r + 4, b);
+// }
context_menu = new QMenu(this);
Modified: branches/Qt5/sources/exportproperties.cpp
===================================================================
--- branches/Qt5/sources/exportproperties.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/exportproperties.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -16,9 +16,10 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "exportproperties.h"
-#include <QDesktopServices>
#include "qetapp.h"
+#include <QStandardPaths>
+
/**
Constructeur par defaut :
* le repertoire de destination est le Bureau de l'utilisateur
@@ -28,7 +29,7 @@
* la zone exportee est le schema avec son cadre et son cartouche
*/
ExportProperties::ExportProperties() :
- destination_directory(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)),
+ destination_directory(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)),
format("PNG"),
draw_grid(false),
draw_border(true),
@@ -67,7 +68,7 @@
@param prefix prefixe a ajouter devant les noms des parametres
*/
void ExportProperties::fromSettings(QSettings &settings, const QString &prefix) {
- QString desktop_path = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
+ QString desktop_path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
destination_directory.setPath(settings.value(prefix + "path", desktop_path).toString());
if (!destination_directory.exists()) destination_directory.setPath(desktop_path);
Modified: branches/Qt5/sources/qetapp.cpp
===================================================================
--- branches/Qt5/sources/qetapp.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/qetapp.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -1373,12 +1373,13 @@
*/
void QETApp::initStyle() {
initial_palette_ = palette();
+
+ //@TODO remove the code below
+// // lorsque le style Plastique est active, on le remplace par une version amelioree
+// if (qobject_cast<QPlastiqueStyle *>(style())) {
+// setStyle(new QETStyle());
+// }
- // lorsque le style Plastique est active, on le remplace par une version amelioree
- if (qobject_cast<QPlastiqueStyle *>(style())) {
- setStyle(new QETStyle());
- }
-
// applique ou non les couleurs de l'environnement
useSystemPalette(settings().value("usesystemcolors", true).toBool());
}
@@ -1637,50 +1638,51 @@
std::cout << qPrintable(QET::license()) << std::endl;
}
-/// Constructeur
-QETStyle::QETStyle() : QPlastiqueStyle() {
-}
+//@TODO remove code below
+///// Constructeur
+//QETStyle::QETStyle() : QPlastiqueStyle() {
+//}
-/// Destructeur
-QETStyle::~QETStyle() {
-}
+///// Destructeur
+//QETStyle::~QETStyle() {
+//}
-/// Gere les parametres de style
-int QETStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returndata) const {
- if (hint == QStyle::SH_DialogButtonBox_ButtonsHaveIcons) {
- return(int(true));
- } else {
- return(QPlastiqueStyle::styleHint(hint, option, widget, returndata));
- }
-}
+///// Gere les parametres de style
+//int QETStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returndata) const {
+// if (hint == QStyle::SH_DialogButtonBox_ButtonsHaveIcons) {
+// return(int(true));
+// } else {
+// return(QPlastiqueStyle::styleHint(hint, option, widget, returndata));
+// }
+//}
-/// Gere les icones standard
-QIcon QETStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget* widget) const {
- switch(standardIcon) {
- case QStyle::SP_DialogSaveButton:
- return(QET::Icons::DocumentSave);
- case QStyle::SP_DialogOpenButton:
- return(QET::Icons::DocumentOpen);
- case QStyle::SP_DialogCancelButton:
- return(QET::Icons::DialogCancel);
- case QStyle::SP_DialogOkButton:
- case QStyle::SP_DialogApplyButton:
- return(QET::Icons::DialogOk);
- case QStyle::SP_DialogCloseButton:
- return(QET::Icons::DocumentClose);
- case QStyle::SP_DialogYesButton:
- return(QET::Icons::Allowed);
- case QStyle::SP_DialogNoButton:
- return(QET::Icons::Forbidden);
- case QStyle::SP_DialogResetButton:
- return(QET::Icons::EditUndo);
- case QStyle::SP_DialogHelpButton:
- case QStyle::SP_DialogDiscardButton:
- return(QIcon());
- default:
- return(QPlastiqueStyle::standardIconImplementation(standardIcon, option, widget));
- }
-}
+///// Gere les icones standard
+//QIcon QETStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget* widget) const {
+// switch(standardIcon) {
+// case QStyle::SP_DialogSaveButton:
+// return(QET::Icons::DocumentSave);
+// case QStyle::SP_DialogOpenButton:
+// return(QET::Icons::DocumentOpen);
+// case QStyle::SP_DialogCancelButton:
+// return(QET::Icons::DialogCancel);
+// case QStyle::SP_DialogOkButton:
+// case QStyle::SP_DialogApplyButton:
+// return(QET::Icons::DialogOk);
+// case QStyle::SP_DialogCloseButton:
+// return(QET::Icons::DocumentClose);
+// case QStyle::SP_DialogYesButton:
+// return(QET::Icons::Allowed);
+// case QStyle::SP_DialogNoButton:
+// return(QET::Icons::Forbidden);
+// case QStyle::SP_DialogResetButton:
+// return(QET::Icons::EditUndo);
+// case QStyle::SP_DialogHelpButton:
+// case QStyle::SP_DialogDiscardButton:
+// return(QIcon());
+// default:
+// return(QPlastiqueStyle::standardIconImplementation(standardIcon, option, widget));
+// }
+//}
/// @return une reference vers les parametres de QElectroTEch
QSettings &QETApp::settings() {
Modified: branches/Qt5/sources/qetapp.h
===================================================================
--- branches/Qt5/sources/qetapp.h 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/qetapp.h 2015-02-21 19:48:31 UTC (rev 3746)
@@ -236,18 +236,19 @@
static QETProject *projectFromString(const QString &);
};
-/**
- This class represents the custom QElectroTech style.
- It implements simple modification such as extra standard icons.
-*/
-class QETStyle : public QPlastiqueStyle {
- Q_OBJECT
- public:
- QETStyle();
- virtual ~QETStyle();
- virtual int styleHint(StyleHint hint, const QStyleOption * = 0, const QWidget * = 0, QStyleHintReturn * = 0) const;
+//TODO remove code below
+///**
+// This class represents the custom QElectroTech style.
+// It implements simple modification such as extra standard icons.
+//*/
+//class QETStyle : public QPlastiqueStyle {
+// Q_OBJECT
+// public:
+// QETStyle();
+// virtual ~QETStyle();
+// virtual int styleHint(StyleHint hint, const QStyleOption * = 0, const QWidget * = 0, QStyleHintReturn * = 0) const;
- protected slots:
- virtual QIcon standardIconImplementation(StandardPixmap, const QStyleOption * = 0, const QWidget * = 0) const;
-};
+// protected slots:
+// virtual QIcon standardIconImplementation(StandardPixmap, const QStyleOption * = 0, const QWidget * = 0) const;
+//};
#endif
Modified: branches/Qt5/sources/qetdiagrameditor.cpp
===================================================================
--- branches/Qt5/sources/qetdiagrameditor.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/qetdiagrameditor.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -43,6 +43,7 @@
#include "ui/dialogautonum.h"
#include <QMessageBox>
+#include <QStandardPaths>
/**
@@ -59,7 +60,7 @@
m_selection_actions_group (this),
m_row_column_actions_group (this),
m_file_actions_group (this),
- open_dialog_dir (QDesktopServices::storageLocation(QDesktopServices::DesktopLocation))
+ open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
{
//Setup the mdi area at center of application
setCentralWidget(&workspace);
Modified: branches/Qt5/sources/qetprintpreviewdialog.cpp
===================================================================
--- branches/Qt5/sources/qetprintpreviewdialog.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/qetprintpreviewdialog.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -21,6 +21,8 @@
#include "exportpropertieswidget.h"
#include "qeticons.h"
+#include <QPrintPreviewWidget>
+
/**
Constructeur
@param project Projet a imprimer
Modified: branches/Qt5/sources/qetprintpreviewdialog.h
===================================================================
--- branches/Qt5/sources/qetprintpreviewdialog.h 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/qetprintpreviewdialog.h 2015-02-21 19:48:31 UTC (rev 3746)
@@ -19,10 +19,14 @@
#define QET_PRINT_PREVIEW_DIALOG
#include <QtWidgets>
#include "exportproperties.h"
+
class Diagram;
class DiagramsChooser;
class ExportPropertiesWidget;
class QETProject;
+class QPrintPreviewWidget;
+class QPrinter;
+
/**
This class provides a dialog for users to refine printing options for a
particular project by relying on a visual print preview.
Modified: branches/Qt5/sources/qetproject.cpp
===================================================================
--- branches/Qt5/sources/qetproject.cpp 2015-02-21 17:41:47 UTC (rev 3745)
+++ branches/Qt5/sources/qetproject.cpp 2015-02-21 19:48:31 UTC (rev 3746)
@@ -32,6 +32,8 @@
#include "numerotationcontext.h"
#include "reportproperties.h"
+#include <QStandardPaths>
+
QString QETProject::integration_category_name = "import";
/**
@@ -255,7 +257,7 @@
QString QETProject::currentDir() const {
QString current_directory;
if (file_path_.isEmpty()) {
- current_directory = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
+ current_directory = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
} else {
current_directory = QFileInfo(file_path_).absoluteDir().absolutePath();
}