Fix save path encoding on non-utf8 systems (e.g. Windows)

Fix progress bar style on Windows
This commit is contained in:
Christophe Dumez
2010-09-25 17:02:40 +00:00
parent a4c7640499
commit 1626d938d1
5 changed files with 27 additions and 5 deletions

View File

@@ -2,6 +2,7 @@
- I18N: Updated Arabic translation
- I18N: Fixes to German translation
- BUGFIX: Save path can now be edited in torrent addition dialog
- BUGFIX: Fix save path encoding on non-utf8 systems
- BUGFIX: OGV can now be previewed
- BUGFIX: Maximum download limit is now 10MB/s
- BUGFIX: Fix 'download in scan dir' persistence
@@ -11,6 +12,7 @@
- BUGFIX: Fix Web UI for spanish users
- BUGFIX: Fix locale switching from Web UI
- BUGFIX: Use AND operator for torrentdownloads.net searches
- COSMETIC: Fix progress bars style on Windows
* Tue Aug 24 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.4.0
- FEATURE: Added actions to "Move to top/bottom" of priority queue

View File

@@ -867,13 +867,13 @@ QTorrentHandle Bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
qDebug("addMagnetURI: Temp folder is enabled.");
qDebug("addTorrent::Temp folder is enabled.");
QString torrent_tmp_path = defaultTempPath.replace("\\", "/");
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
p.save_path = torrent_tmp_path.toUtf8().constData();
// Check if save path exists, creating it otherwise
if(!QDir(torrent_tmp_path).exists())
QDir().mkpath(torrent_tmp_path);
qDebug("addMagnetURI: using save_path: %s", qPrintable(torrent_tmp_path));
} else {
p.save_path = savePath.toLocal8Bit().constData();
p.save_path = savePath.toUtf8().constData();
// Check if save path exists, creating it otherwise
if(!QDir(savePath).exists())
QDir().mkpath(savePath);
@@ -1121,13 +1121,13 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
if(!torrent_tmp_path.endsWith("/")) torrent_tmp_path += "/";
torrent_tmp_path += root_folder;
}
p.save_path = torrent_tmp_path.toLocal8Bit().constData();
p.save_path = torrent_tmp_path.toUtf8().constData();
// Check if save path exists, creating it otherwise
if(!QDir(torrent_tmp_path).exists())
QDir().mkpath(torrent_tmp_path);
qDebug("addTorrent: using save_path: %s", qPrintable(torrent_tmp_path));
} else {
p.save_path = savePath.toLocal8Bit().constData();
p.save_path = savePath.toUtf8().constData();
// Check if save path exists, creating it otherwise
if(!QDir(savePath).exists())
QDir().mkpath(savePath);

View File

@@ -43,6 +43,10 @@
#include "misc.h"
#include "propertieswidget.h"
#ifdef Q_WS_WIN
#include <QPlastiqueStyle>
#endif
// Defines for properties list columns
enum PropColumn {NAME, PCSIZE, PROGRESS, PRIORITY};
@@ -79,7 +83,13 @@ public:
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = true;
#ifndef Q_WS_WIN
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
QPlastiqueStyle st;
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
break;
}
case PRIORITY: {

View File

@@ -227,7 +227,7 @@ int QTorrentHandle::num_incomplete() const {
QString QTorrentHandle::save_path() const {
Q_ASSERT(h.is_valid());
return misc::toQString(h.save_path().string()).replace("\\", "/");
return misc::toQStringU(h.save_path().string()).replace("\\", "/");
}
#if LIBTORRENT_VERSION_MINOR > 14

View File

@@ -41,6 +41,10 @@
#include <QDateTime>
#include "misc.h"
#ifdef Q_WS_WIN
#include <QPlastiqueStyle>
#endif
// Defines for download list list columns
enum TorrentState {STATE_DOWNLOADING, STATE_STALLED_DL, STATE_STALLED_UP, STATE_SEEDING, STATE_PAUSED_DL, STATE_PAUSED_UP, STATE_QUEUED_DL, STATE_QUEUED_UP, STATE_CHECKING_UP, STATE_CHECKING_DL, STATE_INVALID};
enum Column {TR_NAME, TR_PRIORITY, TR_SIZE, TR_PROGRESS, TR_STATUS, TR_SEEDS, TR_PEERS, TR_DLSPEED, TR_UPSPEED, TR_ETA, TR_RATIO, TR_LABEL, TR_ADD_DATE, TR_SEED_DATE, TR_DLLIMIT, TR_UPLIMIT, TR_HASH};
@@ -167,7 +171,13 @@ public:
newopt.minimum = 0;
newopt.state |= QStyle::State_Enabled;
newopt.textVisible = true;
#ifndef Q_WS_WIN
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
#else
// XXX: To avoid having the progress text on the right of the bar
QPlastiqueStyle st;
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
#endif
break;
}
default: