summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rekonqpage/newtabpage.cpp4
-rw-r--r--src/rekonqpage/previewselectorbar.cpp140
-rw-r--r--src/rekonqpage/previewselectorbar.h85
-rw-r--r--src/webinspectorpanel.cpp6
-rw-r--r--src/webinspectorpanel.h2
-rw-r--r--src/webtab.cpp14
-rw-r--r--src/webtab.h5
7 files changed, 134 insertions, 122 deletions
diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp
index 95b15ed9..7a373f62 100644
--- a/src/rekonqpage/newtabpage.cpp
+++ b/src/rekonqpage/newtabpage.cpp
@@ -39,6 +39,7 @@
#include "mainview.h"
#include "websnap.h"
#include "previewselectorbar.h"
+#include "webtab.h"
// KDE Includes
#include <KStandardDirs>
@@ -87,8 +88,7 @@ void NewTabPage::generate(KUrl url)
if(url.directory() == QString("preview/modify"))
{
int index = url.fileName().toInt();
- Application::instance()->mainWindow()->findChild<PreviewSelectorBar *>()
- ->enable(index, qobject_cast< WebPage* >(m_root.webFrame()->page()));
+ Application::instance()->mainWindow()->currentTab()->createPreviewSelectorBar(index);
return;
}
}
diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp
index 5f3956d7..564d286c 100644
--- a/src/rekonqpage/previewselectorbar.cpp
+++ b/src/rekonqpage/previewselectorbar.cpp
@@ -1,29 +1,40 @@
-/*
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Matthieu Gicquel<matgic78 at gmail dot com>
+* Copyright (C) 2010 by Andrea Diamantini <adjam7 at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
// Auto Includes
#include "previewselectorbar.h"
+#include "previewselectorbar.moc"
// Local Include
#include "rekonq.h"
#include "websnap.h"
+#include "application.h"
+#include "mainwindow.h"
+#include "webtab.h"
// KDE Includes
#include <KIcon>
@@ -35,32 +46,23 @@
#include <QString>
-PreviewSelectorBar::PreviewSelectorBar(QWidget* parent)
+PreviewSelectorBar::PreviewSelectorBar(int index, QWidget* parent)
: QWidget(parent)
, m_button(0)
, m_label(0)
- , m_page(0)
+ , m_previewIndex(index)
{
- hide();
-}
-
-
-void PreviewSelectorBar::setup()
-{
- if(m_button != 0)
- return;
-
m_label = new QLabel(i18n("Please open up the webpage you want to add as favorite"), this);
m_label->setWordWrap(true);
QToolButton *closeButton = new QToolButton(this);
closeButton->setAutoRaise(true);
closeButton->setIcon(KIcon("dialog-close"));
- connect(closeButton, SIGNAL(clicked(bool)), SLOT(hide()));
+ connect(closeButton, SIGNAL(clicked(bool)), this, SLOT(destroy()));
m_button = new QPushButton(KIcon("insert-image"), i18n("Set to This Page"), this);
m_button->setMaximumWidth(250);
- connect(m_button, SIGNAL(clicked(bool)), SLOT(clicked()));
+ connect(m_button, SIGNAL(clicked(bool)), this, SLOT(clicked()));
// layout
QHBoxLayout *layout = new QHBoxLayout(this);
@@ -74,16 +76,15 @@ void PreviewSelectorBar::setup()
}
-void PreviewSelectorBar::setPage(WebPage* page)
+PreviewSelectorBar::~PreviewSelectorBar()
{
- m_page = page;
- verifyUrl();
}
void PreviewSelectorBar::verifyUrl()
{
- if(m_page->mainFrame()->url().scheme() != "about")
+
+ if(Application::instance()->mainWindow()->currentTab()->page()->mainFrame()->url().scheme() != "about")
{
m_button->setEnabled(true);
m_button->setToolTip("");
@@ -96,27 +97,6 @@ void PreviewSelectorBar::verifyUrl()
}
-void PreviewSelectorBar::enable(int previewIndex, WebPage* page)
-{
- if(m_page != 0)
- disconnect(m_page, 0, this, 0);
-
-
- setup();
- m_previewIndex = previewIndex;
- m_page = page;
-
- verifyUrl();
-
- show();
-
- connect(page, SIGNAL(loadStarted()), SLOT(loadProgress()));
- connect(page, SIGNAL(loadProgress(int)), SLOT(loadProgress()));
- connect(page, SIGNAL(loadFinished(bool)), SLOT(loadFinished()));
- connect(page->mainFrame(), SIGNAL(urlChanged(QUrl)), SLOT(verifyUrl()));
-}
-
-
void PreviewSelectorBar::loadProgress()
{
m_button->setEnabled(false);
@@ -124,7 +104,6 @@ void PreviewSelectorBar::loadProgress()
}
-
void PreviewSelectorBar::loadFinished()
{
m_button->setEnabled(true);
@@ -136,25 +115,38 @@ void PreviewSelectorBar::loadFinished()
void PreviewSelectorBar::clicked()
{
- KUrl url = m_page->mainFrame()->url();
-
- WebSnap::savePreview(WebSnap::renderPreview(*m_page), url);
-
- QStringList names = ReKonfig::previewNames();
- QStringList urls = ReKonfig::previewUrls();
-
- urls.replace(m_previewIndex, url.toMimeDataString());
- names.replace(m_previewIndex, m_page->mainFrame()->title());
-
- ReKonfig::setPreviewNames(names);
- ReKonfig::setPreviewUrls(urls);
+ WebPage *page = Application::instance()->mainWindow()->currentTab()->page();
- ReKonfig::self()->writeConfig();
-
-
- m_page->mainFrame()->load(KUrl("about:favorites"));
+ if(page)
+ {
+ KUrl url = page->mainFrame()->url();
+
+ WebSnap::savePreview(WebSnap::renderPreview(*page), url);
+
+ QStringList names = ReKonfig::previewNames();
+ QStringList urls = ReKonfig::previewUrls();
+
+ urls.replace(m_previewIndex, url.toMimeDataString());
+ names.replace(m_previewIndex, page->mainFrame()->title());
+
+ ReKonfig::setPreviewNames(names);
+ ReKonfig::setPreviewUrls(urls);
+
+ ReKonfig::self()->writeConfig();
+
+
+ page->mainFrame()->load(KUrl("about:favorites"));
+ }
- hide();
+ destroy();
}
+void PreviewSelectorBar::destroy()
+{
+ if (parentWidget() && parentWidget()->layout())
+ {
+ parentWidget()->layout()->removeWidget(this);
+ }
+ this->deleteLater();
+}
diff --git a/src/rekonqpage/previewselectorbar.h b/src/rekonqpage/previewselectorbar.h
index aa011fe4..4f7fc21b 100644
--- a/src/rekonqpage/previewselectorbar.h
+++ b/src/rekonqpage/previewselectorbar.h
@@ -1,21 +1,29 @@
-/*
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 by Matthieu Gicquel<matgic78 at gmail dot com>
+* Copyright (C) 2010 by Andrea Diamantini <adjam7 at gmail dot com>
+*
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as
+* published by the Free Software Foundation; either version 2 of
+* the License or (at your option) version 3 or any later version
+* accepted by the membership of KDE e.V. (or its successor approved
+* by the membership of KDE e.V.), which shall act as a proxy
+* defined in Section 14 of version 3 of the license.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* ============================================================ */
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-*/
#ifndef PREVIEWSELECTORBAR_H
#define PREVIEWSELECTORBAR_H
@@ -28,33 +36,30 @@
#include <QPushButton>
#include <QLabel>
+
class PreviewSelectorBar : public QWidget
{
- Q_OBJECT
+Q_OBJECT
+
+public:
+ PreviewSelectorBar(int index, QWidget *parent);
+ ~PreviewSelectorBar();
+
+private slots:
+ void clicked();
+
+ void loadProgress();
+ void loadFinished();
+
+ void verifyUrl();
+
+ void destroy();
- public:
- PreviewSelectorBar(QWidget *parent = 0);
-
- void setPage(WebPage *page);
-
- public slots:
- void enable(int previewIndex, WebPage *page);
- void clicked();
-
- void loadProgress();
- void loadFinished();
-
- void verifyUrl();
-
- private:
- void setup();
-
- QPushButton *m_button;
- QLabel *m_label;
-
- int m_previewIndex;
- WebPage *m_page;
+private:
+ QPushButton *m_button;
+ QLabel *m_label;
+ int m_previewIndex;
};
#endif // PREVIEWSELECTORBAR_H
diff --git a/src/webinspectorpanel.cpp b/src/webinspectorpanel.cpp
index a038d280..4f86f5e4 100644
--- a/src/webinspectorpanel.cpp
+++ b/src/webinspectorpanel.cpp
@@ -2,7 +2,7 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2009 by Matthieu Gicquel<matgic78@gmail.com>
+* Copyright (C) 2009 by Matthieu Gicquel<matgic78 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
@@ -10,9 +10,9 @@
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
+* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
-*
+*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
diff --git a/src/webinspectorpanel.h b/src/webinspectorpanel.h
index 8f65b48a..2d6dd8eb 100644
--- a/src/webinspectorpanel.h
+++ b/src/webinspectorpanel.h
@@ -2,7 +2,7 @@
*
* This file is a part of the rekonq project
*
-* Copyright (C) 2009 by Matthieu Gicquel<matgic78@gmail.com>
+* Copyright (C) 2009 by Matthieu Gicquel<matgic78 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
diff --git a/src/webtab.cpp b/src/webtab.cpp
index b3eb71f0..fb925d6e 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -39,6 +39,7 @@
#include "webpage.h"
#include "bookmarksmanager.h"
#include "walletbar.h"
+#include "previewselectorbar.h"
// KDE Includes
#include <KService>
@@ -165,3 +166,16 @@ void WebTab::createWalletBar(const QString &key, const QUrl &url)
connect(walletBar, SIGNAL(saveFormDataRejected(const QString &)),
wallet, SLOT(rejectSaveFormDataRequest(const QString &)));
}
+
+
+void WebTab::createPreviewSelectorBar(int index)
+{
+ QWidget *messageBar = layout()->itemAt(0)->widget();
+ PreviewSelectorBar *bar = new PreviewSelectorBar(index, messageBar);
+ messageBar->layout()->addWidget(bar);
+
+ connect(page(), SIGNAL(loadStarted()), bar, SLOT(loadProgress()));
+ connect(page(), SIGNAL(loadProgress(int)), bar, SLOT(loadProgress()));
+ connect(page(), SIGNAL(loadFinished(bool)), bar, SLOT(loadFinished()));
+ connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), bar, SLOT(verifyUrl()));
+}
diff --git a/src/webtab.h b/src/webtab.h
index ecf8e5b3..7ab5114e 100644
--- a/src/webtab.h
+++ b/src/webtab.h
@@ -51,14 +51,15 @@ public:
KUrl url() const;
QString lastStatusBarText() const;
int progress();
-
+ void createPreviewSelectorBar(int index);
+
private slots:
void setStatusBarText(const QString &string);
void updateProgress(int progress);
void loadFinished(bool);
void createWalletBar(const QString &, const QUrl &);
-
+
private:
WebView *const m_view;
int m_progress;