From e23a3f8dc133cba2e2a403c4719cd441a9460d6c Mon Sep 17 00:00:00 2001 From: bryanherger Date: Tue, 3 Jan 2017 21:54:32 -0500 Subject: [PATCH] 1.10.1 release Fixed issues with Slakware compile, PNG image creation, file dialog behavior --- xdrawchem-qt5/INSTALL.txt | 1 + xdrawchem-qt5/README.txt | 2 +- xdrawchem-qt5/SPECS/xdrawchem.spec | 2 +- xdrawchem-qt5/xdrawchem/application.cpp | 109 +------------------ xdrawchem-qt5/xdrawchem/application.h | 1 + xdrawchem-qt5/xdrawchem/application_ring.cpp | 1 + xdrawchem-qt5/xdrawchem/http.cpp | 6 +- xdrawchem-qt5/xdrawchem/myfiledialog.cpp | 3 + xdrawchem-qt5/xdrawchem/myfiledialog.h | 1 + xdrawchem-qt5/xdrawchem/render2d_draw.cpp | 16 ++- 10 files changed, 25 insertions(+), 117 deletions(-) diff --git a/xdrawchem-qt5/INSTALL.txt b/xdrawchem-qt5/INSTALL.txt index 0445c8e..d347d98 100644 --- a/xdrawchem-qt5/INSTALL.txt +++ b/xdrawchem-qt5/INSTALL.txt @@ -22,3 +22,4 @@ Enjoy! -- Bryan Herger bherger@users.sourceforge.net + diff --git a/xdrawchem-qt5/README.txt b/xdrawchem-qt5/README.txt index 8b7b574..aac1469 100644 --- a/xdrawchem-qt5/README.txt +++ b/xdrawchem-qt5/README.txt @@ -1,4 +1,4 @@ -Welcome to XDrawChem! (version 1.10.0) +Welcome to XDrawChem! (version 1.10.1) Mostly written by Bryan Herger, bherger@users.sourceforge.net See acknowledgements below for specific contributions. diff --git a/xdrawchem-qt5/SPECS/xdrawchem.spec b/xdrawchem-qt5/SPECS/xdrawchem.spec index decf40f..11bd21d 100644 --- a/xdrawchem-qt5/SPECS/xdrawchem.spec +++ b/xdrawchem-qt5/SPECS/xdrawchem.spec @@ -1,6 +1,6 @@ Summary: XDrawChem is an application for drawing and analyzing chemical structures and reactions. Name: xdrawchem -Version: 1.10.0 +Version: 1.10.1 Release: 1 License: GPL Group: Applications/Productivity diff --git a/xdrawchem-qt5/xdrawchem/application.cpp b/xdrawchem-qt5/xdrawchem/application.cpp index dc420f3..121ff6b 100644 --- a/xdrawchem-qt5/xdrawchem/application.cpp +++ b/xdrawchem-qt5/xdrawchem/application.cpp @@ -1461,64 +1461,11 @@ void ApplicationWindow::savePicture() return; } if ( pm != 0 ) { - // check for "convert" (ImageMagick) - bool imagemagick = false; - QString n1, cmd1; - - n1.setNum( getpid() ); - n1.prepend( "/tmp/" ); - cmd1 = "convert > " + n1; - system( cmd1.toLatin1() ); - -// QFile f1( n1 ); -// f1.open(QIODevice::ReadOnly); -// f1.readLine(cmd1, 256); - - QFile f1( n1 ); - - if ( !f1.open( QIODevice::ReadOnly | QIODevice::Text ) ) - return; - - QTextStream in( &f1 ); - - cmd1 = in.readLine(); - - if ( cmd1.contains( "ImageMagick" ) > 0 ) { - qDebug() << "ImageMagick is present"; - imagemagick = true; - } - - cmd1 = "rm " + n1; - system( cmd1.toLatin1() ); - - QPixmap tosave; - - // use "tosave" with ImageMagick to specify size - tosave = m_renderer->MakePixmap( fd.isTransparent() ); - QString sizehint; - - n1.setNum( tosave.width() ); - sizehint = n1; - sizehint.append( "x" ); - n1.setNum( tosave.height() ); - sizehint.append( n1 ); - if ( imagemagick ) { - n1 = selectedFile; - n1.append( ".eps" ); - m_renderer->SaveEPS( n1 ); - //cmd1 = "convert -antialias " + n1 + " " + selectedFile; - cmd1 = "convert -antialias -size " + sizehint + " " + n1 + " -resize " + sizehint + " " + selectedFile; - system( cmd1.toLatin1() ); - cmd1 = "rm " + n1; - system( cmd1.toLatin1() ); - was_saved = true; - } else { - tosave = m_renderer->MakePixmap( fd.isTransparent() ); + QPixmap tosave = m_renderer->MakePixmap( fd.isTransparent() ); if ( pm == 1 ) // PNG was_saved = tosave.save( selectedFile, "PNG" ); if ( pm == 2 ) // BMP was_saved = tosave.save( selectedFile, "BMP" ); - } if ( was_saved ) statusBar()->showMessage( tr( "Saved picture file " ) + selectedFile ); else @@ -1537,63 +1484,15 @@ void ApplicationWindow::savePNG() { bool was_saved; - // check for "convert" (ImageMagick) - bool imagemagick = false; - QString n1, cmd1; - - n1.setNum( getpid() ); - n1.prepend( "/tmp/" ); - cmd1 = "convert > " + n1; - system( cmd1.toLatin1() ); - -// QFile f1( n1 ); -// f1.open(QIODevice::ReadOnly); -// f1.readLine(cmd1, 256); - - QFile f1( n1 ); - - if ( !f1.open( QIODevice::ReadOnly | QIODevice::Text ) ) - return; - - QTextStream in( &f1 ); - - cmd1 = in.readLine(); - - if ( cmd1.contains( "ImageMagick" ) > 0 ) { - qDebug() << "ImageMagick is present"; - imagemagick = true; - } - - cmd1 = "rm " + n1; - system( cmd1.toLatin1() ); - QPixmap tosave; tosave = m_renderer->MakePixmap( ni_tflag ); - QString sizehint; - - n1.setNum( tosave.width() ); - sizehint = n1; - sizehint.append( "x" ); - n1.setNum( tosave.height() ); - sizehint.append( n1 ); - if ( imagemagick ) { - n1 = ni_savefile; - n1.append( ".eps" ); - m_renderer->SaveEPS( n1 ); - cmd1 = "convert -antialias -size " + sizehint + " " + n1 + " -resize " + sizehint + " " + ni_savefile; - system( cmd1.toLatin1() ); - cmd1 = "rm " + n1; - system( cmd1.toLatin1() ); - was_saved = true; - } else { was_saved = tosave.save( ni_savefile, "PNG" ); - } - //QPixmap tosave = m_renderer->MakePixmap( ni_tflag ); //was_saved = tosave.save(ni_savefile, "PNG"); - if ( was_saved == false ) - qDebug() << "save PNG failed"; + if ( was_saved == false ) { + qWarning() << "save PNG failed for " << ni_savefile; + } close(); // this function is only used in non-interactive mode } diff --git a/xdrawchem-qt5/xdrawchem/application.h b/xdrawchem-qt5/xdrawchem/application.h index c2e33ff..1a4f29b 100644 --- a/xdrawchem-qt5/xdrawchem/application.h +++ b/xdrawchem-qt5/xdrawchem/application.h @@ -11,6 +11,7 @@ #ifndef APPLICATION_H #define APPLICATION_H +#include #include #include #include diff --git a/xdrawchem-qt5/xdrawchem/application_ring.cpp b/xdrawchem-qt5/xdrawchem/application_ring.cpp index 7f303af..21e1b36 100644 --- a/xdrawchem-qt5/xdrawchem/application_ring.cpp +++ b/xdrawchem-qt5/xdrawchem/application_ring.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include "application.h" diff --git a/xdrawchem-qt5/xdrawchem/http.cpp b/xdrawchem-qt5/xdrawchem/http.cpp index cdb0310..a9429ef 100644 --- a/xdrawchem-qt5/xdrawchem/http.cpp +++ b/xdrawchem-qt5/xdrawchem/http.cpp @@ -22,10 +22,6 @@ connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), #ifndef QT_NO_SSL connect(reply, SIGNAL(sslErrors(QList)), SLOT(sslErrors(QList))); #endif -//while (!reply->isFinished()) { -//qDebug() << "isRunning: " << reply->isRunning() << "isFinished: " << reply->isFinished(); -//sleep(1); -//} } void HTTP::slotError(const QNetworkReply::NetworkError e) @@ -50,7 +46,7 @@ void HTTP::execute(QString xurl) { QUrl url = QUrl::fromUserInput(xurl); doDownload(url); - while (!finished) { qDebug() << "Waiting..."; sleep(1); } + while (!finished) { qDebug() << "Waiting..."; } } void HTTP::sslErrors(const QList &sslErrors) diff --git a/xdrawchem-qt5/xdrawchem/myfiledialog.cpp b/xdrawchem-qt5/xdrawchem/myfiledialog.cpp index 393b382..3d06a4f 100644 --- a/xdrawchem-qt5/xdrawchem/myfiledialog.cpp +++ b/xdrawchem-qt5/xdrawchem/myfiledialog.cpp @@ -1,3 +1,4 @@ +#include #include #include "myfiledialog.h" @@ -5,6 +6,8 @@ MyFileDialog::MyFileDialog( QWidget *parent ) : QFileDialog( parent ) { + setOption( QFileDialog::DontUseNativeDialog, true ); + setAcceptMode( QFileDialog::AcceptSave ); trans_toggle = new QCheckBox( tr( "Transparent" ), this ); trans_toggle->setChecked( false ); layout()->addWidget( trans_toggle ); ///TODO: place diff --git a/xdrawchem-qt5/xdrawchem/myfiledialog.h b/xdrawchem-qt5/xdrawchem/myfiledialog.h index 65229d4..3b654ff 100644 --- a/xdrawchem-qt5/xdrawchem/myfiledialog.h +++ b/xdrawchem-qt5/xdrawchem/myfiledialog.h @@ -6,6 +6,7 @@ class MyFileDialog : public QFileDialog { + Q_OBJECT public: MyFileDialog( QWidget *parent ); bool isTransparent(); diff --git a/xdrawchem-qt5/xdrawchem/render2d_draw.cpp b/xdrawchem-qt5/xdrawchem/render2d_draw.cpp index bd360c5..9c69586 100644 --- a/xdrawchem-qt5/xdrawchem/render2d_draw.cpp +++ b/xdrawchem-qt5/xdrawchem/render2d_draw.cpp @@ -1123,16 +1123,21 @@ QPixmap Render2D::MakePixmap( bool transp ) update(); r.setTopLeft( zoomCorrect( r.topLeft() ) ); r.setBottomRight( zoomCorrect( r.bottomRight() ) ); + + // hack to avoid cropping text + r.adjust( -10, -10, 10, 10 ); + QPixmap pm( r.size() ); qDebug() << "X1:" << r.left() << " Y1:" << r.top(); qDebug() << "W:" << r.width() << " H:" << r.height(); - while ( !finishedPainting ) { - qDebug() << "Waiting..."; - } - pm = QPixmap::grabWidget( this, r.left(), r.top(), r.width(), r.height() ); + //while ( !finishedPainting ) { + // qInfo() << "Waiting..."; + //} //bitBlt( &pm, 0, 0, this, r.left(), r.top(), r.width(), r.height() ); + // deprecated: pm = QPixmap::grabWidget( this, r.left(), r.top(), r.width(), r.height() ); + pm = grab( r ); pm = pm.scaled( finalsize.width(), finalsize.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation ); @@ -1169,7 +1174,8 @@ QPixmap Render2D::MakeFullPixmap() update(); QPixmap pm( size() ); - pm = QPixmap::grabWidget( this, rect() ); + // deprecated: pm = QPixmap::grabWidget( this, rect() ); + pm = grab( rect() ); return pm; }