Changeset 175 for smplayer/vendor/current/src/infofile.cpp
- Timestamp:
- May 3, 2016, 2:14:41 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/vendor/current/src/infofile.cpp
r168 r175 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 "infofile.h" 20 #include "discname.h" 21 #include "images.h" 22 20 23 #include <QFileInfo> 21 24 #include <QCoreApplication> 22 #include "discname.h" 23 #include "images.h" 24 25 26 InfoFile::InfoFile() { 27 row = 0; 25 #include <QFile> 26 #include <QDebug> 27 28 InfoFile::InfoFile(QObject * parent) 29 : QObject(parent) 30 #ifndef INFO_SIMPLE_LAYOUT 31 , row(0) 32 #endif 33 { 28 34 } 29 35 … … 55 61 } 56 62 icon = icon.replace(".png", ""); // FIXME 57 icon = "<img src=\"" + Images::file(icon) + "\"> ";63 //icon = "<img src=\"" + Images::file(icon) + "\"> "; 58 64 59 65 #ifdef BLURAY_SUPPORT … … 64 70 { 65 71 DiscData disc_data = DiscName::split(md.filename); 66 s += title( icon + disc_data.protocol + "://" + QString::number(disc_data.title));72 s += title(disc_data.protocol + "://" + QString::number(disc_data.title), icon); 67 73 } else { 68 s += title( icon + md.displayName());74 s += title(md.displayName(), icon); 69 75 } 70 76 … … 128 134 if (md.audios.numItems() > 0) { 129 135 s += openPar( tr("Audio Streams") ); 130 row++; 131 s += openItem(); 132 s += "<td>" + tr("#", "Info for translators: this is a abbreviation for number") + "</td><td>" + 133 tr("Language") + "</td><td>" + tr("Name") +"</td><td>" + 134 tr("ID", "Info for translators: this is a identification code") + "</td>"; 135 s += closeItem(); 136 s += addTrackColumns( QStringList() << "#" << tr("Language") << tr("Name") << "ID" ); 137 136 138 for (int n = 0; n < md.audios.numItems(); n++) { 139 #ifndef INFO_SIMPLE_LAYOUT 137 140 row++; 141 #endif 138 142 s += openItem(); 139 143 QString lang = md.audios.itemAt(n).lang(); 140 if (lang.isEmpty()) lang = "<i><"+tr(" empty")+"></i>";144 if (lang.isEmpty()) lang = "<i><"+tr("undefined")+"></i>"; 141 145 QString name = md.audios.itemAt(n).name(); 142 if (name.isEmpty()) name = "<i><"+tr("empty")+"></i>"; 143 s += QString("<td>%1</td><td>%2</td><td>%3</td><td>%4</td>") 144 .arg(n).arg(lang).arg(name) 145 .arg(md.audios.itemAt(n).ID()); 146 if (name.isEmpty()) name = "<i><"+tr("undefined")+"></i>"; 147 s += addTrack(n, lang, name, md.audios.itemAt(n).ID()); 146 148 s += closeItem(); 147 149 } … … 152 154 if (md.subs.numItems() > 0) { 153 155 s += openPar( tr("Subtitles") ); 154 row++; 155 s += openItem(); 156 s += "<td>" + tr("#", "Info for translators: this is a abbreviation for number") + "</td><td>" + 157 tr("Type") + "</td><td>" + 158 tr("Language") + "</td><td>" + tr("Name") +"</td><td>" + 159 tr("ID", "Info for translators: this is a identification code") + "</td>"; 160 s += closeItem(); 156 s += addTrackColumns( QStringList() << "#" << tr("Type") << tr("Language") << tr("Name") << "ID" ); 161 157 for (int n = 0; n < md.subs.numItems(); n++) { 158 #ifndef INFO_SIMPLE_LAYOUT 162 159 row++; 160 #endif 163 161 s += openItem(); 164 162 QString t; … … 169 167 } 170 168 QString lang = md.subs.itemAt(n).lang(); 171 if (lang.isEmpty()) lang = "<i><"+tr(" empty")+"></i>";169 if (lang.isEmpty()) lang = "<i><"+tr("undefined")+"></i>"; 172 170 QString name = md.subs.itemAt(n).name(); 173 if (name.isEmpty()) name = "<i><"+tr("empty")+"></i>"; 174 /* 175 s += QString("<td>%1</td><td>%2</td><td>%3</td><td>%4</td><td>%5</td>") 176 .arg(n).arg(t).arg(lang).arg(name) 177 .arg(md.subs.itemAt(n).ID()); 178 */ 179 s += "<td>" + QString::number(n) + "</td><td>" + t + 180 "</td><td>" + lang + "</td><td>" + name + 181 "</td><td>" + QString::number(md.subs.itemAt(n).ID()) + "</td>"; 171 if (name.isEmpty()) name = "<i><"+tr("undefined")+"></i>"; 172 s += addTrack(n, lang, name, md.subs.itemAt(n).ID(), t); 182 173 s += closeItem(); 183 174 } … … 185 176 } 186 177 187 return "<html><body bgcolor=\"white\"><font color=\"black\">"+ s + "</font></body></html>"; 188 } 189 190 QString InfoFile::title(QString text) { 191 return "<h1>" + text + "</h1>"; 178 QString page = "<html><head><style type=\"text/css\">" + style() + "</style></head><body>"+ s + "</body></html>"; 179 //qDebug() << "InfoFile::getInfo:" << page; 180 return page; 181 } 182 183 184 #ifdef INFO_SIMPLE_LAYOUT 185 QString InfoFile::title(QString text, QString /* icon */) { 186 return QString("<h1>%1</h1>").arg(text); 187 } 188 189 QString InfoFile::openPar(QString text) { 190 return "<h2>" + text + "</h2><ul>"; 191 } 192 193 QString InfoFile::closePar() { 194 return "</ul>"; 195 } 196 197 QString InfoFile::openItem() { 198 return "<li>"; 199 } 200 201 QString InfoFile::closeItem() { 202 return "</li>"; 203 } 204 205 QString InfoFile::addItem( QString tag, QString value ) { 206 return openItem() + QString("<b>%1</b>: %2").arg(tag).arg(value) + closeItem(); 207 } 208 209 QString InfoFile::addTrackColumns(QStringList /* l */) { 210 return ""; 211 } 212 213 QString InfoFile::addTrack(int n, QString lang, QString name, int ID, QString type) { 214 QString s = "<b>" + tr("Track %1").arg(n) + "</b>"; 215 #if 1 216 s += "<ul>"; 217 s += "<li>" + tr("Language: %1").arg(lang) + "</li>"; 218 s += "<li>" + tr("Name: %1").arg(name) + "</li>"; 219 s += "<li>" + tr("ID: %1").arg(ID) + "</li>"; 220 if (!type.isEmpty()) { 221 s += "<li>" + tr("Type: %1").arg(type) + "</li>"; 222 } 223 s += "</ul>"; 224 #else 225 s += "<br> • " + tr("Language: %1").arg(lang); 226 s += "<br> • " + tr("Name: %1").arg(name); 227 s += "<br> • " + tr("ID: %1").arg(ID); 228 if (!type.isEmpty()) { 229 s += "<br> • " + tr("Type: %1").arg(type); 230 } 231 #endif 232 return s; 233 } 234 235 QString InfoFile::defaultStyle() { 236 return 237 "ul { margin: 0px; }" 238 //"body { background-color: gray; }" 239 "h2 { background-color: whitesmoke; color: navy;}" 240 ; 241 } 242 243 #else 244 245 QString InfoFile::title(QString text, QString icon) { 246 return QString("<h1><img src=\"%1\">%2</h1>").arg(Images::file(icon)).arg(text); 192 247 } 193 248 … … 211 266 QString InfoFile::closeItem() { 212 267 return "</tr>"; 268 } 269 270 QString InfoFile::addTrackColumns(QStringList l) { 271 row = 0; 272 QString s = openItem(); 273 foreach(QString i, l) { s += "<td>" + i + "</td>"; } 274 s += closeItem(); 275 return s; 213 276 } 214 277 … … 221 284 } 222 285 223 224 inline QString InfoFile::tr( const char * sourceText, const char * comment, int n ) { 225 #if QT_VERSION >= 0x050000 226 return QCoreApplication::translate("InfoFile", sourceText, comment, n ); 227 #else 228 return QCoreApplication::translate("InfoFile", sourceText, comment, QCoreApplication::CodecForTr, n ); 286 QString InfoFile::addTrack(int n, QString lang, QString name, int ID, QString type) { 287 QString s = "<td>" + QString::number(n) + "</td>"; 288 if (!type.isEmpty()) s += "<td>" + type + "</td>"; 289 s += QString("<td>%1</td><td>%2</td><td>%3</td>").arg(lang).arg(name).arg(ID); 290 return s; 291 } 292 293 QString InfoFile::defaultStyle() { 294 return ""; 295 } 229 296 #endif 230 } 231 297 298 QString InfoFile::style() { 299 QString s = defaultStyle(); 300 301 QString stylesheet_file = Images::file("infofile.css"); 302 qDebug() << "InfoFile::style: stylesheet_file:" << stylesheet_file; 303 304 QFile file(stylesheet_file); 305 if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) { 306 s = file.readAll(); 307 } 308 309 return s; 310 } 311 312 #include "moc_infofile.cpp"
Note:
See TracChangeset
for help on using the changeset viewer.