00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "mainwindow.h"
00022
00023 #include "settings_general_dialog.h"
00024 #include "stationdirectorytree.h"
00025 #include <QDockWidget>
00026 #include <KApplication>
00027 #include <KAction>
00028 #include <KLocale>
00029 #include <KActionCollection>
00030 #include <KTipDialog>
00031 #include <KStatusBar>
00032 #include <KStandardDirs>
00033
00034 MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent)
00035 {
00036
00037 m_streamlistwidget = new stationlistWidget(this);
00038 setCentralWidget(m_streamlistwidget);
00039
00040
00041 KStandardAction::preferences(this, SLOT(display_global_settings_dialog()),
00042 actionCollection());
00043
00044 KStandardAction::quit(kapp, SLOT(quit()), actionCollection());
00045
00046 KAction * newStreamAction = new KAction(this);
00047 newStreamAction->setText(i18nc("@action", "&New stream"));
00048 newStreamAction->setIcon(KIcon("document-new"));
00049 newStreamAction->setShortcut(QKeySequence::New);
00050 connect(newStreamAction, SIGNAL(triggered(bool)),
00051 m_streamlistwidget, SLOT(addNewStation()));
00052 actionCollection()->addAction("newStream", newStreamAction);
00053 m_streamlistwidget->contextMenu.addAction(newStreamAction);
00054
00055 KAction * deleteStreamAction = new KAction(this);
00056 deleteStreamAction->setText(i18nc("@action", "&Delete stream"));
00057 deleteStreamAction->setIcon(KIcon("edit-delete"));
00058 deleteStreamAction->setShortcut(Qt::SHIFT + Qt::Key_Delete);
00059 deleteStreamAction->setDisabled(true);
00060 connect(deleteStreamAction, SIGNAL(triggered(bool)),
00061 m_streamlistwidget, SLOT(deleteStation()));
00062 connect(m_streamlistwidget, SIGNAL(noneSelected(bool)),
00063 deleteStreamAction, SLOT(setDisabled(bool)));
00064 connect(m_streamlistwidget, SIGNAL(oneSelected(bool)),
00065 deleteStreamAction, SLOT(setEnabled(bool)));
00066 connect(m_streamlistwidget, SIGNAL(multipleSelected(bool)),
00067 deleteStreamAction, SLOT(setEnabled(bool)));
00068 actionCollection()->addAction("deleteStream", deleteStreamAction);
00069 m_streamlistwidget->contextMenu.addAction(deleteStreamAction);
00070
00071 KAction * selectAllAction = KStandardAction::selectAll(m_streamlistwidget, SLOT(selectAll()),
00072 actionCollection());
00073 m_streamlistwidget->contextMenu.addAction(selectAllAction);
00074
00075 KAction * recordAction = new KAction(this);
00076 recordAction->setText(i18nc("@action", "&Record"));
00077 recordAction->setIcon(KIcon("media-record"));
00078
00079 recordAction->setShortcut(Qt::CTRL + Qt::Key_R);
00080 recordAction->setDisabled(true);
00081 connect(recordAction, SIGNAL(triggered(bool)),
00082 m_streamlistwidget, SLOT(record()));
00083 connect(m_streamlistwidget, SIGNAL(noneSelected(bool)),
00084 recordAction, SLOT(setDisabled(bool)));
00085
00086 connect(m_streamlistwidget, SIGNAL(oneSelected(bool)),
00087 recordAction, SLOT(setEnabled(bool)));
00088
00089 connect(m_streamlistwidget, SIGNAL(multipleSelected(bool)),
00090 recordAction, SLOT(setEnabled(bool)));
00091 actionCollection()->addAction("record", recordAction);
00092 m_streamlistwidget->contextMenu.addAction(recordAction);
00093
00094 KAction * stopRecordAction = new KAction(this);
00095 stopRecordAction->setText(i18nc("@action", "&Stop"));
00096 stopRecordAction->setIcon(KIcon("media-playback-stop"));
00097 QList<QKeySequence> stopRecordAction_tempShortcutList;
00098 stopRecordAction_tempShortcutList.append(Qt::Key_S);
00099 stopRecordAction_tempShortcutList.append(Qt::CTRL + Qt::Key_S);
00100 stopRecordAction_tempShortcutList.append(Qt::META + Qt::Key_V);
00101
00102 stopRecordAction->setShortcuts(stopRecordAction_tempShortcutList);
00103 stopRecordAction->setDisabled(true);
00104 connect(stopRecordAction, SIGNAL(triggered(bool)),
00105 m_streamlistwidget, SLOT(stopRecord()));
00106 connect(m_streamlistwidget, SIGNAL(noneSelected(bool)),
00107 stopRecordAction, SLOT(setDisabled(bool)));
00108
00109 connect(m_streamlistwidget, SIGNAL(oneSelected(bool)),
00110 stopRecordAction, SLOT(setEnabled(bool)));
00111
00112 connect(m_streamlistwidget, SIGNAL(multipleSelected(bool)),
00113 stopRecordAction, SLOT(setEnabled(bool)));
00114 actionCollection()->addAction("stopRecord", stopRecordAction);
00115 m_streamlistwidget->contextMenu.addAction(stopRecordAction);
00116
00117 KAction * streamSettingsAction = new KAction(this);
00118 streamSettingsAction->setText(i18nc("@action properties of a stream)", "&Properties"));
00119
00120 streamSettingsAction->setShortcut(Qt::ALT + Qt::Key_Return);
00121
00122 streamSettingsAction->setDisabled(true);
00123 connect(streamSettingsAction, SIGNAL(triggered(bool)),
00124 m_streamlistwidget, SLOT(displayStreamSettings()));
00125 connect(m_streamlistwidget, SIGNAL(noneSelected(bool)),
00126 streamSettingsAction, SLOT(setDisabled(bool)));
00127 connect(m_streamlistwidget, SIGNAL(oneSelected(bool)),
00128 streamSettingsAction, SLOT(setEnabled(bool)));
00129
00130 connect(m_streamlistwidget, SIGNAL(multipleSelected(bool)),
00131 streamSettingsAction, SLOT(setDisabled(bool)));
00132 actionCollection()->addAction("streamSettings", streamSettingsAction);
00133 m_streamlistwidget->contextMenu.addAction(streamSettingsAction);
00134
00135 KStandardAction::tipOfDay(this, SLOT(displayTipOfDay()), actionCollection());
00136
00137
00138 setupGUI();
00139
00140 statusBar()->insertPermanentItem(QString(), 0);
00141 statusBar()->insertPermanentItem(QString(), 1);
00142 connect(m_streamlistwidget->stationlistmodel(),
00143 SIGNAL(bandwidthChanged()),
00144 this,
00145 SLOT(actualize_bandwidth_in_statusBar()));
00146 connect(m_streamlistwidget->stationlistmodel(),
00147 SIGNAL(numberOfActiveStreamsChanged()),
00148 this,
00149 SLOT(actualize_numberOfActiveStreams_in_statusBar()));
00150 actualize_bandwidth_in_statusBar();
00151 actualize_numberOfActiveStreams_in_statusBar();
00152
00153 QDockWidget *m_streamDirectory = new QDockWidget(
00154 i18nc("@title:window Dock name of the directory of radio stations",
00155 "Shoutcast radiostation directory"),
00156 this);
00157 m_streamDirectory->setObjectName("theRadiostationDirectory");
00158 m_streamDirectory->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea |
00159 Qt::BottomDockWidgetArea);
00160 stationDirectoryTree *mainwidget_of_dock = new stationDirectoryTree(
00161 m_streamDirectory,
00162 KStandardDirs::locate("appdata", "action-favorite-genres-amarok.svgz"));
00163 m_streamDirectory->setWidget(mainwidget_of_dock);
00164 addDockWidget(Qt::LeftDockWidgetArea, m_streamDirectory);
00165
00166 KTipDialog::showTip(this, "kradioripper/tips");
00167 }
00168
00169 MainWindow::~MainWindow()
00170 {
00171 }
00172
00173 void MainWindow::actualize_numberOfActiveStreams_in_statusBar()
00174 {
00175 statusBar()->changeItem(
00176 i18ncp("@info:status",
00177 "Recording %1 stream.",
00178 "Recording %1 streams.",
00179 m_streamlistwidget->stationlistmodel()->numberOfActiveStreams()),
00180 0);
00181 }
00182
00183 void MainWindow::actualize_bandwidth_in_statusBar()
00184 {
00185 statusBar()->changeItem(
00186 i18ncp("@info:status The unit is kbit (=1000 bit) instead of Kibit (=1024 bit). "
00187 "See http://en.wikipedia.org/wiki/Binary_prefix for details.",
00188 "%1 kbit/s",
00189 "%1 kbit/s",
00190 m_streamlistwidget->stationlistmodel()->bandwidth()),
00191 1);
00192 }
00193
00194 bool MainWindow::queryClose()
00195 {
00196 return m_streamlistwidget->queryClose();
00197 }
00198
00199 void MainWindow::saveProperties(KConfigGroup & m_configGroup)
00200 {
00201 m_streamlistwidget->saveProperties(m_configGroup);
00202 }
00203
00204 void MainWindow::readProperties(const KConfigGroup & m_configGroup)
00205 {
00206 m_streamlistwidget->readProperties(m_configGroup);
00207 }
00208
00209 void MainWindow::display_global_settings_dialog()
00210 {
00211
00212 if (KConfigDialog::showDialog("settings_general_dialog")) {
00213 return;
00214 };
00215
00216
00217 settings_general_dialog * dialog = new settings_general_dialog(this,
00218 "settings_general_dialog");
00219 dialog->show();
00220 }
00221
00222 void MainWindow::displayTipOfDay()
00223 {
00224 KTipDialog::showTip(this, "kradioripper/tips", true);
00225 }