Vladimir Golovnev (Glassez)
9 years ago
9 changed files with 369 additions and 3 deletions
@ -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()); |
||||
} |
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 COOKIESDIALOG_H |
||||
#define COOKIESDIALOG_H |
||||
|
||||
#include <QDialog> |
||||
|
||||
namespace Ui |
||||
{ |
||||
class CookiesDialog; |
||||
} |
||||
|
||||
class CookiesModel; |
||||
|
||||
class CookiesDialog : public QDialog |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
explicit CookiesDialog(QWidget *parent = 0); |
||||
~CookiesDialog(); |
||||
|
||||
public slots: |
||||
void accept() override; |
||||
|
||||
private slots: |
||||
void onButtonAddClicked(); |
||||
void onButtonDeleteClicked(); |
||||
|
||||
private: |
||||
Ui::CookiesDialog *m_ui; |
||||
CookiesModel *m_cookiesModel; |
||||
}; |
||||
|
||||
#endif // COOKIESDIALOG_H
|
@ -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> |
Loading…
Reference in new issue