You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
190 lines
5.3 KiB
190 lines
5.3 KiB
13 years ago
|
/***************************************************************************
|
||
|
* Copyright (C) 2012 by Timothy Pearson *
|
||
|
* kb9vqf@pearsoncomputing.net *
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
* *
|
||
|
* This program is distributed in the hope that it will be useful, *
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||
|
* GNU General Public License for more details. *
|
||
|
* *
|
||
|
* You should have received a copy of the GNU General Public License *
|
||
|
* along with this program; if not, write to the *
|
||
|
* Free Software Foundation, Inc., *
|
||
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include <assert.h>
|
||
|
|
||
|
#include <tqcheckbox.h>
|
||
|
#include <tqlayout.h>
|
||
|
#include <tqhbox.h>
|
||
|
#include <tqvbox.h>
|
||
|
#include <tqlineedit.h>
|
||
|
#include <tqpainter.h>
|
||
|
#include <tqtooltip.h>
|
||
|
#include <tqfile.h>
|
||
|
#include <tqcursor.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
#include <tqgroupbox.h>
|
||
|
#include <tqheader.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqbitmap.h>
|
||
|
|
||
|
#include <kconfig.h>
|
||
|
#include <khelpmenu.h>
|
||
|
#include <kiconloader.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kmessagebox.h>
|
||
|
#include <kpassivepopup.h>
|
||
|
#include <knotifyclient.h>
|
||
|
#include <knuminput.h>
|
||
|
#include <kseparator.h>
|
||
|
#include <kpopupmenu.h>
|
||
|
#include <kdialogbase.h>
|
||
|
#include <kaction.h>
|
||
|
#include <knotifydialog.h>
|
||
|
|
||
|
#include "tealist.h"
|
||
|
#include "timeedit.h"
|
||
|
#include "toplevel.h"
|
||
|
#include "toplevel.moc"
|
||
|
|
||
|
|
||
|
const int TopLevel::DEFAULT_TEA_TIME = 3*60;
|
||
|
|
||
|
|
||
|
TopLevel::TopLevel() : KSystemTray()
|
||
|
{
|
||
|
setBackgroundMode(X11ParentRelative); // what for?
|
||
|
|
||
|
KConfig *config = kapp->config();
|
||
|
config->setGroup("Kerberos");
|
||
|
|
||
|
confAct = new KAction(i18n("&Configure..."), "configure", 0,
|
||
|
TQT_TQOBJECT(this), TQT_SLOT(config()), actionCollection(), "configure");
|
||
|
|
||
|
// create app menu (displayed on right-click)
|
||
|
menu = new TQPopupMenu();
|
||
|
menu->setCheckable(true);
|
||
|
connect(menu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(teaSelected(int)));
|
||
|
|
||
|
KHelpMenu* help = new KHelpMenu(this, KGlobal::instance()->aboutData(), false);
|
||
|
KPopupMenu* helpMnu = help->menu();
|
||
|
|
||
|
menu->insertSeparator();
|
||
|
confAct->plug(menu);
|
||
|
menu->insertItem(SmallIcon("help"), i18n("&Help"), helpMnu);
|
||
|
menu->insertItem(SmallIcon("exit"), i18n("Quit"), kapp, TQT_SLOT(quit()));
|
||
|
|
||
|
confdlg = 0L;
|
||
|
anondlg = 0L;
|
||
|
|
||
|
stop(); // reset timer, disable some menu entries, etc.
|
||
|
}
|
||
|
|
||
|
/* slot: signal shutDown() from KApplication */
|
||
|
/* (not currently needed)
|
||
|
void TopLevel::queryExit()
|
||
|
{
|
||
|
KConfig *config = kapp->config();
|
||
|
// config->sync();
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
|
||
|
/** Destructor */
|
||
|
TopLevel::~TopLevel()
|
||
|
{
|
||
|
delete menu;
|
||
|
// FIXME: must delete more (like all the TQWidgets in config-window)?
|
||
|
}
|
||
|
|
||
|
void TopLevel::resizeEvent ( TQResizeEvent * )
|
||
|
{
|
||
|
activeTicketsPixmap = loadSizedIcon("kerberos_activetickets", width());
|
||
|
noTicketsPixmap = loadSizedIcon("kerberos_notickets", width());
|
||
|
expiredTicketsPixmap = loadSizedIcon("kerberos_expiredtickets", width());
|
||
|
repaint();
|
||
|
}
|
||
|
|
||
|
/** Handle mousePressEvent */
|
||
|
void TopLevel::mousePressEvent(TQMouseEvent *event)
|
||
|
{
|
||
|
if (event->button() == Qt::LeftButton) {
|
||
|
//
|
||
|
}
|
||
|
else if (event->button() == Qt::RightButton) {
|
||
|
menu->popup(TQCursor::pos());
|
||
|
}
|
||
|
else if (event->button() == MidButton) {
|
||
|
// currently unused
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/** Handle paintEvent (ie. animate icon) */
|
||
|
void TopLevel::paintEvent(TQPaintEvent *)
|
||
|
{
|
||
|
TQPixmap *pm = &mugPixmap;
|
||
|
|
||
|
if (running) {
|
||
|
if (useTrayVis)
|
||
|
pm = &teaAnim1Pixmap; // this is 'mugPixmap' plus brown content
|
||
|
else
|
||
|
pm = &teaNotReadyPixmap; // generic "steeping" icon
|
||
|
} else {
|
||
|
// use simple two-frame "animation"
|
||
|
// FIXME: how about using a TQMovie instead? (eg. MNG)
|
||
|
if (ready) {
|
||
|
if (firstFrame)
|
||
|
pm = &teaAnim1Pixmap;
|
||
|
else
|
||
|
pm = &teaAnim2Pixmap;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
TQPixmap base(*pm); // make copy of base pixmap
|
||
|
TQPainter p(this);
|
||
|
p.drawPixmap(x, y, base);
|
||
|
p.end();
|
||
|
}
|
||
|
|
||
|
/** Check timer and initiate appropriate action if finished */
|
||
|
void TopLevel::timerEvent(TQTimerEvent *)
|
||
|
{
|
||
|
//
|
||
|
}
|
||
|
|
||
|
/** update ToolTip */
|
||
|
void TopLevel::setToolTip(const TQString &text, bool force)
|
||
|
{
|
||
|
// don't update if text hasn't changed
|
||
|
if (lastTip == text) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// don't remove Tooltip if (probably - can't know for sure?) currently showing
|
||
|
// FIXME: this isn't too nice: currently mouse must stay outside for >1s for update to occur
|
||
|
if (force || !this->hasMouse() || (lastTip == i18n("Kerberos Tickets Manager"))) {
|
||
|
lastTip = text;
|
||
|
TQToolTip::remove(this);
|
||
|
TQToolTip::add(this, text);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* config-slot: "help" button clicked */
|
||
|
void TopLevel::help()
|
||
|
{
|
||
|
kapp->invokeHelp();
|
||
|
}
|
||
|
|
||
|
void TopLevel::config()
|
||
|
{
|
||
|
//
|
||
|
}
|