ImageViewer::ImageViewer (const QUrl &url, const QString &capText, QWidget *parent) : QDialog( parent ), m_ImageUrl(url), fileIsImage(false) { init(url.fileName(), capText); // check URL if (!m_ImageUrl.isValid()) qDebug() << "URL is malformed: " << m_ImageUrl; if (m_ImageUrl.isLocalFile()) { loadImage(m_ImageUrl.path()); return; } { QTemporaryFile tempfile; tempfile.open(); file.setFileName( tempfile.fileName() ); }// we just need the name and delete the tempfile from disc; if we don't do it, a dialog will be show loadImageFromURL(); }
ImageViewer::ImageViewer (const KUrl &url, const QString &capText, QWidget *parent) : KDialog( parent ), m_ImageUrl(url), fileIsImage(false), downloadJob(0) { init(url.fileName(), capText); // Add save button setButtons( KDialog::User2 | KDialog::User1 | KDialog::Close ); KGuiItem saveButton( i18n("Save"), "document-save", i18n("Save the image to disk") ); setButtonGuiItem( KDialog::User1, saveButton ); // FIXME: Add more options, and do this more nicely KGuiItem invertButton( i18n("Invert colors"), "", i18n("Reverse colors of the image. This is useful to enhance contrast at times. This affects only the display and not the saving.") ); setButtonGuiItem( KDialog::User2, invertButton ); connect( this, SIGNAL( user1Clicked() ), this, SLOT ( saveFileToDisc() ) ); connect( this, SIGNAL( user2Clicked() ), this, SLOT ( invertColors() ) ); // check URL if (!m_ImageUrl.isValid()) kDebug() << "URL is malformed: " << m_ImageUrl; // FIXME: check the logic with temporary files. Races are possible { KTemporaryFile tempfile; tempfile.open(); file.setFileName( tempfile.fileName() ); }// we just need the name and delete the tempfile from disc; if we don't do it, a dialog will be show loadImageFromURL(); }