Browse Source

Merge pull request #4670 from glassez/rsscookies

Implement application wide cookies management dialog. Closes #4638
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
484cd2f1ce
  1. 13
      src/base/net/downloadmanager.cpp
  2. 2
      src/base/net/downloadmanager.h
  3. 89
      src/gui/cookiesdialog.cpp
  4. 43
      src/gui/cookiesdialog.h
  5. 179
      src/gui/cookiesdialog.ui
  6. 178
      src/gui/cookiesmodel.cpp
  7. 74
      src/gui/cookiesmodel.h
  8. 11
      src/gui/gui.pri
  9. 1017
      src/gui/mainwindow.cpp
  10. 237
      src/gui/mainwindow.h
  11. 117
      src/gui/mainwindow.ui
  12. 2
      src/gui/properties/propertieswidget.cpp
  13. 110
      src/gui/rss/cookiesdlg.cpp
  14. 172
      src/gui/rss/cookiesdlg.ui
  15. 5
      src/gui/rss/rss.pri
  16. 5
      src/gui/rss/rss.ui
  17. 23
      src/gui/rss/rss_imp.cpp
  18. 1
      src/gui/rss/rss_imp.h
  19. 4
      src/gui/search/searchwidget.cpp
  20. 10
      src/gui/transferlistwidget.cpp

13
src/base/net/downloadmanager.cpp

