From 85d9f14aa8bac16ab341662c770b64a15c21628b Mon Sep 17 00:00:00 2001
From: Aqua-sama
Date: Wed, 3 Jan 2018 16:39:32 +0100
Subject: Changed from qbs to cmake
---
CMakeLists.txt | 96 +++++++++++
docs/manual/Building.md | 23 ++-
lib/bookmarks/CMakeLists.txt | 10 ++
lib/bookmarks/bookmarksform.ui | 104 ++++++++++++
lib/bookmarks/bookmarkswidget.cpp | 112 +++++++++++++
lib/bookmarks/bookmarkswidget.h | 49 ++++++
lib/bookmarks/xbel.cpp | 193 +++++++++++++++++++++++
lib/bookmarks/xbel.h | 45 ++++++
lib/downloads/CMakeLists.txt | 13 ++
lib/downloads/downloadsform.ui | 24 +++
lib/downloads/downloadswidget.cpp | 91 +++++++++++
lib/downloads/downloadswidget.h | 38 +++++
lib/downloads/widgets/downloaditemform.ui | 74 +++++++++
lib/downloads/widgets/downloaditemwidget.cpp | 103 ++++++++++++
lib/downloads/widgets/downloaditemwidget.h | 43 +++++
lib/downloads/widgets/elidedlabel.cpp | 85 ++++++++++
lib/downloads/widgets/elidedlabel.h | 85 ++++++++++
lib/navigation/CMakeLists.txt | 11 ++
lib/navigation/navigationbutton.cpp | 141 +++++++++++++++++
lib/navigation/navigationbutton.h | 49 ++++++
lib/navigation/urlcompleter.cpp | 26 +++
lib/navigation/urlcompleter.h | 25 +++
lib/navigation/urllineedit.cpp | 136 ++++++++++++++++
lib/navigation/urllineedit.h | 59 +++++++
lib/settings/CMakeLists.txt | 10 ++
lib/settings/configuration.cpp | 4 +
lib/settings/settings.qbs | 38 -----
linux/makepkg/PKGBUILD | 53 ++-----
mach | 65 --------
smolbote.qbs | 153 ------------------
src/forms/aboutdialog.cpp | 37 +++--
src/forms/aboutdialog.h | 2 -
src/interfaces.h | 41 -----
src/lib/bookmarks/bookmarks.qbs | 25 ---
src/lib/bookmarks/bookmarksform.ui | 104 ------------
src/lib/bookmarks/bookmarkswidget.cpp | 112 -------------
src/lib/bookmarks/bookmarkswidget.h | 49 ------
src/lib/bookmarks/xbel.cpp | 193 -----------------------
src/lib/bookmarks/xbel.h | 45 ------
src/lib/downloads/downloads.qbs | 28 ----
src/lib/downloads/downloadsform.ui | 24 ---
src/lib/downloads/downloadswidget.cpp | 91 -----------
src/lib/downloads/downloadswidget.h | 38 -----
src/lib/downloads/widgets/downloaditemform.ui | 74 ---------
src/lib/downloads/widgets/downloaditemwidget.cpp | 103 ------------
src/lib/downloads/widgets/downloaditemwidget.h | 43 -----
src/lib/downloads/widgets/elidedlabel.cpp | 85 ----------
src/lib/downloads/widgets/elidedlabel.h | 85 ----------
src/lib/navigation/navigation.qbs | 26 ---
src/lib/navigation/navigationbutton.cpp | 141 -----------------
src/lib/navigation/navigationbutton.h | 49 ------
src/lib/navigation/urlcompleter.cpp | 26 ---
src/lib/navigation/urlcompleter.h | 25 ---
src/lib/navigation/urllineedit.cpp | 136 ----------------
src/lib/navigation/urllineedit.h | 59 -------
src/main.cpp | 1 +
src/settings.cpp | 182 ---------------------
src/settings.h | 47 ------
src/version.h.in | 7 +
src/webengine/webview.h | 2 +-
tools/hooks/pre-commit.rb | 2 +-
61 files changed, 1685 insertions(+), 2155 deletions(-)
create mode 100644 CMakeLists.txt
create mode 100644 lib/bookmarks/CMakeLists.txt
create mode 100644 lib/bookmarks/bookmarksform.ui
create mode 100644 lib/bookmarks/bookmarkswidget.cpp
create mode 100644 lib/bookmarks/bookmarkswidget.h
create mode 100644 lib/bookmarks/xbel.cpp
create mode 100644 lib/bookmarks/xbel.h
create mode 100644 lib/downloads/CMakeLists.txt
create mode 100644 lib/downloads/downloadsform.ui
create mode 100644 lib/downloads/downloadswidget.cpp
create mode 100644 lib/downloads/downloadswidget.h
create mode 100644 lib/downloads/widgets/downloaditemform.ui
create mode 100644 lib/downloads/widgets/downloaditemwidget.cpp
create mode 100644 lib/downloads/widgets/downloaditemwidget.h
create mode 100644 lib/downloads/widgets/elidedlabel.cpp
create mode 100644 lib/downloads/widgets/elidedlabel.h
create mode 100644 lib/navigation/CMakeLists.txt
create mode 100644 lib/navigation/navigationbutton.cpp
create mode 100644 lib/navigation/navigationbutton.h
create mode 100644 lib/navigation/urlcompleter.cpp
create mode 100644 lib/navigation/urlcompleter.h
create mode 100644 lib/navigation/urllineedit.cpp
create mode 100644 lib/navigation/urllineedit.h
create mode 100644 lib/settings/CMakeLists.txt
delete mode 100644 lib/settings/settings.qbs
delete mode 100755 mach
delete mode 100644 smolbote.qbs
delete mode 100644 src/interfaces.h
delete mode 100644 src/lib/bookmarks/bookmarks.qbs
delete mode 100644 src/lib/bookmarks/bookmarksform.ui
delete mode 100644 src/lib/bookmarks/bookmarkswidget.cpp
delete mode 100644 src/lib/bookmarks/bookmarkswidget.h
delete mode 100644 src/lib/bookmarks/xbel.cpp
delete mode 100644 src/lib/bookmarks/xbel.h
delete mode 100644 src/lib/downloads/downloads.qbs
delete mode 100644 src/lib/downloads/downloadsform.ui
delete mode 100644 src/lib/downloads/downloadswidget.cpp
delete mode 100644 src/lib/downloads/downloadswidget.h
delete mode 100644 src/lib/downloads/widgets/downloaditemform.ui
delete mode 100644 src/lib/downloads/widgets/downloaditemwidget.cpp
delete mode 100644 src/lib/downloads/widgets/downloaditemwidget.h
delete mode 100644 src/lib/downloads/widgets/elidedlabel.cpp
delete mode 100644 src/lib/downloads/widgets/elidedlabel.h
delete mode 100644 src/lib/navigation/navigation.qbs
delete mode 100644 src/lib/navigation/navigationbutton.cpp
delete mode 100644 src/lib/navigation/navigationbutton.h
delete mode 100644 src/lib/navigation/urlcompleter.cpp
delete mode 100644 src/lib/navigation/urlcompleter.h
delete mode 100644 src/lib/navigation/urllineedit.cpp
delete mode 100644 src/lib/navigation/urllineedit.h
delete mode 100644 src/settings.cpp
delete mode 100644 src/settings.h
create mode 100644 src/version.h.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..8700909
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,96 @@
+cmake_minimum_required(VERSION 3.1.0)
+project(smolbote)
+
+# Options
+option(UseLibCpp "Use libc++ over stdlibc++" OFF)
+
+# Libraries
+find_package(Qt5Core REQUIRED)
+find_package(Qt5Widgets REQUIRED)
+find_package(Qt5WebEngineWidgets REQUIRED)
+find_package(libconfig++ REQUIRED)
+
+# Find includes in corresponding build directories
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+# Instruct CMake to run moc automatically when needed.
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+
+# Global C++ settings
+set(CMAKE_CXX_STANDARD 17)
+add_definitions(-DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050900)
+
+# link to libc++
+if (UseLibCpp)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
+endif (UseLibCpp)
+
+add_subdirectory(lib/settings)
+add_subdirectory(lib/bookmarks)
+add_subdirectory(lib/downloads)
+add_subdirectory(lib/navigation)
+
+# configure a header file to pass version information
+execute_process(COMMAND "git" "describe" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GitDescribe OUTPUT_STRIP_TRAILING_WHITESPACE)
+execute_process(COMMAND "git" "describe" "--abbrev=0" WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GitVersion OUTPUT_STRIP_TRAILING_WHITESPACE)
+configure_file(src/version.h.in "${PROJECT_BINARY_DIR}/version.h")
+
+set(SourceCode
+ # main
+ "src/main.cpp"
+ "src/singleapplication.cpp"
+ "src/singleapplication.h"
+ "src/browser.cpp"
+ "src/browser.h"
+
+ # main window
+ # todo: move all to src/mainwindow
+ "src/mainwindow.cpp"
+ "src/mainwindow.h"
+ "src/mainwindow.ui"
+ "src/widgets/loadingbar.cpp"
+ "src/widgets/loadingbar.h"
+ "src/widgets/mainwindowmenubar.cpp"
+ "src/widgets/mainwindowmenubar.h"
+ "src/widgets/mainwindowtabbar.cpp"
+ "src/widgets/mainwindowtabbar.h"
+ # todo: move to src/mainwindow
+ "src/forms/searchform.cpp"
+ "src/forms/searchform.h"
+ "src/forms/searchform.ui"
+ "data/resources.qrc"
+
+ # webengine
+ "src/webengine/urlinterceptor.cpp"
+ "src/webengine/urlinterceptor.h"
+ "src/webengine/webengineprofile.cpp" # todo: rename to profile
+ "src/webengine/webengineprofile.h"
+ "src/webengine/webpage.cpp"
+ "src/webengine/webpage.h"
+ "src/webengine/webview.cpp"
+ "src/webengine/webview.h"
+
+ # forms
+ "src/forms/aboutdialog.cpp"
+ "src/forms/aboutdialog.h"
+ "src/forms/aboutdialog.ui"
+ "src/forms/profileview.cpp"
+ "src/forms/profileview.h"
+ "src/forms/profileview.ui"
+ # todo: move to src/webengine
+ "src/forms/cookiesform.cpp"
+ "src/forms/cookiesform.h"
+ "src/forms/cookiesform.ui"
+ )
+
+add_executable(poi ${SourceCode})
+
+target_include_directories(poi PRIVATE src lib)
+
+target_link_libraries(poi Qt5::Core Qt5::Widgets Qt5::WebEngineWidgets)
+target_link_libraries(poi config++ configuration)
+target_link_libraries(poi bookmarks downloads navigation)
+
+install(TARGETS poi DESTINATION bin CONFIGURATIONS Release)
diff --git a/docs/manual/Building.md b/docs/manual/Building.md
index 56a6646..a0c6d94 100644
--- a/docs/manual/Building.md
+++ b/docs/manual/Building.md
@@ -13,24 +13,19 @@
* A working compiler
- gcc or clang on Linux
- msvc on Windows due to QtWebEngine
-* qbs
- - minimal version 1.8.0
+* cmake
+ - minimal version 3.1.0, but please use something up-to-date
## Compiling
-
-### Create qbs configuration
-Before you can build anything with qbs, you need to set up the compiler
-toolchain.
-
```
-qbs setup-toolchains --detect
-qbs setup-qt /usr/bin/qmake-qt5 qt5
+cmake -DCMAKE_BUILD_TYPE=Release ../smolbote.git
+make -j 4
```
-### Compiling
-```
-mkdir ../build
-qbs build -d ../build profile:qt5 release
+### Using libc++
+```text
+cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DUseLibCpp=On ../smolbote.git
+make -j 4
```
## Packaging
@@ -46,7 +41,7 @@ sha512sum --binary head.tar.lz > head.tar.lz.sha512
```
### makepkg
-A PKGBUILD is provided in linux/makepkg/PKGBUILD.
+A PKGBUILD is provided in linux/makepkg/PKGBUILD. Please read before using.
## Troubleshooting
diff --git a/lib/bookmarks/CMakeLists.txt b/lib/bookmarks/CMakeLists.txt
new file mode 100644
index 0000000..8fb7f45
--- /dev/null
+++ b/lib/bookmarks/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.1.0)
+
+add_library(bookmarks
+ bookmarksform.ui
+ bookmarkswidget.cpp
+ bookmarkswidget.h
+ xbel.cpp
+ xbel.h)
+
+target_link_libraries(bookmarks Qt5::Widgets)
\ No newline at end of file
diff --git a/lib/bookmarks/bookmarksform.ui b/lib/bookmarks/bookmarksform.ui
new file mode 100644
index 0000000..2df0c4b
--- /dev/null
+++ b/lib/bookmarks/bookmarksform.ui
@@ -0,0 +1,104 @@
+
+
+ BookmarksDialog
+
+
+
+ 0
+ 0
+ 420
+ 600
+
+
+
+
+ 420
+ 600
+
+
+
+ Bookmarks
+
+
+ -
+
+
-
+
+
+ ...
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+ ...
+
+
+
+ -
+
+
+ ...
+
+
+
+
+
+ -
+
+
+ true
+
+
+ QAbstractItemView::InternalMove
+
+
+ Qt::MoveAction
+
+
+
+ Title
+
+
+
+
+ href
+
+
+
+
+ -
+
+
+ Details
+
+
+
-
+
+
+ href
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/bookmarks/bookmarkswidget.cpp b/lib/bookmarks/bookmarkswidget.cpp
new file mode 100644
index 0000000..cb191c7
--- /dev/null
+++ b/lib/bookmarks/bookmarkswidget.cpp
@@ -0,0 +1,112 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "bookmarkswidget.h"
+#include "ui_bookmarksform.h"
+#include
+#include
+
+BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::BookmarksDialog)
+{
+ // make sure this dialog does not get deleted on close
+ setAttribute(Qt::WA_DeleteOnClose, false);
+ setWindowTitle(tr("Bookmarks"));
+
+ ui->setupUi(this);
+ ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
+
+ QStyle *style = ui->treeWidget->style();
+ ui->addFolder_toolButton->setIcon(style->standardPixmap(QStyle::SP_DirIcon));
+ ui->addBookmark_toolButton->setIcon(style->standardPixmap(QStyle::SP_FileIcon));
+ ui->deleteItem_toolButton->setIcon(style->standardPixmap(QStyle::SP_TrashIcon));
+
+ connect(ui->treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(showItemDetails()));
+ connect(ui->treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(openItem(QTreeWidgetItem*,int)));
+
+ ui->deleteItem_toolButton->setShortcut(QKeySequence::Delete);
+
+ m_path = path;
+ xbel = new Xbel(ui->treeWidget);
+ qDebug("Reading bookmarks [%s] %s", qUtf8Printable(m_path), xbel->read(m_path) ? "ok" : "failed");
+
+ connect(ui->addFolder_toolButton, &QToolButton::clicked, this, [&]() {
+ xbel->addFolder(ui->treeWidget->currentItem());
+ });
+ connect(ui->addBookmark_toolButton, &QToolButton::clicked, this, [&]() {
+ xbel->addBookmark(ui->treeWidget->currentItem());
+ });
+ connect(ui->deleteItem_toolButton, &QToolButton::clicked, this, [&]() {
+ delete ui->treeWidget->currentItem();
+ });
+
+ // editing bookmarks
+ connect(ui->title_lineEdit, &QLineEdit::returnPressed, this, [&]() {
+ ui->treeWidget->currentItem()->setText(0, ui->title_lineEdit->text());
+ });
+ connect(ui->href_lineEdit, &QLineEdit::returnPressed, this, [&]() {
+ ui->treeWidget->currentItem()->setText(1, ui->href_lineEdit->text());
+ });
+}
+
+BookmarksWidget::~BookmarksWidget()
+{
+ delete xbel;
+ delete ui;
+}
+
+void BookmarksWidget::save()
+{
+ qDebug("Writing bookmarks [%s] %s", qUtf8Printable(m_path), xbel->write(m_path) ? "ok" : "failed");
+}
+
+QStringList BookmarksWidget::bookmarksFor(const QString &term)
+{
+ QStringList ret;
+ for(int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
+ ret += searchItem(ui->treeWidget->topLevelItem(i), term);
+ }
+ return ret;
+}
+
+QAbstractItemModel *BookmarksWidget::model() const
+{
+ return ui->treeWidget->model();
+}
+
+QStringList BookmarksWidget::searchItem(QTreeWidgetItem *item, const QString &term)
+{
+ if(item->text(1).contains(term)) {
+ return { item->text(1) };
+ }
+
+ QStringList ret;
+ for(int i = 0; i < item->childCount(); ++i) {
+ ret += searchItem(item->child(i), term);
+ }
+ return ret;
+}
+
+void BookmarksWidget::openItem(QTreeWidgetItem *item, int column)
+{
+ Q_UNUSED(column)
+ emit openUrl(QUrl::fromUserInput(item->text(1)));
+}
+
+void BookmarksWidget::showItemDetails()
+{
+ QTreeWidgetItem *item = ui->treeWidget->currentItem();
+ if(!item) {
+ ui->title_lineEdit->setText("");
+ ui->href_label->setText("");
+ return;
+ }
+ ui->title_lineEdit->setText(item->text(0));
+ ui->href_lineEdit->setText(item->text(1));
+}
diff --git a/lib/bookmarks/bookmarkswidget.h b/lib/bookmarks/bookmarkswidget.h
new file mode 100644
index 0000000..aa188b2
--- /dev/null
+++ b/lib/bookmarks/bookmarkswidget.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef BOOKMARKSDIALOG_H
+#define BOOKMARKSDIALOG_H
+
+#include
+#include "xbel.h"
+#include
+
+namespace Ui {
+class BookmarksDialog;
+}
+
+class BookmarksWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit BookmarksWidget(const QString &path, QWidget *parent = 0);
+ ~BookmarksWidget();
+
+ void save();
+
+signals:
+ void openUrl(const QUrl &url);
+
+public slots:
+ QStringList bookmarksFor(const QString &term);
+ QAbstractItemModel *model() const;
+
+private slots:
+ void openItem(QTreeWidgetItem *item, int column);
+ void showItemDetails();
+
+private:
+ QStringList searchItem(QTreeWidgetItem *item, const QString &term);
+
+ QString m_path;
+ Ui::BookmarksDialog *ui;
+ Xbel *xbel;
+};
+
+#endif // BOOKMARKSDIALOG_H
diff --git a/lib/bookmarks/xbel.cpp b/lib/bookmarks/xbel.cpp
new file mode 100644
index 0000000..523ed99
--- /dev/null
+++ b/lib/bookmarks/xbel.cpp
@@ -0,0 +1,193 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "xbel.h"
+#include
+
+#include
+
+Xbel::Xbel(QTreeWidget *widget)
+{
+ treeWidget = widget;
+
+ QStyle *style = treeWidget->style();
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On);
+ folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon), QIcon::Normal, QIcon::Off);
+ bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
+}
+
+bool Xbel::read(const QString &xbel)
+{
+ // no file specified
+ if(xbel.isEmpty()) {
+ return false;
+ }
+
+ QFile file(xbel);
+ if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ // file cannot be opened
+ return false;
+ }
+
+ xmlReader.setDevice(&file);
+
+ if(xmlReader.readNextStartElement()) {
+ if(xmlReader.name() == "xbel" && xmlReader.attributes().value("version") == "1.0") {
+ qDebug("valid xbel");
+ readChildElements(0);
+ } else {
+ qDebug("invalid xbel");
+ return false;
+ }
+
+ }
+ return true;
+}
+
+bool Xbel::write(const QString &xbel)
+{
+ // no file specified
+ if(xbel.isEmpty()) {
+ return false;
+ }
+
+ QFile file(xbel);
+ if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ // file cannot be opened
+ qDebug("Cannot open xbel: %s", qUtf8Printable(xbel));
+ return false;
+ }
+
+ xmlWriter.setAutoFormatting(true);
+ xmlWriter.setDevice(&file);
+
+ xmlWriter.writeStartDocument();
+ xmlWriter.writeDTD("");
+ xmlWriter.writeStartElement("xbel");
+ xmlWriter.writeAttribute("version", "1.0");
+
+ for(int i=0; itopLevelItemCount(); i++) {
+ writeItem(treeWidget->topLevelItem(i));
+ }
+
+ xmlWriter.writeEndDocument();
+
+ file.flush();
+ file.close();
+ return true;
+}
+
+void Xbel::readChildElements(QTreeWidgetItem *parentItem)
+{
+ while(xmlReader.readNextStartElement()) {
+ if(xmlReader.name() == "title") {
+ readTitle(parentItem);
+ } else if(xmlReader.name() == "folder") {
+ QTreeWidgetItem *item = addFolder(parentItem);
+ item->setText(1, xmlReader.attributes().value("href").toString());
+ readChildElements(item);
+ } else if(xmlReader.name() == "bookmark") {
+ QTreeWidgetItem *item = addBookmark(parentItem);
+ item->setText(1, xmlReader.attributes().value("href").toString());
+ readChildElements(item);
+ } else if(xmlReader.name() == "separator") {
+ addSeparator(parentItem);
+ xmlReader.skipCurrentElement();
+ } else {
+ xmlReader.skipCurrentElement();
+ }
+ }
+}
+
+void Xbel::readTitle(QTreeWidgetItem *item)
+{
+ item->setText(0, xmlReader.readElementText());
+}
+
+QTreeWidgetItem *Xbel::addFolder(QTreeWidgetItem *parentItem)
+{
+ QTreeWidgetItem *folderItem = createChildItem(parentFolder(parentItem), "folder");
+ //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);
+
+ return folderItem;
+}
+
+QTreeWidgetItem *Xbel::addBookmark(QTreeWidgetItem *parentItem)
+{
+ QTreeWidgetItem *bookmarkItem = createChildItem(parentFolder(parentItem), "bookmark");
+ bookmarkItem->setFlags((bookmarkItem->flags() | Qt::ItemIsEditable) & ~Qt::ItemIsDropEnabled);
+ bookmarkItem->setIcon(0, bookmarkIcon);
+ bookmarkItem->setText(0, "Unknown Title");
+ bookmarkItem->setText(1, "Unknown Address");
+
+ return bookmarkItem;
+}
+
+void Xbel::addSeparator(QTreeWidgetItem *parentItem)
+{
+ QTreeWidgetItem *separatorItem = createChildItem(parentFolder(parentItem), "separator");
+ separatorItem->setFlags(separatorItem->flags() & ~Qt::ItemIsDropEnabled);
+ separatorItem->setText(0, "-----");
+}
+
+QTreeWidgetItem *Xbel::parentFolder(QTreeWidgetItem *item)
+{
+ QTreeWidgetItem *parentItem = item;
+
+ if(parentItem) {
+ while(parentItem->data(0, Qt::UserRole) != "folder") {
+ parentItem = parentItem->parent();
+ if(parentItem == 0) {
+ break;
+ }
+ }
+ }
+
+ return parentItem;
+}
+
+QTreeWidgetItem *Xbel::createChildItem(QTreeWidgetItem *item, const QString &type)
+{
+ QTreeWidgetItem *childItem;
+ if(item) {
+ childItem = new QTreeWidgetItem(item);
+ } else {
+ childItem = new QTreeWidgetItem(treeWidget);
+ }
+ childItem->setData(0, Qt::UserRole, type);
+ return childItem;
+}
+
+void Xbel::writeItem(QTreeWidgetItem *item)
+{
+ QString tagName = item->data(0, Qt::UserRole).toString();
+ if (tagName == "folder") {
+ xmlWriter.writeStartElement(tagName);
+ if(!item->text(1).isEmpty()) {
+ xmlWriter.writeAttribute("href", item->text(1));
+ }
+ xmlWriter.writeAttribute("folded", treeWidget->isItemExpanded(item) ? "no" : "yes");
+ xmlWriter.writeTextElement("title", item->text(0));
+ for (int i = 0; i < item->childCount(); ++i) {
+ writeItem(item->child(i));
+ }
+ xmlWriter.writeEndElement();
+ } else if (tagName == "bookmark") {
+ xmlWriter.writeStartElement(tagName);
+ if (!item->text(1).isEmpty()) {
+ xmlWriter.writeAttribute("href", item->text(1));
+ }
+ xmlWriter.writeTextElement("title", item->text(0));
+ xmlWriter.writeEndElement();
+ } else if (tagName == "separator") {
+ xmlWriter.writeEmptyElement(tagName);
+ }
+}
diff --git a/lib/bookmarks/xbel.h b/lib/bookmarks/xbel.h
new file mode 100644
index 0000000..ed0a256
--- /dev/null
+++ b/lib/bookmarks/xbel.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef XBELREADER_H
+#define XBELREADER_H
+
+#include
+#include
+
+class QTreeWidget;
+class QTreeWidgetItem;
+class Xbel
+{
+public:
+ explicit Xbel(QTreeWidget *widget);
+ bool read(const QString &xbel);
+ bool write(const QString &xbel);
+
+ QTreeWidgetItem *addFolder(QTreeWidgetItem *parentItem);
+ QTreeWidgetItem *addBookmark(QTreeWidgetItem *parentItem);
+ void addSeparator(QTreeWidgetItem *parentItem);
+
+private:
+ void readChildElements(QTreeWidgetItem *parentItem);
+ void readTitle(QTreeWidgetItem *item);
+
+ QTreeWidgetItem *parentFolder(QTreeWidgetItem *item);
+ QTreeWidgetItem *createChildItem(QTreeWidgetItem *item, const QString &type);
+
+ void writeItem(QTreeWidgetItem *item);
+
+ QIcon folderIcon;
+ QIcon bookmarkIcon;
+
+ QTreeWidget *treeWidget;
+ QXmlStreamReader xmlReader;
+ QXmlStreamWriter xmlWriter;
+};
+
+#endif // XBELREADER_H
diff --git a/lib/downloads/CMakeLists.txt b/lib/downloads/CMakeLists.txt
new file mode 100644
index 0000000..ca67f0a
--- /dev/null
+++ b/lib/downloads/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.1.0)
+
+add_library(downloads
+ downloadsform.ui
+ downloadswidget.cpp
+ downloadswidget.h
+ widgets/downloaditemform.ui
+ widgets/downloaditemwidget.cpp
+ widgets/downloaditemwidget.h
+ widgets/elidedlabel.cpp
+ widgets/elidedlabel.h)
+
+target_link_libraries(downloads Qt5::Widgets Qt5::WebEngineWidgets)
\ No newline at end of file
diff --git a/lib/downloads/downloadsform.ui b/lib/downloads/downloadsform.ui
new file mode 100644
index 0000000..43a0d49
--- /dev/null
+++ b/lib/downloads/downloadsform.ui
@@ -0,0 +1,24 @@
+
+
+ DownloadDialog
+
+
+
+ 0
+ 0
+ 600
+ 420
+
+
+
+ Downloads
+
+
+ -
+
+
+
+
+
+
+
diff --git a/lib/downloads/downloadswidget.cpp b/lib/downloads/downloadswidget.cpp
new file mode 100644
index 0000000..f9a8f34
--- /dev/null
+++ b/lib/downloads/downloadswidget.cpp
@@ -0,0 +1,91 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "downloadswidget.h"
+#include "ui_downloadsform.h"
+
+#include
+#include
+#include
+#include
+#include
+#include "widgets/downloaditemwidget.h"
+
+DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::DownloadDialog)
+{
+ // make sure this dialog does not get deleted on close
+ setAttribute(Qt::WA_DeleteOnClose, false);
+ setWindowTitle(tr("Downloads"));
+
+ ui->setupUi(this);
+
+ m_downloadPath = downloadPath;
+
+ connect(ui->listWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous) {
+ DownloadItemWidget *currentWidget = qobject_cast(ui->listWidget->itemWidget(current));
+ currentWidget->showDetails();
+ currentWidget->setFixedWidth(ui->listWidget->viewport()->width());
+ currentWidget->adjustSize();
+ current->setSizeHint(currentWidget->size());
+
+ DownloadItemWidget *previousWidget = qobject_cast(ui->listWidget->itemWidget(previous));
+ if(previousWidget != nullptr) {
+ previousWidget->hideDetails();
+ previousWidget->setFixedWidth(ui->listWidget->viewport()->width());
+ previousWidget->adjustSize();
+ previous->setSizeHint(previousWidget->size());
+ }
+ });
+}
+
+DownloadsWidget::~DownloadsWidget()
+{
+ delete ui;
+}
+
+void DownloadsWidget::addDownload(QWebEngineDownloadItem *item)
+{
+ this->show();
+
+ QString filepath = QFileDialog::getSaveFileName(this,
+ tr("Save"),
+ m_downloadPath + "/" + QFileInfo(item->path()).fileName());
+
+ if(filepath.isEmpty()) {
+ // user cancelled the save dialog
+ item->cancel();
+ return;
+ }
+
+ item->setPath(filepath);
+
+ QListWidgetItem *listItem = new QListWidgetItem();
+ int rowIndex = ui->listWidget->count();
+ ui->listWidget->insertItem(rowIndex, listItem);
+
+ DownloadItemWidget *form = new DownloadItemWidget(item, this);
+ ui->listWidget->setItemWidget(listItem, form);
+
+ item->accept();
+
+ ui->listWidget->setCurrentRow(rowIndex);
+}
+
+void DownloadsWidget::resizeEvent(QResizeEvent *event)
+{
+ QWidget::resizeEvent(event);
+
+ for(int i = 0; i < ui->listWidget->count(); ++i) {
+ QWidget *w = ui->listWidget->itemWidget(ui->listWidget->item(i));
+ w->setFixedWidth(ui->listWidget->viewport()->width());
+ w->adjustSize();
+ ui->listWidget->item(i)->setSizeHint(w->size());
+ }
+}
diff --git a/lib/downloads/downloadswidget.h b/lib/downloads/downloadswidget.h
new file mode 100644
index 0000000..8c9ea21
--- /dev/null
+++ b/lib/downloads/downloadswidget.h
@@ -0,0 +1,38 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef DOWNLOADDIALOG_H
+#define DOWNLOADDIALOG_H
+
+#include
+
+namespace Ui {
+class DownloadDialog;
+}
+
+class QWebEngineDownloadItem;
+class DownloadsWidget : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit DownloadsWidget(const QString &downloadPath, QWidget *parent = nullptr);
+ ~DownloadsWidget();
+
+public slots:
+ void addDownload(QWebEngineDownloadItem *item);
+
+protected:
+ void resizeEvent(QResizeEvent *event) override;
+
+private:
+ Ui::DownloadDialog *ui;
+ QString m_downloadPath;
+};
+
+#endif // DOWNLOADDIALOG_H
diff --git a/lib/downloads/widgets/downloaditemform.ui b/lib/downloads/widgets/downloaditemform.ui
new file mode 100644
index 0000000..17f1d6a
--- /dev/null
+++ b/lib/downloads/widgets/downloaditemform.ui
@@ -0,0 +1,74 @@
+
+
+ DownloadItemForm
+
+
+
+ 0
+ 0
+ 500
+ 122
+
+
+
+
+ 0
+ 0
+
+
+
+ Form
+
+
+
+ 0
+
+ -
+
+
+ [url]
+
+
+
+ -
+
+
+ 24
+
+
+
+ -
+
+
+
-
+
+
+ status_label
+
+
+
+ -
+
+
+ path_label
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+ ElidedLabel
+ QLabel
+
+
+
+
+
+
diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp
new file mode 100644
index 0000000..fff3cfc
--- /dev/null
+++ b/lib/downloads/widgets/downloaditemwidget.cpp
@@ -0,0 +1,103 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "downloaditemwidget.h"
+#include "ui_downloaditemform.h"
+
+#include
+#include
+
+DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::DownloadItemForm)
+{
+ m_item = item;
+
+ ui->setupUi(this);
+
+ ui->url_label->setContent(item->url().toString());
+ ui->detailsWidget->hide();
+
+ ui->path_label->setText(item->path());
+
+ connect(item, &QWebEngineDownloadItem::stateChanged, this, &DownloadItemWidget::updateState);
+ connect(item, &QWebEngineDownloadItem::downloadProgress, this, &DownloadItemWidget::updateProgress);
+ connect(item, &QWebEngineDownloadItem::finished, this, &DownloadItemWidget::updateFinished);
+}
+
+DownloadItemWidget::~DownloadItemWidget()
+{
+ delete ui;
+}
+
+void DownloadItemWidget::showDetails()
+{
+ ui->detailsWidget->show();
+}
+
+void DownloadItemWidget::hideDetails()
+{
+ ui->detailsWidget->hide();
+}
+
+QWebEngineDownloadItem *DownloadItemWidget::item() const
+{
+ return m_item;
+}
+
+QString DownloadItemWidget::sizeString(int size) const
+{
+ if(size < 1024) {
+ return QString("%1 bytes").arg(size);
+ }
+ // KiB
+ if(size < 1024 * 1024) {
+ return QString("%1 kB").arg(size / 1024);
+ }
+ // MiB
+ if(size < 1024 * 1024 * 1024) {
+ return QString("%1 MB").arg(size / (1024 * 1024));
+ }
+ // GiB
+ return QString("%1 GB").arg(size / (1024 * 1024 * 1024));
+}
+
+void DownloadItemWidget::updateState(QWebEngineDownloadItem::DownloadState state)
+{
+ switch (state) {
+ case QWebEngineDownloadItem::DownloadRequested:
+ ui->status_label->setText(tr("Requested"));
+ break;
+ case QWebEngineDownloadItem::DownloadInProgress:
+ ui->status_label->setText(tr("In progress"));
+ break;
+ case QWebEngineDownloadItem::DownloadCompleted:
+ ui->status_label->setText(tr("Completed"));
+ break;
+ case QWebEngineDownloadItem::DownloadCancelled:
+ ui->status_label->setText(tr("Cancelled"));
+ break;
+ case QWebEngineDownloadItem::DownloadInterrupted:
+ ui->status_label->setText(tr("Interrupted"));
+ break;
+ default:
+ break;
+ }
+}
+
+void DownloadItemWidget::updateProgress(qint64 value, qint64 total)
+{
+ ui->progressBar->setMaximum(total);
+ ui->progressBar->setValue(value);
+ ui->progressBar->setFormat(QString("%1 / %2").arg(sizeString(value), sizeString(total)));
+}
+
+void DownloadItemWidget::updateFinished()
+{
+ ui->progressBar->setValue(ui->progressBar->maximum());
+}
diff --git a/lib/downloads/widgets/downloaditemwidget.h b/lib/downloads/widgets/downloaditemwidget.h
new file mode 100644
index 0000000..c6246da
--- /dev/null
+++ b/lib/downloads/widgets/downloaditemwidget.h
@@ -0,0 +1,43 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef DOWNLOADITEMFORM_H
+#define DOWNLOADITEMFORM_H
+
+#include
+#include
+
+namespace Ui {
+class DownloadItemForm;
+}
+
+class DownloadItemWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent = 0);
+ ~DownloadItemWidget();
+
+ void showDetails();
+ void hideDetails();
+
+ QWebEngineDownloadItem *item() const;
+ QString sizeString(int size) const;
+
+private slots:
+ void updateState(QWebEngineDownloadItem::DownloadState state);
+ void updateProgress(qint64 value, qint64 total);
+ void updateFinished();
+
+private:
+ Ui::DownloadItemForm *ui;
+ QWebEngineDownloadItem *m_item;
+};
+
+#endif // DOWNLOADITEMFORM_H
diff --git a/lib/downloads/widgets/elidedlabel.cpp b/lib/downloads/widgets/elidedlabel.cpp
new file mode 100644
index 0000000..dc17d32
--- /dev/null
+++ b/lib/downloads/widgets/elidedlabel.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "elidedlabel.h"
+
+#include
+#include
+#include
+
+ElidedLabel::ElidedLabel(QWidget *parent)
+ : QLabel(parent)
+ , elided(false)
+ , content("elided_label")
+{
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+}
+
+void ElidedLabel::setContent(const QString &newText)
+{
+ content = newText;
+ setText(newText);
+}
+
+void ElidedLabel::resizeEvent(QResizeEvent *event)
+{
+ QLabel::resizeEvent(event);
+
+ QFontMetrics font = this->fontMetrics();
+ QString elidedLine = font.elidedText(content, Qt::ElideRight, width());
+ setText(elidedLine);
+}
diff --git a/lib/downloads/widgets/elidedlabel.h b/lib/downloads/widgets/elidedlabel.h
new file mode 100644
index 0000000..d0f6221
--- /dev/null
+++ b/lib/downloads/widgets/elidedlabel.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ELIDEDLABEL_H
+#define ELIDEDLABEL_H
+
+#include
+
+class ElidedLabel : public QLabel
+{
+
+public:
+ explicit ElidedLabel(QWidget *parent = nullptr);
+
+ void setContent(const QString &text);
+ const QString & text() const {
+ return content;
+ }
+ bool isElided() const {
+ return elided;
+ }
+
+protected:
+ void resizeEvent(QResizeEvent *event) override;
+
+private:
+ bool elided;
+ QString content;
+};
+
+#endif // ELIDEDLABEL_H
diff --git a/lib/navigation/CMakeLists.txt b/lib/navigation/CMakeLists.txt
new file mode 100644
index 0000000..4a4cf94
--- /dev/null
+++ b/lib/navigation/CMakeLists.txt
@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.1.0)
+
+add_library(navigation
+ navigationbutton.cpp
+ navigationbutton.h
+ urlcompleter.cpp
+ urlcompleter.h
+ urllineedit.cpp
+ urllineedit.h)
+
+target_link_libraries(navigation Qt5::Widgets Qt5::WebEngineWidgets)
\ No newline at end of file
diff --git a/lib/navigation/navigationbutton.cpp b/lib/navigation/navigationbutton.cpp
new file mode 100644
index 0000000..13daebc
--- /dev/null
+++ b/lib/navigation/navigationbutton.cpp
@@ -0,0 +1,141 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "navigationbutton.h"
+
+#include
+#include
+#include
+
+NavigationButton::NavigationButton(Type type, QWidget *parent) :
+ QToolButton(parent)
+{
+ m_type = type;
+ menu = new QMenu(this);
+
+ switch (type) {
+ case BackButton:
+ setIcon(style()->standardIcon(QStyle::SP_ArrowBack));
+ setMenu(menu);
+ connect(menu, &QMenu::aboutToShow, this, &NavigationButton::prepareMenu);
+ break;
+ case ForwardButton:
+ setIcon(style()->standardIcon(QStyle::SP_ArrowForward));
+ setMenu(menu);
+ connect(menu, &QMenu::aboutToShow, this, &NavigationButton::prepareMenu);
+ break;
+ case ReloadButton:
+ setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
+ break;
+ case StopButton:
+ setIcon(style()->standardIcon(QStyle::SP_BrowserStop));
+ break;
+ }
+
+ connect(this, &NavigationButton::clicked, this, &NavigationButton::doAction);
+
+}
+
+
+void NavigationButton::setView(WebView *view)
+{
+ disconnect(loadStartedConnection);
+ disconnect(loadFinishedConnection);
+
+ m_view = view;
+ if(m_type == BackButton || m_type == ForwardButton) {
+ updateOnLoadFinished();
+ }
+
+ loadStartedConnection = connect(view, &WebView::loadStarted, this, &NavigationButton::updateOnLoadStarted);
+ loadFinishedConnection = connect(view, &WebView::loadFinished, this, &NavigationButton::updateOnLoadFinished);
+}
+
+void NavigationButton::updateOnLoadStarted()
+{
+ switch (m_type) {
+ case BackButton:
+ break;
+ case ForwardButton:
+ break;
+ case ReloadButton:
+ m_type = StopButton;
+ setIcon(style()->standardIcon(QStyle::SP_BrowserStop));
+ break;
+ case StopButton:
+ break;
+ }
+}
+
+void NavigationButton::updateOnLoadFinished()
+{
+ switch (m_type) {
+ case BackButton:
+ if(m_view->history()->canGoBack()) {
+ setEnabled(true);
+ } else {
+ setEnabled(false);
+ }
+ break;
+ case ForwardButton:
+ if(m_view->history()->canGoForward()) {
+ setEnabled(true);
+ } else {
+ setEnabled(false);
+ }
+ break;
+ case ReloadButton:
+ break;
+ case StopButton:
+ m_type = ReloadButton;
+ setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
+ break;
+ }
+}
+
+void NavigationButton::doAction()
+{
+ switch (m_type) {
+ case BackButton:
+ m_view->history()->back();
+ break;
+ case ForwardButton:
+ m_view->history()->forward();
+ break;
+ case ReloadButton:
+ m_view->reload();
+ break;
+ case StopButton:
+ m_view->stop();
+ break;
+ }
+}
+
+void NavigationButton::prepareMenu()
+{
+ menu->clear();
+
+ QList items;
+ switch (m_type) {
+ case BackButton:
+ items = m_view->history()->backItems(10);
+ break;
+ case ForwardButton:
+ items = m_view->history()->forwardItems(10);
+ break;
+ default:
+ break;
+ }
+
+ for(QWebEngineHistoryItem i : items) {
+ QAction *a = menu->addAction(i.title());
+ connect(a, &QAction::triggered, [i, this]() {
+ m_view->history()->goToItem(i);
+ });
+ }
+}
diff --git a/lib/navigation/navigationbutton.h b/lib/navigation/navigationbutton.h
new file mode 100644
index 0000000..7c76b9c
--- /dev/null
+++ b/lib/navigation/navigationbutton.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef NAVIGATIONBUTTON_H
+#define NAVIGATIONBUTTON_H
+
+#include
+#include "../../src/webengine/webview.h"
+
+class QMenu;
+
+class NavigationButton : public QToolButton
+{
+ Q_OBJECT
+public:
+
+ enum Type {
+ BackButton,
+ ForwardButton,
+ ReloadButton,
+ StopButton
+ };
+
+ explicit NavigationButton(Type type, QWidget *parent = nullptr);
+
+ void setView(WebView *view);
+
+signals:
+
+private slots:
+ void updateOnLoadStarted();
+ void updateOnLoadFinished();
+ void doAction();
+ void prepareMenu();
+
+private:
+ Type m_type;
+ QMenu *menu;
+ WebView *m_view;
+
+ QMetaObject::Connection loadStartedConnection, loadFinishedConnection;
+};
+
+#endif // NAVIGATIONBUTTON_H
diff --git a/lib/navigation/urlcompleter.cpp b/lib/navigation/urlcompleter.cpp
new file mode 100644
index 0000000..bbde297
--- /dev/null
+++ b/lib/navigation/urlcompleter.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "urlcompleter.h"
+
+UrlCompleter::UrlCompleter(QAbstractItemModel *model, QObject *parent) :
+ QCompleter(model, parent)
+{
+ setCompletionMode(QCompleter::PopupCompletion);
+ setFilterMode(Qt::MatchContains);
+}
+
+QStringList UrlCompleter::splitPath(const QString &path) const
+{
+ return path.split('.');
+}
+
+QString UrlCompleter::pathFromIndex(const QModelIndex &index) const
+{
+ return model()->data(index, completionRole()).toString();
+}
diff --git a/lib/navigation/urlcompleter.h b/lib/navigation/urlcompleter.h
new file mode 100644
index 0000000..f2c52ff
--- /dev/null
+++ b/lib/navigation/urlcompleter.h
@@ -0,0 +1,25 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef URLCOMPLETER_H
+#define URLCOMPLETER_H
+
+#include
+
+class UrlCompleter : public QCompleter
+{
+ Q_OBJECT
+public:
+ explicit UrlCompleter(QAbstractItemModel *model, QObject *parent = nullptr);
+
+protected:
+ QStringList splitPath(const QString &path) const override;
+ QString pathFromIndex(const QModelIndex &index) const override;
+};
+
+#endif // URLCOMPLETER_H
diff --git a/lib/navigation/urllineedit.cpp b/lib/navigation/urllineedit.cpp
new file mode 100644
index 0000000..24924bb
--- /dev/null
+++ b/lib/navigation/urllineedit.cpp
@@ -0,0 +1,136 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#include "urllineedit.h"
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+// ssl menu
+#include
+
+#include "../bookmarks/bookmarkswidget.h"
+
+#include
+
+UrlLineEdit::UrlLineEdit(QWidget *parent) :
+ QLineEdit(parent)
+{
+ setPlaceholderText(tr("Enter address"));
+
+ // ssl menu
+ m_sslMenu = new QMenu(this);
+ m_sslLabel = new QLabel(m_sslMenu);
+ QWidgetAction *sslErrorAction = new QWidgetAction(m_sslMenu);
+ sslErrorAction->setDefaultWidget(m_sslLabel);
+ m_sslMenu->addAction(sslErrorAction);
+
+ m_sslAction = addAction(style()->standardIcon(QStyle::SP_DriveNetIcon), QLineEdit::LeadingPosition);
+ m_sslAction->setToolTip(tr("TODO: Display SSL Status popup here"));
+ m_sslAction->setMenu(m_sslMenu);
+
+ connect(m_sslAction, &QAction::triggered, this, [this]() {
+ m_sslMenu->exec(this->mapToGlobal(QPoint(0, height())));
+ });
+
+ m_pageAction = addAction(style()->standardIcon(QStyle::SP_FileIcon), QLineEdit::TrailingPosition);
+ m_pageAction->setShortcut(QKeySequence("F10"));
+ m_pageAction->setToolTip(tr("Page Actions"));
+ connect(m_pageAction, &QAction::triggered, m_pageAction, [&]() {
+ //this->deselect();
+ if(m_pageAction->menu() != nullptr) {
+ m_pageAction->menu()->exec(this->mapToGlobal(QPoint(width(), height())));
+ }
+ });
+
+ QTextCharFormat hostnameFormat;
+ hostnameFormat.setFontWeight(QFont::Bold);
+ m_hostFormat.format = hostnameFormat;
+
+ // connect signals
+ connect(this, &QLineEdit::returnPressed, [this]() {
+ if(this->text().startsWith('#')) {
+ emit searchTermEntered(this->text().mid(1));
+ } else {
+ emit addressEntered(QUrl::fromUserInput(this->text()));
+ }
+ this->clearFocus();
+ });
+
+}
+
+QAction *UrlLineEdit::sslAction()
+{
+ Q_CHECK_PTR(m_sslAction);
+ return m_sslAction;
+}
+
+QAction *UrlLineEdit::pageAction()
+{
+ Q_CHECK_PTR(m_pageAction);
+ return m_pageAction;
+}
+
+void UrlLineEdit::setCompleterModel(QAbstractItemModel *model)
+{
+ Q_CHECK_PTR(model);
+ m_completer = new UrlCompleter(model, this);
+ m_completer->setCompletionColumn(1);
+ this->setCompleter(m_completer);
+}
+
+void UrlLineEdit::setUrl(const QUrl &url)
+{
+ QString urlText = url.toString();
+ QString domain = url.host();
+
+ m_hostFormat.start = urlText.indexOf(domain);
+ m_hostFormat.length = domain.length();
+
+ clear();
+ clearTextFormat();
+ setTextFormat(m_hostFormat);
+ setText(urlText);
+}
+
+void UrlLineEdit::showSslError(const QString &message)
+{
+ m_sslLabel->setText(message);
+ m_sslAction->trigger();
+}
+
+void UrlLineEdit::focusInEvent(QFocusEvent *event)
+{
+ clearTextFormat();
+
+ QLineEdit::focusInEvent(event);
+
+ // select the contents when receiving focus
+ // http://stackoverflow.com/a/35725950/1054406
+ // mousePressEvent triggers right after focusInEvent so text selected in focusInEvent unselects by mousePressEvent
+ //QTimer::singleShot(0, this, SLOT(selectAll()));
+}
+
+// formatting taken from: https://forum.qt.io/topic/60962/setting-qlineedit-text-bold
+void UrlLineEdit::setTextFormat(const QTextLayout::FormatRange &format)
+{
+ QList attributes;
+ attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, format.start, format.length, format.format));
+ QInputMethodEvent ev(QString(), attributes);
+ event(&ev);
+
+}
+
+void UrlLineEdit::clearTextFormat()
+{
+ setTextFormat(QTextLayout::FormatRange());
+}
diff --git a/lib/navigation/urllineedit.h b/lib/navigation/urllineedit.h
new file mode 100644
index 0000000..46366a7
--- /dev/null
+++ b/lib/navigation/urllineedit.h
@@ -0,0 +1,59 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: git://neueland.iserlohn-fortress.net/smolbote.git
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef URLLINEEDIT_H
+#define URLLINEEDIT_H
+
+#include
+#include
+#include
+
+#include "urlcompleter.h"
+
+class QAbstractItemModel;
+class QMenu;
+class QLabel;
+class UrlLineEdit : public QLineEdit
+{
+ Q_OBJECT
+public:
+ explicit UrlLineEdit(QWidget *parent = nullptr);
+
+ QAction *sslAction();
+ QAction *pageAction();
+
+ void setCompleterModel(QAbstractItemModel *model);
+
+signals:
+ void addressEntered(const QUrl &url);
+ void searchTermEntered(const QString &term);
+
+public slots:
+ void setUrl(const QUrl &url);
+ void showSslError(const QString &message);
+
+protected:
+ void focusInEvent(QFocusEvent *event);
+
+private:
+ void setTextFormat(const QTextLayout::FormatRange &format);
+ void clearTextFormat();
+
+ QTextLayout::FormatRange m_hostFormat;
+
+ QAction *m_sslAction = nullptr;
+ QAction *m_pageAction = nullptr;
+
+ // ssl menu
+ QMenu *m_sslMenu;
+ QLabel *m_sslLabel;
+
+ UrlCompleter *m_completer;
+};
+
+#endif // URLLINEEDIT_H
diff --git a/lib/settings/CMakeLists.txt b/lib/settings/CMakeLists.txt
new file mode 100644
index 0000000..704c40f
--- /dev/null
+++ b/lib/settings/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.1.0)
+
+add_library(configuration
+ configuration.cpp
+ configuration.h
+ settingsdialog.cpp
+ settingsdialog.h
+ settingsdialog.ui)
+
+target_link_libraries(configuration Qt5::Widgets)
\ No newline at end of file
diff --git a/lib/settings/configuration.cpp b/lib/settings/configuration.cpp
index 34d50db..4603779 100644
--- a/lib/settings/configuration.cpp
+++ b/lib/settings/configuration.cpp
@@ -214,6 +214,8 @@ void Configuration::setValue(std::string path, const T &val)
// compiler complained about operator= not taking unsinged ints, longs and long longs
if constexpr(std::is_unsigned_v && !std::is_same_v) {
setting = static_cast>(val);
+ } else if constexpr(std::is_same_v) {
+ setting = static_cast(val).c_str();
} else {
setting = val;
}
@@ -240,6 +242,8 @@ void Configuration::setValue(std::string path, const T &val)
if constexpr(std::is_unsigned_v && !std::is_same_v) {
*userSetting = static_cast>(val);
+ } else if constexpr(std::is_same_v) {
+ *userSetting = static_cast(val).c_str();
} else {
*userSetting = val;
}
diff --git a/lib/settings/settings.qbs b/lib/settings/settings.qbs
deleted file mode 100644
index 0559daa..0000000
--- a/lib/settings/settings.qbs
+++ /dev/null
@@ -1,38 +0,0 @@
-import qbs
-
-Project {
- name: "Settings"
-
- StaticLibrary {
- name: "settings"
-
- Depends { name: "cpp" }
-
- cpp.defines: "C_LIKE_CONFIG"
- cpp.cxxLanguageVersion: "c++17"
-
- files: [
- "configuration.cpp",
- "configuration.h"
- ]
- }
-
- StaticLibrary {
- name: "settingsDialog"
-
- Depends { name: "cpp" }
-
- Depends {
- name: "Qt"
- submodules: ["core", "widgets"]
- }
-
- cpp.cxxLanguageVersion: "c++17"
-
- files: [
- "settingsdialog.cpp",
- "settingsdialog.h",
- "settingsdialog.ui",
- ]
- }
-}
diff --git a/linux/makepkg/PKGBUILD b/linux/makepkg/PKGBUILD
index 31b2e9b..69cea4b 100644
--- a/linux/makepkg/PKGBUILD
+++ b/linux/makepkg/PKGBUILD
@@ -10,57 +10,36 @@ arch=('x86_64')
license=('GPL3')
depends=('qt5-base' 'qt5-webengine')
-makedepends=('git' 'qt5-tools' 'qbs' 'libconfig' 'pkg-config')
+makedepends=('git' 'qt5-tools' 'cmake' 'libconfig' 'pkg-config')
source=("git+git://neueland.iserlohn-fortress.net/smolbote.git")
sha512sums=('SKIP')
-# qmake location for your Qt version
-# Useful if you have another Qt version installed in a specific location
-_qmake='/usr/bin/qmake-qt5'
-
-# compiler profile for the qt profile
-_compiler='clang'
-
-# Target architecture: x86 x86_64 arm
-_architecture='x86_64'
-# Optimization level: none, fast, small
-_optimization='fast'
-
-# install root, ex: '/usr' or '/usr/local'
-# Should this install in /usr/bin, or in /usr/local/bin, or perhaps in /somewhere/else/bin?
-_installroot='/usr/local'
+prepare() {
+ # any patches go here
+}
pkgver() {
cd smolbote
echo "$(git describe --long --tags | tr - .)"
}
-prepare() {
- # Prepare qbs toolchain
- # qbs config location
- rm -rf config
- mkdir config
-
- qbs-setup-toolchains --settings-dir config --detect
- qbs-setup-qt --settings-dir config ${_qmake} qt
+build() {
+ cd "$pkgname-$pkgver"
- # set a custom compiler profile
- #qbs-config --settings-dir config profiles.${_compiler}.qbs.architecture ${_architecture}
- qbs-config --settings-dir config profiles.${_compiler}.qbs.optimization ${_optimization}
- qbs-config --settings-dir config profiles.qt.baseProfile ${_compiler}
+ # Generate a makefile
+ # Adjust the install prefix as necessary, default is /usr/local/bin
+ cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local "$srcdir"
- # Clear out the build folder
- rm -rf build
- mkdir build
-}
+ # Use this if you want to link with libc++ instead
+ # This requires clang, since gcc doesn't understand the concept of not using GPL software
+ #cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DUseLibCpp=On "$srcdir"
-build() {
- cd smolbote
- qbs build --settings-dir ../config -d ../build -p poi profile:qt release
+ # build, with 4 threads
+ make -j 4
}
package() {
- cd smolbote
- qbs install --settings-dir ../config -d ../build -p poi --install-root "${pkgdir}${_installroot}" profile:qt release
+ cd "$pkgname-$pkgver"
+ make install
}
diff --git a/mach b/mach
deleted file mode 100755
index 2fce8e9..0000000
--- a/mach
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/env ruby
-# DISCLAIMER: this is not Mozilla's mach
-
-require 'optparse'
-
-options = {
- :settingsDir => "../build/config",
- :profile => 'qt5',
- :build => 'release',
- :buildDir => '../build',
-}
-
-OptionParser.new do |opts|
- opts.banner = "Usage: ./mach [options]"
-
- opts.on("-h", "--help", "Prints this help") do
- puts opts
- puts "Options: #{options}"
- puts 'Commands: setup, run, clean, build'
- exit
- end
-
- opts.on("--profile", "Set profile") do |profile|
- options[:profile] = profile
- end
-
- opts.on("-d", "--build DIRECTORY", "Build location") do |dir|
- options[:buildDir] = dir
- end
-
- opts.on("-i", "--install DIRECTORY", "Install location") do |dir|
- options[:installDir] = dir
- end
-
- opts.on("--debug", "Debug build") do
- options[:build] = 'debug'
- end
-
- opts.on("--release", "Release build") do
- options[:build] = 'release'
- end
-
-end.parse!
-
-if not ARGV.empty? then
- ARGV.each do|arg|
- case arg
- when 'setup'
- system "qbs-setup-toolchains --settings-dir #{options[:settingsDir]} --detect"
- system "qbs-setup-qt --settings-dir #{options[:settingsDir]} /usr/bin/qmake-qt5 #{options[:profile]}"
- when 'run'
- system "qbs run --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} -p poi profile:#{options[:profile]} #{options[:build]}"
- when 'clean'
- system "qbs clean --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} profile:#{options[:profile]} #{options[:build]}"
- when 'build'
- system "qbs build --settings-dir #{options[:settingsDir]} -d #{options[:buildDir]} --force-probe-execution profile:#{options[:profile]} #{options[:build]}"
- else
- puts "Unknown argument #{arg}; use ./mach -h for more details"
- end
- end
-
-else
- puts 'No arguments; use ./mach -h for more details'
-end
-
diff --git a/smolbote.qbs b/smolbote.qbs
deleted file mode 100644
index 406874d..0000000
--- a/smolbote.qbs
+++ /dev/null
@@ -1,153 +0,0 @@
-import qbs
-import "tools/qbs/GitRepo.js" as GitRepo
-import qbs.Probes
-
-Project {
- id: project
- minimumQbsVersion: "1.8.0"
-
- property bool gitVersion: true
-
- // The following define makes your compiler emit warnings if you use any
- // feature of Qt which as been marked as deprecated (the exact warnings
- // depend on your compiler).
- property bool deprecatedWarnings: true
-
- // The code also fails to compile if you use APIs deprecated before Qt 5.9.
- property string deprecatedBefore: "0x050900"
-
- references: [
- "src/lib/bookmarks/bookmarks.qbs",
- "src/lib/downloads/downloads.qbs",
- "src/lib/navigation/navigation.qbs",
- "lib/settings/settings.qbs",
- ]
-
- Probes.PkgConfigProbe {
- id: libconfig
- name: "libconfig++"
- }
-
- Probe {
- id: git
- property string version: ""
- property string describe: ""
- configure: {
- if(project.gitVersion) {
- var meta = GitRepo.read(project.sourceDirectory);
- version = meta.version;
- found = true;
- }
- }
- }
-
- CppApplication {
- id: poi
- name: "poi"
-
- Depends {
- name: "Qt"
- versionAtLeast: "5.7.1"
- submodules: ["core", "widgets", "webenginecore", "webenginewidgets", "printsupport"]
- }
-
- Depends { name: "navigation" }
- Depends { name: "bookmarks" }
- Depends { name: "downloads" }
- Depends { name: "settings" }
- Depends { name: "settingsDialog" }
-
- // global includes
- cpp.includePaths: ['src', 'src/lib', 'lib']
- // global defines
- cpp.defines: {
- var defs = [];
- if(project.deprecatedWarnings) {
- defs.push("QT_DEPRECATED_WARNINGS", "QT_DISABLE_DEPRECATED_BEFORE="+project.deprecatedBefore);
- }
-
- return defs;
- }
-
- cpp.cxxLanguageVersion: "c++17"
-
- cpp.linkerFlags: libconfig.libs
-
- Group {
- name: "main"
- files: [
- "src/main.cpp",
- ]
- cpp.defines: outer.concat(["GIT_VERSION=\""+git.version+"\""])
- }
-
- Group {
- name: "Browser"
- files: [
- "src/browser.cpp",
- "src/browser.h",
- "src/singleapplication.cpp",
- "src/singleapplication.h",
- ]
- }
-
- Group {
- name: "Main Window"
- files: [
- "src/mainwindow.cpp",
- "src/mainwindow.h",
- "src/mainwindow.ui",
- "src/forms/aboutdialog.cpp",
- "src/forms/aboutdialog.h",
- "src/forms/aboutdialog.ui",
- "src/forms/searchform.cpp",
- "src/forms/searchform.h",
- "src/forms/searchform.ui",
- "src/webengine/webpage.cpp",
- "src/webengine/webpage.h",
- "src/webengine/webview.cpp",
- "src/webengine/webview.h",
- "src/widgets/loadingbar.cpp",
- "src/widgets/loadingbar.h",
- "src/widgets/mainwindowmenubar.cpp",
- "src/widgets/mainwindowmenubar.h",
- "src/widgets/mainwindowtabbar.cpp",
- "src/widgets/mainwindowtabbar.h",
- ]
- }
-
- Group {
- name: "Request Filter"
- files: [
- "src/webengine/urlinterceptor.cpp",
- "src/webengine/urlinterceptor.h",
- ]
- }
-
- Group {
- name: "Profile"
- files: [
- "src/forms/cookiesform.cpp",
- "src/forms/cookiesform.h",
- "src/forms/cookiesform.ui",
- "src/forms/profileview.cpp",
- "src/forms/profileview.h",
- "src/forms/profileview.ui",
- "src/webengine/webengineprofile.cpp",
- "src/webengine/webengineprofile.h",
- ]
- }
-
- files: [
- "data/resources.qrc",
- ]
-
- Group {
- name: "Executable"
- fileTagsFilter: product.type
- qbs.install: true
- qbs.installDir: "bin"
- }
- } // CppApplication poi
-
-}
diff --git a/src/forms/aboutdialog.cpp b/src/forms/aboutdialog.cpp
index 25c5384..3f89118 100644
--- a/src/forms/aboutdialog.cpp
+++ b/src/forms/aboutdialog.cpp
@@ -8,6 +8,28 @@
#include "aboutdialog.h"
#include "ui_aboutdialog.h"
+#include "version.h"
+
+constexpr const char *getCompiler()
+{
+ // clang also defines __GNUC__, so we need to check for clang first
+#if defined(__clang__)
+ return "Clang " __clang_version__;
+#elif defined(__GNUC__)
+ return "GCC " __VERSION__;
+#else
+ return "unknown compiler";
+#endif
+}
+
+inline const QString getLongVersion()
+{
+#ifdef GIT_DESCRIBE
+ return QString(GIT_DESCRIBE);
+#else
+ return qApp->applicationVersion();
+#endif
+}
AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent),
@@ -22,7 +44,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
aboutLabel->setWordWrap(true);
aboutLabel->setText(tr("smolbote %1
"
"yet another Qute browser
")
- .arg(qApp->applicationVersion().left(qApp->applicationVersion().indexOf('-'))));
+ .arg(qApp->applicationVersion()));
ui->toolBox->addItem(aboutLabel, tr("About"));
QLabel *licenseLabel = new QLabel(this);
@@ -50,7 +72,7 @@ AboutDialog::AboutDialog(QWidget *parent) :
"Qt %3"
"libconfig"
"
")
- .arg(qApp->applicationVersion(), getCompiler(), qVersion()));
+ .arg(getLongVersion(), getCompiler(), qVersion()));
ui->toolBox->addItem(libsLabel, tr("Details"));
}
@@ -58,14 +80,3 @@ AboutDialog::~AboutDialog()
{
delete ui;
}
-
-constexpr const char *getCompiler()
-{
-#if defined(__clang__)
- return "Clang " __clang_version__;
-#elif defined(__GNUC__)
- return "GCC " __VERSION__;
-#else
- return "unknown compiler";
-#endif
-}
diff --git a/src/forms/aboutdialog.h b/src/forms/aboutdialog.h
index ba848e7..9f2189e 100644
--- a/src/forms/aboutdialog.h
+++ b/src/forms/aboutdialog.h
@@ -27,6 +27,4 @@ private:
Ui::AboutDialog *ui;
};
-constexpr const char* getCompiler();
-
#endif // ABOUTDIALOG_H
diff --git a/src/interfaces.h b/src/interfaces.h
deleted file mode 100644
index f42b513..0000000
--- a/src/interfaces.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef INTERFACES_H
-#define INTERFACES_H
-
-#include
-
-class QString;
-class QWidget;
-class QAction;
-
-class PluginInterface
-{
-public:
- virtual QString name() const = 0;
-};
-
-class GuiInterface
-{
-public:
- // The widget that should be displayed for this plugin
- virtual QWidget *widget() = 0;
- // The action that should trigger displaying the widget
- virtual QAction *action() = 0;
-};
-
-#define PluginInterface_iid "net.iserlohn-fortress.poi.PluginInterface"
-
-Q_DECLARE_INTERFACE(PluginInterface, PluginInterface_iid)
-
-#define GuiInterface_iid "net.iserlohn-fortress.poi.GuiInterface"
-
-Q_DECLARE_INTERFACE(GuiInterface, GuiInterface_iid)
-
-#endif // INTERFACES_H
diff --git a/src/lib/bookmarks/bookmarks.qbs b/src/lib/bookmarks/bookmarks.qbs
deleted file mode 100644
index 211b017..0000000
--- a/src/lib/bookmarks/bookmarks.qbs
+++ /dev/null
@@ -1,25 +0,0 @@
-import qbs 1.0
-
-Project {
- name: "bookmarks"
-
- StaticLibrary {
- id: bookmarks
- name: "bookmarks"
-
- cpp.includePaths: ['../..']
-
- Depends {
- name: "Qt"
- submodules: ["core", "widgets"]
- }
-
- files: [
- "bookmarksform.ui",
- "bookmarkswidget.cpp",
- "bookmarkswidget.h",
- "xbel.cpp",
- "xbel.h",
- ]
- }
-}
diff --git a/src/lib/bookmarks/bookmarksform.ui b/src/lib/bookmarks/bookmarksform.ui
deleted file mode 100644
index 2df0c4b..0000000
--- a/src/lib/bookmarks/bookmarksform.ui
+++ /dev/null
@@ -1,104 +0,0 @@
-
-
- BookmarksDialog
-
-
-
- 0
- 0
- 420
- 600
-
-
-
-
- 420
- 600
-
-
-
- Bookmarks
-
-
- -
-
-
-
-
-
- ...
-
-
-
- -
-
-
- ...
-
-
-
- -
-
-
- ...
-
-
-
- -
-
-
- ...
-
-
-
-
-
- -
-
-
- true
-
-
- QAbstractItemView::InternalMove
-
-
- Qt::MoveAction
-
-
-
- Title
-
-
-
-
- href
-
-
-
-
- -
-
-
- Details
-
-
-
-
-
-
- href
-
-
-
- -
-
-
- -
-
-
-
-
-
-
-
-
-
-
diff --git a/src/lib/bookmarks/bookmarkswidget.cpp b/src/lib/bookmarks/bookmarkswidget.cpp
deleted file mode 100644
index cb191c7..0000000
--- a/src/lib/bookmarks/bookmarkswidget.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "bookmarkswidget.h"
-#include "ui_bookmarksform.h"
-#include
-#include
-
-BookmarksWidget::BookmarksWidget(const QString &path, QWidget *parent) :
- QWidget(parent),
- ui(new Ui::BookmarksDialog)
-{
- // make sure this dialog does not get deleted on close
- setAttribute(Qt::WA_DeleteOnClose, false);
- setWindowTitle(tr("Bookmarks"));
-
- ui->setupUi(this);
- ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
-
- QStyle *style = ui->treeWidget->style();
- ui->addFolder_toolButton->setIcon(style->standardPixmap(QStyle::SP_DirIcon));
- ui->addBookmark_toolButton->setIcon(style->standardPixmap(QStyle::SP_FileIcon));
- ui->deleteItem_toolButton->setIcon(style->standardPixmap(QStyle::SP_TrashIcon));
-
- connect(ui->treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(showItemDetails()));
- connect(ui->treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(openItem(QTreeWidgetItem*,int)));
-
- ui->deleteItem_toolButton->setShortcut(QKeySequence::Delete);
-
- m_path = path;
- xbel = new Xbel(ui->treeWidget);
- qDebug("Reading bookmarks [%s] %s", qUtf8Printable(m_path), xbel->read(m_path) ? "ok" : "failed");
-
- connect(ui->addFolder_toolButton, &QToolButton::clicked, this, [&]() {
- xbel->addFolder(ui->treeWidget->currentItem());
- });
- connect(ui->addBookmark_toolButton, &QToolButton::clicked, this, [&]() {
- xbel->addBookmark(ui->treeWidget->currentItem());
- });
- connect(ui->deleteItem_toolButton, &QToolButton::clicked, this, [&]() {
- delete ui->treeWidget->currentItem();
- });
-
- // editing bookmarks
- connect(ui->title_lineEdit, &QLineEdit::returnPressed, this, [&]() {
- ui->treeWidget->currentItem()->setText(0, ui->title_lineEdit->text());
- });
- connect(ui->href_lineEdit, &QLineEdit::returnPressed, this, [&]() {
- ui->treeWidget->currentItem()->setText(1, ui->href_lineEdit->text());
- });
-}
-
-BookmarksWidget::~BookmarksWidget()
-{
- delete xbel;
- delete ui;
-}
-
-void BookmarksWidget::save()
-{
- qDebug("Writing bookmarks [%s] %s", qUtf8Printable(m_path), xbel->write(m_path) ? "ok" : "failed");
-}
-
-QStringList BookmarksWidget::bookmarksFor(const QString &term)
-{
- QStringList ret;
- for(int i = 0; i < ui->treeWidget->topLevelItemCount(); ++i) {
- ret += searchItem(ui->treeWidget->topLevelItem(i), term);
- }
- return ret;
-}
-
-QAbstractItemModel *BookmarksWidget::model() const
-{
- return ui->treeWidget->model();
-}
-
-QStringList BookmarksWidget::searchItem(QTreeWidgetItem *item, const QString &term)
-{
- if(item->text(1).contains(term)) {
- return { item->text(1) };
- }
-
- QStringList ret;
- for(int i = 0; i < item->childCount(); ++i) {
- ret += searchItem(item->child(i), term);
- }
- return ret;
-}
-
-void BookmarksWidget::openItem(QTreeWidgetItem *item, int column)
-{
- Q_UNUSED(column)
- emit openUrl(QUrl::fromUserInput(item->text(1)));
-}
-
-void BookmarksWidget::showItemDetails()
-{
- QTreeWidgetItem *item = ui->treeWidget->currentItem();
- if(!item) {
- ui->title_lineEdit->setText("");
- ui->href_label->setText("");
- return;
- }
- ui->title_lineEdit->setText(item->text(0));
- ui->href_lineEdit->setText(item->text(1));
-}
diff --git a/src/lib/bookmarks/bookmarkswidget.h b/src/lib/bookmarks/bookmarkswidget.h
deleted file mode 100644
index aa188b2..0000000
--- a/src/lib/bookmarks/bookmarkswidget.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef BOOKMARKSDIALOG_H
-#define BOOKMARKSDIALOG_H
-
-#include
-#include "xbel.h"
-#include
-
-namespace Ui {
-class BookmarksDialog;
-}
-
-class BookmarksWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit BookmarksWidget(const QString &path, QWidget *parent = 0);
- ~BookmarksWidget();
-
- void save();
-
-signals:
- void openUrl(const QUrl &url);
-
-public slots:
- QStringList bookmarksFor(const QString &term);
- QAbstractItemModel *model() const;
-
-private slots:
- void openItem(QTreeWidgetItem *item, int column);
- void showItemDetails();
-
-private:
- QStringList searchItem(QTreeWidgetItem *item, const QString &term);
-
- QString m_path;
- Ui::BookmarksDialog *ui;
- Xbel *xbel;
-};
-
-#endif // BOOKMARKSDIALOG_H
diff --git a/src/lib/bookmarks/xbel.cpp b/src/lib/bookmarks/xbel.cpp
deleted file mode 100644
index 523ed99..0000000
--- a/src/lib/bookmarks/xbel.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "xbel.h"
-#include
-
-#include
-
-Xbel::Xbel(QTreeWidget *widget)
-{
- treeWidget = widget;
-
- QStyle *style = treeWidget->style();
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirOpenIcon), QIcon::Normal, QIcon::On);
- folderIcon.addPixmap(style->standardPixmap(QStyle::SP_DirClosedIcon), QIcon::Normal, QIcon::Off);
- bookmarkIcon.addPixmap(style->standardPixmap(QStyle::SP_FileIcon));
-}
-
-bool Xbel::read(const QString &xbel)
-{
- // no file specified
- if(xbel.isEmpty()) {
- return false;
- }
-
- QFile file(xbel);
- if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
- // file cannot be opened
- return false;
- }
-
- xmlReader.setDevice(&file);
-
- if(xmlReader.readNextStartElement()) {
- if(xmlReader.name() == "xbel" && xmlReader.attributes().value("version") == "1.0") {
- qDebug("valid xbel");
- readChildElements(0);
- } else {
- qDebug("invalid xbel");
- return false;
- }
-
- }
- return true;
-}
-
-bool Xbel::write(const QString &xbel)
-{
- // no file specified
- if(xbel.isEmpty()) {
- return false;
- }
-
- QFile file(xbel);
- if(!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
- // file cannot be opened
- qDebug("Cannot open xbel: %s", qUtf8Printable(xbel));
- return false;
- }
-
- xmlWriter.setAutoFormatting(true);
- xmlWriter.setDevice(&file);
-
- xmlWriter.writeStartDocument();
- xmlWriter.writeDTD("");
- xmlWriter.writeStartElement("xbel");
- xmlWriter.writeAttribute("version", "1.0");
-
- for(int i=0; itopLevelItemCount(); i++) {
- writeItem(treeWidget->topLevelItem(i));
- }
-
- xmlWriter.writeEndDocument();
-
- file.flush();
- file.close();
- return true;
-}
-
-void Xbel::readChildElements(QTreeWidgetItem *parentItem)
-{
- while(xmlReader.readNextStartElement()) {
- if(xmlReader.name() == "title") {
- readTitle(parentItem);
- } else if(xmlReader.name() == "folder") {
- QTreeWidgetItem *item = addFolder(parentItem);
- item->setText(1, xmlReader.attributes().value("href").toString());
- readChildElements(item);
- } else if(xmlReader.name() == "bookmark") {
- QTreeWidgetItem *item = addBookmark(parentItem);
- item->setText(1, xmlReader.attributes().value("href").toString());
- readChildElements(item);
- } else if(xmlReader.name() == "separator") {
- addSeparator(parentItem);
- xmlReader.skipCurrentElement();
- } else {
- xmlReader.skipCurrentElement();
- }
- }
-}
-
-void Xbel::readTitle(QTreeWidgetItem *item)
-{
- item->setText(0, xmlReader.readElementText());
-}
-
-QTreeWidgetItem *Xbel::addFolder(QTreeWidgetItem *parentItem)
-{
- QTreeWidgetItem *folderItem = createChildItem(parentFolder(parentItem), "folder");
- //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);
-
- return folderItem;
-}
-
-QTreeWidgetItem *Xbel::addBookmark(QTreeWidgetItem *parentItem)
-{
- QTreeWidgetItem *bookmarkItem = createChildItem(parentFolder(parentItem), "bookmark");
- bookmarkItem->setFlags((bookmarkItem->flags() | Qt::ItemIsEditable) & ~Qt::ItemIsDropEnabled);
- bookmarkItem->setIcon(0, bookmarkIcon);
- bookmarkItem->setText(0, "Unknown Title");
- bookmarkItem->setText(1, "Unknown Address");
-
- return bookmarkItem;
-}
-
-void Xbel::addSeparator(QTreeWidgetItem *parentItem)
-{
- QTreeWidgetItem *separatorItem = createChildItem(parentFolder(parentItem), "separator");
- separatorItem->setFlags(separatorItem->flags() & ~Qt::ItemIsDropEnabled);
- separatorItem->setText(0, "-----");
-}
-
-QTreeWidgetItem *Xbel::parentFolder(QTreeWidgetItem *item)
-{
- QTreeWidgetItem *parentItem = item;
-
- if(parentItem) {
- while(parentItem->data(0, Qt::UserRole) != "folder") {
- parentItem = parentItem->parent();
- if(parentItem == 0) {
- break;
- }
- }
- }
-
- return parentItem;
-}
-
-QTreeWidgetItem *Xbel::createChildItem(QTreeWidgetItem *item, const QString &type)
-{
- QTreeWidgetItem *childItem;
- if(item) {
- childItem = new QTreeWidgetItem(item);
- } else {
- childItem = new QTreeWidgetItem(treeWidget);
- }
- childItem->setData(0, Qt::UserRole, type);
- return childItem;
-}
-
-void Xbel::writeItem(QTreeWidgetItem *item)
-{
- QString tagName = item->data(0, Qt::UserRole).toString();
- if (tagName == "folder") {
- xmlWriter.writeStartElement(tagName);
- if(!item->text(1).isEmpty()) {
- xmlWriter.writeAttribute("href", item->text(1));
- }
- xmlWriter.writeAttribute("folded", treeWidget->isItemExpanded(item) ? "no" : "yes");
- xmlWriter.writeTextElement("title", item->text(0));
- for (int i = 0; i < item->childCount(); ++i) {
- writeItem(item->child(i));
- }
- xmlWriter.writeEndElement();
- } else if (tagName == "bookmark") {
- xmlWriter.writeStartElement(tagName);
- if (!item->text(1).isEmpty()) {
- xmlWriter.writeAttribute("href", item->text(1));
- }
- xmlWriter.writeTextElement("title", item->text(0));
- xmlWriter.writeEndElement();
- } else if (tagName == "separator") {
- xmlWriter.writeEmptyElement(tagName);
- }
-}
diff --git a/src/lib/bookmarks/xbel.h b/src/lib/bookmarks/xbel.h
deleted file mode 100644
index ed0a256..0000000
--- a/src/lib/bookmarks/xbel.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef XBELREADER_H
-#define XBELREADER_H
-
-#include
-#include
-
-class QTreeWidget;
-class QTreeWidgetItem;
-class Xbel
-{
-public:
- explicit Xbel(QTreeWidget *widget);
- bool read(const QString &xbel);
- bool write(const QString &xbel);
-
- QTreeWidgetItem *addFolder(QTreeWidgetItem *parentItem);
- QTreeWidgetItem *addBookmark(QTreeWidgetItem *parentItem);
- void addSeparator(QTreeWidgetItem *parentItem);
-
-private:
- void readChildElements(QTreeWidgetItem *parentItem);
- void readTitle(QTreeWidgetItem *item);
-
- QTreeWidgetItem *parentFolder(QTreeWidgetItem *item);
- QTreeWidgetItem *createChildItem(QTreeWidgetItem *item, const QString &type);
-
- void writeItem(QTreeWidgetItem *item);
-
- QIcon folderIcon;
- QIcon bookmarkIcon;
-
- QTreeWidget *treeWidget;
- QXmlStreamReader xmlReader;
- QXmlStreamWriter xmlWriter;
-};
-
-#endif // XBELREADER_H
diff --git a/src/lib/downloads/downloads.qbs b/src/lib/downloads/downloads.qbs
deleted file mode 100644
index bdb18ad..0000000
--- a/src/lib/downloads/downloads.qbs
+++ /dev/null
@@ -1,28 +0,0 @@
-import qbs 1.0
-
-Project {
- name: "downloads"
-
- StaticLibrary {
- id: downloads
- name: "downloads"
-
- cpp.includePaths: ['.', '../..']
-
- Depends {
- name: "Qt"
- submodules: ["core", "widgets", "webenginewidgets"]
- }
-
- files: [
- "downloadsform.ui",
- "downloadswidget.cpp",
- "downloadswidget.h",
- "widgets/downloaditemform.ui",
- "widgets/downloaditemwidget.cpp",
- "widgets/downloaditemwidget.h",
- "widgets/elidedlabel.cpp",
- "widgets/elidedlabel.h",
- ]
- }
-}
diff --git a/src/lib/downloads/downloadsform.ui b/src/lib/downloads/downloadsform.ui
deleted file mode 100644
index 43a0d49..0000000
--- a/src/lib/downloads/downloadsform.ui
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
- DownloadDialog
-
-
-
- 0
- 0
- 600
- 420
-
-
-
- Downloads
-
-
- -
-
-
-
-
-
-
-
diff --git a/src/lib/downloads/downloadswidget.cpp b/src/lib/downloads/downloadswidget.cpp
deleted file mode 100644
index f9a8f34..0000000
--- a/src/lib/downloads/downloadswidget.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "downloadswidget.h"
-#include "ui_downloadsform.h"
-
-#include
-#include
-#include
-#include
-#include
-#include "widgets/downloaditemwidget.h"
-
-DownloadsWidget::DownloadsWidget(const QString &downloadPath, QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DownloadDialog)
-{
- // make sure this dialog does not get deleted on close
- setAttribute(Qt::WA_DeleteOnClose, false);
- setWindowTitle(tr("Downloads"));
-
- ui->setupUi(this);
-
- m_downloadPath = downloadPath;
-
- connect(ui->listWidget, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *previous) {
- DownloadItemWidget *currentWidget = qobject_cast(ui->listWidget->itemWidget(current));
- currentWidget->showDetails();
- currentWidget->setFixedWidth(ui->listWidget->viewport()->width());
- currentWidget->adjustSize();
- current->setSizeHint(currentWidget->size());
-
- DownloadItemWidget *previousWidget = qobject_cast(ui->listWidget->itemWidget(previous));
- if(previousWidget != nullptr) {
- previousWidget->hideDetails();
- previousWidget->setFixedWidth(ui->listWidget->viewport()->width());
- previousWidget->adjustSize();
- previous->setSizeHint(previousWidget->size());
- }
- });
-}
-
-DownloadsWidget::~DownloadsWidget()
-{
- delete ui;
-}
-
-void DownloadsWidget::addDownload(QWebEngineDownloadItem *item)
-{
- this->show();
-
- QString filepath = QFileDialog::getSaveFileName(this,
- tr("Save"),
- m_downloadPath + "/" + QFileInfo(item->path()).fileName());
-
- if(filepath.isEmpty()) {
- // user cancelled the save dialog
- item->cancel();
- return;
- }
-
- item->setPath(filepath);
-
- QListWidgetItem *listItem = new QListWidgetItem();
- int rowIndex = ui->listWidget->count();
- ui->listWidget->insertItem(rowIndex, listItem);
-
- DownloadItemWidget *form = new DownloadItemWidget(item, this);
- ui->listWidget->setItemWidget(listItem, form);
-
- item->accept();
-
- ui->listWidget->setCurrentRow(rowIndex);
-}
-
-void DownloadsWidget::resizeEvent(QResizeEvent *event)
-{
- QWidget::resizeEvent(event);
-
- for(int i = 0; i < ui->listWidget->count(); ++i) {
- QWidget *w = ui->listWidget->itemWidget(ui->listWidget->item(i));
- w->setFixedWidth(ui->listWidget->viewport()->width());
- w->adjustSize();
- ui->listWidget->item(i)->setSizeHint(w->size());
- }
-}
diff --git a/src/lib/downloads/downloadswidget.h b/src/lib/downloads/downloadswidget.h
deleted file mode 100644
index 8c9ea21..0000000
--- a/src/lib/downloads/downloadswidget.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef DOWNLOADDIALOG_H
-#define DOWNLOADDIALOG_H
-
-#include
-
-namespace Ui {
-class DownloadDialog;
-}
-
-class QWebEngineDownloadItem;
-class DownloadsWidget : public QDialog
-{
- Q_OBJECT
-
-public:
- explicit DownloadsWidget(const QString &downloadPath, QWidget *parent = nullptr);
- ~DownloadsWidget();
-
-public slots:
- void addDownload(QWebEngineDownloadItem *item);
-
-protected:
- void resizeEvent(QResizeEvent *event) override;
-
-private:
- Ui::DownloadDialog *ui;
- QString m_downloadPath;
-};
-
-#endif // DOWNLOADDIALOG_H
diff --git a/src/lib/downloads/widgets/downloaditemform.ui b/src/lib/downloads/widgets/downloaditemform.ui
deleted file mode 100644
index 17f1d6a..0000000
--- a/src/lib/downloads/widgets/downloaditemform.ui
+++ /dev/null
@@ -1,74 +0,0 @@
-
-
- DownloadItemForm
-
-
-
- 0
- 0
- 500
- 122
-
-
-
-
- 0
- 0
-
-
-
- Form
-
-
-
- 0
-
- -
-
-
- [url]
-
-
-
- -
-
-
- 24
-
-
-
- -
-
-
-
-
-
-
- status_label
-
-
-
- -
-
-
- path_label
-
-
- true
-
-
-
-
-
-
-
-
-
-
- ElidedLabel
- QLabel
-
-
-
-
-
-
diff --git a/src/lib/downloads/widgets/downloaditemwidget.cpp b/src/lib/downloads/widgets/downloaditemwidget.cpp
deleted file mode 100644
index fff3cfc..0000000
--- a/src/lib/downloads/widgets/downloaditemwidget.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "downloaditemwidget.h"
-#include "ui_downloaditemform.h"
-
-#include
-#include
-
-DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent) :
- QWidget(parent),
- ui(new Ui::DownloadItemForm)
-{
- m_item = item;
-
- ui->setupUi(this);
-
- ui->url_label->setContent(item->url().toString());
- ui->detailsWidget->hide();
-
- ui->path_label->setText(item->path());
-
- connect(item, &QWebEngineDownloadItem::stateChanged, this, &DownloadItemWidget::updateState);
- connect(item, &QWebEngineDownloadItem::downloadProgress, this, &DownloadItemWidget::updateProgress);
- connect(item, &QWebEngineDownloadItem::finished, this, &DownloadItemWidget::updateFinished);
-}
-
-DownloadItemWidget::~DownloadItemWidget()
-{
- delete ui;
-}
-
-void DownloadItemWidget::showDetails()
-{
- ui->detailsWidget->show();
-}
-
-void DownloadItemWidget::hideDetails()
-{
- ui->detailsWidget->hide();
-}
-
-QWebEngineDownloadItem *DownloadItemWidget::item() const
-{
- return m_item;
-}
-
-QString DownloadItemWidget::sizeString(int size) const
-{
- if(size < 1024) {
- return QString("%1 bytes").arg(size);
- }
- // KiB
- if(size < 1024 * 1024) {
- return QString("%1 kB").arg(size / 1024);
- }
- // MiB
- if(size < 1024 * 1024 * 1024) {
- return QString("%1 MB").arg(size / (1024 * 1024));
- }
- // GiB
- return QString("%1 GB").arg(size / (1024 * 1024 * 1024));
-}
-
-void DownloadItemWidget::updateState(QWebEngineDownloadItem::DownloadState state)
-{
- switch (state) {
- case QWebEngineDownloadItem::DownloadRequested:
- ui->status_label->setText(tr("Requested"));
- break;
- case QWebEngineDownloadItem::DownloadInProgress:
- ui->status_label->setText(tr("In progress"));
- break;
- case QWebEngineDownloadItem::DownloadCompleted:
- ui->status_label->setText(tr("Completed"));
- break;
- case QWebEngineDownloadItem::DownloadCancelled:
- ui->status_label->setText(tr("Cancelled"));
- break;
- case QWebEngineDownloadItem::DownloadInterrupted:
- ui->status_label->setText(tr("Interrupted"));
- break;
- default:
- break;
- }
-}
-
-void DownloadItemWidget::updateProgress(qint64 value, qint64 total)
-{
- ui->progressBar->setMaximum(total);
- ui->progressBar->setValue(value);
- ui->progressBar->setFormat(QString("%1 / %2").arg(sizeString(value), sizeString(total)));
-}
-
-void DownloadItemWidget::updateFinished()
-{
- ui->progressBar->setValue(ui->progressBar->maximum());
-}
diff --git a/src/lib/downloads/widgets/downloaditemwidget.h b/src/lib/downloads/widgets/downloaditemwidget.h
deleted file mode 100644
index c6246da..0000000
--- a/src/lib/downloads/widgets/downloaditemwidget.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef DOWNLOADITEMFORM_H
-#define DOWNLOADITEMFORM_H
-
-#include
-#include
-
-namespace Ui {
-class DownloadItemForm;
-}
-
-class DownloadItemWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent = 0);
- ~DownloadItemWidget();
-
- void showDetails();
- void hideDetails();
-
- QWebEngineDownloadItem *item() const;
- QString sizeString(int size) const;
-
-private slots:
- void updateState(QWebEngineDownloadItem::DownloadState state);
- void updateProgress(qint64 value, qint64 total);
- void updateFinished();
-
-private:
- Ui::DownloadItemForm *ui;
- QWebEngineDownloadItem *m_item;
-};
-
-#endif // DOWNLOADITEMFORM_H
diff --git a/src/lib/downloads/widgets/elidedlabel.cpp b/src/lib/downloads/widgets/elidedlabel.cpp
deleted file mode 100644
index dc17d32..0000000
--- a/src/lib/downloads/widgets/elidedlabel.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "elidedlabel.h"
-
-#include
-#include
-#include
-
-ElidedLabel::ElidedLabel(QWidget *parent)
- : QLabel(parent)
- , elided(false)
- , content("elided_label")
-{
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
-}
-
-void ElidedLabel::setContent(const QString &newText)
-{
- content = newText;
- setText(newText);
-}
-
-void ElidedLabel::resizeEvent(QResizeEvent *event)
-{
- QLabel::resizeEvent(event);
-
- QFontMetrics font = this->fontMetrics();
- QString elidedLine = font.elidedText(content, Qt::ElideRight, width());
- setText(elidedLine);
-}
diff --git a/src/lib/downloads/widgets/elidedlabel.h b/src/lib/downloads/widgets/elidedlabel.h
deleted file mode 100644
index d0f6221..0000000
--- a/src/lib/downloads/widgets/elidedlabel.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef ELIDEDLABEL_H
-#define ELIDEDLABEL_H
-
-#include
-
-class ElidedLabel : public QLabel
-{
-
-public:
- explicit ElidedLabel(QWidget *parent = nullptr);
-
- void setContent(const QString &text);
- const QString & text() const {
- return content;
- }
- bool isElided() const {
- return elided;
- }
-
-protected:
- void resizeEvent(QResizeEvent *event) override;
-
-private:
- bool elided;
- QString content;
-};
-
-#endif // ELIDEDLABEL_H
diff --git a/src/lib/navigation/navigation.qbs b/src/lib/navigation/navigation.qbs
deleted file mode 100644
index 7719fbc..0000000
--- a/src/lib/navigation/navigation.qbs
+++ /dev/null
@@ -1,26 +0,0 @@
-import qbs 1.0
-
-Project {
- name: "navigation"
-
- StaticLibrary {
- id: navigation
- name: "navigation"
-
- cpp.includePaths: ['../..']
-
- Depends {
- name: "Qt"
- submodules: ["core", "widgets", "webengine", "webenginewidgets"]
- }
-
- files: [
- "navigationbutton.cpp",
- "navigationbutton.h",
- "urlcompleter.cpp",
- "urlcompleter.h",
- "urllineedit.cpp",
- "urllineedit.h",
- ]
- }
-}
diff --git a/src/lib/navigation/navigationbutton.cpp b/src/lib/navigation/navigationbutton.cpp
deleted file mode 100644
index 13daebc..0000000
--- a/src/lib/navigation/navigationbutton.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "navigationbutton.h"
-
-#include
-#include
-#include
-
-NavigationButton::NavigationButton(Type type, QWidget *parent) :
- QToolButton(parent)
-{
- m_type = type;
- menu = new QMenu(this);
-
- switch (type) {
- case BackButton:
- setIcon(style()->standardIcon(QStyle::SP_ArrowBack));
- setMenu(menu);
- connect(menu, &QMenu::aboutToShow, this, &NavigationButton::prepareMenu);
- break;
- case ForwardButton:
- setIcon(style()->standardIcon(QStyle::SP_ArrowForward));
- setMenu(menu);
- connect(menu, &QMenu::aboutToShow, this, &NavigationButton::prepareMenu);
- break;
- case ReloadButton:
- setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
- break;
- case StopButton:
- setIcon(style()->standardIcon(QStyle::SP_BrowserStop));
- break;
- }
-
- connect(this, &NavigationButton::clicked, this, &NavigationButton::doAction);
-
-}
-
-
-void NavigationButton::setView(WebView *view)
-{
- disconnect(loadStartedConnection);
- disconnect(loadFinishedConnection);
-
- m_view = view;
- if(m_type == BackButton || m_type == ForwardButton) {
- updateOnLoadFinished();
- }
-
- loadStartedConnection = connect(view, &WebView::loadStarted, this, &NavigationButton::updateOnLoadStarted);
- loadFinishedConnection = connect(view, &WebView::loadFinished, this, &NavigationButton::updateOnLoadFinished);
-}
-
-void NavigationButton::updateOnLoadStarted()
-{
- switch (m_type) {
- case BackButton:
- break;
- case ForwardButton:
- break;
- case ReloadButton:
- m_type = StopButton;
- setIcon(style()->standardIcon(QStyle::SP_BrowserStop));
- break;
- case StopButton:
- break;
- }
-}
-
-void NavigationButton::updateOnLoadFinished()
-{
- switch (m_type) {
- case BackButton:
- if(m_view->history()->canGoBack()) {
- setEnabled(true);
- } else {
- setEnabled(false);
- }
- break;
- case ForwardButton:
- if(m_view->history()->canGoForward()) {
- setEnabled(true);
- } else {
- setEnabled(false);
- }
- break;
- case ReloadButton:
- break;
- case StopButton:
- m_type = ReloadButton;
- setIcon(style()->standardIcon(QStyle::SP_BrowserReload));
- break;
- }
-}
-
-void NavigationButton::doAction()
-{
- switch (m_type) {
- case BackButton:
- m_view->history()->back();
- break;
- case ForwardButton:
- m_view->history()->forward();
- break;
- case ReloadButton:
- m_view->reload();
- break;
- case StopButton:
- m_view->stop();
- break;
- }
-}
-
-void NavigationButton::prepareMenu()
-{
- menu->clear();
-
- QList items;
- switch (m_type) {
- case BackButton:
- items = m_view->history()->backItems(10);
- break;
- case ForwardButton:
- items = m_view->history()->forwardItems(10);
- break;
- default:
- break;
- }
-
- for(QWebEngineHistoryItem i : items) {
- QAction *a = menu->addAction(i.title());
- connect(a, &QAction::triggered, [i, this]() {
- m_view->history()->goToItem(i);
- });
- }
-}
diff --git a/src/lib/navigation/navigationbutton.h b/src/lib/navigation/navigationbutton.h
deleted file mode 100644
index ec39efa..0000000
--- a/src/lib/navigation/navigationbutton.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef NAVIGATIONBUTTON_H
-#define NAVIGATIONBUTTON_H
-
-#include
-#include
-
-class QMenu;
-
-class NavigationButton : public QToolButton
-{
- Q_OBJECT
-public:
-
- enum Type {
- BackButton,
- ForwardButton,
- ReloadButton,
- StopButton
- };
-
- explicit NavigationButton(Type type, QWidget *parent = nullptr);
-
- void setView(WebView *view);
-
-signals:
-
-private slots:
- void updateOnLoadStarted();
- void updateOnLoadFinished();
- void doAction();
- void prepareMenu();
-
-private:
- Type m_type;
- QMenu *menu;
- WebView *m_view;
-
- QMetaObject::Connection loadStartedConnection, loadFinishedConnection;
-};
-
-#endif // NAVIGATIONBUTTON_H
diff --git a/src/lib/navigation/urlcompleter.cpp b/src/lib/navigation/urlcompleter.cpp
deleted file mode 100644
index bbde297..0000000
--- a/src/lib/navigation/urlcompleter.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "urlcompleter.h"
-
-UrlCompleter::UrlCompleter(QAbstractItemModel *model, QObject *parent) :
- QCompleter(model, parent)
-{
- setCompletionMode(QCompleter::PopupCompletion);
- setFilterMode(Qt::MatchContains);
-}
-
-QStringList UrlCompleter::splitPath(const QString &path) const
-{
- return path.split('.');
-}
-
-QString UrlCompleter::pathFromIndex(const QModelIndex &index) const
-{
- return model()->data(index, completionRole()).toString();
-}
diff --git a/src/lib/navigation/urlcompleter.h b/src/lib/navigation/urlcompleter.h
deleted file mode 100644
index f2c52ff..0000000
--- a/src/lib/navigation/urlcompleter.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef URLCOMPLETER_H
-#define URLCOMPLETER_H
-
-#include
-
-class UrlCompleter : public QCompleter
-{
- Q_OBJECT
-public:
- explicit UrlCompleter(QAbstractItemModel *model, QObject *parent = nullptr);
-
-protected:
- QStringList splitPath(const QString &path) const override;
- QString pathFromIndex(const QModelIndex &index) const override;
-};
-
-#endif // URLCOMPLETER_H
diff --git a/src/lib/navigation/urllineedit.cpp b/src/lib/navigation/urllineedit.cpp
deleted file mode 100644
index 4dc6b39..0000000
--- a/src/lib/navigation/urllineedit.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "urllineedit.h"
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-// ssl menu
-#include
-
-#include "lib/bookmarks/bookmarkswidget.h"
-
-#include
-
-UrlLineEdit::UrlLineEdit(QWidget *parent) :
- QLineEdit(parent)
-{
- setPlaceholderText(tr("Enter address"));
-
- // ssl menu
- m_sslMenu = new QMenu(this);
- m_sslLabel = new QLabel(m_sslMenu);
- QWidgetAction *sslErrorAction = new QWidgetAction(m_sslMenu);
- sslErrorAction->setDefaultWidget(m_sslLabel);
- m_sslMenu->addAction(sslErrorAction);
-
- m_sslAction = addAction(style()->standardIcon(QStyle::SP_DriveNetIcon), QLineEdit::LeadingPosition);
- m_sslAction->setToolTip(tr("TODO: Display SSL Status popup here"));
- m_sslAction->setMenu(m_sslMenu);
-
- connect(m_sslAction, &QAction::triggered, this, [this]() {
- m_sslMenu->exec(this->mapToGlobal(QPoint(0, height())));
- });
-
- m_pageAction = addAction(style()->standardIcon(QStyle::SP_FileIcon), QLineEdit::TrailingPosition);
- m_pageAction->setShortcut(QKeySequence("F10"));
- m_pageAction->setToolTip(tr("Page Actions"));
- connect(m_pageAction, &QAction::triggered, m_pageAction, [&]() {
- //this->deselect();
- if(m_pageAction->menu() != nullptr) {
- m_pageAction->menu()->exec(this->mapToGlobal(QPoint(width(), height())));
- }
- });
-
- QTextCharFormat hostnameFormat;
- hostnameFormat.setFontWeight(QFont::Bold);
- m_hostFormat.format = hostnameFormat;
-
- // connect signals
- connect(this, &QLineEdit::returnPressed, [this]() {
- if(this->text().startsWith('#')) {
- emit searchTermEntered(this->text().mid(1));
- } else {
- emit addressEntered(QUrl::fromUserInput(this->text()));
- }
- this->clearFocus();
- });
-
-}
-
-QAction *UrlLineEdit::sslAction()
-{
- Q_CHECK_PTR(m_sslAction);
- return m_sslAction;
-}
-
-QAction *UrlLineEdit::pageAction()
-{
- Q_CHECK_PTR(m_pageAction);
- return m_pageAction;
-}
-
-void UrlLineEdit::setCompleterModel(QAbstractItemModel *model)
-{
- Q_CHECK_PTR(model);
- m_completer = new UrlCompleter(model, this);
- m_completer->setCompletionColumn(1);
- this->setCompleter(m_completer);
-}
-
-void UrlLineEdit::setUrl(const QUrl &url)
-{
- QString urlText = url.toString();
- QString domain = url.host();
-
- m_hostFormat.start = urlText.indexOf(domain);
- m_hostFormat.length = domain.length();
-
- clear();
- clearTextFormat();
- setTextFormat(m_hostFormat);
- setText(urlText);
-}
-
-void UrlLineEdit::showSslError(const QString &message)
-{
- m_sslLabel->setText(message);
- m_sslAction->trigger();
-}
-
-void UrlLineEdit::focusInEvent(QFocusEvent *event)
-{
- clearTextFormat();
-
- QLineEdit::focusInEvent(event);
-
- // select the contents when receiving focus
- // http://stackoverflow.com/a/35725950/1054406
- // mousePressEvent triggers right after focusInEvent so text selected in focusInEvent unselects by mousePressEvent
- //QTimer::singleShot(0, this, SLOT(selectAll()));
-}
-
-// formatting taken from: https://forum.qt.io/topic/60962/setting-qlineedit-text-bold
-void UrlLineEdit::setTextFormat(const QTextLayout::FormatRange &format)
-{
- QList attributes;
- attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, format.start, format.length, format.format));
- QInputMethodEvent ev(QString(), attributes);
- event(&ev);
-
-}
-
-void UrlLineEdit::clearTextFormat()
-{
- setTextFormat(QTextLayout::FormatRange());
-}
diff --git a/src/lib/navigation/urllineedit.h b/src/lib/navigation/urllineedit.h
deleted file mode 100644
index 46366a7..0000000
--- a/src/lib/navigation/urllineedit.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef URLLINEEDIT_H
-#define URLLINEEDIT_H
-
-#include
-#include
-#include
-
-#include "urlcompleter.h"
-
-class QAbstractItemModel;
-class QMenu;
-class QLabel;
-class UrlLineEdit : public QLineEdit
-{
- Q_OBJECT
-public:
- explicit UrlLineEdit(QWidget *parent = nullptr);
-
- QAction *sslAction();
- QAction *pageAction();
-
- void setCompleterModel(QAbstractItemModel *model);
-
-signals:
- void addressEntered(const QUrl &url);
- void searchTermEntered(const QString &term);
-
-public slots:
- void setUrl(const QUrl &url);
- void showSslError(const QString &message);
-
-protected:
- void focusInEvent(QFocusEvent *event);
-
-private:
- void setTextFormat(const QTextLayout::FormatRange &format);
- void clearTextFormat();
-
- QTextLayout::FormatRange m_hostFormat;
-
- QAction *m_sslAction = nullptr;
- QAction *m_pageAction = nullptr;
-
- // ssl menu
- QMenu *m_sslMenu;
- QLabel *m_sslLabel;
-
- UrlCompleter *m_completer;
-};
-
-#endif // URLLINEEDIT_H
diff --git a/src/main.cpp b/src/main.cpp
index 23dfa68..ffb7a4d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -7,6 +7,7 @@
*/
#include
+#include "version.h"
#include "browser.h"
#include
#include
diff --git a/src/settings.cpp b/src/settings.cpp
deleted file mode 100644
index 7f867f7..0000000
--- a/src/settings.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "settings.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-Settings::Settings(const QString &configFile, const QString &defaultsFile)
-{
- m_configurationPath = configFile;
- m_defaultsPath = defaultsFile;
-
- // homeLocation is the user's home folder
- homeLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
-
- // settingsLocation is the location of the configFile
- if(QFile::exists(configFile)) {
- settingsLocation = QFileInfo(configFile).dir().absolutePath();
- } else {
- // if file doesn't exist, use the generic location
- settingsLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
- }
-
- // cacheLocation
- cacheLocation = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
-
- userValues = parse(m_configurationPath);
- defaultValues = parse(m_defaultsPath);
-
- m_watcher = new QFileSystemWatcher();
- m_watcher->addPath(configFile);
- QObject::connect(m_watcher, &QFileSystemWatcher::fileChanged, [this](const QString &path) {
- if(path == m_configurationPath) {
-#ifdef QT_DEBUG
- qDebug("Reloading user configuration");
-#endif
- userValues = parse(m_configurationPath);
- }
- });
-
-#ifdef QT_DEBUG
- qDebug(">> Configuration");
- qDebug("- userconf: [%s]", qUtf8Printable(m_configurationPath));
- qDebug("- defaults: [%s]", qUtf8Printable(m_defaultsPath));
- qDebug("- $home [%s]", qUtf8Printable(homeLocation));
- qDebug("- $settings [%s]", qUtf8Printable(settingsLocation));
- qDebug("- $cache [%s]", qUtf8Printable(cacheLocation));
-#endif
-}
-
-Settings::~Settings()
-{
- m_watcher->deleteLater();
-}
-
-QString Settings::configurationPath() const
-{
- return m_configurationPath;
-}
-
-QString Settings::defaultsPath() const
-{
- return m_defaultsPath;
-}
-
-bool Settings::isEmpty() const
-{
- return userValues.empty();
-}
-
-QVariant Settings::value(const QString &key) const
-{
- const toml::Value *cValue = userValues.find(key.toStdString());
- const toml::Value *dValue = defaultValues.find(key.toStdString());
-
- QVariant r;
-
- if(userValues.has(key.toStdString())) {
- r = valueToVariant(cValue);
- } else {
- if(defaultValues.has(key.toStdString())) {
- r = valueToVariant(dValue);
- }
- }
-
- // check if key is a path, in which case replace '~' with the home location
- if(key.endsWith(QLatin1String("path"), Qt::CaseInsensitive)) {
- QString value = r.toString();
- while(value.contains('$')) {
- value.replace("$settings", settingsLocation);
- value.replace("$cache", cacheLocation);
- value.replace("$home", homeLocation);
- }
- r = QVariant(value);
- }
-
- return r;
-}
-
-toml::Value Settings::parse(const QString &filename)
-{
- toml::Value r;
-
- if(filename.isEmpty()) {
- qWarning("Empty configuration path.");
-
- } else {
- QFile file(filename);
- if(file.open(QIODevice::ReadOnly)) {
- std::stringstream d(file.readAll().toStdString());
- file.close();
-
- toml::ParseResult result = toml::parse(d);
- if(!result.valid()) {
- qWarning("Invalid configuration: %s", result.errorReason.c_str());
- }
- r = result.value;
-
- } else {
- qWarning("Cannot open configuration: %s", qUtf8Printable(filename));
- }
- }
-
- return r;
-}
-
-QVariant Settings::fromList(const toml::Value *list) const
-{
- QStringList l;
-
- for(const toml::Value &v : list->as()) {
- // TODO check value type
- l.append(QString::fromStdString(v.as()));
- }
-
- return QVariant(l);
-}
-
-QVariant Settings::valueToVariant(const toml::Value *value) const
-{
- QVariant r;
- switch (value->type()) {
- case toml::Value::NULL_TYPE:
- break;
-
- case toml::Value::BOOL_TYPE:
- r = QVariant(value->as());
- break;
-
- case toml::Value::INT_TYPE:
- r = QVariant(value->as());
- break;
-
- case toml::Value::DOUBLE_TYPE:
- r = QVariant(value->as());
- break;
-
- case toml::Value::STRING_TYPE:
- r = QVariant(QString::fromStdString(value->as()));
- break;
-
- case toml::Value::ARRAY_TYPE:
- r = fromList(value);
- break;
-
- default:
- qWarning("Unhandled type in configuration");
- break;
- }
-
- return r;
-}
diff --git a/src/settings.h b/src/settings.h
deleted file mode 100644
index ec25eb4..0000000
--- a/src/settings.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: git://neueland.iserlohn-fortress.net/smolbote.git
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#ifndef SETTINGS_H
-#define SETTINGS_H
-
-#include
-#include
-
-class QFileSystemWatcher;
-class Settings
-{
-public:
- explicit Settings(const QString &configFile, const QString &defaultsFile = QString());
- ~Settings();
-
- QString configurationPath() const;
- QString defaultsPath() const;
-
- bool isEmpty() const;
- QVariant value(const QString &key) const;
-
-private:
- toml::Value parse(const QString &filename);
-
- QVariant fromList(const toml::Value *list) const;
- QVariant valueToVariant(const toml::Value *value) const;
-
- toml::Value userValues;
- toml::Value defaultValues;
-
- QString m_configurationPath;
- QString m_defaultsPath;
-
- QString homeLocation;
- QString settingsLocation;
- QString cacheLocation;
-
- QFileSystemWatcher *m_watcher;
-};
-
-#endif // SETTINGS_H
diff --git a/src/version.h.in b/src/version.h.in
new file mode 100644
index 0000000..1ec633a
--- /dev/null
+++ b/src/version.h.in
@@ -0,0 +1,7 @@
+#ifndef VERSION_H
+#define VERSION_H
+
+#define GIT_VERSION "@GitVersion@"
+#define GIT_DESCRIBE "@GitDescribe@"
+
+#endif //VERSION_H
\ No newline at end of file
diff --git a/src/webengine/webview.h b/src/webengine/webview.h
index bf5b1a6..9951630 100644
--- a/src/webengine/webview.h
+++ b/src/webengine/webview.h
@@ -11,7 +11,7 @@
#include
#include
-#include "webengine/webpage.h"
+#include "webpage.h"
class MainWindow;
class WebView : public QWebEngineView
diff --git a/tools/hooks/pre-commit.rb b/tools/hooks/pre-commit.rb
index f93281c..c224a49 100755
--- a/tools/hooks/pre-commit.rb
+++ b/tools/hooks/pre-commit.rb
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
result = 0
-files = Dir.glob("**/*.h") + Dir.glob("**/*.cpp")
+files = Dir.glob("src/**/*.h") + Dir.glob("src/**/*.cpp") + Dir.glob("lib/**/*.h") + Dir.glob("lib/**/*.cpp")
puts "pre-commit: #{`pwd`}"
--
cgit v1.2.1