aboutsummaryrefslogtreecommitdiff
path: root/src/forms
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-03-20 16:27:03 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-03-20 16:27:03 +0100
commit32693ab1efcd708f0eba06c33fb5b52a59fd377b (patch)
treeafc64b7f89d7880825d89d860dc30e2c05393936 /src/forms
parentDockable bookmarks dialog (diff)
downloadsmolbote-32693ab1efcd708f0eba06c33fb5b52a59fd377b.tar.xz
Fixed opening bookmarks with multiple windows
Diffstat (limited to 'src/forms')
-rw-r--r--src/forms/bookmarksdialog.ui118
-rw-r--r--src/forms/bookmarksform.ui104
-rw-r--r--src/forms/bookmarkswidget.cpp (renamed from src/forms/bookmarksdialog.cpp)50
-rw-r--r--src/forms/bookmarkswidget.h (renamed from src/forms/bookmarksdialog.h)12
4 files changed, 140 insertions, 144 deletions
diff --git a/src/forms/bookmarksdialog.ui b/src/forms/bookmarksdialog.ui
deleted file mode 100644
index f528528..0000000
--- a/src/forms/bookmarksdialog.ui
+++ /dev/null
@@ -1,118 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>BookmarksDialog</class>
- <widget class="QDialog" name="BookmarksDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>820</width>
- <height>480</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Bookmarks</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QTreeWidget" name="treeWidget">
- <property name="dragEnabled">
- <bool>true</bool>
- </property>
- <property name="dragDropMode">
- <enum>QAbstractItemView::InternalMove</enum>
- </property>
- <property name="defaultDropAction">
- <enum>Qt::MoveAction</enum>
- </property>
- <column>
- <property name="text">
- <string notr="true">Title</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>href</string>
- </property>
- </column>
- </widget>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QToolButton" name="addFolder_toolButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="addBookmark_toolButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="addSeparator_toolButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="deleteItem_toolButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
- </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="1" column="0">
- <widget class="QLabel" name="href_label">
- <property name="text">
- <string>href</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="href_lineEdit"/>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="title_lineEdit"/>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/forms/bookmarksform.ui b/src/forms/bookmarksform.ui
new file mode 100644
index 0000000..2df0c4b
--- /dev/null
+++ b/src/forms/bookmarksform.ui
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>BookmarksDialog</class>
+ <widget class="QWidget" name="BookmarksDialog">
+ <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>Bookmarks</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QToolButton" name="addFolder_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="addBookmark_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="addSeparator_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="deleteItem_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="treeWidget">
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::InternalMove</enum>
+ </property>
+ <property name="defaultDropAction">
+ <enum>Qt::MoveAction</enum>
+ </property>
+ <column>
+ <property name="text">
+ <string notr="true">Title</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>href</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Details</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="href_label">
+ <property name="text">
+ <string>href</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="href_lineEdit"/>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="title_lineEdit"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/forms/bookmarksdialog.cpp b/src/forms/bookmarkswidget.cpp
index becac56..8985fff 100644
--- a/src/forms/bookmarksdialog.cpp
+++ b/src/forms/bookmarkswidget.cpp
@@ -18,14 +18,13 @@
**
******************************************************************************/
-#include "bookmarksdialog.h"
-#include "ui_bookmarksdialog.h"
+#include "bookmarkswidget.h"
+#include "ui_bookmarksform.h"
#include "browser.h"
#include <QTreeWidget>
-#include <QDockWidget>
-BookmarksDialog::BookmarksDialog(QWidget *parent) :
- QDialog(parent),
+BookmarksWidget::BookmarksWidget(QWidget *parent) :
+ QWidget(parent),
ui(new Ui::BookmarksDialog)
{
// make sure this dialog does not get deleted on close
@@ -34,6 +33,11 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) :
ui->setupUi(this);
ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
+ window = nullptr;
+ dock = new QDockWidget(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));
@@ -60,7 +64,7 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) :
});
}
-BookmarksDialog::~BookmarksDialog()
+BookmarksWidget::~BookmarksWidget()
{
qDebug("Destroying BookmarksManager");
@@ -72,36 +76,40 @@ BookmarksDialog::~BookmarksDialog()
delete ui;
}
-void BookmarksDialog::show()
+void BookmarksWidget::show()
{
- // show() is called by a QAction in MainWindow
- w = qobject_cast<MainWindow *>(sender()->parent());
+ // 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);
- // dockable widgets
- QDockWidget *bookmarksDock = new QDockWidget(tr("Bookmarks"), w);
- bookmarksDock->setWidget(this);
- bookmarksDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
- w->addDockWidget(Qt::RightDockWidgetArea, bookmarksDock);
- bookmarksDock->setFloating(true);
+ } else {
+ qWarning("BookmarksWidget not called by MainWindow");
+ }
- QDialog::show();
+ QWidget::show();
}
-void BookmarksDialog::deleteCurrentItem()
+void BookmarksWidget::deleteCurrentItem()
{
delete ui->treeWidget->currentItem();
}
-void BookmarksDialog::openItem(QTreeWidgetItem *item, int column)
+void BookmarksWidget::openItem(QTreeWidgetItem *item, int column)
{
Q_UNUSED(column)
- if(w) {
- w->addNewTab(QUrl::fromUserInput(item->text(1)));
+ if(window) {
+ window->addNewTab(QUrl::fromUserInput(item->text(1)));
+ } else {
+ qWarning("Trying to open a link without a MainWindow set");
}
}
-void BookmarksDialog::showItemDetails()
+void BookmarksWidget::showItemDetails()
{
QTreeWidgetItem *item = ui->treeWidget->currentItem();
if(!item) {
diff --git a/src/forms/bookmarksdialog.h b/src/forms/bookmarkswidget.h
index 0fcab42..9164079 100644
--- a/src/forms/bookmarksdialog.h
+++ b/src/forms/bookmarkswidget.h
@@ -21,7 +21,8 @@
#ifndef BOOKMARKSDIALOG_H
#define BOOKMARKSDIALOG_H
-#include <QDialog>
+#include <QWidget>
+#include <QDockWidget>
#include "xbel.h"
#include "mainwindow.h"
@@ -29,13 +30,13 @@ namespace Ui {
class BookmarksDialog;
}
-class BookmarksDialog : public QDialog
+class BookmarksWidget : public QWidget
{
Q_OBJECT
public:
- explicit BookmarksDialog(QWidget *parent = 0);
- ~BookmarksDialog();
+ explicit BookmarksWidget(QWidget *parent = 0);
+ ~BookmarksWidget();
signals:
void openUrl(const QUrl &url);
@@ -52,7 +53,8 @@ private slots:
void showItemDetails();
private:
- MainWindow *w;
+ MainWindow *window;
+ QDockWidget *dock;
Ui::BookmarksDialog *ui;
Xbel *xbel;
};