You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
808 lines
23 KiB
808 lines
23 KiB
15 years ago
|
/***************************************************************************
|
||
|
radioview.cpp - description
|
||
|
-------------------
|
||
|
begin : Mit Mai 28 2003
|
||
|
copyright : (C) 2003 by Martin Witte
|
||
|
email : witte@kawo1.rwth-aachen.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. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
14 years ago
|
#include <tqwidgetstack.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqtoolbutton.h>
|
||
|
#include <tqslider.h>
|
||
|
#include <tqfile.h>
|
||
|
#include <tqtooltip.h>
|
||
|
#include <tqcheckbox.h>
|
||
|
#include <tqimage.h>
|
||
15 years ago
|
|
||
|
#include <kcombobox.h>
|
||
|
#include <kiconloader.h>
|
||
12 years ago
|
#include <tdelocale.h>
|
||
12 years ago
|
#include <tdeapplication.h>
|
||
13 years ago
|
#include <twin.h>
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
12 years ago
|
#include <tdepopupmenu.h>
|
||
15 years ago
|
|
||
|
#include "../../src/include/radiodevice_interfaces.h"
|
||
|
#include "../../src/include/radiostation.h"
|
||
|
#include "../../src/include/stationlist.h"
|
||
|
#include "../../src/include/pluginmanager.h"
|
||
|
#include "../../src/include/plugin_configuration_dialog.h"
|
||
|
#include "../../src/include/aboutwidget.h"
|
||
|
|
||
|
#include "radioview.h"
|
||
|
#include "radioview_frequencyradio.h"
|
||
|
#include "radioview_volume.h"
|
||
|
#include "radioview_frequencyseeker.h"
|
||
|
#include "radioview-configuration.h"
|
||
|
|
||
12 years ago
|
#include <tdeaboutdata.h>
|
||
15 years ago
|
|
||
|
#define POPUP_ID_START_RECORDING_DEFAULT 0
|
||
|
#define POPUP_ID_STOP_RECORDING_BASE 100
|
||
|
|
||
|
///////////////////////////////////////////////////////////////////////
|
||
|
|
||
12 years ago
|
PLUGIN_LIBRARY_FUNCTIONS(RadioView, "tderadio-gui-standard-display", i18n("Standard Display for TDERadio"));
|
||
15 years ago
|
|
||
|
///////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
bool RadioView::ElementCfg::operator == (const ElementCfg &x) const
|
||
|
{
|
||
|
if (!x.element || !element)
|
||
|
return x.cfg == cfg;
|
||
|
if (!x.cfg || !cfg)
|
||
|
return x.element == element;
|
||
|
return element == x.element && cfg == x.cfg;
|
||
|
}
|
||
|
|
||
|
///////////////////////////////////////////////////////////////////////
|
||
|
|
||
14 years ago
|
RadioView::RadioView(const TQString &name)
|
||
|
: TQWidget(NULL, name.ascii()),
|
||
15 years ago
|
WidgetPluginBase(name, i18n("Radio Display")),
|
||
|
enableToolbarFlag(false),
|
||
|
btnPower(NULL),
|
||
|
btnConfigure(NULL),
|
||
|
btnQuit(NULL),
|
||
|
btnRecording(NULL),
|
||
|
btnSnooze(NULL),
|
||
|
btnPlugins(NULL),
|
||
|
comboStations(NULL),
|
||
|
currentDevice(NULL),
|
||
|
m_RecordingMenu(NULL),
|
||
|
m_NextRecordingMenuID(POPUP_ID_STOP_RECORDING_BASE),
|
||
|
m_PluginMenu(NULL)
|
||
|
{
|
||
|
for (int i = 0; i < clsClassMAX; ++i)
|
||
|
maxUsability[i] = 0;
|
||
|
|
||
14 years ago
|
TQBoxLayout *l01 = new TQBoxLayout(this, TQBoxLayout::LeftToRight, /*spacing=*/3);
|
||
15 years ago
|
l01->setMargin(1);
|
||
|
l01->setSpacing(2);
|
||
14 years ago
|
widgetStacks[clsRadioSound] = new TQWidgetStack (this);
|
||
15 years ago
|
l01->addWidget(widgetStacks[clsRadioSound]);
|
||
|
|
||
14 years ago
|
TQBoxLayout *l02 = new TQBoxLayout(l01, TQBoxLayout::Down);
|
||
|
TQBoxLayout *l03 = new TQBoxLayout(l02, TQBoxLayout::LeftToRight);
|
||
15 years ago
|
comboStations = new KComboBox (this);
|
||
|
l02->addWidget (comboStations);
|
||
|
|
||
14 years ago
|
TQBoxLayout *l05 = new TQBoxLayout(l03, TQBoxLayout::Down);
|
||
|
widgetStacks[clsRadioDisplay] = new TQWidgetStack (this);
|
||
15 years ago
|
l05->addWidget(widgetStacks[clsRadioDisplay]);
|
||
14 years ago
|
widgetStacks[clsRadioSeek] = new TQWidgetStack (this);
|
||
15 years ago
|
l05->addWidget(widgetStacks[clsRadioSeek]);
|
||
|
|
||
14 years ago
|
TQGridLayout *l04 = new TQGridLayout (l03, /*rows=*/ 3, /*cols=*/ 2);
|
||
|
btnPower = new TQToolButton(this);
|
||
15 years ago
|
btnPower->setToggleButton(true);
|
||
14 years ago
|
btnRecording = new TQToolButton(this);
|
||
15 years ago
|
btnRecording->setToggleButton(true);
|
||
14 years ago
|
btnConfigure = new TQToolButton(this);
|
||
15 years ago
|
btnConfigure->setToggleButton(true);
|
||
14 years ago
|
btnQuit = new TQToolButton(this);
|
||
|
btnSnooze = new TQToolButton(this);
|
||
15 years ago
|
btnSnooze->setToggleButton(true);
|
||
14 years ago
|
btnPlugins = new TQToolButton(this);
|
||
15 years ago
|
btnPlugins->setPopupDelay(1);
|
||
|
l04->addWidget (btnPower, 0, 0);
|
||
|
l04->addWidget (btnRecording, 0, 1);
|
||
|
l04->addWidget (btnConfigure, 1, 0);
|
||
|
l04->addWidget (btnQuit, 1, 1);
|
||
|
l04->addWidget (btnSnooze, 2, 0);
|
||
|
l04->addWidget (btnPlugins, 2, 1);
|
||
|
|
||
12 years ago
|
m_pauseMenu = new TDEPopupMenu(btnPower);
|
||
12 years ago
|
m_pauseMenu->insertItem(SmallIcon("tderadio_pause"),
|
||
12 years ago
|
i18n("Pause TDERadio"),
|
||
14 years ago
|
this, TQT_SLOT(slotPause()));
|
||
15 years ago
|
btnPower->setPopupDelay(200);
|
||
|
|
||
12 years ago
|
m_RecordingMenu = new TDEPopupMenu(btnRecording);
|
||
12 years ago
|
m_RecordingMenu->insertItem(SmallIcon("tderadio_record"),
|
||
15 years ago
|
i18n("Start Recording"),
|
||
|
POPUP_ID_START_RECORDING_DEFAULT);
|
||
14 years ago
|
TQObject::connect(m_RecordingMenu, TQT_SIGNAL(activated(int)),
|
||
|
this, TQT_SLOT(slotRecordingMenu(int)));
|
||
15 years ago
|
btnRecording->setPopup(m_RecordingMenu);
|
||
|
|
||
|
|
||
12 years ago
|
m_SnoozeMenu = new TDEPopupMenu(btnSnooze);
|
||
14 years ago
|
m_SnoozeMenu->insertItem(i18n("5 min"), this, TQT_SLOT(slotSnooze(int)), 0, 5);
|
||
|
m_SnoozeMenu->insertItem(i18n("10 min"), this, TQT_SLOT(slotSnooze(int)), 0, 10);
|
||
|
m_SnoozeMenu->insertItem(i18n("15 min"), this, TQT_SLOT(slotSnooze(int)), 0, 15);
|
||
|
m_SnoozeMenu->insertItem(i18n("30 min"), this, TQT_SLOT(slotSnooze(int)), 0, 30);
|
||
|
m_SnoozeMenu->insertItem(i18n("60 min"), this, TQT_SLOT(slotSnooze(int)), 0, 60);
|
||
15 years ago
|
btnSnooze->setPopup(m_SnoozeMenu);
|
||
|
btnSnooze->setPopupDelay(200);
|
||
|
|
||
|
// Plugin-Button/Menu
|
||
|
|
||
12 years ago
|
m_PluginMenu = new TDEPopupMenu(btnPlugins);
|
||
15 years ago
|
if (m_manager)
|
||
|
m_manager->addWidgetPluginMenuItems(m_PluginMenu, m_Plugins2MenuID);
|
||
|
btnPlugins->setPopup(m_PluginMenu);
|
||
|
|
||
|
// ICONS
|
||
|
|
||
12 years ago
|
btnPower->setIconSet(SmallIconSet("tderadio_muteon"));
|
||
|
btnRecording->setIconSet(SmallIconSet("tderadio_record"));
|
||
15 years ago
|
btnConfigure->setIconSet(SmallIconSet("configure"));
|
||
10 years ago
|
btnQuit->setIconSet(SmallIconSet("system-log-out"));
|
||
12 years ago
|
btnSnooze->setIconSet(SmallIconSet("tderadio_zzz"));
|
||
|
btnPlugins->setIconSet(SmallIconSet("tderadio_plugins"));
|
||
15 years ago
|
|
||
13 years ago
|
widgetStacks[clsRadioSound] ->setSizePolicy(TQSizePolicy(TQSizePolicy::Minimum, TQSizePolicy::Preferred));
|
||
|
widgetStacks[clsRadioDisplay]->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Preferred));
|
||
|
widgetStacks[clsRadioSeek] ->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Fixed));
|
||
|
comboStations ->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Fixed));
|
||
15 years ago
|
comboStations->setMinimumHeight(28);
|
||
|
|
||
|
|
||
14 years ago
|
TQObject::connect(btnPower, TQT_SIGNAL(toggled(bool)),
|
||
|
this, TQT_SLOT(slotPower(bool)));
|
||
|
TQObject::connect(btnQuit, TQT_SIGNAL(clicked()),
|
||
|
kapp, TQT_SLOT(quit()));
|
||
|
TQObject::connect(btnConfigure, TQT_SIGNAL(toggled(bool)),
|
||
|
this, TQT_SLOT(slotConfigure(bool)));
|
||
|
TQObject::connect(btnRecording, TQT_SIGNAL(clicked()),
|
||
|
this, TQT_SLOT(slotRecord()));
|
||
|
TQObject::connect(btnSnooze, TQT_SIGNAL(toggled(bool)),
|
||
|
this, TQT_SLOT(slotSnooze(bool)));
|
||
|
TQObject::connect(comboStations, TQT_SIGNAL(activated(int)),
|
||
|
this, TQT_SLOT(slotComboStationSelected(int)));
|
||
|
TQObject::connect(btnPlugins, TQT_SIGNAL(clicked()),
|
||
|
this, TQT_SLOT(slotBtnPluginsClicked()));
|
||
15 years ago
|
|
||
|
// tooltips
|
||
|
|
||
12 years ago
|
TQToolTip::add(btnConfigure, i18n("Configure TDERadio"));
|
||
14 years ago
|
TQToolTip::add(btnPower, i18n("Power On/Off"));
|
||
12 years ago
|
TQToolTip::add(btnQuit, i18n("Quit TDERadio Application"));
|
||
14 years ago
|
TQToolTip::add(btnRecording, i18n("Start/Stop Recording"));
|
||
|
TQToolTip::add(btnSnooze, i18n("Start/Stop Sleep Countdown"));
|
||
|
TQToolTip::add(btnPlugins, i18n("Show/Hide Plugins"));
|
||
|
TQToolTip::add(comboStations, i18n("Select a Radio Station"));
|
||
15 years ago
|
|
||
|
// testing
|
||
14 years ago
|
addElement (new RadioViewFrequencyRadio (this, TQString()));
|
||
|
addElement (new RadioViewVolume(this, TQString()));
|
||
|
addElement (new RadioViewFrequencySeeker(this, TQString()));
|
||
15 years ago
|
|
||
|
autoSetCaption();
|
||
|
}
|
||
|
|
||
|
|
||
|
RadioView::~RadioView ()
|
||
|
{
|
||
14 years ago
|
TQPtrListIterator<TQObject> it(configPages);
|
||
15 years ago
|
while (configPages.first()) {
|
||
|
delete configPages.first();
|
||
|
}
|
||
|
configPages.clear();
|
||
|
}
|
||
|
|
||
|
|
||
|
bool RadioView::addElement (RadioViewElement *e)
|
||
|
{
|
||
|
if (!e) return false;
|
||
|
|
||
|
RadioViewClass cls = e->getClass();
|
||
|
|
||
|
if (cls < 0 || cls >= clsClassMAX)
|
||
|
return false;
|
||
|
|
||
|
|
||
14 years ago
|
e->reparent(this, TQPoint(0, 0), true);
|
||
|
TQObject::connect(e, TQT_SIGNAL(destroyed(TQObject*)),
|
||
|
this, TQT_SLOT(removeElement(TQObject*)));
|
||
15 years ago
|
elements.append(e);
|
||
|
widgetStacks[cls]->addWidget(e);
|
||
|
|
||
|
// connect Element with device, disconnect doesn't matter (comp. removeElement)
|
||
|
// other devices follow if currentDevice changes
|
||
|
if (currentDevice)
|
||
|
e->connectI(currentDevice);
|
||
|
|
||
|
e->connectI(getSoundStreamServer());
|
||
|
|
||
14 years ago
|
TQPtrListIterator<TQObject> it(configPages);
|
||
15 years ago
|
for (; it.current(); ++it) {
|
||
14 years ago
|
addConfigurationTabFor(e, (TQTabWidget *)it.current());
|
||
15 years ago
|
}
|
||
|
|
||
|
selectTopWidgets();
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
bool RadioView::removeElement (TQObject *_e)
|
||
15 years ago
|
{
|
||
|
RadioViewElement *e = dynamic_cast<RadioViewElement*>(_e);
|
||
|
if (!e)
|
||
|
return false;
|
||
|
|
||
|
ElementCfgListIterator it;
|
||
13 years ago
|
while ((it = elementConfigPages.find(e)) != elementConfigPages.end()) {
|
||
15 years ago
|
delete (*it).cfg;
|
||
|
// it must not used behind, the element will be deleted automatically
|
||
|
// by slotElementConfigPageDeleted
|
||
|
}
|
||
|
|
||
|
e->disconnectI(getSoundStreamServer());
|
||
|
|
||
|
if (currentDevice)
|
||
|
e->disconnectI(currentDevice);
|
||
|
|
||
|
RadioViewClass cls = e->getClass();
|
||
14 years ago
|
TQObject::disconnect(e, TQT_SIGNAL(destroyed(TQObject*)),
|
||
|
this, TQT_SLOT(removeElement(TQObject*)));
|
||
15 years ago
|
widgetStacks[cls]->removeWidget(e);
|
||
|
elements.remove(e);
|
||
|
|
||
|
selectTopWidgets();
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::selectTopWidgets()
|
||
|
{
|
||
|
for (int i = 0; i < clsClassMAX; ++i)
|
||
|
maxUsability[i] = 0;
|
||
|
|
||
|
for (ElementListIterator i(elements); i.current(); ++i) {
|
||
|
RadioViewElement *e = i.current();
|
||
|
RadioViewClass cls = e->getClass();
|
||
|
float u = e->getUsability(currentDevice);
|
||
|
if (u > maxUsability[cls]) {
|
||
|
maxUsability[cls] = u;
|
||
|
widgetStacks[cls]->raiseWidget(e);
|
||
|
}
|
||
|
}
|
||
|
// adjustLayout!?
|
||
|
}
|
||
|
|
||
|
|
||
|
// IRadioClient
|
||
|
|
||
|
bool RadioView::noticePowerChanged(bool on)
|
||
|
{
|
||
12 years ago
|
btnPower->setIconSet(SmallIconSet( on ? "tderadio_muteoff" : "tderadio_muteon"));
|
||
15 years ago
|
btnPower->setOn(on);
|
||
|
if (on) {
|
||
|
btnPower->setPopup(m_pauseMenu);
|
||
|
} else {
|
||
|
btnPower->setPopup(NULL);
|
||
|
}
|
||
|
autoSetCaption();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool RadioView::noticeStationChanged (const RadioStation &, int idx)
|
||
|
{
|
||
|
// add 1 for "no preset defined" entry
|
||
|
comboStations->setCurrentItem(idx + 1);
|
||
|
autoSetCaption();
|
||
|
bool r = false;
|
||
|
SoundFormat sf;
|
||
|
queryIsRecordingRunning(queryCurrentSoundStreamID(), r, sf);
|
||
|
m_RecordingMenu->setItemEnabled(POPUP_ID_START_RECORDING_DEFAULT, !r);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool RadioView::noticeStationsChanged(const StationList &sl)
|
||
|
{
|
||
|
const RawStationList &list = sl.all();
|
||
|
|
||
|
comboStations->clear();
|
||
|
comboStations->insertItem("<" + i18n("no preset defined") + ">");
|
||
|
|
||
|
for (RawStationList::Iterator i(list); i.current(); ++i) {
|
||
|
RadioStation *stn = i.current();
|
||
14 years ago
|
TQString icon = stn->iconName();
|
||
|
if (icon.length() && TQFile(icon).exists()) {
|
||
|
TQImage img(icon);
|
||
15 years ago
|
int h = img.height();
|
||
|
float f = (float)(comboStations->height() - 4) / (h ? (float)h : 1.0);
|
||
|
comboStations->insertItem(img.smoothScale((int)(img.width()*f), (int)(h * f)), stn->name());
|
||
|
} else {
|
||
|
comboStations->insertItem(stn->name());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
noticeStationChanged(queryCurrentStation(), queryCurrentStationIdx());
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool RadioView::noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/)
|
||
|
{
|
||
|
// FIXME: perhaps do something
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
// IRadioDevicePoolClient
|
||
|
|
||
|
bool RadioView::noticeActiveDeviceChanged(IRadioDevice *newDevice)
|
||
|
{
|
||
|
IRadioDevice *oldDevice = currentDevice;
|
||
|
currentDevice = newDevice;
|
||
|
|
||
|
for (ElementListIterator i(elements); i.current(); ++i) {
|
||
|
RadioViewElement *e = i.current();
|
||
|
if (oldDevice)
|
||
|
e->disconnectI(oldDevice);
|
||
|
if (newDevice)
|
||
|
e->connectI(currentDevice);
|
||
|
}
|
||
|
|
||
|
selectTopWidgets();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
// Interface
|
||
|
|
||
|
bool RadioView::connectI(Interface *i)
|
||
|
{
|
||
|
bool a = IRadioClient::connectI(i);
|
||
|
bool b = IRadioDevicePoolClient::connectI(i);
|
||
|
bool c = PluginBase::connectI(i);
|
||
|
bool d = ITimeControlClient::connectI(i);
|
||
|
|
||
|
// Callbacks for ISoundStreamClient
|
||
|
|
||
|
bool e = ISoundStreamClient::connectI(i);
|
||
|
|
||
|
return a || b || c || d || e;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool RadioView::disconnectI(Interface *i)
|
||
|
{
|
||
|
bool a = IRadioClient::disconnectI(i);
|
||
|
bool b = IRadioDevicePoolClient::disconnectI(i);
|
||
|
bool c = PluginBase::disconnectI(i);
|
||
|
bool d = ITimeControlClient::disconnectI(i);
|
||
|
bool e = ISoundStreamClient::disconnectI(i);
|
||
|
if (e) {
|
||
|
// special task for soundstreamclient, different from radio device pool
|
||
|
for (ElementListIterator it(elements); it.current(); ++it) {
|
||
|
RadioViewElement *e = it.current();
|
||
|
e->disconnectI(i);
|
||
|
}
|
||
|
}
|
||
|
return a || b || c || d || e;
|
||
|
}
|
||
|
|
||
|
void RadioView::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);
|
||
|
|
||
|
// special task for soundstreamclient, different from radio device pool
|
||
|
for (ElementListIterator it(elements); it.current(); ++it) {
|
||
|
RadioViewElement *e = it.current();
|
||
|
e->connectI(s);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// ISoundStreamClient
|
||
|
|
||
|
bool RadioView::startRecordingWithFormat(
|
||
|
SoundStreamID id,
|
||
|
const SoundFormat &/*proposed_format*/,
|
||
|
SoundFormat &/*real_format*/)
|
||
|
{
|
||
13 years ago
|
if (!id.isValid() || id != queryCurrentSoundStreamID() || m_StreamID2MenuID.contains(id))
|
||
15 years ago
|
return false;
|
||
|
|
||
14 years ago
|
TQString descr;
|
||
15 years ago
|
querySoundStreamDescription(id, descr);
|
||
|
int menu_id = m_NextRecordingMenuID++;
|
||
12 years ago
|
m_RecordingMenu->insertItem(SmallIcon("tderadio_record"),
|
||
13 years ago
|
i18n("Stop Recording of %1").arg(descr),
|
||
15 years ago
|
menu_id);
|
||
|
m_MenuID2StreamID.insert(menu_id, id);
|
||
|
m_StreamID2MenuID.insert(id, menu_id);
|
||
|
btnRecording->setOn(true);
|
||
|
|
||
|
if (id == queryCurrentSoundStreamID())
|
||
|
m_RecordingMenu->setItemEnabled(POPUP_ID_START_RECORDING_DEFAULT, false);
|
||
|
|
||
|
return false; // this is only a "hook" that does not initiate the recording so don't say that we handled the event
|
||
|
}
|
||
|
|
||
|
|
||
|
bool RadioView::stopRecording (SoundStreamID id)
|
||
|
{
|
||
13 years ago
|
if (!id.isValid() || !m_StreamID2MenuID.contains(id))
|
||
15 years ago
|
return false;
|
||
|
|
||
|
int menu_id = m_StreamID2MenuID[id];
|
||
|
m_RecordingMenu->removeItem(menu_id);
|
||
|
m_MenuID2StreamID.remove(menu_id);
|
||
|
m_StreamID2MenuID.remove(id);
|
||
|
btnRecording->setOn(m_StreamID2MenuID.count() > 0);
|
||
|
|
||
|
if (id == queryCurrentSoundStreamID())
|
||
|
m_RecordingMenu->setItemEnabled(POPUP_ID_START_RECORDING_DEFAULT, true);
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
bool RadioView::noticeSoundStreamChanged(SoundStreamID id)
|
||
|
{
|
||
13 years ago
|
if (m_StreamID2MenuID.contains(id)) {
|
||
14 years ago
|
TQString descr;
|
||
15 years ago
|
querySoundStreamDescription(id, descr);
|
||
|
m_RecordingMenu->changeItem(m_StreamID2MenuID[id],
|
||
12 years ago
|
SmallIcon("tderadio_record"),
|
||
13 years ago
|
i18n("Stop Recording of %1").arg(descr));
|
||
15 years ago
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
|
||
|
// ITimeControl
|
||
|
|
||
14 years ago
|
bool RadioView::noticeCountdownStarted(const TQDateTime &)
|
||
15 years ago
|
{
|
||
|
btnSnooze->setOn(true);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool RadioView::noticeCountdownStopped()
|
||
|
{
|
||
|
btnSnooze->setOn(false);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool RadioView::noticeCountdownZero()
|
||
|
{
|
||
|
btnSnooze->setOn(false);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
// WidgetPluginBase
|
||
|
|
||
12 years ago
|
void RadioView::saveState (TDEConfig *config) const
|
||
15 years ago
|
{
|
||
14 years ago
|
config->setGroup(TQString("radioview-") + name());
|
||
15 years ago
|
|
||
|
config->writeEntry("enableToobarFlag", enableToolbarFlag);
|
||
|
WidgetPluginBase::saveState(config);
|
||
|
|
||
|
for (ElementListIterator i(elements); i.current(); ++i) {
|
||
|
RadioViewElement *e = i.current();
|
||
|
e->saveState(config);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void RadioView::restoreState (TDEConfig *config)
|
||
15 years ago
|
{
|
||
14 years ago
|
config->setGroup(TQString("radioview-") + name());
|
||
15 years ago
|
|
||
|
enableToolbarFlag = config->readBoolEntry("enableToolbarFlag", false);
|
||
|
WidgetPluginBase::restoreState(config);
|
||
|
|
||
|
for (ElementListIterator i(elements); i.current(); ++i) {
|
||
|
RadioViewElement *e = i.current();
|
||
|
e->restoreState(config);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
ConfigPageInfo RadioView::createConfigurationPage()
|
||
|
{
|
||
|
RadioViewConfiguration *c = new RadioViewConfiguration();
|
||
|
|
||
|
//addCommonConfigurationTab(c);
|
||
|
|
||
|
for (ElementListIterator i(elements); i.current(); ++i) {
|
||
|
addConfigurationTabFor(i.current(), c);
|
||
|
}
|
||
|
|
||
14 years ago
|
configPages.append(TQT_TQOBJECT(c));
|
||
|
TQObject::connect(c, TQT_SIGNAL(destroyed(TQObject *)),
|
||
|
this, TQT_SLOT(slotConfigPageDeleted(TQObject *)));
|
||
15 years ago
|
|
||
|
return ConfigPageInfo(
|
||
|
c,
|
||
|
i18n("Display"),
|
||
|
i18n("Display Configuration"),
|
||
|
"openterm"
|
||
|
);
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void RadioView::addConfigurationTabFor(RadioViewElement *e, TQTabWidget *c)
|
||
15 years ago
|
{
|
||
|
if (!e || !c)
|
||
|
return;
|
||
|
|
||
|
ConfigPageInfo inf = e->createConfigurationPage();
|
||
|
|
||
|
if (inf.page) {
|
||
|
|
||
|
if (inf.iconName.length()) {
|
||
14 years ago
|
c->addTab(inf.page, TQIconSet(SmallIconSet(inf.iconName)), inf.itemName);
|
||
15 years ago
|
} else {
|
||
|
c->addTab(inf.page, inf.itemName);
|
||
|
}
|
||
|
|
||
14 years ago
|
elementConfigPages.push_back(ElementCfg(e, TQT_TQOBJECT(inf.page)));
|
||
|
TQObject::connect(inf.page, TQT_SIGNAL(destroyed(TQObject *)),
|
||
|
this, TQT_SLOT(slotElementConfigPageDeleted(TQObject *)));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void RadioView::addCommonConfigurationTab(TQTabWidget *c)
|
||
15 years ago
|
{
|
||
|
if (!c)
|
||
|
return;
|
||
|
|
||
14 years ago
|
TQFrame *f = new TQFrame(c);
|
||
|
TQVBoxLayout *l = new TQVBoxLayout(f, 10);
|
||
15 years ago
|
|
||
14 years ago
|
l->addWidget(new TQCheckBox(i18n("set Toolbar-Flag for Display"), f));
|
||
|
l->addItem(new TQSpacerItem(1, 3, TQSizePolicy::Fixed, TQSizePolicy::Expanding));
|
||
15 years ago
|
|
||
|
c->addTab(f, i18n("Common"));
|
||
|
|
||
14 years ago
|
elementConfigPages.push_back(ElementCfg(TQT_TQOBJECT(f)));
|
||
|
TQObject::connect(f, TQT_SIGNAL(destroyed(TQObject *)),
|
||
|
this, TQT_SLOT(slotElementConfigPageDeleted(TQObject *)));
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
AboutPageInfo RadioView::createAboutPage()
|
||
|
{
|
||
12 years ago
|
/* TDEAboutData aboutData("tderadio",
|
||
15 years ago
|
NULL,
|
||
|
NULL,
|
||
12 years ago
|
I18N_NOOP("Standard Radio Display for TDERadio"),
|
||
12 years ago
|
TDEAboutData::License_GPL,
|
||
15 years ago
|
"(c) 2002-2005 Martin Witte, Klas Kalass",
|
||
|
0,
|
||
12 years ago
|
"http://sourceforge.net/projects/tderadio",
|
||
15 years ago
|
0);
|
||
|
aboutData.addAuthor("Martin Witte", "", "witte@kawo1.rwth-aachen.de");
|
||
|
aboutData.addAuthor("Klas Kalass", "", "klas.kalass@gmx.de");
|
||
|
|
||
|
return AboutPageInfo(
|
||
12 years ago
|
new TDERadioAboutWidget(aboutData, TDERadioAboutWidget::AbtTabbed),
|
||
15 years ago
|
i18n("Display"),
|
||
12 years ago
|
i18n("Standard Radio Display for TDERadio"),
|
||
15 years ago
|
"openterm"
|
||
|
);*/
|
||
|
return AboutPageInfo();
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::noticeWidgetPluginShown(WidgetPluginBase *p, bool shown)
|
||
|
{
|
||
|
if (!m_manager || !p)
|
||
|
return;
|
||
|
if ((WidgetPluginBase*)m_manager->getConfigDialog() == p) {
|
||
|
btnConfigure->blockSignals(true);
|
||
|
btnConfigure->setOn(shown);
|
||
|
btnConfigure->blockSignals(false);
|
||
|
}
|
||
|
|
||
13 years ago
|
if (m_Plugins2MenuID.contains(p)) {
|
||
15 years ago
|
m_manager->updateWidgetPluginMenuItem(p, m_PluginMenu, m_Plugins2MenuID, shown);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
// own Stuff
|
||
|
|
||
|
void RadioView::noticePluginsChanged(const PluginList &/*l*/)
|
||
|
{
|
||
|
m_Plugins2MenuID.clear();
|
||
|
m_PluginMenu->clear();
|
||
|
if (m_manager)
|
||
|
m_manager->addWidgetPluginMenuItems(m_PluginMenu, m_Plugins2MenuID);
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::slotPower(bool on)
|
||
|
{
|
||
|
on ? sendPowerOn() : sendPowerOff();
|
||
|
btnPower->setOn(queryIsPowerOn());
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::slotPause()
|
||
|
{
|
||
|
if (queryIsPowerOn()) {
|
||
|
sendPausePlayback(queryCurrentSoundStreamID());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::slotConfigure(bool b)
|
||
|
{
|
||
14 years ago
|
TQWidget *w = m_manager ? m_manager->getConfigDialog() : NULL;
|
||
15 years ago
|
if (w) b ? w->show() : w->hide();
|
||
|
if (!w)
|
||
|
btnConfigure->setOn(false);
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::slotRecord()
|
||
|
{
|
||
|
SoundStreamID id = queryCurrentSoundStreamID();
|
||
|
bool b = btnRecording->isOn();
|
||
|
|
||
|
bool r = false;
|
||
|
SoundFormat sf;
|
||
|
queryIsRecordingRunning(id, r, sf);
|
||
|
|
||
13 years ago
|
if (!r && b /*!m_StreamID2MenuID.contains(id)*/) {
|
||
15 years ago
|
if (!queryIsPowerOn())
|
||
|
sendPowerOn();
|
||
|
sendStartRecording(id);
|
||
|
} else if (r && !b) {
|
||
|
sendStopRecording(id);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::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);
|
||
|
}
|
||
13 years ago
|
} else if (m_MenuID2StreamID.contains(i)) {
|
||
15 years ago
|
sendStopRecording(m_MenuID2StreamID[i]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::slotSnooze(bool on)
|
||
|
{
|
||
|
if (on)
|
||
|
sendStartCountdown();
|
||
|
else
|
||
|
sendStopCountdown();
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::slotSnooze(int n)
|
||
|
{
|
||
|
sendCountdownSeconds(n*60);
|
||
|
sendStartCountdown();
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::slotComboStationSelected(int idx)
|
||
|
{
|
||
|
if (idx > 0) {
|
||
|
sendActivateStation(idx - 1);
|
||
|
} else {
|
||
|
comboStations->setCurrentItem(queryCurrentStationIdx() + 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void RadioView::slotBtnPluginsClicked()
|
||
|
{
|
||
|
btnPlugins->openPopup();
|
||
|
}
|
||
|
|
||
14 years ago
|
void RadioView::slotConfigPageDeleted(TQObject *o)
|
||
15 years ago
|
{
|
||
|
configPages.remove(o);
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void RadioView::slotElementConfigPageDeleted(TQObject *o)
|
||
15 years ago
|
{
|
||
|
ElementCfgListIterator it;
|
||
13 years ago
|
while ((it = elementConfigPages.find(o)) != elementConfigPages.end()) {
|
||
15 years ago
|
elementConfigPages.remove(it);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::show()
|
||
|
{
|
||
|
if (enableToolbarFlag)
|
||
|
KWin::setType(winId(), NET::Toolbar);
|
||
|
else
|
||
|
KWin::setType(winId(), NET::Normal);
|
||
|
WidgetPluginBase::pShow();
|
||
14 years ago
|
TQWidget::show();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
void RadioView::showOnOrgDesktop()
|
||
|
{
|
||
|
WidgetPluginBase::pShowOnOrgDesktop();
|
||
14 years ago
|
//TQWidget::show();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
|
||
|
void RadioView::hide()
|
||
|
{
|
||
|
WidgetPluginBase::pHide();
|
||
14 years ago
|
TQWidget::hide();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void RadioView::showEvent(TQShowEvent *e)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget::showEvent(e);
|
||
15 years ago
|
WidgetPluginBase::pShowEvent(e);
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void RadioView::hideEvent(TQHideEvent *e)
|
||
15 years ago
|
{
|
||
14 years ago
|
TQWidget::hideEvent(e);
|
||
15 years ago
|
WidgetPluginBase::pHideEvent(e);
|
||
|
}
|
||
|
|
||
|
|
||
|
void RadioView::autoSetCaption()
|
||
|
{
|
||
|
const RadioStation &rs = queryCurrentStation();
|
||
12 years ago
|
setCaption((queryIsPowerOn() && rs.isValid()) ? rs.longName() : TQString("TDERadio"));
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
#include "radioview.moc"
|