Browse Source

Use AutoExpandableDialog instead of QInputDialog wherever possible

adaptive-webui-19844
Nick Tiskov 11 years ago
parent
commit
fd8a2e05a4
  1. 4
      src/addnewtorrentdialog.cpp
  2. 9
      src/mainwindow.cpp
  3. 1
      src/preferences/options_imp.cpp
  4. 8
      src/properties/propertieswidget.cpp
  5. 17
      src/properties/trackerlist.cpp
  6. 6
      src/rss/automatedrssdownloader.cpp
  7. 8
      src/rss/rss_imp.cpp
  8. 4
      src/searchengine/engineselectdlg.cpp
  9. 1
      src/torrentcreator/torrentcreatordlg.cpp
  10. 4
      src/transferlistfilterswidget.h
  11. 6
      src/transferlistwidget.cpp

4
src/addnewtorrentdialog.cpp

@ -39,10 +39,10 @@
#include "qbtsession.h" #include "qbtsession.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "fs_utils.h" #include "fs_utils.h"
#include "autoexpandabledialog.h"
#include <QString> #include <QString>
#include <QFile> #include <QFile>
#include <QInputDialog>
#include <QUrl> #include <QUrl>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
@ -394,7 +394,7 @@ void AddNewTorrentDialog::renameSelectedFile()
const QModelIndex &index = selectedIndexes.first(); const QModelIndex &index = selectedIndexes.first();
// Ask for new name // Ask for new name
bool ok; bool ok;
const QString new_name_last = QInputDialog::getText(this, tr("Rename the file"), const QString new_name_last = AutoExpandableDialog::getText(this, tr("Rename the file"),
tr("New name:"), QLineEdit::Normal, tr("New name:"), QLineEdit::Normal,
index.data().toString(), &ok).trimmed(); index.data().toString(), &ok).trimmed();
if (ok && !new_name_last.isEmpty()) { if (ok && !new_name_last.isEmpty()) {

9
src/mainwindow.cpp

@ -72,6 +72,9 @@
#include "torrentmodel.h" #include "torrentmodel.h"
#include "executionlog.h" #include "executionlog.h"
#include "iconprovider.h" #include "iconprovider.h"
#ifndef DISABLE_GUI
#include "autoexpandabledialog.h"
#endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
#include "qmacapplication.h" #include "qmacapplication.h"
void qt_mac_set_dock_menu(QMenu *menu); void qt_mac_set_dock_menu(QMenu *menu);
@ -397,7 +400,7 @@ void MainWindow::defineUILockPassword() {
QString old_pass_md5 = Preferences().getUILockPasswordMD5(); QString old_pass_md5 = Preferences().getUILockPasswordMD5();
if (old_pass_md5.isNull()) old_pass_md5 = ""; if (old_pass_md5.isNull()) old_pass_md5 = "";
bool ok = false; bool ok = false;
QString new_clear_password = QInputDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, old_pass_md5, &ok); QString new_clear_password = AutoExpandableDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, old_pass_md5, &ok);
if (ok) { if (ok) {
new_clear_password = new_clear_password.trimmed(); new_clear_password = new_clear_password.trimmed();
if (new_clear_password.size() < 3) { if (new_clear_password.size() < 3) {
@ -417,7 +420,7 @@ void MainWindow::on_actionLock_qBittorrent_triggered() {
if (pref.getUILockPasswordMD5().isEmpty()) { if (pref.getUILockPasswordMD5().isEmpty()) {
// Ask for a password // Ask for a password
bool ok = false; bool ok = false;
QString clear_password = QInputDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, "", &ok); QString clear_password = AutoExpandableDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, "", &ok);
if (!ok) return; if (!ok) return;
pref.setUILockPassword(clear_password); pref.setUILockPassword(clear_password);
} }
@ -687,7 +690,7 @@ void MainWindow::setTabText(int index, QString text) const {
bool MainWindow::unlockUI() { bool MainWindow::unlockUI() {
bool ok = false; bool ok = false;
QString clear_password = QInputDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, "", &ok); QString clear_password = AutoExpandableDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, "", &ok);
if (!ok) return false; if (!ok) return false;
Preferences pref; Preferences pref;
QString real_pass_md5 = pref.getUILockPasswordMD5(); QString real_pass_md5 = pref.getUILockPasswordMD5();

1
src/preferences/options_imp.cpp

@ -30,7 +30,6 @@
#include <QTextStream> #include <QTextStream>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QInputDialog>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QApplication> #include <QApplication>
#include <QDialogButtonBox> #include <QDialogButtonBox>

8
src/properties/propertieswidget.cpp

@ -39,7 +39,6 @@
#include <QMenu> #include <QMenu>
#include <QFileDialog> #include <QFileDialog>
#include <QDesktopServices> #include <QDesktopServices>
#include <QInputDialog>
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include "propertieswidget.h" #include "propertieswidget.h"
#include "transferlistwidget.h" #include "transferlistwidget.h"
@ -58,6 +57,7 @@
#include "iconprovider.h" #include "iconprovider.h"
#include "lineedit.h" #include "lineedit.h"
#include "fs_utils.h" #include "fs_utils.h"
#include "autoexpandabledialog.h"
using namespace libtorrent; using namespace libtorrent;
@ -523,7 +523,7 @@ void PropertiesWidget::renameSelectedFile() {
const QModelIndex index = selectedIndexes.first(); const QModelIndex index = selectedIndexes.first();
// Ask for new name // Ask for new name
bool ok; bool ok;
QString new_name_last = QInputDialog::getText(this, tr("Rename the file"), QString new_name_last = AutoExpandableDialog::getText(this, tr("Rename the file"),
tr("New name:"), QLineEdit::Normal, tr("New name:"), QLineEdit::Normal,
index.data().toString(), &ok).trimmed(); index.data().toString(), &ok).trimmed();
if (ok && !new_name_last.isEmpty()) { if (ok && !new_name_last.isEmpty()) {
@ -636,7 +636,7 @@ void PropertiesWidget::renameSelectedFile() {
void PropertiesWidget::askWebSeed() { void PropertiesWidget::askWebSeed() {
bool ok; bool ok;
// Ask user for a new url seed // Ask user for a new url seed
const QString url_seed = QInputDialog::getText(this, tr("New url seed", "New HTTP source"), const QString url_seed = AutoExpandableDialog::getText(this, tr("New url seed", "New HTTP source"),
tr("New url seed:"), QLineEdit::Normal, tr("New url seed:"), QLineEdit::Normal,
QString::fromUtf8("http://www."), &ok); QString::fromUtf8("http://www."), &ok);
if (!ok) return; if (!ok) return;
@ -689,7 +689,7 @@ void PropertiesWidget::editWebSeed() {
const QListWidgetItem *selected_item = selected_items.last(); const QListWidgetItem *selected_item = selected_items.last();
const QString old_seed = selected_item->text(); const QString old_seed = selected_item->text();
bool result; bool result;
const QString new_seed = QInputDialog::getText(this, tr("Web seed editing"), const QString new_seed = AutoExpandableDialog::getText(this, tr("Web seed editing"),
tr("Web seed URL:"), QLineEdit::Normal, tr("Web seed URL:"), QLineEdit::Normal,
old_seed, &result); old_seed, &result);
if (!result) if (!result)

17
src/properties/trackerlist.cpp

@ -35,7 +35,6 @@
#include <QAction> #include <QAction>
#include <QColor> #include <QColor>
#include <QDebug> #include <QDebug>
#include <QInputDialog>
#include <QUrl> #include <QUrl>
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include <libtorrent/peer_info.hpp> #include <libtorrent/peer_info.hpp>
@ -46,6 +45,7 @@
#include "qbtsession.h" #include "qbtsession.h"
#include "qinisettings.h" #include "qinisettings.h"
#include "misc.h" #include "misc.h"
#include "autoexpandabledialog.h"
using namespace libtorrent; using namespace libtorrent;
@ -355,19 +355,12 @@ void TrackerList::editSelectedTracker() {
// During multi-select only process item selected last // During multi-select only process item selected last
QUrl tracker_url = selected_items.last()->text(COL_URL); QUrl tracker_url = selected_items.last()->text(COL_URL);
QInputDialog editDlg(this); bool ok;
editDlg.setInputMode(QInputDialog::TextInput); QUrl new_tracker_url = AutoExpandableDialog::getText(this, tr("Tracker editing"), tr("Tracker URL:"),
editDlg.setLabelText(tr("Tracker URL:")); QLineEdit::Normal, tracker_url.toString(), &ok).trimmed();
editDlg.setWindowTitle(tr("Tracker editing")); if (!ok)
editDlg.setTextValue(tracker_url.toString());
QSize dlgSize = editDlg.size();
dlgSize.setWidth(350);
editDlg.resize(dlgSize);
if(!editDlg.exec())
return; return;
QUrl new_tracker_url = editDlg.textValue().trimmed();
if (!new_tracker_url.isValid()) { if (!new_tracker_url.isValid()) {
QMessageBox::warning(this, tr("Tracker editing failed"), tr("The tracker URL entered is invalid.")); QMessageBox::warning(this, tr("Tracker editing failed"), tr("The tracker URL entered is invalid."));
return; return;

6
src/rss/automatedrssdownloader.cpp

@ -28,7 +28,6 @@
* Contact : chris@qbittorrent.org * Contact : chris@qbittorrent.org
*/ */
#include <QInputDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QDebug> #include <QDebug>
@ -44,6 +43,7 @@
#include "rssmanager.h" #include "rssmanager.h"
#include "rssfeed.h" #include "rssfeed.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "autoexpandabledialog.h"
AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& manager, QWidget *parent) : AutomatedRssDownloader::AutomatedRssDownloader(const QWeakPointer<RssManager>& manager, QWidget *parent) :
QDialog(parent), QDialog(parent),
@ -309,7 +309,7 @@ void AutomatedRssDownloader::saveEditedRule()
void AutomatedRssDownloader::on_addRuleBtn_clicked() void AutomatedRssDownloader::on_addRuleBtn_clicked()
{ {
// Ask for a rule name // Ask for a rule name
const QString rule_name = QInputDialog::getText(this, tr("New rule name"), tr("Please type the name of the new download rule.")); const QString rule_name = AutoExpandableDialog::getText(this, tr("New rule name"), tr("Please type the name of the new download rule."));
if (rule_name.isEmpty()) return; if (rule_name.isEmpty()) return;
// Check if this rule name already exists // Check if this rule name already exists
if (m_editableRuleList->getRule(rule_name)) { if (m_editableRuleList->getRule(rule_name)) {
@ -424,7 +424,7 @@ void AutomatedRssDownloader::renameSelectedRule()
QListWidgetItem *item = ui->listRules->currentItem(); QListWidgetItem *item = ui->listRules->currentItem();
if (!item) return; if (!item) return;
forever { forever {
QString new_name = QInputDialog::getText(this, tr("Rule renaming"), tr("Please type the new rule name"), QLineEdit::Normal, item->text()); QString new_name = AutoExpandableDialog::getText(this, tr("Rule renaming"), tr("Please type the new rule name"), QLineEdit::Normal, item->text());
new_name = new_name.trimmed(); new_name = new_name.trimmed();
if (new_name.isEmpty()) return; if (new_name.isEmpty()) return;
if (m_editableRuleList->ruleNames().contains(new_name, Qt::CaseInsensitive)) { if (m_editableRuleList->ruleNames().contains(new_name, Qt::CaseInsensitive)) {

8
src/rss/rss_imp.cpp

@ -29,7 +29,6 @@
*/ */
#include <QDesktopServices> #include <QDesktopServices>
#include <QInputDialog>
#include <QMenu> #include <QMenu>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QMessageBox> #include <QMessageBox>
@ -51,6 +50,7 @@
#include "rsssettings.h" #include "rsssettings.h"
#include "automatedrssdownloader.h" #include "automatedrssdownloader.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "autoexpandabledialog.h"
namespace Article { namespace Article {
enum ArticleRoles { enum ArticleRoles {
@ -150,7 +150,7 @@ void RSSImp::askNewFolder()
rss_parent = m_rssManager; rss_parent = m_rssManager;
} }
bool ok; bool ok;
QString new_name = QInputDialog::getText(this, tr("Please choose a folder name"), tr("Folder name:"), QLineEdit::Normal, tr("New folder"), &ok); QString new_name = AutoExpandableDialog::getText(this, tr("Please choose a folder name"), tr("Folder name:"), QLineEdit::Normal, tr("New folder"), &ok);
if (!ok) if (!ok)
return; return;
@ -197,7 +197,7 @@ void RSSImp::on_newFeedButton_clicked()
if (clip_txt.startsWith("http://", Qt::CaseInsensitive) || clip_txt.startsWith("https://", Qt::CaseInsensitive) || clip_txt.startsWith("ftp://", Qt::CaseInsensitive)) if (clip_txt.startsWith("http://", Qt::CaseInsensitive) || clip_txt.startsWith("https://", Qt::CaseInsensitive) || clip_txt.startsWith("ftp://", Qt::CaseInsensitive))
default_url = clip_txt; default_url = clip_txt;
QString newUrl = QInputDialog::getText(this, tr("Please type a rss stream url"), tr("Stream URL:"), QLineEdit::Normal, default_url, &ok); QString newUrl = AutoExpandableDialog::getText(this, tr("Please type a rss stream url"), tr("Stream URL:"), QLineEdit::Normal, default_url, &ok);
if (!ok) if (!ok)
return; return;
@ -372,7 +372,7 @@ void RSSImp::renameSelectedRssFile()
bool ok; bool ok;
QString newName; QString newName;
do { do {
newName = QInputDialog::getText(this, tr("Please choose a new name for this RSS feed"), tr("New feed name:"), QLineEdit::Normal, m_feedList->getRSSItem(item)->displayName(), &ok); newName = AutoExpandableDialog::getText(this, tr("Please choose a new name for this RSS feed"), tr("New feed name:"), QLineEdit::Normal, m_feedList->getRSSItem(item)->displayName(), &ok);
// Check if name is already taken // Check if name is already taken
if (ok) { if (ok) {
if (rss_item->parent()->hasChild(newName)) { if (rss_item->parent()->hasChild(newName)) {

4
src/searchengine/engineselectdlg.cpp

@ -36,13 +36,13 @@
#include "searchengine.h" #include "searchengine.h"
#include "pluginsource.h" #include "pluginsource.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "autoexpandabledialog.h"
#include <QProcess> #include <QProcess>
#include <QHeaderView> #include <QHeaderView>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QDropEvent> #include <QDropEvent>
#include <QInputDialog>
#include <QTemporaryFile> #include <QTemporaryFile>
enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID}; enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
@ -327,7 +327,7 @@ void engineSelectDlg::on_installButton_clicked() {
void engineSelectDlg::askForPluginUrl() { void engineSelectDlg::askForPluginUrl() {
bool ok; bool ok;
QString url = QInputDialog::getText(this, tr("New search engine plugin URL"), QString url = AutoExpandableDialog::getText(this, tr("New search engine plugin URL"),
tr("URL:"), QLineEdit::Normal, tr("URL:"), QLineEdit::Normal,
"http://", &ok); "http://", &ok);
if (ok && !url.isEmpty()) { if (ok && !url.isEmpty()) {

1
src/torrentcreator/torrentcreatordlg.cpp

@ -30,7 +30,6 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QInputDialog>
#include "torrentpersistentdata.h" #include "torrentpersistentdata.h"
#include "torrentcreatordlg.h" #include "torrentcreatordlg.h"

4
src/transferlistfilterswidget.h

@ -37,7 +37,6 @@
#include <QIcon> #include <QIcon>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QMenu> #include <QMenu>
#include <QInputDialog>
#include <QDragMoveEvent> #include <QDragMoveEvent>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QMessageBox> #include <QMessageBox>
@ -51,6 +50,7 @@
#include "torrentmodel.h" #include "torrentmodel.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "fs_utils.h" #include "fs_utils.h"
#include "autoexpandabledialog.h"
class LabelFiltersList: public QListWidget { class LabelFiltersList: public QListWidget {
Q_OBJECT Q_OBJECT
@ -368,7 +368,7 @@ protected slots:
bool invalid; bool invalid;
do { do {
invalid = false; invalid = false;
label = QInputDialog::getText(this, tr("New Label"), tr("Label:"), QLineEdit::Normal, label, &ok); label = AutoExpandableDialog::getText(this, tr("New Label"), tr("Label:"), QLineEdit::Normal, label, &ok);
if (ok && !label.isEmpty()) { if (ok && !label.isEmpty()) {
if (fsutils::isValidFileSystemName(label)) { if (fsutils::isValidFileSystemName(label)) {
addLabel(label); addLabel(label);

6
src/transferlistwidget.cpp

@ -33,7 +33,6 @@
#include <QDesktopServices> #include <QDesktopServices>
#include <QTimer> #include <QTimer>
#include <QClipboard> #include <QClipboard>
#include <QInputDialog>
#include <QColor> #include <QColor>
#include <QUrl> #include <QUrl>
#include <QMenu> #include <QMenu>
@ -61,6 +60,7 @@
#include "qinisettings.h" #include "qinisettings.h"
#include "iconprovider.h" #include "iconprovider.h"
#include "fs_utils.h" #include "fs_utils.h"
#include "autoexpandabledialog.h"
using namespace libtorrent; using namespace libtorrent;
@ -602,7 +602,7 @@ void TransferListWidget::askNewLabelForSelection() {
bool invalid; bool invalid;
do { do {
invalid = false; invalid = false;
const QString label = QInputDialog::getText(this, tr("New Label"), tr("Label:"), QLineEdit::Normal, "", &ok).trimmed(); const QString label = AutoExpandableDialog::getText(this, tr("New Label"), tr("Label:"), QLineEdit::Normal, "", &ok).trimmed();
if (ok && !label.isEmpty()) { if (ok && !label.isEmpty()) {
if (fsutils::isValidFileSystemName(label)) { if (fsutils::isValidFileSystemName(label)) {
setSelectionLabel(label); setSelectionLabel(label);
@ -624,7 +624,7 @@ void TransferListWidget::renameSelectedTorrent() {
if (!h.is_valid()) return; if (!h.is_valid()) return;
// Ask for a new Name // Ask for a new Name
bool ok; bool ok;
QString name = QInputDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok); QString name = AutoExpandableDialog::getText(this, tr("Rename"), tr("New name:"), QLineEdit::Normal, h.name(), &ok);
if (ok && !name.isEmpty()) { if (ok && !name.isEmpty()) {
name.replace(QRegExp("\r?\n|\r"), " "); name.replace(QRegExp("\r?\n|\r"), " ");
// Rename the torrent // Rename the torrent

Loading…
Cancel
Save