summaryrefslogtreecommitdiffstats
path: root/kicker-applets/kolourpicker/kolourpicker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kicker-applets/kolourpicker/kolourpicker.cpp')
-rw-r--r--kicker-applets/kolourpicker/kolourpicker.cpp112
1 files changed, 56 insertions, 56 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;