diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-03-20 14:32:31 +0100 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2017-03-20 14:32:31 +0100 |
commit | fb7586f3c5458bb0a0796fd8f7d207246a9f692c (patch) | |
tree | 7b9421f2fb064accdd2d5201b45222774c41b8ac /src/forms | |
parent | Added custom about box (diff) | |
download | smolbote-fb7586f3c5458bb0a0796fd8f7d207246a9f692c.tar.xz |
Dockable bookmarks dialog
Fixed bugs in bookmarks dialog
Diffstat (limited to 'src/forms')
-rw-r--r-- | src/forms/bookmarksdialog.cpp | 26 | ||||
-rw-r--r-- | src/forms/bookmarksdialog.h | 6 | ||||
-rw-r--r-- | src/forms/bookmarksdialog.ui | 45 |
3 files changed, 24 insertions, 53 deletions
diff --git a/src/forms/bookmarksdialog.cpp b/src/forms/bookmarksdialog.cpp index c088fd8..becac56 100644 --- a/src/forms/bookmarksdialog.cpp +++ b/src/forms/bookmarksdialog.cpp @@ -20,14 +20,17 @@ #include "bookmarksdialog.h" #include "ui_bookmarksdialog.h" +#include "browser.h" #include <QTreeWidget> -#include "xbel/xbel.h" -#include "mainwindow.h" +#include <QDockWidget> BookmarksDialog::BookmarksDialog(QWidget *parent) : QDialog(parent), ui(new Ui::BookmarksDialog) { + // make sure this dialog does not get deleted on close + setAttribute(Qt::WA_DeleteOnClose, false); + ui->setupUi(this); ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch); @@ -44,7 +47,7 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) : connect(ui->deleteItem_toolButton, SIGNAL(clicked(bool)), this, SLOT(deleteCurrentItem())); xbel = new Xbel(ui->treeWidget); - xbel->read("bookmarks.xbel"); + xbel->read(sSettings->value("bookmarks.path").toString()); connect(ui->addFolder_toolButton, &QToolButton::clicked, [this]() { xbel->addFolder(ui->treeWidget->currentItem()); @@ -59,17 +62,28 @@ BookmarksDialog::BookmarksDialog(QWidget *parent) : BookmarksDialog::~BookmarksDialog() { + qDebug("Destroying BookmarksManager"); + if(ui->treeWidget->topLevelItemCount() > 0) { - xbel->write("bookmarks.xbel"); + xbel->write(sSettings->value("bookmarks.path").toString()); } delete xbel; delete ui; } -void BookmarksDialog::show(MainWindow *window) +void BookmarksDialog::show() { - w = window; + // show() is called by a QAction in MainWindow + w = qobject_cast<MainWindow *>(sender()->parent()); + + // 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); + QDialog::show(); } diff --git a/src/forms/bookmarksdialog.h b/src/forms/bookmarksdialog.h index 17f4df7..0fcab42 100644 --- a/src/forms/bookmarksdialog.h +++ b/src/forms/bookmarksdialog.h @@ -22,13 +22,13 @@ #define BOOKMARKSDIALOG_H #include <QDialog> -#include "xbel/xbel.h" +#include "xbel.h" +#include "mainwindow.h" namespace Ui { class BookmarksDialog; } -class MainWindow; class BookmarksDialog : public QDialog { Q_OBJECT @@ -41,7 +41,7 @@ signals: void openUrl(const QUrl &url); public slots: - void show(MainWindow *window); + void show(); // void addFolder(const QString &title); // void addBookmark(const QString &title, const QString &href); // void addSeparator(); diff --git a/src/forms/bookmarksdialog.ui b/src/forms/bookmarksdialog.ui index a0e4316..f528528 100644 --- a/src/forms/bookmarksdialog.ui +++ b/src/forms/bookmarksdialog.ui @@ -111,51 +111,8 @@ </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>BookmarksDialog</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>BookmarksDialog</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> + <connections/> </ui> |