summaryrefslogtreecommitdiffstats
path: root/lib/koproperty/editors/pixmapedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/koproperty/editors/pixmapedit.cpp')
-rw-r--r--lib/koproperty/editors/pixmapedit.cpp130
1 files changed, 65 insertions, 65 deletions
diff --git a/lib/koproperty/editors/pixmapedit.cpp b/lib/koproperty/editors/pixmapedit.cpp
index d141eed3..95cdbb9d 100644
--- a/lib/koproperty/editors/pixmapedit.cpp
+++ b/lib/koproperty/editors/pixmapedit.cpp
@@ -23,22 +23,22 @@
#include "editoritem.h"
#include "property.h"
-#include <qlayout.h>
-#include <qpainter.h>
-#include <qlabel.h>
-#include <qcursor.h>
-#include <qpushbutton.h>
-#include <qfont.h>
-#include <qfontmetrics.h>
-#include <qimage.h>
-#include <qfiledialog.h>
-#include <qtooltip.h>
-#include <qapplication.h>
+#include <tqlayout.h>
+#include <tqpainter.h>
+#include <tqlabel.h>
+#include <tqcursor.h>
+#include <tqpushbutton.h>
+#include <tqfont.h>
+#include <tqfontmetrics.h>
+#include <tqimage.h>
+#include <tqfiledialog.h>
+#include <tqtooltip.h>
+#include <tqapplication.h>
#include <kdebug.h>
#include <kimageio.h>
-#ifdef Q_WS_WIN
+#ifdef TQ_WS_WIN
#include <win32_utils.h>
#include <krecentdirs.h>
#endif
@@ -51,36 +51,36 @@
using namespace KoProperty;
-PixmapEdit::PixmapEdit(Property *property, QWidget *parent, const char *name)
- : Widget(property, parent, name)
+PixmapEdit::PixmapEdit(Property *property, TQWidget *tqparent, const char *name)
+ : Widget(property, tqparent, name)
{
setHasBorders(false);
- m_edit = new QLabel(this, "m_edit");
- QToolTip::add(m_edit, i18n("Click to show image preview"));
- m_edit->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ m_edit = new TQLabel(this, "m_edit");
+ TQToolTip::add(m_edit, i18n("Click to show image preview"));
+ m_edit->tqsetAlignment(TQt::AlignLeft | TQt::AlignVCenter);
m_edit->setMinimumHeight(5);
- m_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- m_edit->setBackgroundMode(Qt::PaletteBase);
+ m_edit->tqsetSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Fixed);
+ m_edit->setBackgroundMode(TQt::PaletteBase);
m_edit->setMouseTracking(true);
- setBackgroundMode(Qt::PaletteBase);
+ setBackgroundMode(TQt::PaletteBase);
- m_button = new QPushButton(i18n("..."), this, "m_button");
- QToolTip::add(m_button, i18n("Insert image from file"));
- m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- QFontMetrics fm(m_button->font());
+ m_button = new TQPushButton(i18n("..."), this, "m_button");
+ TQToolTip::add(m_button, i18n("Insert image from file"));
+ m_button->tqsetSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed);
+ TQFontMetrics fm(m_button->font());
m_button->setFixedWidth(fm.width(m_button->text()+' '));
- m_button->setFocusPolicy(NoFocus);
+ m_button->setFocusPolicy(TQ_NoFocus);
- m_popup = new QLabel(0, "m_popup", Qt::WStyle_Customize|Qt::WStyle_NoBorder|Qt::WX11BypassWM|WStyle_StaysOnTop);
- m_popup->setPaletteBackgroundColor(m_popup->palette().active().base());
- m_popup->setFrameStyle(QFrame::Plain|QFrame::Box);
+ m_popup = new TQLabel(0, "m_popup", TQt::WStyle_Customize|TQt::WStyle_NoBorder|TQt::WX11BypassWM|WStyle_StaysOnTop);
+ m_popup->setPaletteBackgroundColor(m_popup->tqpalette().active().base());
+ m_popup->setFrameStyle(TQFrame::Plain|TQFrame::Box);
m_popup->setMargin(2);
m_popup->setLineWidth(1);
m_popup->hide();
setFocusWidget(m_edit);
- connect(m_button, SIGNAL(clicked()), this, SLOT(selectPixmap()));
+ connect(m_button, TQT_SIGNAL(clicked()), this, TQT_SLOT(selectPixmap()));
}
PixmapEdit::~PixmapEdit()
@@ -88,14 +88,14 @@ PixmapEdit::~PixmapEdit()
delete m_popup;
}
-QVariant
+TQVariant
PixmapEdit::value() const
{
return m_pixmap;
}
void
-PixmapEdit::setValue(const QVariant &value, bool emitChange)
+PixmapEdit::setValue(const TQVariant &value, bool emitChange)
{
m_pixmap = value.toPixmap();
if (m_pixmap.isNull() || (m_pixmap.height()<=height())) {
@@ -103,16 +103,16 @@ PixmapEdit::setValue(const QVariant &value, bool emitChange)
m_previewPixmap = m_pixmap;
}
else {
- QImage img(m_pixmap.convertToImage());
- if (!QRect(QPoint(0,0), m_edit->size()*3).contains(m_pixmap.rect())) {
- img = img.smoothScale(m_edit->size()*3, QImage::ScaleMin);
+ TQImage img(m_pixmap.convertToImage());
+ if (!TQRect(TQPoint(0,0), m_edit->size()*3).tqcontains(m_pixmap.rect())) {
+ img = img.smoothScale(m_edit->size()*3, TQ_ScaleMin);
m_previewPixmap.convertFromImage(img);//preview pixmap is a bit larger
}
else {
m_previewPixmap = m_pixmap;
}
- img = img.smoothScale(m_edit->size(), QImage::ScaleMin);
- QPixmap pm;
+ img = img.smoothScale(m_edit->size(), TQ_ScaleMin);
+ TQPixmap pm;
pm.convertFromImage(img);
m_edit->setPixmap(pm);
}
@@ -121,11 +121,11 @@ PixmapEdit::setValue(const QVariant &value, bool emitChange)
}
void
-PixmapEdit::drawViewer(QPainter *p, const QColorGroup &, const QRect &r, const QVariant &value)
+PixmapEdit::drawViewer(TQPainter *p, const TQColorGroup &, const TQRect &r, const TQVariant &value)
{
- QRect r2(r);
+ TQRect r2(r);
r2.setHeight(r2.height()+1);
- p->setClipRect(r2, QPainter::CoordPainter);
+ p->setClipRect(r2, TQPainter::CoordPainter);
p->setClipping(true);
p->eraseRect(r2);
if (value.toPixmap().isNull())
@@ -134,8 +134,8 @@ PixmapEdit::drawViewer(QPainter *p, const QColorGroup &, const QRect &r, const Q
m_recentlyPainted = value;
m_scaledPixmap = value.toPixmap();
if (m_scaledPixmap.height() > r2.height() || m_scaledPixmap.width() > r2.width()) { //scale down
- QImage img(m_scaledPixmap.convertToImage());
- img = img.smoothScale(r2.size()/*+QSize(0,2)*/, QImage::ScaleMin);
+ TQImage img(m_scaledPixmap.convertToImage());
+ img = img.smoothScale(r2.size()/*+TQSize(0,2)*/, TQ_ScaleMin);
m_scaledPixmap.convertFromImage(img);
}
}
@@ -143,27 +143,27 @@ PixmapEdit::drawViewer(QPainter *p, const QColorGroup &, const QRect &r, const Q
r2.topLeft().y()+(r2.height()-m_scaledPixmap.height())/2, m_scaledPixmap);
}
-QString
+TQString
PixmapEdit::selectPixmapFileName()
{
/*#ifdef PURE_QT
- QString url = QFileDialog::getOpenFileName();
+ TQString url = TQFileDialog::getOpenFileName();
if (!url.isEmpty()) {
- m_edit->setPixmap(QPixmap(url));
+ m_edit->setPixmap(TQPixmap(url));
emit valueChanged(this);
}
#endif*/
- QString caption( i18n("Insert Image From File (for \"%1\" property)").arg(property()->caption()) );
-#ifdef Q_WS_WIN
- QString recentDir;
- QString fileName = QFileDialog::getOpenFileName(
+ TQString caption( i18n("Insert Image From File (for \"%1\" property)").tqarg(property()->caption()) );
+#ifdef TQ_WS_WIN
+ TQString recentDir;
+ TQString fileName = TQFileDialog::getOpenFileName(
KFileDialog::getStartURL(":lastVisitedImagePath", recentDir).path(),
- convertKFileDialogFilterToQFileDialogFilter(KImageIO::pattern(KImageIO::Reading)),
+ convertKFileDialogFilterToTQFileDialogFilter(KImageIO::pattern(KImageIO::Reading)),
this, 0, caption);
#else
KURL url( KFileDialog::getImageOpenURL(
":lastVisitedImagePath", this, caption) );
- QString fileName = url.isLocalFile() ? url.path() : url.prettyURL();
+ TQString fileName = url.isLocalFile() ? url.path() : url.prettyURL();
//! @todo download the file if remote, then set fileName properly
#endif
@@ -173,18 +173,18 @@ PixmapEdit::selectPixmapFileName()
void
PixmapEdit::selectPixmap()
{
- QString fileName( selectPixmapFileName() );
+ TQString fileName( selectPixmapFileName() );
if (fileName.isEmpty())
return;
- QPixmap pm;
+ TQPixmap pm;
if (!pm.load(fileName)) {
//! @todo err msg
return;
}
setValue(pm);
-#ifdef Q_WS_WIN
+#ifdef TQ_WS_WIN
//save last visited path
KURL url(fileName);
if (url.isLocalFile())
@@ -193,41 +193,41 @@ PixmapEdit::selectPixmap()
}
void
-PixmapEdit::resizeEvent(QResizeEvent *e)
+PixmapEdit::resizeEvent(TQResizeEvent *e)
{
Widget::resizeEvent(e);
m_edit->move(0,0);
- m_edit->resize(e->size()-QSize(m_button->width(),-1));
+ m_edit->resize(e->size()-TQSize(m_button->width(),-1));
m_button->move(m_edit->width(),0);
m_button->setFixedSize(m_button->width(), height());
}
bool
-PixmapEdit::eventFilter(QObject *o, QEvent *ev)
+PixmapEdit::eventFilter(TQObject *o, TQEvent *ev)
{
- if(o == m_edit) {
- if(ev->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(ev)->button()==LeftButton) {
+ if(TQT_BASE_OBJECT(o) == m_edit) {
+ if(ev->type() == TQEvent::MouseButtonPress && TQT_TQMOUSEEVENT(ev)->button()==Qt::LeftButton) {
if(m_previewPixmap.height() <= m_edit->height()
&& m_previewPixmap.width() <= m_edit->width())
return false;
m_popup->setPixmap(m_previewPixmap.isNull() ? m_pixmap : m_previewPixmap);
- m_popup->resize(m_previewPixmap.size()+QSize(2*3,2*3));
- QPoint pos = QCursor::pos()+QPoint(3,15);
- QRect screenRect = QApplication::desktop()->availableGeometry( this );
+ m_popup->resize(m_previewPixmap.size()+TQSize(2*3,2*3));
+ TQPoint pos = TQCursor::pos()+TQPoint(3,15);
+ TQRect screenRect = TQApplication::desktop()->availableGeometry( this );
if ((pos.x()+m_popup->width()) > screenRect.width())
pos.setX(screenRect.width()-m_popup->width());
if ((pos.y()+m_popup->height()) > screenRect.height())
- pos.setY(mapToGlobal(QPoint(0,0)).y()-m_popup->height());
+ pos.setY(mapToGlobal(TQPoint(0,0)).y()-m_popup->height());
m_popup->move(pos);
m_popup->show();
}
- else if(ev->type() == QEvent::MouseButtonRelease || ev->type() == QEvent::Hide) {
+ else if(ev->type() == TQEvent::MouseButtonRelease || ev->type() == TQEvent::Hide) {
if(m_popup->isVisible())
m_popup->hide();
}
- else if(ev->type() == QEvent::KeyPress) {
- QKeyEvent* e = static_cast<QKeyEvent*>(ev);
+ else if(ev->type() == TQEvent::KeyPress) {
+ TQKeyEvent* e = TQT_TQKEYEVENT(ev);
if((e->key() == Key_Enter) || (e->key()== Key_Space) || (e->key() == Key_Return)) {
m_button->animateClick();
return true;