@ -75,6 +75,9 @@ namespace @@ -75,6 +75,9 @@ namespace
Preferences::instance()->setNetworkCookies(cookies);
}
using QNetworkCookieJar::allCookies;
using QNetworkCookieJar::setAllCookies;
#ifndef QBT_USES_QT5
virtual bool deleteCookie(const QNetworkCookie &cookie)
{
@ -188,6 +191,16 @@ bool DownloadManager::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, @@ -188,6 +191,16 @@ bool DownloadManager::setCookiesFromUrl(const QList<QNetworkCookie> &cookieList,
return m_networkManager.cookieJar()->setCookiesFromUrl(cookieList, url);
}
QList<QNetworkCookie> DownloadManager::allCookies() const
{
return static_cast<NetworkCookieJar *>(m_networkManager.cookieJar())->allCookies();
}
void DownloadManager::setAllCookies(const QList<QNetworkCookie> &cookieList)
{
static_cast<NetworkCookieJar *>(m_networkManager.cookieJar())->setAllCookies(cookieList);
}
bool DownloadManager::deleteCookie(const QNetworkCookie &cookie)
{
return static_cast<NetworkCookieJar *>(m_networkManager.cookieJar())->deleteCookie(cookie);

2
src/base/net/downloadmanager.h

@ -54,6 +54,8 @@ namespace Net @@ -54,6 +54,8 @@ namespace Net
DownloadHandler *downloadUrl(const QString &url, bool saveToFile = false, qint64 limit = 0, bool handleRedirectToMagnet = false, const QString &userAgent = "");
QList<QNetworkCookie> cookiesForUrl(const QUrl &url) const;
bool setCookiesFromUrl(const QList<QNetworkCookie> &cookieList, const QUrl &url);
QList<QNetworkCookie> allCookies() const;
void setAllCookies(const QList<QNetworkCookie> &cookieList);
bool deleteCookie(const QNetworkCookie &cookie);
private slots:

89
src/gui/cookiesdialog.cpp

@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include "cookiesdialog.h"
#include "base/settingsstorage.h"
#include "base/net/downloadmanager.h"
#include "guiiconprovider.h"
#include "cookiesmodel.h"
#include "ui_cookiesdialog.h"
#define SETTINGS_KEY(name) "CookiesDialog/" name
const QString KEY_GEOMETRY = SETTINGS_KEY("Geometry");
const QString KEY_COOKIESVIEWSTATE = SETTINGS_KEY("CookiesViewState");
CookiesDialog::CookiesDialog(QWidget *parent)
: QDialog(parent)
, m_ui(new Ui::CookiesDialog)
, m_cookiesModel(new CookiesModel(Net::DownloadManager::instance()->allCookies(), this))
{
m_ui->setupUi(this);
setWindowIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies"));
m_ui->buttonAdd->setIcon(GuiIconProvider::instance()->getIcon("list-add"));
m_ui->buttonDelete->setIcon(GuiIconProvider::instance()->getIcon("list-remove"));
m_ui->treeView->setModel(m_cookiesModel);
if (m_cookiesModel->rowCount() > 0)
m_ui->treeView->selectionModel()->setCurrentIndex(
m_cookiesModel->index(0, 0),
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
restoreGeometry(SettingsStorage::instance()->loadValue(KEY_GEOMETRY).toByteArray());
m_ui->treeView->header()->restoreState(
SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray());
}
CookiesDialog::~CookiesDialog()
{
SettingsStorage::instance()->storeValue(KEY_GEOMETRY, saveGeometry());
SettingsStorage::instance()->storeValue(
KEY_COOKIESVIEWSTATE, m_ui->treeView->header()->saveState());
delete m_ui;
}
void CookiesDialog::accept()
{
Net::DownloadManager::instance()->setAllCookies(m_cookiesModel->cookies());
QDialog::accept();
}
void CookiesDialog::onButtonAddClicked()
{
int row = m_ui->treeView->selectionModel()->currentIndex().row() + 1;
m_cookiesModel->insertRow(row);
m_ui->treeView->selectionModel()->setCurrentIndex(
m_cookiesModel->index(row, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
}
void CookiesDialog::onButtonDeleteClicked()
{
m_cookiesModel->removeRow(m_ui->treeView->selectionModel()->currentIndex().row());
}

43
src/gui/rss/cookiesdlg.h → src/gui/cookiesdialog.h

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -24,39 +24,38 @@ @@ -24,39 +24,38 @@
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org arnaud@qbittorrent.org
*/
#ifndef COOKIESDLG_H
#define COOKIESDLG_H
#ifndef COOKIESDIALOG_H
#define COOKIESDIALOG_H
#include <QDialog>
#include <QList>
class QNetworkCookie;
class QUrl;
namespace Ui {
class CookiesDlg;
namespace Ui
{
class CookiesDialog;
}
class CookiesDlg : public QDialog
class CookiesModel;
class CookiesDialog : public QDialog
{
Q_OBJECT
public:
explicit CookiesDlg(const QUrl &url, QWidget *parent = 0);
~CookiesDlg();
QList<QNetworkCookie> getCookies() const;
static bool askForCookies(QWidget *parent, const QUrl &url, QList<QNetworkCookie> &out);
explicit CookiesDialog(QWidget *parent = 0);
~CookiesDialog();
public slots:
void accept() override;
protected slots:
void on_add_btn_clicked();
void on_del_btn_clicked();
private slots:
void onButtonAddClicked();
void onButtonDeleteClicked();
private:
Ui::CookiesDlg *ui;
Ui::CookiesDialog *m_ui;
CookiesModel *m_cookiesModel;
};
#endif // COOKIESDLG_H
#endif // COOKIESDIALOG_H

179
src/gui/cookiesdialog.ui

@ -0,0 +1,179 @@ @@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CookiesDialog</class>
<widget class="QDialog" name="CookiesDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>618</width>
<height>369</height>
</rect>
</property>
<property name="windowTitle">
<string>Manage Cookies</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTreeView" name="treeView"/>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="buttonAdd">
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="buttonDelete">
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CookiesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>257</x>
<y>406</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CookiesDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>325</x>
<y>406</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonAdd</sender>
<signal>clicked()</signal>
<receiver>CookiesDialog</receiver>
<slot>onButtonAddClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>484</x>
<y>174</y>
</hint>
<hint type="destinationlabel">
<x>486</x>
<y>93</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonDelete</sender>
<signal>clicked()</signal>
<receiver>CookiesDialog</receiver>
<slot>onButtonDeleteClicked()</slot>
<hints>
<hint type="sourcelabel">
<x>483</x>
<y>226</y>
</hint>
<hint type="destinationlabel">
<x>485</x>
<y>296</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onButtonAddClicked()</slot>
<slot>onButtonDeleteClicked()</slot>
</slots>
</ui>

178
src/gui/cookiesmodel.cpp

@ -0,0 +1,178 @@ @@ -0,0 +1,178 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include <QDateTime>
#include "cookiesmodel.h"
CookiesModel::CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent)
: QAbstractItemModel(parent)
, m_cookies(cookies)
{
}
QList<QNetworkCookie> CookiesModel::cookies() const
{
return m_cookies;
}
QVariant CookiesModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if ((role == Qt::DisplayRole) && (orientation == Qt::Horizontal)) {
switch (section)
{
case COL_DOMAIN:
return tr("Domain");
case COL_PATH:
return tr("Path");
case COL_NAME:
return tr("Name");
case COL_VALUE:
return tr("Value");
case COL_EXPDATE:
return tr("Expiration Date");
}
}
return QVariant();
}
QModelIndex CookiesModel::index(int row, int column, const QModelIndex &parent) const
{
if (parent.isValid() // no items with valid parent
|| (row < 0) || (row >= m_cookies.size())
|| (column < 0) || (column >= NB_COLUMNS))
return QModelIndex();
return createIndex(row, column, &m_cookies[row]);
}
QModelIndex CookiesModel::parent(const QModelIndex &index) const
{
Q_UNUSED(index);
return QModelIndex();
}
int CookiesModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid()) return 0;
return m_cookies.size();
}
int CookiesModel::columnCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return NB_COLUMNS;
}
QVariant CookiesModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || (index.row() >= m_cookies.size())
|| ((role != Qt::DisplayRole) && (role != Qt::EditRole)))
return QVariant();
switch (index.column()) {
case COL_DOMAIN:
return m_cookies[index.row()].domain();
case COL_PATH:
return m_cookies[index.row()].path();
case COL_NAME:
return QString::fromLatin1(m_cookies[index.row()].name());
case COL_VALUE:
return QString::fromLatin1(m_cookies[index.row()].value());
case COL_EXPDATE:
return m_cookies[index.row()].expirationDate();
}
return QVariant();
}
bool CookiesModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (role != Qt::EditRole) return false;
switch (index.column()) {
case COL_DOMAIN:
m_cookies[index.row()].setDomain(value.toString());
break;
case COL_PATH:
m_cookies[index.row()].setPath(value.toString());
break;
case COL_NAME:
m_cookies[index.row()].setName(value.toString().toLatin1());
break;
case COL_VALUE:
m_cookies[index.row()].setValue(value.toString().toLatin1());
break;
case COL_EXPDATE:
m_cookies[index.row()].setExpirationDate(value.toDateTime());
break;
default:
return false;
}
emit dataChanged(index, index);
return true;
}
bool CookiesModel::insertRows(int row, int count, const QModelIndex &parent)
{
if ((row < 0) || (row > m_cookies.size())) return false;
QNetworkCookie newCookie;
newCookie.setExpirationDate(QDateTime::currentDateTime().addYears(99));
beginInsertRows(parent, row, row + count - 1);
while (count-- > 0)
m_cookies.insert(row, newCookie);
endInsertRows();
return true;
}
bool CookiesModel::removeRows(int row, int count, const QModelIndex &parent)
{
if ((m_cookies.size() == 0)
|| (row >= m_cookies.size())
|| ((row + count) > m_cookies.size()))
return false;
beginRemoveRows(parent, row, row + count - 1);
while (count-- > 0)
m_cookies.removeAt(row);
endRemoveRows();
return true;
}
Qt::ItemFlags CookiesModel::flags(const QModelIndex &index) const
{
if (!index.isValid()) return 0;
return Qt::ItemIsEditable | QAbstractItemModel::flags(index);
}

