diff --git a/src/lib/bookmarks/bookmarkswidget.cpp b/src/lib/bookmarks/bookmarkswidget.cpp
index 79054ca50..c06128c28 100644
--- a/src/lib/bookmarks/bookmarkswidget.cpp
+++ b/src/lib/bookmarks/bookmarkswidget.cpp
@@ -36,6 +36,7 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
, m_view(view)
, m_bookmarksModel(mApp->bookmarksModel())
, m_speedDial(mApp->plugins()->speedDial())
+ , m_edited(false)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
@@ -44,27 +45,12 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
// it dynamically changes and so, it's not good choice for this widget.
setLayoutDirection(QApplication::layoutDirection());
- m_bookmarkId = m_bookmarksModel->bookmarkId(m_url);
-
- if (m_bookmarkId > 0) {
- connect(ui->saveRemove, SIGNAL(clicked()), this, SLOT(removeBookmark()));
- ui->saveRemove->setText(tr("Remove"));
- }
- else {
- connect(ui->saveRemove, SIGNAL(clicked()), this, SLOT(saveBookmark()));
- }
- connect(ui->speeddialButton, SIGNAL(clicked()), this, SLOT(toggleSpeedDial()));
+ connect(ui->speeddialButton, SIGNAL(clicked(QPoint)), this, SLOT(toggleSpeedDial()));
const SpeedDial::Page &page = m_speedDial->pageForUrl(m_url);
- ui->speeddialButton->setText(page.url.isEmpty() ? tr("Add to Speed Dial") : tr("Remove from Speed Dial"));
-
-#ifndef KDE
- // Use light color for QLabels even with Ubuntu Ambiance theme
- QPalette pal = palette();
- pal.setColor(QPalette::WindowText, QToolTip::palette().color(QPalette::ToolTipText));
- ui->label_2->setPalette(pal);
- ui->label_3->setPalette(pal);
-#endif
+ ui->speeddialButton->setText(page.url.isEmpty() ?
+ tr("Add to Speed Dial") :
+ tr("Remove from Speed Dial"));
loadBookmark();
}
@@ -81,13 +67,15 @@ void BookmarksWidget::loadBookmark()
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirIcon), query.value(0).toString(), query.value(0).toString());
}
+ m_bookmarkId = m_bookmarksModel->bookmarkId(m_url);
+
if (m_bookmarkId > 0) {
BookmarksModel::Bookmark bookmark = m_bookmarksModel->getBookmark(m_bookmarkId);
ui->name->setText(bookmark.title);
ui->folder->setCurrentIndex(ui->folder->findData(bookmark.folder));
-
- ui->name->setEnabled(false);
- ui->folder->setEnabled(false);
+ ui->saveRemove->setText(tr("Remove"));
+ connect(ui->name, SIGNAL(textEdited(QString)), SLOT(bookmarkEdited()));
+ connect(ui->folder, SIGNAL(currentIndexChanged(int)), SLOT(bookmarkEdited()));
}
else {
ui->name->setText(m_view->title());
@@ -102,36 +90,49 @@ namespace
const int hideDelay = 270;
}
-void BookmarksWidget::removeBookmark()
-{
- m_bookmarksModel->removeBookmark(m_url);
- emit bookmarkDeleted();
- QTimer::singleShot(hideDelay, this, SLOT(close()));
-}
-
-void BookmarksWidget::saveBookmark()
-{
- m_bookmarksModel->saveBookmark(m_url, ui->name->text(), m_view->icon(), ui->folder->currentText());
- QTimer::singleShot(hideDelay, this, SLOT(close()));
-}
-
void BookmarksWidget::toggleSpeedDial()
{
const SpeedDial::Page &page = m_speedDial->pageForUrl(m_url);
+ QString const dialText("%1");
if (page.url.isEmpty()) {
m_speedDial->addPage(m_url, m_view->title());
- ui->speeddialButton->setText(tr("Remove from Speed Dial"));
}
else {
m_speedDial->removePage(page);
- ui->speeddialButton->setText(tr("Add to Speed Dial"));
-
}
QTimer::singleShot(hideDelay, this, SLOT(close()));
}
+void BookmarksWidget::bookmarkEdited()
+{
+ if (m_edited) {
+ return;
+ }
+
+ m_edited = true;
+ ui->saveRemove->setText(tr("Save"));
+}
+
+void BookmarksWidget::on_saveRemove_clicked(bool)
+{
+ if (m_bookmarkId > 0) {
+ if (m_edited) {
+ m_bookmarksModel->editBookmark(m_bookmarkId, ui->name->text(), QUrl(), ui->folder->itemData(ui->folder->currentIndex()).toString());
+ }
+ else {
+ m_bookmarksModel->removeBookmark(m_url);
+ emit bookmarkDeleted();
+ }
+ }
+ else {
+ m_bookmarksModel->saveBookmark(m_url, ui->name->text(), m_view->icon(), ui->folder->currentText());
+ }
+ QTimer::singleShot(hideDelay, this, SLOT(close()));
+}
+
+
void BookmarksWidget::showAt(QWidget* _parent)
{
layout()->invalidate();
@@ -142,8 +143,8 @@ void BookmarksWidget::showAt(QWidget* _parent)
show();
}
-
BookmarksWidget::~BookmarksWidget()
{
delete ui;
}
+
diff --git a/src/lib/bookmarks/bookmarkswidget.h b/src/lib/bookmarks/bookmarkswidget.h
index 30e963f73..8475639b9 100644
--- a/src/lib/bookmarks/bookmarkswidget.h
+++ b/src/lib/bookmarks/bookmarkswidget.h
@@ -44,11 +44,9 @@ public:
signals:
void bookmarkDeleted();
-public slots:
-
private slots:
- void removeBookmark();
- void saveBookmark();
+ void on_saveRemove_clicked(bool);
+ void bookmarkEdited();
void toggleSpeedDial();
@@ -63,6 +61,7 @@ private:
WebView* m_view;
BookmarksModel* m_bookmarksModel;
SpeedDial* m_speedDial;
+ bool m_edited;
};
#endif // BOOKMARKSWIDGET_H
diff --git a/src/lib/bookmarks/bookmarkswidget.ui b/src/lib/bookmarks/bookmarkswidget.ui
index 257bb5eda..4db49753c 100644
--- a/src/lib/bookmarks/bookmarkswidget.ui
+++ b/src/lib/bookmarks/bookmarkswidget.ui
@@ -6,8 +6,8 @@
0
0
- 295
- 146
+ 210
+ 128
@@ -15,7 +15,7 @@
-
-
+
-
@@ -30,60 +30,35 @@
-
-
-
-
- 0
- 0
-
+
+
+ PointingHandCursor
Add to Speed Dial
+
+ true
+
-
-
-
-
-
-
- Name:
-
-
-
- -
-
-
-
+
-
-
-
-
-
-
- Folder:
-
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
-
+
+
+
+ 0
+ 0
+
+
+
-
-
- 5
-
-
@@ -100,7 +75,7 @@
-
-
+
0
0
@@ -114,6 +89,13 @@
+
+
+ ClickableLabel
+ QLabel
+
+
+