diff options
Diffstat (limited to 'tderadio3/plugins/gui-standard-display')
22 files changed, 3398 insertions, 0 deletions
diff --git a/tderadio3/plugins/gui-standard-display/Makefile.am b/tderadio3/plugins/gui-standard-display/Makefile.am new file mode 100644 index 0000000..a7e7544 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/Makefile.am @@ -0,0 +1,22 @@ +SUBDIRS = po . + +INCLUDES = $(all_includes) +METASOURCES = AUTO + +libkradio_LTLIBRARIES = libstandard-display.la +libstandard_display_la_SOURCES = displaycfg.cpp displaycfg_interfaces.cpp \ + radioview-configuration.cpp radioview.cpp \ + radioview_element.cpp \ + radioview_frequencyradio.cpp \ + radioview_frequencyseeker.cpp \ + radioview_volume.cpp +libstandard_display_la_LDFLAGS = -module -avoid-version $(KDE_RPATH) $(all_libraries) + +noinst_HEADERS = displaycfg.h displaycfg_interfaces.h radioview-configuration.h radioview_element.h radioview_frequencyradio.h radioview_frequencyseeker.h radioview.h radioview_volume.h + +#messages: rc.cpp +# $(XGETTEXT) *.cpp *.h -o po/kradio-gui-standard-display.pot + +messages: rc.cpp + $(EXTRACTRC) *.rc *.ui >> rc.cpp + $(XGETTEXT) rc.cpp *.h *.cpp -o po/kradio-gui-standard-display.pot diff --git a/tderadio3/plugins/gui-standard-display/displaycfg.cpp b/tderadio3/plugins/gui-standard-display/displaycfg.cpp new file mode 100644 index 0000000..40f5f6c --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/displaycfg.cpp @@ -0,0 +1,145 @@ +/*************************************************************************** + displaycfg.cpp - description + ------------------- + begin : Fr Aug 15 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. * + * * + ***************************************************************************/ + +#include "displaycfg.h" +#include <kcolorbutton.h> +#include <kcolordialog.h> +#include <kfontdialog.h> + +#include <tqlayout.h> +#include <klocale.h> +#include <tqlabel.h> +#include <tqbuttongroup.h> + +DisplayConfiguration::DisplayConfiguration(TQWidget *parent) + : TQWidget (parent), + m_dirty(true), + m_ignore_gui_updates(false) +{ + TQGroupBox *bg = new TQGroupBox(i18n("Display Colors"), this); + bg->setColumnLayout(0, Qt::Vertical ); + bg->layout()->setSpacing( 8 ); + bg->layout()->setMargin( 12 ); + TQGridLayout *gl = new TQGridLayout (bg->layout()); + + m_btnActive = new KColorButton(queryDisplayActiveColor(), bg); + m_btnInactive = new KColorButton(queryDisplayInactiveColor(), bg); + m_btnBkgnd = new KColorButton(queryDisplayBkgndColor(), bg); + + connect(m_btnActive, TQT_SIGNAL(changed(const TQColor &)), this, TQT_SLOT(slotSetDirty())); + connect(m_btnInactive, TQT_SIGNAL(changed(const TQColor &)), this, TQT_SLOT(slotSetDirty())); + connect(m_btnBkgnd, TQT_SIGNAL(changed(const TQColor &)), this, TQT_SLOT(slotSetDirty())); + + TQLabel *l1 = new TQLabel(i18n("Active Text"), bg); + TQLabel *l2 = new TQLabel(i18n("Inactive Text"), bg); + TQLabel *l3 = new TQLabel(i18n("Background Color"), bg); + + l1->setAlignment(TQLabel::AlignCenter); + l2->setAlignment(TQLabel::AlignCenter); + l3->setAlignment(TQLabel::AlignCenter); + + l1->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed)); + l2->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed)); + l3->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed)); + m_btnActive ->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding)); + m_btnInactive->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding)); + m_btnBkgnd ->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding)); + + m_btnActive ->setMinimumSize(TQSize(40, 40)); + m_btnInactive->setMinimumSize(TQSize(40, 40)); + m_btnBkgnd ->setMinimumSize(TQSize(40, 40)); + + gl->addWidget (l1, 0, 0, TQt::AlignCenter); + gl->addWidget (l2, 0, 1, TQt::AlignCenter); + gl->addWidget (l3, 0, 2, TQt::AlignCenter); + gl->addWidget (m_btnActive, 1, 0); + gl->addWidget (m_btnInactive, 1, 1); + gl->addWidget (m_btnBkgnd, 1, 2); + + m_fontChooser = new TDEFontChooser(this, NULL, false, TQStringList(), true, 4); + m_fontChooser->setFont(queryDisplayFont()); + m_fontChooser->setSizePolicy(TQSizePolicy(TQSizePolicy::Expanding, TQSizePolicy::Expanding)); + + TQVBoxLayout *l = new TQVBoxLayout(this, 10); + l->addWidget(bg); + l->addWidget(m_fontChooser); + + connect(m_btnActive, TQT_SIGNAL(changed(const TQColor &)), this, TQT_SLOT(slotSetDirty())); + connect(m_btnInactive, TQT_SIGNAL(changed(const TQColor &)), this, TQT_SLOT(slotSetDirty())); + connect(m_btnBkgnd, TQT_SIGNAL(changed(const TQColor &)), this, TQT_SLOT(slotSetDirty())); + connect(m_fontChooser, TQT_SIGNAL(fontSelected(const TQFont &)), this, TQT_SLOT(slotSetDirty())); + +} + + +DisplayConfiguration::~DisplayConfiguration() +{ +} + + +bool DisplayConfiguration::noticeDisplayColorsChanged(const TQColor &activeColor, const TQColor &inactiveColor, const TQColor &bkgnd) +{ + m_ignore_gui_updates = true; + m_btnActive->setColor(activeColor); + m_btnInactive->setColor(inactiveColor); + m_btnBkgnd->setColor(bkgnd); + m_ignore_gui_updates = false; + return true; +} + + +bool DisplayConfiguration::noticeDisplayFontChanged(const TQFont &f) +{ + m_ignore_gui_updates = true; + m_fontChooser->setFont(f); + m_ignore_gui_updates = false; + return true; +} + + +void DisplayConfiguration::slotOK() +{ + if (m_dirty) { + sendDisplayColors(m_btnActive->color(), m_btnInactive->color(), m_btnBkgnd->color()); + sendDisplayFont(m_fontChooser->font()); + m_dirty = false; + } +} + +void DisplayConfiguration::slotCancel() +{ + if (m_dirty) { + m_ignore_gui_updates = true; + m_btnActive ->setColor(queryDisplayActiveColor()); + m_btnInactive->setColor(queryDisplayInactiveColor()); + m_btnBkgnd ->setColor(queryDisplayBkgndColor()); + m_fontChooser->setFont(queryDisplayFont()); + m_dirty = false; + m_ignore_gui_updates = false; + } +} + +void DisplayConfiguration::slotSetDirty() +{ + if (!m_dirty && !m_ignore_gui_updates) { + m_dirty = true; + emit sigDirty(); + } +} + + +#include "displaycfg.moc" diff --git a/tderadio3/plugins/gui-standard-display/displaycfg.h b/tderadio3/plugins/gui-standard-display/displaycfg.h new file mode 100644 index 0000000..aeb3e97 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/displaycfg.h @@ -0,0 +1,73 @@ +/*************************************************************************** + displaycfg.h - description + ------------------- + begin : Fr Aug 15 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_DISPLAYCFG_H +#define KRADIO_DISPLAYCFG_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "displaycfg_interfaces.h" +#include <tqwidget.h> + +class KColorButton; +class TDEFontChooser; + +class DisplayConfiguration : public TQWidget, + public IDisplayCfgClient +{ +Q_OBJECT + +public: + DisplayConfiguration(TQWidget *parent); + ~DisplayConfiguration(); + +// Interface + + bool connectI (Interface *i) { return IDisplayCfgClient::connectI(i); } + bool disconnectI (Interface *i) { return IDisplayCfgClient::disconnectI(i); } + +// IDisplayCfgClient + +RECEIVERS: + bool noticeDisplayColorsChanged(const TQColor &activeColor, const TQColor &inactiveColor, const TQColor &bkgnd); + bool noticeDisplayFontChanged(const TQFont &f); + + +public slots: + + void slotOK(); + void slotCancel(); + void slotSetDirty(); + +signals: + + void sigDirty(); + +protected: + KColorButton *m_btnActive; + KColorButton *m_btnInactive; + KColorButton *m_btnBkgnd; + TDEFontChooser *m_fontChooser; + + bool m_dirty; + bool m_ignore_gui_updates; +}; + + +#endif diff --git a/tderadio3/plugins/gui-standard-display/displaycfg_interfaces.cpp b/tderadio3/plugins/gui-standard-display/displaycfg_interfaces.cpp new file mode 100644 index 0000000..67e5aba --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/displaycfg_interfaces.cpp @@ -0,0 +1,69 @@ +/*************************************************************************** + displaycfg_interfaces.cpp - description + ------------------- + begin : Fr Aug 15 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. * + * * + ***************************************************************************/ + +#include "displaycfg_interfaces.h" + +// IDisplayCfg + +IF_IMPL_SENDER ( IDisplayCfg::notifyDisplayColorsChanged(const TQColor &a, const TQColor &b, const TQColor &c), + noticeDisplayColorsChanged(a,b, c) ) + +IF_IMPL_SENDER ( IDisplayCfg::notifyDisplayFontChanged(const TQFont &f), + noticeDisplayFontChanged(f) ) + +// IDisplayCfgClient + +IF_IMPL_SENDER ( IDisplayCfgClient::sendDisplayColors(const TQColor &a, const TQColor &b, const TQColor &c), + setDisplayColors(a,b, c) ) + +IF_IMPL_SENDER ( IDisplayCfgClient::sendDisplayFont(const TQFont &f), + setDisplayFont(f) ) + +const TQColor default_display_active_color = TQColor(20, 244, 20); +IF_IMPL_QUERY ( const TQColor &IDisplayCfgClient::queryDisplayActiveColor(), + getDisplayActiveColor(), + default_display_active_color ) + +const TQColor default_display_inactive_color = TQColor(10, 117, 10).light(75); +IF_IMPL_QUERY ( const TQColor &IDisplayCfgClient::queryDisplayInactiveColor(), + getDisplayInactiveColor(), + default_display_inactive_color ) + +const TQColor default_display_bkgnd_color = TQColor(10, 117, 10); +IF_IMPL_QUERY ( const TQColor &IDisplayCfgClient::queryDisplayBkgndColor(), + getDisplayBkgndColor(), + default_display_bkgnd_color ) + +const TQFont default_display_font = TQFont("Helvetica"); +IF_IMPL_QUERY ( const TQFont &IDisplayCfgClient::queryDisplayFont(), + getDisplayFont(), + default_display_font ) + + +void IDisplayCfgClient::noticeConnectedI (cmplInterface *, bool /*pointer_valid*/) +{ + noticeDisplayColorsChanged(queryDisplayActiveColor(), queryDisplayInactiveColor(), queryDisplayBkgndColor()); + noticeDisplayFontChanged(queryDisplayFont()); +} + + +void IDisplayCfgClient::noticeDisconnectedI (cmplInterface *, bool /*pointer_valid*/) +{ + noticeDisplayColorsChanged(queryDisplayActiveColor(), queryDisplayInactiveColor(), queryDisplayBkgndColor()); + noticeDisplayFontChanged(queryDisplayFont()); +} + diff --git a/tderadio3/plugins/gui-standard-display/displaycfg_interfaces.h b/tderadio3/plugins/gui-standard-display/displaycfg_interfaces.h new file mode 100644 index 0000000..d458dc9 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/displaycfg_interfaces.h @@ -0,0 +1,82 @@ +/*************************************************************************** + displaycfg_interfaces.h - description + ------------------- + begin : Fr Aug 15 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_DISPLAYCFG_INTERFACES_H +#define KRADIO_DISPLAYCFG_INTERFACES_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "../../src/include/interfaces.h" + +#include <tqfont.h> +#include <tqcolor.h> + +/////////////////////////////////////////////////////////////////////// + + +INTERFACE(IDisplayCfg, IDisplayCfgClient) +{ +public : + IF_CON_DESTRUCTOR(IDisplayCfg, -1) + +RECEIVERS: + IF_RECEIVER( setDisplayColors(const TQColor &activeColor, const TQColor &inactiveColor, const TQColor &bkgnd) ) + IF_RECEIVER( setDisplayFont (const TQFont &f) ) + +SENDERS: + IF_SENDER ( notifyDisplayColorsChanged(const TQColor &activeColor, const TQColor &inactiveColor, const TQColor &bkgnd) ) + IF_SENDER ( notifyDisplayFontChanged(const TQFont &f) ) + +ANSWERS: + IF_ANSWER ( const TQColor &getDisplayActiveColor() const ) + IF_ANSWER ( const TQColor &getDisplayInactiveColor() const ) + IF_ANSWER ( const TQColor &getDisplayBkgndColor() const ) + IF_ANSWER ( const TQFont &getDisplayFont() const ) + +}; + + +INTERFACE(IDisplayCfgClient, IDisplayCfg) +{ +friend class IDisplayCfg; + +public : + IF_CON_DESTRUCTOR(IDisplayCfgClient, 1) + +SENDERS: + IF_SENDER ( sendDisplayColors(const TQColor &activeColor, const TQColor &inactiveColor, const TQColor &bkgnd) ) + IF_SENDER ( sendDisplayFont (const TQFont &f) ) + +RECEIVERS: + IF_RECEIVER( noticeDisplayColorsChanged(const TQColor &activeColor, const TQColor &inactiveColor, const TQColor &bkgnd) ) + IF_RECEIVER( noticeDisplayFontChanged(const TQFont &f) ) + +QUERIES: + IF_QUERY ( const TQColor &queryDisplayActiveColor() ) + IF_QUERY ( const TQColor &queryDisplayInactiveColor() ) + IF_QUERY ( const TQColor &queryDisplayBkgndColor() ) + IF_QUERY ( const TQFont &queryDisplayFont() ) + +RECEIVERS: + virtual void noticeConnectedI (cmplInterface *, bool pointer_valid); + virtual void noticeDisconnectedI (cmplInterface *, bool pointer_valid); +}; + + +#endif diff --git a/tderadio3/plugins/gui-standard-display/po/Makefile.am b/tderadio3/plugins/gui-standard-display/po/Makefile.am new file mode 100644 index 0000000..956ae72 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/po/Makefile.am @@ -0,0 +1,2 @@ +PACKAGE = kradio-gui-standard-display +POFILES = AUTO diff --git a/tderadio3/plugins/gui-standard-display/po/de.po b/tderadio3/plugins/gui-standard-display/po/de.po new file mode 100644 index 0000000..732628e --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/po/de.po @@ -0,0 +1,212 @@ +# translation of kradio-gui-standard-display.po to +# This file is put in the public domain. +# +# Ernst Martin Witte <emw@nocabal.de>, 2006. +msgid "" +msgstr "" +"Project-Id-Version: kradio-gui-standard-display\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2006-11-06 01:24+0100\n" +"PO-Revision-Date: 2006-11-06 01:23+0100\n" +"Last-Translator: Ernst Martin Witte <emw@nocabal.de>\n" +"Language-Team: <de@li.org>\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" + +#. i18n: file radioview_seekinterface.ui line 17 +#: rc.cpp:3 rc.cpp:25 +#, no-c-format +msgid "RadioView_SeekInterface" +msgstr "RadioView_SeekInterface" + +#. i18n: file radioview_seekinterface.ui line 45 +#: rc.cpp:7 rc.cpp:29 +#, no-c-format +msgid "search previous station" +msgstr "Suche vorherigen Sender" + +#. i18n: file radioview_seekinterface.ui line 73 +#: rc.cpp:11 rc.cpp:33 +#, no-c-format +msgid "decrease freq. by 0.05 MHz" +msgstr "Frequenz um 0.05 MHz verringern" + +#. i18n: file radioview_seekinterface.ui line 108 +#: rc.cpp:14 rc.cpp:36 +#, no-c-format +msgid "Frequency control" +msgstr "Frequenz verändern" + +#. i18n: file radioview_seekinterface.ui line 129 +#: rc.cpp:18 rc.cpp:40 +#, no-c-format +msgid "increase freq. by 0.05 MHz" +msgstr "Frequenz um 0.05 MHz erhöhen" + +#. i18n: file radioview_seekinterface.ui line 146 +#: rc.cpp:22 rc.cpp:44 +#, no-c-format +msgid "search next station" +msgstr "Suche nächsten Sender" + +#: _translatorinfo.cpp:1 +msgid "" +"_: NAME OF TRANSLATORS\n" +"Your names" +msgstr "Ernst Martin Witte" + +#: _translatorinfo.cpp:3 +msgid "" +"_: EMAIL OF TRANSLATORS\n" +"Your emails" +msgstr "emw@nocabal.de" + +#: displaycfg.cpp:33 +msgid "Display Colors" +msgstr "Farben für die Radioanzeige" + +#: displaycfg.cpp:47 +msgid "Active Text" +msgstr "Aktiver Text" + +#: displaycfg.cpp:48 +msgid "Inactive Text" +msgstr "Inaktiver Text" + +#: displaycfg.cpp:49 +msgid "Background Color" +msgstr "Hintergrundfarbe" + +#: radioview.cpp:55 +msgid "Standard Display for TDERadio" +msgstr "Standardanzeige für TDERadio" + +#: radioview.cpp:72 +msgid "Radio Display" +msgstr "Radio-Anzeige" + +#: radioview.cpp:127 +msgid "Pause TDERadio" +msgstr "TDERadio pausieren" + +#: radioview.cpp:133 +msgid "Start Recording" +msgstr "Aufnahme starten" + +#: radioview.cpp:141 +msgid "5 min" +msgstr "5 min" + +#: radioview.cpp:142 +msgid "10 min" +msgstr "10 min" + +#: radioview.cpp:143 +msgid "15 min" +msgstr "15 min" + +#: radioview.cpp:144 +msgid "30 min" +msgstr "30 min" + +#: radioview.cpp:145 +msgid "60 min" +msgstr "60 min" + +#: radioview.cpp:189 +msgid "Configure TDERadio" +msgstr "TDERadio Einrichten" + +#: radioview.cpp:190 +msgid "Power On/Off" +msgstr "Ein/Ausschalten" + +#: radioview.cpp:191 +msgid "Quit TDERadio Application" +msgstr "TDERadio beenden" + +#: radioview.cpp:192 +msgid "Start/Stop Recording" +msgstr "Aufnahme starten/beenden" + +#: radioview.cpp:193 +msgid "Start/Stop Sleep Countdown" +msgstr "Schlummermodus ein/ausschalten" + +#: radioview.cpp:194 +msgid "Show/Hide Plugins" +msgstr "Plugins anzeigen/verstecken" + +#: radioview.cpp:195 +msgid "Select a Radio Station" +msgstr "Sender auswählen" + +#: radioview.cpp:332 +msgid "no preset defined" +msgstr "kein voreingestellter Sender gefunden" + +#: radioview.cpp:442 radioview.cpp:480 +msgid "Stop Recording of %1" +msgstr "Aufnahme von %1 beenden" + +#: radioview.cpp:553 +msgid "Display" +msgstr "Anzeige" + +#: radioview.cpp:554 +msgid "Display Configuration" +msgstr "Konfiguration der Radio-Anzeige" + +#: radioview.cpp:590 +msgid "set Toolbar-Flag for Display" +msgstr "Werkzeugleisten-Flag für das Displayfenster" + +#: radioview.cpp:593 +msgid "Common" +msgstr "Allgemein" + +#: radioview_frequencyradio.cpp:99 radioview_frequencyradio.cpp:100 +msgid "Frequency Display" +msgstr "Frequenzanzeige" + +#: radioview_frequencyradio.cpp:388 radioview_frequencyradio.cpp:389 +msgid "AM" +msgstr "MW" + +#: radioview_frequencyradio.cpp:394 radioview_frequencyradio.cpp:395 +msgid "FM" +msgstr "UKW" + +#: radioview_frequencyradio.cpp:406 +msgid "%1 kHz" +msgstr "%1 kHz" + +#: radioview_frequencyradio.cpp:408 +msgid "%1 MHz" +msgstr "%1 MHz" + +#: radioview_frequencyseeker.cpp:76 +msgid "Search for previous Radio Station" +msgstr "Suche nach vorherigem Sender" + +#: radioview_frequencyseeker.cpp:77 +msgid "Search for next Radio Station" +msgstr "Suche nach nächstem Sender" + +#: radioview_frequencyseeker.cpp:78 +msgid "Decrement Frequency" +msgstr "Frequenz erniedrigen" + +#: radioview_frequencyseeker.cpp:79 +msgid "Increment Frequency" +msgstr "Frequenz erhöhen" + +#: radioview_frequencyseeker.cpp:80 +msgid "Change Frequency" +msgstr "Frequenz verändern" + +#: radioview_volume.cpp:56 +msgid "Change Volume" +msgstr "Läutstärke verändern" diff --git a/tderadio3/plugins/gui-standard-display/po/ru.po b/tderadio3/plugins/gui-standard-display/po/ru.po new file mode 100644 index 0000000..1dcbf99 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/po/ru.po @@ -0,0 +1,213 @@ +# translation of ru.po to +# translation of kradio-gui-standard-display.po to +# This file is put in the public domain. +# Алексей Кузнецов <Alexey.Kouznetsov@GMail.com>, 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 13:06+0300\n" +"Last-Translator: Алексей Кузнецов <Alexey.Kouznetsov@GMail.com>\n" +"Language-Team: <ru@li.org>\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" + +#. i18n: file radioview_seekinterface.ui line 17 +#: rc.cpp:3 rc.cpp:25 +#, no-c-format +msgid "RadioView_SeekInterface" +msgstr "RadioView_SeekInterface" + +#. i18n: file radioview_seekinterface.ui line 45 +#: rc.cpp:7 rc.cpp:29 +#, no-c-format +msgid "search previous station" +msgstr "Поиск предыдущей станции" + +#. i18n: file radioview_seekinterface.ui line 73 +#: rc.cpp:11 rc.cpp:33 +#, no-c-format +msgid "decrease freq. by 0.05 MHz" +msgstr "Уменьшать частоту по 0,05 МГц" + +#. i18n: file radioview_seekinterface.ui line 108 +#: rc.cpp:14 rc.cpp:36 +#, no-c-format +msgid "Frequency control" +msgstr "Управление частотой" + +#. i18n: file radioview_seekinterface.ui line 129 +#: rc.cpp:18 rc.cpp:40 +#, no-c-format +msgid "increase freq. by 0.05 MHz" +msgstr "Увеличивать частоту по 0,05 МГц" + +#. i18n: file radioview_seekinterface.ui line 146 +#: rc.cpp:22 rc.cpp:44 +#, no-c-format +msgid "search next station" +msgstr "Поиск следующей станции" + +#: _translatorinfo.cpp:1 +msgid "" +"_: NAME OF TRANSLATORS\n" +"Your names" +msgstr "Алексей Кузнецов" + +#: _translatorinfo.cpp:3 +msgid "" +"_: EMAIL OF TRANSLATORS\n" +"Your emails" +msgstr "Alexey.Kouznetsov@GMail.com" + +#: displaycfg.cpp:33 +msgid "Display Colors" +msgstr "Цвета" + +#: displaycfg.cpp:47 +msgid "Active Text" +msgstr "Цвет активного текста" + +#: displaycfg.cpp:48 +msgid "Inactive Text" +msgstr "Цвет инертного текста" + +#: displaycfg.cpp:49 +msgid "Background Color" +msgstr "Цвет фона" + +#: radioview.cpp:55 +msgid "Standard Display for TDERadio" +msgstr "Главное окно TDERadio" + +#: radioview.cpp:72 +msgid "Radio Display" +msgstr "Главное окно" + +#: radioview.cpp:127 +msgid "Pause TDERadio" +msgstr "Приостановить" + +#: radioview.cpp:133 +msgid "Start Recording" +msgstr "Начать запись" + +#: radioview.cpp:141 +msgid "5 min" +msgstr "5 минут" + +#: radioview.cpp:142 +msgid "10 min" +msgstr "10 минут" + +#: radioview.cpp:143 +msgid "15 min" +msgstr "четверть часа" + +#: radioview.cpp:144 +msgid "30 min" +msgstr "полчаса" + +#: radioview.cpp:145 +msgid "60 min" +msgstr "час" + +#: radioview.cpp:189 +msgid "Configure TDERadio" +msgstr "Настроить TDERadio" + +#: radioview.cpp:190 +msgid "Power On/Off" +msgstr "Включить/выключить" + +#: radioview.cpp:191 +msgid "Quit TDERadio Application" +msgstr "Закрыть TDERadio" + +#: radioview.cpp:192 +msgid "Start/Stop Recording" +msgstr "Начать/завершить запись" + +#: radioview.cpp:193 +msgid "Start/Stop Sleep Countdown" +msgstr "Включить/выключить таймер отключения" + +#: radioview.cpp:194 +msgid "Show/Hide Plugins" +msgstr "Показать/скрыть" + +#: radioview.cpp:195 +msgid "Select a Radio Station" +msgstr "Выбор радиостанции из списка" + +#: radioview.cpp:332 +msgid "no preset defined" +msgstr "Станция не определена" + +#: radioview.cpp:442 radioview.cpp:480 +msgid "Stop Recording of %1" +msgstr "Остановить запись %1" + +#: radioview.cpp:553 +msgid "Display" +msgstr "Вид" + +#: radioview.cpp:554 +msgid "Display Configuration" +msgstr "Настройка внешнего вида" + +#: radioview.cpp:590 +msgid "set Toolbar-Flag for Display" +msgstr "" + +#: radioview.cpp:593 +msgid "Common" +msgstr "Общие" + +#: radioview_frequencyradio.cpp:99 radioview_frequencyradio.cpp:100 +msgid "Frequency Display" +msgstr "Отображение частоты" + +#: radioview_frequencyradio.cpp:388 radioview_frequencyradio.cpp:389 +msgid "AM" +msgstr "ДВ/СВ/КВ" + +#: radioview_frequencyradio.cpp:394 radioview_frequencyradio.cpp:395 +msgid "FM" +msgstr "УКВ" + +#: radioview_frequencyradio.cpp:406 +msgid "%1 kHz" +msgstr "%1 кГц" + +#: radioview_frequencyradio.cpp:408 +msgid "%1 MHz" +msgstr "%1 МГц" + +#: radioview_frequencyseeker.cpp:76 +msgid "Search for previous Radio Station" +msgstr "Искать станцию вниз" + +#: radioview_frequencyseeker.cpp:77 +msgid "Search for next Radio Station" +msgstr "Искать станцию вверх" + +#: radioview_frequencyseeker.cpp:78 +msgid "Decrement Frequency" +msgstr "Уменьшить частоту" + +#: radioview_frequencyseeker.cpp:79 +msgid "Increment Frequency" +msgstr "Увеличить частоту" + +#: radioview_frequencyseeker.cpp:80 +msgid "Change Frequency" +msgstr "Изменить частоту" + +#: radioview_volume.cpp:56 +msgid "Change Volume" +msgstr "Изменить громкость" diff --git a/tderadio3/plugins/gui-standard-display/radioview-configuration.cpp b/tderadio3/plugins/gui-standard-display/radioview-configuration.cpp new file mode 100644 index 0000000..64af3ed --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview-configuration.cpp @@ -0,0 +1,116 @@ +/*************************************************************************** + radioview-configuration.cpp - description + ------------------- + begin : Fr Aug 15 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. * + * * + ***************************************************************************/ + +#include "radioview-configuration.h" + +RadioViewConfiguration::RadioViewConfiguration(TQWidget *parent) + : TQTabWidget (parent), + m_dirty(true) +{ +} + +RadioViewConfiguration::~RadioViewConfiguration() +{ +} + + +void RadioViewConfiguration::addTab (TQWidget *child, const TQString &label) +{ + TQTabWidget::addTab(child, label); + TQObject::connect(this, TQT_SIGNAL(sigOK()), child, TQT_SLOT(slotOK())); + TQObject::connect(this, TQT_SIGNAL(sigCancel()), child, TQT_SLOT(slotCancel())); + TQObject::connect(child, TQT_SIGNAL(sigDirty()), this, TQT_SLOT(slotSetDirty())); +} + + +void RadioViewConfiguration::addTab (TQWidget *child, const TQIconSet &iconset, const TQString &label) +{ + TQTabWidget::addTab(child, iconset, label); + TQObject::connect(this, TQT_SIGNAL(sigOK()), child, TQT_SLOT(slotOK())); + TQObject::connect(this, TQT_SIGNAL(sigCancel()), child, TQT_SLOT(slotCancel())); + TQObject::connect(child, TQT_SIGNAL(sigDirty()), this, TQT_SLOT(slotSetDirty())); +} + + +void RadioViewConfiguration::addTab (TQWidget *child, TQTab *tab) +{ + TQTabWidget::addTab(child, tab); + TQObject::connect(this, TQT_SIGNAL(sigOK()), child, TQT_SLOT(slotOK())); + TQObject::connect(this, TQT_SIGNAL(sigCancel()), child, TQT_SLOT(slotCancel())); + TQObject::connect(child, TQT_SIGNAL(sigDirty()), this, TQT_SLOT(slotSetDirty())); +} + + +void RadioViewConfiguration::insertTab (TQWidget *child, const TQString &label, int index) +{ + TQTabWidget::insertTab(child, label, index); + TQObject::connect(this, TQT_SIGNAL(sigOK()), child, TQT_SLOT(slotOK())); + TQObject::connect(this, TQT_SIGNAL(sigCancel()), child, TQT_SLOT(slotCancel())); + TQObject::connect(child, TQT_SIGNAL(sigDirty()), this, TQT_SLOT(slotSetDirty())); +} + + +void RadioViewConfiguration::insertTab (TQWidget *child, const TQIconSet &iconset, const TQString &label, int index) +{ + TQTabWidget::insertTab(child, iconset, label, index); + TQObject::connect(this, TQT_SIGNAL(sigOK()), child, TQT_SLOT(slotOK())); + TQObject::connect(this, TQT_SIGNAL(sigCancel()), child, TQT_SLOT(slotCancel())); + TQObject::connect(child, TQT_SIGNAL(sigDirty()), this, TQT_SLOT(slotSetDirty())); +} + + +void RadioViewConfiguration::insertTab (TQWidget *child, TQTab *tab, int index) +{ + TQTabWidget::insertTab(child, tab, index); + TQObject::connect(this, TQT_SIGNAL(sigOK()), child, TQT_SLOT(slotOK())); + TQObject::connect(this, TQT_SIGNAL(sigCancel()), child, TQT_SLOT(slotCancel())); + TQObject::connect(child, TQT_SIGNAL(sigDirty()), this, TQT_SLOT(slotSetDirty())); +} + + +void RadioViewConfiguration::removePage(TQWidget *w) +{ + TQObject::disconnect(this, TQT_SIGNAL(sigOK()), w, TQT_SLOT(slotOK())); + TQObject::disconnect(this, TQT_SIGNAL(sigCancel()), w, TQT_SLOT(slotCancel())); + TQObject::disconnect(w, TQT_SIGNAL(sigDirty()), this, TQT_SLOT(slotSetDirty())); + TQTabWidget::removePage(w); +} + + +void RadioViewConfiguration::slotOK() +{ + if (m_dirty) { + emit sigOK(); + m_dirty = false; + } +} + +void RadioViewConfiguration::slotCancel() +{ + if (m_dirty) { + emit sigCancel(); + m_dirty = false; + } +} + +void RadioViewConfiguration::slotSetDirty() +{ + m_dirty = true; +} + + +#include "radioview-configuration.moc" diff --git a/tderadio3/plugins/gui-standard-display/radioview-configuration.h b/tderadio3/plugins/gui-standard-display/radioview-configuration.h new file mode 100644 index 0000000..7f14638 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview-configuration.h @@ -0,0 +1,62 @@ +/*************************************************************************** + radioview-configuration.h - description + ------------------- + begin : Fr Aug 15 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_RADIOVIEW_CONFIGURATION_H +#define KRADIO_RADIOVIEW_CONFIGURATION_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + + + +#include <tqtabwidget.h> + +class RadioViewConfiguration : public TQTabWidget +{ +Q_OBJECT + +public : + RadioViewConfiguration(TQWidget *parent = NULL); + ~RadioViewConfiguration(); + + void addTab (TQWidget *child, const TQString &label); + void addTab (TQWidget *child, const TQIconSet &iconset, const TQString &label); + void addTab (TQWidget *child, TQTab *tab); + void insertTab (TQWidget *child, const TQString &label, int index = -1); + void insertTab (TQWidget *child, const TQIconSet &iconset, const TQString &label, int index = -1); + void insertTab (TQWidget *child, TQTab *tab, int index = -1); + void removePage(TQWidget *w); + +public slots: + + void slotOK(); + void slotCancel(); + void slotSetDirty(); + +signals: + + void sigOK(); + void sigCancel(); + +protected: + bool m_dirty; +}; + + + +#endif diff --git a/tderadio3/plugins/gui-standard-display/radioview.cpp b/tderadio3/plugins/gui-standard-display/radioview.cpp new file mode 100644 index 0000000..73735d2 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview.cpp @@ -0,0 +1,807 @@ +/*************************************************************************** + 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. * + * * + ***************************************************************************/ + +#include <tqwidgetstack.h> +#include <tqlayout.h> +#include <tqtoolbutton.h> +#include <tqslider.h> +#include <tqfile.h> +#include <tqtooltip.h> +#include <tqcheckbox.h> +#include <tqimage.h> + +#include <kcombobox.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kapplication.h> +#include <twin.h> +#include <tdeconfig.h> +#include <kpopupmenu.h> + +#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" + +#include <kaboutdata.h> + +#define POPUP_ID_START_RECORDING_DEFAULT 0 +#define POPUP_ID_STOP_RECORDING_BASE 100 + +/////////////////////////////////////////////////////////////////////// + +PLUGIN_LIBRARY_FUNCTIONS(RadioView, "kradio-gui-standard-display", i18n("Standard Display for TDERadio")); + +/////////////////////////////////////////////////////////////////////// + +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; +} + +/////////////////////////////////////////////////////////////////////// + +RadioView::RadioView(const TQString &name) + : TQWidget(NULL, name.ascii()), + 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; + + TQBoxLayout *l01 = new TQBoxLayout(this, TQBoxLayout::LeftToRight, /*spacing=*/3); + l01->setMargin(1); + l01->setSpacing(2); + widgetStacks[clsRadioSound] = new TQWidgetStack (this); + l01->addWidget(widgetStacks[clsRadioSound]); + + TQBoxLayout *l02 = new TQBoxLayout(l01, TQBoxLayout::Down); + TQBoxLayout *l03 = new TQBoxLayout(l02, TQBoxLayout::LeftToRight); + comboStations = new KComboBox (this); + l02->addWidget (comboStations); + + TQBoxLayout *l05 = new TQBoxLayout(l03, TQBoxLayout::Down); + widgetStacks[clsRadioDisplay] = new TQWidgetStack (this); + l05->addWidget(widgetStacks[clsRadioDisplay]); + widgetStacks[clsRadioSeek] = new TQWidgetStack (this); + l05->addWidget(widgetStacks[clsRadioSeek]); + + TQGridLayout *l04 = new TQGridLayout (l03, /*rows=*/ 3, /*cols=*/ 2); + btnPower = new TQToolButton(this); + btnPower->setToggleButton(true); + btnRecording = new TQToolButton(this); + btnRecording->setToggleButton(true); + btnConfigure = new TQToolButton(this); + btnConfigure->setToggleButton(true); + btnQuit = new TQToolButton(this); + btnSnooze = new TQToolButton(this); + btnSnooze->setToggleButton(true); + btnPlugins = new TQToolButton(this); + 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); + + m_pauseMenu = new TDEPopupMenu(btnPower); + m_pauseMenu->insertItem(SmallIcon("kradio_pause"), + i18n("Pause TDERadio"), + this, TQT_SLOT(slotPause())); + btnPower->setPopupDelay(200); + + m_RecordingMenu = new TDEPopupMenu(btnRecording); + m_RecordingMenu->insertItem(SmallIcon("kradio_record"), + i18n("Start Recording"), + POPUP_ID_START_RECORDING_DEFAULT); + TQObject::connect(m_RecordingMenu, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotRecordingMenu(int))); + btnRecording->setPopup(m_RecordingMenu); + + + m_SnoozeMenu = new TDEPopupMenu(btnSnooze); + 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); + btnSnooze->setPopup(m_SnoozeMenu); + btnSnooze->setPopupDelay(200); + + // Plugin-Button/Menu + + m_PluginMenu = new TDEPopupMenu(btnPlugins); + if (m_manager) + m_manager->addWidgetPluginMenuItems(m_PluginMenu, m_Plugins2MenuID); + btnPlugins->setPopup(m_PluginMenu); + + // ICONS + + btnPower->setIconSet(SmallIconSet("kradio_muteon")); + btnRecording->setIconSet(SmallIconSet("kradio_record")); + btnConfigure->setIconSet(SmallIconSet("configure")); + btnQuit->setIconSet(SmallIconSet("exit")); + btnSnooze->setIconSet(SmallIconSet("kradio_zzz")); + btnPlugins->setIconSet(SmallIconSet("kradio_plugins")); + + 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)); + comboStations->setMinimumHeight(28); + + + 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())); + + // tooltips + + TQToolTip::add(btnConfigure, i18n("Configure TDERadio")); + TQToolTip::add(btnPower, i18n("Power On/Off")); + TQToolTip::add(btnQuit, i18n("Quit TDERadio Application")); + 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")); + + // testing + addElement (new RadioViewFrequencyRadio (this, TQString())); + addElement (new RadioViewVolume(this, TQString())); + addElement (new RadioViewFrequencySeeker(this, TQString())); + + autoSetCaption(); +} + + +RadioView::~RadioView () +{ + TQPtrListIterator<TQObject> it(configPages); + 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; + + + e->reparent(this, TQPoint(0, 0), true); + TQObject::connect(e, TQT_SIGNAL(destroyed(TQObject*)), + this, TQT_SLOT(removeElement(TQObject*))); + 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()); + + TQPtrListIterator<TQObject> it(configPages); + for (; it.current(); ++it) { + addConfigurationTabFor(e, (TQTabWidget *)it.current()); + } + + selectTopWidgets(); + + return true; +} + + +bool RadioView::removeElement (TQObject *_e) +{ + RadioViewElement *e = dynamic_cast<RadioViewElement*>(_e); + if (!e) + return false; + + ElementCfgListIterator it; + while ((it = elementConfigPages.find(e)) != elementConfigPages.end()) { + 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(); + TQObject::disconnect(e, TQT_SIGNAL(destroyed(TQObject*)), + this, TQT_SLOT(removeElement(TQObject*))); + 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) +{ + btnPower->setIconSet(SmallIconSet( on ? "kradio_muteoff" : "kradio_muteon")); + 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(); + TQString icon = stn->iconName(); + if (icon.length() && TQFile(icon).exists()) { + TQImage img(icon); + 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*/) +{ + 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); + 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) +{ + 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); + 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) +{ + 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; +} + + +// ITimeControl + +bool RadioView::noticeCountdownStarted(const TQDateTime &) +{ + btnSnooze->setOn(true); + return true; +} + +bool RadioView::noticeCountdownStopped() +{ + btnSnooze->setOn(false); + return true; +} + +bool RadioView::noticeCountdownZero() +{ + btnSnooze->setOn(false); + return true; +} + +// WidgetPluginBase + +void RadioView::saveState (TDEConfig *config) const +{ + config->setGroup(TQString("radioview-") + name()); + + config->writeEntry("enableToobarFlag", enableToolbarFlag); + WidgetPluginBase::saveState(config); + + for (ElementListIterator i(elements); i.current(); ++i) { + RadioViewElement *e = i.current(); + e->saveState(config); + } +} + + +void RadioView::restoreState (TDEConfig *config) +{ + config->setGroup(TQString("radioview-") + name()); + + 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); + } + + configPages.append(TQT_TQOBJECT(c)); + TQObject::connect(c, TQT_SIGNAL(destroyed(TQObject *)), + this, TQT_SLOT(slotConfigPageDeleted(TQObject *))); + + return ConfigPageInfo( + c, + i18n("Display"), + i18n("Display Configuration"), + "openterm" + ); +} + + +void RadioView::addConfigurationTabFor(RadioViewElement *e, TQTabWidget *c) +{ + if (!e || !c) + return; + + ConfigPageInfo inf = e->createConfigurationPage(); + + if (inf.page) { + + if (inf.iconName.length()) { + c->addTab(inf.page, TQIconSet(SmallIconSet(inf.iconName)), inf.itemName); + } else { + c->addTab(inf.page, inf.itemName); + } + + elementConfigPages.push_back(ElementCfg(e, TQT_TQOBJECT(inf.page))); + TQObject::connect(inf.page, TQT_SIGNAL(destroyed(TQObject *)), + this, TQT_SLOT(slotElementConfigPageDeleted(TQObject *))); + } +} + + +void RadioView::addCommonConfigurationTab(TQTabWidget *c) +{ + if (!c) + return; + + TQFrame *f = new TQFrame(c); + TQVBoxLayout *l = new TQVBoxLayout(f, 10); + + l->addWidget(new TQCheckBox(i18n("set Toolbar-Flag for Display"), f)); + l->addItem(new TQSpacerItem(1, 3, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + c->addTab(f, i18n("Common")); + + elementConfigPages.push_back(ElementCfg(TQT_TQOBJECT(f))); + TQObject::connect(f, TQT_SIGNAL(destroyed(TQObject *)), + this, TQT_SLOT(slotElementConfigPageDeleted(TQObject *))); +} + + +AboutPageInfo RadioView::createAboutPage() +{ +/* TDEAboutData aboutData("kradio", + NULL, + NULL, + I18N_NOOP("Standard Radio Display for TDERadio"), + TDEAboutData::License_GPL, + "(c) 2002-2005 Martin Witte, Klas Kalass", + 0, + "http://sourceforge.net/projects/kradio", + 0); + aboutData.addAuthor("Martin Witte", "", "witte@kawo1.rwth-aachen.de"); + aboutData.addAuthor("Klas Kalass", "", "klas.kalass@gmx.de"); + + return AboutPageInfo( + new TDERadioAboutWidget(aboutData, TDERadioAboutWidget::AbtTabbed), + i18n("Display"), + i18n("Standard Radio Display for TDERadio"), + "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); + } + + if (m_Plugins2MenuID.contains(p)) { + 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) +{ + TQWidget *w = m_manager ? m_manager->getConfigDialog() : NULL; + 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); + + if (!r && b /*!m_StreamID2MenuID.contains(id)*/) { + 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); + } + } else if (m_MenuID2StreamID.contains(i)) { + 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(); +} + +void RadioView::slotConfigPageDeleted(TQObject *o) +{ + configPages.remove(o); +} + + +void RadioView::slotElementConfigPageDeleted(TQObject *o) +{ + ElementCfgListIterator it; + while ((it = elementConfigPages.find(o)) != elementConfigPages.end()) { + elementConfigPages.remove(it); + } +} + + +void RadioView::show() +{ + if (enableToolbarFlag) + KWin::setType(winId(), NET::Toolbar); + else + KWin::setType(winId(), NET::Normal); + WidgetPluginBase::pShow(); + TQWidget::show(); +} + + +void RadioView::showOnOrgDesktop() +{ + WidgetPluginBase::pShowOnOrgDesktop(); + //TQWidget::show(); +} + + + +void RadioView::hide() +{ + WidgetPluginBase::pHide(); + TQWidget::hide(); +} + + +void RadioView::showEvent(TQShowEvent *e) +{ + TQWidget::showEvent(e); + WidgetPluginBase::pShowEvent(e); +} + + +void RadioView::hideEvent(TQHideEvent *e) +{ + TQWidget::hideEvent(e); + WidgetPluginBase::pHideEvent(e); +} + + +void RadioView::autoSetCaption() +{ + const RadioStation &rs = queryCurrentStation(); + setCaption((queryIsPowerOn() && rs.isValid()) ? rs.longName() : TQString("TDERadio")); +} + + + + +#include "radioview.moc" diff --git a/tderadio3/plugins/gui-standard-display/radioview.h b/tderadio3/plugins/gui-standard-display/radioview.h new file mode 100644 index 0000000..2874d18 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview.h @@ -0,0 +1,208 @@ +/*************************************************************************** + radioview.h - 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_RADIOVIEW_H +#define KRADIO_RADIOVIEW_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <tqobjectlist.h> + +#include "../../src/include/radio_interfaces.h" +#include "../../src/include/radiodevicepool_interfaces.h" +#include "../../src/include/soundstreamclient_interfaces.h" +#include "../../src/include/timecontrol_interfaces.h" +#include "../../src/include/widgetplugins.h" +#include "radioview_element.h" + +class TQWidgetStack; +class TQToolButton; +class KComboBox; +class TQTabWidget; +class TDEPopupMenu; + + + +class RadioView : public TQWidget, + public WidgetPluginBase, + public IRadioClient, + public IRadioDevicePoolClient, + public ISoundStreamClient, + public ITimeControlClient +{ +Q_OBJECT + +public: + + RadioView(const TQString &name); + virtual ~RadioView(); + + virtual TQString pluginClassName() const { return "RadioView"; } + + const TQString &name() const { return PluginBase::name(); } + TQString &name() { return PluginBase::name(); } + + // WidgetPluginBase + +public: + virtual void saveState (TDEConfig *) const; + virtual void restoreState (TDEConfig *); + + virtual bool connectI(Interface *i); + virtual bool disconnectI(Interface *i); + + virtual void noticeWidgetPluginShown(WidgetPluginBase *p, bool shown); + virtual void noticePluginsChanged(const PluginList &); + + virtual ConfigPageInfo createConfigurationPage(); + virtual AboutPageInfo createAboutPage(); + +public slots: + // connects destroy-msg with remove-function + bool addElement (RadioViewElement *); + bool removeElement (TQObject *); + +protected: + void selectTopWidgets(); + + + // 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); + + // IRadioDevicePoolClient + +RECEIVERS: + bool noticeActiveDeviceChanged(IRadioDevice *rd); + bool noticeDevicesChanged(const TQPtrList<IRadioDevice> &) { return false; } + bool noticeDeviceDescriptionChanged(const TQString &) { 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); + + // ITimeControlClient + +RECEIVERS: + bool noticeAlarmsChanged(const AlarmVector &) { return false; } + bool noticeAlarm(const Alarm &) { return false; } + bool noticeNextAlarmChanged(const Alarm *) { return false; } + bool noticeCountdownStarted(const TQDateTime &end); + bool noticeCountdownStopped(); + bool noticeCountdownZero(); + bool noticeCountdownSecondsChanged(int) { return false; } + +protected slots: + + void slotPower (bool on); + void slotPause(); + void slotConfigure (bool show); + void slotRecord (); + void slotSnooze (bool start); + void slotSnooze (int time); + void slotRecordingMenu(int i); + void slotBtnPluginsClicked(); + void slotComboStationSelected(int); + + void slotConfigPageDeleted(TQObject*); + void slotElementConfigPageDeleted(TQObject*); + +public slots: + + void toggleShown() { WidgetPluginBase::pToggleShown(); } + void showOnOrgDesktop(); + void show(); + void hide(); + +protected: + virtual void showEvent(TQShowEvent *); + virtual void hideEvent(TQHideEvent *); + + virtual void autoSetCaption(); + + const TQWidget *getWidget() const { return this; } + TQWidget *getWidget() { return this; } + + void addConfigurationTabFor(RadioViewElement *, TQTabWidget *); + void addCommonConfigurationTab(TQTabWidget *); + +protected: + bool enableToolbarFlag; + + TQToolButton *btnPower; + TQToolButton *btnConfigure; + TQToolButton *btnQuit; + TQToolButton *btnRecording; + TQToolButton *btnSnooze; + TQToolButton *btnPlugins; + KComboBox *comboStations; + + struct ElementCfg + { + RadioViewElement *element; + TQObject *cfg; + ElementCfg() : element(NULL), cfg(NULL) {} + ElementCfg(RadioViewElement *e, TQObject *w) : element(e), cfg(w) {} + ElementCfg(RadioViewElement *e) : element(e), cfg(NULL) {} + ElementCfg(TQObject *w) : element(NULL), cfg(w) {} + bool operator == (const ElementCfg &x) const; + }; + + typedef TQPtrList<RadioViewElement> ElementList; + typedef TQPtrListIterator<RadioViewElement> ElementListIterator; + typedef TQValueList<ElementCfg> ElementCfgList; + typedef TQValueListIterator<ElementCfg> ElementCfgListIterator; + + ElementList elements; + ElementCfgList elementConfigPages; + TQObjectList configPages; + TQWidgetStack * widgetStacks[clsClassMAX]; + float maxUsability[clsClassMAX]; + + IRadioDevice *currentDevice; + + TDEPopupMenu *m_RecordingMenu; + TDEPopupMenu *m_pauseMenu; + TDEPopupMenu *m_SnoozeMenu; + int m_NextRecordingMenuID; + TQMap<int, SoundStreamID> m_MenuID2StreamID; + TQMap<SoundStreamID, int> m_StreamID2MenuID; + + TDEPopupMenu *m_PluginMenu; + TQMap<WidgetPluginBase *, int> m_Plugins2MenuID; +}; + + + + +#endif diff --git a/tderadio3/plugins/gui-standard-display/radioview_element.cpp b/tderadio3/plugins/gui-standard-display/radioview_element.cpp new file mode 100644 index 0000000..7ad8bb1 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_element.cpp @@ -0,0 +1,34 @@ +/*************************************************************************** + radioview_element.cpp - description + ------------------- + begin : Fre Jun 20 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. * + * * + ***************************************************************************/ + +#include "radioview_element.h" + +RadioViewElement::RadioViewElement (TQWidget * /*parent*/, const TQString & /*name*/, + RadioViewClass cls) + : myClass(cls) +{ +} + + +RadioViewElement::~RadioViewElement() +{ +} + + + + +#include "radioview_element.moc" diff --git a/tderadio3/plugins/gui-standard-display/radioview_element.h b/tderadio3/plugins/gui-standard-display/radioview_element.h new file mode 100644 index 0000000..cab2c89 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_element.h @@ -0,0 +1,67 @@ +/*************************************************************************** + radioview_element.h - description + ------------------- + begin : Fre Jun 20 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_RADIOVIEW_ELEMENT_H +#define KRADIO_RADIOVIEW_ELEMENT_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <tqframe.h> +#include "../../src/include/interfaces.h" +#include "../../src/include/plugins.h" + +enum RadioViewClass { clsRadioSound = 0, + clsRadioSeek, + clsRadioDisplay, + clsClassMAX + }; + + +// Defaults to an empty element +class RadioViewElement : public TQFrame, + public virtual Interface +{ +Q_OBJECT + +public: + RadioViewElement (TQWidget *parent, const TQString &name, RadioViewClass myClass); + virtual ~RadioViewElement(); + + bool connectI (Interface *) { return false; } // default behaviour, please overwrite in derived class + bool disconnectI(Interface *) { return false; } // default behaviour, please overwrite in derived class + + float getUsability (Interface *) const { return 0.01; } // 0 <= Usability <= 1, used to decide wich Element to use + // should be overwritten ;) + + RadioViewClass getClass() const { return myClass; } + + // Configuration ?? + virtual ConfigPageInfo createConfigurationPage() { return ConfigPageInfo(); } + + virtual void saveState (TDEConfig *) const {} + virtual void restoreState (TDEConfig *) {} + + +protected : + + RadioViewClass myClass; +}; + + +#endif diff --git a/tderadio3/plugins/gui-standard-display/radioview_frequencyradio.cpp b/tderadio3/plugins/gui-standard-display/radioview_frequencyradio.cpp new file mode 100644 index 0000000..e320102 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_frequencyradio.cpp @@ -0,0 +1,443 @@ +/*************************************************************************** + kradiodisplay.cpp - description + ------------------- + begin : Mit Jan 29 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. * + * * + ***************************************************************************/ + +#include "../../src/include/utils.h" + +#include <tqpainter.h> +#include <tqimage.h> +#include <tqpixmap.h> +#include <kimageeffect.h> // fading, blending, ... +#include <kpixmapio.h> // fast conversion between TQPixmap/TQImage +#include "radioview_frequencyradio.h" +#include "displaycfg.h" + +RadioViewFrequencyRadio::RadioViewFrequencyRadio(TQWidget *parent, const TQString &name ) + : RadioViewElement(parent, name, clsRadioDisplay), + m_power(false), + m_valid(false), + m_frequency(0), + m_quality(0.0), + m_stereo(false) +{ + setFrameStyle(Box | Sunken); + setLineWidth(1); + setMidLineWidth(1); + + + // set some sensless default colors + // real values are read in restoreState + setDisplayColors(TQColor(20, 244, 20), + TQColor(10, 117, 10).light(75), + TQColor(10, 117, 10)); + setDisplayFont(TQFont("Helvetica")); + +} + + +RadioViewFrequencyRadio::~RadioViewFrequencyRadio(){ +} + + +float RadioViewFrequencyRadio::getUsability (Interface *i) const +{ + if (dynamic_cast<IFrequencyRadio*>(i)) + return 1.0; + else + return 0.0; +} + + +void RadioViewFrequencyRadio::saveState (TDEConfig *config) const +{ + config->writeEntry("frequency-view-colorActiveText", m_colorActiveText); + config->writeEntry("frequency-view-colorInactiveText", m_colorInactiveText); + config->writeEntry("frequency-view-colorButton", m_colorButton); + config->writeEntry("frequency-view-font", m_font); +} + + +void RadioViewFrequencyRadio::restoreState (TDEConfig *config) +{ + TQColor defaultActive (20, 244, 20), + defaultInactive(TQColor(10, 117, 10).light(75)), + defaultButton (10, 117, 10); + TQFont defaultFont ("Helvetica"); + TQColor a, b, c; + TQFont f; + a = config->readColorEntry ("frequency-view-colorActiveText", + &defaultActive); + b = config->readColorEntry ("frequency-view-colorInactiveText", + &defaultInactive); + c = config->readColorEntry ("frequency-view-colorButton", + &defaultButton); + f = config->readFontEntry ("frequency-view-font", + &defaultFont); + setDisplayColors(a, b, c); + setDisplayFont(f); +} + + +ConfigPageInfo RadioViewFrequencyRadio::createConfigurationPage() +{ + DisplayConfiguration *a = new DisplayConfiguration(NULL); + connectI(a); + return ConfigPageInfo (a, + i18n("Frequency Display"), + i18n("Frequency Display"), + TQString() + ); +} + + +// Interface + +bool RadioViewFrequencyRadio::connectI(Interface *i) +{ + bool o = IDisplayCfg::connectI(i); + bool c = ISoundStreamClient::connectI(i); + if (dynamic_cast<IFrequencyRadio *>(i)) { + + bool a = IRadioDeviceClient::connectI(i); + bool b = IFrequencyRadioClient::connectI(i); + return o || a || b || c; + + } else { + return o || c; + } +} + + +bool RadioViewFrequencyRadio::disconnectI(Interface *i) +{ + // no check for IFrequencyRadio, it's just a disconnect + + bool a = IRadioDeviceClient::disconnectI(i); + bool b = IFrequencyRadioClient::disconnectI(i); + bool c = ISoundStreamClient::disconnectI(i); + bool o = IDisplayCfg::disconnectI(i); + + return a || b || c || o; +} + +void RadioViewFrequencyRadio::noticeConnectedI (ISoundStreamServer *s, bool pointer_valid) +{ + ISoundStreamClient::noticeConnectedI(s, pointer_valid); + if (s && pointer_valid) { + s->register4_notifySignalQualityChanged(this); + s->register4_notifyStereoChanged(this); + } +} + +// IDisplayCfg + +bool RadioViewFrequencyRadio::setDisplayColors(const TQColor &activeText, + const TQColor &inactiveText, + const TQColor &button) +{ + bool change = (activeText != m_colorActiveText || inactiveText != m_colorInactiveText || button != m_colorButton); + + m_colorActiveText = activeText; + m_colorInactiveText = inactiveText; + m_colorButton = button; + + TQPalette pl = palette(); + TQColorGroup cg = pl.inactive(); + + TQBrush fg = cg.brush(TQColorGroup::Foreground), + btn = cg.brush(TQColorGroup::Button), + lgt = cg.brush(TQColorGroup::Light), + drk = cg.brush(TQColorGroup::Dark), + mid = cg.brush(TQColorGroup::Mid), + txt = cg.brush(TQColorGroup::Text), + btx = cg.brush(TQColorGroup::BrightText), + bas = cg.brush(TQColorGroup::Base), + bg = cg.brush(TQColorGroup::Background); + + fg.setColor (m_colorActiveText); + btn.setColor(m_colorButton); + lgt.setColor(m_colorButton.light(180)); + drk.setColor(m_colorButton.light( 50)); + mid.setColor(m_colorInactiveText); + txt.setColor(m_colorActiveText); + btx.setColor(m_colorActiveText); + bas.setColor(m_colorButton); + bg.setColor (m_colorButton); + + TQColorGroup ncg(fg, btn, lgt, drk, mid, txt, btx, bas, bg); + pl.setInactive(ncg); + pl.setActive(ncg); + setPalette(pl); + + if (parentWidget() && parentWidget()->backgroundPixmap() ){ + KPixmapIO io; + TQImage i = io.convertToImage(*parentWidget()->backgroundPixmap()); + KImageEffect::fade(i, 0.5, colorGroup().color(TQColorGroup::Dark)); + setPaletteBackgroundPixmap(io.convertToPixmap(i)); + setBackgroundOrigin(WindowOrigin); + } else { + setBackgroundColor(colorGroup().color(TQColorGroup::Button)); + } + + if (change) + notifyDisplayColorsChanged(m_colorActiveText, m_colorInactiveText, m_colorButton); + return true; +} + +bool RadioViewFrequencyRadio::setDisplayFont (const TQFont &f) +{ + if (m_font != f) { + m_font = f; + notifyDisplayFontChanged(m_font); + RadioViewElement::setFont(f); + } + return true; +} + +// IRadioDeviceClient + + +bool RadioViewFrequencyRadio::noticePowerChanged (bool on, const IRadioDevice */*sender*/) +{ + m_power = on; + + SoundStreamID ssid = queryCurrentSoundStreamID(); + float q = 0.0; + bool s = false; + querySignalQuality(ssid, q); + noticeSignalQualityChanged(ssid, q); + queryIsStereo(ssid, s); + noticeStereoChanged(ssid, s); + + repaint(); + return true; +} + + +bool RadioViewFrequencyRadio::noticeStationChanged (const RadioStation &, const IRadioDevice */*sender*/) +{ + return false; // we don't care +} + + +bool RadioViewFrequencyRadio::noticeDescriptionChanged (const TQString &, const IRadioDevice */*sender*/) +{ + return false; // we don't care +} + + +// IRadioSoundClient + +bool RadioViewFrequencyRadio::noticeSignalQualityChanged(SoundStreamID id, float q) +{ + if (queryCurrentSoundStreamID() != id) + return false; + m_quality = q; + repaint (); + return true; +} + + +bool RadioViewFrequencyRadio::noticeStereoChanged(SoundStreamID id, bool s) +{ + if (queryCurrentSoundStreamID() != id) + return false; + m_stereo = s; + repaint (); + return true; +} + + + + +// IFrequencyRadioClient + + +bool RadioViewFrequencyRadio::noticeFrequencyChanged(float f, const RadioStation *) +{ + m_frequency = f; + repaint (); + return true; +} + + +bool RadioViewFrequencyRadio::noticeMinMaxFrequencyChanged(float /*min*/, float /*max*/) +{ + return false; // we don't care +} + + +bool RadioViewFrequencyRadio::noticeDeviceMinMaxFrequencyChanged(float /*min*/, float /*max*/) +{ + return false; // we don't care +} + + +bool RadioViewFrequencyRadio::noticeScanStepChanged(float /*s*/) +{ + return false; // we don't care +} + + + +void RadioViewFrequencyRadio::drawContents(TQPainter *paint) +{ + if (!paint) return; + + TQRect r = contentsRect(); + + int margin = TQMAX(4, TQMIN(r.width() / 50, r.height() / 50)), + tmp = TQMIN(r.height(), (r.width() - 2*margin) / 4), + xd_st = TQMIN((r.height() - margin * 2) / 3, tmp/3), + xw = TQMIN(tmp / 2, xd_st * 3 / 2), + penw = TQMAX(1, xw / 25), + xh_st = xd_st, + xx_st = r.x() + margin + xw + 2 * margin + penw/2, + xy_st = r.y() + margin + penw/2, + + xx_am = xx_st, + xy_am = xy_st + xh_st + margin / 2, + xh_am = (r.bottom() - margin - xy_am + 1 - margin/2) / 2, + + xx_fm = xx_am, + xy_fm = xy_am + xh_am + margin/2, + xh_fm = xh_am, + + xh_sg = r.height() - margin * 2, + xx_sg = r.x() + margin, + xy_sg = r.y() + margin; + + TQPen activePen (colorGroup().color(TQColorGroup::Text), penw); + TQPen inactivePen (colorGroup().color(TQColorGroup::Mid), penw); + TQBrush activeBrush = colorGroup().brush(TQColorGroup::Text); + TQBrush inactiveBrush = colorGroup().brush(TQColorGroup::Mid); + + // draw stereo symbol + paint->setPen( (m_stereo && m_power) ? activePen : inactivePen); + paint->drawArc((int)xx_st, (int)xy_st, + (int)(xd_st - penw), (int)(xd_st - penw), + 0, 360*16); + paint->drawArc((int)(xx_st + xd_st/2), (int)xy_st, + (int)(xd_st - penw), (int)(xd_st - penw), + 0, 360*16); + + // draw signal quality symbol + float cx = xx_sg, + cy = xy_sg, + cw = xw, + ch = xw; + + float open_a = 30.0; + // outer circle + paint->setPen( (m_quality > 0.75 && m_power) ? activePen : inactivePen); + paint->drawArc((int)rint(cx), (int)rint(cy), + (int)rint(cw), (int)rint(ch), + (int)(-90+open_a)*16, (int)(360 - 2*open_a)*16 + ); + + // mid circle + paint->setPen( (m_quality > 0.50 && m_power) ? activePen : inactivePen); + cx += (float)xw/5.0; cy += (float)xw/5.0; + cw -= (float)xw/2.5; ch -= (float)xw/2.5; + paint->drawArc((int)rint(cx), (int)rint(cy), + (int)rint(cw), (int)rint(ch), + (int)(-90+open_a)*16, (int)(360 - 2*open_a)*16 + ); + + // inner circle + paint->setPen( (m_quality > 0.25 && m_power) ? activePen : inactivePen); + cx += (float)xw/5.0; cy += (float)xw/5.0; + cw -= (float)xw/2.5; ch -= (float)xw/2.5; + paint->drawArc((int)rint(cx), (int)rint(cy), + (int)rint(cw), (int)rint(ch), + (int)(-90+open_a)*16, (int)(360 - 2*open_a)*16 + ); + + // triangle + TQPen tmppen = (m_quality > 0.1 && m_power) ? activePen : inactivePen; + tmppen.setWidth(1); + paint->setPen(tmppen); + paint->setBrush( (m_quality > 0.1 && m_power) ? activeBrush : inactiveBrush); + TQPointArray pts(3); + pts.setPoint(0, (int)(xx_sg + xw / 4), (int)(xy_sg + xh_sg - penw/2)); + pts.setPoint(1, (int)(xx_sg + xw *3/4), (int)(xy_sg + xh_sg - penw/2)); + pts.setPoint(2, (int)(xx_sg + xw / 2), (int)(xy_sg + xw/2 + penw)); + paint->drawConvexPolygon(pts); + + + + // AM/FM display + + TQFont f = m_font; + paint->setPen ( (m_frequency <= 10 && m_power) ? activePen : inactivePen); + f.setPixelSize(xh_am); + paint->setFont(f); + paint->drawText(xx_am, xy_am + xh_am - 1, i18n("AM")); + int xw_am = TQFontMetrics(f).width(i18n("AM")); + + paint->setPen ( (m_frequency > 10 && m_power) ? activePen : inactivePen); + f.setPixelSize(xh_fm); + paint->setFont(f); + paint->drawText(xx_fm, xy_fm + xh_fm - 1, i18n("FM")); + int xw_fm = TQFontMetrics(f).width(i18n("FM")); + + int xx_f = TQMAX(xx_fm + xw_fm, TQMAX(xw_am + xx_am, TQMAX(xx_st + xw, xw + xx_sg))) + margin, + xy_f = r.y() + margin, + xw_f = r.right() - margin - xx_f + 1, + xh_f = r.bottom() - margin - xy_f + 1; + + // Frequency Display + + TQString s; + if (m_frequency < 10) { + s = i18n("%1 kHz").arg(TDEGlobal::locale()->formatNumber((int)(m_frequency * 1000), 0)); + } else { + s = i18n("%1 MHz").arg(TDEGlobal::locale()->formatNumber(m_frequency, 2)); + } + + float pxs = xh_f; + paint->setPen ( m_power ? activePen : inactivePen); + f.setPixelSize((int)pxs); + int n = 30; + while (1) { + TQFontMetrics fm(f); + int sw = fm.boundingRect(xx_f, xy_f, xw_f, xh_f, TQt::AlignRight | TQt::AlignVCenter, s).width(); + if (sw <= xw_f || --n <= 0) break; + + float fact = (float)xw_f / (float)sw; + pxs = TQMIN(pxs - 1, pxs * fact); + f.setPixelSize(TQMAX(1,(int)pxs)); + } + paint->setFont(f); + paint->drawText(xx_f, xy_f, xw_f, xh_f, TQt::AlignRight | TQt::AlignVCenter, s); +} + + + + + + +void RadioViewFrequencyRadio::reparent (TQWidget *prnt, + WFlags f, + const TQPoint &p, + bool showIt) +{ + RadioViewElement::reparent(prnt, f, p, showIt); + setDisplayColors(m_colorActiveText, m_colorInactiveText, m_colorButton); +} + + +#include "radioview_frequencyradio.moc" diff --git a/tderadio3/plugins/gui-standard-display/radioview_frequencyradio.h b/tderadio3/plugins/gui-standard-display/radioview_frequencyradio.h new file mode 100644 index 0000000..b13db67 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_frequencyradio.h @@ -0,0 +1,109 @@ +/*************************************************************************** + kradiodisplay.h - description + ------------------- + begin : Mit Jan 29 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_RADIOVIEW_FREQUENCYRADIO_H +#define KRADIO_RADIOVIEW_FREQUENCYRADIO_H + +#include "../../src/include/radiodevice_interfaces.h" +#include "../../src/include/soundstreamclient_interfaces.h" +#include "radioview_element.h" +#include "displaycfg_interfaces.h" + +/** + *@author Martin Witte + */ + +class RadioViewFrequencyRadio : public RadioViewElement, // is a TQObject, must be first + public IRadioDeviceClient, + public IFrequencyRadioClient, + public ISoundStreamClient, + public IDisplayCfg +{ +Q_OBJECT + +public: + RadioViewFrequencyRadio(TQWidget *parent, const TQString &name); + ~RadioViewFrequencyRadio(); + + float getUsability (Interface *) const; + + virtual void saveState (TDEConfig *) const; + virtual void restoreState (TDEConfig *); + + ConfigPageInfo createConfigurationPage(); + +// Interface + + bool connectI (Interface *); + bool disconnectI(Interface *); + +// IDisplayCfg + +RECEIVERS: + bool setDisplayColors(const TQColor &activeColor, const TQColor &inactiveColor, const TQColor &bkgnd); + bool setDisplayFont (const TQFont &f); + +ANSWERS: + const TQColor &getDisplayActiveColor() const { return m_colorActiveText; } + const TQColor &getDisplayInactiveColor() const { return m_colorInactiveText; } + const TQColor &getDisplayBkgndColor() const { return m_colorButton; } + const TQFont &getDisplayFont() const { return m_font; } + +// IRadioDeviceClient +RECEIVERS: + bool noticePowerChanged (bool on, const IRadioDevice *sender = NULL); + bool noticeStationChanged (const RadioStation &, const IRadioDevice *sender = NULL); + bool noticeDescriptionChanged (const TQString &, const IRadioDevice *sender = NULL); + bool noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/, const IRadioDevice */*sender*/) { return false; } + +// ISoundStreamClient +RECEIVERS: + void noticeConnectedI (ISoundStreamServer *s, bool pointer_valid); + + bool noticeSignalQualityChanged(SoundStreamID id, float q); + bool noticeStereoChanged(SoundStreamID id, bool s); + +// IFrequencyRadioClient +RECEIVERS: + bool noticeFrequencyChanged(float f, const RadioStation *s); + bool noticeMinMaxFrequencyChanged(float min, float max); + bool noticeDeviceMinMaxFrequencyChanged(float min, float max); + bool noticeScanStepChanged(float s); + +// own stuff ;) + +public: + + void reparent (TQWidget *parent, WFlags f, const TQPoint &p, bool showIt = FALSE); + +protected: + + void drawContents(TQPainter *p); + +protected: + + TQColor m_colorActiveText, m_colorInactiveText, m_colorButton; + TQFont m_font; + + bool m_power; + bool m_valid; + float m_frequency; + float m_quality; + bool m_stereo; +}; + +#endif diff --git a/tderadio3/plugins/gui-standard-display/radioview_frequencyseeker.cpp b/tderadio3/plugins/gui-standard-display/radioview_frequencyseeker.cpp new file mode 100644 index 0000000..e334e45 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_frequencyseeker.cpp @@ -0,0 +1,250 @@ +/*************************************************************************** + radioview_frequencyseeker.cpp - description + ------------------- + begin : Fre Jun 20 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. * + * * + ***************************************************************************/ + +#include <math.h> +#include <tqlayout.h> +#include <tqslider.h> +#include <tqtoolbutton.h> +#include <tqaccel.h> +#include <tqtooltip.h> + +#include <kiconloader.h> +#include <klocale.h> + +#include "radioview_frequencyseeker.h" + +RadioViewFrequencySeeker::RadioViewFrequencySeeker(TQWidget *parent, const TQString &name) + : RadioViewElement(parent, name, clsRadioSeek), + m_btnSearchLeft(NULL), + m_btnStepLeft(NULL), + m_btnStepRight(NULL), + m_btnSearchRight(NULL), + m_sldFrequency(NULL), + m_ignoreChanges(false) +{ + TQBoxLayout *l = new TQBoxLayout(this, TQBoxLayout::LeftToRight, /*spacing=*/ 3); + l->setMargin(0); + + m_sldFrequency = new TQSlider(Qt::Horizontal, this); + m_btnSearchLeft = new TQToolButton(this); + m_btnSearchRight = new TQToolButton(this); + m_btnStepLeft = new TQToolButton(this); + m_btnStepRight = new TQToolButton(this); + + m_btnSearchLeft ->setToggleButton(true); + m_btnSearchRight->setToggleButton(true); + m_sldFrequency->setPageStep(1); + + m_btnSearchLeft ->setIconSet(SmallIconSet("2leftarrow")); + m_btnSearchRight->setIconSet(SmallIconSet("2rightarrow")); + m_btnStepLeft ->setIconSet(SmallIconSet("1leftarrow")); + m_btnStepRight ->setIconSet(SmallIconSet("1rightarrow")); + + l->addWidget (m_btnSearchLeft); + l->addWidget (m_btnStepLeft); + l->addWidget (m_sldFrequency); + l->addWidget (m_btnStepRight); + l->addWidget (m_btnSearchRight); + + TQObject::connect(m_sldFrequency, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotSliderChanged(int))); + TQObject::connect(m_btnSearchLeft, TQT_SIGNAL(toggled(bool)), + this, TQT_SLOT(slotSearchLeft(bool))); + TQObject::connect(m_btnSearchRight, TQT_SIGNAL(toggled(bool)), + this, TQT_SLOT(slotSearchRight(bool))); + TQObject::connect(m_btnStepLeft, TQT_SIGNAL(clicked()), + m_sldFrequency, TQT_SLOT(subtractStep())); + TQObject::connect(m_btnStepRight, TQT_SIGNAL(clicked()), + m_sldFrequency, TQT_SLOT(addStep())); + + // Tooltips + + TQToolTip::add(m_btnSearchLeft, i18n("Search for previous Radio Station")); + TQToolTip::add(m_btnSearchRight, i18n("Search for next Radio Station")); + TQToolTip::add(m_btnStepLeft, i18n("Decrement Frequency")); + TQToolTip::add(m_btnStepRight, i18n("Increment Frequency")); + TQToolTip::add(m_sldFrequency, i18n("Change Frequency")); + + // Accelerators + + TQAccel *Accel = new TQAccel (this); + Accel->insertItem (Key_Left, 100); + Accel->insertItem (Key_Right, 101); + Accel->connectItem (100, m_sldFrequency, TQT_SLOT(subtractStep())); + Accel->connectItem (101, m_sldFrequency, TQT_SLOT(addStep())); +} + + +RadioViewFrequencySeeker::~RadioViewFrequencySeeker() +{ +} + + +float RadioViewFrequencySeeker::getUsability (Interface *i) const +{ + if (dynamic_cast<IFrequencyRadio*>(i)) + return 0.9; + else + return 0.0; +} + + +// Interface + +bool RadioViewFrequencySeeker::connectI (Interface *i) +{ + if (IFrequencyRadioClient::connectI(i)) { + ISeekRadioClient::connectI(i); + return true; + } else { + return false; + } +} + + +bool RadioViewFrequencySeeker::disconnectI(Interface *i) +{ + bool a = IFrequencyRadioClient::disconnectI(i); + bool b = ISeekRadioClient::disconnectI(i); + return a || b; +} + + + +// ISeekRadioClient + +bool RadioViewFrequencySeeker::noticeSeekStarted (bool up) +{ + m_ignoreChanges = true; + m_btnSearchLeft->setOn(!up); + m_btnSearchRight->setOn(up); + m_ignoreChanges = false; + return true; +} + + +bool RadioViewFrequencySeeker::noticeSeekStopped () +{ + m_ignoreChanges = true; + m_btnSearchLeft->setOn(false); + m_btnSearchRight->setOn(false); + m_ignoreChanges = false; + return true; +} + + +bool RadioViewFrequencySeeker::noticeSeekFinished (const RadioStation &/*s*/, bool /*goodQuality*/) +{ + m_ignoreChanges = true; + m_btnSearchLeft->setOn(false); + m_btnSearchRight->setOn(false); + m_ignoreChanges = false; + return true; +} + + + +// IFrequencyRadioClient + +bool RadioViewFrequencySeeker::noticeFrequencyChanged(float f, const RadioStation */*s*/) +{ + float step = queryScanStep(); + if (step == 0) step = 0.000001; + + m_ignoreChanges = true; + m_sldFrequency->setValue((int)rint(f / step)); + m_ignoreChanges = false; + return true; +} + + +bool RadioViewFrequencySeeker::noticeMinMaxFrequencyChanged(float min, float max) +{ + float step = queryScanStep(); + if (step == 0) step = 0.000001; + + m_ignoreChanges = true; + m_sldFrequency->setMinValue((int)rint(min / step)); + m_sldFrequency->setMaxValue((int)rint(max / step)); + m_sldFrequency->setValue ((int)rint(queryFrequency() / step)); + m_ignoreChanges = false; + return true; +} + + +bool RadioViewFrequencySeeker::noticeDeviceMinMaxFrequencyChanged(float /*min*/, float /*max*/) +{ + return false; // we don't care +} + + +bool RadioViewFrequencySeeker::noticeScanStepChanged(float s) +{ + if (s == 0) s = 0.000001; + m_ignoreChanges = true; + m_sldFrequency->setMinValue((int)rint(queryMinFrequency() / s)); + m_sldFrequency->setMaxValue((int)rint(queryMaxFrequency() / s)); + m_sldFrequency->setValue ((int)rint(queryFrequency() / s)); + m_ignoreChanges = false; + return true; +} + + +void RadioViewFrequencySeeker::slotSearchLeft(bool on) +{ + if (m_ignoreChanges) return; + if (on) { + if (queryIsSeekUpRunning()) + sendStopSeek(); + if (!queryIsSeekRunning()) + sendStartSeekDown(); + } else { + if (queryIsSeekDownRunning()) + sendStopSeek(); + } + if (!queryIsSeekDownRunning()) + m_btnSearchLeft->setOn(false); +} + + +void RadioViewFrequencySeeker::slotSearchRight(bool on) +{ + if (m_ignoreChanges) return; + if (on) { + if (queryIsSeekDownRunning()) + sendStopSeek(); + if (!queryIsSeekRunning()) + sendStartSeekUp(); + } else { + if (queryIsSeekUpRunning()) + sendStopSeek(); + } + if (!queryIsSeekUpRunning()) + m_btnSearchRight->setOn(false); +} + + +void RadioViewFrequencySeeker::slotSliderChanged(int val) +{ + if (m_ignoreChanges) return; + sendFrequency(val * queryScanStep()); +} + + + + +#include "radioview_frequencyseeker.moc" diff --git a/tderadio3/plugins/gui-standard-display/radioview_frequencyseeker.h b/tderadio3/plugins/gui-standard-display/radioview_frequencyseeker.h new file mode 100644 index 0000000..651ef7f --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_frequencyseeker.h @@ -0,0 +1,79 @@ +/*************************************************************************** + radioview_frequencyseeker.h - description + ------------------- + begin : Fre Jun 20 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_RADIOVIEW_FREQUENCYSEEKER_H +#define KRADIO_RADIOVIEW_FREQUENCYSEEKER_H + +#include "../../src/include/radiodevice_interfaces.h" +#include "radioview_element.h" + +class TQToolButton; +class TQSlider; + +class RadioViewFrequencySeeker : public RadioViewElement, // is a TQObject, must be first + public ISeekRadioClient, + public IFrequencyRadioClient +{ +Q_OBJECT + +public: + RadioViewFrequencySeeker(TQWidget *parent, const TQString &name); + ~RadioViewFrequencySeeker(); + + float getUsability(Interface *) const; + +// Interface + + bool connectI (Interface *); + bool disconnectI(Interface *); + +// ISeekRadioClient +RECEIVERS: + bool noticeSeekStarted (bool up); + bool noticeSeekStopped (); + bool noticeSeekFinished (const RadioStation &s, bool goodQuality); + bool noticeProgress (float ) { return false; } + +// IFrequencyRadioClient +RECEIVERS: + bool noticeFrequencyChanged(float f, const RadioStation *s); + bool noticeMinMaxFrequencyChanged(float min, float max); + bool noticeDeviceMinMaxFrequencyChanged(float min, float max); + bool noticeScanStepChanged(float s); + +// own stuff ;) + +protected slots: + + void slotSearchLeft(bool on); + void slotSearchRight(bool on); + void slotSliderChanged(int val); + +protected: + + TQToolButton *m_btnSearchLeft, + *m_btnStepLeft, + *m_btnStepRight, + *m_btnSearchRight; + TQSlider *m_sldFrequency; + + bool m_ignoreChanges; +}; + + + +#endif diff --git a/tderadio3/plugins/gui-standard-display/radioview_seekinterface.ui b/tderadio3/plugins/gui-standard-display/radioview_seekinterface.ui new file mode 100644 index 0000000..29542f9 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_seekinterface.ui @@ -0,0 +1,167 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>RadioView_SeekerUI</class> +<author>Ernst Martin Witte</author> +<widget class="TQWidget"> + <property name="name"> + <cstring>RadioView_SeekerUI</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>477</width> + <height>43</height> + </rect> + </property> + <property name="caption"> + <string>RadioView_SeekInterface</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQToolButton" row="0" column="0"> + <property name="name"> + <cstring>btnSearchDown</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>TabFocus</enum> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"2rightarrow"</iconset> + </property> + <property name="toolTip" stdset="0"> + <string>search previous station</string> + </property> + </widget> + <widget class="TQToolButton" row="0" column="1"> + <property name="name"> + <cstring>btnStepDown</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>TabFocus</enum> + </property> + <property name="text"> + <string></string> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>"2rightarrow"</iconset> + </property> + <property name="toolTip" stdset="0"> + <string>decrease freq. by 0.05 MHz</string> + </property> + </widget> + <widget class="TQSlider" row="0" column="2"> + <property name="name"> + <cstring>sldRange</cstring> + </property> + <property name="minValue"> + <number>8700</number> + </property> + <property name="maxValue"> + <number>10900</number> + </property> + <property name="lineStep"> + <number>5</number> + </property> + <property name="pageStep"> + <number>5</number> + </property> + <property name="value"> + <number>8700</number> + </property> + <property name="tracking"> + <bool>true</bool> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="tickmarks"> + <enum>NoMarks</enum> + </property> + <property name="tickInterval"> + <number>100</number> + </property> + <property name="toolTip" stdset="0"> + <string>Frequency control</string> + <comment>Frequency</comment> + </property> + </widget> + <widget class="TQToolButton" row="0" column="3"> + <property name="name"> + <cstring>btnStepUp</cstring> + </property> + <property name="focusPolicy"> + <enum>TabFocus</enum> + </property> + <property name="text"> + <string></string> + </property> + <property name="autoRepeat"> + <bool>true</bool> + </property> + <property name="iconSet"> + <iconset>"2rightarrow"</iconset> + </property> + <property name="toolTip" stdset="0"> + <string>increase freq. by 0.05 MHz</string> + </property> + </widget> + <widget class="TQToolButton" row="0" column="4"> + <property name="name"> + <cstring>btnSearchUp</cstring> + </property> + <property name="focusPolicy"> + <enum>TabFocus</enum> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"2rightarrow"</iconset> + </property> + <property name="toolTip" stdset="0"> + <string>search next station</string> + </property> + </widget> + </grid> +</widget> +<tabstops> + <tabstop>btnSearchDown</tabstop> + <tabstop>btnStepDown</tabstop> + <tabstop>sldRange</tabstop> + <tabstop>btnStepUp</tabstop> + <tabstop>btnSearchUp</tabstop> +</tabstops> +<includes> + <include location="local" impldecl="in implementation">radioview_seekinterface.ui.h</include> +</includes> +<functions> + <function access="protected">init()</function> + <function>destroy()</function> +</functions> +<pixmapfunction>SmallIconSet</pixmapfunction> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/tderadio3/plugins/gui-standard-display/radioview_seekinterface.ui.h b/tderadio3/plugins/gui-standard-display/radioview_seekinterface.ui.h new file mode 100644 index 0000000..c13c945 --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_seekinterface.ui.h @@ -0,0 +1,21 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions or slots use +** TQt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ + +void RadioView_SeekerUI::init() +{ + Accel = new TQAccel (this); + Accel->insertItem (Key_Left, 100); + Accel->insertItem (Key_Right, 101); + Accel->connectItem (100, sldRange, TQT_SLOT(subtractStep())); + Accel->connectItem (101, sldRange, TQT_SLOT(addStep())); +} + +void RadioView_SeekerUI::destroy() +{ +} diff --git a/tderadio3/plugins/gui-standard-display/radioview_volume.cpp b/tderadio3/plugins/gui-standard-display/radioview_volume.cpp new file mode 100644 index 0000000..921a6ed --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_volume.cpp @@ -0,0 +1,141 @@ +/*************************************************************************** + radioview_volume.cpp - description + ------------------- + begin : Don Jun 19 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. * + * * + ***************************************************************************/ + +#include <math.h> +#include <tqslider.h> +#include <tqlayout.h> +#include <tqaccel.h> +#include <tqtooltip.h> + +#include <klocale.h> + +#include "radioview_volume.h" +#include "../../src/include/plugins.h" + +#define SLIDER_MINVAL 0 +#define SLIDER_MAXVAL 32768 +#define SLIDER_RANGE (SLIDER_MAXVAL - SLIDER_MINVAL) + +RadioViewVolume::RadioViewVolume(TQWidget *parent, const TQString &name) + : RadioViewElement (parent, name, clsRadioSound), + m_slider(NULL), + m_handlingSlot(false) +{ + float v = 0; + SoundStreamID ssid = queryCurrentSoundStreamID(); + sendLogDebug (TQString ("RadioViewVolume: ssid=%1").arg(ssid.getID())); + queryPlaybackVolume(ssid, v); + m_slider = new TQSlider(SLIDER_MINVAL, + SLIDER_MAXVAL, + SLIDER_RANGE/10, + getSlider4Volume(v), + Qt::Vertical, this); + + TQObject::connect(m_slider, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotVolumeChanged(int))); + + TQBoxLayout *l = new TQBoxLayout(this, TQBoxLayout::LeftToRight); + l->addWidget(m_slider); + + // Tooltips + + TQToolTip::add(m_slider, i18n("Change Volume")); + + // Accelerators + TQAccel *Accel = new TQAccel (this); + Accel->insertItem (Key_Up, 100); + Accel->insertItem (Key_Down, 101); + Accel->connectItem (100, m_slider, TQT_SLOT(subtractStep())); + Accel->connectItem (101, m_slider, TQT_SLOT(addStep())); + +} + + +RadioViewVolume::~RadioViewVolume() +{ +} + + +float RadioViewVolume::getUsability (Interface */*i*/) const +{ + return 0.5; // there could be more features like mute control, capture settings, ... +} + + +bool RadioViewVolume::connectI (Interface *i) +{ + bool a = IRadioDeviceClient::connectI(i); + bool b = ISoundStreamClient::connectI(i); + return a || b; +} + + +bool RadioViewVolume::disconnectI(Interface *i) +{ + bool a = IRadioDeviceClient::disconnectI(i); + bool b = ISoundStreamClient::disconnectI(i); + return a || b; +} + +void RadioViewVolume::noticeConnectedI (ISoundStreamServer *s, bool pointer_valid) +{ + ISoundStreamClient::noticeConnectedI(s, pointer_valid); + if (s && pointer_valid) { + s->register4_notifyPlaybackVolumeChanged(this); + } +} + +// ISoundStreamClient + +bool RadioViewVolume::noticePlaybackVolumeChanged(SoundStreamID id, float v) +{ + if (queryCurrentSoundStreamID() != id) + return false; + m_slider->setValue(getSlider4Volume(v)); + return true; +} + + + +void RadioViewVolume::slotVolumeChanged(int val) +{ + if (m_handlingSlot) return; + m_handlingSlot = true; + SoundStreamID ssid = queryCurrentSoundStreamID(); + sendPlaybackVolume(ssid, getVolume4Slider(val)); + m_handlingSlot = false; +} + + +int RadioViewVolume::getSlider4Volume(float volume) +{ + if (volume >= 1) volume = 1; + if (volume < 0) volume = 0; + return SLIDER_MAXVAL - (int)rint(SLIDER_RANGE * volume); +} + + +float RadioViewVolume::getVolume4Slider(int sl) +{ + if (sl > SLIDER_MAXVAL) sl = SLIDER_MAXVAL; + if (sl < SLIDER_MINVAL) sl = SLIDER_MINVAL; + return (float)(SLIDER_MAXVAL - sl) / (float)SLIDER_RANGE; +} + + + +#include "radioview_volume.moc" diff --git a/tderadio3/plugins/gui-standard-display/radioview_volume.h b/tderadio3/plugins/gui-standard-display/radioview_volume.h new file mode 100644 index 0000000..581fc7c --- /dev/null +++ b/tderadio3/plugins/gui-standard-display/radioview_volume.h @@ -0,0 +1,76 @@ +/*************************************************************************** + radioview_volume.h - description + ------------------- + begin : Don Jun 19 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. * + * * + ***************************************************************************/ + +#ifndef KRADIO_RADIOVIEW_VOLUME_H +#define KRADIO_RADIOVIEW_VOLUME_H + +#include "../../src/include/radiodevice_interfaces.h" +#include "../../src/include/soundstreamclient_interfaces.h" +#include "radioview_element.h" + +/** + *@author Martin Witte + */ + +class TQSlider; + +class RadioViewVolume : public RadioViewElement, // is a TQObject, must be first + public IRadioDeviceClient, + public ISoundStreamClient, + public IErrorLogClient +{ +Q_OBJECT + +public: + RadioViewVolume(TQWidget *parent, const TQString &name); + ~RadioViewVolume(); + + float getUsability(Interface *) const; + +// Interface + + bool connectI (Interface *); + bool disconnectI(Interface *); + +// IRadioDeviceClient +RECEIVERS: + bool noticePowerChanged (bool /*on*/, const IRadioDevice */*sender*/) { return false; } + bool noticeStationChanged (const RadioStation &, const IRadioDevice */*sender*/) { return false; } + bool noticeDescriptionChanged (const TQString &, const IRadioDevice */*sender*/) { return false; } + bool noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/, const IRadioDevice */*sender*/) { return false; } + +// ISoundStreamClient +RECEIVERS: + void noticeConnectedI (ISoundStreamServer *s, bool pointer_valid); + bool noticePlaybackVolumeChanged(SoundStreamID id, float v); + +// own stuff +protected slots: + + void slotVolumeChanged(int val); + +protected: + + int getSlider4Volume(float volume); + float getVolume4Slider(int sl); + + TQSlider *m_slider; + bool m_handlingSlot; + +}; + +#endif |