Browse Source

- Improved unicode support a bit

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
8ba1cb329d
  1. 1
      Changelog
  2. 1
      TODO
  3. 2
      src/GUI.cpp
  4. 8
      src/createtorrent_imp.cpp
  5. 36
      src/main.cpp
  6. 8
      src/options_imp.cpp
  7. 4
      src/properties_imp.cpp
  8. 8
      src/rss.h
  9. 18
      src/rss_imp.cpp
  10. 8
      src/searchEngine.cpp

1
Changelog

@ -48,6 +48,7 @@ @@ -48,6 +48,7 @@
- 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 incremental download
- BUGFIX: Improved unicode support
- COSMETIC: Redesigned torrent properties a little
- COSMETIC: Redesigned options a little
- COSMETIC: Display more logs messages concerning features

1
TODO

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

2
src/GUI.cpp

@ -1248,7 +1248,7 @@ void GUI::configureSession(bool deleteOptions) { @@ -1248,7 +1248,7 @@ void GUI::configureSession(bool deleteOptions) {
BTSession->setListeningPortsRange(options->getPorts());
new_listenPort = BTSession->getListenPort();
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)
BTSession->setMaxConnections(options->getMaxConnec());

8
src/createtorrent_imp.cpp

@ -54,10 +54,10 @@ createtorrent::createtorrent(QWidget *parent): QDialog(parent){ @@ -54,10 +54,10 @@ createtorrent::createtorrent(QWidget *parent): QDialog(parent){
}
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.endsWith(".torrent"))
destination += ".torrent";
if(!destination.endsWith(QString::fromUtf8(".torrent")))
destination += QString::fromUtf8(".torrent");
txt_destination->setText(destination);
}
}
@ -204,7 +204,7 @@ void createtorrent::on_createButton_clicked(){ @@ -204,7 +204,7 @@ void createtorrent::on_createButton_clicked(){
}
catch (std::exception& e){
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();
return;
}

36
src/main.cpp

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

8
src/options_imp.cpp

@ -1029,8 +1029,8 @@ void options_imp::processFilterFile(QString filePath){ @@ -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());
// add it to list
QStringList item(QString(start.to_string().c_str()));
item.append(QString(last.to_string().c_str()));
QStringList item(QString::fromUtf8(start.to_string().c_str()));
item.append(QString::fromUtf8(last.to_string().c_str()));
if(!i){
item.append(QString::fromUtf8("Manual"));
}else{
@ -1048,8 +1048,8 @@ void options_imp::processFilterFile(QString filePath){ @@ -1048,8 +1048,8 @@ void options_imp::processFilterFile(QString filePath){
address_v6 last = address_v6::from_string(strEndIP.remove(':', 0).toUtf8().data());
// add it to list
QStringList item(QString(start.to_string().c_str()));
item.append(QString(last.to_string().c_str()));
QStringList item(QString::fromUtf8(start.to_string().c_str()));
item.append(QString::fromUtf8(last.to_string().c_str()));
if(!i){
item.append(QString::fromUtf8("Manual"));
}else{

4
src/properties_imp.cpp

@ -303,7 +303,7 @@ void properties::loadTrackers(){ @@ -303,7 +303,7 @@ void properties::loadTrackers(){
trackersURLS->clear();
unsigned int nbTrackers = trackers.size();
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();
if(!tracker.isEmpty()){
@ -449,7 +449,7 @@ void properties::lowerSelectedTracker(){ @@ -449,7 +449,7 @@ void properties::lowerSelectedTracker(){
foreach(item, selectedItems){
QString url = item->text();
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("its tier was %d and will become %d", trackers[i].tier, trackers[i].tier+1);
if(i < nbTrackers-1){

8
src/rss.h

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

18
src/rss_imp.cpp

@ -134,10 +134,10 @@ @@ -134,10 +134,10 @@
RssStream* stream;
foreach(stream, feeds){
QTreeWidgetItem* item = new QTreeWidgetItem(listStreams);
item->setData(0, Qt::DisplayRole, stream->getAliasOrUrl()+ QString(" (0)"));
item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/loading.png")));
item->setData(0, Qt::DisplayRole, stream->getAliasOrUrl()+ QString::fromUtf8(" (0)"));
item->setData(0,Qt::DecorationRole, QVariant(QIcon(QString::fromUtf8(":/Icons/loading.png"))));
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 @@ @@ -157,10 +157,10 @@
return;
}
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->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)
selectFirstFeed();
rssmanager->refresh(newUrl);
@ -174,7 +174,7 @@ @@ -174,7 +174,7 @@
for(unsigned int i=0; i<nbFeeds; ++i){
QTreeWidgetItem* item = listStreams->topLevelItem(i);
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 @@ @@ -232,15 +232,15 @@
void RSSImp::updateFeedNbNews(QString url){
QTreeWidgetItem *item = getTreeItemFromUrl(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){
QTreeWidgetItem *item = getTreeItemFromUrl(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->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(selectedFeedUrl == url){
refreshNewsList(getTreeItemFromUrl(url), 0);

8
src/searchEngine.cpp

@ -204,7 +204,7 @@ void SearchEngine::saveColWidthSearchList() const{ @@ -204,7 +204,7 @@ void SearchEngine::saveColWidthSearchList() const{
QSettings settings("qBittorrent", "qBittorrent");
QStringList width_list;
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(" "));
qDebug("Search list columns width saved");
@ -359,7 +359,7 @@ void SearchEngine::readSearchOutput(){ @@ -359,7 +359,7 @@ void SearchEngine::readSearchOutput(){
foreach(line, lines_list){
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
@ -409,7 +409,7 @@ QByteArray SearchEngine::getNovaChangelog(QString novaPath, float my_version) co @@ -409,7 +409,7 @@ QByteArray SearchEngine::getNovaChangelog(QString novaPath, float my_version) co
QString end_version = "# Version: ";
char tmp[5];
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(in_changelog){
line.remove(0,1);
@ -516,7 +516,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ @@ -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);
stop_search_button->setEnabled(false);
}

Loading…
Cancel
Save