1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/***************************************************************************
v4lradio-configuration.cpp - description
-------------------
begin : Fre Jun 20 2003
copyright : (C) 2003 by Martin Witte
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/soundcard.h>
#include <tqspinbox.h>
#include <tqlineedit.h>
#include <tqcombobox.h>
#include <tqlabel.h>
#include <tqfile.h>
#include <tqpushbutton.h>
#include <tdefiledialog.h>
#include <knuminput.h>
#include <tdelocale.h>
#include "../../src/include/utils.h"
#include "../../src/include/gui_list_helper.h"
#include "timeshifter-configuration.h"
#include "timeshifter.h"
TimeShifterConfiguration::TimeShifterConfiguration (TQWidget *parent, TimeShifter *shifter)
: TimeShifterConfigurationUI(parent),
m_ignoreGUIChanges(false),
m_myControlChange(0),
m_PlaybackMixerHelper(comboPlaybackMixerDevice, StringListHelper::SORT_BY_DESCR),
m_PlaybackChannelHelper(comboPlaybackMixerChannel),
m_Shifter(shifter),
m_dirty(true)
{
TQObject::connect(buttonSelectTempFile, TQT_SIGNAL(clicked()),
this, TQT_SLOT(selectTempFile()));
TQObject::connect(comboPlaybackMixerDevice, TQT_SIGNAL(activated(int)),
this, TQT_SLOT(slotComboPlaybackMixerSelected(int)));
connect(editTempFile, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(slotSetDirty()));
connect(editTempFileSize, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetDirty()));
connect(comboPlaybackMixerChannel, TQT_SIGNAL(activated( int )), this, TQT_SLOT(slotSetDirty()));
connect(comboPlaybackMixerDevice, TQT_SIGNAL(activated( int )), this, TQT_SLOT(slotSetDirty()));
slotCancel();
}
TimeShifterConfiguration::~TimeShifterConfiguration ()
{
}
bool TimeShifterConfiguration::connectI (Interface *i)
{
bool a = ISoundStreamClient::connectI(i);
return a;
}
bool TimeShifterConfiguration::disconnectI (Interface *i)
{
bool a = ISoundStreamClient::disconnectI(i);
return a;
}
void TimeShifterConfiguration::noticeConnectedI (ISoundStreamServer *s, bool pointer_valid)
{
ISoundStreamClient::noticeConnectedI(s, pointer_valid);
if (s && pointer_valid) {
s->register4_notifyPlaybackChannelsChanged(this);
}
}
void TimeShifterConfiguration::noticeConnectedSoundClient(ISoundStreamClient::thisInterface *i, bool pointer_valid)
{
if (i && pointer_valid && i->supportsPlayback() && m_Shifter) {
const TQString &org_mid = m_Shifter->getPlaybackMixer();
bool org_present = m_PlaybackMixerHelper.contains(org_mid);
const TQString &mid = org_present ? m_PlaybackMixerHelper.getCurrentItem() : org_mid;
const TQString &org_ch = m_Shifter->getPlaybackMixerChannel();
const TQString &ch = org_present ? m_PlaybackChannelHelper.getCurrentText() : org_ch;
setPlaybackMixer(mid, ch);
}
}
void TimeShifterConfiguration::noticeDisconnectedSoundClient(ISoundStreamClient::thisInterface *i, bool pointer_valid)
{
if (i && pointer_valid && i->supportsPlayback()) {
setPlaybackMixer(m_Shifter->getPlaybackMixer(), m_Shifter->getPlaybackMixerChannel());
}
}
bool TimeShifterConfiguration::setPlaybackMixer(const TQString &_mixer_id, const TQString &Channel)
{
TQString mixer_id = _mixer_id;
bool old = m_ignoreGUIChanges;
m_ignoreGUIChanges = true;
m_PlaybackMixerHelper.setData(getPlaybackClientDescriptions());
m_PlaybackMixerHelper.setCurrentItem(mixer_id);
mixer_id = m_PlaybackMixerHelper.getCurrentItem();
ISoundStreamClient *mixer = getSoundStreamClientWithID(mixer_id);
if (mixer) {
m_PlaybackChannelHelper.setData(mixer->getPlaybackChannels());
m_PlaybackChannelHelper.setCurrentText(m_PlaybackChannelHelper.contains(Channel) ? Channel : m_Shifter->getPlaybackMixerChannel());
}
labelPlaybackMixerChannel->setEnabled(mixer != NULL);
comboPlaybackMixerChannel->setEnabled(mixer != NULL);
m_ignoreGUIChanges = old;
return true;
}
// GUI Slots
void TimeShifterConfiguration::selectTempFile()
{
KFileDialog fd("/tmp/",
i18n("any ( * )").ascii(),
this,
i18n("TimeShifter Temporary File Selection").ascii(),
TRUE);
fd.setMode(KFile::File);
fd.setCaption (i18n("Select TimeShifter Temporary File"));
if (fd.exec() == TQDialog::Accepted) {
editTempFile->setText(fd.selectedFile());
}
}
void TimeShifterConfiguration::slotComboPlaybackMixerSelected(int /*idx*/)
{
if (m_ignoreGUIChanges) return;
setPlaybackMixer(m_PlaybackMixerHelper.getCurrentItem(), m_PlaybackChannelHelper.getCurrentText());
}
void TimeShifterConfiguration::slotOK()
{
if (m_Shifter && m_dirty) {
m_Shifter->setTempFile(editTempFile->text(), editTempFileSize->value() * (TQ_UINT64)(1024 * 1024));
m_Shifter->setPlaybackMixer(m_PlaybackMixerHelper.getCurrentItem(),
m_PlaybackChannelHelper.getCurrentText());
m_dirty = false;
}
}
void TimeShifterConfiguration::slotCancel()
{
if (m_Shifter && m_dirty) {
editTempFile->setText(m_Shifter->getTempFileName());
editTempFileSize->setValue(m_Shifter->getTempFileMaxSize() / 1024 / 1024);
setPlaybackMixer(m_Shifter->getPlaybackMixer(), m_Shifter->getPlaybackMixerChannel());
m_dirty = false;
}
}
bool TimeShifterConfiguration::noticePlaybackChannelsChanged(const TQString & client_id, const TQStringList &/*channels*/)
{
if (m_PlaybackMixerHelper.getCurrentItem() == client_id) {
setPlaybackMixer(client_id, m_PlaybackChannelHelper.getCurrentText());
}
return true;
}
void TimeShifterConfiguration::slotSetDirty()
{
if (!m_ignoreGUIChanges) {
m_dirty = true;
}
}
void TimeShifterConfiguration::slotUpdateConfig()
{
slotSetDirty();
slotCancel();
}
#include "timeshifter-configuration.moc"
|