aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUGS.md14
-rw-r--r--data/poi.cfg5
-rw-r--r--lib/settings/configuration.cpp7
-rw-r--r--lib/settings/configuration.h2
-rw-r--r--lib/settings/settingsdialog.cpp25
-rw-r--r--src/browser.cpp7
-rw-r--r--src/main.cpp4
7 files changed, 53 insertions, 11 deletions
diff --git a/BUGS.md b/BUGS.md
index 41883dd..a14c19e 100644
--- a/BUGS.md
+++ b/BUGS.md
@@ -12,6 +12,9 @@ to the search.
### databases-incognito in home
https://bugreports.qt.io/browse/QTBUG-62957
+### Shortcuts don't work at times
+A field on a page is probably taking focus.
+
## To do list
List of things to do before 1.0 release
@@ -20,6 +23,7 @@ List of things to do before 1.0 release
### Request filter
- How are multiple IPs per hostname to be treated?
+- match host names against QHash
- review code
### No Script
@@ -32,8 +36,9 @@ Deny 'resource://' to prevent website fingerprinting
### Deny mouse information
### Settings dialog
+- reset button
+- Settings dialog only displays values (Save button does nothing)
- show settings dialog on startup if config was auto-generated
-- add scrollbar and limit max height to about 600
### Bookmarks
- review code
@@ -42,6 +47,13 @@ Deny 'resource://' to prevent website fingerprinting
- review code
- possibly split off into a dialog window
- properly show download item information
+- size in details is -1, but is shown correctly on item
+- download speed
+- In DownloadItem widget: no offsets
+- Elapsed time, avg speed, remaining time
+- In details: stop, pause/resume
+- flip download widget to landscape
+- script to run other downloader
### Rewrite documentation
- quickstart/manual that lists keyboard shortcuts
diff --git a/data/poi.cfg b/data/poi.cfg
index bf8a022..dd8af64 100644
--- a/data/poi.cfg
+++ b/data/poi.cfg
@@ -41,6 +41,11 @@ browser = {
};
};
+// Filter settings
+filter = {
+ path = "~/.config/smolbote/hosts.d";
+};
+
// Profile settings
profile = {
path = "~/.config/smolbote/Profiles";
diff --git a/lib/settings/configuration.cpp b/lib/settings/configuration.cpp
index d91ae97..34d50db 100644
--- a/lib/settings/configuration.cpp
+++ b/lib/settings/configuration.cpp
@@ -95,6 +95,13 @@ std::vector<std::string> Configuration::childrenGroups(const char* name)
return groupNames;
}
+void Configuration::resetValue(const char *path)
+{
+ if(m_userCfg->exists(path)) {
+ m_userCfg->getRoot().remove(path);
+ }
+}
+
template<typename T>
std::optional<T> Configuration::value(const char* path) const
{
diff --git a/lib/settings/configuration.h b/lib/settings/configuration.h
index 49f92d6..1909eb8 100644
--- a/lib/settings/configuration.h
+++ b/lib/settings/configuration.h
@@ -32,6 +32,8 @@ public:
std::vector<std::string> childrenSettings(const char *name = "");
std::vector<std::string> childrenGroups(const char *name = "");
+ void resetValue(const char* path);
+
template<typename T>
std::optional<T> value(const char* path) const;
diff --git a/lib/settings/settingsdialog.cpp b/lib/settings/settingsdialog.cpp
index 2b11416..6de3894 100644
--- a/lib/settings/settingsdialog.cpp
+++ b/lib/settings/settingsdialog.cpp
@@ -9,13 +9,14 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "configuration.h"
+#include <QScrollArea>
#include <QFormLayout>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QToolButton>
#include <QGroupBox>
-inline QHBoxLayout *createEntry(const QString &value, QWidget *widget);
+inline QHBoxLayout *createEntry(Configuration *config, const std::string &path, QWidget *widget);
SettingsDialog::SettingsDialog(std::shared_ptr<Configuration> &settings, QWidget *parent) :
QDialog(parent),
@@ -24,8 +25,10 @@ SettingsDialog::SettingsDialog(std::shared_ptr<Configuration> &settings, QWidget
ui->setupUi(this);
for(const std::string &group : settings->childrenGroups("")) {
- QWidget *widget = widgetForGroup(settings, group, this);
- ui->tabWidget->addTab(widget, QString::fromStdString(group));
+ QScrollArea *area = new QScrollArea(this);
+ area->setWidgetResizable(true);
+ area->setWidget(widgetForGroup(settings, group, this));
+ ui->tabWidget->addTab(area, QString::fromStdString(group));
}
}
@@ -43,7 +46,7 @@ QWidget *widgetForGroup(std::shared_ptr<Configuration> &settings, const std::str
// add entry for every key
QFormLayout *form = new QFormLayout();
for(const std::string &key : settings->childrenSettings(group.c_str())) {
- QHBoxLayout *hBox = createEntry(QString::fromStdString(settings->value<std::string>((group + '.' + key).c_str()).value()), widget);
+ QHBoxLayout *hBox = createEntry(settings.get(), group + '.' + key, widget);
form->addRow(parent->tr(key.c_str()), hBox);
}
layout->addLayout(form);
@@ -57,7 +60,7 @@ QWidget *widgetForGroup(std::shared_ptr<Configuration> &settings, const std::str
const std::string groupPath = group + '.' + childGroup;
for(const std::string &key : settings->childrenSettings(groupPath.c_str())) {
- QHBoxLayout *hBox = createEntry(QString::fromStdString(settings->value<std::string>((groupPath + '.' + key).c_str()).value()), groupBox);
+ QHBoxLayout *hBox = createEntry(settings.get(), groupPath + '.' + key, groupBox);
boxForm->addRow(parent->tr(key.c_str()), hBox);
}
}
@@ -65,13 +68,21 @@ QWidget *widgetForGroup(std::shared_ptr<Configuration> &settings, const std::str
return widget;
}
-inline QHBoxLayout *createEntry(const QString &value, QWidget *widget)
+inline QHBoxLayout *createEntry(Configuration* config, const std::string &path, QWidget *widget)
{
QLineEdit *lineEdit = new QLineEdit(widget);
- lineEdit->setText(value);
+ lineEdit->setText(QString::fromStdString(config->value<std::string>(path.c_str()).value()));
QToolButton *resetButton = new QToolButton(widget);
resetButton->setIcon(widget->style()->standardIcon(QStyle::SP_DialogResetButton));
+ QObject::connect(resetButton, &QToolButton::clicked, [config, path, lineEdit]() {
+ config->resetValue(path.c_str());
+ lineEdit->setText(QString::fromStdString(config->value<std::string>(path.c_str()).value()));
+ });
+ QObject::connect(lineEdit, &QLineEdit::editingFinished, [config, path, lineEdit]() {
+ config->setValue<std::string>(path, lineEdit->text().toStdString());
+ });
+
QHBoxLayout *hBox = new QHBoxLayout();
hBox->addWidget(lineEdit);
hBox->addWidget(resetButton);
diff --git a/src/browser.cpp b/src/browser.cpp
index 6305c0e..1d09951 100644
--- a/src/browser.cpp
+++ b/src/browser.cpp
@@ -26,7 +26,9 @@ Browser::Browser(int &argc, char *argv[]) :
Browser::~Browser()
{
- m_bookmarksManager->save();
+ if(m_bookmarksManager) {
+ m_bookmarksManager->save();
+ }
}
void Browser::setConfiguration(std::shared_ptr<Configuration> &config)
@@ -36,8 +38,7 @@ void Browser::setConfiguration(std::shared_ptr<Configuration> &config)
m_bookmarksManager = std::make_shared<BookmarksWidget>(QString::fromStdString(m_config->value<std::string>("bookmarks.path").value()));
m_downloadManager = std::make_shared<DownloadsWidget>(QString::fromStdString(m_config->value<std::string>("downloads.path").value()));
- // TODO: change path
- m_urlRequestInterceptor = std::make_shared<UrlRequestInterceptor>(QString::fromStdString(m_config->value<std::string>("browser.filterPath").value_or("")));
+ m_urlRequestInterceptor = std::make_shared<UrlRequestInterceptor>(QString::fromStdString(m_config->value<std::string>("filter.path").value()));
// set default profile
m_defaultProfile = profile(QString::fromStdString(m_config->value<std::string>("browser.profile").value()));
diff --git a/src/main.cpp b/src/main.cpp
index 3483da7..23dfa68 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -40,6 +40,10 @@ bool writeUserConfig(const std::string &path, Configuration &config)
// The .path's need to be overriden because ~ doesn't translate to home
const QString &home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+ // filter.path
+ std::string filterPath = config.value<std::string>("filter.path").value();
+ config.setValue<std::string>("filter.path", patchHome(filterPath, home.toStdString()));
+
// profile.path
std::string profilePath = config.value<std::string>("profile.path").value();
config.setValue<std::string>("profile.path", patchHome(profilePath, home.toStdString()));