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
|
/* smplayer, GUI front-end for mplayer.
Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "prefdrives.h"
#include "images.h"
#include "preferences.h"
#include <QFile>
#include <QFileInfoList>
#include <QDir>
#ifdef Q_OS_WIN
#include <windows.h>
bool isCDDevice(QString drive) {
if (QSysInfo::WindowsVersion >= QSysInfo::WV_NT) {
unsigned int r = GetDriveTypeW((LPCWSTR) drive.utf16());
qDebug("isCDDevice: '%s' r: %d", drive.toUtf8().data(), r);
return (r == DRIVE_CDROM);
} else {
//Win98
return true;
}
}
#endif
PrefDrives::PrefDrives(QWidget * parent, Qt::WindowFlags f)
: PrefWidget(parent, f )
{
setupUi(this);
#if !DVDNAV_SUPPORT
use_dvdnav_check->hide();
#endif
#ifndef Q_OS_WIN
check_drives_button->hide();
#endif
updateDriveCombos();
retranslateStrings();
}
PrefDrives::~PrefDrives()
{
}
QString PrefDrives::sectionName() {
return tr("Drives");
}
QPixmap PrefDrives::sectionIcon() {
return Images::icon("pref_devices");
}
void PrefDrives::retranslateStrings() {
retranslateUi(this);
cdrom_drive_icon->setPixmap( Images::icon("cdrom_drive") );
dvd_drive_icon->setPixmap( Images::icon("dvd_drive") );
createHelp();
}
void PrefDrives::updateDriveCombos(bool detect_cd_devices) {
qDebug("PrefDrives::updateDriveCombos: detect_cd_devices: %d", detect_cd_devices);
// Save current values
QString current_dvd_device = dvdDevice();
QString current_cd_device = cdromDevice();
dvd_device_combo->clear();
cdrom_device_combo->clear();
// DVD device combo
// In windows, insert the drives letters
#ifdef Q_OS_WIN
QFileInfoList list = QDir::drives();
for (int n = 0; n < list.size(); n++) {
QString s = list[n].filePath();
bool is_cd_device = true;
if (detect_cd_devices) is_cd_device = isCDDevice(s);
if (is_cd_device) {
if (s.endsWith("/")) s = s.remove( s.length()-1,1);
dvd_device_combo->addItem( s );
cdrom_device_combo->addItem( s );
}
}
#else
QDir dev_dir("/dev");
QStringList devices = dev_dir.entryList( QStringList() << "dvd*" << "cdrom*" << "cdrw*" << "sr*" << "cdrecorder*" << "acd[0-9]*" << "cd[0-9]*",
QDir::Files | QDir::System | QDir::Readable);
for (int n=0; n < devices.count(); n++) {
QString device_name = "/dev/" + devices[n];
qDebug("PrefDrives::PrefDrives: device found: '%s'", device_name.toUtf8().constData());
dvd_device_combo->addItem(device_name);
cdrom_device_combo->addItem(device_name);
}
#endif
// Restore previous values
setDVDDevice( current_dvd_device );
setCDRomDevice( current_cd_device );
}
void PrefDrives::setData(Preferences * pref) {
setDVDDevice( pref->dvd_device );
setCDRomDevice( pref->cdrom_device );
#if DVDNAV_SUPPORT
setUseDVDNav( pref->use_dvdnav );
#endif
}
void PrefDrives::getData(Preferences * pref) {
requires_restart = false;
pref->dvd_device = dvdDevice();
pref->cdrom_device = cdromDevice();
#if DVDNAV_SUPPORT
pref->use_dvdnav = useDVDNav();
#endif
}
void PrefDrives::setDVDDevice( QString dir ) {
dvd_device_combo->setCurrentText( dir );
}
QString PrefDrives::dvdDevice() {
return dvd_device_combo->currentText();
}
void PrefDrives::setCDRomDevice( QString dir ) {
cdrom_device_combo->setCurrentText( dir );
}
QString PrefDrives::cdromDevice() {
return cdrom_device_combo->currentText();
}
#if DVDNAV_SUPPORT
void PrefDrives::setUseDVDNav(bool b) {
use_dvdnav_check->setChecked(b);
}
bool PrefDrives::useDVDNav() {
return use_dvdnav_check->isChecked();
}
#endif
void PrefDrives::on_check_drives_button_clicked() {
qDebug("PrefDrives::on_check_drives_button_clicked");
updateDriveCombos(true);
}
void PrefDrives::createHelp() {
clearHelp();
setWhatsThis(cdrom_device_combo, tr("CD device"),
tr("Choose your CDROM device. It will be used to play "
"VCDs and Audio CDs.") );
setWhatsThis(dvd_device_combo, tr("DVD device"),
tr("Choose your DVD device. It will be used to play DVDs.") );
#if DVDNAV_SUPPORT
setWhatsThis(use_dvdnav_check, tr("Enable DVD menus"),
tr("If this option is checked, smplayer will play DVDs using "
"dvdnav. Requires a recent version of mplayer compiled with dvdnav "
"support.") +"<br>" +
tr("<b>Note 1</b>: cache will be disabled, this can affect performance.") +"<br>"+
tr("<b>Note 2</b>: you may want to assign the action "
"\"activate option in DVD menus\" to one of the mouse buttons.") + "<br>"+
tr("<b>Note 3</b>: this feature is under development, expect a lot of "
"issues with it."));
#endif
}
#include "moc_prefdrives.cpp"
|