[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Neat interface or Bloat you decide
From:       ian reinhart geiser <geiseri () yahoo ! com>
Date:       2001-10-23 2:41:53
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Greetings
	I added a feature that I have found very handy, but I fear it may be 
misplaced or considered bloat.  So I ask you please review this patch.

It provides a dcop interface to KMainWindow to allow the screen capture of a 
window.

Example:
	dcop kwrite kwrite-mainwindow#1 grabImageToFile test.png

Will capture KWrites main window to a png.

I have attached the diff, has anyone an opinion?  I know you do ;)
- -ian reinhart geiser
- -- 
========================================
<<<<< EVACUATION ROUTE <<<<<
========================================
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE71NjxPy62TRm8dvgRArjpAKDHfb/PR+IOHBdc0IIT9VE5vIh8oACfXBeA
WlDcGBcYTKU8AhOiU140AhE=
=NMAm
-----END PGP SIGNATURE-----

["screengrab.diff" (text/x-diff)]

? screengrab.diff
Index: kmainwindowiface.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindowiface.cpp,v
retrieving revision 1.5
diff -u -r1.5 kmainwindowiface.cpp
--- kmainwindowiface.cpp	2001/10/12 15:52:48	1.5
+++ kmainwindowiface.cpp	2001/10/23 02:36:56
@@ -24,8 +24,11 @@
 #include <kdcopactionproxy.h>
 #include <kmainwindow.h>
 #include <kaction.h>
+#include <qpixmap.h>
+#include <qclipboard.h>
+#include <kimageio.h>
+#include <kdebug.h>
 
-
 KMainWindowInterface::KMainWindowInterface(KMainWindow * mainWindow)
 	: DCOPObject( mainWindow->name())
 {
@@ -115,7 +118,7 @@
 		return "Error no such object!";
 }
 
-DCOPRef KMainWindowInterface::action( const QCString &name )
+DCOPRef KMainWindowInterface::action( QCString name )
 {
 	return DCOPRef( kapp->dcopClient()->appId(), m_dcopActionProxy->actionObjectId( name ) );
 }
@@ -123,4 +126,21 @@
 QMap<QCString,DCOPRef> KMainWindowInterface::actionMap()
 {
 	return m_dcopActionProxy->actionMap();
+}
+
+void KMainWindowInterface::grabImageToClipboard()
+{
+	QClipboard *clipboard = QApplication::clipboard();
+	clipboard->setPixmap(doGrab());
+}
+
+bool KMainWindowInterface::grabImageToFile(QCString theURL)
+{
+	kdDebug() << "Save file " << theURL << endl;
+	return (doGrab().save(theURL, "PNG"));
+}
+
+QPixmap KMainWindowInterface::doGrab()
+{
+	return QPixmap::grabWindow(m_MainWindow->winId());
 }
Index: kmainwindowiface.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindowiface.h,v
retrieving revision 1.7
diff -u -r1.7 kmainwindowiface.h
--- kmainwindowiface.h	2001/10/17 09:55:01	1.7
+++ kmainwindowiface.h	2001/10/23 02:36:56
@@ -20,13 +20,15 @@
 #ifndef KWINDOW_INTERFACE_H
 #define KWINDOW_INTERFACE_H
 
+#include <dcopref.h>
 #include <dcopobject.h>
+
 #include <qstringlist.h>
 #include <qcstring.h>
-#include <dcopref.h>
 
 class KDCOPActionProxy;
 class KMainWindow;
+class QPixmap;
 
 /**
 This is the main interface to the @ref KMainWindow.  This will provide a consistant
@@ -50,6 +52,10 @@
 	Cleans up the dcop action proxy object.
 	**/
 	~KMainWindowInterface();
+private:
+	QPixmap doGrab();
+
+public:
 k_dcop:
 	/**
 	Return a list of actions available to the application's window.
@@ -103,13 +109,23 @@
 	actions can be found by calling @actions().
 	@return A @ref DCOPRef for the kaction.
 	**/
-	DCOPRef action( const QCString &name );
+	DCOPRef action( QCString name );
 
 	/**
 	Returns and action map
 	**/
     	QMap<QCString,DCOPRef> actionMap();
 
+	/**
+	Grabs a pixmap of the main window and puts the data on the X clipboard
+	**/
+	void grabImageToClipboard();
+
+	/**
+	Grabs a pixmap of the main window and puts the data in the declared file.
+	@param theURL to write the file to.  This is not network aware.
+	**/
+	bool grabImageToFile(QCString theURL);
 private:
 	KMainWindow *m_MainWindow;
 	KDCOPActionProxy *m_dcopActionProxy;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic