summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-11-08 10:17:36 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-11-08 10:17:36 +0100
commit7187da9812bbe6ffb5bf272f18f8e74c8d23d3c7 (patch)
tree210924711005452a622383dcfadb20c5c4cfb364 /src
parentLet rekonq save file remotely (diff)
downloadrekonq-7187da9812bbe6ffb5bf272f18f8e74c8d23d3c7.tar.xz
Application Shortcut
Added an action to manage it in the tools menu, added initial code to manage icons, added kwebapp application
Diffstat (limited to 'src')
-rw-r--r--src/application.cpp32
-rw-r--r--src/application.h2
-rw-r--r--src/iconmanager.cpp13
-rw-r--r--src/iconmanager.h2
-rw-r--r--src/mainwindow.cpp5
-rw-r--r--src/rekonqui.rc3
6 files changed, 56 insertions, 1 deletions
diff --git a/src/application.cpp b/src/application.cpp
index df99b785..ea0a65e6 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -764,3 +764,35 @@ void Application::queryQuit()
// in case of just one window...
quit();
}
+
+
+void Application::createWebAppShortcut()
+{
+ KUrl u = mainWindow()->currentTab()->url();
+ QString h = u.host();
+
+ QString desktop = KGlobalSettings::desktopPath();
+ QFile wAppFile(desktop + QL1C('/') + h + QL1S(".desktop"));
+
+ if (!wAppFile.open(QIODevice::WriteOnly | QIODevice::Text))
+ {
+ kDebug() << "oops! " << wAppFile.errorString();
+ return;
+ }
+
+ iconManager()->saveDesktopIconForUrl(u);
+
+ QString iconPath = KStandardDirs::locateLocal("cache" , "favicons/" , true) + h + QL1S("_WEBAPPICON.png");
+
+ QTextStream out(&wAppFile);
+ out.setCodec("UTF-8");
+
+ out << QL1S("[Desktop Entry]\n");
+ out << QL1S("name=kwebapp\n");
+ out << QL1S("Icon=") << iconPath << QL1S("\n");
+ out << QL1S("Exec=kwebapp ") << u.url() << QL1S("\n");
+ out << QL1S("Type=Application\n");
+ out << QL1S("Categories=Application;\n");
+
+ wAppFile.close();
+}
diff --git a/src/application.h b/src/application.h
index 0c4d3101..30d2b55d 100644
--- a/src/application.h
+++ b/src/application.h
@@ -134,6 +134,8 @@ private slots:
void queryQuit();
+ void createWebAppShortcut();
+
private:
QWeakPointer<HistoryManager> m_historyManager;
QWeakPointer<BookmarkProvider> m_bookmarkProvider;
diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp
index 9ee024e2..ac53fdac 100644
--- a/src/iconmanager.cpp
+++ b/src/iconmanager.cpp
@@ -225,3 +225,16 @@ void IconManager::notifyLastStuffs(KJob *j)
doLastStuffs(j);
emit iconChanged();
}
+
+
+void IconManager::saveDesktopIconForUrl(const KUrl &u)
+{
+ KIcon icon = iconForUrl(u);
+ QString destPath = _faviconsDir + u.host() + QL1S("_WEBAPPICON.png");
+
+ QPixmap pix = icon.pixmap(16, 16);
+ int s = KIconLoader::global()->currentSize(KIconLoader::Desktop);
+ pix = pix.scaled(s, s);
+
+ pix.save(destPath);
+}
diff --git a/src/iconmanager.h b/src/iconmanager.h
index 8f55b7df..85db5ddd 100644
--- a/src/iconmanager.h
+++ b/src/iconmanager.h
@@ -54,6 +54,8 @@ public:
void clearIconCache();
+ void saveDesktopIconForUrl(const KUrl &u);
+
private Q_SLOTS:
void doLastStuffs(KJob *);
void notifyLastStuffs(KJob *);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index beab3afc..880e4d47 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -531,6 +531,11 @@ void MainWindow::setupActions()
a = new KAction(KIcon("preferences-web-browser-adblock"), i18n("Ad Block"), this);
actionCollection()->addAction(QL1S("adblock"), a);
connect(a, SIGNAL(triggered(bool)), rApp->adblockManager(), SLOT(showSettings()));
+
+ // Web Applications
+ a = new KAction(KIcon("applications-internet"), i18n("Create application shortcut"), this);
+ actionCollection()->addAction(QL1S("webapp_shortcut"), a);
+ connect(a, SIGNAL(triggered(bool)), rApp, SLOT(createWebAppShortcut()));
}
diff --git a/src/rekonqui.rc b/src/rekonqui.rc
index 66d34980..bad56615 100644
--- a/src/rekonqui.rc
+++ b/src/rekonqui.rc
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE gui SYSTEM "kpartgui.dtd">
-<gui name="rekonq" version="56">
+<gui name="rekonq" version="58">
<!--- =========== Rekonq Menu ============= -->
<Menu name="rekonqMenu" noMerge="1">
@@ -16,6 +16,7 @@
<Menu name="toolsMenu" icon="preferences-other" noMerge="1">
<text>&amp;Tools</text>
+ <Action name="webapp_shortcut" />
<Action name="web_inspector" />
<Action name="page_source" />
<Action name="net_analyzer" />