summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/previewimage.cpp24
-rw-r--r--src/previewimage.h3
-rw-r--r--src/websnap.cpp1
3 files changed, 21 insertions, 7 deletions
diff --git a/src/previewimage.cpp b/src/previewimage.cpp
index 873abccf..fd007432 100644
--- a/src/previewimage.cpp
+++ b/src/previewimage.cpp
@@ -52,11 +52,12 @@ PreviewImage::PreviewImage(const QUrl &url, int index, bool isFavorite)
: QLabel()
, ws(0)
, m_url(0)
+ , loadingSnapshot(false)
, m_isFavorite(isFavorite)
, m_index(index)
, m_button(0)
{
- setUrl(url);
+ loadUrlPreview(url);
}
@@ -67,7 +68,7 @@ PreviewImage::~PreviewImage()
-void PreviewImage::setUrl(const QUrl& url)
+void PreviewImage::loadUrlPreview(const QUrl& url)
{
m_url = url;
@@ -86,12 +87,13 @@ void PreviewImage::setUrl(const QUrl& url)
}
else
{
+ loadingSnapshot = true;
ws = new WebSnap( url );
connect(ws, SIGNAL(finished()), this, SLOT(snapFinished()));
QString path = KStandardDirs::locate("appdata", "pics/busywidget.gif");
-
+ // load an animation waiting for site preview
QMovie *movie = new QMovie(path, QByteArray(), this);
movie->setSpeed(50);
setMovie(movie);
@@ -102,6 +104,7 @@ void PreviewImage::setUrl(const QUrl& url)
void PreviewImage::snapFinished()
{
+ loadingSnapshot = false;
QMovie *m = movie();
delete m;
setMovie(0);
@@ -124,12 +127,17 @@ void PreviewImage::snapFinished()
ReKonfig::setPreviewNames(names);
ReKonfig::setPreviewUrls(urls);
+
+ ReKonfig::self()->writeConfig();
}
}
void PreviewImage::showEmptyPreview()
{
+ if(!m_isFavorite)
+ return;
+
clear();
QHBoxLayout *layout = new QHBoxLayout(this);
@@ -186,6 +194,9 @@ void PreviewImage::contextMenuEvent(QContextMenuEvent* event)
if(!m_isFavorite)
return;
+ if(loadingSnapshot)
+ return;
+
KMenu menu(this);
KAction *a;
@@ -219,8 +230,8 @@ KActionMenu* PreviewImage::historyMenu()
{
HistoryItem it = history.at(i);
KAction *a = new KAction(Application::icon(it.url), it.title, this);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(setUrlFromAction()));
a->setData(it.url);
+ connect(a, SIGNAL(triggered(bool)), this, SLOT(setUrlFromAction()));
histMenu->addAction(a);
}
@@ -241,6 +252,9 @@ void PreviewImage::removeMe()
ReKonfig::setPreviewNames(names);
ReKonfig::setPreviewUrls(urls);
+ // sync file data
+ ReKonfig::self()->writeConfig();
+
showEmptyPreview();
m_url = "";
@@ -258,7 +272,7 @@ void PreviewImage::setUrlFromAction()
m_button->menu()->deleteLater();
m_button->deleteLater();
}
- setUrl(url);
+ loadUrlPreview(url);
}
diff --git a/src/previewimage.h b/src/previewimage.h
index 0abbe479..99e278f1 100644
--- a/src/previewimage.h
+++ b/src/previewimage.h
@@ -61,7 +61,7 @@ protected:
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
- void setUrl(const QUrl &url);
+ void loadUrlPreview(const QUrl &url);
KActionMenu *historyMenu();
void showEmptyPreview();
@@ -72,6 +72,7 @@ private:
QUrl m_url;
QString m_savePath;
+ bool loadingSnapshot;
bool m_isFavorite;
int m_index;
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 83cfe88b..577370ba 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -134,7 +134,6 @@ void WebSnap::saveResult(bool ok)
QString WebSnap::snapTitle()
{
return m_page.mainFrame()->title();
- return QString("");
}