mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 12:46:35 +01:00
Feature: implemented bookmark editing on the fly
This commit is contained in:
parent
11601f866e
commit
603f7f3211
@ -71,6 +71,7 @@ void BookmarksToolbar::contextMenuRequested(const QPoint &pos)
|
||||
QAction* actNewTab = menu.addAction(IconProvider::newTabIcon(), tr("Open in new tab"));
|
||||
QAction* actNewWindow = menu.addAction(IconProvider::newWindowIcon(), tr("Open in new window"));
|
||||
menu.addSeparator();
|
||||
QAction* actEdit = menu.addAction(tr("Edit"));
|
||||
QAction* actDelete = menu.addAction(QIcon::fromTheme("edit-delete"), tr("Delete"));
|
||||
menu.addSeparator();
|
||||
m_actShowOnlyIcons = menu.addAction(tr("Show Only Icons"));
|
||||
@ -84,8 +85,10 @@ void BookmarksToolbar::contextMenuRequested(const QPoint &pos)
|
||||
|
||||
connect(actNewTab, SIGNAL(triggered()), this, SLOT(openBookmarkInNewTab()));
|
||||
connect(actNewWindow, SIGNAL(triggered()), this, SLOT(openBookmarkInNewWindow()));
|
||||
connect(actEdit, SIGNAL(triggered()), this, SLOT(editBookmark()));
|
||||
connect(actDelete, SIGNAL(triggered()), this, SLOT(deleteBookmark()));
|
||||
|
||||
actEdit->setEnabled(m_clickedBookmark && m_bookmarks->canBeModified(m_clickedBookmark));
|
||||
actDelete->setEnabled(m_clickedBookmark && m_bookmarks->canBeModified(m_clickedBookmark));
|
||||
actNewTab->setEnabled(m_clickedBookmark && m_clickedBookmark->isUrl());
|
||||
actNewWindow->setEnabled(m_clickedBookmark && m_clickedBookmark->isUrl());
|
||||
@ -162,6 +165,14 @@ void BookmarksToolbar::openBookmarkInNewWindow()
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::editBookmark()
|
||||
{
|
||||
if (m_clickedBookmark) {
|
||||
BookmarksTools::editBookmarkDialog(this, m_clickedBookmark);
|
||||
m_bookmarks->changeBookmark(m_clickedBookmark);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::deleteBookmark()
|
||||
{
|
||||
if (m_clickedBookmark) {
|
||||
|
@ -46,6 +46,7 @@ private slots:
|
||||
|
||||
void openBookmarkInNewTab();
|
||||
void openBookmarkInNewWindow();
|
||||
void editBookmark();
|
||||
void deleteBookmark();
|
||||
|
||||
private:
|
||||
|
@ -29,8 +29,10 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QBoxLayout>
|
||||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QStyle>
|
||||
#include <QDialog>
|
||||
|
||||
@ -215,6 +217,55 @@ bool BookmarksTools::bookmarkAllTabsDialog(QWidget* parent, TabWidget* tabWidget
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BookmarksTools::editBookmarkDialog(QWidget* parent, BookmarkItem *item)
|
||||
{
|
||||
QDialog* dialog = new QDialog(parent);
|
||||
QFormLayout* layout = new QFormLayout(dialog);
|
||||
|
||||
QLineEdit* title = new QLineEdit;
|
||||
QLineEdit* address = new QLineEdit;
|
||||
QLineEdit* keyword = new QLineEdit;
|
||||
QPlainTextEdit* description = new QPlainTextEdit;
|
||||
|
||||
QDialogButtonBox* box = new QDialogButtonBox(dialog);
|
||||
box->addButton(QDialogButtonBox::Ok);
|
||||
box->addButton(QDialogButtonBox::Cancel);
|
||||
QObject::connect(box, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
|
||||
QObject::connect(box, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
|
||||
|
||||
layout->addRow(Bookmarks::tr("Title:"), title);
|
||||
title->setText(item->title());
|
||||
if (!item->isFolder()) {
|
||||
layout->addRow(Bookmarks::tr("Address:"), address);
|
||||
address->setText(item->urlString());
|
||||
layout->addRow(Bookmarks::tr("Keyword:"), keyword);
|
||||
keyword->setText(item->keyword());
|
||||
}
|
||||
layout->addRow(Bookmarks::tr("Description:"), description);
|
||||
description->document()->setPlainText(item->description());
|
||||
layout->addWidget(box);
|
||||
|
||||
dialog->setWindowIcon(item->icon());
|
||||
dialog->setWindowTitle(Bookmarks::tr("Edit Bookmark"));
|
||||
|
||||
dialog->exec();
|
||||
|
||||
if (dialog->result() == QDialog::Rejected) {
|
||||
delete dialog;
|
||||
return false;
|
||||
}
|
||||
|
||||
item->setTitle(title->text());
|
||||
if (!item->isFolder()) {
|
||||
item->setUrl(QUrl::fromEncoded(address->text().toUtf8()));
|
||||
item->setKeyword(keyword->text());
|
||||
}
|
||||
item->setDescription(description->toPlainText());
|
||||
|
||||
delete dialog;
|
||||
return true;
|
||||
}
|
||||
|
||||
void BookmarksTools::openBookmark(BrowserWindow* window, BookmarkItem* item)
|
||||
{
|
||||
Q_ASSERT(window);
|
||||
|
@ -82,6 +82,9 @@ public:
|
||||
static bool addBookmarkDialog(QWidget* parent, const QUrl &url, const QString &title, BookmarkItem* folder = 0);
|
||||
static bool bookmarkAllTabsDialog(QWidget* parent, TabWidget* tabWidget, BookmarkItem* folder = 0);
|
||||
|
||||
// Edit Bookmark Dialog
|
||||
static bool editBookmarkDialog(QWidget* parent, BookmarkItem* item);
|
||||
|
||||
// Open Bookmarks
|
||||
static void openBookmark(BrowserWindow* window, BookmarkItem* item);
|
||||
static void openBookmarkInNewTab(BrowserWindow* window, BookmarkItem* item);
|
||||
|
Loading…
Reference in New Issue
Block a user