aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-03-20 14:32:31 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-03-20 14:32:31 +0100
commitfb7586f3c5458bb0a0796fd8f7d207246a9f692c (patch)
tree7b9421f2fb064accdd2d5201b45222774c41b8ac
parentAdded custom about box (diff)
downloadsmolbote-fb7586f3c5458bb0a0796fd8f7d207246a9f692c.tar.xz
Dockable bookmarks dialog
Fixed bugs in bookmarks dialog
-rw-r--r--data/bookmarks.xbel13
-rw-r--r--data/poi.conf2
-rw-r--r--smolbote.qbs16
-rw-r--r--src/forms/bookmarksdialog.cpp26
-rw-r--r--src/forms/bookmarksdialog.h6
-rw-r--r--src/forms/bookmarksdialog.ui45
-rw-r--r--src/mainwindow.cpp2
-rw-r--r--src/settings.cpp8
-rw-r--r--src/xbel.cpp (renamed from src/xbel/xbel.cpp)3
-rw-r--r--src/xbel.h (renamed from src/xbel/xbel.h)0
l---------[-rw-r--r--]test/bookmarks.xbel41
11 files changed, 61 insertions, 101 deletions
diff --git a/data/bookmarks.xbel b/data/bookmarks.xbel
new file mode 100644
index 0000000..5aab255
--- /dev/null
+++ b/data/bookmarks.xbel
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xbel>
+<xbel version="1.0">
+ <folder folded="no">
+ <title>smolbote</title>
+ <bookmark href="https://gitlab.com/xiannox/smolbote/">
+ <title>Repository</title>
+ </bookmark>
+ <bookmark href="https://doc.qt.io/">
+ <title>Qt Documentation</title>
+ </bookmark>
+ </folder>
+</xbel>
diff --git a/data/poi.conf b/data/poi.conf
index b9c1aee..1e4965f 100644
--- a/data/poi.conf
+++ b/data/poi.conf
@@ -52,7 +52,7 @@ subscriptions=[
# Bookmark manager
[bookmarks]
dialogShortcut="Ctrl+Shift+B"
-path="bookmarks.xbel"
+path="~settings/bookmarks.xbel"
# Download manager
[downloads]
diff --git a/smolbote.qbs b/smolbote.qbs
index c4112de..21e0165 100644
--- a/smolbote.qbs
+++ b/smolbote.qbs
@@ -76,6 +76,17 @@ Project {
]
}
+ Group {
+ name: "bookmarks"
+ files: [
+ "src/forms/bookmarksdialog.cpp",
+ "src/forms/bookmarksdialog.h",
+ "src/forms/bookmarksdialog.ui",
+ "src/xbel.cpp",
+ "src/xbel.h",
+ ]
+ }
+
files: [
"data/resources.qrc",
"src/blocker/blockermanager.cpp",
@@ -88,9 +99,6 @@ Project {
"src/blocker/regexp.h",
"src/blocker/subscriptiondialog.ui",
"src/blocker/subscriptionform.ui",
- "src/forms/bookmarksdialog.cpp",
- "src/forms/bookmarksdialog.h",
- "src/forms/bookmarksdialog.ui",
"src/forms/downloaddialog.cpp",
"src/forms/downloaddialog.h",
"src/forms/downloaddialog.ui",
@@ -114,8 +122,6 @@ Project {
"src/widgets/urllineedit.h",
"src/widgets/webviewtabbar.cpp",
"src/widgets/webviewtabbar.h",
- "src/xbel/xbel.cpp",
- "src/xbel/xbel.h",
]
Group {
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>
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 8eb5462..5cf9590 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -61,6 +61,7 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
QAction *downloadsAction = toolsMenu->addAction(tr("Downloads"), Browser::instance()->downloads(), SLOT(show()));
downloadsAction->setShortcut(QKeySequence::fromString(sSettings->value("downloads.dialogShortcut").toString()));
QAction *bookmarksAction = toolsMenu->addAction(tr("Bookmarks"), Browser::instance()->bookmarks(), SLOT(show()));
+ bookmarksAction->setParent(this);
bookmarksAction->setShortcut(QKeySequence(sSettings->value("bookmarks.dialogShortcut").toString()));
toolsMenu->addSeparator();
toolsMenu->addAction(tr("Blocker"), blocklistManager, SLOT(show()), QKeySequence::fromString(sSettings->value("blocker.shortcut").toString()));
@@ -124,6 +125,7 @@ MainWindow::MainWindow(const QStringList urlList, QWidget *parent) :
MainWindow::~MainWindow()
{
+ qApp->bookmarks()->setParent(0);
delete ui;
}
diff --git a/src/settings.cpp b/src/settings.cpp
index 7a08061..aee0eb5 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -21,6 +21,8 @@
#include "settings.h"
#include <QStandardPaths>
#include <fstream>
+#include <QDir>
+#include <QFileInfo>
Settings::Settings(const QString &configFile)
{
@@ -43,7 +45,11 @@ Settings::Settings(const QString &configFile)
path = configFile;
homeLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
- settingsLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
+ settingsLocation = QFileInfo(configFile).dir().absolutePath();
+
+ qDebug("Read configuration: [%s]", qUtf8Printable(configFile));
+ qDebug("~ => '%s'", qUtf8Printable(homeLocation));
+ qDebug("~settings => '%s'", qUtf8Printable(settingsLocation));
}
Settings::~Settings()
diff --git a/src/xbel/xbel.cpp b/src/xbel.cpp
index 2047e99..59204d8 100644
--- a/src/xbel/xbel.cpp
+++ b/src/xbel.cpp
@@ -120,7 +120,8 @@ void Xbel::readTitle(QTreeWidgetItem *item)
QTreeWidgetItem *Xbel::addFolder(QTreeWidgetItem *parentItem)
{
QTreeWidgetItem *folderItem = createChildItem(parentFolder(parentItem), "folder");
- folderItem->setExpanded(xmlReader.attributes().value("folded") != "no");
+ //folderItem->setExpanded(xmlReader.attributes().value("folded") != "no");
+ treeWidget->setItemExpanded(folderItem, xmlReader.attributes().value("folded") != "yes");
folderItem->setFlags(folderItem->flags() | Qt::ItemIsEditable);
folderItem->setIcon(0, folderIcon);
diff --git a/src/xbel/xbel.h b/src/xbel.h
index 6ffafb1..6ffafb1 100644
--- a/src/xbel/xbel.h
+++ b/src/xbel.h
diff --git a/test/bookmarks.xbel b/test/bookmarks.xbel
index 66fbc25..8644c64 100644..120000
--- a/test/bookmarks.xbel
+++ b/test/bookmarks.xbel
@@ -1,40 +1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE xbel>
-<xbel version="1.0">
- <folder folded="no">
- <title>Bookmarks Bar</title>
- <bookmark href="http://qt.io/">
- <title>Qt Home Page</title>
- </bookmark>
- <bookmark href="http://doc.qt.io/">
- <title>Qt Documentation</title>
- </bookmark>
- <bookmark href="http://planet.qt.io/">
- <title>Qt Blog</title>
- </bookmark>
- <bookmark href="http://www.qtcentre.org/">
- <title>Qt Centre</title>
- </bookmark>
- <bookmark href="http://qt-apps.org/">
- <title>Qt-Apps.org</title>
- </bookmark>
- <bookmark href="http://wiki.qt.io/OnlineCommunities">
- <title>Online Communities</title>
- </bookmark>
- <bookmark href="http://www.chromium.org/">
- <title>The Chromium Projects</title>
- </bookmark>
- <bookmark href="http://xkcd.com/">
- <title>xkcd</title>
- </bookmark>
- <bookmark href="http://twitter.com/qtproject">
- <title>Twitter</title>
- </bookmark>
- </folder>
- <folder folded="no">
- <title>Bookmarks Menu</title>
- <bookmark href="http://reddit.com/">
- <title>reddit.com: what's new online!</title>
- </bookmark>
- </folder>
-</xbel>
+../data/bookmarks.xbel \ No newline at end of file