- Improved unicode support a bit

This commit is contained in:
Christophe Dumez 2007-08-20 07:03:41 +00:00
parent a28160bcaa
commit 8ba1cb329d
10 changed files with 48 additions and 46 deletions

View file

@ -48,6 +48,7 @@
- BUGFIX: Update torrent progress when its content changed (filtered files) - BUGFIX: Update torrent progress when its content changed (filtered files)
- BUGFIX: Improved the way menu icons are installed to avoid problems on some systems - BUGFIX: Improved the way menu icons are installed to avoid problems on some systems
- BUGFIX: Improved incremental download - BUGFIX: Improved incremental download
- BUGFIX: Improved unicode support
- COSMETIC: Redesigned torrent properties a little - COSMETIC: Redesigned torrent properties a little
- COSMETIC: Redesigned options a little - COSMETIC: Redesigned options a little
- COSMETIC: Display more logs messages concerning features - COSMETIC: Display more logs messages concerning features

1
TODO
View file

@ -88,5 +88,6 @@ beta4->beta5 changelog:
- BUGFIX: Improved incremental download - BUGFIX: Improved incremental download
- BUGFIX: Fixed preview from seeding list - BUGFIX: Fixed preview from seeding list
- BUGFIX: Fixed Alt+3 & Ctrl+F keyboard shortcuts for third tab - BUGFIX: Fixed Alt+3 & Ctrl+F keyboard shortcuts for third tab
- BUGFIX: Improved unicode support
- I18N: Updated Italian, Polish, Portuguese, Brazilian and Spanish translations - I18N: Updated Italian, Polish, Portuguese, Brazilian and Spanish translations
- COSMETIC: Changed the way progress bars are rendered - COSMETIC: Changed the way progress bars are rendered

View file

@ -1248,7 +1248,7 @@ void GUI::configureSession(bool deleteOptions) {
BTSession->setListeningPortsRange(options->getPorts()); BTSession->setListeningPortsRange(options->getPorts());
new_listenPort = BTSession->getListenPort(); new_listenPort = BTSession->getListenPort();
if(new_listenPort != old_listenPort) { if(new_listenPort != old_listenPort) {
setInfoBar(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( QString(misc::toString(new_listenPort).c_str()))); setInfoBar(tr("qBittorrent is bind to port: %1", "e.g: qBittorrent is bind to port: 1666").arg( misc::toQString(new_listenPort)));
} }
// Apply max connec limit (-1 if disabled) // Apply max connec limit (-1 if disabled)
BTSession->setMaxConnections(options->getMaxConnec()); BTSession->setMaxConnections(options->getMaxConnec());

View file

@ -54,10 +54,10 @@ createtorrent::createtorrent(QWidget *parent): QDialog(parent){
} }
void createtorrent::on_browse_destination_clicked(){ void createtorrent::on_browse_destination_clicked(){
QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), QDir::homePath(), tr("Torrent Files")+" (*.torrent)"); QString destination = QFileDialog::getSaveFileName(this, tr("Select destination torrent file"), QDir::homePath(), tr("Torrent Files")+QString::fromUtf8(" (*.torrent)"));
if(!destination.isEmpty()){ if(!destination.isEmpty()){
if(!destination.endsWith(".torrent")) if(!destination.endsWith(QString::fromUtf8(".torrent")))
destination += ".torrent"; destination += QString::fromUtf8(".torrent");
txt_destination->setText(destination); txt_destination->setText(destination);
} }
} }
@ -204,7 +204,7 @@ void createtorrent::on_createButton_clicked(){
} }
catch (std::exception& e){ catch (std::exception& e){
std::cerr << e.what() << "\n"; std::cerr << e.what() << "\n";
QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(QString(e.what()))); QMessageBox::information(0, tr("Torrent creation"), tr("Torrent creation was unsuccessful, reason: %1").arg(QString::fromUtf8(e.what())));
hide(); hide();
return; return;
} }

View file

