mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
Merge branch 'bookmarks_simplified_1.3.5' of git://github.com/ff2000/qupzilla into ff2000-bookmarks_simplified_1.3.5
This commit is contained in:
commit
23dfe8b8a8
@ -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,18 +65,13 @@ 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);
|
||||
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(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;
|
||||
@ -78,31 +80,37 @@ void BookmarksWidget::loadBookmark()
|
||||
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);
|
||||
ui->folder->setCurrentIndex(ui->folder->findData(bookmark.folder));
|
||||
|
||||
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