diff options
Diffstat (limited to 'katapult/katapult')
21 files changed, 1819 insertions, 0 deletions
diff --git a/katapult/katapult/Makefile.am b/katapult/katapult/Makefile.am new file mode 100644 index 0000000..2eac818 --- /dev/null +++ b/katapult/katapult/Makefile.am @@ -0,0 +1,23 @@ +# set the include path for X, qt and KDE +INCLUDES = -I$(top_srcdir)/katapult/common $(all_includes) + +# these are the headers for your project +noinst_HEADERS = katapult.h katapultsettings.h katapultconfigdlg.h \ + katapultiface.h + + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +KDE_ICON = katapult + +bin_PROGRAMS = katapult + +# the application source, library search path, and link libraries +katapult_SOURCES = confgeneral.ui confcatalogs.ui confdisplay.ui main.cpp \ + katapult.cpp katapultsettings.cpp katapultconfigdlg.cpp katapultiface.skel +katapult_LDFLAGS = $(KDE_RPATH) $(all_libraries) +katapult_LDADD = $(LIB_QT) $(LIB_KDECORE) $(LIB_KDEUI) $(LIB_KIO) $(top_builddir)/katapult/common/libkatapult.la + +# this is where the desktop file will go +xdg_apps_DATA = katapult.desktop diff --git a/katapult/katapult/confcatalogs.ui b/katapult/katapult/confcatalogs.ui new file mode 100644 index 0000000..a62e070 --- /dev/null +++ b/katapult/katapult/confcatalogs.ui @@ -0,0 +1,39 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>ConfCatalogs</class> +<widget class="QWidget"> + <property name="name"> + <cstring>ConfCatalogs</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>300</width> + <height>211</height> + </rect> + </property> + <property name="caption"> + <string>Catalogs</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KActionSelector"> + <property name="name"> + <cstring>catalogs</cstring> + </property> + <property name="selectedInsertionPolicy"> + <enum>Sorted</enum> + </property> + <property name="showUpDownButtons"> + <bool>false</bool> + </property> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kactionselector.h</includehint> +</includehints> +</UI> diff --git a/katapult/katapult/confdisplay.ui b/katapult/katapult/confdisplay.ui new file mode 100644 index 0000000..164fefc --- /dev/null +++ b/katapult/katapult/confdisplay.ui @@ -0,0 +1,64 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>ConfDisplay</class> +<widget class="QWidget"> + <property name="name"> + <cstring>ConfDisplay</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>299</width> + <height>216</height> + </rect> + </property> + <property name="caption"> + <string>Display</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KComboBox"> + <property name="name"> + <cstring>displayName</cstring> + </property> + <property name="duplicatesEnabled"> + <bool>false</bool> + </property> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>displaySettings</cstring> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>80</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kcombobox.h</includehint> +</includehints> +</UI> diff --git a/katapult/katapult/confgeneral.ui b/katapult/katapult/confgeneral.ui new file mode 100644 index 0000000..2c4d839 --- /dev/null +++ b/katapult/katapult/confgeneral.ui @@ -0,0 +1,250 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>ConfGeneral</class> +<widget class="QWidget"> + <property name="name"> + <cstring>ConfGeneral</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>543</width> + <height>669</height> + </rect> + </property> + <property name="caption"> + <string>General Settings</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>buttonGroup2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Executing Actions</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>HideDelayLabel</cstring> + </property> + <property name="text"> + <string>Delay before hiding &launcher:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>hideDelay</cstring> + </property> + <property name="toolTip" stdset="0"> + <string>How long Katapult waits before hiding the launcher</string> + </property> + <property name="whatsThis" stdset="0"> + <string>After an action is performed or no results were found, the Katapult launcher will be hidden. + +This sets how long Katapult will wait before hiding the launcher.</string> + </property> + </widget> + <widget class="QSlider"> + <property name="name"> + <cstring>hideDelay</cstring> + </property> + <property name="maxValue"> + <number>5000</number> + </property> + <property name="lineStep"> + <number>100</number> + </property> + <property name="pageStep"> + <number>1000</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="tickmarks"> + <enum>Below</enum> + </property> + <property name="tickInterval"> + <number>1000</number> + </property> + </widget> + <widget class="QCheckBox"> + <property name="name"> + <cstring>autoExec</cstring> + </property> + <property name="text"> + <string>Automatically perform &default action</string> + </property> + <property name="toolTip" stdset="0"> + <string>Whether to wait for confirmation or automatically execute actions</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If enabled, Katapult will automatically perform the default action once all items but one have been eliminated. This avoids the extra keystroke after there is only one possibility.</string> + </property> + </widget> + </vbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>noResultOptions</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>No Results</string> + </property> + <property name="selectedId" stdset="0"> + <number>-1</number> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>When there are no results:</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>nrClearQuery</cstring> + </property> + <property name="text"> + <string>&Clear the query after a delay</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>nrHideDisplay</cstring> + </property> + <property name="text"> + <string>&Hide the display after a delay</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>nrDoNothing</cstring> + </property> + <property name="text"> + <string>Do &nothing</string> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="text"> + <string>&Delay before clearing or hiding:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>noResultsDelay</cstring> + </property> + </widget> + <widget class="QSlider"> + <property name="name"> + <cstring>noResultsDelay</cstring> + </property> + <property name="maxValue"> + <number>5000</number> + </property> + <property name="lineStep"> + <number>100</number> + </property> + <property name="pageStep"> + <number>1000</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="tickmarks"> + <enum>Below</enum> + </property> + <property name="tickInterval"> + <number>1000</number> + </property> + </widget> + </vbox> + </widget> + <widget class="QButtonGroup"> + <property name="name"> + <cstring>buttonGroup3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>System Tray</string> + </property> + <widget class="QCheckBox"> + <property name="name"> + <cstring>systrayIcon</cstring> + </property> + <property name="geometry"> + <rect> + <x>10</x> + <y>30</y> + <width>280</width> + <height>24</height> + </rect> + </property> + <property name="mouseTracking"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Show an icon in the systray</string> + </property> + <property name="toolTip" stdset="0"> + <string>If activated, katapult shows an icon in the System Tray when running</string> + </property> + <property name="whatsThis" stdset="0"> + <string>If enabled, Katapult will automatically show an Icon in the System Tray.</string> + </property> + </widget> + </widget> + <spacer> + <property name="name"> + <cstring>spacer3_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>62</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/katapult/katapult/hi128-app-katapult.png b/katapult/katapult/hi128-app-katapult.png Binary files differnew file mode 100644 index 0000000..88234a0 --- /dev/null +++ b/katapult/katapult/hi128-app-katapult.png diff --git a/katapult/katapult/hi16-app-katapult.png b/katapult/katapult/hi16-app-katapult.png Binary files differnew file mode 100644 index 0000000..e4b2cf2 --- /dev/null +++ b/katapult/katapult/hi16-app-katapult.png diff --git a/katapult/katapult/hi22-app-katapult.png b/katapult/katapult/hi22-app-katapult.png Binary files differnew file mode 100644 index 0000000..e8ec188 --- /dev/null +++ b/katapult/katapult/hi22-app-katapult.png diff --git a/katapult/katapult/hi32-app-katapult.png b/katapult/katapult/hi32-app-katapult.png Binary files differnew file mode 100644 index 0000000..d7ab85b --- /dev/null +++ b/katapult/katapult/hi32-app-katapult.png diff --git a/katapult/katapult/hi48-app-katapult.png b/katapult/katapult/hi48-app-katapult.png Binary files differnew file mode 100644 index 0000000..c7e71d9 --- /dev/null +++ b/katapult/katapult/hi48-app-katapult.png diff --git a/katapult/katapult/hi64-app-katapult.png b/katapult/katapult/hi64-app-katapult.png Binary files differnew file mode 100644 index 0000000..b11b16c --- /dev/null +++ b/katapult/katapult/hi64-app-katapult.png diff --git a/katapult/katapult/hisc-app-katapult.svgz b/katapult/katapult/hisc-app-katapult.svgz Binary files differnew file mode 100644 index 0000000..894e2f5 --- /dev/null +++ b/katapult/katapult/hisc-app-katapult.svgz diff --git a/katapult/katapult/katapult.cpp b/katapult/katapult/katapult.cpp new file mode 100644 index 0000000..b0d2756 --- /dev/null +++ b/katapult/katapult/katapult.cpp @@ -0,0 +1,360 @@ +/*************************************************************************** + * Copyright (C) 2005 by Joe Ferris * + * jferris@optimistictech.com * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <kapp.h> +#include <kiconloader.h> +#include <kglobal.h> +#include <kwin.h> +#include <kkeydialog.h> +#include <kaction.h> +#include <kparts/componentfactory.h> +#include <kpassivepopup.h> +#include <kpopupmenu.h> +#include <klocale.h> +#include <kaboutapplication.h> +#include <dcopclient.h> + +#include <qpopupmenu.h> +#include <qmenudata.h> +#include <qcursor.h> + +#include "katapult.h" +#include "actionregistry.h" +#include "katapultcatalog.h" +#include "katapultdisplay.h" +#include "katapultsettings.h" +#include "status.h" + +Katapult::Katapult() + : DCOPObject("Katapult"), + KSystemTray(0, "katapultSysTray") +{ + // Register with DCOP + kapp->dcopClient()->registerAs("katapult", false); + kapp->dcopClient()->setDefaultObject(objId()); + + setPixmap(KGlobal::iconLoader()->loadIcon("katapult", KIcon::Small)); + + display = 0; + globalAccel = 0; + actions = 0; + action = 0; + executing = FALSE; + _query = ""; + + settings = new KatapultSettings(); + + hideTimer = new QTimer(this); + connect(hideTimer, SIGNAL(timeout()), this, SLOT(hideLauncher())); + clearTimer = new QTimer(this); + connect(clearTimer, SIGNAL(timeout()), this, SLOT(clearQuery())); + + connect(settings, SIGNAL(catalogsChanged()), this, SLOT(loadCatalogPlugins())); + connect(settings, SIGNAL(displayChanged()), this, SLOT(initDisplay())); + connect(settings, SIGNAL(systrayChanged()), this, SLOT(updateSystray())); + + loadCatalogPlugins(); + initDisplay(); + + if(settings->systrayIcon()) + { + show(); + } + + //show popup (unless we're session restored) + if (!settings->hideNotification()) { + QString msg = i18n("Application successfully started !\nPress %1 to use it...") + .arg(globalAccel->shortcut("show_katapult").toString()); + KPassivePopup::message(i18n("Katapult Notification"), msg, kapp->miniIcon(), this, 0, settings->notificationTimeout()); + } +} + +Katapult::~Katapult() +{ + if(globalAccel != 0) + delete globalAccel; + if(actions != 0) + delete actions; + delete settings; +} + +void Katapult::loadCatalogPlugins() +{ + catalogs = settings->activeCatalogs(); +} + +void Katapult::initDisplay() +{ + display = settings->display(); + if(display == 0) { + initAccel(this); + } else { + initAccel(display); + setQuery(""); + connect(display, SIGNAL(keyReleased(QKeyEvent *)), this, SLOT(keyReleased(QKeyEvent *))); + connect(display, SIGNAL(focusOut()), this, SLOT(hideLauncher())); + } +} + +void Katapult::initAccel(QWidget *parent) +{ + globalAccel = new KGlobalAccel(parent); + globalAccel->insert("show_katapult", i18n("Show Launcher"), i18n("Shows the Katapult launcher"), ALT+Key_Space, ALT+Key_Space, + this, SLOT(showLauncher())); + globalAccel->readSettings(); + globalAccel->updateConnections(); + + actions = new KActionCollection(parent); + actionCollection()->clear(); + + contextMenu()->clear(); + + new KAction(i18n("Execute"), "exec", Key_Return, this, SLOT(execute()), actions, "execute"); + new KAction(i18n("Clear"), "editclear", Key_Left, this, SLOT(clearQuery()), actions, "clear"); + new KAction(i18n("Close"), "fileclose", Key_Escape, this, SLOT(hideLauncher()), actions, "close"); + new KAction(i18n("Complete Query"), "next", Key_Right, this, SLOT(completeQuery()), actions, "complete_query"); + new KAction(i18n("Show Context Menu"), "menu", CTRL+Key_C, this, SLOT(showContextMenu()), actions, "show_menu"); + + KAction *actGlobAccel = KStdAction::keyBindings(this, SLOT(showGlobalShortcutsDialog()), actions); + actGlobAccel->setText(i18n("Configure &Global Shortcuts...")); + actGlobAccel->plug((QWidget *) contextMenu()); + + KStdAction::keyBindings(this, SLOT(showShortcutsDialog()), actions)->plug((QWidget *) contextMenu()); + KStdAction::preferences(settings, SLOT(configure()), actions)->plug((QWidget *) contextMenu()); + + contextMenu()->insertSeparator(); + KStdAction::aboutApp(this, SLOT(showAboutDialog()), actions)->plug((QWidget *) contextMenu()); + contextMenu()->insertSeparator(); + + KStdAction::quit(this, SLOT(close()), actions)->plug((QWidget *) contextMenu()); + + actions->readShortcutSettings(); +} + +void Katapult::completeQuery() +{ + if(!bestMatch.isNull()) { + QString newQuery = bestMatch.item()->text(); + setQuery(""); + setQuery(newQuery); + } +} + +void Katapult::clearQuery() +{ + setQuery(""); +} + +void Katapult::setQuery(QString _query) +{ + allStatus=0; + bestMatch = Match(); + + this->_query = _query; + if(display != 0) + display->setQuery(_query); + if(_query == "") + { + QDictIterator<KatapultCatalog> it(catalogs); + KatapultCatalog *catalog; + while((catalog = it.current()) != 0) + { + ++it; + catalog->setQuery(""); + } + display->setItem(0); + display->setAction(0); + display->setStatus(0); + display->setSelected(0); + action = 0; + } else if(catalogs.count() == 0) { + allStatus = S_Active | S_NoResults; + display->setStatus(allStatus); + } else { + QDictIterator<KatapultCatalog> it(catalogs); + KatapultCatalog *catalog; + int status; + + while((catalog = it.current()) != 0) + { + ++it; + catalog->setQuery(_query); + + status = catalog->status(); + if(status & S_HasResults) + { + if(allStatus & S_HasResults) + allStatus |= S_Multiple; + Match match = catalog->bestMatch(); + if(!match.isNull()) + { + if(bestMatch.isNull() || bestMatch.rank() < match.rank()) + bestMatch = match; + } + } + allStatus |= status; + } + if(bestMatch.isNull() || bestMatch.rank() == 0) + bestMatch = Match(); + if(!bestMatch.isNull()) { + QPtrList<KatapultAction> itemActions = ActionRegistry::self()->actionsForItem(bestMatch.item()); + action = itemActions.at(0); + connect(bestMatch.item(), SIGNAL(itemChanged()), this, SLOT(updateDisplay())); + } + } + if(!(allStatus & S_HasResults) && allStatus & S_Active) { + // no results + switch(settings->noResultsAction()) { + case KatapultSettings::NR_HideDisplay: + hideTimer->start(settings->noResultsDelay(), TRUE); + break; + case KatapultSettings::NR_ClearQuery: + clearTimer->start(settings->noResultsDelay(), TRUE); + break; + default: + break; + } + } else { + //stop timers if a catalog has suddenly realized it + //does accept the input after all. + if (hideTimer->isActive()) + hideTimer->stop(); + if (clearTimer->isActive()) + clearTimer->stop(); + } + + if(!executing && settings->isAutoExecute() && allStatus & S_HasResults && !(allStatus & S_Multiple)) { + execute(); + } + + updateDisplay(); +} + +void Katapult::showAboutDialog() +{ + KAboutApplication *aboutDialog = new KAboutApplication(this); + aboutDialog->exec(); + delete aboutDialog; +} + +void Katapult::updateDisplay() +{ + if(display != 0 && executing == FALSE) + { + display->setItem(bestMatch.item()); + if(bestMatch.isNull()) { + display->setAction(0); + display->setSelected(0); + } else { + display->setAction(action); + display->setSelected(bestMatch.matched()); + } + display->setStatus(allStatus); + display->update(); + } +} + +void Katapult::showLauncher() +{ + if(!settings->isConfiguring() && display != 0) + { + setQuery(""); + display->setStatus(0); + display->setQuery(""); + display->show(); + display->update(); + KWin::forceActiveWindow(display->winId()); + } +} + +void Katapult::hideLauncher() +{ + if(display != 0) + display->hide(); + setQuery(""); +} + +void Katapult::showShortcutsDialog() +{ + KKeyDialog::configure(actions); +} + +void Katapult::showGlobalShortcutsDialog() +{ + KKeyDialog::configure(globalAccel); +} + +void Katapult::execute() +{ + executing = TRUE; + if(action == 0) + { + display->setStatus(S_Active | S_NoResults); + display->update(); + hideTimer->start(settings->hideDelay(), TRUE); + } else { + completeQuery(); + if(!bestMatch.isNull()) + action->execute(bestMatch.item()); + hideTimer->start(settings->hideDelay(), TRUE); + } + executing = FALSE; +} + +void Katapult::updateSystray() +{ + if(settings->systrayIcon()) + show(); + else + hide(); +} + +void Katapult::showContextMenu() +{ + contextMenu()->popup(QCursor::pos()); +} + +void Katapult::keyReleased(QKeyEvent *e) +{ + if(e->key() == Key_BackSpace) { + if(hideTimer->isActive()) + hideTimer->stop(); + if(clearTimer->isActive()) + clearTimer->stop(); + QString newQuery = _query.left(_query.length()-1); + setQuery(""); + setQuery(newQuery); + } else { + QString t = e->text(); + if ( !t.isEmpty() && (!e->ascii() || e->ascii()>=32) && + e->key() != Key_Delete) + setQuery(_query + t); + } +} + +void Katapult::mousePressEvent(QMouseEvent *e) +{ + if(e->button() == LeftButton) + showLauncher(); + else + KSystemTray::mousePressEvent(e); +} + +#include "katapult.moc" diff --git a/katapult/katapult/katapult.desktop b/katapult/katapult/katapult.desktop new file mode 100644 index 0000000..1e86939 --- /dev/null +++ b/katapult/katapult/katapult.desktop @@ -0,0 +1,30 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Katapult +Name[uk]=Катапульта +Exec=katapult +Icon=katapult +GenericName=KDE launcher +GenericName[ar]=مقلع KDE +GenericName[bg]=Стартиране на KDE +GenericName[br]=Loc'her KDE +GenericName[da]=KDE-startværktøj +GenericName[de]=KDE-Starter +GenericName[el]=Εκτελεστής του KDE +GenericName[es]=Iniciador KDE +GenericName[et]=KDE käivitaja +GenericName[fr]=Lanceur pour KDE +GenericName[ga]=Tosaitheoir KDE +GenericName[gl]=Iniciador de aplicazóns para KDE +GenericName[it]=Avviatore per KDE +GenericName[ja]=KDE ランチャー +GenericName[nb]=KDE oppstarter +GenericName[nl]=KDE-starter +GenericName[pt]=Lançador do KDE +GenericName[pt_BR]=Lançador do KDE +GenericName[sv]=KDE-startverktyg +GenericName[tr]=KDE Başlatıcısı +GenericName[uk]=KDE пускач +Terminal=false +Type=Application +Categories=Qt;KDE;Utility; diff --git a/katapult/katapult/katapult.h b/katapult/katapult/katapult.h new file mode 100644 index 0000000..6ba20d6 --- /dev/null +++ b/katapult/katapult/katapult.h @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2005 by Joe Ferris * + * jferris@optimistictech.com * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#ifndef _KATAPULT_H_ +#define _KATAPULT_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <ksystemtray.h> +#include <kglobalaccel.h> +#include <kactioncollection.h> +#include <dcopobject.h> + +#include <qstring.h> +#include <qptrlist.h> +#include <qevent.h> +#include <qtimer.h> +#include <qdict.h> + +#include <match.h> + +#include "katapultdisplay.h" +#include "katapultcatalog.h" +#include "katapultaction.h" +#include "katapultiface.h" + +class KatapultSettings; + +class Katapult : public KSystemTray, virtual public KatapultIface +{ + Q_OBJECT +public: + Katapult(); + ~Katapult(); + + void setQuery(QString); + QString query() const; + +public slots: + void updateDisplay(); + void showLauncher(); + void hideLauncher(); + void completeQuery(); + void clearQuery(); + void showShortcutsDialog(); + void showGlobalShortcutsDialog(); + void showAboutDialog(); + void loadCatalogPlugins(); + void initDisplay(); + virtual void keyReleased(QKeyEvent *); + void execute(); + void updateSystray(); + void showContextMenu(); + +protected: + virtual void mousePressEvent(QMouseEvent *); + +private: + void initAccel(QWidget *); + + bool executing; + int allStatus; + KatapultDisplay *display; + KGlobalAccel *globalAccel; + KActionCollection *actions; + KatapultSettings *settings; + Match bestMatch; + const KatapultAction *action; + QString _query; + QDict<KatapultCatalog> catalogs; + QTimer *hideTimer; + QTimer *clearTimer; +}; + +#endif // _KATAPULT_H_ diff --git a/katapult/katapult/katapultconfigdlg.cpp b/katapult/katapult/katapultconfigdlg.cpp new file mode 100644 index 0000000..26b275e --- /dev/null +++ b/katapult/katapult/katapultconfigdlg.cpp @@ -0,0 +1,181 @@ +/*************************************************************************** + * Copyright (C) 2005 by Joe Ferris * + * jferris@optimistictech.com * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <kactionselector.h> +#include <kconfig.h> +#include <kapplication.h> +#include <kcombobox.h> +#include <klocale.h> + +#include <qframe.h> +#include <qlayout.h> +#include <qslider.h> +#include <qcheckbox.h> +#include <qstringlist.h> +#include <qradiobutton.h> + +#include "katapultconfigdlg.h" +#include "katapultsettings.h" +#include "katapultcatalog.h" +#include "katapultdisplay.h" + +#include "confgeneral.h" +#include "confcatalogs.h" +#include "confdisplay.h" + +KatapultConfigDlg::KatapultConfigDlg(KatapultSettings *settings) + : KDialogBase(TreeList, "Configure", Ok|Cancel, Ok) +{ + this->settings = settings; + setTreeListAutoResize(TRUE); + + // general settings + QFrame *fConfGeneral = addPage(QString("Katapult"), i18n("General Settings")); + general = new ConfGeneral(fConfGeneral); + (new QVBoxLayout(fConfGeneral, 0, KDialog::spacingHint()))->addWidget(general); + + general->hideDelay->setValue(settings->hideDelay()); + general->autoExec->setChecked(settings->isAutoExecute()); + general->noResultsDelay->setValue(settings->noResultsDelay()); + general->systrayIcon->setChecked(settings->systrayIcon()); + switch(settings->noResultsAction()) { + case KatapultSettings::NR_DoNothing: general->nrDoNothing->setChecked(TRUE); break; + case KatapultSettings::NR_HideDisplay: general->nrHideDisplay->setChecked(TRUE); break; + default: general->nrClearQuery->setChecked(TRUE); break; + } + connect(general->nrDoNothing, SIGNAL(toggled(bool)), this, SLOT(nrDoNothingToggled(bool))); + general->noResultsDelay->setEnabled(!general->nrDoNothing->isChecked()); + + // catalog settings + QFrame *fConfCatalogs = addPage(i18n("Catalogs"), i18n("Enabled Catalogs")); + catalogConf = new ConfCatalogs(fConfCatalogs); + (new QVBoxLayout(fConfCatalogs, 0, KDialog::spacingHint()))->addWidget(catalogConf); + + catalogConf->catalogs->selectedListBox()->insertStringList(settings->activeCatalogNames()); + catalogConf->catalogs->availableListBox()->insertStringList(settings->inactiveCatalogNames()); + + catalogPages.setAutoDelete(TRUE); + QDict<KatapultCatalog> catalogs; + catalogs = settings->activeCatalogs(); + QDictIterator<KatapultCatalog> it(catalogs); + KatapultCatalog *catalog; + while((catalog = it.current()) != 0) + { + QString catalogName = it.currentKey(); + addCatalogPage(catalogName, catalog); + ++it; + } + + // display settings + QFrame *fConfDisplay = addPage(i18n("Display"), i18n("Display")); + display = new ConfDisplay(fConfDisplay); + (new QVBoxLayout(fConfDisplay, 0, KDialog::spacingHint()))->addWidget(display); + new QVBoxLayout((QWidget *) display->displaySettings, 0, KDialog::spacingHint()); + + QStringList displays = settings->displayNames(); + display->displayName->insertStringList(displays); + display->displayName->setCurrentItem(settings->displayNumber()); + displayConfig = 0; + addDisplaySettings(); + + unfoldTreeList(TRUE); + + // connect signals + connect(catalogConf->catalogs, SIGNAL(added(QListBoxItem *)), this, SLOT(activateCatalog(QListBoxItem* ))); + connect(catalogConf->catalogs, SIGNAL(removed(QListBoxItem *)), this, SLOT(deactivateCatalog(QListBoxItem* ))); + connect(display->displayName, SIGNAL(activated(int)), this, SLOT(activateDisplay(int))); + connect(this, SIGNAL(okClicked()), this, SLOT(saveSettings())); +} + +KatapultConfigDlg::~KatapultConfigDlg() +{ +} + +void KatapultConfigDlg::nrDoNothingToggled(bool on) +{ + general->noResultsDelay->setEnabled(!on); +} + +void KatapultConfigDlg::saveSettings() +{ + settings->setHideDelay(general->hideDelay->value()); + settings->setAutoExecute(general->autoExec->isChecked()); + settings->setNoResultsDelay(general->noResultsDelay->value()); + settings->setSystrayIcon(general->systrayIcon->isChecked()); + if (general->nrDoNothing->isChecked()) { + settings->setNoResultsAction(KatapultSettings::NR_DoNothing); + } else if (general->nrHideDisplay->isChecked()) { + settings->setNoResultsAction(KatapultSettings::NR_HideDisplay); + } else { + settings->setNoResultsAction(KatapultSettings::NR_ClearQuery); + } +} + +void KatapultConfigDlg::activateCatalog(QListBoxItem *i) +{ + settings->activateCatalog(i->text()); + KatapultCatalog *catalog = settings->catalog(i->text()); + if(catalog != 0) + addCatalogPage(i->text(), catalog); +} + +void KatapultConfigDlg::deactivateCatalog(QListBoxItem *i) +{ + catalogPages.remove(i->text()); + settings->deactivateCatalog(i->text()); +} + +void KatapultConfigDlg::activateDisplay(int index) +{ + settings->setDisplayName(settings->displayIds()[index]); + addDisplaySettings(); +} + +void KatapultConfigDlg::addCatalogPage(QString name, KatapultCatalog *catalog) +{ + QWidget *catalogConfig = catalog->configure(); + if(catalogConfig != 0) + { + QStringList path; + path << i18n("Catalogs") << name; + QFrame *fCatalog = addPage(path, name); + catalogConfig->reparent(fCatalog, QPoint(0, 0)); + (new QVBoxLayout(fCatalog, 0, KDialog::spacingHint()))->addWidget(catalogConfig); + catalogPages.insert(name, fCatalog); + } +} + +void KatapultConfigDlg::addDisplaySettings() +{ + if(displayConfig != 0) + { + delete displayConfig; + displayConfig = 0; + } + displayConfig = settings->display()->configure(); + if(displayConfig != 0) + { + displayConfig->reparent((QWidget *) display->displaySettings, QPoint(0, 0)); + display->displaySettings->layout()->add(displayConfig); + displayConfig->show(); + } +} + +#include "katapultconfigdlg.moc" diff --git a/katapult/katapult/katapultconfigdlg.h b/katapult/katapult/katapultconfigdlg.h new file mode 100644 index 0000000..6b164ab --- /dev/null +++ b/katapult/katapult/katapultconfigdlg.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * Copyright (C) 2005 by Joe Ferris * + * jferris@optimistictech.com * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef KATAPULTCONFIGDLG_H +#define KATAPULTCONFIGDLG_H + +#include <kdialogbase.h> + +#include <qdict.h> + +class KatapultSettings; +class KatapultCatalog; +class ConfGeneral; +class ConfCatalogs; +class ConfDisplay; +class QListBoxItem; +class QFrame; + +/** +@author Joe Ferris +*/ +class KatapultConfigDlg : public KDialogBase +{ +Q_OBJECT +public: + KatapultConfigDlg(KatapultSettings *settings); + ~KatapultConfigDlg(); + +public slots: + void saveSettings(); + void activateCatalog(QListBoxItem *); + void deactivateCatalog(QListBoxItem *); + void activateDisplay(int); + void nrDoNothingToggled(bool); + +private: + void addCatalogPage(QString name, KatapultCatalog *catalog); + void addDisplaySettings(); + + KatapultSettings *settings; + ConfGeneral *general; + ConfCatalogs *catalogConf; + ConfDisplay *display; + QWidget *displayConfig; + QDict<QFrame> catalogPages; +}; + +#endif diff --git a/katapult/katapult/katapultiface.h b/katapult/katapult/katapultiface.h new file mode 100644 index 0000000..9595246 --- /dev/null +++ b/katapult/katapult/katapultiface.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2005 by Bastian Holst * + * bastianholst@gmx.de * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +// -*- c++ -*- + +#ifndef KATAPULTDCOPIFACE_H +#define KATAPULTDCOPIFACE_H + +#include <dcopobject.h> + +class KatapultIface : virtual public DCOPObject +{ + K_DCOP + k_dcop: + + virtual void showLauncher() = 0; + virtual void hideLauncher() = 0; + virtual void setQuery(QString) = 0; + virtual void execute() = 0; +}; + +#endif // KATAPULTDCOPIFACE_H diff --git a/katapult/katapult/katapultsettings.cpp b/katapult/katapult/katapultsettings.cpp new file mode 100644 index 0000000..ae316f5 --- /dev/null +++ b/katapult/katapult/katapultsettings.cpp @@ -0,0 +1,377 @@ +/*************************************************************************** + * Copyright (C) 2007 Martin Meredith * + * mez@ubuntu.com * + * * + * Copyright (C) 2005 by Joe Ferris * + * jferris@optimistictech.com * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <kapplication.h> +#include <kconfig.h> +#include <kparts/componentfactory.h> +#include <klocale.h> + +#include <qstring.h> +#include <qstringlist.h> + +#include "katapultsettings.h" +#include "katapultcatalog.h" +#include "katapultconfigdlg.h" +#include "katapultdisplay.h" +#include "actionregistry.h" + +KatapultSettings::KatapultSettings() +{ + _forceWrite = FALSE; + readSettings(); + _isConfiguring = FALSE; + _activeCatalogs.setAutoDelete(TRUE); + _display = 0; + + loadCatalogPlugins(); + loadDisplayPlugins(); +} + + +KatapultSettings::~KatapultSettings() +{ + if (_forceWrite) + writeSettings(); + + if(_display != 0) + delete _display; +} + +void KatapultSettings::readSettings() +{ + KConfig *config = kapp->config(); + _hideSessionNotification = config->readNumEntry("HideSessionNotification", 1); + _hideUserNotification = config->readNumEntry("HideUserNotification", 0); + _notificationTimeout = config->readNumEntry("NotificationTimeout", 5000); + _hideDelay = config->readUnsignedNumEntry("HideDelay", 1000); + _noResultsDelay = config->readUnsignedNumEntry("NoResultsDelay", 2500); + _noResultsAction = (NRAction) config->readUnsignedNumEntry("NoResultsAction", NR_ClearQuery); + _systrayIcon = config->readBoolEntry("SystrayIcon", TRUE); + _autoExec = config->readBoolEntry("AutoExec", FALSE); + _displayName = config->readEntry("Display", "Pure Display"); + + QStringList defCatalogs; + defCatalogs << "Program Catalog" << "Bookmark Catalog" << "Document Catalog" << "Calculator Catalog" << "Amarok Catalog" << "Spell Catalog" << "Google Catalog" << "Execution Catalog"; + _activeCatalogNames = config->readListEntry("Catalogs", defCatalogs); + + // Force a config write if notification is to be shown once. + // (in writeSettings(), _hideSessionNotification or _hideUserNotification + // is changed before writing [if necessary]). + _forceWrite = ((kapp->isSessionRestored() && _hideSessionNotification == 1) || + (!kapp->isSessionRestored() && _hideUserNotification == 1)); +} + +void KatapultSettings::writeSettings() +{ + KConfig *config = kapp->config(); + int hideSession = _hideSessionNotification; + int hideUser = _hideUserNotification; + + // If notification had to be shown once, set it to hide always. + if (kapp->isSessionRestored()) { + if (hideSession == 1) hideSession = 2; + } else { + if (hideUser == 1) hideUser = 2; + } + + config->writeEntry("HideSessionNotification", hideSession); + config->writeEntry("HideUserNotification", hideUser); + config->writeEntry("NotificationTimeout", _notificationTimeout); + config->writeEntry("HideDelay", _hideDelay); + config->writeEntry("NoResultsDelay", _noResultsDelay); + config->writeEntry("NoResultsAction", (int) _noResultsAction); + config->writeEntry("SystrayIcon", _systrayIcon); + config->writeEntry("AutoExec", _autoExec); + config->writeEntry("Catalogs", _activeCatalogNames); + config->writeEntry("Display", _displayName); + + QDictIterator<KatapultCatalog> it(_activeCatalogs); + KatapultCatalog *catalog; + while((catalog = it.current()) != 0) + { + KConfigGroup group(config, QString("Catalogs/%1").arg(it.currentKey())); + catalog->writeSettings(&group); + ++it; + } + + if(_display != 0) + { + KConfigGroup group(config, QString("Displays/%1").arg(_displayName)); + _display->writeSettings(&group); + } + + config->sync(); +} + +void KatapultSettings::configure() +{ + if(!_isConfiguring) + { + _isConfiguring = TRUE; + + KatapultConfigDlg *dlg = new KatapultConfigDlg(this); + if(dlg->exec() == QDialog::Accepted) { + writeSettings(); + emit systrayChanged(); + loadCatalogPlugins(); + emit catalogsChanged(); + + } else { + readSettings(); + loadCatalogPlugins(); + loadDisplayPlugins(); + emit catalogsChanged(); + emit displayChanged(); + } + delete dlg; + + _isConfiguring = FALSE; + } +} + +bool KatapultSettings::isConfiguring() const +{ + return _isConfiguring; +} + +bool KatapultSettings::isAutoExecute() const +{ + return _autoExec; +} + +void KatapultSettings::setAutoExecute(bool _autoExec) +{ + this->_autoExec = _autoExec; +} + +int KatapultSettings::hideDelay() const +{ + return _hideDelay; +} + +void KatapultSettings::setHideDelay(int _hideDelay) +{ + this->_hideDelay = _hideDelay; +} + +int KatapultSettings::noResultsDelay() const +{ + return _noResultsDelay; +} + +void KatapultSettings::setNoResultsDelay(int _noResultsDelay) +{ + this->_noResultsDelay = _noResultsDelay; +} + +KatapultSettings::NRAction KatapultSettings::noResultsAction() const +{ + return _noResultsAction; +} + +void KatapultSettings::setNoResultsAction(NRAction _noResultsAction) +{ + this->_noResultsAction = _noResultsAction; +} + +bool KatapultSettings::systrayIcon() const +{ + return _systrayIcon; +} + +void KatapultSettings::setSystrayIcon(bool _systrayIcon) +{ + this->_systrayIcon = _systrayIcon; +} + +bool KatapultSettings::hideNotification() const +{ + int hide = kapp->isSessionRestored() ? _hideSessionNotification : _hideUserNotification; + return (hide != 0 && hide != 1); +} + +int KatapultSettings::notificationTimeout() const +{ + return _notificationTimeout; +} + +QString KatapultSettings::displayName() const +{ + return _displayName; +} + +QStringList KatapultSettings::displayNames() const +{ + return _displayNames; +} + +QStringList KatapultSettings::displayIds() const +{ + return _displayIds; +} + +int KatapultSettings::displayNumber() const +{ + return _displayIds.findIndex(_displayName); +} + +KatapultDisplay * KatapultSettings::display() const +{ + return _display; +} + +void KatapultSettings::setDisplayName(QString name) +{ + _displayName = name; + loadDisplayPlugins(); + emit displayChanged(); +} + +QStringList KatapultSettings::catalogNames() const +{ + return _catalogNames; +} + +QStringList KatapultSettings::catalogIds() const +{ + return _catalogIds; +} + +QStringList KatapultSettings::activeCatalogNames() const +{ + return _activeCatalogNames; +} + +QStringList KatapultSettings::inactiveCatalogNames() const +{ + QStringList inactiveCatalogs, catalogs = _catalogIds; + for(QStringList::Iterator it = catalogs.begin(); it != catalogs.end(); ++it) + { + if(!_activeCatalogNames.contains(*it)) + inactiveCatalogs.append(*it); + } + return inactiveCatalogs; +} + +QDict<KatapultCatalog> KatapultSettings::activeCatalogs() const +{ + return _activeCatalogs; +} + +void KatapultSettings::activateCatalog(QString catalogName) +{ + _activeCatalogNames.append(catalogName); + loadCatalogPlugins(); + emit catalogsChanged(); +} + +void KatapultSettings::deactivateCatalog(QString catalogName) +{ + _activeCatalogNames.remove(catalogName); + loadCatalogPlugins(); + emit catalogsChanged(); +} + +void KatapultSettings::loadCatalogPlugins() +{ + _activeCatalogs.clear(); + _catalogNames.clear(); + _catalogIds.clear(); + ActionRegistry::self()->clear(); + + KTrader::OfferList offers = KTrader::self()->query("Katapult/Catalog"); + KTrader::OfferList::ConstIterator it; + for(it = offers.begin(); it != offers.end(); ++it) + { + QString id; + + KService::Ptr service = *it; + KatapultCatalog *catalog; + + if(!service->property("X-Katapult-ID", QVariant::String).toString().isEmpty()) + id = service->property("X-Katapult-ID", QVariant::String).toString(); + else + id = service->name(); + + _catalogNames.append(service->name()); + _catalogIds.append(id); + + if(_activeCatalogNames.contains(id)) + { + int errCode = 0; + catalog = KParts::ComponentFactory::createInstanceFromService<KatapultCatalog> + (service, 0, 0, QStringList(), &errCode); + if(catalog != 0) + { + KConfigGroup group(kapp->config(), QString("Catalogs/%1").arg(id)); + catalog->readSettings(&group); + catalog->initialize(); + _activeCatalogs.insert(id, catalog); + } + } + } +} + +void KatapultSettings::loadDisplayPlugins() +{ + if(_display != 0) + { + delete _display; + _display = 0; + } + + _displayNames.clear(); + _displayIds.clear(); + + KTrader::OfferList offers = KTrader::self()->query("Katapult/Display"); + KTrader::OfferList::ConstIterator it; + for(it = offers.begin(); it != offers.end(); ++it) + { + KService::Ptr service = *it; + + _displayNames.append(service->name()); + if(!service->property("X-Katapult-ID", QVariant::String).toString().isEmpty()) + _displayIds.append(service->property("X-Katapult-ID", QVariant::String).toString()); + else + _displayIds.append(service->name()); + + if(_displayIds.last() == _displayName) + { + int errCode = 0; + _display = KParts::ComponentFactory::createInstanceFromService<KatapultDisplay> + (service, 0, 0, QStringList(), &errCode); + } + } + if(_display != 0) + { + KConfigGroup group(kapp->config(), QString("Displays/%1").arg(_displayName)); + _display->readSettings(&group); + } +} + +KatapultCatalog * KatapultSettings::catalog(QString catalogName) const +{ + return _activeCatalogs.find(catalogName); +} + +#include "katapultsettings.moc" diff --git a/katapult/katapult/katapultsettings.h b/katapult/katapult/katapultsettings.h new file mode 100644 index 0000000..079ea2b --- /dev/null +++ b/katapult/katapult/katapultsettings.h @@ -0,0 +1,120 @@ +/*************************************************************************** + * Copyright (C) 2005 by Joe Ferris * + * jferris@optimistictech.com * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ +#ifndef KATAPULTSETTINGS_H +#define KATAPULTSETTINGS_H + +#include <qobject.h> +#include <qptrlist.h> +#include <qdict.h> + +class KatapultCatalog; +class KatapultDisplay; +class QStringList; +class QString; + +/** +@author Joe Ferris +*/ +class KatapultSettings : public QObject +{ + Q_OBJECT +public: + enum NRAction { + NR_DoNothing = 0, + NR_ClearQuery = 1, + NR_HideDisplay = 2 + }; + + KatapultSettings(); + ~KatapultSettings(); + + bool isConfiguring() const; + + // general settings + bool isAutoExecute() const; + void setAutoExecute(bool); + int hideDelay() const; + void setHideDelay(int); + int noResultsDelay() const; + void setNoResultsDelay(int); + NRAction noResultsAction() const; + void setNoResultsAction(NRAction); + bool systrayIcon() const; + void setSystrayIcon(bool); + bool hideNotification() const; + int notificationTimeout() const; + + // display settings + QString displayName() const; + QStringList displayNames() const; + QStringList displayIds() const; + int displayNumber() const; + KatapultDisplay * display() const; + void setDisplayName(QString name); + + // catalog settings + QStringList catalogNames() const; + QStringList catalogIds() const; + QStringList activeCatalogNames() const; + QStringList inactiveCatalogNames() const; + QDict<KatapultCatalog> activeCatalogs() const; + void activateCatalog(QString catalogName); + void deactivateCatalog(QString catalogName); + KatapultCatalog * catalog(QString catalogName) const; + +public slots: + void readSettings(); + void writeSettings(); + void configure(); + +signals: + void systrayChanged(); + void displayChanged(); + void catalogsChanged(); + +private: + void loadCatalogPlugins(); + void loadDisplayPlugins(); + + bool _isConfiguring; + bool _forceWrite; + + // general settings + int _hideSessionNotification; // Hide Katapult Notification? (session restore / manual start) + int _hideUserNotification; // if 0: show always, if 1: show once, else: show never + int _notificationTimeout; // Delay before notification hides. + bool _autoExec; + int _hideDelay; + int _noResultsDelay; + NRAction _noResultsAction; + bool _systrayIcon; + + // display settings + QString _displayName; + QStringList _displayNames; + QStringList _displayIds; + KatapultDisplay *_display; + + // catalog settings + QStringList _catalogNames, _catalogIds, _activeCatalogNames; + QDict<KatapultCatalog> _activeCatalogs; +}; + +#endif diff --git a/katapult/katapult/main.cpp b/katapult/katapult/main.cpp new file mode 100644 index 0000000..0fc993d --- /dev/null +++ b/katapult/katapult/main.cpp @@ -0,0 +1,73 @@ +/*************************************************************************** + * Copyright (C) 2005 by Joe Ferris * + * jferris@optimistictech.com * + * * + * 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., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> +#include <kapp.h> +#include <dcopclient.h> + +#include "katapult.h" + +static const char description[] = + I18N_NOOP("A plugin-driven utility that can launch applications, bookmarks, or anything else that you can find a plugin for."); + +static const char version[] = "0.3.2.1"; + +static KCmdLineOptions options[] = +{ + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("katapult", I18N_NOOP("Katapult"), version, description, + KAboutData::License_GPL, I18N_NOOP("(C) until 2005, Joe Ferris\n(C) 2005, the Katapult development team"), 0, 0, "dev@thekatapult.org.uk"); + about.addAuthor( "Martin Meredith" , I18N_NOOP("Project Manager"), "mez@thekatapult.org.uk"); + about.addAuthor( "Bastian Holst", I18N_NOOP("Lead Developer"), "oculus@thekatapult.org.uk" ); + about.addAuthor( "Tobi Vollebregt", I18N_NOOP("Developer"), "tobi@thekatapult.org.uk" ); + about.addAuthor( "Lee Olson", I18N_NOOP("Graphics"), "clearbeast@gmail.com" ); + about.addAuthor( "Jean-Remy Falleri", 0, "jr.falleri@gmail.com" ); + about.addAuthor( "Jonathan Riddell", 0, "jriddell@ubuntu.com" ); + about.addAuthor( "Joe Ferris", I18N_NOOP("Original Author"), "jferris@optimistictech.com" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + KApplication app; + + if(kapp->dcopClient()->isApplicationRegistered("katapult")) { + kapp->dcopClient()->send("katapult", "Katapult", "showLauncher()", QByteArray()); + app.setStartupId(""); + return(0); + } + + Katapult mainWin; + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + app.setMainWidget( &mainWin ); + + args->clear(); + + app.setStartupId(""); + + return app.exec(); +} + diff --git a/katapult/katapult/settings.cpp b/katapult/katapult/settings.cpp new file mode 100644 index 0000000..a659e42 --- /dev/null +++ b/katapult/katapult/settings.cpp @@ -0,0 +1,106 @@ +#include <klocale.h> +/**************************************************************************** +** Form implementation generated from reading ui file '/home/doros/src/local/kde/katapult/katapult/settings.ui' +** +** Created: Fri Feb 18 12:48:28 2005 +** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ + +#include "settings.h" + +#include <qvariant.h> +#include <qlistbox.h> +#include <qtabwidget.h> +#include <qwidget.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +/* + * Constructs a MyDialog1 as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +MyDialog1::MyDialog1( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + if ( !name ) + setName( "MyDialog1" ); + setSizeGripEnabled( TRUE ); + MyDialog1Layout = new QGridLayout( this, 1, 1, 11, 6, "MyDialog1Layout"); + + listBox = new QListBox( this, "listBox" ); + listBox->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)7, 0, 0, listBox->sizePolicy().hasHeightForWidth() ) ); + + MyDialog1Layout->addWidget( listBox, 0, 0 ); + + tabWidget = new QTabWidget( this, "tabWidget" ); + + Widget2 = new QWidget( tabWidget, "Widget2" ); + tabWidget->insertTab( Widget2, QString("") ); + + Widget3 = new QWidget( tabWidget, "Widget3" ); + tabWidget->insertTab( Widget3, QString("") ); + + MyDialog1Layout->addWidget( tabWidget, 0, 1 ); + + Layout1 = new QHBoxLayout( 0, 0, 6, "Layout1"); + + buttonHelp = new QPushButton( this, "buttonHelp" ); + buttonHelp->setAutoDefault( TRUE ); + Layout1->addWidget( buttonHelp ); + Horizontal_Spacing2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + Layout1->addItem( Horizontal_Spacing2 ); + + buttonOk = new QPushButton( this, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + Layout1->addWidget( buttonOk ); + + buttonCancel = new QPushButton( this, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + Layout1->addWidget( buttonCancel ); + + MyDialog1Layout->addMultiCellLayout( Layout1, 1, 1, 0, 1 ); + languageChange(); + resize( QSize(597, 364).expandedTo(minimumSizeHint()) ); + clearWState( WState_Polished ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +MyDialog1::~MyDialog1() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void MyDialog1::languageChange() +{ + setCaption( tr2i18n( "MyDialog1" ) ); + listBox->clear(); + listBox->insertItem( tr2i18n( "New Item" ) ); + tabWidget->changeTab( Widget2, tr2i18n( "Tab" ) ); + tabWidget->changeTab( Widget3, tr2i18n( "Tab" ) ); + buttonHelp->setText( tr2i18n( "&Help" ) ); + buttonHelp->setAccel( QKeySequence( tr2i18n( "F1" ) ) ); + buttonOk->setText( tr2i18n( "&OK" ) ); + buttonOk->setAccel( QKeySequence( QString::null ) ); + buttonCancel->setText( tr2i18n( "&Cancel" ) ); + buttonCancel->setAccel( QKeySequence( QString::null ) ); +} + +#include "settings.moc" |