mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
Remove Name/Folder-Labels, change SpeeddialButton into a ClickableLabel.
This commit is contained in:
parent
814abafade
commit
4a33a9c538
@ -36,6 +36,7 @@ BookmarksWidget::BookmarksWidget(QupZilla* mainClass, WebView* view, QWidget* pa
|
|||||||
, m_view(view)
|
, m_view(view)
|
||||||
, m_bookmarksModel(mApp->bookmarksModel())
|
, m_bookmarksModel(mApp->bookmarksModel())
|
||||||
, m_speedDial(mApp->plugins()->speedDial())
|
, m_speedDial(mApp->plugins()->speedDial())
|
||||||
|
, m_edited(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
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.
|
// it dynamically changes and so, it's not good choice for this widget.
|
||||||
setLayoutDirection(QApplication::layoutDirection());
|
setLayoutDirection(QApplication::layoutDirection());
|
||||||
|
|
||||||
m_bookmarkId = m_bookmarksModel->bookmarkId(m_url);
|
connect(ui->speeddialButton, SIGNAL(clicked(QPoint)), this, SLOT(toggleSpeedDial()));
|
||||||
|
|
||||||
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);
|
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") :
|
||||||
#ifndef KDE
|
tr("Remove from Speed Dial"));
|
||||||
// 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
|
|
||||||
|
|
||||||
loadBookmark();
|
loadBookmark();
|
||||||
}
|
}
|
||||||
@ -81,13 +67,15 @@ void BookmarksWidget::loadBookmark()
|
|||||||
ui->folder->addItem(style()->standardIcon(QStyle::SP_DirIcon), query.value(0).toString(), query.value(0).toString());
|
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) {
|
if (m_bookmarkId > 0) {
|
||||||
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);
|
||||||
ui->folder->setCurrentIndex(ui->folder->findData(bookmark.folder));
|
ui->folder->setCurrentIndex(ui->folder->findData(bookmark.folder));
|
||||||
|
ui->saveRemove->setText(tr("Remove"));
|
||||||
ui->name->setEnabled(false);
|
connect(ui->name, SIGNAL(textEdited(QString)), SLOT(bookmarkEdited()));
|
||||||
ui->folder->setEnabled(false);
|
connect(ui->folder, SIGNAL(currentIndexChanged(int)), SLOT(bookmarkEdited()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->name->setText(m_view->title());
|
ui->name->setText(m_view->title());
|
||||||
@ -102,36 +90,49 @@ namespace
|
|||||||
const int hideDelay = 270;
|
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()
|
void BookmarksWidget::toggleSpeedDial()
|
||||||
{
|
{
|
||||||
const SpeedDial::Page &page = m_speedDial->pageForUrl(m_url);
|
const SpeedDial::Page &page = m_speedDial->pageForUrl(m_url);
|
||||||
|
|
||||||
|
QString const dialText("<a href='toggle_dial'>%1</a>");
|
||||||
if (page.url.isEmpty()) {
|
if (page.url.isEmpty()) {
|
||||||
m_speedDial->addPage(m_url, m_view->title());
|
m_speedDial->addPage(m_url, m_view->title());
|
||||||
ui->speeddialButton->setText(tr("Remove from Speed Dial"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_speedDial->removePage(page);
|
m_speedDial->removePage(page);
|
||||||
ui->speeddialButton->setText(tr("Add to Speed Dial"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
QTimer::singleShot(hideDelay, this, SLOT(close()));
|
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)
|
void BookmarksWidget::showAt(QWidget* _parent)
|
||||||
{
|
{
|
||||||
layout()->invalidate();
|
layout()->invalidate();
|
||||||
@ -142,8 +143,8 @@ void BookmarksWidget::showAt(QWidget* _parent)
|
|||||||
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
BookmarksWidget::~BookmarksWidget()
|
BookmarksWidget::~BookmarksWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,11 +44,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void bookmarkDeleted();
|
void bookmarkDeleted();
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void removeBookmark();
|
void on_saveRemove_clicked(bool);
|
||||||
void saveBookmark();
|
void bookmarkEdited();
|
||||||
|
|
||||||
void toggleSpeedDial();
|
void toggleSpeedDial();
|
||||||
|
|
||||||
@ -63,6 +61,7 @@ private:
|
|||||||
WebView* m_view;
|
WebView* m_view;
|
||||||
BookmarksModel* m_bookmarksModel;
|
BookmarksModel* m_bookmarksModel;
|
||||||
SpeedDial* m_speedDial;
|
SpeedDial* m_speedDial;
|
||||||
|
bool m_edited;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BOOKMARKSWIDGET_H
|
#endif // BOOKMARKSWIDGET_H
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>295</width>
|
<width>210</width>
|
||||||
<height>146</height>
|
<height>128</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -15,7 +15,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -30,43 +30,23 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="speeddialButton">
|
<widget class="ClickableLabel" name="speeddialButton">
|
||||||
<property name="sizePolicy">
|
<property name="cursor">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<cursorShape>PointingHandCursor</cursorShape>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add to Speed Dial</string>
|
<string>Add to Speed Dial</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="html-link-look" stdset="0">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Name:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="name"/>
|
<widget class="QLineEdit" name="name"/>
|
||||||
</item>
|
</item>
|
||||||
</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>
|
<item>
|
||||||
<widget class="QComboBox" name="folder">
|
<widget class="QComboBox" name="folder">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -77,13 +57,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="spacing">
|
|
||||||
<number>5</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -100,7 +75,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="saveRemove">
|
<widget class="QPushButton" name="saveRemove">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -114,6 +89,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>ClickableLabel</class>
|
||||||
|
<extends>QLabel</extends>
|
||||||
|
<header>clickablelabel.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user