aboutsummaryrefslogtreecommitdiff
path: root/src/forms
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-03-20 18:44:46 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-03-20 18:44:46 +0100
commitda688a422ec94e342467f102c3361c0be3d7fd44 (patch)
treeabf72b532c621ddc64aa22791a67eff7f5880e1b /src/forms
parentFixed bug where the BookmarksWidget was not re-openable (diff)
downloadsmolbote-da688a422ec94e342467f102c3361c0be3d7fd44.tar.xz
Dockable DownloadsWidget
Diffstat (limited to 'src/forms')
-rw-r--r--src/forms/bookmarkswidget.cpp29
-rw-r--r--src/forms/bookmarkswidget.h16
-rw-r--r--src/forms/downloaddialog.ui134
-rw-r--r--src/forms/downloadsform.ui81
-rw-r--r--src/forms/downloadswidget.cpp (renamed from src/forms/downloaddialog.cpp)20
-rw-r--r--src/forms/downloadswidget.h (renamed from src/forms/downloaddialog.h)8
6 files changed, 99 insertions, 189 deletions
diff --git a/src/forms/bookmarkswidget.cpp b/src/forms/bookmarkswidget.cpp
index ee945cb..63062a2 100644
--- a/src/forms/bookmarkswidget.cpp
+++ b/src/forms/bookmarkswidget.cpp
@@ -23,19 +23,8 @@
#include "browser.h"
#include <QTreeWidget>
-DockWidget::DockWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags) :
- QDockWidget(title, parent, flags)
-{
-}
-
-void DockWidget::closeEvent(QCloseEvent *event)
-{
- setParent(0);
- event->ignore();
-}
-
BookmarksWidget::BookmarksWidget(QWidget *parent) :
- QWidget(parent),
+ DockingWidget(tr("Bookmarks"), parent),
ui(new Ui::BookmarksDialog)
{
// make sure this dialog does not get deleted on close
@@ -44,11 +33,6 @@ BookmarksWidget::BookmarksWidget(QWidget *parent) :
ui->setupUi(this);
ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
- window = nullptr;
- dock = new DockWidget(tr("Bookmarks"), 0);
- dock->setWidget(this);
- dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
-
QStyle *style = ui->treeWidget->style();
ui->addFolder_toolButton->setIcon(style->standardPixmap(QStyle::SP_DirIcon));
ui->addBookmark_toolButton->setIcon(style->standardPixmap(QStyle::SP_FileIcon));
@@ -91,17 +75,8 @@ void BookmarksWidget::show()
{
// show() gets called by a QAction in MainWindow
window = qobject_cast<MainWindow *>(sender()->parent());
- if(window) {
-
- // dockable widgets
- dock->setParent(window);
- window->addDockWidget(Qt::RightDockWidgetArea, dock);
-
- } else {
- qWarning("BookmarksWidget not called by MainWindow");
- }
- QWidget::show();
+ DockingWidget::show();
}
void BookmarksWidget::deleteCurrentItem()
diff --git a/src/forms/bookmarkswidget.h b/src/forms/bookmarkswidget.h
index ca0889b..19c49e5 100644
--- a/src/forms/bookmarkswidget.h
+++ b/src/forms/bookmarkswidget.h
@@ -21,27 +21,16 @@
#ifndef BOOKMARKSDIALOG_H
#define BOOKMARKSDIALOG_H
-#include <QWidget>
+#include "widgets/dockingwidget.h"
#include <QDockWidget>
#include "xbel.h"
#include "mainwindow.h"
-class DockWidget : public QDockWidget
-{
- Q_OBJECT
-
-public:
- explicit DockWidget(const QString &title, QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
-
-protected:
- void closeEvent(QCloseEvent *event);
-};
-
namespace Ui {
class BookmarksDialog;
}
-class BookmarksWidget : public QWidget
+class BookmarksWidget : public DockingWidget
{
Q_OBJECT
@@ -65,7 +54,6 @@ private slots:
private:
MainWindow *window;
- DockWidget *dock;
Ui::BookmarksDialog *ui;
Xbel *xbel;
};
diff --git a/src/forms/downloaddialog.ui b/src/forms/downloaddialog.ui
deleted file mode 100644
index 2e21106..0000000
--- a/src/forms/downloaddialog.ui
+++ /dev/null
@@ -1,134 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>DownloadDialog</class>
- <widget class="QDialog" name="DownloadDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>820</width>
- <height>480</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Downloads</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QListWidget" name="listWidget"/>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox">
- <property name="minimumSize">
- <size>
- <width>250</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>250</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="title">
- <string>Details</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
- <widget class="QLabel" name="mimeType">
- <property name="text">
- <string>Type</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="mimeType_label">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="filePath">
- <property name="text">
- <string>Path</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="fileSize">
- <property name="text">
- <string>Size</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="fileSize_label">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLabel" name="filePath_label">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Close</set>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>DownloadDialog</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>DownloadDialog</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>
diff --git a/src/forms/downloadsform.ui b/src/forms/downloadsform.ui
new file mode 100644
index 0000000..5ab770f
--- /dev/null
+++ b/src/forms/downloadsform.ui
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DownloadDialog</class>
+ <widget class="QWidget" name="DownloadDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>420</width>
+ <height>600</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>420</width>
+ <height>600</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Downloads</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QListWidget" name="listWidget"/>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Details</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="mimeType">
+ <property name="text">
+ <string>Type</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="mimeType_label">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="filePath">
+ <property name="text">
+ <string>Path</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="fileSize">
+ <property name="text">
+ <string>Size</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="fileSize_label">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="filePath_label">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/forms/downloaddialog.cpp b/src/forms/downloadswidget.cpp
index d182076..45c458d 100644
--- a/src/forms/downloaddialog.cpp
+++ b/src/forms/downloadswidget.cpp
@@ -18,19 +18,19 @@
**
******************************************************************************/
-#include "downloaddialog.h"
-#include "ui_downloaddialog.h"
+#include "downloadswidget.h"
+#include "ui_downloadsform.h"
#include <QWebEngineDownloadItem>
#include <QUrl>
#include <QFileDialog>
#include <QListWidget>
#include <QLabel>
-#include "webengine/downloaditemform.h"
+#include "widgets/downloaditemwidget.h"
#include "browser.h"
-DownloadDialog::DownloadDialog(QWidget *parent) :
- QDialog(parent),
+DownloadsWidget::DownloadsWidget(QWidget *parent) :
+ DockingWidget(tr("Downloads"), parent),
ui(new Ui::DownloadDialog)
{
ui->setupUi(this);
@@ -39,12 +39,12 @@ DownloadDialog::DownloadDialog(QWidget *parent) :
connect(ui->listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(showItemDetails(int)));
}
-DownloadDialog::~DownloadDialog()
+DownloadsWidget::~DownloadsWidget()
{
delete ui;
}
-void DownloadDialog::addDownload(QWebEngineDownloadItem *item)
+void DownloadsWidget::addDownload(QWebEngineDownloadItem *item)
{
QString filepath = QFileDialog::getSaveFileName(this, tr("Save"), sSettings->value("downloads.path").toString() + "/" + QFileInfo(item->path()).fileName());
@@ -60,7 +60,7 @@ void DownloadDialog::addDownload(QWebEngineDownloadItem *item)
int rowIndex = ui->listWidget->count();
ui->listWidget->insertItem(rowIndex, listItem);
- DownloadItemForm *form = new DownloadItemForm(item, this);
+ DownloadItemWidget *form = new DownloadItemWidget(item, this);
listItem->setSizeHint(form->size());
ui->listWidget->setItemWidget(listItem, form);
@@ -68,9 +68,9 @@ void DownloadDialog::addDownload(QWebEngineDownloadItem *item)
this->show();
}
-void DownloadDialog::showItemDetails(int index)
+void DownloadsWidget::showItemDetails(int index)
{
- DownloadItemForm *form = qobject_cast<DownloadItemForm *>(ui->listWidget->itemWidget(ui->listWidget->item(index)));
+ DownloadItemWidget *form = qobject_cast<DownloadItemWidget *>(ui->listWidget->itemWidget(ui->listWidget->item(index)));
ui->mimeType_label->setText(form->item()->mimeType());
ui->filePath_label->setText(form->item()->path());
ui->fileSize_label->setText(QString("%1 bytes").arg(form->item()->totalBytes()));
diff --git a/src/forms/downloaddialog.h b/src/forms/downloadswidget.h
index 9a74cf0..1ae29ee 100644
--- a/src/forms/downloaddialog.h
+++ b/src/forms/downloadswidget.h
@@ -21,20 +21,20 @@
#ifndef DOWNLOADDIALOG_H
#define DOWNLOADDIALOG_H
-#include <QDialog>
+#include "widgets/dockingwidget.h"
namespace Ui {
class DownloadDialog;
}
class QWebEngineDownloadItem;
-class DownloadDialog : public QDialog
+class DownloadsWidget : public DockingWidget
{
Q_OBJECT
public:
- explicit DownloadDialog(QWidget *parent = 0);
- ~DownloadDialog();
+ explicit DownloadsWidget(QWidget *parent = 0);
+ ~DownloadsWidget();
public slots:
void addDownload(QWebEngineDownloadItem *item);