[repo.or.cz] nomnom.git branch next updated: v0.3.0-4-g7ee1b92
Brought to you by:
legatvs
From: <nom...@li...> - 2011-11-03 16:55:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project nomnom.git. The branch, next has been updated via 7ee1b920439239e2bf9b47a5dff09fe233efe0af (commit) via 34321f54d60a82d9c0f57648efee09653dff4f0d (commit) from a831f1cd8c389e271b40706c6f35342550f1f823 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://repo.or.cz/w/nomnom.git/commit/7ee1b920439239e2bf9b47a5dff09fe233efe0af commit 7ee1b920439239e2bf9b47a5dff09fe233efe0af Author: Toni Gundogdu <le...@gm...> Date: Thu Nov 3 18:16:29 2011 +0200 Improve handling of user URL input * Use QUrl::fromUserInput * Validate URLs diff --git a/src/i/MainWindow.cpp b/src/i/MainWindow.cpp index a88f2f3..ae408fb 100644 --- a/src/i/MainWindow.cpp +++ b/src/i/MainWindow.cpp @@ -191,8 +191,17 @@ static void print_url(const nn::NRecentEntry& r) } #endif -void MainWindow::handleURL(const QString& url) +void MainWindow::handleURL(const QString& u) { + const QUrl url = QUrl::fromUserInput(u); + + if (!url.isValid()) + { + // QUrl::errorString() is less than ideal. + nn::info(this, tr("Invalid URL: %1").arg(u)); + return; + } + QString s = settings.eitherValue(nn::ParseUsing, nn::ParseUsingOther) .toString() @@ -232,7 +241,7 @@ void MainWindow::handleURL(const QString& url) // Recent. nn::NRecentEntry e; - e.setURL(url); + e.setURL(url.toEncoded()); recent << e; @@ -291,7 +300,7 @@ void MainWindow::handleURL(const QString& url) // Query media stream data. - q_args.replaceInStrings("%u", url); + q_args.replaceInStrings("%u", url.toEncoded()); q_args << "-f" << fmt; #ifdef ENABLE_VERBOSE @@ -336,11 +345,11 @@ void MainWindow::handleURL(const QString& url) bool MainWindow::queryFormats(QStringList& formats, const QStringList& q_args, - const QString& url, + const QUrl& url, bool& failed) { QStringList args = q_args; - args.replaceInStrings("%u", url); + args.replaceInStrings("%u", url.toEncoded()); args << "-F"; #ifdef ENABLE_VERBOSE @@ -692,7 +701,10 @@ void MainWindow::onRecent() void MainWindow::onAddress() { const QString url = - QInputDialog::getText(this, tr("Address"), tr("Media page URL:")); + QInputDialog::getText(this, + tr("Address"), + tr("Media page URL:")) + .simplified(); if (url.isEmpty()) return; @@ -746,7 +758,7 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *e) void MainWindow::dropEvent(QDropEvent *e) { - handleURL(e->mimeData()->text().simplified()); + handleURL(e->mimeData()->text()); e->acceptProposedAction(); } diff --git a/src/i/MainWindow.h b/src/i/MainWindow.h index 7be959c..91e7a8b 100644 --- a/src/i/MainWindow.h +++ b/src/i/MainWindow.h @@ -28,6 +28,7 @@ class ProcessProgressDialog; class DownloadDialog; +class QUrl; class MainWindow : public QMainWindow, private Ui::MainWindow { @@ -43,7 +44,7 @@ private: void handleURL(const QString&); bool queryFormats(QStringList&, const QStringList&, - const QString&, + const QUrl&, bool&); void createContextMenu(); void changeProgramIcon(); http://repo.or.cz/w/nomnom.git/commit/34321f54d60a82d9c0f57648efee09653dff4f0d commit 34321f54d60a82d9c0f57648efee09653dff4f0d Author: Toni Gundogdu <le...@gm...> Date: Thu Nov 3 18:43:39 2011 +0200 Add "Always get the best media format" diff --git a/src/i/MainWindow.cpp b/src/i/MainWindow.cpp index 5ebd2a1..a88f2f3 100644 --- a/src/i/MainWindow.cpp +++ b/src/i/MainWindow.cpp @@ -256,8 +256,10 @@ void MainWindow::handleURL(const QString& url) << have_quvi_feature_query_formats; #endif + const bool get_best = settings.value(nn::GetBestFormat).toBool(); + QStringList formats; - if (have_quvi_feature_query_formats) + if (have_quvi_feature_query_formats && !get_best) { bool failed = false; @@ -284,7 +286,7 @@ void MainWindow::handleURL(const QString& url) // Choose format. QString fmt; - if (!selectFormat(formats, fmt)) + if (!selectFormat(formats, fmt, get_best)) return; // Query media stream data. @@ -382,12 +384,19 @@ bool MainWindow::queryFormats(QStringList& formats, return false; } -bool MainWindow::selectFormat(QStringList& formats, QString& fmt) +bool MainWindow::selectFormat(QStringList& formats, + QString& fmt, + const bool get_best) { - // Prompt only if count exceeds 1 ("default)". - if (formats.size() < 2) + if (get_best) + { + fmt = "best"; + return true; + } + + if (formats.size() < 2) // Skip prompt unless >1 formats available { - fmt = "default"; // Do not translate. quvi understands only this. + fmt = "default"; return true; } diff --git a/src/i/MainWindow.h b/src/i/MainWindow.h index aa1b8ff..7be959c 100644 --- a/src/i/MainWindow.h +++ b/src/i/MainWindow.h @@ -39,7 +39,7 @@ protected: void closeEvent(QCloseEvent*); void dropEvent(QDropEvent*); private: - bool selectFormat(QStringList&, QString&); + bool selectFormat(QStringList&, QString&, const bool); void handleURL(const QString&); bool queryFormats(QStringList&, const QStringList&, diff --git a/src/settings/nsettings.cpp b/src/settings/nsettings.cpp index 99da9e8..58b685a 100644 --- a/src/settings/nsettings.cpp +++ b/src/settings/nsettings.cpp @@ -55,6 +55,7 @@ const char *key_strings[] = "AskWhereToSaveMediaFile", "ClearURLRecordAtExit", "ReplaceExistingMedia", + "GetBestFormat", // Options: Systray "ShowInTrayIcon", "TerminateInstead", diff --git a/src/settings/nsettings.h b/src/settings/nsettings.h index 5b9857d..0bf6bb5 100644 --- a/src/settings/nsettings.h +++ b/src/settings/nsettings.h @@ -54,6 +54,7 @@ typedef enum AskWhereToSaveMediaFile, ClearURLRecordAtExit, ReplaceExistingMedia, + GetBestFormat, // Options: Systray ShowInTrayIcon, TerminateInstead, diff --git a/src/settings/nsettingsdialog.h b/src/settings/nsettingsdialog.h index 40a30ea..c9d63bb 100644 --- a/src/settings/nsettingsdialog.h +++ b/src/settings/nsettingsdialog.h @@ -218,6 +218,7 @@ private: QCheckBox *clearURLRecordAtExitBox; QCheckBox *askWhereSaveMediaBox; QCheckBox *keepAppWinTopBox; + QCheckBox *getBestFormatBox; QCheckBox *playWhenDoneBox; }; diff --git a/src/settings/nsettingsdialog_options_behaviour.cpp b/src/settings/nsettingsdialog_options_behaviour.cpp index 3cfd88d..522942e 100644 --- a/src/settings/nsettingsdialog_options_behaviour.cpp +++ b/src/settings/nsettingsdialog_options_behaviour.cpp @@ -40,8 +40,9 @@ NSettingsBehaviour::NSettingsBehaviour(QWidget *parent/*=NULL*/) QVBoxLayout *box = new QVBoxLayout; box->addWidget(clearURLRecordAtExitBox); - box->addWidget(replaceExistingMediaBox); + box->addWidget(getBestFormatBox); box->addWidget(askWhereSaveMediaBox); + box->addWidget(replaceExistingMediaBox); box->addWidget(keepAppWinTopBox); box->addWidget(playWhenDoneBox); box->addStretch(0); @@ -64,6 +65,9 @@ void NSettingsBehaviour::createWidgets() replaceExistingMediaBox = new QCheckBox(tr("Al&ways replace existing media")); + + getBestFormatBox = + new QCheckBox(tr("Always &get the best media format")); } void NSettingsBehaviour::init() @@ -81,6 +85,7 @@ void NSettingsBehaviour::write() _write(ClearURLRecordAtExit, clearURLRecordAtExitBox); _write(AskWhereToSaveMediaFile, askWhereSaveMediaBox); _write(KeepApplicationWindowOnTop, keepAppWinTopBox); + _write(GetBestFormat, getBestFormatBox); _write(PlayWhenDoneDownloading, playWhenDoneBox); } @@ -96,6 +101,7 @@ void NSettingsBehaviour::read() _read(ReplaceExistingMedia, replaceExistingMediaBox); _read(ClearURLRecordAtExit, clearURLRecordAtExitBox); _read(AskWhereToSaveMediaFile, askWhereSaveMediaBox); + _read(GetBestFormat, getBestFormatBox); _read(KeepApplicationWindowOnTop, keepAppWinTopBox); _read(PlayWhenDoneDownloading, playWhenDoneBox); } ----------------------------------------------------------------------- Summary of changes: src/i/MainWindow.cpp | 47 ++++++++++++++----- src/i/MainWindow.h | 5 +- src/settings/nsettings.cpp | 1 + src/settings/nsettings.h | 1 + src/settings/nsettingsdialog.h | 1 + src/settings/nsettingsdialog_options_behaviour.cpp | 8 +++- 6 files changed, 47 insertions(+), 16 deletions(-) repo.or.cz automatic notification. Contact project admin le...@gm... if you want to unsubscribe, or site admin ad...@re... if you receive no reply. -- nomnom.git ("The graphical media download tool") |