diff options
Diffstat (limited to 'src/systemtray.cpp')
-rw-r--r-- | src/systemtray.cpp | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/src/systemtray.cpp b/src/systemtray.cpp index d245a3a..3d65a36 100644 --- a/src/systemtray.cpp +++ b/src/systemtray.cpp @@ -21,17 +21,17 @@ /** KSystemTray2 */ // To draw the systray screenshot image: -#include <qdockwindow.h> -#include <qmovie.h> -#include <qvariant.h> +#include <tqdockwindow.h> +#include <tqmovie.h> +#include <tqvariant.h> #include "linklabel.h" #include "note.h" -#include <qdesktopwidget.h> -#include <qmime.h> -#include <qpainter.h> -#include <qpoint.h> -#include <qpixmap.h> +#include <tqdesktopwidget.h> +#include <tqmime.h> +#include <tqpainter.h> +#include <tqpoint.h> +#include <tqpixmap.h> // To know the program name: #include <kglobal.h> #include <kinstance.h> @@ -51,8 +51,8 @@ #include "global.h" #include "tools.h" -KSystemTray2::KSystemTray2(QWidget *parent, const char *name) - : KSystemTray(parent, name) +KSystemTray2::KSystemTray2(TQWidget *tqparent, const char *name) + : KSystemTray(tqparent, name) { } @@ -60,11 +60,11 @@ KSystemTray2::~KSystemTray2() { } -void KSystemTray2::displayCloseMessage(QString fileMenu) +void KSystemTray2::displayCloseMessage(TQString fileMenu) { /* IDEAS OF IMPROVEMENTS: * - Use queuedMessageBox() but it need a dontAskAgainName parameter - * and image in QMimeSourceFactory shouldn't be removed. + * and image in TQMimeSourceFactory shouldn't be removed. * - Sometimes the systray icon is covered (a passive popup...) * Use XComposite extension, if available, to get the kicker pixmap. * - Perhapse desaturate the area around the proper SysTray icon, @@ -83,7 +83,7 @@ void KSystemTray2::displayCloseMessage(QString fileMenu) fileMenu = i18n("File"); // Some values we need: - QPoint g = mapToGlobal(pos()); + TQPoint g = mapToGlobal(pos()); int desktopWidth = kapp->desktop()->width(); int desktopHeight = kapp->desktop()->height(); int tw = width(); @@ -94,21 +94,21 @@ void KSystemTray2::displayCloseMessage(QString fileMenu) // we should not show that screenshot but only a text! // 1. Determine if the user use a system tray area or not: - QCString screenstr; + TQCString screenstr; screenstr.setNum(qt_xscreen()); - QCString trayatom = "_NET_SYSTEM_TRAY_S" + screenstr; - bool useSystray = (KSelectionWatcher(trayatom).owner() != 0L); + TQCString trayatom = "_NET_SYSTEM_TRAY_S" + screenstr; + bool useSystray = (KSelectionWatcher(trayatom.data()).owner() != 0L); // 2. And then if the icon is visible too (eg. this->show() has been called): useSystray = useSystray && isVisible(); - // 3. Kicker (or another systray manager) can be visible but masked out of + // 3. Kicker (or another systray manager) can be visible but tqmasked out of // the screen (ie. on right or on left of it). We check if the icon isn't // out of screen. if (useSystray) { - QRect deskRect(0, 0, desktopWidth, desktopHeight); - if ( !deskRect.contains(g.x(), g.y()) || - !deskRect.contains(g.x() + tw, g.y() + th) ) + TQRect deskRect(0, 0, desktopWidth, desktopHeight); + if ( !deskRect.tqcontains(g.x(), g.y()) || + !deskRect.tqcontains(g.x() + tw, g.y() + th) ) useSystray = false; } @@ -118,10 +118,10 @@ void KSystemTray2::displayCloseMessage(QString fileMenu) // We are testing if one of the corners is hidden, and if yes, we would enter // a time consuming process (raise kicker and wait some time): // if (kapp->widgetAt(g) != this || -// kapp->widgetAt(g + QPoint(tw-1, 0)) != this || -// kapp->widgetAt(g + QPoint(0, th-1)) != this || -// kapp->widgetAt(g + QPoint(tw-1, th-1)) != this) { - int systrayManagerWinId = topLevelWidget()->winId(); +// kapp->widgetAt(g + TQPoint(tw-1, 0)) != this || +// kapp->widgetAt(g + TQPoint(0, th-1)) != this || +// kapp->widgetAt(g + TQPoint(tw-1, th-1)) != this) { + int systrayManagerWinId = tqtopLevelWidget()->winId(); KWin::forceActiveWindow(systrayManagerWinId); kapp->processEvents(); // Because without it the systrayManager is raised only after the messageBox is displayed // KWin::activateWindow(systrayManagerWinId); @@ -133,13 +133,13 @@ void KSystemTray2::displayCloseMessage(QString fileMenu) // } }*/ -// KMessageBox::information(this, QString::number(g.x()) + ":" + QString::number(g.y()) + ":" + -// QString::number((int)(kapp->widgetAt(g+QPoint(1,1))))); +// KMessageBox::information(this, TQString::number(g.x()) + ":" + TQString::number(g.y()) + ":" + +// TQString::number((int)(kapp->widgetAt(g+TQPoint(1,1))))); - QString message = i18n( + TQString message = i18n( "<p>Closing the main window will keep %1 running in the system tray. " "Use <b>Quit</b> from the <b>Basket</b> menu to quit the application.</p>" - ).arg(KGlobal::instance()->aboutData()->programName()); + ).tqarg(KGlobal::instance()->aboutData()->programName()); // We are sure the systray icon is visible: ouf! if (useSystray) { // Compute size and position of the pixmap to be grabbed: @@ -153,18 +153,18 @@ void KSystemTray2::displayCloseMessage(QString fileMenu) if (y + h > desktopHeight) y = desktopHeight - h; // Grab the desktop and draw a circle arround the icon: - QPixmap shot = QPixmap::grabWindow(qt_xrootwin(), x, y, w, h); - QPainter painter(&shot); + TQPixmap shot = TQPixmap::grabWindow(qt_xrootwin(), x, y, w, h); + TQPainter painter(&shot); const int CIRCLE_MARGINS = 6; const int CIRCLE_WIDTH = 3; const int SHADOW_OFFSET = 1; const int IMAGE_BORDER = 1; int ax = g.x() - x - CIRCLE_MARGINS - 1; int ay = g.y() - y - CIRCLE_MARGINS - 1; - painter.setPen( QPen(KApplication::palette().active().dark(), CIRCLE_WIDTH) ); + painter.setPen( TQPen(KApplication::tqpalette().active().dark(), CIRCLE_WIDTH) ); painter.drawArc(ax + SHADOW_OFFSET, ay + SHADOW_OFFSET, tw + 2*CIRCLE_MARGINS, th + 2*CIRCLE_MARGINS, 0, 16*360); - painter.setPen( QPen(Qt::red/*KApplication::palette().active().highlight()*/, CIRCLE_WIDTH) ); + painter.setPen( TQPen(TQt::red/*KApplication::tqpalette().active().highlight()*/, CIRCLE_WIDTH) ); painter.drawArc(ax, ay, tw + 2*CIRCLE_MARGINS, th + 2*CIRCLE_MARGINS, 0, 16*360); #if 1 // Draw the pixmap over the screenshot in case a window hide the icon: @@ -173,20 +173,20 @@ void KSystemTray2::displayCloseMessage(QString fileMenu) painter.end(); // Then, we add a border arround the image to make it more visible: - QPixmap finalShot(w + 2*IMAGE_BORDER, h + 2*IMAGE_BORDER); - finalShot.fill(KApplication::palette().active().foreground()); + TQPixmap finalShot(w + 2*IMAGE_BORDER, h + 2*IMAGE_BORDER); + finalShot.fill(KApplication::tqpalette().active().foreground()); painter.begin(&finalShot); painter.drawPixmap(IMAGE_BORDER, IMAGE_BORDER, shot); painter.end(); // Associate source to image and show the dialog: - QMimeSourceFactory::defaultFactory()->setPixmap("systray_shot", finalShot); - KMessageBox::information(kapp->activeWindow(), + TQMimeSourceFactory::defaultFactory()->setPixmap("systray_shot", finalShot); + KMessageBox::information(TQT_TQWIDGET(kapp->activeWindow()), message + "<p><center><img source=\"systray_shot\"></center></p>", i18n("Docking in System Tray"), "hideOnCloseInfo"); - QMimeSourceFactory::defaultFactory()->setData("systray_shot", 0L); + TQMimeSourceFactory::defaultFactory()->setData("systray_shot", 0L); } else { - KMessageBox::information(kapp->activeWindow(), + KMessageBox::information(TQT_TQWIDGET(kapp->activeWindow()), message, i18n("Docking in System Tray"), "hideOnCloseInfo"); } @@ -194,25 +194,25 @@ void KSystemTray2::displayCloseMessage(QString fileMenu) /** SystemTray */ -SystemTray::SystemTray(QWidget *parent, const char *name) - : KSystemTray2(parent, name != 0 ? name : "SystemTray"), m_showTimer(0), m_autoShowTimer(0) +SystemTray::SystemTray(TQWidget *tqparent, const char *name) + : KSystemTray2(tqparent, name != 0 ? name : "SystemTray"), m_showTimer(0), m_autoShowTimer(0) { setAcceptDrops(true); - m_showTimer = new QTimer(this); - connect( m_showTimer, SIGNAL(timeout()), Global::bnpView, SLOT(setActive()) ); + m_showTimer = new TQTimer(this); + connect( m_showTimer, TQT_SIGNAL(timeout()), Global::bnpView, TQT_SLOT(setActive()) ); - m_autoShowTimer = new QTimer(this); - connect( m_autoShowTimer, SIGNAL(timeout()), Global::bnpView, SLOT(setActive()) ); + m_autoShowTimer = new TQTimer(this); + connect( m_autoShowTimer, TQT_SIGNAL(timeout()), Global::bnpView, TQT_SLOT(setActive()) ); // Create pixmaps for the icon: m_iconPixmap = loadIcon("basket"); // FIXME: When main window is shown at start, the icon is loaded 1 pixel too high // and then reloaded instantly after at the right position. // setPixmap(m_iconPixmap); // Load it the sooner as possible to avoid flicker - QImage lockedIconImage = m_iconPixmap.convertToImage(); - QPixmap lockOverlayPixmap = loadIcon("lockoverlay"); - QImage lockOverlayImage = lockOverlayPixmap.convertToImage(); + TQImage lockedIconImage = m_iconPixmap.convertToImage(); + TQPixmap lockOverlayPixmap = loadIcon("lockoverlay"); + TQImage lockOverlayImage = lockOverlayPixmap.convertToImage(); KIconEffect::overlay(lockedIconImage, lockOverlayImage); m_lockedIconPixmap.convertFromImage(lockedIconImage); @@ -223,7 +223,7 @@ SystemTray::~SystemTray() { } -void SystemTray::mousePressEvent(QMouseEvent *event) +void SystemTray::mousePressEvent(TQMouseEvent *event) { if (event->button() & Qt::LeftButton) { // Prepare drag m_pressPos = event->globalPos(); @@ -231,7 +231,7 @@ void SystemTray::mousePressEvent(QMouseEvent *event) event->accept(); } else if (event->button() & Qt::MidButton) { // Paste Global::bnpView->currentBasket()->setInsertPopupMenu(); - Global::bnpView->currentBasket()->pasteNote(QClipboard::Selection); + Global::bnpView->currentBasket()->pasteNote(TQClipboard::Selection); Global::bnpView->currentBasket()->cancelInsertPopupMenu(); if (Settings::usePassivePopup()) Global::bnpView->showPassiveDropped(i18n("Pasted selection to basket <i>%1</i>")); @@ -281,23 +281,23 @@ void SystemTray::mousePressEvent(QMouseEvent *event) } Global::bnpView->currentBasket()->setInsertPopupMenu(); - connect( &menu, SIGNAL(aboutToHide()), Global::bnpView->currentBasket(), SLOT(delayedCancelInsertPopupMenu()) ); + connect( &menu, TQT_SIGNAL(aboutToHide()), Global::bnpView->currentBasket(), TQT_SLOT(delayedCancelInsertPopupMenu()) ); menu.exec(event->globalPos()); event->accept(); } else event->ignore(); } -void SystemTray::mouseMoveEvent(QMouseEvent *event) +void SystemTray::mouseMoveEvent(TQMouseEvent *event) { event->ignore(); } -void SystemTray::mouseReleaseEvent(QMouseEvent *event) +void SystemTray::mouseReleaseEvent(TQMouseEvent *event) { m_canDrag = false; if (event->button() == Qt::LeftButton) // Show / hide main window - if ( rect().contains(event->pos()) ) { // Accept only if released in systemTray + if ( TQT_TQRECT_OBJECT(rect()).tqcontains(event->pos()) ) { // Accept only if released in systemTray toggleActive(); emit showPart(); event->accept(); @@ -305,7 +305,7 @@ void SystemTray::mouseReleaseEvent(QMouseEvent *event) event->ignore(); } -void SystemTray::dragEnterEvent(QDragEnterEvent *event) +void SystemTray::dragEnterEvent(TQDragEnterEvent *event) { m_showTimer->start( Settings::dropTimeToShow() * 100, true ); Global::bnpView->currentBasket()->showFrameInsertTo(); @@ -313,12 +313,12 @@ void SystemTray::dragEnterEvent(QDragEnterEvent *event) Basket::acceptDropEvent(event); } -void SystemTray::dragMoveEvent(QDragMoveEvent *event) +void SystemTray::dragMoveEvent(TQDragMoveEvent *event) { Basket::acceptDropEvent(event); } -void SystemTray::dragLeaveEvent(QDragLeaveEvent*) +void SystemTray::dragLeaveEvent(TQDragLeaveEvent*) { m_showTimer->stop(); m_canDrag = false; @@ -328,7 +328,7 @@ void SystemTray::dragLeaveEvent(QDragLeaveEvent*) #include <iostream> -void SystemTray::dropEvent(QDropEvent *event) +void SystemTray::dropEvent(TQDropEvent *event) { m_showTimer->stop(); @@ -350,10 +350,10 @@ void SystemTray::dropEvent(QDropEvent *event) /* * This function copies the entirety of src into dest, starting in - * dest at x and y. This function exists because I was unable to find - * a function like it in either QImage or kdefx + * dest at x and y. This function exists because I was unable to tqfind + * a function like it in either TQImage or kdefx */ -static bool copyImage(QImage &dest, QImage &src, int x, int y) +static bool copyImage(TQImage &dest, TQImage &src, int x, int y) { if(dest.depth() != src.depth()) return false; @@ -365,7 +365,7 @@ static bool copyImage(QImage &dest, QImage &src, int x, int y) // We want to use KIconEffect::overlay to do this, since it handles // alpha, but the images need to be the same size. We can handle that. - QImage large_src(dest); + TQImage large_src(dest); // It would perhaps be better to create large_src based on a size, but // this is the easiest way to make a new image with the same depth, size, @@ -405,12 +405,12 @@ void SystemTray::updateToolTip() setPixmap(basket->isLocked() ? m_lockedIconPixmap : m_iconPixmap); else { // Code that comes from JuK: - QPixmap bgPix = loadIcon("basket"); - QPixmap fgPix = SmallIcon(basket->icon()); + TQPixmap bgPix = loadIcon("basket"); + TQPixmap fgPix = SmallIcon(basket->icon()); - QImage bgImage = bgPix.convertToImage(); // Probably 22x22 - QImage fgImage = fgPix.convertToImage(); // Should be 16x16 - QImage lockOverlayImage = loadIcon("lockoverlay").convertToImage(); + TQImage bgImage = bgPix.convertToImage(); // Probably 22x22 + TQImage fgImage = fgPix.convertToImage(); // Should be 16x16 + TQImage lockOverlayImage = loadIcon("lockoverlay").convertToImage(); KIconEffect::semiTransparent(bgImage); copyImage(bgImage, fgImage, (bgImage.width() - fgImage.width()) / 2, @@ -422,7 +422,7 @@ void SystemTray::updateToolTip() setPixmap(bgPix); } - //QTimer::singleShot( Container::c_delayTooltipTime, this, SLOT(updateToolTipDelayed()) ); + //TQTimer::singleShot( Container::c_delayTooltipTime, this, TQT_SLOT(updateToolTipDelayed()) ); // No need to delay: it's be called when notes are changed: updateToolTipDelayed(); } @@ -431,14 +431,14 @@ void SystemTray::updateToolTipDelayed() { Basket *basket = Global::bnpView->currentBasket(); - QString tip = "<p><nobr>" + ( basket->isLocked() ? kapp->makeStdCaption(i18n("%1 (Locked)")) + TQString tip = "<p><nobr>" + ( basket->isLocked() ? kapp->makeStdCaption(i18n("%1 (Locked)")) : kapp->makeStdCaption( "%1") ) - .arg(Tools::textToHTMLWithoutP(basket->basketName())); + .tqarg(Tools::textToHTMLWithoutP(basket->basketName())); - QToolTip::add(this, tip); + TQToolTip::add(this, tip); } -void SystemTray::wheelEvent(QWheelEvent *event) +void SystemTray::wheelEvent(TQWheelEvent *event) { if (event->delta() > 0) Global::bnpView->goToPreviousBasket(); @@ -449,13 +449,13 @@ void SystemTray::wheelEvent(QWheelEvent *event) Global::bnpView->showPassiveContent(); } -void SystemTray::enterEvent(QEvent*) +void SystemTray::enterEvent(TQEvent*) { if (Settings::showOnMouseIn()) m_autoShowTimer->start(Settings::timeToShowOnMouseIn() * 100, true ); } -void SystemTray::leaveEvent(QEvent*) +void SystemTray::leaveEvent(TQEvent*) { m_autoShowTimer->stop(); } |