Browse Source

Use system icons in the Web UI too

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
b61e4363f5
  1. 1
      Changelog
  2. 24
      src/misc.h
  3. 20
      src/webui/css/style.css
  4. 62
      src/webui/html/index.html
  5. 2
      src/webui/html/preferences_content.html
  6. 2
      src/webui/html/prop-trackers.html
  7. 9
      src/webui/httpconnection.cpp

1
Changelog

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.6.0
- FEATURE: Use system icons (Linux, Qt >= 4.6)
- FEATURE: Simplify program preferences
* Sun Dec 5 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.5.0

24
src/misc.h

@ -41,10 +41,7 @@ @@ -41,10 +41,7 @@
#include <QPoint>
#include <QFile>
#include <QDir>
#ifndef DISABLE_GUI
#include <QIcon>
#endif
#include <libtorrent/torrent_info.hpp>
#include <libtorrent/torrent_handle.hpp>
@ -85,17 +82,30 @@ public: @@ -85,17 +82,30 @@ public:
return libtorrent::sha1_hash(qPrintable(hash));
}
#ifndef DISABLE_GUI
static inline QIcon getIcon(const QString& id) {
static inline QIcon getIcon(const QString& iconId) {
#if (QT_VERSION >= QT_VERSION_CHECK(4,6,0))
const QIcon icon = QIcon::fromTheme(id, QIcon(":/Icons/oxygen/"+id+".png"));
const QIcon icon = QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png"));
#else
const QIcon icon(":/Icons/oxygen/"+id+".png");
const QIcon icon(":/Icons/oxygen/"+iconId+".png");
#endif
Q_ASSERT(!icon.isNull());
return icon;
}
static QString getIconPath(const QString &iconId) {
#if (QT_VERSION >= QT_VERSION_CHECK(4,6,0))
QString path = QDir::temp().absoluteFilePath(iconId+".png");
if(!QFile::exists(path)) {
const QIcon icon = QIcon::fromTheme(iconId);
if(icon.isNull()) return ":/Icons/oxygen/"+iconId+".png";
QPixmap px = icon.pixmap(32);
px.save(path);
}
return path;
#else
return ":/Icons/oxygen/"+iconId+".png";
#endif
}
static void chmod644(const QDir& folder);

20
src/webui/css/style.css

@ -164,7 +164,7 @@ a.propButton img { @@ -164,7 +164,7 @@ a.propButton img {
#contextmenu { border:1px solid #999; padding:0; background:#eee; list-style-type:none; display:none; width: 164px;}
#contextmenu .separator { border-top:1px solid #999; }
#contextmenu li { margin:0; padding:0;}
#contextmenu li a { display:block; padding:5px 10px 5px 35px; font-size:12px; text-decoration:none; font-family:tahoma,arial,sans-serif; color:#000; background-position:8px 2px; background-repeat:no-repeat; }
#contextmenu li a { display:block; padding:5px 10px 5px 5px; font-size:12px; text-decoration:none; font-family:tahoma,arial,sans-serif; color:#000; }
#contextmenu li a:hover { background-color:#ddd; }
#contextmenu li a.disabled { color:#ccc; font-style:italic; }
#contextmenu li a.disabled:hover { background-color:#eee; }
@ -195,18 +195,12 @@ a.propButton img { @@ -195,18 +195,12 @@ a.propButton img {
left: auto;
}
/* context menu items */
#contextmenu li a.pause { background-image:url(../images/skin/pause22.png); }
#contextmenu li a.start { background-image:url(../images/skin/play22.png); }
#contextmenu li a.recheck { background-image:url(../images/oxygen/gear.png); }
#contextmenu li a.delete { background-image:url(../images/skin/delete22.png); }
#contextmenu li a.deleteHD { background-image:url(../images/skin/delete_perm22.png); }
#contextmenu li a.uploadLimit { background-image:url(../images/skin/seeding.png); }
#contextmenu li a.downloadLimit { background-image:url(../images/skin/download.png); }
#contextmenu li a.prioTop { background-image:url(../images/oxygen/go-top22.png); }
#contextmenu li a.prioUp { background-image:url(../images/oxygen/go-up22.png); }
#contextmenu li a.prioDown { background-image:url(../images/oxygen/go-down22.png); }
#contextmenu li a.prioBottom { background-image:url(../images/oxygen/go-bottom22.png); }
#contextmenu li img {
width: 16px;
height: 16px;
margin-bottom: -4px;
-ms-interpolation-mode : bicubic;
}
/* Sliders */

62
src/webui/html/index.html

@ -43,28 +43,28 @@ @@ -43,28 +43,28 @@
<li>
<a class="returnFalse">_(Edit)</a>
<ul>
<li><a id="resumeAllLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/play_all.png" width="16" height="16" onload="fixPNG(this)"/>_(S&tart All)</a></li>
<li><a id="pauseAllLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/pause_all.png" width="16" height="16" onload="fixPNG(this)"/>_(P&ause All)</a></li>
<li class="divider"><a id="resumeLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/play.png" width="16" height="16" onload="fixPNG(this)"/>_(&Start)</a></li>
<li><a id="pauseLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/pause.png" width="16" height="16" onload="fixPNG(this)"/>_(&Pause)</a></li>
<li><a id="recheckLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/oxygen/gear.png" width="16" height="16" onload="fixPNG(this)"/>_(Force recheck)</a></li>
<li class="divider"><a id="deleteLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/delete.png" width="16" height="16" onload="fixPNG(this)"/>_(&Delete)</a></li>
<li><a id="deletePermLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/delete_perm.png" width="16" height="16" onload="fixPNG(this)"/>_(Delete from HD)</a></li>
<li><a id="resumeAllLink"><img class="MyMenuIcon" src="theme/media-playback-start" width="16" height="16" onload="fixPNG(this)"/>_(S&tart All)</a></li>
<li><a id="pauseAllLink"><img class="MyMenuIcon" src="theme/media-playback-pause" width="16" height="16" onload="fixPNG(this)"/>_(P&ause All)</a></li>
<li class="divider"><a id="resumeLink"><img class="MyMenuIcon" src="theme/media-playback-start" width="16" height="16" onload="fixPNG(this)"/>_(&Start)</a></li>
<li><a id="pauseLink"><img class="MyMenuIcon" src="theme/media-playback-pause" width="16" height="16" onload="fixPNG(this)"/>_(&Pause)</a></li>
<li><a id="recheckLink"><img class="MyMenuIcon" src="theme/document-edit-verify" width="16" height="16" onload="fixPNG(this)"/>_(Force recheck)</a></li>
<li class="divider"><a id="deleteLink"><img class="MyMenuIcon" src="theme/edit-delete" width="16" height="16" onload="fixPNG(this)"/>_(&Delete)</a></li>
<li><a id="deletePermLink"><img class="MyMenuIcon" src="theme/edit-delete" width="16" height="16" onload="fixPNG(this)"/>_(Delete from HD)</a></li>
</ul>
</li>
<li>
<a class="returnFalse">_(&Tools)</a>
<ul>
<li><a id="preferencesLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/settings.png" width="16" height="16" onload="fixPNG(this)"/>_(&Options...)</a></li>
<li><a id="preferencesLink"><img class="MyMenuIcon" src="theme/preferences-system" width="16" height="16" onload="fixPNG(this)"/>_(&Options...)</a></li>
</ul>
</li>
<li>
<a class="returnFalse">_(&Help)</a>
<ul>
<li><a id="bugLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/oxygen/bug.png" width="16" height="16" onload="fixPNG(this)"/>_(Report a &bug)</a></li>
<li><a id="siteLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/qbittorrent16.png" width="16" height="16" onload="fixPNG(this)"/>_(Visit &Website)</a></li>
<li><a id="docsLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/qb_question.png" width="16" height="16" onload="fixPNG(this)"/>_(&Documentation)</a></li>
<li><a id="aboutLink"><img class="MyMenuIcon" alt="_(Download local torrent)" src="images/skin/info.png" width="16" height="16" onload="fixPNG(this)"/>_(&About)</a></li>
<li><a id="bugLink"><img class="MyMenuIcon" src="theme/tools-report-bug" width="16" height="16" onload="fixPNG(this)"/>_(Report a &bug)</a></li>
<li><a id="siteLink"><img class="MyMenuIcon" src="images/skin/qbittorrent16.png" width="16" height="16" onload="fixPNG(this)"/>_(Visit &Website)</a></li>
<li><a id="docsLink"><img class="MyMenuIcon" src="theme/help-contents" width="16" height="16" onload="fixPNG(this)"/>_(&Documentation)</a></li>
<li><a id="aboutLink"><img class="MyMenuIcon" src="theme/help-about" width="16" height="16" onload="fixPNG(this)"/>_(&About)</a></li>
</ul>
</li>
</ul>
@ -72,38 +72,36 @@ @@ -72,38 +72,36 @@
<div id="mochaToolbar">
<a id="uploadButton"><img class="mochaToolButton" title="_(Download local torrent)" src="images/skin/open.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="downloadButton"><img class="mochaToolButton" title="_(Download from URL)" src="images/skin/url.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="deleteButton" class="divider"><img class="mochaToolButton" title="_(Delete)" src="images/skin/delete.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="deleteButton" class="divider"><img class="mochaToolButton" title="_(Delete)" src="theme/edit-delete" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="deletePermButton"><img class="mochaToolButton" title="_(Delete from HD)" src="images/skin/delete_perm.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="resumeButton" class="divider"><img class="mochaToolButton" title="_(Start)" src="images/skin/play.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="pauseButton"><img class="mochaToolButton" title="_(Pause)" src="images/skin/pause.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="resumeAllButton" class="divider"><img class="mochaToolButton" title="_(Start All)" src="images/skin/play_all.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="pauseAllButton"><img class="mochaToolButton" title="_(Pause All)" src="images/skin/pause_all.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="resumeButton" class="divider"><img class="mochaToolButton" title="_(Start)" src="theme/media-playback-start" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="pauseButton"><img class="mochaToolButton" title="_(Pause)" src="theme/media-playback-pause" width="32" height="32" onload="fixPNG(this)"/></a>
<span id="queueingButtons">
<a id="decreasePrioButton" class="divider"><img class="mochaToolButton" title="_(Decrease priority)" src="images/skin/decrease.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="increasePrioButton"><img class="mochaToolButton" title="_(Increase priority)" src="images/skin/increase.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="decreasePrioButton" class="divider"><img class="mochaToolButton" title="_(Decrease priority)" src="theme/go-down" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="increasePrioButton"><img class="mochaToolButton" title="_(Increase priority)" src="theme/go-up" width="32" height="32" onload="fixPNG(this)"/></a>
</span>
<a id="preferencesButton" class="divider"><img class="mochaToolButton" title="_(Preferences)" src="images/skin/settings.png" width="32" height="32" onload="fixPNG(this)"/></a>
<a id="preferencesButton" class="divider"><img class="mochaToolButton" title="_(Preferences)" src="theme/preferences-system" width="32" height="32" onload="fixPNG(this)"/></a>
</div>
</div>
<div id="pageWrapper"><span id="error_div"></span>
</div>
</div>
<ul id="contextmenu">
<li><a href="#Start" class="start">_(Start)</a></li>
<li><a href="#Pause" class="pause">_(Pause)</a></li>
<li class="separator"><a href="#Delete" class="delete">_(Delete)</a></li>
<li><a href="#DeleteHD" class="deleteHD">_(Delete from HD)</a></li>
<li class="separator"><a href="#priority" class="priority arrow-right">_(Priority)</a>
<li><a href="#Start"><img src="theme/media-playback-start"/> _(Start)</a></li>
<li><a href="#Pause"><img src="theme/media-playback-pause"/> _(Pause)</a></li>
<li class="separator"><a href="#Delete""><img src="theme/edit-delete"/> _(Delete)</a></li>
<li><a href="#DeleteHD"><img src="theme/edit-delete"/> _(Delete from HD)</a></li>
<li class="separator"><a href="#priority" class="arrow-right">_(Priority)</a>
<ul>
<li><a href="#prioTop" class="prioTop">_(Move to top)</a></li>
<li><a href="#prioUp" class="prioUp">_(Move up)</a></li>
<li><a href="#prioDown" class="prioDown">_(Move down)</a></li>
<li><a href="#prioBottom" class="prioBottom">_(Move to bottom)</a></li>
<li><a href="#prioTop""><img src="theme/go-top"/> _(Move to top)</a></li>
<li><a href="#prioUp"><img src="theme/go-up"/> _(Move up)</a></li>
<li><a href="#prioDown"><img src="theme/go-down"/> _(Move down)</a></li>
<li><a href="#prioBottom"><img src="theme/go-bottom"/> _(Move to bottom)</a></li>
</ul>
</li>
<li class="separator"><a href="#DownloadLimit" class="downloadLimit">_(Limit download rate)</a></li>
<li><a href="#UploadLimit" class="uploadLimit">_(Limit upload rate)</a></li>
<li class="separator"><a href="#ForceRecheck" class="recheck">_(Force recheck)</a></li>
<li class="separator"><a href="#DownloadLimit"><img src="images/skin/download.png"/> _(Limit download rate)</a></li>
<li><a href="#UploadLimit"><img src="images/skin/seeding.png"/> _(Limit upload rate)</a></li>
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify"/> _(Force recheck)</a></li>
</ul>
<div id="desktopFooterWrapper">
<div id="desktopFooter">

2
src/webui/html/preferences_content.html

@ -95,7 +95,7 @@ @@ -95,7 +95,7 @@
<table style="text-align: center" border="1" id="watched_folders_tab">
<thead><tr><th>_(Watched Folder)</th><th>_(Download here)</th></tr></thead>
<tbody></tbody>
<tfoot><tr><td style="padding-top:4px;"><input type="text" id="new_watch_folder_txt"/></td><td style="padding-top:4px;"><input type="checkbox" id="new_watch_folder_dl" style="padding-left:18px;"/><img src="images/oxygen/list-add.png" alt="Add" style="padding-left:2px;width:16px;cursor:pointer;margin-right:-18px;" onclick="javascript:addWatchFolder();"/></td></tr></tfoot>
<tfoot><tr><td style="padding-top:4px;"><input type="text" id="new_watch_folder_txt"/></td><td style="padding-top:4px;"><input type="checkbox" id="new_watch_folder_dl" style="padding-left:18px;"/><img src="theme/list-add" alt="Add" style="padding-left:2px;width:16px;cursor:pointer;margin-right:-18px;" onclick="javascript:addWatchFolder();"/></td></tr></tfoot>
</table>
</td>
</tr>

2
src/webui/html/prop-trackers.html

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
<table class="torrentTable" cellpadding="0" cellspacing="0" style="width: 100%">
<thead>
<tr>
<th>_(URL) <img src="images/oxygen/list-add.png" id="addTrackersPlus" style="width:16px;cursor:pointer;"/></th>
<th>_(URL) <img src="theme/list-add" id="addTrackersPlus" style="width:16px;cursor:pointer;"/></th>
<th>_(Status)</th>
<th>_(Peers)</th>
<th>_(Message)</th>

9
src/webui/httpconnection.cpp

@ -217,9 +217,11 @@ void HttpConnection::respond() { @@ -217,9 +217,11 @@ void HttpConnection::respond() {
} else {
if(list[1] == "preferences") {
respondPreferencesJson();
return;
} else {
if(list[1] == "transferInfo") {
respondGlobalTransferInfoJson();
return;
}
}
}
@ -233,6 +235,12 @@ void HttpConnection::respond() { @@ -233,6 +235,12 @@ void HttpConnection::respond() {
return;
}
}
// Icons from theme
qDebug() << "list[0]" << list[0];
if(list[0] == "theme" && list.size() == 2) {
url = misc::getIconPath(list[1]);
qDebug() << "There icon:" << url;
} else {
if (list[0] == "images") {
list[0] = "Icons";
} else {
@ -241,6 +249,7 @@ void HttpConnection::respond() { @@ -241,6 +249,7 @@ void HttpConnection::respond() {
list.prepend("webui");
}
url = ":/" + list.join("/");
}
QFile file(url);
if(!file.open(QIODevice::ReadOnly))
{

Loading…
Cancel
Save