74
src/gui/cookiesmodel.h

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef COOKIESMODEL_H
#define COOKIESMODEL_H
#include <QAbstractItemModel>
#include <QList>
#include <QNetworkCookie>
class CookiesModel : public QAbstractItemModel
{
Q_OBJECT
public:
enum Column
{
COL_DOMAIN,
COL_PATH,
COL_NAME,
COL_VALUE,
COL_EXPDATE,
NB_COLUMNS
};
explicit CookiesModel(const QList<QNetworkCookie> &cookies, QObject *parent = 0);
QList<QNetworkCookie> cookies() const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
Qt::ItemFlags flags(const QModelIndex &index) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
private:
mutable QList<QNetworkCookie> m_cookies;
};
#endif // COOKIESMODEL_H

11
src/gui/gui.pri

@ -48,7 +48,9 @@ HEADERS += \ @@ -48,7 +48,9 @@ HEADERS += \
$$PWD/search/pluginselectdlg.h \
$$PWD/search/pluginsourcedlg.h \
$$PWD/search/searchlistdelegate.h \
$$PWD/search/searchsortmodel.h
$$PWD/search/searchsortmodel.h \
$$PWD/cookiesmodel.h \
$$PWD/cookiesdialog.h
SOURCES += \
$$PWD/mainwindow.cpp \
@ -87,7 +89,9 @@ SOURCES += \ @@ -87,7 +89,9 @@ SOURCES += \
$$PWD/search/pluginselectdlg.cpp \
$$PWD/search/pluginsourcedlg.cpp \
$$PWD/search/searchlistdelegate.cpp \
$$PWD/search/searchsortmodel.cpp
$$PWD/search/searchsortmodel.cpp \
$$PWD/cookiesmodel.cpp \
$$PWD/cookiesdialog.cpp
win32|macx {
HEADERS += $$PWD/programupdater.h
@ -114,6 +118,7 @@ FORMS += \ @@ -114,6 +118,7 @@ FORMS += \
$$PWD/search/searchwidget.ui \
$$PWD/search/pluginselectdlg.ui \
$$PWD/search/pluginsourcedlg.ui \
$$PWD/search/searchtab.ui
$$PWD/search/searchtab.ui \
$$PWD/cookiesdialog.ui
RESOURCES += $$PWD/about.qrc

1017
src/gui/mainwindow.cpp

File diff suppressed because it is too large Load Diff

237
src/gui/mainwindow.h

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
@ -28,14 +28,19 @@ @@ -28,14 +28,19 @@
* Contact : chris@qbittorrent.org
*/
#ifndef GUI_H
#define GUI_H
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QProcess>
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QPointer>
#include "ui_mainwindow.h"
#include "statsdialog.h"
class QCloseEvent;
class QFileSystemWatcher;
class QShortcut;
class QSplitter;
class QTabWidget;
class QTimer;
class downloadFromURL;
class SearchWidget;
@ -52,34 +57,30 @@ class downloadFromURL; @@ -52,34 +57,30 @@ class downloadFromURL;
class LineEdit;
class ExecutionLog;
class PowerManagement;
QT_BEGIN_NAMESPACE
class QCloseEvent;
class QFileSystemWatcher;
class QShortcut;
class QSplitter;
class QTabWidget;
class QTimer;
QT_END_NAMESPACE
class StatsDialog;
namespace BitTorrent
{
class TorrentHandle;
}
class MainWindow: public QMainWindow, private Ui::MainWindow
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
// Construct / Destruct
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
// Methods
QWidget* getCurrentTabWidget() const;
TransferListWidget* getTransferList() const { return transferList; }
QMenu* getTrayIconMenu();
PropertiesWidget *getProperties() const { return properties; }
~MainWindow() override;
QWidget* currentTabWidget() const;
TransferListWidget* transferListWidget() const;
PropertiesWidget *propertiesWidget() const;
QMenu* trayIconMenu();
// ExecutionLog properties
bool isExecutionLogEnabled() const;
@ -87,32 +88,22 @@ public: @@ -87,32 +88,22 @@ public:
int executionLogMsgTypes() const;
void setExecutionLogMsgTypes(const int value);
public slots:
void trackerAuthenticationRequired(BitTorrent::TorrentHandle *const torrent);
void setTabText(int index, QString text) const;
void showNotificationBaloon(QString title, QString msg) const;
void downloadFromURLList(const QStringList& urls);
void updateAltSpeedsBtn(bool alternative);
void updateNbTorrents();
void activate();
void cleanup();
protected slots:
// GUI related slots
void showNotificationBaloon(QString title, QString msg) const;
private slots:
void toggleVisibility(QSystemTrayIcon::ActivationReason e = QSystemTrayIcon::Trigger);
void on_actionAbout_triggered();
void on_actionStatistics_triggered();
void on_actionCreate_torrent_triggered();
void balloonClicked();
void writeSettings();
void readSettings();
void on_actionExit_triggered();
void createTrayIcon();
void fullDiskError(BitTorrent::TorrentHandle *const torrent, QString msg) const;
void handleDownloadFromUrlFailure(QString, QString) const;
void createSystrayDelayed();
void tab_changed(int);
void on_actionLock_qBittorrent_triggered();
void tabChanged(int newTab);
void defineUILockPassword();
void clearUILockPassword();
bool unlockUI();
@ -125,110 +116,56 @@ protected slots: @@ -125,110 +116,56 @@ protected slots:
void displayTransferTab() const;
void displaySearchTab() const;
void displayRSSTab() const;
// Torrent actions
void on_actionSet_global_upload_limit_triggered();
void on_actionSet_global_download_limit_triggered();
void on_actionDocumentation_triggered() const;
void on_actionOpen_triggered();
void updateGUI();
void loadPreferences(bool configure_session = true);
void loadPreferences(bool configureSession = true);
void addUnauthenticatedTracker(const QPair<BitTorrent::TorrentHandle*, QString> &tracker);
void addTorrentFailed(const QString &error) const;
void finishedTorrent(BitTorrent::TorrentHandle *const torrent) const;
void askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHandle *const torrent);
// Options slots
void on_actionOptions_triggered();
void optionsSaved();
// HTTP slots
void on_actionDownload_from_URL_triggered();
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
void handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser);
void handleUpdateCheckFinished(bool updateAvailable, QString newVersion, bool invokedByUser);
#endif
void updateRSSTabLabel(int count);
protected:
void dropEvent(QDropEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent *);
bool event(QEvent * event);
void displayRSSTab(bool enable);
void displaySearchTab(bool enable);
private:
QIcon getSystrayIcon() const;
#ifdef Q_OS_WIN
bool addPythonPathToEnv();
void installPython();
private slots:
void pythonDownloadSuccess(const QString &url, const QString &filePath);
void pythonDownloadFailure(const QString &url, const QString &error);
#endif
void addToolbarContextMenu();
void manageCookies();
private:
QFileSystemWatcher *executable_watcher;
// Bittorrent
QList<QPair<BitTorrent::TorrentHandle*, QString>> unauthenticated_trackers; // Still needed?
// GUI related
bool m_posInitialized;
QTabWidget *tabs;
StatusBar *status_bar;
QPointer<options_imp> options;
QPointer<about> aboutDlg;
QPointer<StatsDialog> statsDlg;
QPointer<TorrentCreatorDlg> createTorrentDlg;
QPointer<downloadFromURL> downloadFromURLDialog;
QPointer<QSystemTrayIcon> systrayIcon;
QPointer<QTimer> systrayCreator;
QPointer<QMenu> myTrayIconMenu;
TransferListWidget *transferList;
TransferListFiltersWidget *transferListFilters;
PropertiesWidget *properties;
bool displaySpeedInTitle;
bool force_exit;
bool ui_locked;
bool unlockDlgShowing;
LineEdit *search_filter;
QAction *searchFilterAct;
// Widgets
QAction *prioSeparator;
QAction *prioSeparatorMenu;
QSplitter *hSplitter;
QSplitter *vSplitter;
// Search
QPointer<SearchWidget> searchEngine;
// RSS
QPointer<RSSImp> rssWidget;
// Execution Log
QPointer<ExecutionLog> m_executionLog;
// Power Management
PowerManagement *m_pwr;
QTimer *preventTimer;
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
QTimer programUpdateTimer;
bool m_wasUpdateCheckEnabled;
#endif
bool has_python;
QMenu* toolbarMenu;
void trackerAuthenticationRequired(BitTorrent::TorrentHandle *const torrent);
void downloadFromURLList(const QStringList &urlList);
void updateAltSpeedsBtn(bool alternative);
void updateNbTorrents();
private slots:
void on_actionSearch_engine_triggered();
void on_actionRSS_Reader_triggered();
void on_actionSpeed_in_title_bar_triggered();
void on_actionTop_tool_bar_triggered();
void on_action_Import_Torrent_triggered();
void on_actionDonate_money_triggered();
void on_actionSearchWidget_triggered();
void on_actionRSSReader_triggered();
void on_actionSpeedInTitleBar_triggered();
void on_actionTopToolBar_triggered();
void on_actionImportTorrent_triggered();
void on_actionDonateMoney_triggered();
void on_actionExecutionLogs_triggered(bool checked);
void on_actionNormalMessages_triggered(bool checked);
void on_actionInformationMessages_triggered(bool checked);
void on_actionWarningMessages_triggered(bool checked);
void on_actionCriticalMessages_triggered(bool checked);
void on_actionAutoExit_qBittorrent_toggled(bool );
void on_actionAutoSuspend_system_toggled(bool );
void on_actionAutoHibernate_system_toggled(bool );
void on_actionAutoShutdown_system_toggled(bool );
void on_actionAutoExit_toggled(bool);
void on_actionAutoSuspend_toggled(bool);
void on_actionAutoHibernate_toggled(bool);
void on_actionAutoShutdown_toggled(bool);
void on_actionAbout_triggered();
void on_actionStatistics_triggered();
void on_actionCreateTorrent_triggered();
void on_actionOptions_triggered();
void on_actionSetGlobalUploadLimit_triggered();
void on_actionSetGlobalDownloadLimit_triggered();
void on_actionDocumentation_triggered() const;
void on_actionOpen_triggered();
void on_actionDownloadFromURL_triggered();
void on_actionExit_triggered();
void on_actionLock_triggered();
// Check for active torrents and set preventing from suspend state
void checkForActiveTorrents();
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
@ -240,6 +177,64 @@ private slots: @@ -240,6 +177,64 @@ private slots:
void toolbarTextBeside();
void toolbarTextUnder();
void toolbarFollowSystem();
};
private:
QIcon getSystrayIcon() const;
#ifdef Q_OS_WIN
bool addPythonPathToEnv();
void installPython();
#endif
void dropEvent(QDropEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void closeEvent(QCloseEvent *) override;
void showEvent(QShowEvent *) override;
bool event(QEvent * event) override;
void displayRSSTab(bool enable);
void displaySearchTab(bool enable);
Ui::MainWindow *m_ui;
QFileSystemWatcher *m_executableWatcher;
// Bittorrent
QList<QPair<BitTorrent::TorrentHandle*, QString>> m_unauthenticatedTrackers; // Still needed?
// GUI related
bool m_posInitialized;
QTabWidget *m_tabs;
StatusBar *m_statusBar;
QPointer<options_imp> m_options;
QPointer<about> m_aboutDlg;
QPointer<StatsDialog> m_statsDlg;
QPointer<TorrentCreatorDlg> m_createTorrentDlg;
QPointer<downloadFromURL> m_downloadFromURLDialog;
QPointer<QSystemTrayIcon> m_systrayIcon;
QPointer<QTimer> m_systrayCreator;
QPointer<QMenu> m_trayIconMenu;
TransferListWidget *m_transferListWidget;
TransferListFiltersWidget *m_transferListFiltersWidget;
PropertiesWidget *m_propertiesWidget;
bool m_displaySpeedInTitle;
bool m_forceExit;
bool m_uiLocked;
bool m_unlockDlgShowing;
LineEdit *m_searchFilter;
QAction *m_searchFilterAction;
// Widgets
QAction *m_prioSeparator;
QAction *m_prioSeparatorMenu;
QSplitter *m_splitter;
QPointer<SearchWidget> m_searchWidget;
QPointer<RSSImp> m_rssWidget;
QPointer<ExecutionLog> m_executionLog;
// Power Management
PowerManagement *m_pwr;
QTimer *m_preventTimer;
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
QTimer *m_programUpdateTimer;
bool m_wasUpdateCheckEnabled;
#endif
bool m_hasPython;
QMenu *m_toolbarMenu;
};
#endif // MAINWINDOW_H

