1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Merge pull request #521 from srazi/master

A new bookmarkswidget
This commit is contained in:
David Rosca 2012-08-22 10:58:00 -07:00
commit c3d803366c
4 changed files with 141 additions and 165 deletions

View File

@ -47,7 +47,7 @@ BookmarkIcon::BookmarkIcon(QupZilla* mainClass, QWidget* parent)
void BookmarkIcon::iconClicked() void BookmarkIcon::iconClicked()
{ {
BookmarksWidget* menu = new BookmarksWidget(p_QupZilla->weView(), p_QupZilla->locationBar()); BookmarksWidget* menu = new BookmarksWidget(p_QupZilla, p_QupZilla->weView(), p_QupZilla->locationBar());
menu->showAt(this); menu->showAt(this);
} }

View File

@ -22,13 +22,15 @@
#include "pluginproxy.h" #include "pluginproxy.h"
#include "speeddial.h" #include "speeddial.h"
#include "webview.h" #include "webview.h"
#include "qupzilla.h"
#include <QToolTip> #include <QToolTip>
#include <QSqlQuery> #include <QSqlQuery>
BookmarksWidget::BookmarksWidget(WebView* view, QWidget* parent) BookmarksWidget::BookmarksWidget(QupZilla *mainClass, WebView* view, QWidget* parent)
: QMenu(parent) : QMenu(parent)
, ui(new Ui::BookmarksWidget) , ui(new Ui::BookmarksWidget)
, p_QupZilla(mainClass)
, m_url(view->url()) , m_url(view->url())
, m_view(view) , m_view(view)
, m_bookmarksModel(mApp->bookmarksModel()) , m_bookmarksModel(mApp->bookmarksModel())
@ -36,17 +38,18 @@ BookmarksWidget::BookmarksWidget(WebView* view, QWidget* parent)
{ {
ui->setupUi(this); ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
// The locationbar's direction is direction of its text,
// it dynamically changes and so, it's not good choice for this widget.
setLayoutDirection(QApplication::layoutDirection());
connect(ui->close, SIGNAL(clicked()), this, SLOT(close())); connect(ui->close, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->removeBookmark, SIGNAL(clicked()), this, SLOT(removeBookmark())); connect(ui->removeBookmark, SIGNAL(clicked()), this, SLOT(removeBookmark()));
connect(ui->save, SIGNAL(clicked()), this, SLOT(saveBookmark())); connect(ui->save, SIGNAL(clicked()), this, SLOT(saveBookmark()));
connect(ui->bookmarksButton, SIGNAL(clicked()), this, SLOT(addBookmark())); connect(ui->organizeBookmarksButton, SIGNAL(clicked()), p_QupZilla, SLOT(showBookmarksManager()));
connect(ui->speeddialButton, SIGNAL(clicked()), this, SLOT(toggleSpeedDial())); connect(ui->speeddialButton, SIGNAL(clicked()), this, SLOT(toggleSpeedDial()));
if (m_bookmarksModel->isBookmarked(m_url)) {
ui->bookmarksButton->setText(tr("Edit Bookmark"));
}
const SpeedDial::Page &page = m_speedDial->pageForUrl(m_url); 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")); ui->speeddialButton->setText(page.url.isEmpty() ? tr("Add to Speed Dial") : tr("Remove from Speed Dial"));
@ -57,13 +60,13 @@ BookmarksWidget::BookmarksWidget(WebView* view, QWidget* parent)
ui->label_2->setPalette(pal); ui->label_2->setPalette(pal);
ui->label_3->setPalette(pal); ui->label_3->setPalette(pal);
#endif #endif
addBookmark();
} }
void BookmarksWidget::loadBookmark() void BookmarksWidget::loadBookmark()
{ {
if (m_bookmarksModel->isBookmarked(m_url)) { if (m_bookmarksModel->isBookmarked(m_url)) {
ui->stackedWidget->setCurrentIndex(0);
m_bookmarkId = m_bookmarksModel->bookmarkId(m_url); m_bookmarkId = m_bookmarksModel->bookmarkId(m_url);
BookmarksModel::Bookmark bookmark = m_bookmarksModel->getBookmark(m_bookmarkId); BookmarksModel::Bookmark bookmark = m_bookmarksModel->getBookmark(m_bookmarkId);
ui->name->setText(bookmark.title); ui->name->setText(bookmark.title);

View File

@ -31,11 +31,13 @@ class BookmarksWidget;
class WebView; class WebView;
class SpeedDial; class SpeedDial;
class BookmarksModel; class BookmarksModel;
class QupZilla;
class QT_QUPZILLA_EXPORT BookmarksWidget : public QMenu class QT_QUPZILLA_EXPORT BookmarksWidget : public QMenu
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BookmarksWidget(WebView* view, QWidget* parent = 0); explicit BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* parent = 0);
~BookmarksWidget(); ~BookmarksWidget();
void showAt(QWidget* _parent); void showAt(QWidget* _parent);
@ -57,6 +59,7 @@ private:
Ui::BookmarksWidget* ui; Ui::BookmarksWidget* ui;
QUrl m_url; QUrl m_url;
int m_bookmarkId; int m_bookmarkId;
QupZilla* p_QupZilla;
WebView* m_view; WebView* m_view;
BookmarksModel* m_bookmarksModel; BookmarksModel* m_bookmarksModel;

View File

@ -7,62 +7,79 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>275</width> <width>275</width>
<height>98</height> <height>130</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="speeddialButton">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="windowTitle">
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="Frame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>9</number>
</property>
<item row="1" column="0">
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Folder:</string> <string>Add to Speed Dial</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QPushButton" name="organizeBookmarksButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Organize Bookmarks</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Name:</string> <string>Name:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item>
<widget class="QComboBox" name="folder"/>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="name"/> <widget class="QLineEdit" name="name"/>
</item> </item>
<item row="3" column="0" colspan="2"> </layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Folder:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="folder">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing"> <property name="spacing">
<number>5</number> <number>5</number>
@ -123,53 +140,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_2"> <resources/>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>25</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>25</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="bookmarksButton">
<property name="text">
<string>Add to Bookmarks</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="speeddialButton">
<property name="text">
<string>Add to Speed Dial</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Frame</class>
<extends>QFrame</extends>
<header>frame.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../data/icons.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>