diff options
Diffstat (limited to 'kicker-applets/kolourpicker')
-rw-r--r-- | kicker-applets/kolourpicker/kolourpicker.cpp | 112 | ||||
-rw-r--r-- | kicker-applets/kolourpicker/kolourpicker.h | 26 | ||||
-rw-r--r-- | kicker-applets/kolourpicker/simplebutton.cpp | 84 | ||||
-rw-r--r-- | kicker-applets/kolourpicker/simplebutton.h | 38 |
4 files changed, 130 insertions, 130 deletions
diff --git a/kicker-applets/kolourpicker/kolourpicker.cpp b/kicker-applets/kolourpicker/kolourpicker.cpp index 98f5302..cadbb2d 100644 --- a/kicker-applets/kolourpicker/kolourpicker.cpp +++ b/kicker-applets/kolourpicker/kolourpicker.cpp @@ -19,16 +19,16 @@ $Id$ */ -#include <qfile.h> -#include <qtextstream.h> -#include <qlayout.h> -#include <qimage.h> -#include <qclipboard.h> -#include <qregexp.h> -#include <qbitmap.h> -#include <qpainter.h> -#include <qtooltip.h> -#include <qcursor.h> +#include <tqfile.h> +#include <tqtextstream.h> +#include <tqlayout.h> +#include <tqimage.h> +#include <tqclipboard.h> +#include <tqregexp.h> +#include <tqbitmap.h> +#include <tqpainter.h> +#include <tqtooltip.h> +#include <tqcursor.h> #include <kglobal.h> #include <klocale.h> @@ -48,7 +48,7 @@ $Id$ // Applet initialization function extern "C" { - KDE_EXPORT KPanelApplet* init(QWidget *parent, const QString& configFile) + KDE_EXPORT KPanelApplet* init(TQWidget *parent, const TQString& configFile) { KGlobal::locale()->insertCatalogue("kolourpicker"); return new KolourPicker(configFile, KPanelApplet::Normal, @@ -57,8 +57,8 @@ extern "C" } } -KolourPicker::KolourPicker(const QString& configFile, Type type, - int actions, QWidget *parent, const char *name) +KolourPicker::KolourPicker(const TQString& configFile, Type type, + int actions, TQWidget *parent, const char *name) : KPanelApplet(configFile, type, actions, parent, name), m_picking(0) { @@ -73,17 +73,17 @@ KolourPicker::KolourPicker(const QString& configFile, Type type, KConfig *conf = config(); conf->setGroup("General"); - QStringList history = conf->readListEntry("History"); - for (QStringList::ConstIterator it = history.begin(); it != history.end(); ++it) - m_history.append(QColor(*it)); + TQStringList history = conf->readListEntry("History"); + for (TQStringList::ConstIterator it = history.begin(); it != history.end(); ++it) + m_history.append(TQColor(*it)); setBackgroundOrigin(AncestorOrigin); m_colourButton = new SimpleButton(this); m_colourButton->setPixmap(SmallIcon("colorpicker")); m_colourButton->setFixedSize(20, 20); - QToolTip::add(m_colourButton, i18n("Pick a color")); - connect(m_colourButton, SIGNAL(clicked()), SLOT(slotPick())); + TQToolTip::add(m_colourButton, i18n("Pick a color")); + connect(m_colourButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotPick())); m_historyButton = new SimpleButton(this); m_historyButton->setFixedSize(20, 20); @@ -91,11 +91,11 @@ KolourPicker::KolourPicker(const QString& configFile, Type type, m_historyButton->setPixmap(colorPixmap(m_history.last())); else { - m_historyButton->setPixmap(colorPixmap(QColor())); + m_historyButton->setPixmap(colorPixmap(TQColor())); m_historyButton->setEnabled(false); } - QToolTip::add(m_historyButton, i18n("History")); - connect(m_historyButton, SIGNAL(clicked()), SLOT(slotHistory())); + TQToolTip::add(m_historyButton, i18n("History")); + connect(m_historyButton, TQT_SIGNAL(clicked()), TQT_SLOT(slotHistory())); } KolourPicker::~KolourPicker() @@ -131,21 +131,21 @@ void KolourPicker::slotHistory() { KPopupMenu popup; popup.insertTitle(SmallIcon("colorize"), i18n("History")); - QPtrList<QPopupMenu> subMenus; + TQPtrList<TQPopupMenu> subMenus; subMenus.setAutoDelete(true); - for (QValueList<QColor>::ConstIterator it = m_history.fromLast(); + for (TQValueList<TQColor>::ConstIterator it = m_history.fromLast(); it != m_history.end(); --it) { - QPopupMenu *sub = copyPopup(*it, false); + TQPopupMenu *sub = copyPopup(*it, false); subMenus.append(sub); popup.insertItem(colorPixmap(*it), - QString("%1, %2, %3").arg((*it).red()).arg((*it).green()).arg((*it).blue()), + TQString("%1, %2, %3").arg((*it).red()).arg((*it).green()).arg((*it).blue()), sub); } popup.insertSeparator(); int clear = popup.insertItem(SmallIcon("history_clear"), i18n("&Clear History")); - int id = popup.exec(QCursor::pos()); + int id = popup.exec(TQCursor::pos()); if (id == clear) { m_history.clear(); @@ -153,28 +153,28 @@ void KolourPicker::slotHistory() arrangeButtons(); KConfig *conf = config(); conf->setGroup("General"); - conf->writeEntry("History", QStringList()); + conf->writeEntry("History", TQStringList()); conf->sync(); } else if (id != -1) setClipboard(popup.findItem(id)->text()); } -void KolourPicker::mouseReleaseEvent(QMouseEvent *e) +void KolourPicker::mouseReleaseEvent(TQMouseEvent *e) { if (m_picking) { m_picking = false; releaseMouse(); releaseKeyboard(); - QWidget *desktop = QApplication::desktop(); - QPixmap pm = QPixmap::grabWindow(desktop->winId(), + TQWidget *desktop = TQApplication::desktop(); + TQPixmap pm = TQPixmap::grabWindow(desktop->winId(), e->globalPos().x(), e->globalPos().y(), 1, 1); - QImage img = pm.convertToImage(); - QColor color(img.pixel(0, 0)); + TQImage img = pm.convertToImage(); + TQColor color(img.pixel(0, 0)); // eventually remove a dupe - QValueListIterator<QColor> dupe = m_history.find(color); + TQValueListIterator<TQColor> dupe = m_history.find(color); if (dupe != m_history.end()) m_history.remove(dupe); @@ -183,8 +183,8 @@ void KolourPicker::mouseReleaseEvent(QMouseEvent *e) m_history.remove(m_history.begin()); m_historyButton->setEnabled(true); arrangeButtons(); - QStringList history; - for (QValueList<QColor>::ConstIterator it = m_history.begin(); + TQStringList history; + for (TQValueList<TQColor>::ConstIterator it = m_history.begin(); it != m_history.end(); ++it) { @@ -195,7 +195,7 @@ void KolourPicker::mouseReleaseEvent(QMouseEvent *e) conf->writeEntry("History", history); conf->sync(); m_historyButton->setPixmap(colorPixmap(color)); - QPopupMenu *popup = copyPopup(color, true); + TQPopupMenu *popup = copyPopup(color, true); int id = popup->exec(e->globalPos()); if (id != -1) setClipboard( popup->findItem(id)->text() ); @@ -206,9 +206,9 @@ void KolourPicker::mouseReleaseEvent(QMouseEvent *e) } // set both clipboard and selection -void KolourPicker::setClipboard(const QString& text) +void KolourPicker::setClipboard(const TQString& text) { - QClipboard *clip = QApplication::clipboard(); + QClipboard *clip = TQApplication::clipboard(); bool oldMode = clip->selectionModeEnabled(); clip->setSelectionMode(true); clip->setText(text); @@ -217,7 +217,7 @@ void KolourPicker::setClipboard(const QString& text) clip->setSelectionMode( oldMode ); } -void KolourPicker::keyPressEvent(QKeyEvent *e) +void KolourPicker::keyPressEvent(TQKeyEvent *e) { if (m_picking) { @@ -233,7 +233,7 @@ void KolourPicker::keyPressEvent(QKeyEvent *e) KPanelApplet::keyPressEvent(e); } -void KolourPicker::resizeEvent(QResizeEvent *) +void KolourPicker::resizeEvent(TQResizeEvent *) { arrangeButtons(); } @@ -282,19 +282,19 @@ void KolourPicker::arrangeButtons() updateGeometry(); } -QPopupMenu *KolourPicker::copyPopup(const QColor &c, bool title) const +TQPopupMenu *KolourPicker::copyPopup(const TQColor &c, bool title) const { KPopupMenu *popup = new KPopupMenu; if (title) popup->insertTitle(colorPixmap(c), i18n("Copy Color Value")); - QString value; + TQString value; // r, g, b value.sprintf("%u, %u, %u", c.red(), c.green(), c.blue()); popup->insertItem(SmallIcon("text"), value); // HTML, lower case hex chars value.sprintf("#%.2x%.2x%.2x", c.red(), c.green(), c.blue()); popup->insertItem(SmallIcon("html"), value); - if (value.find(QRegExp("[a-f]")) >= 0) + if (value.find(TQRegExp("[a-f]")) >= 0) { // HTML, upper case hex chars value.sprintf("#%.2X%.2X%.2X", c.red(), c.green(), c.blue()); @@ -303,26 +303,26 @@ QPopupMenu *KolourPicker::copyPopup(const QColor &c, bool title) const // lower case hex chars value.sprintf( "%.2x%.2x%.2x", c.red(), c.green(), c.blue() ); popup->insertItem( SmallIcon( "html" ), value ); - if ( value.find( QRegExp( "[a-f]" ) ) >= 0 ) + if ( value.find( TQRegExp( "[a-f]" ) ) >= 0 ) { // upper case hex chars value.sprintf( "%.2X%.2X%.2X", c.red(), c.green(), c.blue() ); popup->insertItem( SmallIcon( "html" ), value ); } // Color name - QStringList names = colorNames(c.red(), c.green(), c.blue()); - for (QStringList::ConstIterator it = names.begin(); it != names.end(); ++it) + TQStringList names = colorNames(c.red(), c.green(), c.blue()); + for (TQStringList::ConstIterator it = names.begin(); it != names.end(); ++it) popup->insertItem(SmallIcon("text"), *it); return popup; } #define AAFACTOR 4 -QPixmap KolourPicker::colorPixmap(const QColor &c) const +TQPixmap KolourPicker::colorPixmap(const TQColor &c) const { int x, y, dx, dy, d; - QImage img(16 * AAFACTOR, 16 * AAFACTOR, 32); + TQImage img(16 * AAFACTOR, 16 * AAFACTOR, 32); img.setAlphaBuffer(true); img.fill(0); @@ -339,30 +339,30 @@ QPixmap KolourPicker::colorPixmap(const QColor &c) const img.setPixel(x, y, qRgba(128, 128, 128, 255)); } - QBitmap mask(16, 16); + TQBitmap mask(16, 16); mask.fill(Qt::color0); - QPainter p(&mask); + TQPainter p(&mask); p.setPen(Qt::NoPen); p.setBrush(Qt::color1); p.drawEllipse(0, 0, 15, 15); p.end(); - QPixmap pm = QPixmap(img.smoothScale(16, 16)); + TQPixmap pm = TQPixmap(img.smoothScale(16, 16)); pm.setMask(mask); return pm; } -const QStringList &KolourPicker::colorNames(int r, int g, int b) const +const TQStringList &KolourPicker::colorNames(int r, int g, int b) const { - static QStringList NullList; + static TQStringList NullList; if (m_colorNames.isEmpty()) { - QFile f("/usr/lib/X11/rgb.txt"); + TQFile f("/usr/lib/X11/rgb.txt"); if (!f.open(IO_ReadOnly)) return NullList; - QTextStream str(&f); - QString red, green, blue; + TQTextStream str(&f); + TQString red, green, blue; while (!str.atEnd()) { str >> red; diff --git a/kicker-applets/kolourpicker/kolourpicker.h b/kicker-applets/kolourpicker/kolourpicker.h index 0b576e9..20780f9 100644 --- a/kicker-applets/kolourpicker/kolourpicker.h +++ b/kicker-applets/kolourpicker/kolourpicker.h @@ -21,8 +21,8 @@ #ifndef _KOLOURPICKER_H_ #define _KOLOURPICKER_H_ -#include <qmap.h> -#include <qvaluelist.h> +#include <tqmap.h> +#include <tqvaluelist.h> #include <kpanelapplet.h> @@ -35,34 +35,34 @@ class KolourPicker : public KPanelApplet { Q_OBJECT public: - KolourPicker(const QString& configFile, Type t = Normal, int actions = 0, - QWidget *parent = 0, const char *name = 0); + KolourPicker(const TQString& configFile, Type t = Normal, int actions = 0, + TQWidget *parent = 0, const char *name = 0); ~KolourPicker(); virtual int heightForWidth(int) const; virtual int widthForHeight(int) const; virtual void about(); protected: - virtual void mouseReleaseEvent(QMouseEvent *); - virtual void keyPressEvent(QKeyEvent *); - virtual void resizeEvent(QResizeEvent*); + virtual void mouseReleaseEvent(TQMouseEvent *); + virtual void keyPressEvent(TQKeyEvent *); + virtual void resizeEvent(TQResizeEvent*); private slots: void slotPick(); void slotHistory(); private: - QPopupMenu *copyPopup(const QColor &, bool title) const; - QPixmap colorPixmap(const QColor &) const; - const QStringList &colorNames(int r, int g, int b) const; + TQPopupMenu *copyPopup(const TQColor &, bool title) const; + TQPixmap colorPixmap(const TQColor &) const; + const TQStringList &colorNames(int r, int g, int b) const; void arrangeButtons(); - void setClipboard(const QString& text); + void setClipboard(const TQString& text); KInstance *m_instance; bool m_picking; SimpleButton *m_historyButton, *m_colourButton; - QValueList<QColor> m_history; - QMap<int, QStringList> m_colorNames; + TQValueList<TQColor> m_history; + TQMap<int, TQStringList> m_colorNames; }; #endif diff --git a/kicker-applets/kolourpicker/simplebutton.cpp b/kicker-applets/kolourpicker/simplebutton.cpp index 9daa926..478ca2d 100644 --- a/kicker-applets/kolourpicker/simplebutton.cpp +++ b/kicker-applets/kolourpicker/simplebutton.cpp @@ -20,8 +20,8 @@ #include "simplebutton.h" -#include <qpainter.h> -#include <qstyle.h> +#include <tqpainter.h> +#include <tqstyle.h> #include <kapplication.h> #include <kcursor.h> @@ -32,17 +32,17 @@ #include <kipc.h> #include <kstandarddirs.h> -SimpleButton::SimpleButton(QWidget *parent, const char *name) - : QButton(parent, name), +SimpleButton::SimpleButton(TQWidget *parent, const char *name) + : TQButton(parent, name), m_highlight(false), m_orientation(Qt::Horizontal) { setBackgroundOrigin( AncestorOrigin ); - connect( kapp, SIGNAL( settingsChanged( int ) ), - SLOT( slotSettingsChanged( int ) ) ); - connect( kapp, SIGNAL( iconChanged( int ) ), - SLOT( slotIconChanged( int ) ) ); + connect( kapp, TQT_SIGNAL( settingsChanged( int ) ), + TQT_SLOT( slotSettingsChanged( int ) ) ); + connect( kapp, TQT_SIGNAL( iconChanged( int ) ), + TQT_SLOT( slotIconChanged( int ) ) ); kapp->addKipcEventMask( KIPC::SettingsChanged ); kapp->addKipcEventMask( KIPC::IconChanged ); @@ -50,9 +50,9 @@ SimpleButton::SimpleButton(QWidget *parent, const char *name) slotSettingsChanged( KApplication::SETTINGS_MOUSE ); } -void SimpleButton::setPixmap(const QPixmap &pix) +void SimpleButton::setPixmap(const TQPixmap &pix) { - QButton::setPixmap(pix); + TQButton::setPixmap(pix); generateIcons(); update(); } @@ -63,39 +63,39 @@ void SimpleButton::setOrientation(Qt::Orientation orientation) update(); } -QSize SimpleButton::sizeHint() const +TQSize SimpleButton::sizeHint() const { - const QPixmap* pm = pixmap(); + const TQPixmap* pm = pixmap(); if (!pm) - return QButton::sizeHint(); + return TQButton::sizeHint(); else - return QSize(pm->width() + KDialog::spacingHint(), pm->height() + KDialog::spacingHint()); + return TQSize(pm->width() + KDialog::spacingHint(), pm->height() + KDialog::spacingHint()); } -QSize SimpleButton::minimumSizeHint() const +TQSize SimpleButton::minimumSizeHint() const { - const QPixmap* pm = pixmap(); + const TQPixmap* pm = pixmap(); if (!pm) - return QButton::minimumSizeHint(); + return TQButton::minimumSizeHint(); else - return QSize(pm->width(), pm->height()); + return TQSize(pm->width(), pm->height()); } -void SimpleButton::drawButton( QPainter *p ) +void SimpleButton::drawButton( TQPainter *p ) { drawButtonLabel(p); } -void SimpleButton::drawButtonLabel( QPainter *p ) +void SimpleButton::drawButtonLabel( TQPainter *p ) { if (!pixmap()) { return; } - QPixmap pix = isEnabled() ? (m_highlight? m_activeIcon : m_normalIcon) : m_disabledIcon; + TQPixmap pix = isEnabled() ? (m_highlight? m_activeIcon : m_normalIcon) : m_disabledIcon; if (isOn() || isDown()) { @@ -108,7 +108,7 @@ void SimpleButton::drawButtonLabel( QPainter *p ) int ph = pix.height(); int pw = pix.width(); int margin = KDialog::spacingHint(); - QPoint origin(margin / 2, margin / 2); + TQPoint origin(margin / 2, margin / 2); if (ph < (h - margin)) { @@ -130,7 +130,7 @@ void SimpleButton::generateIcons() return; } - QImage image = pixmap()->convertToImage(); + TQImage image = pixmap()->convertToImage(); KIconEffect effect; m_normalIcon = effect.apply(image, KIcon::Panel, KIcon::DefaultState); @@ -170,29 +170,29 @@ void SimpleButton::slotIconChanged( int group ) update(); } -void SimpleButton::enterEvent( QEvent *e ) +void SimpleButton::enterEvent( TQEvent *e ) { m_highlight = true; repaint( false ); - QButton::enterEvent( e ); + TQButton::enterEvent( e ); } -void SimpleButton::leaveEvent( QEvent *e ) +void SimpleButton::leaveEvent( TQEvent *e ) { m_highlight = false; repaint( false ); - QButton::enterEvent( e ); + TQButton::enterEvent( e ); } -void SimpleButton::resizeEvent( QResizeEvent * ) +void SimpleButton::resizeEvent( TQResizeEvent * ) { generateIcons(); } -SimpleArrowButton::SimpleArrowButton(QWidget *parent, Qt::ArrowType arrow, const char *name) +SimpleArrowButton::SimpleArrowButton(TQWidget *parent, Qt::ArrowType arrow, const char *name) : SimpleButton(parent, name) { setBackgroundOrigin(AncestorOrigin); @@ -200,9 +200,9 @@ SimpleArrowButton::SimpleArrowButton(QWidget *parent, Qt::ArrowType arrow, const _inside = false; } -QSize SimpleArrowButton::sizeHint() const +TQSize SimpleArrowButton::sizeHint() const { - return QSize( 12, 12 ); + return TQSize( 12, 12 ); } void SimpleArrowButton::setArrowType(Qt::ArrowType a) @@ -219,32 +219,32 @@ Qt::ArrowType SimpleArrowButton::arrowType() const return _arrow; } -void SimpleArrowButton::drawButton( QPainter *p ) +void SimpleArrowButton::drawButton( TQPainter *p ) { - QRect r(1, 1, width() - 2, height() - 2); + TQRect r(1, 1, width() - 2, height() - 2); - QStyle::PrimitiveElement pe = QStyle::PE_ArrowLeft; + TQStyle::PrimitiveElement pe = TQStyle::PE_ArrowLeft; switch (_arrow) { - case Qt::LeftArrow: pe = QStyle::PE_ArrowLeft; break; - case Qt::RightArrow: pe = QStyle::PE_ArrowRight; break; - case Qt::UpArrow: pe = QStyle::PE_ArrowUp; break; - case Qt::DownArrow: pe = QStyle::PE_ArrowDown; break; + case Qt::LeftArrow: pe = TQStyle::PE_ArrowLeft; break; + case Qt::RightArrow: pe = TQStyle::PE_ArrowRight; break; + case Qt::UpArrow: pe = TQStyle::PE_ArrowUp; break; + case Qt::DownArrow: pe = TQStyle::PE_ArrowDown; break; } - int flags = QStyle::Style_Default | QStyle::Style_Enabled; - if (isDown() || isOn()) flags |= QStyle::Style_Down; + int flags = TQStyle::Style_Default | TQStyle::Style_Enabled; + if (isDown() || isOn()) flags |= TQStyle::Style_Down; style().drawPrimitive(pe, p, r, colorGroup(), flags); } -void SimpleArrowButton::enterEvent( QEvent *e ) +void SimpleArrowButton::enterEvent( TQEvent *e ) { _inside = true; SimpleButton::enterEvent( e ); update(); } -void SimpleArrowButton::leaveEvent( QEvent *e ) +void SimpleArrowButton::leaveEvent( TQEvent *e ) { _inside = false; SimpleButton::enterEvent( e ); diff --git a/kicker-applets/kolourpicker/simplebutton.h b/kicker-applets/kolourpicker/simplebutton.h index 5423dff..1ea5c7a 100644 --- a/kicker-applets/kolourpicker/simplebutton.h +++ b/kicker-applets/kolourpicker/simplebutton.h @@ -21,8 +21,8 @@ #ifndef SIMPLEBUTTON_H #define SIMPLEBUTTON_H -#include <qbutton.h> -#include <qpixmap.h> +#include <tqbutton.h> +#include <tqpixmap.h> #include <kdemacros.h> @@ -31,20 +31,20 @@ class KDE_EXPORT SimpleButton : public QButton Q_OBJECT public: - SimpleButton(QWidget *parent, const char *name = 0); - void setPixmap(const QPixmap &pix); + SimpleButton(TQWidget *parent, const char *name = 0); + void setPixmap(const TQPixmap &pix); void setOrientation(Qt::Orientation orientaton); - QSize sizeHint() const; - QSize minimumSizeHint() const; + TQSize sizeHint() const; + TQSize minimumSizeHint() const; protected: - void drawButton( QPainter *p ); - void drawButtonLabel( QPainter *p ); + void drawButton( TQPainter *p ); + void drawButtonLabel( TQPainter *p ); void generateIcons(); - void enterEvent( QEvent *e ); - void leaveEvent( QEvent *e ); - void resizeEvent( QResizeEvent *e ); + void enterEvent( TQEvent *e ); + void leaveEvent( TQEvent *e ); + void resizeEvent( TQResizeEvent *e ); protected slots: virtual void slotSettingsChanged( int category ); @@ -52,9 +52,9 @@ class KDE_EXPORT SimpleButton : public QButton private: bool m_highlight; - QPixmap m_normalIcon; - QPixmap m_activeIcon; - QPixmap m_disabledIcon; + TQPixmap m_normalIcon; + TQPixmap m_activeIcon; + TQPixmap m_disabledIcon; Qt::Orientation m_orientation; class SimpleButtonPrivate; SimpleButtonPrivate* d; @@ -65,14 +65,14 @@ class KDE_EXPORT SimpleArrowButton: public SimpleButton Q_OBJECT public: - SimpleArrowButton(QWidget *parent = 0, Qt::ArrowType arrow = Qt::UpArrow, const char *name = 0); + SimpleArrowButton(TQWidget *parent = 0, Qt::ArrowType arrow = Qt::UpArrow, const char *name = 0); virtual ~SimpleArrowButton() {}; - QSize sizeHint() const; + TQSize sizeHint() const; protected: - virtual void enterEvent( QEvent *e ); - virtual void leaveEvent( QEvent *e ); - virtual void drawButton(QPainter *p); + virtual void enterEvent( TQEvent *e ); + virtual void leaveEvent( TQEvent *e ); + virtual void drawButton(TQPainter *p); Qt::ArrowType arrowType() const; public slots: |