diff options
Diffstat (limited to 'src/traylabelmgr.cpp')
-rw-r--r-- | src/traylabelmgr.cpp | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/src/traylabelmgr.cpp b/src/traylabelmgr.cpp index cbc007f..61dfd7e 100644 --- a/src/traylabelmgr.cpp +++ b/src/traylabelmgr.cpp @@ -19,15 +19,15 @@ // $Id: traylabelmgr.cpp,v 1.10 2005/02/09 03:38:43 cs19713 Exp $ -#include <qdir.h> -#include <qapplication.h> -#include <qmessagebox.h> -#include <qtimer.h> -#include <qfile.h> -#include <qaction.h> -#include <qpopupmenu.h> -#include <qtextstream.h> -#include <qfiledialog.h> +#include <tqdir.h> +#include <tqapplication.h> +#include <tqmessagebox.h> +#include <tqtimer.h> +#include <tqfile.h> +#include <tqaction.h> +#include <tqpopupmenu.h> +#include <tqtextstream.h> +#include <tqfiledialog.h> #include <klocale.h> @@ -52,7 +52,7 @@ TrayLabelMgr* TrayLabelMgr::instance(void) TrayLabelMgr::TrayLabelMgr() : mReady(false), mHiddenLabelsCount(0) { // Set ourselves up to be called from the application loop - QTimer::singleShot(0, this, SLOT(startup())); + TQTimer::singleShot(0, this, SLOT(startup())); } TrayLabelMgr::~TrayLabelMgr() @@ -62,11 +62,11 @@ TrayLabelMgr::~TrayLabelMgr() void TrayLabelMgr::about(void) { - if (QMessageBox::information(NULL, i18n("About KDocker"), + if (TQMessageBox::information(NULL, i18n("About KDocker"), i18n("Bugs/wishes to Girish Ramakrishnan (gramakri@uiuc.edu)\n" "English translation by Girish (gramakri@uiuc.edu)\n\n" "http://kdocker.sourceforge.net for updates"), - QString::null, SHOW_TRACE_TEXT) == 1) SHOW_TRACE(); + TQString::null, SHOW_TRACE_TEXT) == 1) SHOW_TRACE(); } void TrayLabelMgr::startup(void) @@ -78,25 +78,25 @@ void TrayLabelMgr::startup(void) * stdout is a tty) OR if we are getting restored, wait for WAIT_TIME until * the system tray shows up (before informing the user) */ - static bool do_wait = !isatty(fileno(stdout)) || qApp->isSessionRestored(); + static bool do_wait = !isatty(fileno(stdout)) || tqApp->isSessionRestored(); - SysTrayState state = sysTrayStatus(QPaintDevice::x11AppDisplay()); + SysTrayState state = sysTrayStatus(TQPaintDevice::x11AppDisplay()); if (state != SysTrayPresent) { if (wait_time-- > 0 && do_wait) { TRACE("Will check sys tray status after 1 second"); - QTimer::singleShot(1000, this, SLOT(startup())); + TQTimer::singleShot(1000, this, SLOT(startup())); return; } - if (QMessageBox::warning(NULL, i18n("KDocker"), + if (TQMessageBox::warning(NULL, i18n("KDocker"), i18n(state == SysTrayAbsent ? "No system tray found" : "System tray appears to be hidden"), - QMessageBox::Abort, QMessageBox::Ignore) == QMessageBox::Abort) + TQMessageBox::Abort, TQMessageBox::Ignore) == TQMessageBox::Abort) { - qApp->quit(); + tqApp->quit(); return; } } @@ -104,34 +104,34 @@ void TrayLabelMgr::startup(void) // Things are fine or user with OK with the state of system tray mReady = true; bool ok = false; - if (qApp->isSessionRestored()) ok = restoreSession(qApp->sessionId()); - else ok = processCommand(qApp->argc(), qApp->argv()); + if (tqApp->isSessionRestored()) ok = restoreSession(tqApp->sessionId()); + else ok = processCommand(tqApp->argc(), tqApp->argv()); // Process the request Q from previous instances TRACE("Request queue has %i requests", mRequestQ.count()); for(unsigned i=0; i < mRequestQ.count(); i++) ok |= processCommand(mRequestQ[i]); - if (!ok) qApp->quit(); + if (!ok) tqApp->quit(); } -// Initialize a QTrayLabel after its creation -void TrayLabelMgr::manageTrayLabel(QTrayLabel *t) +// Initialize a TQTrayLabel after its creation +void TrayLabelMgr::manageTrayLabel(TQTrayLabel *t) { - connect(t, SIGNAL(destroyed(QObject *)), - this, SLOT(trayLabelDestroyed(QObject *))); - connect(t, SIGNAL(undocked(QTrayLabel *)), t, SLOT(deleteLater())); + connect(t, SIGNAL(destroyed(TQObject *)), + this, SLOT(trayLabelDestroyed(TQObject *))); + connect(t, SIGNAL(undocked(TQTrayLabel *)), t, SLOT(deleteLater())); - // All QTrayLabels will emit this signal. We just need one of them + // All TQTrayLabels will emit this signal. We just need one of them if (mTrayLabels.count() == 0) connect(t, SIGNAL(sysTrayDestroyed()), this, SLOT(sysTrayDestroyed())); mTrayLabels.prepend(t); - TRACE("New QTrayLabel prepended. Count=%i", mTrayLabels.count()); + TRACE("New TQTrayLabel prepended. Count=%i", mTrayLabels.count()); } void TrayLabelMgr::dockAnother() { - QTrayLabel *t = selectAndDock(); + TQTrayLabel *t = selectAndDock(); if (t == NULL) return; manageTrayLabel(t); t->withdraw(); @@ -142,8 +142,8 @@ void TrayLabelMgr::dockAnother() void TrayLabelMgr::undockAll() { TRACE("Number of tray labels = %i", mTrayLabels.count()); - QPtrListIterator<QTrayLabel> it(mTrayLabels); - QTrayLabel *t; + TQPtrListIterator<TQTrayLabel> it(mTrayLabels); + TQTrayLabel *t; while ((t = it.current()) != 0) { ++it; @@ -152,7 +152,7 @@ void TrayLabelMgr::undockAll() } // Process the command line -bool TrayLabelMgr::processCommand(const QStringList& args) +bool TrayLabelMgr::processCommand(const TQStringList& args) { if (!mReady) { @@ -186,7 +186,7 @@ bool TrayLabelMgr::processCommand(int argc, char** argv) if (qstrcmp(argv[1], "-session") == 0) { TRACE("Restoring session %s (new instance request)", argv[2]); - return restoreSession(QString(argv[2])); + return restoreSession(TQString(argv[2])); } int option; @@ -206,7 +206,7 @@ bool TrayLabelMgr::processCommand(int argc, char** argv) case '?': return false; case 'a': - qDebug("%s", i18n("Girish Ramakrishnan (gramakri@uiuc.edu)").local8Bit().data()); + tqDebug("%s", i18n("Girish Ramakrishnan (gramakri@uiuc.edu)").local8Bit().data()); return false; case 'b': check_normality = false; @@ -218,7 +218,7 @@ bool TrayLabelMgr::processCommand(int argc, char** argv) enable_sm = true; break; case 'f': - w = activeWindow(QPaintDevice::x11AppDisplay()); + w = activeWindow(TQPaintDevice::x11AppDisplay()); TRACE("Active window is %i", (unsigned) w); break; case 'i': @@ -247,9 +247,9 @@ bool TrayLabelMgr::processCommand(int argc, char** argv) sscanf(optarg, "%x", (unsigned *) &w); else w = (Window) atoi(optarg); - if (!isValidWindowId(QPaintDevice::x11AppDisplay(), w)) + if (!isValidWindowId(TQPaintDevice::x11AppDisplay(), w)) { - qDebug("Window 0x%x invalid", (unsigned) w); + tqDebug("Window 0x%x invalid", (unsigned) w); return false; } break; @@ -277,32 +277,32 @@ bool TrayLabelMgr::processCommand(int argc, char** argv) /* * Request user to make a window selection if necessary. Dock the window. */ -QTrayLabel *TrayLabelMgr::selectAndDock(Window w, bool checkNormality) +TQTrayLabel *TrayLabelMgr::selectAndDock(Window w, bool checkNormality) { if (w == None) { - qDebug("%s", i18n("Select the application/window to dock with button1.").local8Bit().data()); - qDebug("%s", i18n("Click any other button to abort\n").local8Bit().data()); + tqDebug("%s", i18n("Select the application/window to dock with button1.").local8Bit().data()); + tqDebug("%s", i18n("Click any other button to abort\n").local8Bit().data()); const char *err = NULL; - if ((w = selectWindow(QPaintDevice::x11AppDisplay(), &err)) == None) + if ((w = selectWindow(TQPaintDevice::x11AppDisplay(), &err)) == None) { - if (err) QMessageBox::critical(NULL, i18n("KDocker"), i18n(err)); + if (err) TQMessageBox::critical(NULL, i18n("KDocker"), i18n(err)); return NULL; } } - if (checkNormality && !isNormalWindow(QPaintDevice::x11AppDisplay(), w)) + if (checkNormality && !isNormalWindow(TQPaintDevice::x11AppDisplay(), w)) { /* * Abort should be the only option here really. "Ignore" is provided here * for the curious user who wants to screw himself very badly */ - if (QMessageBox::warning(NULL, i18n("KDocker"), + if (TQMessageBox::warning(NULL, i18n("KDocker"), i18n("The window you are attempting to dock does not seem to be a" - " normal window."), QMessageBox::Abort, - QMessageBox::Ignore) == QMessageBox::Abort) + " normal window."), TQMessageBox::Abort, + TQMessageBox::Ignore) == TQMessageBox::Abort) return NULL; } @@ -310,7 +310,7 @@ QTrayLabel *TrayLabelMgr::selectAndDock(Window w, bool checkNormality) TRACE("0x%x is not docked", (unsigned) w); - QMessageBox::message(i18n("KDocker"), + TQMessageBox::message(i18n("KDocker"), i18n("This window is already docked.\n" "Click on system tray icon to toggle docking.")); return NULL; @@ -318,8 +318,8 @@ QTrayLabel *TrayLabelMgr::selectAndDock(Window w, bool checkNormality) bool TrayLabelMgr::isWindowDocked(Window w) { - QPtrListIterator<QTrayLabel> it(mTrayLabels); - for(QTrayLabel *t; (t = it.current()); ++it) + TQPtrListIterator<TQTrayLabel> it(mTrayLabels); + for(TQTrayLabel *t; (t = it.current()); ++it) if (t->dockedWindow() == w) return true; return false; @@ -330,7 +330,7 @@ bool TrayLabelMgr::isWindowDocked(Window w) * notifications (for MapEvent on children). We will monitor these new windows * to make a pid to wid mapping (see HACKING for more details) */ -QTrayLabel *TrayLabelMgr::dockApplication(char *argv[]) +TQTrayLabel *TrayLabelMgr::dockApplication(char *argv[]) { pid_t pid = -1; int filedes[2]; @@ -338,9 +338,9 @@ QTrayLabel *TrayLabelMgr::dockApplication(char *argv[]) /* * The pipe created here serves as a synchronization mechanism between the - * parent and the child. QTrayLabel ctor keeps looking out for newly created + * parent and the child. TQTrayLabel ctor keeps looking out for newly created * windows. Need to make sure that the application is actually exec'ed only - * after we QTrayLabel is created (it requires pid of child) + * after we TQTrayLabel is created (it requires pid of child) */ pipe(filedes); @@ -352,7 +352,7 @@ QTrayLabel *TrayLabelMgr::dockApplication(char *argv[]) if (execvp(argv[0], argv) == -1) { - qDebug("%s", i18n("Failed to exec [%1]: %2").arg(argv[0]).arg(strerror(errno)).local8Bit().data()); + tqDebug("%s", i18n("Failed to exec [%1]: %2").arg(argv[0]).arg(strerror(errno)).local8Bit().data()); ::exit(0); // will become a zombie in some systems :( return NULL; } @@ -360,17 +360,17 @@ QTrayLabel *TrayLabelMgr::dockApplication(char *argv[]) if (pid == -1) { - QMessageBox::critical(NULL, "KDocker", + TQMessageBox::critical(NULL, "KDocker", i18n("Failed to fork: %1").arg(strerror(errno))); return NULL; } - QStringList cmd_line; + TQStringList cmd_line; for(int i=0;;i++) if (argv[i]) cmd_line << argv[i]; else break; - QTrayLabel *label = new CustomTrayLabel(cmd_line, pid); - qApp->syncX(); + TQTrayLabel *label = new CustomTrayLabel(cmd_line, pid); + tqApp->syncX(); write(filedes[1], buf, sizeof(buf)); close(filedes[0]); close(filedes[1]); @@ -378,14 +378,14 @@ QTrayLabel *TrayLabelMgr::dockApplication(char *argv[]) } /* - * Returns the number of QTrayLabels actually created but not show in the + * Returns the number of TQTrayLabels actually created but not show in the * System Tray */ int TrayLabelMgr::hiddenLabelsCount(void) const { - QPtrListIterator<QTrayLabel> it(mTrayLabels); + TQPtrListIterator<TQTrayLabel> it(mTrayLabels); int count = 0; - for(QTrayLabel *t; (t=it.current()); ++it) + for(TQTrayLabel *t; (t=it.current()); ++it) if (t->dockedWindow() == None) ++count; return count; } @@ -396,11 +396,11 @@ int TrayLabelMgr::dockedLabelsCount(void) const return mTrayLabels.count() - hiddenLabelsCount(); } -void TrayLabelMgr::trayLabelDestroyed(QObject *t) +void TrayLabelMgr::trayLabelDestroyed(TQObject *t) { - bool reconnect = ((QObject *)mTrayLabels.getLast() == t); - mTrayLabels.removeRef((QTrayLabel*)t); - if (mTrayLabels.isEmpty()) qApp->quit(); + bool reconnect = ((TQObject *)mTrayLabels.getLast() == t); + mTrayLabels.removeRef((TQTrayLabel*)t); + if (mTrayLabels.isEmpty()) tqApp->quit(); else if (reconnect) { TRACE("Reconnecting"); @@ -417,17 +417,17 @@ void TrayLabelMgr::sysTrayDestroyed(void) * to not pop up a box when the user is logging out. So, we set ourselves * up to notify user after 3 seconds. */ - QTimer::singleShot(3000, this, SLOT(notifySysTrayAbsence())); + TQTimer::singleShot(3000, this, SLOT(notifySysTrayAbsence())); } void TrayLabelMgr::notifySysTrayAbsence() { - SysTrayState state = sysTrayStatus(QPaintDevice::x11AppDisplay()); + SysTrayState state = sysTrayStatus(TQPaintDevice::x11AppDisplay()); if (state == SysTrayPresent) return; // So sweet of the systray to come back so soon - if (QMessageBox::warning(NULL, i18n("KDocker"), + if (TQMessageBox::warning(NULL, i18n("KDocker"), i18n("The System tray was hidden or removed"), i18n("Undock All"), i18n("Ignore")) == 0) undockAll(); @@ -436,30 +436,30 @@ void TrayLabelMgr::notifySysTrayAbsence() /* * Session Management. Always return "true". Atleast, for now */ -bool TrayLabelMgr::restoreSession(const QString& sessionId) +bool TrayLabelMgr::restoreSession(const TQString& sessionId) { - QString session_file = "kdocker_" + sessionId; + TQString session_file = "kdocker_" + sessionId; - QSettings settings; - settings.beginGroup(QString("/" + session_file)); + TQSettings settings; + settings.beginGroup(TQString("/" + session_file)); for(int i = 1;; i++) { - settings.beginGroup(QString("/Instance") + QString("").setNum(i)); - QString pname = settings.readEntry("/Application"); + settings.beginGroup(TQString("/Instance") + TQString("").setNum(i)); + TQString pname = settings.readEntry("/Application"); TRACE("Restoring Application[%s]", pname.latin1()); if (pname.isEmpty()) break; if (settings.readBoolEntry("/LaunchOnStartup")) { - QStringList args("kdocker"); - args += QStringList::split(" ", pname); + TQStringList args("kdocker"); + args += TQStringList::split(" ", pname); TRACE("Triggering AutoLaunch"); if (!processCommand(args)) continue; } else - manageTrayLabel(new CustomTrayLabel(QStringList::split(" ", pname), 0)); + manageTrayLabel(new CustomTrayLabel(TQStringList::split(" ", pname), 0)); - QTrayLabel *tl = mTrayLabels.getFirst(); // the one that was created above + TQTrayLabel *tl = mTrayLabels.getFirst(); // the one that was created above tl->restoreState(settings); settings.endGroup(); } @@ -467,51 +467,51 @@ bool TrayLabelMgr::restoreSession(const QString& sessionId) return true; } -QString TrayLabelMgr::saveSession(void) +TQString TrayLabelMgr::saveSession(void) { - QString session_file = "kdocker_" + qApp->sessionId(); + TQString session_file = "kdocker_" + tqApp->sessionId(); - QSettings settings; - settings.beginGroup(QString("/" + session_file)); + TQSettings settings; + settings.beginGroup(TQString("/" + session_file)); TRACE("Saving session"); - QPtrListIterator <QTrayLabel> it(mTrayLabels); - QTrayLabel *t; + TQPtrListIterator <TQTrayLabel> it(mTrayLabels); + TQTrayLabel *t; int i = 1; while ((t = it.current()) != 0) { ++it; TRACE("Saving instance %i", i); - settings.beginGroup(QString("/Instance") + QString("").setNum(i)); + settings.beginGroup(TQString("/Instance") + TQString("").setNum(i)); bool ok = t->saveState(settings); settings.endGroup(); if (ok) ++i; else TRACE("Saving of instance %i was skipped", i); } // Aaaaaaaaaaaaaa......... - settings.removeEntry(QString("/Instance") + QString("").setNum(i)); + settings.removeEntry(TQString("/Instance") + TQString("").setNum(i)); - return QDir::homeDirPath() + "/.qt/" + session_file + "rc"; + return TQDir::homeDirPath() + "/.qt/" + session_file + "rc"; } /* - * The X11 Event Filter. Pass on events to the QTrayLabels that we created. + * The X11 Event Filter. Pass on events to the TQTrayLabels that we created. * The logic and the code below is a bit fuzzy. * a) Events about windows that are being docked need to be processed only by - * the QTrayLabel object that is docking that window. + * the TQTrayLabel object that is docking that window. * b) Events about windows that are not docked but of interest (like - * SystemTray) need to be passed on to all QTrayLabel objects. - * c) When a QTrayLabel manages to find the window that is was looking for, we + * SystemTray) need to be passed on to all TQTrayLabel objects. + * c) When a TQTrayLabel manages to find the window that is was looking for, we * need not process the event further */ bool TrayLabelMgr::x11EventFilter(XEvent *ev) { - QPtrListIterator<QTrayLabel> it(mTrayLabels); + TQPtrListIterator<TQTrayLabel> it(mTrayLabels); bool ret = false; // We pass on the event to all tray labels - for(QTrayLabel *t; (t = it.current()); ++it) + for(TQTrayLabel *t; (t = it.current()); ++it) { Window w = t->dockedWindow(); bool res = t->x11EventFilter(ev); |