Open in KolourPaint

Signed-off-by: Emanoil Kotsev <deloptes@gmail.com>
Emanoil Kotsev 1 year ago
parent 513cf6435a
commit f2ac34e605
Signed by: deloptes
GPG Key ID: F1EEB8CD9FB16A50

@ -6,6 +6,7 @@
* (c) Aaron J. Seigo 2002
* (c) Nadeem Hasan 2003
* (c) Bernd Brandstetter 2004
* (c) Emanoil Kotsev 2023
*
* Released under the LGPL see file LICENSE for details.
*/
@ -41,6 +42,8 @@
#include <tqpainter.h>
#include <tqpaintdevicemetrics.h>
#include <tqwhatsthis.h>
#include <tqbuffer.h>
#include <tqprocess.h>
#include <stdlib.h>
@ -58,6 +61,8 @@
#define kApp TDEApplication::kApplication()
#define KOLOURPAINT_EXE "/opt/trinity/bin/kolourpaint"
KSnapshot::KSnapshot(TQWidget *parent, const char *name, bool grabCurrent)
: DCOPObject("interface"),
KDialogBase(parent, name, true, TQString(), Help|User1, User1,
@ -78,6 +83,7 @@ KSnapshot::KSnapshot(TQWidget *parent, const char *name, bool grabCurrent)
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( openKolourPaint() ), TQT_SLOT( slotOpenKolourPaint() ) );
grabber->show();
grabber->grabMouse( waitCursor );
@ -359,6 +365,33 @@ void KSnapshot::slotWindowGrabbed( const TQPixmap &pix )
show();
}
void KSnapshot::slotOpenKolourPaint()
{
slotCopy();
TQFileInfo kolourPaintExeFile( KOLOURPAINT_EXE );
if (!kolourPaintExeFile.exists())
{
tqWarning( "koulourpaint executable was not found\nMake sure the executable is in the default location");
}
TQProcess *kolourPaintExe = new TQProcess(kolourPaintExeFile.filePath(), this);
TQImage img = snapshot.convertToImage();
tqApp->processEvents();
if (!kolourPaintExe->isRunning())
{
TQByteArray ba;
TQBuffer buffer( ba );
buffer.open( IO_WriteOnly );
img.save( &buffer, "PNG" ); // writes image into ba in PNG format
if (!kolourPaintExe->launch(ba))
tqWarning( "koulourpaint executable was not able to start");
}
}
void KSnapshot::closeEvent( TQCloseEvent * e )
{
TDEConfig *conf=TDEGlobal::config();

@ -107,6 +107,7 @@ protected slots:
void slotSaveAs();
void slotCopy();
void slotPrint();
void slotOpenKolourPaint();
void slotMovePointer( int x, int y );
void setTime(int newTime);

@ -242,6 +242,23 @@ If &lt;i&gt;no delay&lt;/i&gt; is set, the program will wait for a mouse click b
<string>Click this button to print the current screenshot.</string>
</property>
</widget>
<widget class="KPushButton">
<property name="name">
<cstring>btnOpenInKP</cstring>
</property>
<property name="text">
<string>Open in &amp;KolourPaint</string>
</property>
<property name="accel">
<string>Alt+K</string>
</property>
<property name="iconSet">
<iconset>"document-save"</iconset>
</property>
<property name="whatsThis" stdset="0">
<string>Click this button to open in KolourPaint.</string>
</property>
</widget>
</vbox>
</widget>
</grid>
@ -289,6 +306,12 @@ If &lt;i&gt;no delay&lt;/i&gt; is set, the program will wait for a mouse click b
<receiver>KSnapshotWidget</receiver>
<slot>slotPrintClicked()</slot>
</connection>
<connection>
<sender>btnOpenInKP</sender>
<signal>clicked()</signal>
<receiver>KSnapshotWidget</receiver>
<slot>slotOpenKolourPaint()</slot>
</connection>
<connection>
<sender>btnSave</sender>
<signal>clicked()</signal>
@ -328,6 +351,7 @@ If &lt;i&gt;no delay&lt;/i&gt; is set, the program will wait for a mouse click b
<signal>saveClicked()</signal>
<signal>copyClicked()</signal>
<signal>printClicked()</signal>
<signal>openKolourPaint()</signal>
<signal>startImageDrag()</signal>
</Q_SIGNALS>
<Q_SLOTS>
@ -337,6 +361,7 @@ If &lt;i&gt;no delay&lt;/i&gt; is set, the program will wait for a mouse click b
<slot access="protected" specifier="non virtual">slotCopyClicked()</slot>
<slot access="protected" specifier="non virtual">slotPrintClicked()</slot>
<slot access="protected" specifier="non virtual">slotStartDrag()</slot>
<slot access="protected" specifier="non virtual">slotOpenKolourPaint()</slot>
<slot specifier="non virtual" returnType="int">previewWidth()</slot>
<slot specifier="non virtual" returnType="int">previewHeight()</slot>
</Q_SLOTS>

@ -136,3 +136,8 @@ void KSnapshotWidget::slotCopyClicked()
{
emit copyClicked();
}
void KSnapshotWidget::slotOpenKolourPaint()
{
emit openKolourPaint();
}

Loading…
Cancel
Save