Commit d72ceb31 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement config dialog

parent 4013e343
Pipeline #125216 passed with stage
in 12 minutes and 2 seconds
......@@ -14,7 +14,7 @@
namespace
{
static const char myOpenUrlWithConfigureConfigGroupName[] = "OpenUrlWithConfigureDialogbonjour ";
static const char myOpenUrlWithConfigureConfigGroupName[] = "OpenUrlWithConfigureDialog";
}
OpenUrlWithConfigureDialog::OpenUrlWithConfigureDialog(QWidget *parent)
......
......@@ -5,8 +5,11 @@
*/
#include "openurlwithconfigurewidget.h"
#include "openurlwithconfigurecreatedialog.h"
#include <KLocalizedString>
#include <KMessageBox>
#include <QHeaderView>
#include <QMenu>
#include <QTreeWidget>
#include <QVBoxLayout>
......@@ -23,6 +26,12 @@ OpenUrlWithConfigureWidget::OpenUrlWithConfigureWidget(QWidget *parent)
mTreeWidget->setRootIsDecorated(false);
mTreeWidget->header()->setSectionsMovable(false);
mTreeWidget->setHeaderLabels({i18n("Domain"), i18n("Command Line")});
mTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
mTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
mTreeWidget->header()->setSortIndicatorShown(true);
mTreeWidget->setSortingEnabled(true);
connect(mTreeWidget, &QTreeWidget::customContextMenuRequested, this, &OpenUrlWithConfigureWidget::slotCustomContextMenuRequested);
connect(mTreeWidget, &QTreeWidget::itemDoubleClicked, this, &OpenUrlWithConfigureWidget::slotEditRule);
}
OpenUrlWithConfigureWidget::~OpenUrlWithConfigureWidget()
......@@ -38,3 +47,49 @@ void OpenUrlWithConfigureWidget::writeSettings()
{
// TODO
}
void OpenUrlWithConfigureWidget::slotAddRule()
{
// TODO
}
void OpenUrlWithConfigureWidget::slotEditRule()
{
// TODO
}
void OpenUrlWithConfigureWidget::slotRemoveRule()
{
auto items = mTreeWidget->selectedItems();
if (!items.isEmpty()) {
const int answer = KMessageBox::questionYesNo(this,
i18np("Do you want to remove this rule?", "Do you want to remove these rules?", items.count()),
i18nc("@title", "Remove Rule"),
KStandardGuiItem::remove(),
KStandardGuiItem::cancel());
if (answer == KMessageBox::Yes) {
while (!items.isEmpty()) {
delete items.takeFirst();
}
}
}
}
void OpenUrlWithConfigureWidget::slotCustomContextMenuRequested(const QPoint &p)
{
QMenu menu(this);
const int selectedItemCount{mTreeWidget->selectedItems().count()};
menu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add Rule..."), this, &OpenUrlWithConfigureWidget::slotAddRule);
if (selectedItemCount == 1) {
menu.addAction(QIcon::fromTheme(QStringLiteral("document-edit")), i18n("Edit Rule..."), this, &OpenUrlWithConfigureWidget::slotEditRule);
}
if (selectedItemCount > 0) {
menu.addSeparator();
menu.addAction(QIcon::fromTheme(QStringLiteral("list-remove")),
i18np("Remove Rule", "Remove Rules", selectedItemCount),
this,
&OpenUrlWithConfigureWidget::slotRemoveRule);
}
menu.exec(QCursor::pos());
}
......@@ -19,5 +19,9 @@ public:
void writeSettings();
private:
void slotCustomContextMenuRequested(const QPoint &p);
void slotAddRule();
void slotEditRule();
void slotRemoveRule();
QTreeWidget *const mTreeWidget;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment