diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 24 | ||||
-rw-r--r-- | src/cr16-app-kerberostray.png | bin | 0 -> 868 bytes | |||
-rw-r--r-- | src/cr22-action-kerberos_activetickets.png | bin | 0 -> 1251 bytes | |||
-rw-r--r-- | src/cr22-action-kerberos_notickets.png | bin | 0 -> 1238 bytes | |||
-rw-r--r-- | src/cr22-actionkerberos_expiredtickets.png | bin | 0 -> 1253 bytes | |||
-rw-r--r-- | src/cr32-app-kerberostray.png | bin | 0 -> 2280 bytes | |||
-rw-r--r-- | src/cr48-app-kerberostray.png | bin | 0 -> 4151 bytes | |||
-rw-r--r-- | src/kerberostray.desktop | 11 | ||||
-rw-r--r-- | src/main.cpp | 52 | ||||
-rw-r--r-- | src/toplevel.cpp | 189 | ||||
-rw-r--r-- | src/toplevel.h | 65 |
11 files changed, 341 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..9572872 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,24 @@ + +INCLUDES= $(all_includes) + +bin_PROGRAMS = kerberostray + +kerberostray_SOURCES = main.cpp toplevel.cpp tealist.cpp timeedit.cpp + +kerberostray_METASOURCES = AUTO +kerberostray_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -lktexteditor + +# LIB_KIO needed for KNotifyDialog +kerberostray_LDADD = $(LIB_TDEUI) $(LIB_KIO) + +KDE_ICON = kerberostray + +KDE_OPTIONS = nofinal + +kerberostrayicondir = $(kde_datadir)/kerberostray/icons +kerberostrayicon_ICON = AUTO + +messages: + $(XGETTEXT) $(kerberostray_SOURCES) -o $(podir)/kerberostray.pot + +xdg_apps_DATA = kerberostray.desktop diff --git a/src/cr16-app-kerberostray.png b/src/cr16-app-kerberostray.png Binary files differnew file mode 100644 index 0000000..8f69e2b --- /dev/null +++ b/src/cr16-app-kerberostray.png diff --git a/src/cr22-action-kerberos_activetickets.png b/src/cr22-action-kerberos_activetickets.png Binary files differnew file mode 100644 index 0000000..5447d8f --- /dev/null +++ b/src/cr22-action-kerberos_activetickets.png diff --git a/src/cr22-action-kerberos_notickets.png b/src/cr22-action-kerberos_notickets.png Binary files differnew file mode 100644 index 0000000..6b71537 --- /dev/null +++ b/src/cr22-action-kerberos_notickets.png diff --git a/src/cr22-actionkerberos_expiredtickets.png b/src/cr22-actionkerberos_expiredtickets.png Binary files differnew file mode 100644 index 0000000..744eef7 --- /dev/null +++ b/src/cr22-actionkerberos_expiredtickets.png diff --git a/src/cr32-app-kerberostray.png b/src/cr32-app-kerberostray.png Binary files differnew file mode 100644 index 0000000..a5cbf22 --- /dev/null +++ b/src/cr32-app-kerberostray.png diff --git a/src/cr48-app-kerberostray.png b/src/cr48-app-kerberostray.png Binary files differnew file mode 100644 index 0000000..d8b241c --- /dev/null +++ b/src/cr48-app-kerberostray.png diff --git a/src/kerberostray.desktop b/src/kerberostray.desktop new file mode 100644 index 0000000..71827a0 --- /dev/null +++ b/src/kerberostray.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=KerberosTray +GenericName=Kerberos Ticket Manager +Exec=kerberostray +Icon=kerberostray +Type=Application +Terminal=false +DocPath=kerberostray/index.html +X-KDE-StartupNotify=true +X-DCOP-ServiceType=Multi +Categories=Qt;KDE;Utilities; diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..0008198 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * [email protected] * + * * + * 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 <twin.h> +#include <kstartupinfo.h> +#include <kcmdlineargs.h> +#include <kaboutdata.h> + +#include "toplevel.h" + + +static const char description[] = + I18N_NOOP("TDE utility for managing Kerberos tickets"); + +static const char version[] = "v0.0.1"; + +int main(int argc, char *argv[]) +{ + KAboutData aboutData( "kerberostray", I18N_NOOP("Kerberos Ticket Manager"), + version, description, KAboutData::License_GPL, + "(c) 2012, Timothy Pearson"); + aboutData.addAuthor("Timothy Pearson",0, "[email protected]"); + KCmdLineArgs::init( argc, argv, &aboutData ); + + KApplication app; + + TopLevel toplevel; + KWin::setSystemTrayWindowFor(toplevel.winId(), 0); + toplevel.show(); + + app.setTopWidget(&toplevel); + KStartupInfo::appStarted(); + + return app.exec(); +} diff --git a/src/toplevel.cpp b/src/toplevel.cpp new file mode 100644 index 0000000..6e79055 --- /dev/null +++ b/src/toplevel.cpp @@ -0,0 +1,189 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * [email protected] * + * * + * 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() +{ + // +} diff --git a/src/toplevel.h b/src/toplevel.h new file mode 100644 index 0000000..38aeab3 --- /dev/null +++ b/src/toplevel.h @@ -0,0 +1,65 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * [email protected] * + * * + * 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. * + ***************************************************************************/ + +#ifndef TOPLEVEL_H +#define TOPLEVEL_H + +#include <kapplication.h> +#include <tqpopupmenu.h> +#include <tqtimer.h> +#include <tqlineedit.h> +#include <tqvaluevector.h> +#include <tqlistview.h> +#include <tqpushbutton.h> +#include <tqgroupbox.h> +#include <knuminput.h> +#include <ksystemtray.h> +#include <tqpixmap.h> + +class KAction; +class KDialogBase; +class TQCheckBox; +class TimeEdit; + +class TopLevel : public KSystemTray +{ + Q_OBJECT + + +public: + + TopLevel(); + ~TopLevel(); + +protected: + void paintEvent(TQPaintEvent *); + void mousePressEvent(TQMouseEvent *); + void timerEvent(TQTimerEvent *); + void resizeEvent(TQResizeEvent *); + +private slots: + void config(); + void help(); + +private: + TQPixmap activeTicketsPixmap, noTicketsPixmap, expiredTicketsPixmap; +}; + +#endif |