aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-15 22:58:20 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-15 22:58:20 +0200
commitc407c15457b24cfcd85c32cb62473489645858f7 (patch)
tree035535c86de7dd39e79fcb2284d5b9628b44ea9c
parentSubWindow: delete views right away when closing tab (diff)
downloadsmolbote-c407c15457b24cfcd85c32cb62473489645858f7.tar.xz
Bookmarks manager bugfixes
WebProfile: remove addBookmark signal and member Bookmarks: remove unused '...' button Bookmarks: stop crashing if there's no selected item Bookmarks: activating an item will only open it if it's a bookmark Bookmarks: change header size split
-rw-r--r--BUGS.md5
-rw-r--r--lib/bookmarks/bookmarksform.ui30
-rw-r--r--lib/bookmarks/bookmarksview.cpp5
-rw-r--r--lib/bookmarks/bookmarksview.h1
-rw-r--r--lib/bookmarks/bookmarkswidget.cpp4
-rw-r--r--lib/web/webprofile.h8
-rw-r--r--src/browser.cpp1
-rw-r--r--src/browser.h5
-rw-r--r--src/webengine/widgets/pagemenu.cpp5
9 files changed, 39 insertions, 25 deletions
diff --git a/BUGS.md b/BUGS.md
index 85ad893..9ac353b 100644
--- a/BUGS.md
+++ b/BUGS.md
@@ -44,6 +44,5 @@ Only affects Qt 5.11.0. Set __QTBUG_68224_WORKAROUND__.
## Wayland bugs
### mainwindow.maximized doesn't work
-setWindowState(Qt::WindowMaximized) has no effect
-
-### window icon is not set
+setWindowState(Qt::WindowMaximized) has no effect on KDE/Wayland:
+https://community.kde.org/Plasma/Wayland_Showstoppers
diff --git a/lib/bookmarks/bookmarksform.ui b/lib/bookmarks/bookmarksform.ui
index db1a85e..491bdc3 100644
--- a/lib/bookmarks/bookmarksform.ui
+++ b/lib/bookmarks/bookmarksform.ui
@@ -17,30 +17,36 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <widget class="QToolButton" name="addFolder_toolButton">
- <property name="text">
- <string>...</string>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- </widget>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
<item>
- <widget class="QToolButton" name="addBookmark_toolButton">
+ <widget class="QToolButton" name="addFolder_toolButton">
<property name="text">
- <string>...</string>
+ <string>Add Folder</string>
</property>
</widget>
</item>
<item>
- <widget class="QToolButton" name="addSeparator_toolButton">
+ <widget class="QToolButton" name="addBookmark_toolButton">
<property name="text">
- <string>...</string>
+ <string>Add Bookmark</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="deleteItem_toolButton">
<property name="text">
- <string>...</string>
+ <string>Delete Item</string>
</property>
</widget>
</item>
@@ -63,6 +69,12 @@
<property name="columnCount">
<number>2</number>
</property>
+ <attribute name="headerDefaultSectionSize">
+ <number>200</number>
+ </attribute>
+ <attribute name="headerMinimumSectionSize">
+ <number>100</number>
+ </attribute>
<column>
<property name="text">
<string notr="true">Title</string>
diff --git a/lib/bookmarks/bookmarksview.cpp b/lib/bookmarks/bookmarksview.cpp
index e427c2f..a92a3a7 100644
--- a/lib/bookmarks/bookmarksview.cpp
+++ b/lib/bookmarks/bookmarksview.cpp
@@ -45,5 +45,8 @@ QTreeWidgetItem *BookmarksView::createFolder(QTreeWidgetItem *parentItem)
BookmarksView::Type BookmarksView::itemType(QTreeWidgetItem *item) const
{
+ if(item == nullptr)
+ return Invalid;
+
return item->data(0, Qt::UserRole).value<Type>();
-} \ No newline at end of file
+}
diff --git a/lib/bookmarks/bookmarksview.h b/lib/bookmarks/bookmarksview.h
index 47b3f9c..f99fd2a 100644
--- a/lib/bookmarks/bookmarksview.h
+++ b/lib/bookmarks/bookmarksview.h
@@ -17,6 +17,7 @@ class BookmarksView : public QTreeWidget
public:
enum Type {
+ Invalid,
Folder,
Bookmark
};
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
index f56c53b..a027518 100644
--- a/lib/bookmarks/bookmarkswidget.cpp
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -17,7 +17,6 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
{
// make sure this dialog does not get deleted on close
setAttribute(Qt::WA_DeleteOnClose, false);
- setWindowTitle(tr("Bookmarks"));
ui->setupUi(this);
ui->bookmark_groupBox->setVisible(false);
@@ -43,7 +42,8 @@ BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent)
// open bookmark action
connect(ui->treeWidget, &QTreeWidget::itemActivated, this, [this](QTreeWidgetItem *item, int column) {
- emit openUrl(QUrl::fromUserInput(item->text(1)));
+ if(ui->treeWidget->itemType(item) == BookmarksView::Bookmark)
+ emit openUrl(QUrl::fromUserInput(item->text(1)));
});
// add bookmark action
diff --git a/lib/web/webprofile.h b/lib/web/webprofile.h
index 7a747a3..f4d31e6 100644
--- a/lib/web/webprofile.h
+++ b/lib/web/webprofile.h
@@ -81,15 +81,7 @@ public:
void setSpellCheckEnabled(bool enable);
- void addBookmark(const QString &title, const QString &url)
- {
- if(!title.isEmpty() && !url.isEmpty())
- emit addBookmarkRequested(title, url);
- }
-
signals:
- void addBookmarkRequested(const QString &title, const QString &url);
-
void searchChanged(const QString &url);
void homepageChanged(const QUrl &url);
void newtabChanged(const QUrl &url);
diff --git a/src/browser.cpp b/src/browser.cpp
index 7c7dca3..4c6549c 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -145,7 +145,6 @@ void Browser::setup(const QString &defaultProfile)
connect(m_bookmarks.get(), &BookmarksWidget::openUrl, this, [this](const QUrl &url) {
m_windows.last()->createTab(url);
});
- connect(WebProfile::defaultProfile(), &WebProfile::addBookmarkRequested, m_bookmarks.get(), &BookmarksWidget::addBookmark);
// downloads
m_downloads = std::make_shared<DownloadsWidget>(QString::fromStdString(m_config->value<std::string>("downloads.path").value()));
diff --git a/src/browser.h b/src/browser.h
index e6b94e4..8148e99 100644
--- a/src/browser.h
+++ b/src/browser.h
@@ -36,6 +36,11 @@ public:
void setConfiguration(std::shared_ptr<Configuration> &config);
void setup(const QString &defaultProfile);
+ std::shared_ptr<BookmarksWidget> bookmarks()
+ {
+ return m_bookmarks;
+ }
+
WebProfile *profile(const QString &name) const;
const QStringList profiles() const
{
diff --git a/src/webengine/widgets/pagemenu.cpp b/src/webengine/widgets/pagemenu.cpp
index 9cfeb71..21efd3d 100644
--- a/src/webengine/widgets/pagemenu.cpp
+++ b/src/webengine/widgets/pagemenu.cpp
@@ -19,6 +19,7 @@
#include <QVBoxLayout>
#include <QWidgetAction>
#include "browser.h"
+#include <bookmarks/bookmarkswidget.h>
PageMenu::PageMenu(WebView *parent)
: QMenu(tr("Page"), parent)
@@ -28,7 +29,9 @@ PageMenu::PageMenu(WebView *parent)
auto *bookmarkAction = addAction(tr("Bookmark page"));
connect(bookmarkAction, &QAction::triggered, parent, [parent]() {
- parent->profile()->addBookmark(parent->title(), parent->url().toString());
+ auto *browser = qobject_cast<Browser *>(qApp);
+ Q_CHECK_PTR(browser);
+ browser->bookmarks()->addBookmark(parent->title(), parent->url().toString());
});
auto *savePageAction = addAction(tr("Save Page"));