Browse Source

Replace dialog ok-cancel buttons with QDialogButtonBox

This PR will make button order follow the platform default.
For example: windows use: OK, Cancel; linux use: Cancel, OK.
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
7059b947e8
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 27
      src/gui/downloadfromurldlg.h
  2. 52
      src/gui/downloadfromurldlg.ui
  3. 82
      src/gui/login.ui
  4. 69
      src/gui/preview.ui
  5. 17
      src/gui/previewselect.cpp
  6. 7
      src/gui/previewselect.h
  7. 23
      src/gui/trackerlogin.cpp
  8. 6
      src/gui/trackerlogin.h

27
src/gui/downloadfromurldlg.h

@ -31,23 +31,31 @@ @@ -31,23 +31,31 @@
#ifndef DOWNLOADFROMURL_H
#define DOWNLOADFROMURL_H
#include <QClipboard>
#include <QDialog>
#include <QMessageBox>
#include <QString>
#include <QPushButton>
#include <QRegExp>
#include <QString>
#include <QStringList>
#include <QClipboard>
#include "ui_downloadfromurldlg.h"
class downloadFromURL : public QDialog, private Ui::downloadFromURL{
class downloadFromURL : public QDialog, private Ui::downloadFromURL
{
Q_OBJECT
public:
downloadFromURL(QWidget *parent): QDialog(parent) {
downloadFromURL(QWidget *parent): QDialog(parent)
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
setModal(true);
buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Download"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &downloadFromURL::downloadButtonClicked);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
// Paste clipboard if there is an URL in it
QString clip_txt = qApp->clipboard()->text();
QStringList clip_txt_list = clip_txt.split(QString::fromUtf8("\n"));
@ -80,8 +88,9 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ @@ -80,8 +88,9 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
signals:
void urlsReadyToBeDownloaded(const QStringList& torrent_urls);
public slots:
void on_downloadButton_clicked() {
private slots:
void downloadButtonClicked()
{
QString urls = textUrls->toPlainText();
QStringList url_list = urls.split(QString::fromUtf8("\n"));
QString url;
@ -100,11 +109,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ @@ -100,11 +109,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{
}
emit urlsReadyToBeDownloaded(url_list_cleaned);
qDebug("Emitted urlsReadytobedownloaded signal");
close();
}
void on_cancelButton_clicked() {
close();
accept();
}
};

52
src/gui/downloadfromurldlg.ui

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>482</width>
<width>501</width>
<height>220</height>
</rect>
</property>
@ -50,48 +50,14 @@ @@ -50,48 +50,14 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="downloadButton">
<property name="text">
<string>Download</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>

82
src/gui/login.ui

@ -134,85 +134,19 @@ @@ -134,85 +134,19 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="loginButton">
<property name="text">
<string>Log in</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>authentication</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>245</x>
<y>195</y>
</hint>
<hint type="destinationlabel">
<x>179</x>
<y>230</y>
</hint>
</hints>
</connection>
<connection>
<sender>linePasswd</sender>
<signal>returnPressed()</signal>
<receiver>loginButton</receiver>
<slot>click()</slot>
<hints>
<hint type="sourcelabel">
<x>139</x>
<y>158</y>
</hint>
<hint type="destinationlabel">
<x>122</x>
<y>199</y>
</hint>
</hints>
</connection>
<connection>
<sender>lineUsername</sender>
<signal>returnPressed()</signal>

69
src/gui/preview.ui

@ -32,68 +32,17 @@ @@ -32,68 +32,17 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="previewButton">
<property name="text">
<string>Preview</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="centerButtons">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>cancelButton</sender>
<signal>clicked()</signal>
<receiver>preview</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>296</x>
<y>245</y>
</hint>
<hint type="destinationlabel">
<x>179</x>
<y>282</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>

17
src/gui/previewselect.cpp

@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
#include <QFile>
#include <QHeaderView>
#include <QMessageBox>
#include <QPushButton>
#include <QStandardItemModel>
#include <QTableView>
@ -45,6 +46,11 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t @@ -45,6 +46,11 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Preview"));
connect(buttonBox, &QDialogButtonBox::accepted, this, &PreviewSelect::previewButtonClicked);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
Preferences *const pref = Preferences::instance();
// Preview list
m_previewListModel = new QStandardItemModel(0, NB_COLUMNS);
@ -95,7 +101,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t @@ -95,7 +101,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
if (m_previewListModel->rowCount() == 1) {
qDebug("Torrent file only contains one file, no need to display selection dialog before preview");
// Only one file : no choice
on_previewButton_clicked();
previewButtonClicked();
}
else {
qDebug("Displaying media file selection dialog for preview");
@ -110,7 +116,7 @@ PreviewSelect::~PreviewSelect() @@ -110,7 +116,7 @@ PreviewSelect::~PreviewSelect()
}
void PreviewSelect::on_previewButton_clicked()
void PreviewSelect::previewButtonClicked()
{
QModelIndexList selectedIndexes = previewList->selectionModel()->selectedRows(FILE_INDEX);
if (selectedIndexes.size() == 0) return;
@ -127,10 +133,5 @@ void PreviewSelect::on_previewButton_clicked() @@ -127,10 +133,5 @@ void PreviewSelect::on_previewButton_clicked()
else
QMessageBox::critical(this->parentWidget(), tr("Preview impossible"), tr("Sorry, we can't preview this file"));
close();
}
void PreviewSelect::on_cancelButton_clicked()
{
close();
accept();
}

7
src/gui/previewselect.h

@ -39,7 +39,7 @@ class QStandardItemModel; @@ -39,7 +39,7 @@ class QStandardItemModel;
class PreviewListDelegate;
class PreviewSelect: public QDialog, private Ui::preview
class PreviewSelect : public QDialog, private Ui::preview
{
Q_OBJECT
@ -60,9 +60,8 @@ public: @@ -60,9 +60,8 @@ public:
signals:
void readyToPreviewFile(QString) const;
protected slots:
void on_previewButton_clicked();
void on_cancelButton_clicked();
private slots:
void previewButtonClicked();
private:
QStandardItemModel *m_previewListModel;

23
src/gui/trackerlogin.cpp

@ -30,6 +30,7 @@ @@ -30,6 +30,7 @@
#include "trackerlogin.h"
#include <QPushButton>
#include <libtorrent/version.hpp>
#include "base/bittorrent/torrenthandle.h"
@ -39,24 +40,36 @@ trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const tor @@ -39,24 +40,36 @@ trackerLogin::trackerLogin(QWidget *parent, BitTorrent::TorrentHandle *const tor
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Log in"));
login_logo->setPixmap(QPixmap(QString::fromUtf8(":/icons/qbt-theme/encrypted.png")));
tracker_url->setText(torrent->currentTracker());
connect(this, SIGNAL(trackerLoginCancelled(QPair<BitTorrent::TorrentHandle*, QString>)), parent, SLOT(addUnauthenticatedTracker(QPair<BitTorrent::TorrentHandle*, QString>)));
connect(buttonBox, &QDialogButtonBox::accepted, this, &trackerLogin::loginButtonClicked);
connect(buttonBox, &QDialogButtonBox::rejected, this, &trackerLogin::cancelButtonClicked);
connect(linePasswd, &QLineEdit::returnPressed, this, &trackerLogin::loginButtonClicked);
connect(this, SIGNAL(trackerLoginCancelled(QPair<BitTorrent::TorrentHandle*, QString>)), // TODO: use Qt5 connect syntax
parent, SLOT(addUnauthenticatedTracker(QPair<BitTorrent::TorrentHandle*, QString>)));
show();
}
trackerLogin::~trackerLogin() {}
void trackerLogin::on_loginButton_clicked() {
void trackerLogin::loginButtonClicked()
{
// login
#if LIBTORRENT_VERSION_NUM < 10100
m_torrent->setTrackerLogin(lineUsername->text(), linePasswd->text());
#endif
close();
accept();
}
void trackerLogin::on_cancelButton_clicked() {
void trackerLogin::cancelButtonClicked()
{
// Emit a signal to GUI to stop asking for authentication
emit trackerLoginCancelled(qMakePair(m_torrent, m_torrent->currentTracker()));
close();
reject();
}

6
src/gui/trackerlogin.h

@ -53,9 +53,9 @@ class trackerLogin : public QDialog, private Ui::authentication{ @@ -53,9 +53,9 @@ class trackerLogin : public QDialog, private Ui::authentication{
signals:
void trackerLoginCancelled(QPair<BitTorrent::TorrentHandle*, QString> tracker);
public slots:
void on_loginButton_clicked();
void on_cancelButton_clicked();
private slots:
void loginButtonClicked();
void cancelButtonClicked();
};
#endif

Loading…
Cancel
Save