diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-30 19:40:31 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2022-05-31 01:17:58 +0900 |
commit | d95a4fea540b371fa86493d069fdbd54f33c5b40 (patch) | |
tree | 079b038ab559439eb7ded40a07bd79fd92926b3b /plugins/radio | |
parent | e54890e0480e5adee69f5220a7c6dd072bbd75ea (diff) | |
download | tderadio-d95a4fea540b371fa86493d069fdbd54f33c5b40.tar.gz tderadio-d95a4fea540b371fa86493d069fdbd54f33c5b40.zip |
Standardize folder structure.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'plugins/radio')
-rw-r--r-- | plugins/radio/CMakeL10n.txt | 6 | ||||
-rw-r--r-- | plugins/radio/Makefile.am | 18 | ||||
-rw-r--r-- | plugins/radio/po/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/radio/po/de.po | 168 | ||||
-rw-r--r-- | plugins/radio/po/ru.po | 171 | ||||
-rw-r--r-- | plugins/radio/po/tderadio-radio.pot | 164 | ||||
-rw-r--r-- | plugins/radio/radio-configuration-ui.ui | 771 | ||||
-rw-r--r-- | plugins/radio/radio-configuration.cpp | 592 | ||||
-rw-r--r-- | plugins/radio/radio-configuration.h | 107 | ||||
-rw-r--r-- | plugins/radio/radio.cpp | 497 | ||||
-rw-r--r-- | plugins/radio/radio.h | 167 |
11 files changed, 2663 insertions, 0 deletions
diff --git a/plugins/radio/CMakeL10n.txt b/plugins/radio/CMakeL10n.txt new file mode 100644 index 0000000..e47b1d1 --- /dev/null +++ b/plugins/radio/CMakeL10n.txt @@ -0,0 +1,6 @@ +##### create translation templates ############## + +tde_l10n_create_template( + CATALOG "tderadio-radio" + DESTINATION "po" +) diff --git a/plugins/radio/Makefile.am b/plugins/radio/Makefile.am new file mode 100644 index 0000000..79b5cac --- /dev/null +++ b/plugins/radio/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = po . + +INCLUDES = -I$(top_builddir)/src -I$(top_srcdir) $(all_includes) +METASOURCES = AUTO + +libtderadio_LTLIBRARIES = libradio.la +libradio_la_SOURCES = radio-configuration.cpp radio-configuration-ui.ui \ + radio.cpp +libradio_la_LDFLAGS = -module -avoid-version $(KDE_RPATH) $(all_libraries) + +noinst_HEADERS = radio-configuration.h radio.h + +#messages: rc.cpp +# $(XGETTEXT) *.cpp *.h -o po/tderadio-radio.pot + +messages: rc.cpp + $(EXTRACTRC) *.rc *.ui >> rc.cpp + $(XGETTEXT) rc.cpp *.h *.cpp -o po/tderadio-radio.pot diff --git a/plugins/radio/po/Makefile.am b/plugins/radio/po/Makefile.am new file mode 100644 index 0000000..b5baba9 --- /dev/null +++ b/plugins/radio/po/Makefile.am @@ -0,0 +1,2 @@ +PACKAGE = tderadio-radio +POFILES = AUTO diff --git a/plugins/radio/po/de.po b/plugins/radio/po/de.po new file mode 100644 index 0000000..7709106 --- /dev/null +++ b/plugins/radio/po/de.po @@ -0,0 +1,168 @@ +# translation of de.po to +# translation of tderadio-radio.po to +# This file is put in the public domain. +# +# Ernst Martin Witte <emw@nocabal.de>, 2006. +msgid "" +msgstr "" +"Project-Id-Version: de\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-05-11 04:30+0200\n" +"PO-Revision-Date: 2006-11-06 01:18+0100\n" +"Last-Translator: Ernst Martin Witte <emw@nocabal.de>\n" +"Language-Team: <de@li.org>\n" +"Language: \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" + +#. Instead of a literal translation, add your name to the end of the list (separated by a comma). +msgid "" +"_: NAME OF TRANSLATORS\n" +"Your names" +msgstr "Ernst Martin Witte" + +#. Instead of a literal translation, add your email to the end of the list (separated by a comma). +msgid "" +"_: EMAIL OF TRANSLATORS\n" +"Your emails" +msgstr "witte@kawo1.rwth-aachen.de" + +#: radio-configuration.cpp:350 +msgid "Image Selection" +msgstr "Symbolauswahl" + +#: radio-configuration.cpp:355 +msgid "ignoring non-local image" +msgstr "Ignoriere nicht-lokale Symbole" + +#: radio-configuration.cpp:450 radio-configuration.cpp:470 +msgid "TDERadio Preset Files" +msgstr "Senderdateien für TDERadio" + +#: radio-configuration.cpp:452 radio-configuration.cpp:472 +msgid "Preset File Selection" +msgstr "Auswahl der Senderdatei" + +#: radio-configuration.cpp:455 +msgid "Select Preset File" +msgstr "Wählen Sie eine Senderdatei aus" + +#: radio-configuration.cpp:475 +msgid "Store Preset File" +msgstr "Speichern der Senderdatei" + +#: radio.cpp:34 +msgid "Central Radio Device Multiplexer" +msgstr "Zentraler Radio-Multiplexer" + +#: radio.cpp:39 +msgid "Radio Multiplexer Plugin" +msgstr "Plugin für den Radio-Gerätemultiplexer" + +#: radio.cpp:116 +msgid "Radio Stations" +msgstr "Radiosender" + +#: radio.cpp:117 +msgid "Setup Radio Stations" +msgstr "Einstellung der Radiosender" + +#: radio.cpp:351 +msgid "unknown" +msgstr "unbekannt" + +#: radio-configuration-ui.ui:28 +#, no-c-format +msgid "Station &Presets" +msgstr "&Voreingestellte Sender" + +#: radio-configuration-ui.ui:53 +#, no-c-format +msgid "Stations" +msgstr "Sender" + +#: radio-configuration-ui.ui:179 +#, no-c-format +msgid "&Search Stations" +msgstr "&Sendersuche" + +#: radio-configuration-ui.ui:198 +#, no-c-format +msgid "Load" +msgstr "Öffnen" + +#: radio-configuration-ui.ui:263 +#, no-c-format +msgid "Name" +msgstr "Name" + +#: radio-configuration-ui.ui:294 +#, no-c-format +msgid "Short Name" +msgstr "Kurzname" + +#: radio-configuration-ui.ui:325 +#, no-c-format +msgid "Pixmap File" +msgstr "Bilddatei" + +#: radio-configuration-ui.ui:457 +#, no-c-format +msgid " %" +msgstr " %" + +#: radio-configuration-ui.ui:471 +#, no-c-format +msgid "Volume Preset" +msgstr "Lautstärke" + +#: radio-configuration-ui.ui:508 +#, no-c-format +msgid "Personal Preset File" +msgstr "Persönliche Senderdatei" + +#: radio-configuration-ui.ui:564 +#, no-c-format +msgid "City" +msgstr "Stadt" + +#: radio-configuration-ui.ui:577 +#, no-c-format +msgid "Country" +msgstr "Land" + +#: radio-configuration-ui.ui:617 +#, no-c-format +msgid "&Now" +msgstr "&Jetzt" + +#: radio-configuration-ui.ui:627 +#, no-c-format +msgid "Comment" +msgstr "Kommentar" + +#: radio-configuration-ui.ui:640 +#, no-c-format +msgid "Media" +msgstr "Medium" + +#: radio-configuration-ui.ui:648 +#, no-c-format +msgid "Maintainer" +msgstr "Maintainer" + +#: radio-configuration-ui.ui:661 +#, no-c-format +msgid "Last Change" +msgstr "Letzte Änderung" + +#: radio-configuration-ui.ui:698 +#, no-c-format +msgid "" +"<p align=\"center\">Click on the link below to contribute this station " +"preset file to the tderadio project.</p>" +msgstr "" +"<p align=\"center\">Klicke auf den folgenden Link um mit deinen " +"Senderinformationen zum TDERadio-Projekt beizutragen.</p>" diff --git a/plugins/radio/po/ru.po b/plugins/radio/po/ru.po new file mode 100644 index 0000000..39d0881 --- /dev/null +++ b/plugins/radio/po/ru.po @@ -0,0 +1,171 @@ +# translation of ru.po to +# translation of tderadio-radio.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: 2020-05-11 04:30+0200\n" +"PO-Revision-Date: 2020-01-03 16:07+0000\n" +"Last-Translator: Serg Bormant <bormant@mail.ru>\n" +"Language-Team: Russian <https://mirror.git.trinitydesktop.org/weblate/" +"projects/applications/tderadio-radio/ru/>\n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 3.10\n" + +#. Instead of a literal translation, add your name to the end of the list (separated by a comma). +msgid "" +"_: NAME OF TRANSLATORS\n" +"Your names" +msgstr "Алексей Кузнецов" + +#. Instead of a literal translation, add your email to the end of the list (separated by a comma). +msgid "" +"_: EMAIL OF TRANSLATORS\n" +"Your emails" +msgstr "Alexey.Kouznetsov@GMail.com" + +#: radio-configuration.cpp:350 +msgid "Image Selection" +msgstr "Выбор картинки" + +#: radio-configuration.cpp:355 +msgid "ignoring non-local image" +msgstr "Пропускать не локальные файлы" + +#: radio-configuration.cpp:450 radio-configuration.cpp:470 +msgid "TDERadio Preset Files" +msgstr "Файлы TDERadio" + +#: radio-configuration.cpp:452 radio-configuration.cpp:472 +msgid "Preset File Selection" +msgstr "Выбор файла радиостанций" + +#: radio-configuration.cpp:455 +msgid "Select Preset File" +msgstr "Выбор файла радиостанций" + +#: radio-configuration.cpp:475 +msgid "Store Preset File" +msgstr "Сохранить файл радиостанций" + +#: radio.cpp:34 +msgid "Central Radio Device Multiplexer" +msgstr "Главный мультиплексор устройства радио" + +#: radio.cpp:39 +msgid "Radio Multiplexer Plugin" +msgstr "Модуль мультиплексирования для TDERadio" + +#: radio.cpp:116 +msgid "Radio Stations" +msgstr "Радиостанции" + +#: radio.cpp:117 +msgid "Setup Radio Stations" +msgstr "Настройка радиостанции" + +#: radio.cpp:351 +msgid "unknown" +msgstr "низвестно" + +#: radio-configuration-ui.ui:28 +#, no-c-format +msgid "Station &Presets" +msgstr "Параметры &радиостанций" + +#: radio-configuration-ui.ui:53 +#, no-c-format +msgid "Stations" +msgstr "Список" + +#: radio-configuration-ui.ui:179 +#, no-c-format +msgid "&Search Stations" +msgstr "&Поиск" + +#: radio-configuration-ui.ui:198 +#, no-c-format +msgid "Load" +msgstr "Из файла" + +#: radio-configuration-ui.ui:263 +#, no-c-format +msgid "Name" +msgstr "Название" + +#: radio-configuration-ui.ui:294 +#, no-c-format +msgid "Short Name" +msgstr "Сокращённое название" + +#: radio-configuration-ui.ui:325 +#, no-c-format +msgid "Pixmap File" +msgstr "Пиктограмма" + +#: radio-configuration-ui.ui:457 +#, no-c-format +msgid " %" +msgstr " %" + +#: radio-configuration-ui.ui:471 +#, no-c-format +msgid "Volume Preset" +msgstr "Установить громкость (-1=не менять)" + +#: radio-configuration-ui.ui:508 +#, no-c-format +msgid "Personal Preset File" +msgstr "Пользовательский файл настроек" + +#: radio-configuration-ui.ui:564 +#, no-c-format +msgid "City" +msgstr "Город" + +#: radio-configuration-ui.ui:577 +#, no-c-format +msgid "Country" +msgstr "Страна" + +#: radio-configuration-ui.ui:617 +#, no-c-format +msgid "&Now" +msgstr "&Текущее время" + +#: radio-configuration-ui.ui:627 +#, no-c-format +msgid "Comment" +msgstr "Описание" + +#: radio-configuration-ui.ui:640 +#, no-c-format +msgid "Media" +msgstr "Носитель" + +#: radio-configuration-ui.ui:648 +#, no-c-format +msgid "Maintainer" +msgstr "Сопровождающий" + +#: radio-configuration-ui.ui:661 +#, fuzzy, no-c-format +msgid "Last Change" +msgstr "Последнее изменение" + +#: radio-configuration-ui.ui:698 +#, no-c-format +msgid "" +"<p align=\"center\">Click on the link below to contribute this station " +"preset file to the tderadio project.</p>" +msgstr "" +"<p align=\"center\"> Чтобы добавить этот файл в проект TDERadio, щёлкните по " +"ссылке ниже</p>" diff --git a/plugins/radio/po/tderadio-radio.pot b/plugins/radio/po/tderadio-radio.pot new file mode 100644 index 0000000..352caab --- /dev/null +++ b/plugins/radio/po/tderadio-radio.pot @@ -0,0 +1,164 @@ +# SOME DESCRIPTIVE TITLE. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2020-05-11 04:30+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Instead of a literal translation, add your name to the end of the list (separated by a comma). +#, ignore-inconsistent +msgid "" +"_: NAME OF TRANSLATORS\n" +"Your names" +msgstr "" + +#. Instead of a literal translation, add your email to the end of the list (separated by a comma). +#, ignore-inconsistent +msgid "" +"_: EMAIL OF TRANSLATORS\n" +"Your emails" +msgstr "" + +#: radio-configuration.cpp:350 +msgid "Image Selection" +msgstr "" + +#: radio-configuration.cpp:355 +msgid "ignoring non-local image" +msgstr "" + +#: radio-configuration.cpp:450 radio-configuration.cpp:470 +msgid "TDERadio Preset Files" +msgstr "" + +#: radio-configuration.cpp:452 radio-configuration.cpp:472 +msgid "Preset File Selection" +msgstr "" + +#: radio-configuration.cpp:455 +msgid "Select Preset File" +msgstr "" + +#: radio-configuration.cpp:475 +msgid "Store Preset File" +msgstr "" + +#: radio.cpp:34 +msgid "Central Radio Device Multiplexer" +msgstr "" + +#: radio.cpp:39 +msgid "Radio Multiplexer Plugin" +msgstr "" + +#: radio.cpp:116 +msgid "Radio Stations" +msgstr "" + +#: radio.cpp:117 +msgid "Setup Radio Stations" +msgstr "" + +#: radio.cpp:351 +msgid "unknown" +msgstr "" + +#: radio-configuration-ui.ui:28 +#, no-c-format +msgid "Station &Presets" +msgstr "" + +#: radio-configuration-ui.ui:53 +#, no-c-format +msgid "Stations" +msgstr "" + +#: radio-configuration-ui.ui:179 +#, no-c-format +msgid "&Search Stations" +msgstr "" + +#: radio-configuration-ui.ui:198 +#, no-c-format +msgid "Load" +msgstr "" + +#: radio-configuration-ui.ui:263 +#, no-c-format +msgid "Name" +msgstr "" + +#: radio-configuration-ui.ui:294 +#, no-c-format +msgid "Short Name" +msgstr "" + +#: radio-configuration-ui.ui:325 +#, no-c-format +msgid "Pixmap File" +msgstr "" + +#: radio-configuration-ui.ui:457 +#, no-c-format +msgid " %" +msgstr "" + +#: radio-configuration-ui.ui:471 +#, no-c-format +msgid "Volume Preset" +msgstr "" + +#: radio-configuration-ui.ui:508 +#, no-c-format +msgid "Personal Preset File" +msgstr "" + +#: radio-configuration-ui.ui:564 +#, no-c-format +msgid "City" +msgstr "" + +#: radio-configuration-ui.ui:577 +#, no-c-format +msgid "Country" +msgstr "" + +#: radio-configuration-ui.ui:617 +#, no-c-format +msgid "&Now" +msgstr "" + +#: radio-configuration-ui.ui:627 +#, no-c-format +msgid "Comment" +msgstr "" + +#: radio-configuration-ui.ui:640 +#, no-c-format +msgid "Media" +msgstr "" + +#: radio-configuration-ui.ui:648 +#, no-c-format +msgid "Maintainer" +msgstr "" + +#: radio-configuration-ui.ui:661 +#, no-c-format +msgid "Last Change" +msgstr "" + +#: radio-configuration-ui.ui:698 +#, no-c-format +msgid "" +"<p align=\"center\">Click on the link below to contribute this station " +"preset file to the tderadio project.</p>" +msgstr "" diff --git a/plugins/radio/radio-configuration-ui.ui b/plugins/radio/radio-configuration-ui.ui new file mode 100644 index 0000000..63ea82f --- /dev/null +++ b/plugins/radio/radio-configuration-ui.ui @@ -0,0 +1,771 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>RadioConfigurationUI</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>RadioConfigurationUI</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>490</width> + <height>348</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>tabWidget3</cstring> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>stations</cstring> + </property> + <attribute name="title"> + <string>Station &Presets</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <widget class="TQLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout32</cstring> + </property> + <property name="margin" stdset="0"> + <number>6</number> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>labelStationList</cstring> + </property> + <property name="text"> + <string>Stations</string> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout22</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="RadioStationListView"> + <property name="name"> + <cstring>listStations</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonNewStation</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"filenew2"</iconset> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonDeleteStation</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"edit-delete"</iconset> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonStationUp</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"1uparrow"</iconset> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonStationDown</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"1downarrow"</iconset> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout21</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonSearchStations</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Search Stations</string> + </property> + <property name="iconSet"> + <iconset>"edit-find"</iconset> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonLoadPresets</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Load</string> + </property> + <property name="iconSet"> + <iconset>"document-open"</iconset> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonStorePresets</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>1</horstretch> + <verstretch>1</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Save As</string> + </property> + <property name="iconSet"> + <iconset>"document-save-as"</iconset> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget" row="0" column="1"> + <property name="name"> + <cstring>layout18</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQWidgetStack"> + <property name="name"> + <cstring>stackStationEdit</cstring> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>page</cstring> + </property> + <attribute name="id"> + <number>0</number> + </attribute> + </widget> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>labelStationName</cstring> + </property> + <property name="text"> + <string>Name</string> + </property> + </widget> + <widget class="TQLineEdit"> + <property name="name"> + <cstring>editStationName</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout32</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>labelStationShortName</cstring> + </property> + <property name="text"> + <string>Short Name</string> + </property> + </widget> + <widget class="TQLineEdit"> + <property name="name"> + <cstring>editStationShortName</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>labelPixmapFile</cstring> + </property> + <property name="text"> + <string>Pixmap File</string> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout5</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLineEdit"> + <property name="name"> + <cstring>editPixmapFile</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonSelectPixmapFile</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"document-open"</iconset> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout19</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>pixmapStation</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer7</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>10</width> + <height>5</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer4_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout20</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQSpinBox"> + <property name="name"> + <cstring>editVolumePreset</cstring> + </property> + <property name="suffix"> + <string> %</string> + </property> + <property name="maxValue"> + <number>100</number> + </property> + <property name="minValue"> + <number>-1</number> + </property> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>labelVolumePreset</cstring> + </property> + <property name="text"> + <string>Volume Preset</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer12</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout25</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>editLabelPresetFile</cstring> + </property> + <property name="text"> + <string>Personal Preset File</string> + </property> + </widget> + <widget class="KURLRequester"> + <property name="name"> + <cstring>editPresetFile</cstring> + </property> + </widget> + </hbox> + </widget> + </grid> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>About</cstring> + </property> + <attribute name="title"> + <string>A&bout</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <spacer row="5" column="1"> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>21</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQLayoutWidget" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>layout21</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="3" column="0"> + <property name="name"> + <cstring>labelCity</cstring> + </property> + <property name="text"> + <string>City</string> + </property> + </widget> + <widget class="TQLineEdit" row="2" column="1"> + <property name="name"> + <cstring>editCountry</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>labelCountry</cstring> + </property> + <property name="text"> + <string>Country</string> + </property> + </widget> + <widget class="TQLayoutWidget" row="1" column="1"> + <property name="name"> + <cstring>layout19</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQDateTimeEdit"> + <property name="name"> + <cstring>editLastChange</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="focusPolicy"> + <enum>StrongFocus</enum> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonLastChangeNow</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>&Now</string> + </property> + </widget> + </hbox> + </widget> + <widget class="TQLabel" row="5" column="0"> + <property name="name"> + <cstring>labelComment</cstring> + </property> + <property name="text"> + <string>Comment</string> + </property> + </widget> + <widget class="TQLineEdit" row="5" column="1"> + <property name="name"> + <cstring>editComment</cstring> + </property> + </widget> + <widget class="TQLabel" row="4" column="0"> + <property name="name"> + <cstring>labelMedia</cstring> + </property> + <property name="text"> + <string>Media</string> + </property> + </widget> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>labelMaintainer</cstring> + </property> + <property name="text"> + <string>Maintainer</string> + </property> + </widget> + <widget class="TQLineEdit" row="3" column="1"> + <property name="name"> + <cstring>editCity</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>labelLastChange</cstring> + </property> + <property name="text"> + <string>Last Change</string> + </property> + </widget> + <widget class="TQLineEdit" row="0" column="1"> + <property name="name"> + <cstring>editMaintainer</cstring> + </property> + </widget> + <widget class="TQLineEdit" row="4" column="1"> + <property name="name"> + <cstring>editMedia</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="1" column="1"> + <property name="name"> + <cstring>spacer7_2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQLabel" row="2" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string><p align="center">Click on the link below to contribute this station preset file to the tderadio project.</p></string> + </property> + <property name="alignment"> + <set>WordBreak|AlignCenter</set> + </property> + </widget> + <widget class="KURLLabel" row="4" column="1"> + <property name="name"> + <cstring>mailLabel</cstring> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + </grid> + </widget> + </widget> + </grid> +</widget> +<customwidgets> + <customwidget> + <class>RadioStationListView</class> + <header location="local">src/include/radiostation-listview.h</header> + <sizehint> + <width>-1</width> + <height>-1</height> + </sizehint> + <container>0</container> + <sizepolicy> + <hordata>5</hordata> + <verdata>5</verdata> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + <pixmap>image0</pixmap> + </customwidget> +</customwidgets> +<images> + <image name="image0"> + <data format="XPM.GZ" length="2782">789c8dd4df53e2481007f077ff0aca7eb3ae7a4948425257f78080a2828baebbea5eddc32493c80f110414f1eafef7eb7437dcdd9cd95a478afad47ca733193af97454bb1b0e6a479f0e566bb31e67b56c6496b523fb329b6d7fffe3b73f0f0e7dbf46ff5e3dacf987bf1c1c5ead6b59ed72fe9497800b02d4f9af34cefe6be83b1e3879ebb8e5b8edb8703c743c760c8e73c7a9e389e347c799733fe7cefc83e39163e378eaf8461d68fd253b26c73c1faa637550daab9783f3bc7fbf5e0e9eafab03f57776e2677ec2fe52ba9134e2061b36e2a0ae7e2e1d78413df038ff591d8881cf3730411c18f6bc74e88761c8cd02a84ec4f8956dc8923f565b319e958efcd046b2fe451c8562ecb14d642359cfe7dd6c34bd6683e7afd5a11846ea44bd65a7944fd96fea44fd543a6ec45e2cf5eed9691cc63c8f57ea44eda9ad3a12279e9afb2309923009b87e5b9da8b9ff928c9c713e515b31f07998a0e9697f6cd4a17aab4ed49762131aae8f7c7e26dbe7dfd4bbfcf1dedc4fb0101b63e4faafe2d4579f944effb9debbdaaa9b6293a7727f569cfaea5c6dd4fc7ba6968e437eff85da6abf5c88d328b5ecbedaa84fd5b99a9f972c349ef6d35aadfd03469ce659c87e17679118b9df33bb5f3f57effaef556da4ff70a5ceb51f3b3b6b3f36c4545ff637501b31acd5b9cec762ebeb3cdf1f3d1cbbfadd9db59f3371965bb99f99d8faea953a1223f7b7cdb348fb8bdf3f7964f33c6217e272709e7fef9c667379dfb7d4468cdfd4b9da2f5d44b929647d479d8b612c2e7c35bf5f8b825c70beab8ed4776aa3be5517e2abb53b10d0608a195a77e6a33ca7732cf0014738fe288f139cfec478c499e6a7f884735ce0332e3ffcac708d2f94b2fbfc2b6ef0adf2b3c577fa9e626b9f5ff0faea71ccf3ed7d7eceeb3bd8c5133cc51e9ee1395e601f0778899ff7f3c37d7ec9ebaff01abfe00d7ec56f784be38ed6dee3f7fdfcd0a92fe306ebe8a18f0daa1c90c3cafa534a46b49326c6543ba1da97800095f57b60781f3c20a5dddc4206b6b27e0f72bae33b4a15d8850718c118c674bd8afa30c17b9852e61166d8812798c302afe1b9aa3e2ce90a2baadd410f524a4fe87b0d2fd5e70300af74e62730a3dd4c60036fd88055e5fe6f30802dbcd39e0a68d1d91cd38a0db4ff5f1f3ad4233fe807e83af5d770423d52d19f700a3d67ffd5bda91f38fb57bf3dfeccf302e7fb7e9ea1c516b671f883d1a6843e2f708133e8c38056550e18409f9ec7bf7e3df81bd372939b</data> + </image> +</images> +<tabstops> + <tabstop>tabWidget3</tabstop> + <tabstop>listStations</tabstop> + <tabstop>buttonNewStation</tabstop> + <tabstop>buttonDeleteStation</tabstop> + <tabstop>buttonStationUp</tabstop> + <tabstop>buttonStationDown</tabstop> + <tabstop>buttonSearchStations</tabstop> + <tabstop>buttonLoadPresets</tabstop> + <tabstop>editStationName</tabstop> + <tabstop>editStationShortName</tabstop> + <tabstop>editPixmapFile</tabstop> + <tabstop>buttonSelectPixmapFile</tabstop> + <tabstop>editVolumePreset</tabstop> + <tabstop>editMaintainer</tabstop> + <tabstop>editLastChange</tabstop> + <tabstop>editCountry</tabstop> + <tabstop>editCity</tabstop> + <tabstop>editMedia</tabstop> + <tabstop>editComment</tabstop> +</tabstops> +<pixmapfunction>SmallIconSet</pixmapfunction> +<layoutdefaults spacing="6" margin="0"/> +<includes> + <include location="global" impldecl="in implementation">kiconloader.h</include> + <include location="global" impldecl="in implementation">klineedit.h</include> + <include location="global" impldecl="in implementation">kpushbutton.h</include> + <include location="global" impldecl="in implementation">kurlrequester.h</include> + <include location="global" impldecl="in implementation">src/include/radiostation-listview.h</include> + <include location="global" impldecl="in implementation">tqwidgetstack.h</include> +</includes> +</UI> diff --git a/plugins/radio/radio-configuration.cpp b/plugins/radio/radio-configuration.cpp new file mode 100644 index 0000000..a08d458 --- /dev/null +++ b/plugins/radio/radio-configuration.cpp @@ -0,0 +1,592 @@ +/*************************************************************************** + radio-configuration.cpp - description + ------------------- + begin : Son Aug 3 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/radiostation.h" +#include "../../src/include/stationlist.h" +#include "../../src/include/plugins.h" +#include "../../src/include/radiodevice_interfaces.h" +#include "../../src/include/standardscandialog.h" +#include "../../src/include/radiostation-listview.h" +#include "../../src/include/radiostation-config.h" +#include "../../src/include/errorlog-interfaces.h" + +#include "radio-configuration.h" + +#include <math.h> + +#include <tqlistbox.h> +#include <tdelistbox.h> +#include <tqdatetimeedit.h> +#include <tqlineedit.h> +#include <tqlabel.h> +#include <tqspinbox.h> +#include <tqpushbutton.h> +#include <tqpopupmenu.h> +#include <tqtoolbutton.h> +#include <tqwidgetstack.h> +#include <tqimage.h> + +#include <tdefiledialog.h> +#include <kstandarddirs.h> +#include <kurllabel.h> +#include <tqregexp.h> +#include <krun.h> +#include <kurlrequester.h> +#include <tdelocale.h> + +RadioConfiguration::RadioConfiguration (TQWidget *parent, const IErrorLogClient &logger) + : RadioConfigurationUI(parent), + ignoreChanges(false), + devicePopup(NULL), + m_logger(logger), + m_dirty(true) +{ + TQObject::connect(listStations, TQT_SIGNAL(sigCurrentStationChanged(int)), + this, TQT_SLOT(slotStationSelectionChanged(int))); + TQObject::connect(buttonSelectPixmapFile, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotSelectPixmap())); + TQObject::connect(buttonNewStation, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotNewStation())); + TQObject::connect(buttonDeleteStation, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotDeleteStation())); + TQObject::connect(editPixmapFile, TQT_SIGNAL(textChanged(const TQString &)), + this, TQT_SLOT(slotPixmapChanged(const TQString &))); + TQObject::connect(editStationName, TQT_SIGNAL(textChanged(const TQString &)), + this, TQT_SLOT(slotStationNameChanged(const TQString &))); + TQObject::connect(editStationShortName, TQT_SIGNAL(textChanged(const TQString &)), + this, TQT_SLOT(slotStationShortNameChanged(const TQString &))); + TQObject::connect(editVolumePreset, TQT_SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotVolumePresetChanged(int))); + TQObject::connect(buttonStationUp, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotStationUp())); + TQObject::connect(buttonStationDown, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotStationDown())); + TQObject::connect(listStations, TQT_SIGNAL(sigStationActivated(int)), + this, TQT_SLOT(slotActivateStation( int ))); + TQObject::connect(buttonLoadPresets, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotLoadPresets())); + TQObject::connect(buttonStorePresets, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotStorePresets())); + TQObject::connect(buttonLastChangeNow, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotLastChangeNow())); + + connect(editMaintainer, TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT(slotSetDirty())); + connect(editLastChange, TQT_SIGNAL(valueChanged(const TQDateTime &)), TQT_SLOT(slotSetDirty())); + connect(editCountry, TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT(slotSetDirty())); + connect(editCity, TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT(slotSetDirty())); + connect(editMedia, TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT(slotSetDirty())); + connect(editComment, TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT(slotSetDirty())); + connect(editPresetFile, TQT_SIGNAL(textChanged(const TQString &)), TQT_SLOT(slotSetDirty())); + + mailLabel->setText("mailto:witte-presets@kawo1.rwth-aachen.de"); + mailLabel->setURL ("mailto:witte-presets@kawo1.rwth-aachen.de"); + TQObject::connect(mailLabel, TQT_SIGNAL(leftClickedURL(const TQString &)), + this, TQT_SLOT(slotSendPresetsByMail(const TQString &))); + + TQObject::connect(buttonSearchStations, TQT_SIGNAL(clicked()), + this, TQT_SLOT(slotSearchStations0())); + + devicePopup = new TQPopupMenu(buttonSearchStations); + buttonSearchStations->setPopup(devicePopup); + TQObject::connect(devicePopup, TQT_SIGNAL(activated(int)), + this, TQT_SLOT(slotSearchStations(int))); +} + + +RadioConfiguration::~RadioConfiguration () +{ +} + + +bool RadioConfiguration::connectI (Interface *i) +{ + bool a = IRadioClient::connectI(i); + bool b = IRadioDevicePoolClient::connectI(i); + + return a || b; +} + +bool RadioConfiguration::disconnectI (Interface *i) +{ + bool a = IRadioClient::disconnectI(i); + bool b = IRadioDevicePoolClient::disconnectI(i); + + return a || b; +} + +// IRadioDevicePoolClient + +bool RadioConfiguration::noticeDevicesChanged(const TQPtrList<IRadioDevice> &l) +{ + TQPtrListIterator<IRadioDevice> it(l); + devices.clear(); + devicePopup->clear(); + int id = 0; + for (; it.current(); ++it) { + IRadioDevice *d = it.current(); + if (dynamic_cast<ISeekRadio*>(d)) { + devicePopup->insertItem(d->getDescription(), id++); + devices.append(d); + } + } + return true; +} + + +bool RadioConfiguration::noticeDeviceDescriptionChanged(const TQString &) +{ + noticeDevicesChanged(queryDevices()); + return true; +} + + +// IRadioClient + +bool RadioConfiguration::noticeStationsChanged(const StationList &sl) +{ + ignoreChanges = true; + + m_stations = sl; + + listStations->setStations(sl); + + StationListMetaData &info = m_stations.metaData(); + + editMaintainer->setText(info.maintainer); + editLastChange->setDateTime(info.lastChange); + editCountry->setText(info.country); + editCity->setText(info.city); + editMedia->setText(info.media); + editComment->setText(info.comment); + + ignoreChanges = false; + + slotStationSelectionChanged(listStations->currentStationIndex()); + + return true; +} + + +bool RadioConfiguration::noticePresetFileChanged(const TQString &f) +{ + ignoreChanges = true; + editPresetFile->setURL(f); + ignoreChanges = false; + return true; +} + + +void RadioConfiguration::slotStationSelectionChanged(int idx) +{ + RadioStation *s = NULL; + + if (idx >= 0 && idx < m_stations.count()) { + s = &m_stations.at(idx); + } + + editStationName ->setDisabled(!s); + labelStationName ->setDisabled(!s); + editPixmapFile ->setDisabled(!s); + labelPixmapFile ->setDisabled(!s); + editStationShortName ->setDisabled(!s); + labelStationShortName ->setDisabled(!s); + editVolumePreset ->setDisabled(!s); + labelVolumePreset ->setDisabled(!s); + buttonSelectPixmapFile->setDisabled(!s); + buttonDeleteStation ->setDisabled(!s); + + buttonStationUp ->setDisabled(!s || idx == 0); + buttonStationDown ->setDisabled(!s || idx == m_stations.count()-1); + + if (ignoreChanges) return; + ignoreChanges = true; + + editStationName ->setText (s ? s->name() : TQString()); + editStationShortName ->setText (s ? s->shortName() : TQString()); + editPixmapFile ->setText (s ? s->iconName() : TQString()); + editVolumePreset ->setValue (s ? (int)rint(s->initialVolume()*100) : -1); + + TQPixmap pixmap(s ? s->iconName() : TQString()); + if (!pixmap.isNull()) { + pixmapStation->setPixmap(pixmap); + } else { + pixmapStation->setText(""); + } + + + stackStationEdit->setDisabled(!s); + if (s) { + RadioStationConfig *c = stationEditors.find(s->getClassName()); + if (!c) { + c = s->createEditor(); + if (c) { + c->reparent(this, TQPoint(0,0), true); + TQObject::connect(c, TQT_SIGNAL(changed(RadioStationConfig*)), + this, TQT_SLOT(slotStationEditorChanged(RadioStationConfig*))); + stationEditors.insert(s->getClassName(), c); + stackStationEdit->addWidget(c); + } + } + if (c) { + c->setStationData(*s); + stackStationEdit->raiseWidget(c); + } + } + + ignoreChanges = false; +} + + +void RadioConfiguration::slotNewStation() +{ + slotSetDirty(); + const RadioStation *st = &queryCurrentStation(); + int n = m_stations.count(); + m_stations.all().append(st); + if (m_stations.count() == n) { + st = st->copyNewID(); + m_stations.all().append(st); + } + if (m_stations.count() > n) { + listStations->appendStation(*st); + listStations->setCurrentStation (listStations->count()-1); + slotStationSelectionChanged(listStations->count()-1); + listStations->ensureItemVisible(listStations->selectedItem()); + } +} + + +void RadioConfiguration::slotDeleteStation() +{ + int idx = listStations->currentStationIndex(); + + if (idx >= 0 && idx < m_stations.count()) { + slotSetDirty(); + m_stations.all().remove(idx); + listStations->removeStation(idx); + } +} + + +void RadioConfiguration::slotStationEditorChanged(RadioStationConfig *c) +{ + if (!c) return; + if (ignoreChanges) return; + + + int idx = listStations->currentStationIndex(); + if (idx >= 0 && idx < m_stations.count()) { + slotSetDirty(); + RadioStation &st = m_stations.at(idx); + + ignoreChanges = true; + bool o = listStations->signalsBlocked(); + listStations->blockSignals(true); + + c->storeStationData(st); + listStations->setStation(idx, st); + + listStations->blockSignals(o); + ignoreChanges = false; + } +} + + +void RadioConfiguration::slotStationNameChanged( const TQString & s) +{ + if (ignoreChanges) return; + + int idx = listStations->currentStationIndex(); + if (idx >= 0 && idx < m_stations.count()) { + slotSetDirty(); + RadioStation &st = m_stations.at(idx); + st.setName(s); + ignoreChanges = true; + bool o = listStations->signalsBlocked(); + listStations->blockSignals(true); + listStations->setStation(idx, st); + listStations->blockSignals(o); + ignoreChanges = false; + } +} + + +void RadioConfiguration::slotStationShortNameChanged( const TQString & sn) +{ + if (ignoreChanges) return; + + int idx = listStations->currentStationIndex(); + if (idx >= 0 && idx < m_stations.count()) { + slotSetDirty(); + RadioStation &st = m_stations.at(idx); + st.setShortName(sn); + ignoreChanges = true; + bool o = listStations->signalsBlocked(); + listStations->blockSignals(true); + listStations->setStation(idx, st); + listStations->blockSignals(o); + ignoreChanges = false; + } +} + + +void RadioConfiguration::slotSelectPixmap() +{ + KURL url = KFileDialog::getImageOpenURL(TQString(), this, + i18n("Image Selection")); + if (!url.isEmpty()) { + if (url.isLocalFile()) { + editPixmapFile->setText(url.path()); + } else { + m_logger.logWarning(i18n("ignoring non-local image")); + } + } +} + + +void RadioConfiguration::slotPixmapChanged( const TQString &s ) +{ + if (ignoreChanges) return; + + int idx = listStations->currentStationIndex(); + if (idx >= 0 && idx < m_stations.count()) { + slotSetDirty(); + RadioStation &st = m_stations.at(idx); + st.setIconName(s); + ignoreChanges = true; + pixmapStation->setPixmap(TQPixmap(s)); + bool o = listStations->signalsBlocked(); + listStations->blockSignals(true); + listStations->setStation(idx, st); + listStations->blockSignals(o); + ignoreChanges = false; + } +} + + +void RadioConfiguration::slotVolumePresetChanged(int v) +{ + int idx = listStations->currentStationIndex(); + if (idx >= 0 && idx < m_stations.count()) { + slotSetDirty(); + RadioStation &s = m_stations.at(idx); + s.setInitialVolume(0.01 * (double)v); + } +} + + + +void RadioConfiguration::slotStationUp() +{ + int idx = listStations->currentStationIndex(); + if (idx > 0 && idx < m_stations.count()) { + slotSetDirty(); + RawStationList &sl = m_stations.all(); + + RadioStation *st = sl.take(idx-1); + sl.insert(idx, st); + delete st; + + ignoreChanges = true; +// bool o = listStations->signalsBlocked(); +// listStations->blockSignals(true); + listStations->setStation(idx-1, *sl.at(idx-1)); + listStations->setStation(idx, *sl.at(idx)); + listStations->setCurrentStation(idx-1); +// listStations->blockSignals(o); + ignoreChanges = false; + } +} + + +void RadioConfiguration::slotStationDown() +{ + int idx = listStations->currentStationIndex(); + if (idx >= 0 && idx < m_stations.count() - 1) { + slotSetDirty(); + RawStationList &sl = m_stations.all(); + + RadioStation *st = sl.take(idx); + sl.insert(idx+1, st); + delete st; + + ignoreChanges = true; +// bool o = listStations->signalsBlocked(); +// listStations->blockSignals(true); + listStations->setStation(idx, *sl.at(idx)); + listStations->setStation(idx+1, *sl.at(idx+1)); + listStations->setCurrentStation(idx+1); +// listStations->blockSignals(o); + ignoreChanges = false; + } +} + + +void RadioConfiguration::slotActivateStation(int idx) +{ + if (idx >= 0 && idx < m_stations.count()) { + sendActivateStation(m_stations.at(idx)); + sendPowerOn(); + } +} + +void RadioConfiguration::slotLoadPresets() +{ + KFileDialog fd(locate("data", "tderadio/presets/"), + ("*.krp|" + i18n("TDERadio Preset Files")).ascii(), + this, + i18n("Preset File Selection").ascii(), + true); + fd.setMode(KFile::File | KFile::ExistingOnly); + fd.setCaption (i18n("Select Preset File")); + + if (fd.exec() == TQDialog::Accepted) { + slotSetDirty(); + StationList sl; + if (sl.readXML(fd.selectedURL(), m_logger)) { + noticeStationsChanged(sl); + } + } +} + + +void RadioConfiguration::slotStorePresets() +{ + KFileDialog fd("", + ("*.krp|" + i18n("TDERadio Preset Files")).ascii(), + this, + i18n("Preset File Selection").ascii(), + true); + fd.setMode(KFile::File); + fd.setCaption (i18n("Store Preset File")); + + if (fd.exec() == TQDialog::Accepted) { + editPresetFile->setURL(fd.selectedURL().url()); + m_stations.writeXML(fd.selectedURL(), m_logger); + } +} + + +void RadioConfiguration::slotLastChangeNow() +{ + slotSetDirty(); + editLastChange->setDateTime(TQDateTime::currentDateTime()); +} + + +static TQString &urlEscapes(TQString &s) +{ + s.replace(TQRegExp("%"), "%25"); + s.replace(TQRegExp("\t"), "%09"); + s.replace(TQRegExp("\n"), "%0A"); + s.replace(TQRegExp("\n"), "%0D"); + s.replace(TQRegExp(" "), "%20"); + s.replace(TQRegExp("\\!"), "%21"); + s.replace(TQRegExp("\""), "%22"); + s.replace(TQRegExp("#"), "%23"); + s.replace(TQRegExp("\\$"), "%24"); + s.replace(TQRegExp("\\&"), "%26"); + s.replace(TQRegExp("'"), "%27"); + s.replace(TQRegExp(","), "%2C"); + s.replace(TQRegExp(":"), "%3A"); + s.replace(TQRegExp(";"), "%3B"); + s.replace(TQRegExp("="), "%3D"); + s.replace(TQRegExp("\\?"), "%3F"); + return s; +} + +void RadioConfiguration::slotSendPresetsByMail( const TQString &url ) +{ + TQString presets = m_stations.writeXML(m_logger); + + urlEscapes(presets); + + // documentation says, krun object deletes itself, + // so we do not need to store the pointer + + TQString country = m_stations.metaData().country; + TQString city = m_stations.metaData().city; + TQString location = city + "/" + country; + urlEscapes(location); + + TQString cmd = url + "?subject=station preset file for " + location + "&body="; + + cmd += presets; + new KRun (cmd); +} + + +void RadioConfiguration::slotSearchStations(int idev) +{ + if (idev >= 0 && (unsigned)idev < devices.count()) { + IRadioDevice *dev = devices.at(idev); + + StandardScanDialog *x = new StandardScanDialog(NULL); + x->connectI(dev); // connect device + x->connectI(IRadioDevicePoolClient::iConnections.at(0)); // connect radio to get verbous station information + sendActiveDevice(dev); + x->show(); + x->start(); + if (x->exec() == TQDialog::Accepted) { + slotSetDirty(); + m_stations.merge(x->getStations()); + noticeStationsChanged(m_stations); + } + delete x; +// logDebug("scan finished"); + } +// logDebug("scan finished completely"); +} + + +void RadioConfiguration::slotOK() +{ + if (m_dirty) { + StationListMetaData &i = m_stations.metaData(); + + i.maintainer = editMaintainer->text(); + i.lastChange = editLastChange->dateTime(); + i.country = editCountry->text(); + i.city = editCity->text(); + i.media = editMedia->text(); + i.comment = editComment->text(); + + sendStations(m_stations); + sendPresetFile(editPresetFile->url()); + m_dirty = false; + } +} + +void RadioConfiguration::slotCancel() +{ + if (m_dirty) { + noticeStationsChanged(queryStations()); + noticePresetFileChanged(queryPresetFile()); + m_dirty = false; + } +} + + +void RadioConfiguration::slotSetDirty() +{ + if (!ignoreChanges) { + m_dirty = true; + } +} + + +#include "radio-configuration.moc" diff --git a/plugins/radio/radio-configuration.h b/plugins/radio/radio-configuration.h new file mode 100644 index 0000000..4e01ad9 --- /dev/null +++ b/plugins/radio/radio-configuration.h @@ -0,0 +1,107 @@ +/*************************************************************************** + radio-configuration.h - description + ------------------- + begin : Son Aug 3 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_RADIO_CONFIGURATION_H +#define KRADIO_RADIO_CONFIGURATION_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <tqdict.h> + +#include "../../src/include/radio_interfaces.h" +#include "../../src/include/stationlist.h" +#include "../../src/include/radiodevicepool_interfaces.h" +#include "radio-configuration-ui.h" + +class TQPopupMenu; +class RadioStationConfig; + +class RadioConfiguration : public RadioConfigurationUI, + public IRadioClient, + public IRadioDevicePoolClient +{ +Q_OBJECT + +public : + RadioConfiguration (TQWidget *parent, const IErrorLogClient &m_logger); + ~RadioConfiguration (); + + bool connectI (Interface *i); + bool disconnectI (Interface *i); + + // IRadioDevicePoolClient + +RECEIVERS: + bool noticeActiveDeviceChanged(IRadioDevice *) { return false; } + bool noticeDevicesChanged(const TQPtrList<IRadioDevice> &); + bool noticeDeviceDescriptionChanged(const TQString &); + + // IRadioClient + +RECEIVERS: + bool noticePowerChanged(bool /*on*/) { return false; } // don't care + bool noticeStationChanged (const RadioStation &, int /*idx*/) { return false; } // don't care + bool noticeStationsChanged(const StationList &sl); + bool noticePresetFileChanged(const TQString &f); + + bool noticeCurrentSoundStreamIDChanged(SoundStreamID /*id*/) { return false; } + +protected slots: + + void slotStationSelectionChanged(int idx); + void slotNewStation(); + void slotDeleteStation(); + void slotStationEditorChanged(RadioStationConfig *c); + void slotStationNameChanged( const TQString & s); + void slotStationShortNameChanged( const TQString & sn); + void slotPixmapChanged( const TQString &s ); + void slotSelectPixmap(); + void slotVolumePresetChanged(int v); + void slotStationUp(); + void slotStationDown(); + void slotActivateStation( int ); + void slotLoadPresets(); + void slotStorePresets(); + void slotLastChangeNow(); + void slotSendPresetsByMail( const TQString &url ); + + void slotSearchStations(int i); + void slotSearchStations0() { slotSearchStations(0); } + + void slotOK(); + void slotCancel(); + void slotSetDirty(); + + +protected: + + StationList m_stations; + bool ignoreChanges; + + TQPopupMenu *devicePopup; + TQPtrList<IRadioDevice> devices; + + TQDict<RadioStationConfig> stationEditors; + + const IErrorLogClient &m_logger; + bool m_dirty; +}; + +#endif + diff --git a/plugins/radio/radio.cpp b/plugins/radio/radio.cpp new file mode 100644 index 0000000..4e853ce --- /dev/null +++ b/plugins/radio/radio.cpp @@ -0,0 +1,497 @@ +/*************************************************************************** + radio.cpp - description + ------------------- + begin : Sat March 29 2003 + copyright : (C) 2003 by Klas Kalass, Ernst Martin Witte + email : klas@kde.org, 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/radiostation.h" +#include "../../src/include/aboutwidget.h" +#include "../../src/include/radiodevice_interfaces.h" +#include "radio.h" +#include "radio-configuration.h" + +#include <kstandarddirs.h> +#include <kurl.h> +#include <tdeaboutdata.h> +#include <tdeconfig.h> + +#include "../../src/include/debug-profiler.h" + +/////////////////////////////////////////////////////////////////////// +//// plugin library functions + +PLUGIN_LIBRARY_FUNCTIONS(Radio, "tderadio-radio", i18n("Central Radio Device Multiplexer")); + +///////////////////////////////////////////////////////////////////////////// + +Radio::Radio(const TQString &name) + : PluginBase(name, i18n("Radio Multiplexer Plugin")), + IRadioDeviceClient(-1), + m_presetFile(locateLocal("data", "tderadio/stations.krp")), + m_activeDevice (NULL) +{ +} + + +Radio::~Radio() +{ +} + + +bool Radio::connectI (Interface *i) +{ + bool a = IRadio::connectI(i); + bool b = IRadioDeviceClient::connectI(i); + bool c = IRadioDevicePool::connectI(i); + bool d = PluginBase::connectI(i); + bool e = ISoundStreamClient::connectI(i); + + // no "return IA::connectI() | return IB::connnectI to + // prevent "early termination" optimization in boolean expressions + return a || b || c || d || e; +} + + +bool Radio::disconnectI (Interface *i) +{ + bool a = IRadio::disconnectI(i); + bool b = IRadioDeviceClient::disconnectI(i); + bool c = IRadioDevicePool::disconnectI(i); + bool d = PluginBase::disconnectI(i); + bool e = ISoundStreamClient::disconnectI(i); + + // no "return IA::disconnectI() | return IB::disconnnectI to + // prevent "early termination" optimization in boolean expressions + return a || b || c || d || e; +} + + +void Radio::saveState (TDEConfig *config) const +{ + config->setGroup(TQString("radio-") + name()); + + config->writeEntry("presetfile", m_presetFile); + + m_stationList.writeXML(m_presetFile, *this); +} + + +void Radio::restoreState (TDEConfig *config) +{ + config->setGroup(TQString("radio-") + name()); + + m_presetFile = config->readEntry("presetfile", + TQString()); + bool first_restore = false; + if (m_presetFile.isNull() || m_presetFile.length() == 0) { + m_presetFile = locateLocal("data", "tderadio/stations.krp"); + first_restore = true; + } + + m_stationList.readXML(KURL(m_presetFile), *this, /*enable-messagebox*/ !first_restore); + + notifyStationsChanged(m_stationList); + notifyPresetFileChanged(m_presetFile); +} + + + +ConfigPageInfo Radio::createConfigurationPage() +{ + RadioConfiguration *conf = new RadioConfiguration (NULL, *this); + connectI (conf); + return ConfigPageInfo( + conf, + i18n("Radio Stations"), + i18n("Setup Radio Stations"), + "tderadio" + ); +} + + +AboutPageInfo Radio::createAboutPage() +{ +/* TDEAboutData aboutData("tderadio", + NULL, + NULL, + I18N_NOOP("Radio Device Multiplexer and Station Management for TDERadio"), + TDEAboutData::License_GPL, + "(c) 2002-2005 Martin Witte, Klas Kalass", + 0, + "http://sourceforge.net/projects/tderadio", + 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("Device and Station Management"), + i18n("Radio Device Multiplexer and Station Management"), + "tderadio" + ); +*/ + return AboutPageInfo(); +} + + + + + + +/* IRadio Interface Methods +*/ + +/* offer new station to current device. + if that does not accept, try all other devices. + Any device will be powered off if it does not accept the station +*/ + +bool Radio::activateStation (const RadioStation &rs) { + + if (sendActivateStation(rs)) { // first try activeDevice + + return true; + + } else { // hmm... active device did not want it. Try others... + + int n = 0; + + for (IRadioDeviceClient::IFIterator it(IRadioDeviceClient::iConnections); it.current(); ++it) { + + if (it.current()->activateStation(rs)) { + + setActiveDevice(it.current()); // select new device + ++n; + + } else { + + it.current()->powerOff(); + + } + } + + return n > 0; + } +} + + +bool Radio::activateStation(int index) +{ + if (index < 0 || index >= m_stationList.count()) + return false; + + return activateStation(m_stationList.at(index)); +} + + +bool Radio::setStations(const StationList &sl) +{ + if (true/*m_stationList != sl*/) { + BlockProfiler("Radio::setStations"); + m_stationList = sl; + notifyStationsChanged(m_stationList); + } + return true; +} + +bool Radio::setPresetFile(const TQString &presetFile) +{ + if (m_presetFile != presetFile) { + m_presetFile = presetFile; + notifyPresetFileChanged(m_presetFile); + } + return true; +} + +int Radio::getStationIdx(const RadioStation &rs) const +{ + RawStationList &sl = const_cast<RawStationList&>(m_stationList.all()); + return sl.find(&rs); +} + +int Radio::getCurrentStationIdx() const +{ + return getStationIdx(getCurrentStation()); +} + +SoundStreamID Radio::getCurrentSoundStreamID() const +{ + return queryCurrentSoundStreamID(); +} + + +/* IRadioDevicePool Interface Methods + +*/ + + +bool Radio::setActiveDevice(IRadioDevice *rd, bool keepPower) +{ + // do nothing if old == new + if (m_activeDevice == rd) + return true; + + // check if new station is in "connections" + // special case: rd == NULL: power off active device, new active device = NULL + + if (!rd || IRadioDeviceClient::iConnections.containsRef(rd)) { // new device is ok + + // save old power state and power off old device + bool oldPowerOn = false; + if (m_activeDevice) { + oldPowerOn = m_activeDevice->isPowerOn(); + m_activeDevice->powerOff(); + } + + // setup new active device && send notifications + m_activeDevice = rd; + + // send notifications + notifyActiveDeviceChanged(m_activeDevice); + notifyCurrentSoundStreamIDChanged(queryCurrentSoundStreamID()); + const RadioStation &rs = queryCurrentStation(); + notifyStationChanged(rs, getStationIdx(rs)); + + if (keepPower) + oldPowerOn ? sendPowerOn() : sendPowerOff(); + + return true; + + } else { + return false; + } +} + + +IRadioDevice *Radio::getActiveDevice() const +{ + return m_activeDevice; +} + + +const TQPtrList<IRadioDevice> &Radio::getDevices() const +{ + return IRadioDeviceClient::iConnections; +} + + +const TQString &Radio::getDeviceDescription() const +{ + return queryDescription(); +} + + + +/* IRadioDeviceClient Interface Methods + + Many things are overwritten, particularly all sending methods + +*/ + +int Radio::sendPowerOn() const +{ + return m_activeDevice ? m_activeDevice->powerOn() : 0; +} + + +int Radio::sendPowerOff() const +{ + return m_activeDevice ? m_activeDevice->powerOff() : 0; +} + +int Radio::sendActivateStation (const RadioStation &rs) const +{ + return m_activeDevice ? m_activeDevice->activateStation(rs) : 0; +} + + + +bool Radio::queryIsPowerOn() const +{ + return m_activeDevice ? m_activeDevice->isPowerOn() : false; +} + + +bool Radio::queryIsPowerOff() const +{ + return m_activeDevice ? m_activeDevice->isPowerOff() : true; +} + + +const RadioStation & Radio::queryCurrentStation() const +{ + if (m_activeDevice) { + RadioStation &rs = const_cast<RadioStation&>(m_activeDevice->getCurrentStation()); + int idx = getStationIdx(rs); + + if (idx >= 0) { + rs.copyDescriptionFrom(m_stationList.at(idx)); + } else { + rs.copyDescriptionFrom(undefinedRadioStation); + } + + return rs; + } else { + return undefinedRadioStation; + } +} + + +static TQString qstrUnknown(I18N_NOOP("unknown")); +static TQString i18nqstrUnknown; +const TQString &Radio::queryDescription() const +{ + return m_activeDevice ? m_activeDevice->getDescription() : (i18nqstrUnknown = i18n(qstrUnknown.ascii())); +} + + + +bool Radio::noticePowerChanged (bool on, const IRadioDevice *sender) +{ + if (on) { + setActiveDevice(const_cast<IRadioDevice*>(sender), false); + // false: do not set power state on new device + // constcast valid because power-state of sender is not changed + notifyPowerChanged(true); + return true; + + } else { + if (sender == m_activeDevice) { + sendStopCountdown(); + notifyPowerChanged(false); + return true; + } + return false; + } +} + + +bool Radio::noticeStationChanged (const RadioStation &_rs, const IRadioDevice *sender) +{ + RadioStation &rs = const_cast<RadioStation&>(_rs); + int idx = getStationIdx(rs); + + RadioStation &known = (idx >= 0) ? (RadioStation&)m_stationList.at(idx) : + (RadioStation&)undefinedRadioStation; + rs.copyDescriptionFrom(known); + + if (sender == m_activeDevice) + notifyStationChanged(rs, idx); + return true; +} + + +bool Radio::noticeDescriptionChanged (const TQString &s, const IRadioDevice *sender) +{ + if (sender == m_activeDevice) + notifyDeviceDescriptionChanged(s); + return true; +} + + +bool Radio::noticeCurrentSoundStreamIDChanged(SoundStreamID id, const IRadioDevice *sender) +{ + if (sender == m_activeDevice) + notifyCurrentSoundStreamIDChanged(id); + return true; +} + + +SoundStreamID Radio::queryCurrentSoundStreamID() const +{ + return m_activeDevice ? m_activeDevice->getCurrentSoundStreamID() : SoundStreamID::InvalidID; +} + + + +void Radio::noticeConnectedI(IRadioDeviceClient::cmplInterface *dev, bool pointer_valid) +{ + IRadioDeviceClient::noticeConnectedI(dev, pointer_valid); + + if (! m_activeDevice && pointer_valid) + setActiveDevice (dev, false); + + notifyDevicesChanged(IRadioDeviceClient::iConnections); +} + + +void Radio::noticeDisconnectI(IRadioDeviceClient::cmplInterface *rd, bool pointer_valid) +{ + IRadioDeviceClient::noticeDisconnectI(rd, pointer_valid); + + if (rd == m_activeDevice) { + + // search a new active device + if (IRadioDeviceClient::iConnections.findRef(rd) >= 0) { + + IRadioDevice *new_rd = NULL; + + new_rd = IRadioDeviceClient::iConnections.next(); // choose next device as active device if next exists + if (!new_rd) { + IRadioDeviceClient::iConnections.findRef(rd); + new_rd = IRadioDeviceClient::iConnections.prev(); // otherwise try prev then, may be NULL (no connections) + } + setActiveDevice(new_rd); + + } else { + // strange error occurred, m_activeDevice not in connections... set to first. + + setActiveDevice(IRadioDeviceClient::iConnections.first()); + } + } + notifyDevicesChanged(IRadioDeviceClient::iConnections); +} + + +// ITimeControlClient + +bool Radio::noticeAlarm(const Alarm &a) +{ + if (a.alarmType() == Alarm::StartPlaying || + a.alarmType() == Alarm::StartRecording) + { + const RawStationList &sl = getStations().all(); + const RadioStation &rs = sl.stationWithID(a.stationID()); + activateStation(rs); + powerOn(); + + if (a.volumePreset() >= 0) + sendPlaybackVolume(getCurrentSoundStreamID(), a.volumePreset()); + + SoundStreamID id = getCurrentSoundStreamID(); + bool r = false; + SoundFormat sf; + queryIsRecordingRunning(id, r, sf); + if (a.alarmType() == Alarm::StartRecording && !r) + sendStartRecording(id); + + } else { + powerOff(); + } + return true; +} + + +bool Radio::noticeCountdownZero() +{ + powerOff(); + return true; +} + + +void Radio::aboutToQuit() +{ + sendPowerOff(); +} + diff --git a/plugins/radio/radio.h b/plugins/radio/radio.h new file mode 100644 index 0000000..66798fb --- /dev/null +++ b/plugins/radio/radio.h @@ -0,0 +1,167 @@ +/*************************************************************************** + radio.h - description + ------------------- + begin : Sat March 29 2003 + copyright : (C) 2003 by Klas Kalass, Ernst Martin Witte + email : klas@kde.org, 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_RADIO_H +#define KRADIO_RADIO_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + + +#include "../../src/include/radio_interfaces.h" +#include "../../src/include/radiodevicepool_interfaces.h" +#include "../../src/include/radiodevice_interfaces.h" +#include "../../src/include/timecontrol_interfaces.h" +#include "../../src/include/soundstreamclient_interfaces.h" +#include "../../src/include/stationlist.h" +#include "../../src/include/plugins.h" + +/** + * The main Radio class, which is used as the interface of the radio functionality + * to the GUI parts of the application + * @author Klas Kalass, Ernst Martin Witte + */ + +///////////////////////////////////////////////////////////////////////////// + +/* A class, that is able to manage more than one radio device, one of those + is active at a time. This class behaves represents the active device, + the active devices can be changed either by selecting a station or by + explicitly changing the devices. + + At any time a valid active device exists as long as any device is connected. + +*/ + +class Radio : public PluginBase, + public IRadio, + public IRadioDevicePool, + public IRadioDeviceClient, + public ITimeControlClient, + public ISoundStreamClient +{ +public: + Radio(const TQString &name); + ~Radio(); + + + // PluginBase + +public: + virtual void saveState (TDEConfig *) const; + virtual void restoreState (TDEConfig *); + + virtual TQString pluginClassName() const { return "Radio"; } + + virtual const TQString &name() const { return PluginBase::name(); } + virtual TQString &name() { return PluginBase::name(); } + + virtual ConfigPageInfo createConfigurationPage(); + virtual AboutPageInfo createAboutPage(); + + virtual void aboutToQuit(); + + // IRadio methods + +RECEIVERS: + bool powerOn() { return sendPowerOn() > 0; } + bool powerOff() { return sendPowerOff() > 0; } + bool activateStation(const RadioStation &rs); + bool activateStation(int index); + bool setStations(const StationList &sl); + bool setPresetFile(const TQString &presetFile); + +ANSWERS: + bool isPowerOn() const { return queryIsPowerOn(); } + bool isPowerOff() const { return queryIsPowerOff(); } + const RadioStation & getCurrentStation() const { return queryCurrentStation(); } + int getStationIdx(const RadioStation &) const; + int getCurrentStationIdx() const; + const StationList & getStations() const { return m_stationList; } + const TQString & getPresetFile() const { return m_presetFile; } + + SoundStreamID getCurrentSoundStreamID() const; + + +public: + bool connectI (Interface *i); + bool disconnectI (Interface *i); + + void noticeConnectedI (IRadioDeviceClient::cmplInterface *i, bool pointer_valid); + void noticeDisconnectI(IRadioDeviceClient::cmplInterface *i, bool pointer_valid); + + // IRadioDevicePool methods + +RECEIVERS: + bool setActiveDevice(IRadioDevice *rd, bool keepPower = true); + +ANSWERS: + IRadioDevice * getActiveDevice() const; + const TQPtrList<IRadioDevice> & getDevices() const; + const TQString & getDeviceDescription() const; + + + + // IRadioDeviceClient methods, even sending methods overwritten + // to provide "1-of-N" functionality + +SENDERS: + IF_SENDER ( sendPowerOn() ) + IF_SENDER ( sendPowerOff() ) + IF_SENDER ( sendActivateStation (const RadioStation &rs) ) + +QUERIES: + IF_QUERY ( bool queryIsPowerOn() ) + IF_QUERY ( bool queryIsPowerOff() ) + IF_QUERY ( const RadioStation & queryCurrentStation() ) + IF_QUERY ( const TQString & queryDescription() ) + IF_QUERY ( SoundStreamID queryCurrentSoundStreamID() ) + +RECEIVERS: + virtual bool noticePowerChanged (bool on, const IRadioDevice *sender = NULL); + virtual bool noticeStationChanged (const RadioStation &rs, const IRadioDevice *sender = NULL); + virtual bool noticeDescriptionChanged (const TQString &, const IRadioDevice *sender = NULL); + + virtual bool noticeCurrentSoundStreamIDChanged(SoundStreamID id, const IRadioDevice *sender = NULL); + + // ITimeControlClient + +RECEIVERS: + bool noticeAlarmsChanged(const AlarmVector &) { return false; } // ignore + bool noticeAlarm(const Alarm &); + bool noticeNextAlarmChanged(const Alarm *) { return false; } // ignore + bool noticeCountdownStarted(const TQDateTime &/*end*/){ return false; } // ignore + bool noticeCountdownStopped() { return false; } // ignore + bool noticeCountdownZero(); + bool noticeCountdownSecondsChanged(int /*n*/) { return false; } // ignore + + // ISoundStreamClient + +RECEIVERS: + + // ... + +protected: + + TQString m_presetFile; + StationList m_stationList; + IRadioDevice *m_activeDevice; +}; + + +#endif |