KSnapshots: fixed remaining issues related to PR #50.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>

KSnapshot: remove stray slot

This was erroneously introduced in PR #50.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/52/head
Michele Calgaro 1 year ago
parent db379a2f50
commit 3bac83b229
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -77,12 +77,12 @@ KSnapshot::KSnapshot(TQWidget *parent, const char *name, bool grabCurrent)
mainWidget = new KSnapshotWidget( vbox, "mainWidget" );
connect(mainWidget, TQT_SIGNAL(startImageDrag()), TQT_SLOT(slotDragSnapshot()));
connect( mainWidget, TQT_SIGNAL( newClicked() ), TQT_SLOT( slotGrab() ) );
connect( mainWidget, TQT_SIGNAL( saveClicked() ), TQT_SLOT( slotSaveAs() ) );
connect( mainWidget, TQT_SIGNAL( printClicked() ), TQT_SLOT( slotPrint() ) );
connect( mainWidget, TQT_SIGNAL( copyClicked() ), TQT_SLOT( slotCopy() ) );
connect( mainWidget, TQT_SIGNAL( openWithKPClicked() ), TQT_SLOT( slotOpenWithKP() ) );
connect(mainWidget, TQT_SIGNAL(newClicked()), TQT_SLOT(slotGrab()));
connect(mainWidget, TQT_SIGNAL(saveClicked()), TQT_SLOT(slotSaveAs()));
connect(mainWidget, TQT_SIGNAL(printClicked()), TQT_SLOT(slotPrint()));
connect(mainWidget, TQT_SIGNAL(copyClicked()), TQT_SLOT(slotCopy()));
connect(mainWidget, TQT_SIGNAL(openWithKPClicked()), TQT_SLOT(slotOpenWithKP()));
connect(tqApp, TQT_SIGNAL(aboutToQuit()), TQT_SLOT(slotAboutToQuit()));
grabber->show();
grabber->grabMouse( waitCursor );
@ -394,12 +394,10 @@ void KSnapshot::slotOpenWithKP() {
}
}
static KTempFile *tmpFile = nullptr;
void KSnapshot::openWithExternalApp(const KService &service) {
// Write snapshot to temporary file
bool ok = false;
tmpFile = new KTempFile;
KTempFile *tmpFile = new KTempFile;
if (tmpFile->status() == 0) {
if (snapshot.save(tmpFile->file(), "PNG")) {
if (tmpFile->close()) {
@ -409,9 +407,9 @@ void KSnapshot::openWithExternalApp(const KService &service) {
}
if (!ok) {
KMessageBox::error(this, i18n("KSnapshot was unable to create "
"temporary file."),
KMessageBox::error(this, i18n("KSnapshot was unable to create temporary file."),
i18n("Unable to save image"));
delete tmpFile;
return;
}
@ -423,33 +421,55 @@ void KSnapshot::openWithExternalApp(const KService &service) {
TDEProcess *externalApp = new TDEProcess;
*externalApp << args;
connect(externalApp, SIGNAL(processExited(TDEProcess*)),
this, SLOT(slotExternalAppClosed()));
this, SLOT(slotExternalAppClosed(TDEProcess*)));
if (!externalApp->start(TDEProcess::OwnGroup)) {
KMessageBox::error(this, i18n("Cannot start %1!").arg(service.name()));
delete tmpFile;
return;
}
m_tmpFiles[externalApp] = tmpFile;
}
void KSnapshot::slotExternalAppClosed() {
snapshot.load(tmpFile->name());
updatePreview();
tmpFile->unlink();
delete tmpFile;
tmpFile = nullptr;
void KSnapshot::slotExternalAppClosed(TDEProcess *process)
{
if (process && m_tmpFiles.contains(process))
{
KTempFile *tmpFile = m_tmpFiles[process];
if (tmpFile)
{
snapshot.load(tmpFile->name());
updatePreview();
tmpFile->unlink();
delete tmpFile;
}
m_tmpFiles.remove(process);
}
}
void KSnapshot::slotAboutToQuit()
{
for (KTempFile *tmpFile : m_tmpFiles)
{
tmpFile->unlink();
delete tmpFile;
}
m_tmpFiles.clear();
TDEConfig *conf=TDEGlobal::config();
conf->setGroup("GENERAL");
conf->writeEntry("delay",mainWidget->delay());
conf->writeEntry("mode",mainWidget->mode());
conf->writeEntry("includeDecorations",mainWidget->includeDecorations());
KURL url = filename;
url.setPass( TQString() );
conf->writePathEntry("filename",url.url());
}
void KSnapshot::closeEvent( TQCloseEvent * e )
{
TDEConfig *conf=TDEGlobal::config();
conf->setGroup("GENERAL");
conf->writeEntry("delay",mainWidget->delay());
conf->writeEntry("mode",mainWidget->mode());
conf->writeEntry("includeDecorations",mainWidget->includeDecorations());
KURL url = filename;
url.setPass( TQString() );
conf->writePathEntry("filename",url.url());
e->accept();
e->accept();
}
bool KSnapshot::eventFilter( TQObject* o, TQEvent* e)

@ -5,6 +5,7 @@
#include <tqbitmap.h>
#include <tqcursor.h>
#include <tqlabel.h>
#include <tqmap.h>
#include <tqpainter.h>
#include <tqpixmap.h>
#include <tqstyle.h>
@ -18,6 +19,8 @@
class RegionGrabber;
class KSnapshotWidget;
class KTempFile;
class TDEProcess;
class KSnapshotPreview : public TQLabel
{
@ -101,6 +104,7 @@ public:
TQString url() const { return filename.url(); }
protected slots:
void slotAboutToQuit();
void slotGrab();
void slotSave();
void slotSaveAs();
@ -108,7 +112,7 @@ protected slots:
void slotPrint();
void slotOpenWith(int id);
void slotOpenWithKP();
void slotExternalAppClosed();
void slotExternalAppClosed(TDEProcess *process);
void slotMovePointer( int x, int y );
void setTime(int newTime);
@ -148,6 +152,7 @@ private:
RegionGrabber *rgnGrab;
bool modified;
TDETrader::OfferList openWithOffers;
TQMap<TDEProcess*, KTempFile*> m_tmpFiles;
};
#endif // KSNAPSHOT_H

@ -323,12 +323,6 @@ If &lt;i&gt;no delay&lt;/i&gt; is set, the program will wait for a mouse click b
<receiver>KSnapshotWidget</receiver>
<slot>slotOpenWithKPClicked()</slot>
</connection>
<connection>
<sender>btnOpenWith</sender>
<signal>clicked()</signal>
<receiver>KSnapshotWidget</receiver>
<slot>slotOpenWithClicked()</slot>
</connection>
<connection>
<sender>btnSave</sender>
<signal>clicked()</signal>

Loading…
Cancel
Save