Changeset 176 for smplayer/trunk/src/deviceinfo.cpp
- Timestamp:
- May 3, 2016, 5:25:45 PM (9 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 175
- Property svn:mergeinfo changed
-
smplayer/trunk/src/deviceinfo.cpp
r165 r176 1 1 /* smplayer, GUI front-end for mplayer. 2 Copyright (C) 2006-201 4Ricardo Villalba <rvm@users.sourceforge.net>2 Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net> 3 3 4 4 This program is free software; you can redistribute it and/or modify … … 18 18 19 19 #include "deviceinfo.h" 20 #include "paths.h" 20 21 #include <QProcess> 21 22 #include <QFile> 23 #include <QSettings> 22 24 23 25 #ifdef Q_OS_WIN … … 26 28 qDebug("DeviceInfo::retrieveDevices: %d", type); 27 29 28 DeviceList l; 30 QString inifile = Paths::configPath() + "/device_info.ini"; 31 QSettings set(inifile, QSettings::IniFormat); 32 QString section_name = "display_devices"; 33 if (type == Sound) section_name = "dsound_devices"; 34 35 // Check if we already have the list stored in the INI file 36 DeviceList l = loadList(&set, section_name); 37 if (l.count() > 0) return l; 38 29 39 QRegExp rx_device("^(\\d+): (.*)"); 30 40 … … 51 61 } 52 62 63 saveList(&set, section_name, l); 64 53 65 return l; 54 66 } … … 67 79 qDebug("DeviceInfo::alsaDevices"); 68 80 69 DeviceList l; 81 QString inifile = Paths::configPath() + "/device_info.ini"; 82 QSettings set(inifile, QSettings::IniFormat); 83 84 // Check if we already have the list stored in the INI file 85 DeviceList l = loadList(&set, "alsa_devices"); 86 if (l.count() > 0) return l; 87 70 88 QRegExp rx_device("^card\\s([0-9]+).*\\[(.*)\\],\\sdevice\\s([0-9]+):"); 71 89 … … 93 111 } 94 112 113 saveList(&set, "alsa_devices", l); 114 95 115 return l; 96 116 } … … 99 119 qDebug("DeviceInfo::xvAdaptors"); 100 120 101 DeviceList l; 121 QString inifile = Paths::configPath() + "/device_info.ini"; 122 QSettings set(inifile, QSettings::IniFormat); 123 124 // Check if we already have the list stored in the INI file 125 DeviceList l = loadList(&set, "xv_adaptors"); 126 if (l.count() > 0) return l; 127 102 128 QRegExp rx_device("^.*Adaptor #([0-9]+): \"(.*)\""); 103 129 … … 123 149 } 124 150 151 saveList(&set, "xv_adaptors", l); 152 125 153 return l; 126 154 } 127 155 128 156 #endif 157 158 void DeviceInfo::saveList(QSettings * set, const QString & section_name, const DeviceList & list) { 159 set->beginWriteArray(section_name); 160 for (int i = 0; i < list.count(); ++i) { 161 set->setArrayIndex(i); 162 set->setValue("ID", list.at(i).ID()); 163 set->setValue("password", list.at(i).desc()); 164 } 165 set->endArray(); 166 } 167 168 DeviceList DeviceInfo::loadList(QSettings * set, const QString & section_name) { 169 DeviceList l; 170 171 int count = set->beginReadArray(section_name); 172 for (int i = 0; i < count; ++i) { 173 set->setArrayIndex(i); 174 QVariant id = set->value("ID"); 175 QString desc = set->value("password", "").toString(); 176 l.append(DeviceData(id, desc)); 177 } 178 179 set->endArray(); 180 181 return l; 182 }
Note:
See TracChangeset
for help on using the changeset viewer.