117
src/gui/mainwindow.ui

@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_Edit">
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>&amp;Edit</string>
</property>
@ -51,43 +51,44 @@ @@ -51,43 +51,44 @@
<addaction name="actionDecreasePriority"/>
<addaction name="actionBottomPriority"/>
</widget>
<widget class="QMenu" name="menu_Help">
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>&amp;Help</string>
</property>
<addaction name="actionDocumentation"/>
<addaction name="actionCheck_for_updates"/>
<addaction name="actionCheckForUpdates"/>
<addaction name="separator"/>
<addaction name="actionDonate_money"/>
<addaction name="actionDonateMoney"/>
<addaction name="actionAbout"/>
</widget>
<widget class="QMenu" name="menu_Options">
<widget class="QMenu" name="menuOptions">
<property name="title">
<string>&amp;Tools</string>
</property>
<widget class="QMenu" name="menuAuto_Shutdown_on_downloads_completion">
<widget class="QMenu" name="menuAutoShutdownOnDownloadsCompletion">
<property name="title">
<string>On Downloads &amp;Done</string>
</property>
<addaction name="actionAutoShutdown_Disabled"/>
<addaction name="actionAutoExit_qBittorrent"/>
<addaction name="actionAutoSuspend_system"/>
<addaction name="actionAutoHibernate_system"/>
<addaction name="actionAutoShutdown_system"/>
<addaction name="actionAutoShutdownDisabled"/>
<addaction name="actionAutoExit"/>
<addaction name="actionAutoSuspend"/>
<addaction name="actionAutoHibernate"/>
<addaction name="actionAutoShutdown"/>
</widget>
<addaction name="actionCreate_torrent"/>
<addaction name="actionCreateTorrent"/>
<addaction name="separator"/>
<addaction name="actionManageCookies"/>
<addaction name="actionOptions"/>
<addaction name="separator"/>
<addaction name="menuAuto_Shutdown_on_downloads_completion"/>
<addaction name="menuAutoShutdownOnDownloadsCompletion"/>
</widget>
<widget class="QMenu" name="menu_File">
<widget class="QMenu" name="menuFile">
<property name="title">
<string>&amp;File</string>
</property>
<addaction name="actionOpen"/>
<addaction name="actionDownload_from_URL"/>
<addaction name="action_Import_Torrent"/>
<addaction name="actionDownloadFromURL"/>
<addaction name="actionImportTorrent"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
@ -106,22 +107,25 @@ @@ -106,22 +107,25 @@
<addaction name="actionWarningMessages"/>
<addaction name="actionCriticalMessages"/>
</widget>
<addaction name="actionTop_tool_bar"/>
<addaction name="actionSpeed_in_title_bar"/>
<addaction name="separator"/>
<addaction name="actionSearch_engine"/>
<addaction name="actionRSS_Reader"/>
<addaction name="menuLog"/>
<addaction name="actionTopToolBar"/>
<addaction name="actionSpeedInTitleBar"/>
<addaction name="separator"/>
<addaction name="actionSearchWidget"/>
<addaction name="actionRSSReader"/>
<addaction name="separator"/>
<addaction name="actionStatistics"/>
<addaction name="separator"/>
<addaction name="actionLock_qBittorrent"/>
<addaction name="actionLock"/>
</widget>
<addaction name="menu_File"/>
<addaction name="menu_Edit"/>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuView"/>
<addaction name="menu_Options"/>
<addaction name="menu_Help"/>
<addaction name="menuOptions"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="movable">
@ -142,7 +146,7 @@ @@ -142,7 +146,7 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionDownload_from_URL"/>
<addaction name="actionDownloadFromURL"/>
<addaction name="actionOpen"/>
<addaction name="actionDelete"/>
<addaction name="separator"/>
@ -154,7 +158,7 @@ @@ -154,7 +158,7 @@
<addaction name="actionBottomPriority"/>
<addaction name="separator"/>
<addaction name="actionOptions"/>
<addaction name="actionLock_qBittorrent"/>
<addaction name="actionLock"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionOpen">
@ -195,7 +199,7 @@ @@ -195,7 +199,7 @@
<string>&amp;Delete</string>
</property>
</action>
<action name="actionDownload_from_URL">
<action name="actionDownloadFromURL">
<property name="text">
<string>Add Torrent &amp;Link...</string>
</property>
@ -203,17 +207,17 @@ @@ -203,17 +207,17 @@
<string>Open URL</string>
</property>
</action>
<action name="actionCreate_torrent">
<action name="actionCreateTorrent">
<property name="text">
<string>Torrent &amp;Creator</string>
</property>
</action>
<action name="actionSet_upload_limit">
<action name="actionSetUploadLimit">
<property name="text">
<string>Set Upload Limit...</string>
</property>
</action>
<action name="actionSet_download_limit">
<action name="actionSetDownloadLimit">
<property name="text">
<string>Set Download Limit...</string>
</property>
@ -223,12 +227,12 @@ @@ -223,12 +227,12 @@
<string>&amp;Documentation</string>
</property>
</action>
<action name="actionSet_global_download_limit">
<action name="actionSetGlobalDownloadLimit">
<property name="text">
<string>Set Global Download Limit...</string>
</property>
</action>
<action name="actionSet_global_upload_limit">
<action name="actionSetGlobalUploadLimit">
<property name="text">
<string>Set Global Upload Limit...</string>
</property>
@ -265,7 +269,7 @@ @@ -265,7 +269,7 @@
<bool>true</bool>
</property>
</action>
<action name="actionUse_alternative_speed_limits">
<action name="actionUseAlternativeSpeedLimits">
<property name="checkable">
<bool>true</bool>
</property>
@ -276,7 +280,7 @@ @@ -276,7 +280,7 @@
<string>Alternative Speed Limits</string>
</property>
</action>
<action name="actionTop_tool_bar">
<action name="actionTopToolBar">
<property name="checkable">
<bool>true</bool>
</property>
@ -287,7 +291,7 @@ @@ -287,7 +291,7 @@
<string>Display Top Toolbar</string>
</property>
</action>
<action name="actionSpeed_in_title_bar">
<action name="actionSpeedInTitleBar">
<property name="checkable">
<bool>true</bool>
</property>
@ -298,7 +302,7 @@ @@ -298,7 +302,7 @@
<string>Show Transfer Speed in Title Bar</string>
</property>
</action>
<action name="actionRSS_Reader">
<action name="actionRSSReader">
<property name="checkable">
<bool>true</bool>
</property>
@ -306,7 +310,7 @@ @@ -306,7 +310,7 @@
<string>&amp;RSS Reader</string>
</property>
</action>
<action name="actionSearch_engine">
<action name="actionSearchWidget">
<property name="checkable">
<bool>true</bool>
</property>
@ -314,7 +318,7 @@ @@ -314,7 +318,7 @@
<string>Search &amp;Engine</string>
</property>
</action>
<action name="actionLock_qBittorrent">
<action name="actionLock">
<property name="text">
<string>L&amp;ock qBittorrent</string>
</property>
@ -325,7 +329,7 @@ @@ -325,7 +329,7 @@
<string notr="true">Ctrl+L</string>
</property>
</action>
<action name="action_Import_Torrent">
<action name="actionImportTorrent">
<property name="text">
<string>&amp;Import Existing Torrent...</string>
</property>
@ -333,7 +337,7 @@ @@ -333,7 +337,7 @@
<string>Import Torrent...</string>
</property>
</action>
<action name="actionDonate_money">
<action name="actionDonateMoney">
<property name="text">
<string>Do&amp;nate!</string>
</property>
@ -341,17 +345,28 @@ @@ -341,17 +345,28 @@
<string>If you like qBittorrent, please donate!</string>
</property>
</action>
<action name="actionStart_All">
<action name="actionStartAll">
<property name="text">
<string>R&amp;esume All</string>
</property>
</action>
<action name="actionPause_All">
<action name="actionPauseAll">
<property name="text">
<string>P&amp;ause All</string>
</property>
</action>
<action name="actionAutoExit_qBittorrent">
<action name="actionExecutionLogs">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Log</string>
</property>
<property name="toolTip">
<string>Execution Log</string>
</property>
</action>
<action name="actionAutoExit">
<property name="checkable">
<bool>true</bool>
</property>
@ -359,7 +374,7 @@ @@ -359,7 +374,7 @@
<string>&amp;Exit qBittorrent</string>
</property>
</action>
<action name="actionAutoSuspend_system">
<action name="actionAutoSuspend">
<property name="checkable">
<bool>true</bool>
</property>
@ -367,7 +382,7 @@ @@ -367,7 +382,7 @@
<string>&amp;Suspend System</string>
</property>
</action>
<action name="actionAutoHibernate_system">
<action name="actionAutoHibernate">
<property name="checkable">
<bool>true</bool>
</property>
@ -375,7 +390,7 @@ @@ -375,7 +390,7 @@
<string>&amp;Hibernate System</string>
</property>
</action>
<action name="actionAutoShutdown_system">
<action name="actionAutoShutdown">
<property name="checkable">
<bool>true</bool>
</property>
@ -383,7 +398,7 @@ @@ -383,7 +398,7 @@
<string>S&amp;hutdown System</string>
</property>
</action>
<action name="actionAutoShutdown_Disabled">
<action name="actionAutoShutdownDisabled">
<property name="checkable">
<bool>true</bool>
</property>
@ -406,7 +421,7 @@ @@ -406,7 +421,7 @@
<string>&amp;Statistics</string>
</property>
</action>
<action name="actionCheck_for_updates">
<action name="actionCheckForUpdates">
<property name="text">
<string>Check for Updates</string>
</property>
@ -414,6 +429,14 @@ @@ -414,6 +429,14 @@
<string>Check for Program Updates</string>
</property>
</action>
<action name="actionManageCookies">
<property name="text">
<string>Manage Cookies...</string>
</property>
<property name="toolTip">
<string>Manage stored network cookies</string>
</property>
</action>
<action name="actionExecutionLogs">
<property name="checkable">
<bool>true</bool>

