aboutsummaryrefslogtreecommitdiff
path: root/plugins/ProfileEditor
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-06-14 18:09:01 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2018-06-14 18:09:01 +0200
commit1efd63efaf435db81cf5bfd0ca6b0534d8c1c36c (patch)
treeee62ae5a32ef13983f61379e3d25b14f0e07179c /plugins/ProfileEditor
parentAdd poi.desktop (diff)
downloadsmolbote-1efd63efaf435db81cf5bfd0ca6b0534d8c1c36c.tar.xz
ProfileEditor: add delete button
Diffstat (limited to 'plugins/ProfileEditor')
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.cpp29
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.h1
-rw-r--r--plugins/ProfileEditor/forms/profilemanagerdialog.ui50
-rw-r--r--plugins/ProfileEditor/forms/profileview.cpp2
-rw-r--r--plugins/ProfileEditor/forms/profileview.h4
-rw-r--r--plugins/ProfileEditor/forms/profileview.ui2
6 files changed, 76 insertions, 12 deletions
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
index d05b480..2f0f4a2 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.cpp
@@ -2,6 +2,7 @@
#include "profileview.h"
#include "ui_profilemanagerdialog.h"
#include <webprofile.h>
+#include <QDir>
ProfileManagerDialog::ProfileManagerDialog(QHash<QString, WebProfile *> *profiles, QWidget *parent)
: QDialog(parent)
@@ -13,6 +14,10 @@ ProfileManagerDialog::ProfileManagerDialog(QHash<QString, WebProfile *> *profile
connect(ui->listWidget, &QListWidget::itemPressed, this, &ProfileManagerDialog::showProfile);
showProfile(nullptr);
+ connect(ui->delete_pushButton, &QPushButton::clicked, this, [=]() {
+ deleteProfile(ui->listWidget->currentItem());
+ });
+
for(auto i = profiles->constBegin(); i != profiles->constEnd(); ++i) {
ui->listWidget->addItem(i.key());
}
@@ -42,3 +47,27 @@ void ProfileManagerDialog::showProfile(QListWidgetItem *item)
ui->groupBox->layout()->addWidget(v);
v->adjustSize();
}
+
+void ProfileManagerDialog::deleteProfile(QListWidgetItem *item)
+{
+ if(item == nullptr)
+ return;
+
+ // clear out groupbox layout
+ QLayoutItem *i;
+ while((i = ui->groupBox->layout()->takeAt(0)) != nullptr) {
+ delete i->widget();
+ delete i;
+ }
+
+ auto *profile = profiles->value(item->text());
+ Q_CHECK_PTR(profile);
+
+ qDebug("deleting profile %s", qUtf8Printable(profile->name()));
+ qDebug("deleting %s: %s", qUtf8Printable(profile->configurationPath()), QFile(profile->configurationPath()).remove() ? "okay" : "failed");
+ qDebug("deleting %s: %s", qUtf8Printable(profile->persistentStoragePath()), QDir(profile->persistentStoragePath()).removeRecursively() ? "okay" : "failed");
+ qDebug("deleting %s: %s", qUtf8Printable(profile->cachePath()), QDir(profile->cachePath()).removeRecursively() ? "okay" : "failed");
+
+ delete item;
+ delete profile;
+}
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.h b/plugins/ProfileEditor/forms/profilemanagerdialog.h
index ba315ce..a4b6f83 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.h
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.h
@@ -21,6 +21,7 @@ public:
private slots:
void showProfile(QListWidgetItem *item);
+ void deleteProfile(QListWidgetItem *item);
private:
Ui::ProfileManagerDialog *ui;
diff --git a/plugins/ProfileEditor/forms/profilemanagerdialog.ui b/plugins/ProfileEditor/forms/profilemanagerdialog.ui
index ae3829a..f7acdec 100644
--- a/plugins/ProfileEditor/forms/profilemanagerdialog.ui
+++ b/plugins/ProfileEditor/forms/profilemanagerdialog.ui
@@ -40,14 +40,48 @@
</layout>
</item>
<item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Close</set>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="buttons_horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="new_pushButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>New</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="delete_pushButton">
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Close</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
diff --git a/plugins/ProfileEditor/forms/profileview.cpp b/plugins/ProfileEditor/forms/profileview.cpp
index b723a61..2d96d43 100644
--- a/plugins/ProfileEditor/forms/profileview.cpp
+++ b/plugins/ProfileEditor/forms/profileview.cpp
@@ -18,7 +18,7 @@ inline void connectSetting(QCheckBox *checkBox, QWebEngineSettings *settings, QW
}
ProfileView::ProfileView(QWebEngineProfile *profile, QWidget *parent)
- : QDialog(parent)
+ : QWidget(parent)
, ui(new Ui::ProfileView)
{
Q_CHECK_PTR(profile);
diff --git a/plugins/ProfileEditor/forms/profileview.h b/plugins/ProfileEditor/forms/profileview.h
index a264cc0..6a8e8ab 100644
--- a/plugins/ProfileEditor/forms/profileview.h
+++ b/plugins/ProfileEditor/forms/profileview.h
@@ -9,7 +9,7 @@
#ifndef PROFILEDIALOG_H
#define PROFILEDIALOG_H
-#include <QDialog>
+#include <QWidget>
#include <QWebEngineProfile>
namespace Ui
@@ -17,7 +17,7 @@ namespace Ui
class ProfileView;
}
-class ProfileView : public QDialog
+class ProfileView : public QWidget
{
Q_OBJECT
diff --git a/plugins/ProfileEditor/forms/profileview.ui b/plugins/ProfileEditor/forms/profileview.ui
index f0ea24c..2f6c889 100644
--- a/plugins/ProfileEditor/forms/profileview.ui
+++ b/plugins/ProfileEditor/forms/profileview.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProfileView</class>
- <widget class="QDialog" name="ProfileView">
+ <widget class="QWidget" name="ProfileView">
<property name="geometry">
<rect>
<x>0</x>