mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
Rework the quick bookmark widget.
* QupZilla is not firefox or chrome: QZ has speeddial by default, the latter ones only by extensions. So adding an url to the unsorted bookmarks by default when clicking the star is a no-go, as the user probably only wants to add a speed dial. The star is the only possibility to add speed dials. * Having a save and a remove-button possibly confuses the user (at least confused me ;)) Only take one button and change the text according to the state. * Disable the name-edit and folder-combo in the case the url is already bookmarked. Chosing another folder and press save will move the bookmark to another folder. Moving bookmarks IMHO is the job of the "organize bookmarks" tool (renaming them, too) *** In a future (post-1.3.5) I would like to see the bookmark-button an the folder-choser merged like it is done in Opera. (Opera HAS speed dial by default) But I am open for suggestions :)
This commit is contained in:
parent
8d8a033ebd
commit
29cc7cf47d
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <QToolTip>
|
||||
#include <QSqlQuery>
|
||||
#include <QTimer>
|
||||
|
||||
BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent)
|
||||
: QMenu(parent)
|
||||
|
@ -43,8 +44,14 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
|
|||
// it dynamically changes and so, it's not good choice for this widget.
|
||||
setLayoutDirection(QApplication::layoutDirection());
|
||||
|
||||
connect(ui->removeBookmark, SIGNAL(clicked()), this, SLOT(removeBookmark()));
|
||||
connect(ui->save, SIGNAL(clicked()), this, SLOT(saveBookmark()));
|
||||
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()));
|
||||
|
||||
const SpeedDial::Page &page = m_speedDial->pageForUrl(m_url);
|
||||
|
@ -58,51 +65,52 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
|
|||
ui->label_3->setPalette(pal);
|
||||
#endif
|
||||
|
||||
addBookmark();
|
||||
loadBookmark();
|
||||
}
|
||||
|
||||
void BookmarksWidget::loadBookmark()
|
||||
{
|
||||
if (m_bookmarksModel->isBookmarked(m_url)) {
|
||||
m_bookmarkId = m_bookmarksModel->bookmarkId(m_url);
|
||||
// Bookmark folders
|
||||
ui->folder->addItem(QIcon(":/icons/other/unsortedbookmarks.png"), _bookmarksUnsorted, "unsorted");
|
||||
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirOpenIcon), _bookmarksMenu, "bookmarksMenu");
|
||||
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirOpenIcon), _bookmarksToolbar, "bookmarksToolbar");
|
||||
QSqlQuery query;
|
||||
query.exec("SELECT name FROM folders");
|
||||
while (query.next()) {
|
||||
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirIcon), query.value(0).toString(), query.value(0).toString());
|
||||
}
|
||||
|
||||
if (m_bookmarkId > 0) {
|
||||
BookmarksModel::Bookmark bookmark = m_bookmarksModel->getBookmark(m_bookmarkId);
|
||||
ui->name->setText(bookmark.title);
|
||||
|
||||
// Bookmark folders
|
||||
ui->folder->addItem(QIcon(":icons/other/unsortedbookmarks.png"), _bookmarksUnsorted, "unsorted");
|
||||
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirOpenIcon), _bookmarksMenu, "bookmarksMenu");
|
||||
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirOpenIcon), _bookmarksToolbar, "bookmarksToolbar");
|
||||
QSqlQuery query;
|
||||
query.exec("SELECT name FROM folders");
|
||||
while (query.next()) {
|
||||
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirIcon), query.value(0).toString(), query.value(0).toString());
|
||||
}
|
||||
|
||||
ui->folder->setCurrentIndex(ui->folder->findData(bookmark.folder));
|
||||
ui->name->setCursorPosition(0);
|
||||
|
||||
ui->name->setEnabled(false);
|
||||
ui->folder->setEnabled(false);
|
||||
} else {
|
||||
ui->name->setText(m_view->title());
|
||||
ui->folder->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
ui->name->setCursorPosition(0);
|
||||
}
|
||||
|
||||
namespace {
|
||||
const int hideDelay = 270;
|
||||
}
|
||||
|
||||
void BookmarksWidget::removeBookmark()
|
||||
{
|
||||
m_bookmarksModel->removeBookmark(m_url);
|
||||
emit bookmarkDeleted();
|
||||
close();
|
||||
QTimer::singleShot(hideDelay, this, SLOT(close()));
|
||||
}
|
||||
|
||||
void BookmarksWidget::saveBookmark()
|
||||
{
|
||||
m_bookmarksModel->editBookmark(m_bookmarkId, ui->name->text(), QUrl(), ui->folder->itemData(ui->folder->currentIndex()).toString());
|
||||
close();
|
||||
}
|
||||
|
||||
void BookmarksWidget::addBookmark()
|
||||
{
|
||||
if (!m_bookmarksModel->isBookmarked(m_url)) {
|
||||
m_bookmarksModel->saveBookmark(m_view);
|
||||
}
|
||||
|
||||
loadBookmark();
|
||||
// m_bookmarksModel->editBookmark(m_bookmarkId, ui->name->text(), QUrl(), ui->folder->itemData(ui->folder->currentIndex()).toString());
|
||||
m_bookmarksModel->saveBookmark(m_view, ui->folder->currentText());
|
||||
QTimer::singleShot(hideDelay, this, SLOT(close()));
|
||||
}
|
||||
|
||||
void BookmarksWidget::toggleSpeedDial()
|
||||
|
@ -119,6 +127,7 @@ void BookmarksWidget::toggleSpeedDial()
|
|||
ui->speeddialButton->setText(tr("Add to Speed Dial"));
|
||||
|
||||
}
|
||||
QTimer::singleShot(hideDelay, this, SLOT(close()));
|
||||
}
|
||||
|
||||
void BookmarksWidget::showAt(QWidget* _parent)
|
||||
|
|
|
@ -50,7 +50,6 @@ private slots:
|
|||
void removeBookmark();
|
||||
void saveBookmark();
|
||||
|
||||
void addBookmark();
|
||||
void toggleSpeedDial();
|
||||
|
||||
private:
|
||||
|
|
|
@ -16,19 +16,6 @@
|
|||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeBookmark">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -111,7 +98,7 @@
|
|||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="save">
|
||||
<widget class="QPushButton" name="saveRemove">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
|
|
Loading…
Reference in New Issue
Block a user