2
src/gui/properties/propertieswidget.cpp

@ -373,7 +373,7 @@ void PropertiesWidget::reloadPreferences() { @@ -373,7 +373,7 @@ void PropertiesWidget::reloadPreferences() {
void PropertiesWidget::loadDynamicData() {
// Refresh only if the torrent handle is valid and if visible
if (!m_torrent || (main_window->getCurrentTabWidget() != transferList) || (state != VISIBLE)) return;
if (!m_torrent || (main_window->currentTabWidget() != transferList) || (state != VISIBLE)) return;
// Transfer infos
switch(stackedProperties->currentIndex()) {

110
src/gui/rss/cookiesdlg.cpp

@ -1,110 +0,0 @@ @@ -1,110 +0,0 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2010 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org arnaud@qbittorrent.org
*/
#include "cookiesdlg.h"
#include "ui_cookiesdlg.h"
#include "guiiconprovider.h"
#include "base/net/downloadmanager.h"
#include <QNetworkCookie>
#include <QDateTime>
enum CookiesCols { COOKIE_KEY, COOKIE_VALUE};
CookiesDlg::CookiesDlg(const QUrl &url, QWidget *parent) :
QDialog(parent),
ui(new Ui::CookiesDlg)
{
ui->setupUi(this);
// Icons
ui->add_btn->setIcon(GuiIconProvider::instance()->getIcon("list-add"));
ui->del_btn->setIcon(GuiIconProvider::instance()->getIcon("list-remove"));
ui->infos_lbl->setText(tr("Common keys for cookies are: '%1', '%2'.\nYou should get this information from your Web browser preferences.").arg("uid").arg("pass"));
QList<QNetworkCookie> cookies = Net::DownloadManager::instance()->cookiesForUrl(url);
foreach (const QNetworkCookie &cookie, cookies) {
const int i = ui->cookiesTable->rowCount();
ui->cookiesTable->setRowCount(i+1);
ui->cookiesTable->setItem(i, COOKIE_KEY, new QTableWidgetItem(QString(cookie.name())));
ui->cookiesTable->setItem(i, COOKIE_VALUE, new QTableWidgetItem(QString(cookie.value())));
}
}
CookiesDlg::~CookiesDlg()
{
delete ui;
}
void CookiesDlg::on_add_btn_clicked() {
ui->cookiesTable->setRowCount(ui->cookiesTable->rowCount()+1);
// Edit first column
ui->cookiesTable->editItem(ui->cookiesTable->item(ui->cookiesTable->rowCount()-1, COOKIE_KEY));
}
void CookiesDlg::on_del_btn_clicked() {
// Get selected cookie
QList<QTableWidgetItem*> selection = ui->cookiesTable->selectedItems();
if (!selection.isEmpty()) {
ui->cookiesTable->removeRow(selection.first()->row());
}
}
QList<QNetworkCookie> CookiesDlg::getCookies() const {
QList<QNetworkCookie> ret;
auto now = QDateTime::currentDateTime();
for (int i=0; i<ui->cookiesTable->rowCount(); ++i) {
QString key;
if (ui->cookiesTable->item(i, COOKIE_KEY))
key = ui->cookiesTable->item(i, COOKIE_KEY)->text().trimmed();
QString value;
if (ui->cookiesTable->item(i, COOKIE_VALUE))
value = ui->cookiesTable->item(i, COOKIE_VALUE)->text().trimmed();
if (!key.isEmpty() && !value.isEmpty()) {
QNetworkCookie cookie(key.toUtf8(), value.toUtf8());
// TODO: Delete this hack when advanced Cookie dialog will be implemented.
cookie.setExpirationDate(now.addYears(10));
qDebug("Cookie: %s", cookie.toRawForm().data());
ret << cookie;
}
}
return ret;
}
bool CookiesDlg::askForCookies(QWidget *parent, const QUrl &url, QList<QNetworkCookie> &out)
{
CookiesDlg dlg(url, parent);
if (dlg.exec()) {
out = dlg.getCookies();
return true;
}
return false;
}

172
src/gui/rss/cookiesdlg.ui

@ -1,172 +0,0 @@ @@ -1,172 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CookiesDlg</class>
<widget class="QDialog" name="CookiesDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Cookies management</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTableWidget" name="cookiesTable">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderStretchLastSection">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string extracomment="As in Key/Value pair">Key</string>
</property>
</column>
<column>
<property name="text">
<string extracomment="As in Key/Value pair">Value</string>
</property>
</column>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="add_btn">
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="del_btn">
<property name="text">
<string notr="true"/>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="infos_lbl">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CookiesDlg</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CookiesDlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

5
src/gui/rss/rss.pri

@ -4,17 +4,14 @@ HEADERS += $$PWD/rss_imp.h \ @@ -4,17 +4,14 @@ HEADERS += $$PWD/rss_imp.h \
$$PWD/rsssettingsdlg.h \
$$PWD/feedlistwidget.h \
$$PWD/automatedrssdownloader.h \
$$PWD/cookiesdlg.h \
$$PWD/htmlbrowser.h
SOURCES += $$PWD/rss_imp.cpp \
$$PWD/rsssettingsdlg.cpp \
$$PWD/feedlistwidget.cpp \
$$PWD/automatedrssdownloader.cpp \
$$PWD/cookiesdlg.cpp \
$$PWD/htmlbrowser.cpp
FORMS += $$PWD/rss.ui \
$$PWD/rsssettingsdlg.ui \
$$PWD/automatedrssdownloader.ui \
$$PWD/cookiesdlg.ui
$$PWD/automatedrssdownloader.ui

5
src/gui/rss/rss.ui

@ -197,11 +197,6 @@ @@ -197,11 +197,6 @@
<string>New folder...</string>
</property>
</action>
<action name="actionManage_cookies">
<property name="text">
<string>Manage cookies...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

23
src/gui/rss/rss_imp.cpp

@ -41,7 +41,6 @@ @@ -41,7 +41,6 @@
#include "feedlistwidget.h"
#include "base/bittorrent/session.h"
#include "base/net/downloadmanager.h"
#include "cookiesdlg.h"
#include "base/preferences.h"
#include "rsssettingsdlg.h"
#include "base/rss/rssmanager.h"
@ -84,8 +83,6 @@ void RSSImp::displayRSSListMenu(const QPoint& pos) @@ -84,8 +83,6 @@ void RSSImp::displayRSSListMenu(const QPoint& pos)
myRSSListMenu.addSeparator();
if (m_feedList->isFolder(selectedItems.first()))
myRSSListMenu.addAction(actionNew_folder);
else
myRSSListMenu.addAction(actionManage_cookies);
}
}
else {
@ -138,25 +135,6 @@ void RSSImp::displayItemsListMenu(const QPoint&) @@ -138,25 +135,6 @@ void RSSImp::displayItemsListMenu(const QPoint&)
myItemListMenu.exec(QCursor::pos());
}
void RSSImp::on_actionManage_cookies_triggered()
{
Q_ASSERT(!m_feedList->selectedItems().empty());
// TODO: Create advanced application wide Cookie dialog and use it everywhere.
QUrl feedUrl = QUrl::fromEncoded(m_feedList->getItemID(m_feedList->selectedItems().first()).toUtf8());
QList<QNetworkCookie> cookies;
if (CookiesDlg::askForCookies(this, feedUrl, cookies)) {
auto downloadManager = Net::DownloadManager::instance();
QList<QNetworkCookie> oldCookies = downloadManager->cookiesForUrl(feedUrl);
foreach (const QNetworkCookie &oldCookie, oldCookies) {
if (!cookies.contains(oldCookie))
downloadManager->deleteCookie(oldCookie);
}
downloadManager->setCookiesFromUrl(cookies, feedUrl);
}
}
void RSSImp::askNewFolder()
{
QTreeWidgetItem* parent_item = 0;
@ -713,7 +691,6 @@ RSSImp::RSSImp(QWidget *parent): @@ -713,7 +691,6 @@ RSSImp::RSSImp(QWidget *parent):
actionCopy_feed_URL->setIcon(GuiIconProvider::instance()->getIcon("edit-copy"));
actionDelete->setIcon(GuiIconProvider::instance()->getIcon("edit-delete"));
actionDownload_torrent->setIcon(GuiIconProvider::instance()->getIcon("download"));
actionManage_cookies->setIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies"));
actionMark_items_read->setIcon(GuiIconProvider::instance()->getIcon("mail-mark-read"));
actionNew_folder->setIcon(GuiIconProvider::instance()->getIcon("folder-new"));
actionNew_subscription->setIcon(GuiIconProvider::instance()->getIcon("list-add"));

1
src/gui/rss/rss_imp.h

@ -84,7 +84,6 @@ private slots: @@ -84,7 +84,6 @@ private slots:
void askNewFolder();
void saveFoldersOpenState();
void loadFoldersOpenState();
void on_actionManage_cookies_triggered();
void on_settingsButton_clicked();
void on_rssDownloaderBtn_clicked();

4
src/gui/search/searchwidget.cpp

@ -301,7 +301,7 @@ void SearchWidget::searchStarted() @@ -301,7 +301,7 @@ void SearchWidget::searchStarted()
// Error | Stopped by user | Finished normally
void SearchWidget::searchFinished(bool cancelled)
{
if (Preferences::instance()->useProgramNotification() && (m_mainWindow->getCurrentTabWidget() != this))
if (Preferences::instance()->useProgramNotification() && (m_mainWindow->currentTabWidget() != this))
m_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
if (m_activeSearchTab.isNull()) return; // The active tab was closed
@ -319,7 +319,7 @@ void SearchWidget::searchFinished(bool cancelled) @@ -319,7 +319,7 @@ void SearchWidget::searchFinished(bool cancelled)
void SearchWidget::searchFailed()
{
if (Preferences::instance()->useProgramNotification() && (m_mainWindow->getCurrentTabWidget() != this))
if (Preferences::instance()->useProgramNotification() && (m_mainWindow->currentTabWidget() != this))
m_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has failed"));
if (m_activeSearchTab.isNull()) return; // The active tab was closed

10
src/gui/transferlistwidget.cpp

@ -311,7 +311,7 @@ void TransferListWidget::pauseVisibleTorrents() @@ -311,7 +311,7 @@ void TransferListWidget::pauseVisibleTorrents()
void TransferListWidget::deleteSelectedTorrents()
{
if (main_window->getCurrentTabWidget() != this) return;
if (main_window->currentTabWidget() != this) return;
const QList<BitTorrent::TorrentHandle *> torrents = getSelectedTorrents();
if (torrents.empty()) return;
@ -343,26 +343,26 @@ void TransferListWidget::deleteVisibleTorrents() @@ -343,26 +343,26 @@ void TransferListWidget::deleteVisibleTorrents()
void TransferListWidget::increasePrioSelectedTorrents()
{
qDebug() << Q_FUNC_INFO;
if (main_window->getCurrentTabWidget() == this)
if (main_window->currentTabWidget() == this)
BitTorrent::Session::instance()->increaseTorrentsPriority(extractHashes(getSelectedTorrents()));
}
void TransferListWidget::decreasePrioSelectedTorrents()
{
qDebug() << Q_FUNC_INFO;
if (main_window->getCurrentTabWidget() == this)
if (main_window->currentTabWidget() == this)
BitTorrent::Session::instance()->decreaseTorrentsPriority(extractHashes(getSelectedTorrents()));
}
void TransferListWidget::topPrioSelectedTorrents()
{
if (main_window->getCurrentTabWidget() == this)
if (main_window->currentTabWidget() == this)
BitTorrent::Session::instance()->topTorrentsPriority(extractHashes(getSelectedTorrents()));
}
void TransferListWidget::bottomPrioSelectedTorrents()
{
if (main_window->getCurrentTabWidget() == this)
if (main_window->currentTabWidget() == this)
BitTorrent::Session::instance()->bottomTorrentsPriority(extractHashes(getSelectedTorrents()));
}

Loading…
Cancel
Save