summaryrefslogtreecommitdiffstats
path: root/tderadio3/plugins/gui-docking-menu
diff options
context:
space:
mode:
Diffstat (limited to 'tderadio3/plugins/gui-docking-menu')
-rw-r--r--tderadio3/plugins/gui-docking-menu/Makefile.am18
-rw-r--r--tderadio3/plugins/gui-docking-menu/docking-configuration.cpp114
-rw-r--r--tderadio3/plugins/gui-docking-menu/docking-configuration.h55
-rw-r--r--tderadio3/plugins/gui-docking-menu/docking.cpp674
-rw-r--r--tderadio3/plugins/gui-docking-menu/docking.h190
-rw-r--r--tderadio3/plugins/gui-docking-menu/po/Makefile.am2
-rw-r--r--tderadio3/plugins/gui-docking-menu/po/de.po117
-rw-r--r--tderadio3/plugins/gui-docking-menu/po/ru.po117
8 files changed, 1287 insertions, 0 deletions
diff --git a/tderadio3/plugins/gui-docking-menu/Makefile.am b/tderadio3/plugins/gui-docking-menu/Makefile.am
new file mode 100644
index 0000000..be50ef5
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/Makefile.am
@@ -0,0 +1,18 @@
+SUBDIRS = po .
+
+INCLUDES = -I$(top_builddir)/kradio3/src $(all_includes)
+METASOURCES = AUTO
+
+libkradio_LTLIBRARIES = libdocking-menu.la
+libdocking_menu_la_SOURCES = docking-configuration.cpp docking.cpp
+libdocking_menu_la_LDFLAGS = -module -avoid-version $(KDE_RPATH) $(all_libraries)
+
+noinst_HEADERS = docking-configuration.h docking.h
+
+
+#messages: rc.cpp
+# $(XGETTEXT) *.cpp *.h -o po/kradio-gui-docking-menu.pot
+
+messages: rc.cpp
+ $(EXTRACTRC) *.rc *.ui >> rc.cpp
+ $(XGETTEXT) rc.cpp *.h *.cpp -o po/kradio-gui-docking-menu.pot
diff --git a/tderadio3/plugins/gui-docking-menu/docking-configuration.cpp b/tderadio3/plugins/gui-docking-menu/docking-configuration.cpp
new file mode 100644
index 0000000..daff887
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/docking-configuration.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+ docking-configuration.cpp - description
+ -------------------
+ begin : Son Aug 3 2003
+ copyright : (C) 2003 by Martin Witte
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include "docking-configuration.h"
+
+#include <tqcombobox.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqframe.h>
+
+#include <klocale.h>
+
+using namespace std;
+
+DockingConfiguration::DockingConfiguration (RadioDocking *docking, TQWidget *parent)
+ : StationSelector(parent),
+ m_docking(docking),
+ m_disableGUIUpdates(false)
+{
+ TQHBoxLayout *layout = new TQHBoxLayout();
+ TQHBoxLayout *layout2 = new TQHBoxLayout();
+
+ m_labelClickMode = new TQLabel(this);
+ layout->addWidget(m_labelClickMode);
+
+ m_comboClickMode = new TQComboBox(this);
+ layout->addWidget(m_comboClickMode);
+
+ TQSpacerItem *spacer = new TQSpacerItem( 20, 2, TQSizePolicy::Expanding, TQSizePolicy::Minimum);
+ layout->addItem(spacer);
+
+ TQFrame *line = new TQFrame(this);
+ line->setFrameShape ( TQFrame::HLine );
+ line->setFrameShadow( TQFrame::Sunken );
+ layout2->addWidget(line);
+
+ StationSelectorUILayout->expand(2,0);
+ StationSelectorUILayout->addMultiCellLayout(layout2, 2, 2, 0, 2);
+ StationSelectorUILayout->addMultiCellLayout(layout, 3, 3, 0, 2);
+
+ connect(m_comboClickMode, TQT_SIGNAL(activated( int )), this, TQT_SLOT(slotSetDirty()));
+
+ languageChange();
+ slotCancel();
+}
+
+
+DockingConfiguration::~DockingConfiguration ()
+{
+}
+
+
+void DockingConfiguration::languageChange()
+{
+ StationSelector::languageChange();
+ m_labelClickMode->setText( i18n( "Left Mouse Click on Tray" ) );
+
+ m_comboClickMode->clear();
+ m_comboClickMode->insertItem(i18n("Show/Hide all GUI Elements"));
+ m_comboClickMode->insertItem(i18n("Power On/Off"));
+}
+
+void DockingConfiguration::slotOK()
+{
+ if (m_dirty) {
+ StationSelector::slotOK();
+ bool old = m_disableGUIUpdates;
+ m_disableGUIUpdates = true;
+ if (m_docking)
+ m_docking->setLeftClickAction((LeftClickAction)m_comboClickMode->currentItem());
+ m_disableGUIUpdates = old;
+ m_dirty = false;
+ }
+}
+
+void DockingConfiguration::slotCancel()
+{
+ if (m_dirty) {
+ StationSelector::slotCancel();
+ if (m_docking)
+ m_comboClickMode->setCurrentItem(m_docking->getLeftClickAction());
+ m_dirty = false;
+ }
+}
+
+void DockingConfiguration::slotLeftClickActionChanged(LeftClickAction action)
+{
+ if (!m_disableGUIUpdates) {
+ if (m_docking)
+ m_comboClickMode->setCurrentItem(action);
+ }
+}
+
+void DockingConfiguration::slotSetDirty()
+{
+ m_dirty = true;
+}
+
+
+#include "docking-configuration.moc"
diff --git a/tderadio3/plugins/gui-docking-menu/docking-configuration.h b/tderadio3/plugins/gui-docking-menu/docking-configuration.h
new file mode 100644
index 0000000..61133c3
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/docking-configuration.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ docking-configuration.h - description
+ -------------------
+ begin : Son Aug 3 2003
+ copyright : (C) 2003 by Martin Witte
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_DOCKING_CONFIGURATION_H
+#define KRADIO_DOCKING_CONFIGURATION_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "../../src/include/stationselector.h"
+#include "docking.h"
+
+class TQComboBox;
+class TQLabel;
+
+class DockingConfiguration : public StationSelector
+{
+Q_OBJECT
+
+public :
+ DockingConfiguration (RadioDocking *docking, TQWidget *parent);
+ ~DockingConfiguration ();
+
+protected slots:
+
+ void slotOK();
+ void slotCancel();
+ void slotSetDirty();
+
+ void slotLeftClickActionChanged(LeftClickAction action);
+ void languageChange();
+
+protected:
+ RadioDocking *m_docking;
+ TQComboBox *m_comboClickMode;
+ TQLabel *m_labelClickMode;
+ bool m_disableGUIUpdates;
+};
+
+#endif
diff --git a/tderadio3/plugins/gui-docking-menu/docking.cpp b/tderadio3/plugins/gui-docking-menu/docking.cpp
new file mode 100644
index 0000000..7c5d817
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/docking.cpp
@@ -0,0 +1,674 @@
+/***************************************************************************
+ docking.cpp - description
+ -------------------
+ begin : Don M�r 8 21:57:17 CET 2001
+ copyright : (C) 2002 by Ernst Martin Witte
+***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include <kiconloader.h>
+#include <tqtooltip.h>
+#include <kpopupmenu.h>
+#include <kapplication.h>
+#include <kaction.h>
+#include <kdialogbase.h>
+#include <kaboutdata.h>
+#include <tdeconfig.h>
+#include <twin.h>
+
+#include "../../src/include/radiodevice_interfaces.h"
+#include "../../src/include/stationlist.h"
+#include "../../src/include/pluginmanager.h"
+#include "../../src/include/widgetplugins.h"
+#include "../../src/include/radiostation.h"
+#include "../../src/include/aboutwidget.h"
+#include "../../src/include/station-drag-object.h"
+
+#include "docking.h"
+#include "docking-configuration.h"
+
+#define POPUP_ID_START_RECORDING_DEFAULT 0
+#define POPUP_ID_STOP_RECORDING_BASE 100
+
+///////////////////////////////////////////////////////////////////////
+
+PLUGIN_LIBRARY_FUNCTIONS(RadioDocking, "kradio-gui-docking-menu", i18n("Tray Menu for TDERadio"));
+
+/////////////////////////////////////////////////////////////////////////////
+
+RadioDocking::RadioDocking(const TQString &name)
+ : KSystemTray (NULL, name.ascii()),
+ PluginBase(name, i18n("Docking Plugin")),
+ m_pluginMenu(NULL),
+ m_recordingMenu(NULL),
+ m_NextRecordingMenuID(POPUP_ID_STOP_RECORDING_BASE),
+ m_leftClickAction(lcaShowHide)
+{
+ setPixmap(BarIcon("kradio"));
+
+ m_menu = contextMenu();
+ TQObject::connect(m_menu, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(slotMenuItemActivated(int)));
+
+ buildContextMenu ();
+ show();
+ setAcceptDrops(true);
+}
+
+RadioDocking::~RadioDocking()
+{
+}
+
+
+bool RadioDocking::connectI (Interface *i)
+{
+ bool a = IRadioClient::connectI(i);
+ bool b = ITimeControlClient::connectI(i);
+ bool c = IRadioDevicePoolClient::connectI(i);
+ bool d = IStationSelection::connectI(i);
+ bool e = ISoundStreamClient::connectI(i);
+ bool f = PluginBase::connectI(i);
+ return a || b || c || d || e || f;
+}
+
+
+bool RadioDocking::disconnectI (Interface *i)
+{
+ bool a = IRadioClient::disconnectI(i);
+ bool b = ITimeControlClient::disconnectI(i);
+ bool c = IRadioDevicePoolClient::disconnectI(i);
+ bool d = IStationSelection::disconnectI(i);
+ bool e = ISoundStreamClient::disconnectI(i);
+ bool f = PluginBase::disconnectI(i);
+ return a || b || c || d || e || f;
+}
+
+
+void RadioDocking::noticeConnectedI (ISoundStreamServer *s, bool pointer_valid)
+{
+ ISoundStreamClient::noticeConnectedI(s, pointer_valid);
+ if (s && pointer_valid) {
+ s->register4_sendStartRecordingWithFormat(this);
+ s->register4_sendStopRecording (this);
+ s->register4_notifySoundStreamChanged (this);
+ }
+}
+
+
+
+bool RadioDocking::setStationSelection(const TQStringList &sl)
+{
+ if (m_stationIDs != sl) {
+ m_stationIDs = sl;
+ buildContextMenu();
+ notifyStationSelectionChanged(m_stationIDs);
+ }
+ return true;
+}
+
+
+// PluginBase
+
+void RadioDocking::restoreState (TDEConfig *config)
+{
+ config->setGroup(TQString("radiodocking-") + name());
+
+ m_stationIDs.clear();
+ int nStations = config->readNumEntry("nStations", 0);
+ for (int i = 1; i <= nStations; ++i) {
+ TQString s = config->readEntry(TQString("stationID-") + TQString().setNum(i), TQString());
+ if (s.length())
+ m_stationIDs += s;
+ }
+
+ m_leftClickAction = (LeftClickAction)config->readNumEntry("left_click_action", lcaShowHide);
+
+ buildContextMenu();
+ notifyStationSelectionChanged(m_stationIDs);
+
+ int n = config->readNumEntry("show_hide_cache_entries", 0);
+ for (int i = 1; i <= n; ++i) {
+ TQString s = config->readEntry(TQString("show_hide_cache_id_%1").arg(i), TQString());
+ bool b = config->readBoolEntry(TQString("show_hide_cache_value_%1").arg(i), false);
+ if (!s.isNull()) {
+ m_widgetsShownCache.insert(s,b);
+ }
+ }
+}
+
+
+void RadioDocking::saveState (TDEConfig *config) const
+{
+ config->setGroup(TQString("radiodocking-") + name());
+
+ config->writeEntry("nStations", m_stationIDs.size());
+ int i = 1;
+ TQStringList::const_iterator end = m_stationIDs.end();
+ for (TQStringList::const_iterator it = m_stationIDs.begin(); it != end; ++it, ++i) {
+ config->writeEntry(TQString("stationID-") + TQString().setNum(i), *it);
+ }
+ config->writeEntry("left_click_action", (int)m_leftClickAction);
+
+ config->writeEntry("show_hide_cache_entries", m_widgetsShownCache.count());
+ i = 1;
+ for (TQMapConstIterator<TQString, bool> it = m_widgetsShownCache.begin(); it != m_widgetsShownCache.end(); ++it, ++i) {
+ config->writeEntry(TQString("show_hide_cache_id_%1").arg(i), it.key());
+ config->writeEntry(TQString("show_hide_cache_value_%1").arg(i), *it);
+ }
+}
+
+
+ConfigPageInfo RadioDocking::createConfigurationPage()
+{
+ DockingConfiguration *conf = new DockingConfiguration(this, NULL);
+ connectI (conf);
+
+ TQObject::connect(this, TQT_SIGNAL(sigLeftClickActionChanged(LeftClickAction)),
+ conf, TQT_SLOT(slotLeftClickActionChanged(LeftClickAction)));
+
+ return ConfigPageInfo(
+ conf,
+ i18n("Docking Menu"),
+ i18n("Docking Menu Configuration"),
+ "kmenuedit"
+ );
+}
+
+AboutPageInfo RadioDocking::createAboutPage()
+{
+/* TDEAboutData aboutData("kradio",
+ NULL,
+ NULL,
+ I18N_NOOP("Docking Menu for TDERadio"),
+ TDEAboutData::License_GPL,
+ "(c) 2002-2005 Martin Witte, Klas Kalass",
+ 0,
+ "http://sourceforge.net/projects/kradio",
+ 0);
+ aboutData.addAuthor("Martin Witte", "", "[email protected]");
+ aboutData.addAuthor("Klas Kalass", "", "[email protected]");
+
+ return AboutPageInfo(
+ new TDERadioAboutWidget(aboutData, TDERadioAboutWidget::AbtTabbed),
+ i18n("Docking Menu"),
+ i18n("Docking Menu Plugin"),
+ "kmenuedit"
+ );*/
+ return AboutPageInfo();
+}
+
+
+
+void RadioDocking::buildContextMenu()
+{
+ m_menu->clear();
+ m_pluginMenu = NULL;
+ m_recordingMenu = NULL;
+
+ m_titleID = m_menu->insertTitle ("title-dummy");
+
+ buildStationList();
+
+ m_alarmID = m_menu->insertTitle ("alarm-dummy");
+ noticeNextAlarmChanged(queryNextAlarm());
+
+ m_sleepID = m_menu->insertItem(SmallIcon("kradio_zzz"), "sleep-dummy",
+ this, TQT_SLOT(slotSleepCountdown()));
+ noticeCountdownStarted(queryCountdownEnd());
+
+ m_seekfwID = m_menu->insertItem(SmallIcon("forward"), i18n("Search Next Station"),
+ this, TQT_SLOT(slotSeekFwd()));
+ m_seekbwID = m_menu->insertItem(SmallIcon("back"), i18n("Search Previous Station"),
+ this, TQT_SLOT(slotSeekBkwd()));
+
+ // recording menu
+ buildRecordingMenu();
+ m_menu->insertItem(i18n("Recording"), m_recordingMenu);
+
+
+ m_powerID = m_menu->insertItem(SmallIcon("kradio_muteoff"), "power-dummy",
+ this, TQT_SLOT(slotPower()));
+ m_pauseID = m_menu->insertItem(SmallIcon("kradio_pause"), i18n("Pause Radio"),
+ this, TQT_SLOT(slotPause()));
+ noticePowerChanged(queryIsPowerOn());
+
+ m_menu->insertSeparator();
+
+ m_menu->insertItem(SmallIcon("kradio"), i18n("&About"), this, TQT_SLOT(slotShowAbout()));
+
+ // build list of widgets for hide/show items
+ m_pluginMenu = new TDEPopupMenu(m_menu);
+ if (m_manager) {
+ m_manager->addWidgetPluginMenuItems(m_pluginMenu, m_widgetPluginIDs);
+ m_menu->insertItem(SmallIcon("kradio_plugins"), i18n("Show/Hide Plugins"), m_pluginMenu);
+ }
+
+ m_menu->insertSeparator();
+ m_menu->insertItem( SmallIcon("exit"), i18n("&Quit" ), kapp, TQT_SLOT(quit()) );
+
+
+ noticeStationChanged(queryCurrentStation(), -1);
+
+}
+
+
+void RadioDocking::buildStationList()
+{
+ m_stationMenuIDs.clear();
+
+ const RawStationList &sl = queryStations().all();
+ const RadioStation &crs = queryCurrentStation();
+
+ int k = 0;
+ TQStringList::iterator end = m_stationIDs.end();
+ for (TQStringList::iterator it = m_stationIDs.begin(); it != end; ++it) {
+ const RadioStation &rs = sl.stationWithID(*it);
+
+ if (rs.isValid()) {
+
+ ++k;
+ TQString shortcut = k < 10 ? "&"+TQString().setNum(k) : k == 10 ? "1&0" : TQString().setNum(k);
+ TQString name = rs.longName().replace("&", "&&");
+ TQString item = shortcut + " " + name;
+ int id = m_menu->insertItem(item);
+
+ m_stationMenuIDs.push_back(id);
+ m_menu->setItemChecked (id, rs.compare(crs) == 0);
+
+ } else {
+ m_stationMenuIDs.push_back(-1);
+ }
+ }
+}
+
+
+void RadioDocking::slotSeekFwd()
+{
+ ISeekRadio *seeker = dynamic_cast<ISeekRadio*>(queryActiveDevice());
+ if (seeker)
+ seeker->startSeekUp();
+}
+
+
+void RadioDocking::slotSeekBkwd()
+{
+ ISeekRadio *seeker = dynamic_cast<ISeekRadio*>(queryActiveDevice());
+ if (seeker)
+ seeker->startSeekUp();
+}
+
+
+
+void RadioDocking::slotShowAbout()
+{
+ if (m_manager) {
+ KDialogBase *d = m_manager->getAboutDialog();
+ if (d) d->show();
+ }
+}
+
+
+void RadioDocking::slotPower()
+{
+ if (queryIsPowerOn()) {
+ sendPowerOff();
+ } else {
+ sendPowerOn();
+ }
+}
+
+
+void RadioDocking::slotPause()
+{
+ if (queryIsPowerOn()) {
+ sendPausePlayback(queryCurrentSoundStreamID());
+ }
+}
+
+
+void RadioDocking::slotSleepCountdown()
+{
+ if (queryCountdownEnd().isValid()) {
+ sendStopCountdown();
+ } else {
+ sendStartCountdown();
+ }
+}
+
+
+bool RadioDocking::noticeNextAlarmChanged(const Alarm *a)
+{
+ TQDateTime d;
+ if (a) d = a->nextAlarm();
+
+ if (d.isValid())
+ m_menu->changeTitle (m_alarmID, i18n("next alarm: %1").arg(d.toString()));
+ else
+ m_menu->changeTitle (m_alarmID, i18n("<no alarm pending>"));
+ return true;
+}
+
+
+bool RadioDocking::noticeCountdownStarted(const TQDateTime &end)
+{
+ if (end.isValid())
+ m_menu->changeItem (m_sleepID, SmallIcon("kradio_zzz"), i18n("Stop Sleep Countdown (running until %1)").arg(end.toString()));
+ else
+ m_menu->changeItem (m_sleepID, SmallIcon("kradio_zzz"), i18n("Start Sleep Countdown"));
+ return true;
+}
+
+
+bool RadioDocking::noticeCountdownStopped()
+{
+ m_menu->changeItem (m_sleepID, SmallIcon("kradio_zzz"), i18n("Start Sleep Countdown"));
+ return true;
+}
+
+
+bool RadioDocking::noticeCountdownZero()
+{
+ m_menu->changeItem (m_sleepID, SmallIcon("kradio_zzz"), i18n("Start Sleep Countdown"));
+ return true;
+}
+
+
+bool RadioDocking::noticePowerChanged(bool on)
+{
+ m_menu->changeItem(m_powerID, SmallIcon(on ? "kradio_muteon" : "kradio_muteoff"),
+ on ? i18n("Power Off") : i18n("Power On"));
+ m_menu->setItemEnabled(m_pauseID, on);
+ return true;
+}
+
+bool RadioDocking::noticeCountdownSecondsChanged(int /*n*/)
+{
+ return false;
+}
+
+
+
+bool RadioDocking::noticeStationChanged (const RadioStation &rs, int /*idx*/)
+{
+ TQString s = i18n("invalid station");
+ if (rs.isValid())
+ s = rs.longName();
+
+ TQToolTip::add(this, s);
+ m_menu->changeTitle (m_titleID, i18n("TDERadio: %1").arg(s));
+ // FIXME: title does not change in opened popupmenu
+
+ TQValueList<int>::iterator iit = m_stationMenuIDs.begin();
+ TQValueList<int>::iterator end = m_stationMenuIDs.end();
+ TQStringList::iterator sit = m_stationIDs.begin();
+ for (; iit != end; ++iit, ++sit) {
+ if (*iit != -1) {
+ bool on = rs.stationID() == *sit;
+ m_menu->setItemChecked (*iit, on);
+ }
+ }
+
+ bool r = false;
+ SoundFormat sf;
+ queryIsRecordingRunning(queryCurrentSoundStreamID(), r, sf);
+ m_recordingMenu->setItemEnabled(m_recordingID, !r);
+ return true;
+}
+
+
+bool RadioDocking::noticeStationsChanged(const StationList &/*sl*/)
+{
+ buildContextMenu();
+ return true;
+}
+
+
+void RadioDocking::mousePressEvent( TQMouseEvent *e )
+{
+ KSystemTray::mousePressEvent(e);
+
+ switch ( e->button() ) {
+ case Qt::LeftButton:
+ switch (m_leftClickAction) {
+ case lcaShowHide :
+ ShowHideWidgetPlugins();
+ // FIXME: [mcamen] According the KDE usability guidelines a left
+ // click on the systray icon should show/hide the
+ // application window
+ // TODO: [mcamen] Use KSystemtray::toggleActive and friends once we
+ // depend on KDE 3.3
+ break;
+ case lcaPowerOnOff :
+ if (queryIsPowerOn())
+ sendPowerOff();
+ else
+ sendPowerOn();
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ // nothing
+ break;
+ }
+}
+
+void RadioDocking::ShowHideWidgetPlugins()
+{
+ // nothing in cache => hide everything
+ if (!m_widgetsShownCache.count()) {
+ for (TQMapIterator<WidgetPluginBase*, int> it = m_widgetPluginIDs.begin(); it != m_widgetPluginIDs.end(); ++it) {
+ WidgetPluginBase *p = it.key();
+ if (p) {
+ bool visible = p->isAnywhereVisible();
+ TQString name = p->name();
+ logDebug(TQString("visibility of %1: %2").arg(name).arg(visible));
+ m_widgetsShownCache.insert(name, visible);
+ p->getWidget()->hide();
+ }
+ }
+ }
+ else {
+ TQMap<TQString, bool> tmpCache = m_widgetsShownCache;
+ int d = KWin::currentDesktop();
+ for (TQMapIterator<WidgetPluginBase*, int> it = m_widgetPluginIDs.begin(); it != m_widgetPluginIDs.end(); ++it) {
+ WidgetPluginBase *p = it.key();
+ TQString name = p ? p->name() : TQString();
+ if (p && tmpCache.contains(name) && tmpCache[name]) {
+ p->showOnOrgDesktop();
+ }
+ }
+ m_widgetsShownCache.clear();
+ KWin::setCurrentDesktop(d);
+ }
+}
+
+void RadioDocking::slotMenuItemActivated(int id)
+{
+ const StationList &sl = queryStations();
+ TQValueList<int>::iterator iit = m_stationMenuIDs.begin();
+ TQValueList<int>::iterator end = m_stationMenuIDs.end();
+ TQStringList::iterator sit = m_stationIDs.begin();
+ for (; iit != end; ++iit, ++sit) {
+ if (*iit == id) {
+ const RadioStation &rs = sl.stationWithID(*sit);
+ if (rs.isValid())
+ sendActivateStation(rs);
+ }
+ }
+}
+
+
+void RadioDocking::noticeWidgetPluginShown(WidgetPluginBase *b, bool shown)
+{
+ if (!m_manager || !b || !m_widgetPluginIDs.contains(b))
+ return;
+ m_manager->updateWidgetPluginMenuItem(b, m_pluginMenu, m_widgetPluginIDs, shown);
+
+ if (shown)
+ m_widgetsShownCache.clear();
+}
+
+
+void RadioDocking::noticePluginsChanged(const PluginList &/*l*/)
+{
+ buildContextMenu();
+}
+
+
+// ISoundStreamClient
+
+bool RadioDocking::startRecordingWithFormat(
+ SoundStreamID id,
+ const SoundFormat &/*proposed_format*/,
+ SoundFormat &/*real_format*/)
+{
+ if (!id.isValid() || id != queryCurrentSoundStreamID() || m_StreamID2MenuID.contains(id))
+ return false;
+
+ TQString descr;
+ querySoundStreamDescription(id, descr);
+ int menu_id = m_NextRecordingMenuID++;
+ m_recordingMenu->insertItem(SmallIcon("kradio_record"),
+ i18n("Stop Recording of %1").arg(descr),
+ menu_id);
+ m_MenuID2StreamID.insert(menu_id, id);
+ m_StreamID2MenuID.insert(id, menu_id);
+
+ if (id == queryCurrentSoundStreamID())
+ m_recordingMenu->setItemEnabled(m_recordingID, false);
+
+ setPixmap(BarIcon("kradio_plus_rec"));
+ return false; // this is only a "hook" that does not initiate the recording so don't say that we handled the event
+}
+
+
+bool RadioDocking::stopRecording (SoundStreamID id)
+{
+ if (!id.isValid() || !m_StreamID2MenuID.contains(id))
+ return false;
+
+ int menu_id = m_StreamID2MenuID[id];
+ m_recordingMenu->removeItem(menu_id);
+ m_MenuID2StreamID.remove(menu_id);
+ m_StreamID2MenuID.remove(id);
+
+ if (id == queryCurrentSoundStreamID())
+ m_recordingMenu->setItemEnabled(m_recordingID, true);
+
+ setPixmap(BarIcon("kradio"));
+
+ return false;
+}
+
+
+void RadioDocking::slotRecordingMenu(int i)
+{
+ if (i == POPUP_ID_START_RECORDING_DEFAULT) {
+ SoundStreamID id = queryCurrentSoundStreamID();
+ bool r = false;
+ SoundFormat sf;
+ queryIsRecordingRunning(id, r, sf);
+ if (!r) {
+ if (!queryIsPowerOn())
+ sendPowerOn();
+ sendStartRecording(id);
+ }
+ } else if (m_MenuID2StreamID.contains(i)) {
+ sendStopRecording(m_MenuID2StreamID[i]);
+ }
+}
+
+void RadioDocking::buildRecordingMenu()
+{
+ TQMap<TQString, SoundStreamID> streams;
+ queryEnumerateSoundStreams(streams);
+
+ TDEPopupMenu *m = new TDEPopupMenu(m_menu);
+
+ m_recordingID = m->insertItem(SmallIcon("kradio_record"), i18n("Start Recording"),
+ POPUP_ID_START_RECORDING_DEFAULT);
+ TQObject::connect(m, TQT_SIGNAL(activated(int)),
+ this, TQT_SLOT(slotRecordingMenu(int)));
+ SoundStreamID currentID = queryCurrentSoundStreamID();
+
+ TQMapIterator<TQString, SoundStreamID> end = streams.end();
+ for (TQMapIterator<TQString, SoundStreamID> it = streams.begin(); it != end; ++it) {
+
+ SoundStreamID id = *it;
+ TQString descr = it.key();
+ bool r = false;
+ SoundFormat sf;
+ queryIsRecordingRunning(id, r, sf);
+ if (r) {
+ int menu_id = m_NextRecordingMenuID++;
+ m->insertItem(SmallIcon("kradio_record"),
+ i18n("Stop Recording of %1").arg(descr),
+ menu_id);
+ m_MenuID2StreamID.insert(menu_id, id);
+ m_StreamID2MenuID.insert(id, menu_id);
+
+ if (id == currentID)
+ m_recordingMenu->setItemEnabled(m_recordingID, false);
+ }
+ }
+ m_recordingMenu = m;
+}
+
+
+bool RadioDocking::noticeSoundStreamChanged(SoundStreamID id)
+{
+ if (m_StreamID2MenuID.contains(id)) {
+ TQString descr;
+ querySoundStreamDescription(id, descr);
+ m_recordingMenu->changeItem(m_StreamID2MenuID[id],
+ SmallIcon("kradio_record"),
+ i18n("Stop Recording of %1").arg(descr));
+ return true;
+ }
+ return false;
+}
+
+
+void RadioDocking::setLeftClickAction(LeftClickAction action)
+{
+ if (m_leftClickAction != action) {
+ m_leftClickAction = action;
+ emit sigLeftClickActionChanged(m_leftClickAction);
+ }
+}
+
+void RadioDocking::dragEnterEvent(TQDragEnterEvent* event)
+{
+ bool a = StationDragObject::canDecode(event);
+ if (a)
+ IErrorLogClient::staticLogDebug("contentsDragEnterEvent accepted");
+ else
+ IErrorLogClient::staticLogDebug("contentsDragEnterEvent rejected");
+ event->accept(a);
+}
+
+void RadioDocking::dropEvent(TQDropEvent* event)
+{
+ TQStringList list;
+
+ if ( StationDragObject::decode(event, list) ) {
+ TQStringList l = getStationSelection();
+ for (TQValueListConstIterator<TQString> it = list.begin(); it != list.end(); ++it)
+ if (!l.contains(*it))
+ l.append(*it);
+ setStationSelection(l);
+ }
+}
+
+#include "docking.moc"
diff --git a/tderadio3/plugins/gui-docking-menu/docking.h b/tderadio3/plugins/gui-docking-menu/docking.h
new file mode 100644
index 0000000..c4e5f6d
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/docking.h
@@ -0,0 +1,190 @@
+/***************************************************************************
+ docking.h - description
+ -------------------
+ begin : Mon Jan 14 2002
+ copyright : (C) 2001, 2002 by Frank Schwanz, Ernst Martin Witte
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KRADIO_DOCKING_H
+#define KRADIO_DOCKING_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ksystemtray.h>
+#include <tqpixmap.h>
+#include <tqptrdict.h>
+
+#include "../../src/include/timecontrol_interfaces.h"
+#include "../../src/include/radio_interfaces.h"
+#include "../../src/include/radiodevicepool_interfaces.h"
+#include "../../src/include/stationselection_interfaces.h"
+#include "../../src/include/plugins.h"
+#include "../../src/include/soundstreamclient_interfaces.h"
+
+enum LeftClickAction { lcaShowHide = 0, lcaPowerOnOff = 1 };
+
+class RadioDocking : public KSystemTray,
+ public PluginBase,
+ public IRadioClient,
+ public ITimeControlClient,
+ public IRadioDevicePoolClient,
+ public IStationSelection,
+ public ISoundStreamClient
+{
+Q_OBJECT
+
+public:
+ RadioDocking (const TQString &name);
+ virtual ~RadioDocking();
+
+ virtual bool connectI (Interface *);
+ virtual bool disconnectI (Interface *);
+
+ virtual TQString pluginClassName() const { return "RadioDocking"; }
+
+ virtual const TQString &name() const { return PluginBase::name(); }
+ virtual TQString &name() { return PluginBase::name(); }
+
+
+ // PluginBase
+
+public:
+ virtual void saveState (TDEConfig *) const;
+ virtual void restoreState (TDEConfig *);
+
+ virtual ConfigPageInfo createConfigurationPage();
+ virtual AboutPageInfo createAboutPage();
+
+
+ // IStationSelection
+
+RECEIVERS:
+ bool setStationSelection(const TQStringList &sl);
+
+ANSWERS:
+ const TQStringList & getStationSelection () const { return m_stationIDs; }
+
+
+ // IRadioDevicePoolClient
+
+RECEIVERS:
+ bool noticeActiveDeviceChanged(IRadioDevice *) { return false; }
+ bool noticeDevicesChanged(const TQPtrList<IRadioDevice> &) { return false; }
+ bool noticeDeviceDescriptionChanged(const TQString &) { return false; }
+
+ // ITimeControlClient
+
+RECEIVERS:
+ bool noticeAlarmsChanged(const AlarmVector &) { return false; }
+ bool noticeAlarm(const Alarm &) { return false; }
+ bool noticeNextAlarmChanged(const Alarm *);
+ bool noticeCountdownStarted(const TQDateTime &/*end*/);
+ bool noticeCountdownStopped();
+ bool noticeCountdownZero();
+ bool noticeCountdownSecondsChanged(int n);
+
+
+ // IRadioClient
+
+RECEIVERS:
+ bool noticePowerChanged(bool on);
+ bool noticeStationChanged (const RadioStation &, int idx);
+ bool noticeStationsChanged(const StationList &sl);
+ bool noticePresetFileChanged(const TQString &/*f*/) { return false; }
+
+ bool noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/) { return false; }
+
+ // ISoundStreamClient
+
+RECEIVERS:
+ void noticeConnectedI (ISoundStreamServer *s, bool pointer_valid);
+
+ bool startRecordingWithFormat(SoundStreamID /*id*/,
+ const SoundFormat &/*proposed_format*/,
+ SoundFormat &/*real_format*/);
+ bool stopRecording(SoundStreamID /*id*/);
+
+ bool noticeSoundStreamChanged(SoundStreamID id);
+
+
+protected slots:
+
+ void slotSeekFwd();
+ void slotSeekBkwd();
+
+ void slotPower();
+ void slotPause();
+ void slotSleepCountdown();
+ void slotShowAbout();
+
+ void slotMenuItemActivated(int id);
+ void slotRecordingMenu(int i);
+
+protected:
+ void mousePressEvent( TQMouseEvent *e );
+
+ void buildContextMenu();
+ void buildRecordingMenu();
+ void buildStationList();
+
+ void noticeWidgetPluginShown(WidgetPluginBase *, bool shown);
+ void noticePluginsChanged(const PluginList &);
+
+ void showEvent(TQShowEvent *) {} // do nothing, original implementation adds "Quit" menu item
+
+ void ShowHideWidgetPlugins();
+
+ void dragEnterEvent(TQDragEnterEvent* event);
+ void dropEvent(TQDropEvent* event);
+
+public:
+
+ LeftClickAction getLeftClickAction() const { return m_leftClickAction; }
+ void setLeftClickAction(LeftClickAction action);
+
+signals:
+ void sigLeftClickActionChanged(LeftClickAction action);
+
+protected:
+
+ TDEPopupMenu *m_menu;
+ TDEPopupMenu *m_pluginMenu;
+ TDEPopupMenu *m_recordingMenu;
+ TQStringList m_stationIDs;
+
+ // menu Item IDs
+ int m_titleID;
+ int m_alarmID;
+ int m_recordingID;
+ int m_powerID;
+ int m_pauseID;
+ int m_sleepID;
+ int m_seekfwID;
+ int m_seekbwID;
+ TQValueList<int> m_stationMenuIDs;
+
+ TQMap<WidgetPluginBase *, int> m_widgetPluginIDs;
+
+ int m_NextRecordingMenuID;
+ TQMap<int, SoundStreamID> m_MenuID2StreamID;
+ TQMap<SoundStreamID, int> m_StreamID2MenuID;
+
+ LeftClickAction m_leftClickAction;
+
+ TQMap<TQString, bool> m_widgetsShownCache;
+};
+
+
+#endif
diff --git a/tderadio3/plugins/gui-docking-menu/po/Makefile.am b/tderadio3/plugins/gui-docking-menu/po/Makefile.am
new file mode 100644
index 0000000..e02511d
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/po/Makefile.am
@@ -0,0 +1,2 @@
+PACKAGE = kradio-gui-docking-menu
+POFILES = AUTO
diff --git a/tderadio3/plugins/gui-docking-menu/po/de.po b/tderadio3/plugins/gui-docking-menu/po/de.po
new file mode 100644
index 0000000..717d5f9
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/po/de.po
@@ -0,0 +1,117 @@
+# translation of de.po to
+# translation of kradio-gui-docking-menu.po to
+# This file is put in the public domain.
+#
+# Ernst Martin Witte <[email protected]>, 2006.
+msgid ""
+msgstr ""
+"Project-Id-Version: de\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-10 23:20+0100\n"
+"PO-Revision-Date: 2006-11-06 00:36+0100\n"
+"Last-Translator: Ernst Martin Witte <[email protected]>\n"
+"Language-Team: <[email protected]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.11.4\n"
+
+#: _translatorinfo.cpp:1
+msgid ""
+"_: NAME OF TRANSLATORS\n"
+"Your names"
+msgstr "Ernst Martin Witte"
+
+#: _translatorinfo.cpp:3
+msgid ""
+"_: EMAIL OF TRANSLATORS\n"
+"Your emails"
+
+#: docking-configuration.cpp:70
+msgid "Left Mouse Click on Tray"
+msgstr "Linker Mausklick auf Kontrolleistensymbol"
+
+#: docking-configuration.cpp:73
+msgid "Show/Hide all GUI Elements"
+msgstr "Alle Fenster anzeigen/verstecken"
+
+#: docking-configuration.cpp:74
+msgid "Power On/Off"
+msgstr "Ein/Ausschalten"
+
+#: docking.cpp:44
+msgid "Tray Menu for TDERadio"
+msgstr "Kontrollleistenmenü für TDERadio"
+
+#: docking.cpp:50
+msgid "Docking Plugin"
+msgstr "Plugin für die Kontrolleiste"
+
+#: docking.cpp:180
+msgid "Docking Menu"
+msgstr "Kontrolleisten-Menü"
+
+#: docking.cpp:181
+msgid "Docking Menu Configuration"
+msgstr "Konfiguration des Kontrollleisten-Menüs"
+
+#: docking.cpp:228
+msgid "Search Next Station"
+msgstr "Suche nächsten Sender"
+
+#: docking.cpp:230
+msgid "Search Previous Station"
+msgstr "Suche vorherigen Sender"
+
+#: docking.cpp:235
+msgid "Recording"
+msgstr "Aufnahme"
+
+#: docking.cpp:240
+msgid "Pause Radio"
+msgstr "Radiowiedergabe pausieren"
+
+#: docking.cpp:252
+msgid "Show/Hide Plugins"
+msgstr "Plugins anzeigen/verstecken"
+
+#: docking.cpp:354
+msgid "next alarm: %1"
+msgstr "Nächstes Wecken: %1"
+
+#: docking.cpp:356
+msgid "<no alarm pending>"
+msgstr "<Wecker nicht aktiv>"
+
+#: docking.cpp:364
+msgid "Stop Sleep Countdown (running until %1)"
+msgstr "Schlummermodus abbrechen (liefe bis %1)"
+
+#: docking.cpp:366 docking.cpp:373 docking.cpp:380
+msgid "Start Sleep Countdown"
+msgstr "Schlummermodus einschalten"
+
+#: docking.cpp:388
+msgid "Power Off"
+msgstr "Ausschalten"
+
+#: docking.cpp:388
+msgid "Power On"
+msgstr "Einschalten"
+
+#: docking.cpp:402
+msgid "invalid station"
+msgstr "ungültiger Sender"
+
+#: docking.cpp:407
+msgid "TDERadio: %1"
+msgstr "TDERadio: %1"
+
+#: docking.cpp:543 docking.cpp:616 docking.cpp:636
+msgid "Stop Recording of %1"
+msgstr "Aufnahme %1 abbrechen"
+
+#: docking.cpp:599
+msgid "Start Recording"
+msgstr "Aufnahme starten"
diff --git a/tderadio3/plugins/gui-docking-menu/po/ru.po b/tderadio3/plugins/gui-docking-menu/po/ru.po
new file mode 100644
index 0000000..03050f6
--- /dev/null
+++ b/tderadio3/plugins/gui-docking-menu/po/ru.po
@@ -0,0 +1,117 @@
+# translation of ru.po to
+# translation of kradio-gui-docking-menu.po to
+# This file is put in the public domain.
+# Алексей Кузнецов <[email protected]>, 2006.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: ru\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2006-11-11 02:11+0100\n"
+"PO-Revision-Date: 2006-11-08 12:16+0300\n"
+"Last-Translator: Алексей Кузнецов <[email protected]>\n"
+"Language-Team: <[email protected]>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Generator: KBabel 1.10\n"
+
+#: _translatorinfo.cpp:1
+msgid ""
+"_: NAME OF TRANSLATORS\n"
+"Your names"
+msgstr "Алексей Кузнецов"
+
+#: _translatorinfo.cpp:3
+msgid ""
+"_: EMAIL OF TRANSLATORS\n"
+"Your emails"
+
+#: docking-configuration.cpp:70
+msgid "Left Mouse Click on Tray"
+msgstr "По щелчку левой кнопкой мыши"
+
+#: docking-configuration.cpp:73
+msgid "Show/Hide all GUI Elements"
+msgstr "Показать/скрыть все окна"
+
+#: docking-configuration.cpp:74
+msgid "Power On/Off"
+msgstr "Включить/выключить"
+
+#: docking.cpp:44
+msgid "Tray Menu for TDERadio"
+msgstr "Меню лотка для TDERadio"
+
+#: docking.cpp:50
+msgid "Docking Plugin"
+msgstr "Модуль системного лотка"
+
+#: docking.cpp:180
+msgid "Docking Menu"
+msgstr "Меню лотка"
+
+#: docking.cpp:181
+msgid "Docking Menu Configuration"
+msgstr "Конфигурация меню лотка"
+
+#: docking.cpp:228
+msgid "Search Next Station"
+msgstr "Искать следующую станцию"
+
+#: docking.cpp:230
+msgid "Search Previous Station"
+msgstr "Искать предыдущую станцию"
+
+#: docking.cpp:235
+msgid "Recording"
+msgstr "Запись"
+
+#: docking.cpp:240
+msgid "Pause Radio"
+msgstr "Приостановить"
+
+#: docking.cpp:252
+msgid "Show/Hide Plugins"
+msgstr "Показать/скрыть"
+
+#: docking.cpp:354
+msgid "next alarm: %1"
+msgstr "След. действие: %1"
+
+#: docking.cpp:356
+msgid "<no alarm pending>"
+msgstr "<Расписание пусто>"
+
+#: docking.cpp:364
+msgid "Stop Sleep Countdown (running until %1)"
+msgstr "Остановить таймер отключения (установлено на %1)"
+
+#: docking.cpp:366 docking.cpp:373 docking.cpp:380
+msgid "Start Sleep Countdown"
+msgstr "Запустить таймер отключения"
+
+#: docking.cpp:388
+msgid "Power Off"
+msgstr "Выключить"
+
+#: docking.cpp:388
+msgid "Power On"
+msgstr "Включить"
+
+#: docking.cpp:402
+msgid "invalid station"
+msgstr "Неверная станция"
+
+#: docking.cpp:407
+msgid "TDERadio: %1"
+msgstr "Радиоприёмник KDE"
+
+#: docking.cpp:543 docking.cpp:616 docking.cpp:636
+msgid "Stop Recording of %1"
+msgstr "Остановить запись %1"
+
+#: docking.cpp:599
+msgid "Start Recording"
+msgstr "Начать запись"