@ -46,26 +46,26 @@
void useStyle(QApplication *app, QString style){ void useStyle(QApplication *app, QString style){
std::cout << "* Style: Using " << style.toStdString() << " style\n"; std::cout << "* Style: Using " << style.toStdString() << " style\n";
if(style == "Cleanlooks"){ if(style == QString::fromUtf8("Cleanlooks")){
app->setStyle(new QCleanlooksStyle()); app->setStyle(new QCleanlooksStyle());
return; return;
} }
if(style == "Motif"){ if(style == QString::fromUtf8("Motif")){
app->setStyle(new QMotifStyle()); app->setStyle(new QMotifStyle());
return; return;
} }
if(style == "CDE"){ if(style == QString::fromUtf8("CDE")){
app->setStyle(new QCDEStyle()); app->setStyle(new QCDEStyle());
return; return;
} }
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
if(style == "MacOS"){ if(style == QString::fromUtf8("MacOS")){
app->setStyle(new QMacStyle()); app->setStyle(new QMacStyle());
return; return;
} }
#endif #endif
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
if(style == "WinXP"){ if(style == QString::fromUtf8("WinXP")){
app->setStyle(new QWindowsXPStyle()); app->setStyle(new QWindowsXPStyle());
return; return;
} }
@ -78,11 +78,11 @@ int main(int argc, char *argv[]){
QFile file; QFile file;
QString locale; QString locale;
if(argc > 1){ if(argc > 1){
if(QString(argv[1])=="--version"){ if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--version")){
std::cout << "qBittorrent " << VERSION << '\n'; std::cout << "qBittorrent " << VERSION << '\n';
return 0; return 0;
} }
if(QString(argv[1])=="--help"){ if(QString::fromUtf8(argv[1]) == QString::fromUtf8("--help")){
std::cout << "Usage: \n"; std::cout << "Usage: \n";
std::cout << '\t' << argv[0] << " --version : displays program version\n"; std::cout << '\t' << argv[0] << " --version : displays program version\n";
std::cout << '\t' << argv[0] << " --help : displays this help message\n"; std::cout << '\t' << argv[0] << " --help : displays this help message\n";
@ -103,8 +103,8 @@ int main(int argc, char *argv[]){
if(argc > 1){ if(argc > 1){
QStringList params; QStringList params;
for(int i=1;i<argc;++i){ for(int i=1;i<argc;++i){
params << QString(argv[i]); params << QString::fromUtf8(argv[i]);
std::cout << QString(argv[i]).toStdString() << '\n'; std::cout << argv[i] << '\n';
} }
QByteArray block = params.join("\n").toUtf8(); QByteArray block = params.join("\n").toUtf8();
std::cout << "writting: " << block.data() << '\n'; std::cout << "writting: " << block.data() << '\n';
@ -122,36 +122,36 @@ int main(int argc, char *argv[]){
return 0; return 0;
} }
QApplication app(argc, argv); QApplication app(argc, argv);
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QString style; QString style;
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
style = settings.value("Options/Style", "WinXP").toString(); style = settings.value(QString::fromUtf8("Options/Style"), QString::fromUtf8("WinXP")).toString();
#endif #endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
style = settings.value("Options/Style", "MacOS").toString(); style = settings.value(QString::fromUtf8("Options/Style"), QString::fromUtf8("MacOS")).toString();
#endif #endif
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
#ifndef Q_WS_MAC #ifndef Q_WS_MAC
style = settings.value("Options/Style", "Plastique").toString(); style = settings.value(QString::fromUtf8("Options/Style"), QString::fromUtf8("Plastique")).toString();
#endif #endif
#endif #endif
useStyle(&app, style); useStyle(&app, style);
QSplashScreen *splash = new QSplashScreen(QPixmap(":/Icons/splash.png")); QSplashScreen *splash = new QSplashScreen(QPixmap(QString::fromUtf8(":/Icons/splash.png")));
splash->show(); splash->show();
// Open options file to read locale // Open options file to read locale
locale = settings.value("Options/Language/Locale", QString()).toString(); locale = settings.value(QString::fromUtf8("Options/Language/Locale"), QString()).toString();
QTranslator translator; QTranslator translator;
if(locale.isEmpty()){ if(locale.isEmpty()){
locale = QLocale::system().name(); locale = QLocale::system().name();
settings.setValue("Options/Language/Locale", locale); settings.setValue(QString::fromUtf8("Options/Language/Locale"), locale);
} }
if(translator.load(QString(":/lang/qbittorrent_") + locale)){ if(translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
qDebug("%s locale recognized, using translation.", (const char*)locale.toUtf8()); qDebug("%s locale recognized, using translation.", (const char*)locale.toUtf8());
}else{ }else{
qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toUtf8()); qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toUtf8());
} }
app.installTranslator(&translator); app.installTranslator(&translator);
app.setApplicationName("qBittorrent"); app.setApplicationName(QString::fromUtf8("qBittorrent"));
app.setQuitOnLastWindowClosed(false); app.setQuitOnLastWindowClosed(false);
// Read torrents given on command line // Read torrents given on command line
QStringList torrentCmdLine = app.arguments(); QStringList torrentCmdLine = app.arguments();

View file

@ -1029,8 +1029,8 @@ void options_imp::processFilterFile(QString filePath){
address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt()); address_v4 last((IP.at(0).toInt() << 24) + (IP.at(1).toInt() << 16) + (IP.at(2).toInt() << 8) + IP.at(3).toInt());
// add it to list // add it to list
QStringList item(QString(start.to_string().c_str())); QStringList item(QString::fromUtf8(start.to_string().c_str()));
item.append(QString(last.to_string().c_str())); item.append(QString::fromUtf8(last.to_string().c_str()));
if(!i){ if(!i){
item.append(QString::fromUtf8("Manual")); item.append(QString::fromUtf8("Manual"));
}else{ }else{
@ -1048,8 +1048,8 @@ void options_imp::processFilterFile(QString filePath){
address_v6 last = address_v6::from_string(strEndIP.remove(':', 0).toUtf8().data()); address_v6 last = address_v6::from_string(strEndIP.remove(':', 0).toUtf8().data());
// add it to list // add it to list
QStringList item(QString(start.to_string().c_str())); QStringList item(QString::fromUtf8(start.to_string().c_str()));
item.append(QString(last.to_string().c_str())); item.append(QString::fromUtf8(last.to_string().c_str()));
if(!i){ if(!i){
item.append(QString::fromUtf8("Manual")); item.append(QString::fromUtf8("Manual"));
}else{ }else{

View file

@ -303,7 +303,7 @@ void properties::loadTrackers(){
trackersURLS->clear(); trackersURLS->clear();
unsigned int nbTrackers = trackers.size(); unsigned int nbTrackers = trackers.size();
for(unsigned int i=0; i<nbTrackers; ++i){ for(unsigned int i=0; i<nbTrackers; ++i){
trackersURLS->addItem(QString(trackers[i].url.c_str())); trackersURLS->addItem(misc::toQString(trackers[i].url));
} }
QString tracker = h.current_tracker().trimmed(); QString tracker = h.current_tracker().trimmed();
if(!tracker.isEmpty()){ if(!tracker.isEmpty()){
@ -449,7 +449,7 @@ void properties::lowerSelectedTracker(){
foreach(item, selectedItems){ foreach(item, selectedItems){
QString url = item->text(); QString url = item->text();
for(i=0; i<nbTrackers; ++i){ for(i=0; i<nbTrackers; ++i){
if(QString(trackers.at(i).url.c_str()) == url){ if(misc::toQString(trackers.at(i).url) == url){
qDebug("Asked to lower %s", trackers.at(i).url.c_str()); qDebug("Asked to lower %s", trackers.at(i).url.c_str());
qDebug("its tier was %d and will become %d", trackers[i].tier, trackers[i].tier+1); qDebug("its tier was %d and will become %d", trackers[i].tier, trackers[i].tier+1);
if(i < nbTrackers-1){ if(i < nbTrackers-1){

View file

@ -274,7 +274,7 @@ class RssStream : public QObject{
// download the icon from the adress // download the icon from the adress
QString getIconUrl() { QString getIconUrl() {
QUrl siteUrl(url); QUrl siteUrl(url);
return QString("http://"+siteUrl.host()+"/favicon.ico"); return QString::fromUtf8("http://")+siteUrl.host()+QString::fromUtf8("/favicon.ico");
} }
private: private:
@ -282,12 +282,12 @@ class RssStream : public QObject{
short readDoc(const QDomDocument& doc) { short readDoc(const QDomDocument& doc) {
// is it a rss file ? // is it a rss file ?
QDomElement root = doc.documentElement(); QDomElement root = doc.documentElement();
if(root.tagName() == "html"){ if(root.tagName() == QString::fromUtf8("html")){
qDebug("the file is empty, maybe the url is invalid or the server is too busy"); qDebug("the file is empty, maybe the url is invalid or the server is too busy");
return -1; return -1;
} }
else if(root.tagName() != "rss"){ else if(root.tagName() != QString::fromUtf8("rss")){
qDebug("the file is not a rss stream, <rss> omitted: %s", (const char*)root.tagName().toUtf8()); qDebug("the file is not a rss stream, <rss> omitted: %s", root.tagName().toUtf8().data());
return -1; return -1;
} }
QDomNode rss = root.firstChild(); QDomNode rss = root.firstChild();

View file

@ -134,10 +134,10 @@
RssStream* stream; RssStream* stream;
foreach(stream, feeds){ foreach(stream, feeds){
QTreeWidgetItem* item = new QTreeWidgetItem(listStreams); QTreeWidgetItem* item = new QTreeWidgetItem(listStreams);
item->setData(0, Qt::DisplayRole, stream->getAliasOrUrl()+ QString(" (0)")); item->setData(0, Qt::DisplayRole, stream->getAliasOrUrl()+ QString::fromUtf8(" (0)"));
item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); item->setData(0,Qt::DecorationRole, QVariant(QIcon(QString::fromUtf8(":/Icons/loading.png"))));
item->setData(1, Qt::DisplayRole, stream->getUrl()); item->setData(1, Qt::DisplayRole, stream->getUrl());
item->setToolTip(0, QString("<b>")+tr("Description:")+QString("</b> ")+stream->getDescription()+QString("<br/><b>")+tr("url:")+QString("</b> ")+stream->getUrl()+QString("<br/><b>")+tr("Last refresh:")+QString("</b> ")+stream->getLastRefreshElapsedString()); item->setToolTip(0, QString::fromUtf8("<b>")+tr("Description:")+QString::fromUtf8("</b> ")+stream->getDescription()+QString::fromUtf8("<br/><b>")+tr("url:")+QString::fromUtf8("</b> ")+stream->getUrl()+QString::fromUtf8("<br/><b>")+tr("Last refresh:")+QString::fromUtf8("</b> ")+stream->getLastRefreshElapsedString());
} }
} }
@ -157,10 +157,10 @@
return; return;
} }
QTreeWidgetItem* item = new QTreeWidgetItem(listStreams); QTreeWidgetItem* item = new QTreeWidgetItem(listStreams);
item->setText(0, stream->getAliasOrUrl() + QString(" (0)")); item->setText(0, stream->getAliasOrUrl() + QString::fromUtf8(" (0)"));
item->setText(1, stream->getUrl()); item->setText(1, stream->getUrl());
item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png"))); item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
item->setToolTip(0, QString("<b>")+tr("Description:")+QString("</b> ")+stream->getDescription()+QString("<br/><b>")+tr("url:")+QString("</b> ")+stream->getUrl()+QString("<br/><b>")+tr("Last refresh:")+QString("</b> ")+stream->getLastRefreshElapsedString()); item->setToolTip(0, QString::fromUtf8("<b>")+tr("Description:")+QString::fromUtf8("</b> ")+stream->getDescription()+QString::fromUtf8("<br/><b>")+tr("url:")+QString::fromUtf8("</b> ")+stream->getUrl()+QString::fromUtf8("<br/><b>")+tr("Last refresh:")+QString::fromUtf8("</b> ")+stream->getLastRefreshElapsedString());
if(listStreams->topLevelItemCount() == 1) if(listStreams->topLevelItemCount() == 1)
selectFirstFeed(); selectFirstFeed();
rssmanager->refresh(newUrl); rssmanager->refresh(newUrl);
@ -174,7 +174,7 @@
for(unsigned int i=0; i<nbFeeds; ++i){ for(unsigned int i=0; i<nbFeeds; ++i){
QTreeWidgetItem* item = listStreams->topLevelItem(i); QTreeWidgetItem* item = listStreams->topLevelItem(i);
RssStream* stream = rssmanager->getFeed(item->data(1, Qt::DisplayRole).toString()); RssStream* stream = rssmanager->getFeed(item->data(1, Qt::DisplayRole).toString());
item->setToolTip(0, QString("<b>")+tr("Description:")+QString("</b> ")+stream->getDescription()+QString("<br/><b>")+tr("url:")+QString("</b> ")+stream->getUrl()+QString("<br/><b>")+tr("Last refresh:")+QString("</b> ")+stream->getLastRefreshElapsedString()); item->setToolTip(0, QString::fromUtf8("<b>")+tr("Description:")+QString::fromUtf8("</b> ")+stream->getDescription()+QString::fromUtf8("<br/><b>")+tr("url:")+QString::fromUtf8("</b> ")+stream->getUrl()+QString::fromUtf8("<br/><b>")+tr("Last refresh:")+QString::fromUtf8("</b> ")+stream->getLastRefreshElapsedString());
} }
} }
@ -232,15 +232,15 @@
void RSSImp::updateFeedNbNews(QString url){ void RSSImp::updateFeedNbNews(QString url){
QTreeWidgetItem *item = getTreeItemFromUrl(url); QTreeWidgetItem *item = getTreeItemFromUrl(url);
RssStream *stream = rssmanager->getFeed(url); RssStream *stream = rssmanager->getFeed(url);
item->setText(0, stream->getAliasOrUrl() + QString(" (") + QString::number(stream->getNbUnRead(), 10)+ String(")")); item->setText(0, stream->getAliasOrUrl() + QString::fromUtf8(" (") + QString::number(stream->getNbUnRead(), 10)+ String(")"));
} }
void RSSImp::updateFeedInfos(QString url, QString aliasOrUrl, unsigned int nbUnread){ void RSSImp::updateFeedInfos(QString url, QString aliasOrUrl, unsigned int nbUnread){
QTreeWidgetItem *item = getTreeItemFromUrl(url); QTreeWidgetItem *item = getTreeItemFromUrl(url);
RssStream *stream = rssmanager->getFeed(url); RssStream *stream = rssmanager->getFeed(url);
item->setText(0, aliasOrUrl + QString(" (") + QString::number(nbUnread, 10)+ String(")")); item->setText(0, aliasOrUrl + QString::fromUtf8(" (") + QString::number(nbUnread, 10)+ String(")"));
item->setData(0,Qt::DecorationRole, QVariant(QIcon(stream->getIconPath()))); item->setData(0,Qt::DecorationRole, QVariant(QIcon(stream->getIconPath())));
item->setToolTip(0, QString("<b>")+tr("Description:")+QString("</b> ")+stream->getDescription()+QString("<br/><b>")+tr("url:")+QString("</b> ")+stream->getUrl()+QString("<br/><b>")+tr("Last refresh:")+QString("</b> ")+stream->getLastRefreshElapsedString()); item->setToolTip(0, QString::fromUtf8("<b>")+tr("Description:")+QString::fromUtf8("</b> ")+stream->getDescription()+QString::fromUtf8("<br/><b>")+tr("url:")+QString::fromUtf8("</b> ")+stream->getUrl()+QString::fromUtf8("<br/><b>")+tr("Last refresh:")+QString::fromUtf8("</b> ")+stream->getLastRefreshElapsedString());
// If the feed is selected, update the displayed news // If the feed is selected, update the displayed news
if(selectedFeedUrl == url){ if(selectedFeedUrl == url){
refreshNewsList(getTreeItemFromUrl(url), 0); refreshNewsList(getTreeItemFromUrl(url), 0);

View file

@ -204,7 +204,7 @@ void SearchEngine::saveColWidthSearchList() const{
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
QStringList width_list; QStringList width_list;
for(int i=0; i<SearchListModel->columnCount(); ++i){ for(int i=0; i<SearchListModel->columnCount(); ++i){
width_list << QString(misc::toString(resultsBrowser->columnWidth(i)).c_str()); width_list << misc::toQString(resultsBrowser->columnWidth(i));
} }
settings.setValue("SearchListColsWidth", width_list.join(" ")); settings.setValue("SearchListColsWidth", width_list.join(" "));
qDebug("Search list columns width saved"); qDebug("Search list columns width saved");
@ -359,7 +359,7 @@ void SearchEngine::readSearchOutput(){
foreach(line, lines_list){ foreach(line, lines_list){
appendSearchResult(QString(line)); appendSearchResult(QString(line));
} }
results_lbl->setText(tr("Results")+" <i>("+QString(misc::toString(nb_search_results).c_str())+")</i>:"); results_lbl->setText(tr("Results")+QString::fromUtf8(" <i>(")+misc::toQString(nb_search_results)+QString::fromUtf8(")</i>:"));
} }
// Returns version of nova.py search engine // Returns version of nova.py search engine
@ -409,7 +409,7 @@ QByteArray SearchEngine::getNovaChangelog(QString novaPath, float my_version) co
QString end_version = "# Version: "; QString end_version = "# Version: ";
char tmp[5]; char tmp[5];
snprintf(tmp, 5, "%.2f", my_version); snprintf(tmp, 5, "%.2f", my_version);
end_version+=QString(tmp); end_version+=QString::fromUtf8(tmp);
if(line.startsWith((const char*)end_version.toUtf8())) break; if(line.startsWith((const char*)end_version.toUtf8())) break;
if(in_changelog){ if(in_changelog){
line.remove(0,1); line.remove(0,1);
@ -516,7 +516,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
} }
} }
} }
results_lbl->setText(tr("Results", "i.e: Search results")+" <i>("+QString(misc::toString(nb_search_results).c_str())+")</i>:"); results_lbl->setText(tr("Results", "i.e: Search results")+QString::fromUtf8(" <i>(")+misc::toQString(nb_search_results)+QString::fromUtf8(")</i>:"));
search_button->setEnabled(true); search_button->setEnabled(true);
stop_search_button->setEnabled(false); stop_search_button->setEnabled(false);
} }