Skip to content

Commit

Permalink
1.10.1 release
Browse files Browse the repository at this point in the history
Fixed issues with Slakware compile, PNG image creation, file dialog
behavior
  • Loading branch information
bryanherger committed Jan 4, 2017
1 parent 98e4cc2 commit e23a3f8
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 117 deletions.
1 change: 1 addition & 0 deletions xdrawchem-qt5/INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ Enjoy!
-- Bryan Herger
bherger@users.sourceforge.net


2 changes: 1 addition & 1 deletion xdrawchem-qt5/README.txt
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion xdrawchem-qt5/SPECS/xdrawchem.spec
Original file line number Diff line number Diff line change
@@ -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
Expand Down
109 changes: 4 additions & 105 deletions xdrawchem-qt5/xdrawchem/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions xdrawchem-qt5/xdrawchem/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifndef APPLICATION_H
#define APPLICATION_H

#include <QtGlobal>
#include <QString>
#include <QLabel>
#include <QMenu>
Expand Down
1 change: 1 addition & 0 deletions xdrawchem-qt5/xdrawchem/application_ring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <cstdlib>
#include <cerrno>

#include <QtGlobal>
#include <QBitmap>

#include "application.h"
Expand Down
6 changes: 1 addition & 5 deletions xdrawchem-qt5/xdrawchem/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
#ifndef QT_NO_SSL
connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(sslErrors(QList<QSslError>)));
#endif
//while (!reply->isFinished()) {
//qDebug() << "isRunning: " << reply->isRunning() << "isFinished: " << reply->isFinished();
//sleep(1);
//}
}

void HTTP::slotError(const QNetworkReply::NetworkError e)
Expand All @@ -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<QSslError> &sslErrors)
Expand Down
3 changes: 3 additions & 0 deletions xdrawchem-qt5/xdrawchem/myfiledialog.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include <QtGlobal>
#include <QLayout>

#include "myfiledialog.h"

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
Expand Down
1 change: 1 addition & 0 deletions xdrawchem-qt5/xdrawchem/myfiledialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class MyFileDialog : public QFileDialog
{
Q_OBJECT
public:
MyFileDialog( QWidget *parent );
bool isTransparent();
Expand Down
16 changes: 11 additions & 5 deletions xdrawchem-qt5/xdrawchem/render2d_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit e23a3f8

Please sign in to comment.