summaryrefslogtreecommitdiffstats
path: root/krita/plugins/viewplugins/screenshot/ksnapshot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'krita/plugins/viewplugins/screenshot/ksnapshot.cpp')
-rw-r--r--krita/plugins/viewplugins/screenshot/ksnapshot.cpp194
1 files changed, 97 insertions, 97 deletions
diff --git a/krita/plugins/viewplugins/screenshot/ksnapshot.cpp b/krita/plugins/viewplugins/screenshot/ksnapshot.cpp
index 77b4da4b..09bdca48 100644
--- a/krita/plugins/viewplugins/screenshot/ksnapshot.cpp
+++ b/krita/plugins/viewplugins/screenshot/ksnapshot.cpp
@@ -22,11 +22,11 @@
#include <ksavefile.h>
#include <ktempfile.h>
-#include <qbitmap.h>
-#include <qdragobject.h>
-#include <qimage.h>
-#include <qclipboard.h>
-#include <qvbox.h>
+#include <tqbitmap.h>
+#include <tqdragobject.h>
+#include <tqimage.h>
+#include <tqclipboard.h>
+#include <tqvbox.h>
#include <kaccel.h>
#include <knotifyclient.h>
@@ -35,11 +35,11 @@
#include <kpushbutton.h>
#include <kstartupinfo.h>
-#include <qcursor.h>
-#include <qregexp.h>
-#include <qpainter.h>
-#include <qpaintdevicemetrics.h>
-#include <qwhatsthis.h>
+#include <tqcursor.h>
+#include <tqregexp.h>
+#include <tqpainter.h>
+#include <tqpaintdevicemetrics.h>
+#include <tqwhatsthis.h>
#include <stdlib.h>
@@ -58,10 +58,10 @@
#include <kglobal.h>
-KSnapshot::KSnapshot(QWidget *parent, const char *name)
- : super(parent, name, false, QString::null, Ok|Cancel)
+KSnapshot::KSnapshot(TQWidget *tqparent, const char *name)
+ : super(tqparent, name, false, TQString(), Ok|Cancel)
{
- grabber = new QWidget( 0, 0, WStyle_Customize | WX11BypassWM );
+ grabber = new TQWidget( 0, 0, WStyle_Customize | WX11BypassWM );
Q_CHECK_PTR(grabber);
grabber->move( -1000, -1000 );
grabber->installEventFilter( this );
@@ -72,21 +72,21 @@ KSnapshot::KSnapshot(QWidget *parent, const char *name)
haveXShape = XShapeQueryExtension( qt_xdisplay(), &tmp1, &tmp2 );
#endif
- QVBox *vbox = makeVBoxMainWidget();
+ TQVBox *vbox = makeVBoxMainWidget();
mainWidget = new KSnapshotWidget( vbox, "mainWidget" );
Q_CHECK_PTR(mainWidget);
mainWidget->btnSave->hide();
mainWidget->btnPrint->hide();
- connect(mainWidget, SIGNAL(startImageDrag()), SLOT(slotDragSnapshot()));
+ connect(mainWidget, TQT_SIGNAL(startImageDrag()), TQT_SLOT(slotDragSnapshot()));
- connect( mainWidget, SIGNAL( newClicked() ), SLOT( slotGrab() ) );
- connect( mainWidget, SIGNAL( printClicked() ), SLOT( slotPrint() ) );
+ connect( mainWidget, TQT_SIGNAL( newClicked() ), TQT_SLOT( slotGrab() ) );
+ connect( mainWidget, TQT_SIGNAL( printClicked() ), TQT_SLOT( slotPrint() ) );
grabber->show();
grabber->grabMouse( waitCursor );
- snapshot = QPixmap::grabWindow( qt_xrootwin() );
+ snapshot = TQPixmap::grabWindow( qt_xrootwin() );
updatePreview();
grabber->releaseMouse();
grabber->hide();
@@ -97,16 +97,16 @@ KSnapshot::KSnapshot(QWidget *parent, const char *name)
mainWidget->setMode( conf->readNumEntry( "mode", 0 ) );
mainWidget->setIncludeDecorations(conf->readBoolEntry("includeDecorations",true));
- connect( &grabTimer, SIGNAL( timeout() ), this, SLOT( grabTimerDone() ) );
+ connect( &grabTimer, TQT_SIGNAL( timeout() ), this, TQT_SLOT( grabTimerDone() ) );
KAccel* accel = new KAccel(this);
Q_CHECK_PTR(accel);
- accel->insert(KStdAccel::Print, this, SLOT(slotPrint()));
- accel->insert(KStdAccel::New, this, SLOT(slotGrab()));
+ accel->insert(KStdAccel::Print, this, TQT_SLOT(slotPrint()));
+ accel->insert(KStdAccel::New, this, TQT_SLOT(slotGrab()));
- accel->insert( "Print2", Qt::Key_P, this, SLOT(slotPrint()));
- accel->insert( "New2", Qt::Key_N, this, SLOT(slotGrab()));
- accel->insert( "New3", Qt::Key_Space, this, SLOT(slotGrab()));
+ accel->insert( "Print2", TQt::Key_P, this, TQT_SLOT(slotPrint()));
+ accel->insert( "New2", TQt::Key_N, this, TQT_SLOT(slotGrab()));
+ accel->insert( "New3", TQt::Key_Space, this, TQT_SLOT(slotGrab()));
mainWidget->btnNew->setFocus();
@@ -116,14 +116,14 @@ KSnapshot::~KSnapshot()
{
}
-bool KSnapshot::save( const QString &filename )
+bool KSnapshot::save( const TQString &filename )
{
return save( KURL::fromPathOrURL( filename ));
}
bool KSnapshot::save( const KURL& url )
{
- QString type( KImageIO::type(url.path()) );
+ TQString type( KImageIO::type(url.path()) );
if ( type.isNull() )
type = "PNG";
@@ -147,13 +147,13 @@ bool KSnapshot::save( const KURL& url )
}
}
- QApplication::restoreOverrideCursor();
+ TQApplication::restoreOverrideCursor();
if ( !ok ) {
kdWarning() << "KSnapshot was unable to save the snapshot" << endl;
- QString caption = i18n("Unable to Save Image");
- QString text = i18n("KSnapshot was unable to save the image to\n%1.")
- .arg(url.prettyURL());
+ TQString caption = i18n("Unable to Save Image");
+ TQString text = i18n("KSnapshot was unable to save the image to\n%1.")
+ .tqarg(url.prettyURL());
KMessageBox::error(this, text, caption);
}
@@ -162,13 +162,13 @@ bool KSnapshot::save( const KURL& url )
void KSnapshot::slotCopy()
{
- QClipboard *cb = QApplication::clipboard();
+ TQClipboard *cb = TQApplication::tqclipboard();
cb->setPixmap( snapshot );
}
void KSnapshot::slotDragSnapshot()
{
- QDragObject *drobj = new QImageDrag(snapshot.convertToImage(), this);
+ TQDragObject *drobj = new TQImageDrag(snapshot.convertToImage(), this);
Q_CHECK_PTR(drobj);
drobj->setPixmap(mainWidget->preview());
drobj->dragCopy();
@@ -181,8 +181,8 @@ void KSnapshot::slotGrab()
{
rgnGrab = new RegionGrabber();
Q_CHECK_PTR(rgnGrab);
- connect( rgnGrab, SIGNAL( regionGrabbed( const QPixmap & ) ),
- SLOT( slotRegionGrabbed( const QPixmap & ) ) );
+ connect( rgnGrab, TQT_SIGNAL( regionGrabbed( const TQPixmap & ) ),
+ TQT_SLOT( slotRegionGrabbed( const TQPixmap & ) ) );
}
else
{
@@ -203,14 +203,14 @@ void KSnapshot::slotPrint()
else
printer.setOrientation(KPrinter::Portrait);
- qApp->processEvents();
+ tqApp->processEvents();
if (printer.setup(this, i18n("Print Screenshot")))
{
- qApp->processEvents();
+ tqApp->processEvents();
- QPainter painter(&printer);
- QPaintDeviceMetrics metrics(painter.device());
+ TQPainter painter(&printer);
+ TQPaintDeviceMetrics metrics(painter.device());
float w = snapshot.width();
float dw = w - metrics.width();
@@ -223,8 +223,8 @@ void KSnapshot::slotPrint()
if ( scale ) {
- QImage img = snapshot.convertToImage();
- qApp->processEvents();
+ TQImage img = snapshot.convertToImage();
+ tqApp->processEvents();
float newh, neww;
if ( dw > dh ) {
@@ -236,8 +236,8 @@ void KSnapshot::slotPrint()
neww = newh/h*w;
}
- img = img.smoothScale( int(neww), int(newh), QImage::ScaleMin );
- qApp->processEvents();
+ img = img.smoothScale( int(neww), int(newh), TQ_ScaleMin );
+ tqApp->processEvents();
int x = (metrics.width()-img.width())/2;
int y = (metrics.height()-img.height())/2;
@@ -251,10 +251,10 @@ void KSnapshot::slotPrint()
}
}
- qApp->processEvents();
+ tqApp->processEvents();
}
-void KSnapshot::slotRegionGrabbed( const QPixmap &pix )
+void KSnapshot::slotRegionGrabbed( const TQPixmap &pix )
{
if ( !pix.isNull() )
{
@@ -264,15 +264,15 @@ void KSnapshot::slotRegionGrabbed( const QPixmap &pix )
}
delete rgnGrab;
- QApplication::restoreOverrideCursor();
+ TQApplication::restoreOverrideCursor();
show();
}
-bool KSnapshot::eventFilter( QObject* o, QEvent* e)
+bool KSnapshot::eventFilter( TQObject* o, TQEvent* e)
{
- if ( o == grabber && e->type() == QEvent::MouseButtonPress ) {
- QMouseEvent* me = (QMouseEvent*) e;
- if ( QWidget::mouseGrabber() != grabber )
+ if ( o == grabber && e->type() == TQEvent::MouseButtonPress ) {
+ TQMouseEvent* me = (TQMouseEvent*) e;
+ if ( TQWidget::mouseGrabber() != grabber )
return false;
if ( me->button() == LeftButton )
performGrab();
@@ -282,7 +282,7 @@ bool KSnapshot::eventFilter( QObject* o, QEvent* e)
void KSnapshot::updatePreview()
{
- QImage img = snapshot.convertToImage();
+ TQImage img = snapshot.convertToImage();
double r1 = ((double) snapshot.height() ) / snapshot.width();
if ( r1 * mainWidget->previewWidth() < mainWidget->previewHeight() )
img = img.smoothScale( mainWidget->previewWidth(),
@@ -291,7 +291,7 @@ void KSnapshot::updatePreview()
img = img.smoothScale( (int) (((double)mainWidget->previewHeight()) / r1),
(mainWidget->previewHeight() ) );
- QPixmap pm;
+ TQPixmap pm;
pm.convertFromImage( img );
mainWidget->setPreview( pm );
}
@@ -319,17 +319,17 @@ Window findRealWindow( Window w, int depth = 0 )
if( type != None )
return w;
}
- Window root, parent;
- Window* children;
- unsigned int nchildren;
+ Window root, tqparent;
+ Window* tqchildren;
+ unsigned int ntqchildren;
Window ret = None;
- if( XQueryTree( qt_xdisplay(), w, &root, &parent, &children, &nchildren ) != 0 ) {
+ if( XQueryTree( qt_xdisplay(), w, &root, &tqparent, &tqchildren, &ntqchildren ) != 0 ) {
for( unsigned int i = 0;
- i < nchildren && ret == None;
+ i < ntqchildren && ret == None;
++i )
- ret = findRealWindow( children[ i ], depth + 1 );
- if( children != NULL )
- XFree( children );
+ ret = findRealWindow( tqchildren[ i ], depth + 1 );
+ if( tqchildren != NULL )
+ XFree( tqchildren );
}
return ret;
}
@@ -343,11 +343,11 @@ void KSnapshot::performGrab()
if ( mainWidget->mode() == WindowUnderCursor ) {
Window root;
Window child;
- uint mask;
+ uint tqmask;
int rootX, rootY, winX, winY;
XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child,
&rootX, &rootY, &winX, &winY,
- &mask);
+ &tqmask);
if( child == None )
child = qt_xrootwin();
if( !mainWidget->includeDecorations()) {
@@ -364,77 +364,77 @@ void KSnapshot::performGrab()
w += 2 * border;
h += 2 * border;
- Window parent;
- Window* children;
- unsigned int nchildren;
- if( XQueryTree( qt_xdisplay(), child, &root, &parent,
- &children, &nchildren ) != 0 ) {
- if( children != NULL )
- XFree( children );
+ Window tqparent;
+ Window* tqchildren;
+ unsigned int ntqchildren;
+ if( XQueryTree( qt_xdisplay(), child, &root, &tqparent,
+ &tqchildren, &ntqchildren ) != 0 ) {
+ if( tqchildren != NULL )
+ XFree( tqchildren );
int newx, newy;
Window dummy;
- if( XTranslateCoordinates( qt_xdisplay(), parent, qt_xrootwin(),
+ if( XTranslateCoordinates( qt_xdisplay(), tqparent, qt_xrootwin(),
x, y, &newx, &newy, &dummy )) {
x = newx;
y = newy;
}
}
- snapshot = QPixmap::grabWindow( qt_xrootwin(), x, y, w, h );
+ snapshot = TQPixmap::grabWindow( qt_xrootwin(), x, y, w, h );
#ifdef HAVE_X11_EXTENSIONS_SHAPE_H
//No XShape - no work.
if (haveXShape) {
- QBitmap mask(w, h);
- //As the first step, get the mask from XShape.
+ TQBitmap tqmask(w, h);
+ //As the first step, get the tqmask from XShape.
int count, order;
XRectangle* rects = XShapeGetRectangles( qt_xdisplay(), child,
ShapeBounding, &count, &order);
- //The ShapeBounding region is the outermost shape of the window;
+ //The ShapeBounding region is the outermost tqshape of the window;
//ShapeBounding - ShapeClipping is defined to be the border.
//Since the border area is part of the window, we use bounding
// to limit our work region
if (rects) {
- //Create a QRegion from the rectangles describing the bounding mask.
- QRegion contents;
+ //Create a TQRegion from the rectangles describing the bounding tqmask.
+ TQRegion contents;
for (int pos = 0; pos < count; pos++)
- contents += QRegion(rects[pos].x, rects[pos].y,
+ contents += TQRegion(rects[pos].x, rects[pos].y,
rects[pos].width, rects[pos].height);
XFree(rects);
//Create the bounding box.
- QRegion bbox(0, 0, snapshot.width(), snapshot.height());
+ TQRegion bbox(0, 0, snapshot.width(), snapshot.height());
if( border > 0 ) {
contents.translate( border, border );
- contents += QRegion( 0, 0, border, h );
- contents += QRegion( 0, 0, w, border );
- contents += QRegion( 0, h - border, w, border );
- contents += QRegion( w - border, 0, border, h );
+ contents += TQRegion( 0, 0, border, h );
+ contents += TQRegion( 0, 0, w, border );
+ contents += TQRegion( 0, h - border, w, border );
+ contents += TQRegion( w - border, 0, border, h );
}
- //Get the masked away area.
- QRegion maskedAway = bbox - contents;
- QMemArray<QRect> maskedAwayRects = maskedAway.rects();
-
- //Construct a bitmap mask from the rectangles
- QPainter p(&mask);
- p.fillRect(0, 0, w, h, Qt::color1);
- for (uint pos = 0; pos < maskedAwayRects.count(); pos++)
- p.fillRect(maskedAwayRects[pos], Qt::color0);
+ //Get the tqmasked away area.
+ TQRegion tqmaskedAway = bbox - contents;
+ TQMemArray<TQRect> tqmaskedAwayRects = tqmaskedAway.rects();
+
+ //Construct a bitmap tqmask from the rectangles
+ TQPainter p(&tqmask);
+ p.fillRect(0, 0, w, h, TQt::color1);
+ for (uint pos = 0; pos < tqmaskedAwayRects.count(); pos++)
+ p.fillRect(tqmaskedAwayRects[pos], TQt::color0);
p.end();
- snapshot.setMask(mask);
+ snapshot.setMask(tqmask);
}
}
#endif
}
else {
- snapshot = QPixmap::grabWindow( qt_xrootwin() );
+ snapshot = TQPixmap::grabWindow( qt_xrootwin() );
}
XUngrabServer( qt_xdisplay());
updatePreview();
- QApplication::restoreOverrideCursor();
+ TQApplication::restoreOverrideCursor();
modified = true;
// show();
slotOk();
@@ -445,7 +445,7 @@ void KSnapshot::setTime(int newTime)
mainWidget->setDelay(newTime);
}
-void KSnapshot::setURL( const QString &url )
+void KSnapshot::setURL( const TQString &url )
{
KURL newURL = KURL::fromPathOrURL( url );
if ( newURL == filename )
@@ -461,7 +461,7 @@ void KSnapshot::setGrabMode( int m )
void KSnapshot::slotMovePointer(int x, int y)
{
- QCursor::setPos( x, y );
+ TQCursor::setPos( x, y );
}
void KSnapshot::exit()
@@ -473,7 +473,7 @@ void KSnapshot::exit()
conf->writeEntry("mode",mainWidget->mode());
conf->writeEntry("includeDecorations",mainWidget->includeDecorations());
KURL url = filename;
- url.setPass( QString::null );
+ url.setPass( TQString() );
conf->writePathEntry("filename",url.url());
reject();
@@ -488,7 +488,7 @@ void KSnapshot::slotOk()
conf->writeEntry("mode",mainWidget->mode());
conf->writeEntry("includeDecorations",mainWidget->includeDecorations());
KURL url = filename;
- url.setPass( QString::null );
+ url.setPass( TQString() );
conf->writePathEntry("filename",url.url());
emit screenGrabbed();