From 00ea3abd0138fa3883fa4241ccd628638b8fdea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Fri, 3 Sep 2010 18:00:08 +0200 Subject: No need to show the url in the bookmark widget (specially if it's not editable). --- src/urlbar/bookmarkwidget.cpp | 72 +++++++++++++++++-------------------------- src/urlbar/bookmarkwidget.h | 14 ++++----- 2 files changed, 35 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index cb711723..6b507490 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -35,99 +35,96 @@ // KDE Includes #include +#include #include -#include // Qt Includes -#include #include +#include #include #include - BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) : QFrame(parent, Qt::Popup) - , m_bookmark(bookmark) + , m_bookmark(new KBookmark(bookmark)) { setAttribute(Qt::WA_DeleteOnClose); setFixedWidth(350); setFrameStyle(QFrame::Panel); QFormLayout *layout = new QFormLayout(this); - setLayout(layout); - - QHBoxLayout *hLayout = new QHBoxLayout(); + // Bookmark icon + QHBoxLayout *hLayout = new QHBoxLayout(this); QLabel *bookmarkIcon = new QLabel(this); bookmarkIcon->setPixmap(KIcon("bookmarks").pixmap(32, 32)); - hLayout->addWidget(bookmarkIcon); hLayout->setSpacing(10); + hLayout->addWidget(bookmarkIcon); - QVBoxLayout *vLayout = new QVBoxLayout(); - + // Title + QVBoxLayout *vLayout = new QVBoxLayout(this); QLabel *bookmarkInfo = new QLabel(this); bookmarkInfo->setText(i18n("Edit this Bookmark")); QFont font; font.setPointSize(font.pointSize() + 2); bookmarkInfo->setFont(font); - + bookmarkInfo->setAlignment(Qt::AlignCenter); vLayout->addWidget(bookmarkInfo); + // Remove button QPushButton *removeButton = new QPushButton(this); removeButton->setText(i18n("Remove this Bookmark")); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeBookmark())); - vLayout->addWidget(removeButton); + hLayout->addLayout(vLayout); layout->addItem(hLayout); - + // Bookmark name QLabel *nameLabel = new QLabel(this); nameLabel->setText(i18n("Name:")); - m_name = new KLineEdit(this); - if (m_bookmark.isNull()) + if (m_bookmark->isNull()) { m_name->setEnabled(false); } else { - m_name->setText(m_bookmark.text()); + m_name->setText(m_bookmark->text()); m_name->setFocus(); } - layout->addRow(nameLabel, m_name); - QLabel *urlLabel = new QLabel(this); - urlLabel->setText("URL:"); - - KLineEdit *url = new KLineEdit(this); - url->setText(m_bookmark.url().url()); - url->setEnabled(false); - - layout->addRow(urlLabel, url); - + // Ok & Cancel buttons QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); - buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Done")); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - layout->addWidget(buttonBox); + + setLayout(layout); } BookmarkWidget::~BookmarkWidget() { - delete m_name; + delete m_bookmark; +} + + +void BookmarkWidget::showAt(const QPoint &pos) +{ + QPoint p(pos.x()-350, pos.y()+12); + move(p); + show(); } void BookmarkWidget::accept() { - if (!m_bookmark.isNull() && m_name->text() != m_bookmark.fullText()) + if (!m_bookmark->isNull() && m_name->text() != m_bookmark->fullText()) { - m_bookmark.setFullText(m_name->text()); + m_bookmark->setFullText(m_name->text()); Application::bookmarkProvider()->bookmarkManager()->emitChanged(); } reject(); @@ -137,22 +134,11 @@ void BookmarkWidget::accept() void BookmarkWidget::reject() { close(); - deleteLater(); -} - - -void BookmarkWidget::showAt(const QPoint &pos) -{ - QPoint p; - p.setX(pos.x() - 350); - p.setY(pos.y() + 12); - move(p); - show(); } void BookmarkWidget::removeBookmark() { - Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(m_bookmark); + Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(*m_bookmark); reject(); } diff --git a/src/urlbar/bookmarkwidget.h b/src/urlbar/bookmarkwidget.h index c3c15e18..b95e55db 100644 --- a/src/urlbar/bookmarkwidget.h +++ b/src/urlbar/bookmarkwidget.h @@ -30,14 +30,13 @@ // Rekonq Includes #include "rekonq_defines.h" -// KDE Includes -#include -#include -#include - // Qt Includes #include +// Forward Declarations +class KBookmark; +class KLineEdit; + class BookmarkWidget : public QFrame { @@ -45,7 +44,7 @@ class BookmarkWidget : public QFrame public: explicit BookmarkWidget(const KBookmark &bookmark, QWidget *parent = 0); - ~BookmarkWidget(); + virtual ~BookmarkWidget(); void showAt(const QPoint &pos); @@ -55,9 +54,8 @@ private slots: void removeBookmark(); private: - KBookmark m_bookmark; + KBookmark *m_bookmark; KLineEdit *m_name; - }; #endif // BOOKMARKWIDGET_H -- cgit v1.2.1 From 1d341f01de25b734fbc52fd14394b7f4cdcd4214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Fri, 10 Sep 2010 10:28:15 +0200 Subject: BookmarkWidget now inherits from QMenu (much nicer). --- src/urlbar/bookmarkwidget.cpp | 3 +-- src/urlbar/bookmarkwidget.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index 6b507490..ca04cd4f 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -46,12 +46,11 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) - : QFrame(parent, Qt::Popup) + : QMenu(parent) , m_bookmark(new KBookmark(bookmark)) { setAttribute(Qt::WA_DeleteOnClose); setFixedWidth(350); - setFrameStyle(QFrame::Panel); QFormLayout *layout = new QFormLayout(this); diff --git a/src/urlbar/bookmarkwidget.h b/src/urlbar/bookmarkwidget.h index b95e55db..e97c1859 100644 --- a/src/urlbar/bookmarkwidget.h +++ b/src/urlbar/bookmarkwidget.h @@ -31,14 +31,14 @@ #include "rekonq_defines.h" // Qt Includes -#include +#include // Forward Declarations class KBookmark; class KLineEdit; -class BookmarkWidget : public QFrame +class BookmarkWidget : public QMenu { Q_OBJECT -- cgit v1.2.1 From f24af9b9aea23cac811e11014b38e435b7c1a818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Fri, 10 Sep 2010 11:50:38 +0200 Subject: The RSS widget and the bookmark widget are now more consistent (they have the same look and behavior) --- src/urlbar/bookmarkwidget.cpp | 17 ++++---------- src/urlbar/bookmarkwidget.h | 4 ---- src/urlbar/rsswidget.cpp | 53 ++++++++++++++++--------------------------- src/urlbar/rsswidget.h | 20 ++++++---------- 4 files changed, 32 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index ca04cd4f..59df85a1 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -64,10 +64,7 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) // Title QVBoxLayout *vLayout = new QVBoxLayout(this); QLabel *bookmarkInfo = new QLabel(this); - bookmarkInfo->setText(i18n("Edit this Bookmark")); - QFont font; - font.setPointSize(font.pointSize() + 2); - bookmarkInfo->setFont(font); + bookmarkInfo->setText(i18n("

Edit this Bookmark

")); bookmarkInfo->setAlignment(Qt::AlignCenter); vLayout->addWidget(bookmarkInfo); @@ -113,7 +110,9 @@ BookmarkWidget::~BookmarkWidget() void BookmarkWidget::showAt(const QPoint &pos) { - QPoint p(pos.x()-350, pos.y()+12); + adjustSize(); + + QPoint p(pos.x()-width(), pos.y()+10); move(p); show(); } @@ -126,12 +125,6 @@ void BookmarkWidget::accept() m_bookmark->setFullText(m_name->text()); Application::bookmarkProvider()->bookmarkManager()->emitChanged(); } - reject(); -} - - -void BookmarkWidget::reject() -{ close(); } @@ -139,5 +132,5 @@ void BookmarkWidget::reject() void BookmarkWidget::removeBookmark() { Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(*m_bookmark); - reject(); + close(); } diff --git a/src/urlbar/bookmarkwidget.h b/src/urlbar/bookmarkwidget.h index e97c1859..e07dac24 100644 --- a/src/urlbar/bookmarkwidget.h +++ b/src/urlbar/bookmarkwidget.h @@ -27,9 +27,6 @@ #ifndef BOOKMARKWIDGET_H #define BOOKMARKWIDGET_H -// Rekonq Includes -#include "rekonq_defines.h" - // Qt Includes #include @@ -50,7 +47,6 @@ public: private slots: void accept(); - void reject(); void removeBookmark(); private: diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp index 25587502..270468a1 100644 --- a/src/urlbar/rsswidget.cpp +++ b/src/urlbar/rsswidget.cpp @@ -30,42 +30,40 @@ // Local includes #include "application.h" +#include "iconmanager.h" #include "mainwindow.h" #include "webtab.h" -#include "webview.h" -#include "iconmanager.h" // KDE Includes +#include #include -#include -#include #include +#include +#include // Qt Includes -#include +#include +#include + #include +#include #include #include -#include -#include - - RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent) - : QFrame(parent, Qt::Popup) + : QMenu(parent) , m_map(map) { setAttribute(Qt::WA_DeleteOnClose); - - setMinimumWidth(200); - setFrameStyle(Panel); + setMinimumWidth(250); QFormLayout *layout = new QFormLayout(this); - setLayout(layout); + // Title QLabel *title = new QLabel(this); title->setText(i18n("

Subscribe to RSS Feeds

")); + title->setAlignment(Qt::AlignCenter); layout->addRow(title); // Agregators @@ -74,7 +72,7 @@ RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent) m_agregators = new KComboBox(this); m_agregators->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - + m_agregators->addItem(KIcon("akregator"), QString("Akregator")); m_agregators->addItem(Application::iconManager()->iconForUrl(KUrl("http://google.com/reader")), i18n("Google Reader")); @@ -91,37 +89,34 @@ RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent) { m_feeds->addItem(title); } - + layout->addRow(feed, m_feeds); // Buttons QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal, this); - + QPushButton *addFeed = new QPushButton(KIcon("list-add"), i18n("Add Feed"), buttonBox); buttonBox->addButton(addFeed, QDialogButtonBox::AcceptRole); - + connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); layout->addRow(buttonBox); + + setLayout(layout); } RSSWidget::~RSSWidget() { - delete m_agregators; - delete m_feeds; } void RSSWidget::showAt(const QPoint &pos) { adjustSize(); - - QPoint p; - p.setX(pos.x() - width()); - p.setY(pos.y() + 10); - + + QPoint p(pos.x()-width(), pos.y()+10); move(p); show(); } @@ -136,14 +131,7 @@ void RSSWidget::accept() else addWithGoogleReader(url); - reject(); -} - - -void RSSWidget::reject() -{ close(); - this->deleteLater(); } @@ -179,6 +167,5 @@ void RSSWidget::addWithAkregator(const QString &url) KMessageBox::error(0, QString(i18n("There was an error. Please verify Akregator is installed on your system.") + "

" + url + "")); } - } } diff --git a/src/urlbar/rsswidget.h b/src/urlbar/rsswidget.h index 0272805e..33c34e76 100644 --- a/src/urlbar/rsswidget.h +++ b/src/urlbar/rsswidget.h @@ -27,20 +27,15 @@ #ifndef RSSWIDGET_H #define RSSWIDGET_H -// Rekonq Includes -#include "rekonq_defines.h" - -// KDE Includes -#include -#include - // Qt Includes -#include +#include -#include +// Forward Declarations +class KComboBox; +class KUrl; -class RSSWidget : public QFrame +class RSSWidget : public QMenu { Q_OBJECT @@ -48,13 +43,12 @@ public: // QMap< feedUrl, feedTitle> RSSWidget(const QMap &map, QWidget *parent = 0); ~RSSWidget(); - + void showAt(const QPoint &pos); private slots: void accept(); - void reject(); - + private: void addWithAkregator(const QString &url); void addWithGoogleReader(const QString &url); -- cgit v1.2.1 From b2f8b1e4a123069bbf131aa4bd50fd67cd93727f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Fri, 10 Sep 2010 12:04:47 +0200 Subject: Minor bug introduced in previous commit fixed --- src/urlbar/bookmarkwidget.cpp | 2 +- src/urlbar/rsswidget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index 59df85a1..4569bc27 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -95,7 +95,7 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) // Ok & Cancel buttons QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); layout->addWidget(buttonBox); setLayout(layout); diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp index 270468a1..b29ed0e8 100644 --- a/src/urlbar/rsswidget.cpp +++ b/src/urlbar/rsswidget.cpp @@ -99,7 +99,7 @@ RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent) buttonBox->addButton(addFeed, QDialogButtonBox::AcceptRole); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); + connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); layout->addRow(buttonBox); -- cgit v1.2.1 From ef0c5630983853473e1e3c97a4c68baa1d487e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Ander=20Pe=C3=B1alba?= Date: Fri, 10 Sep 2010 12:50:00 +0200 Subject: Fixes a string change (this commit should be reverted after v0.6) --- src/urlbar/bookmarkwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp index 4569bc27..409f1468 100644 --- a/src/urlbar/bookmarkwidget.cpp +++ b/src/urlbar/bookmarkwidget.cpp @@ -64,7 +64,10 @@ BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent) // Title QVBoxLayout *vLayout = new QVBoxLayout(this); QLabel *bookmarkInfo = new QLabel(this); - bookmarkInfo->setText(i18n("

Edit this Bookmark

")); + bookmarkInfo->setText(i18n("Edit this Bookmark")); + QFont font; + font.setPointSize(font.pointSize() + 2); + bookmarkInfo->setFont(font); bookmarkInfo->setAlignment(Qt::AlignCenter); vLayout->addWidget(bookmarkInfo); -- cgit v1.2.1