summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-10-30 19:39:27 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:48:06 +0100
commit546cd34324529dbfdf7a26660e349e0b92c95348 (patch)
tree04bed3623d7d1e0d6c853a2c2aa5e8e1e4e4161f
parentwork on the findbar (diff)
downloadrekonq-546cd34324529dbfdf7a26660e349e0b92c95348.tar.xz
Improve webapp creation, fixing title name choice
-rw-r--r--src/application.cpp45
-rw-r--r--src/application.h2
2 files changed, 30 insertions, 17 deletions
diff --git a/src/application.cpp b/src/application.cpp
index 957bee7f..4ce8b121 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -132,12 +132,9 @@ int Application::newInstance()
u = UrlResolver::urlFromTextTyped(args->arg(0));
}
kDebug() << "URL: " << u;
- WebTab *tab = new WebTab;
- tab->view()->load(u);
- tab->installEventFilter(this);
- m_webApps.prepend(tab);
- tab->show();
+ WebTab *tab = newWebApp();
+ tab->view()->load(u);
if (isFirstLoad)
{
@@ -423,6 +420,19 @@ TabWindow *Application::newTabWindow(bool withTab, bool PrivateBrowsingMode)
}
+WebTab *Application::newWebApp()
+{
+ WebTab *tab = new WebTab;
+
+ tab->installEventFilter(this);
+ m_webApps.prepend(tab);
+
+ tab->show();
+
+ return tab;
+}
+
+
TabWindowList Application::tabWindowList()
{
return m_tabWindows;
@@ -721,8 +731,8 @@ void Application::createWebAppShortcut()
QWidget widget;
wAppWidget.setupUi(&widget);
- const QString title = tabWindow()->currentWebWindow()->title().remove('&');
- wAppWidget.nameLineEdit->setText(title);
+ QString webAppTitle = tabWindow()->currentWebWindow()->title().remove('&');
+ wAppWidget.nameLineEdit->setText(webAppTitle);
wAppWidget.kcfg_createDesktopAppShortcut->setChecked(ReKonfig::createDesktopAppShortcut());
wAppWidget.kcfg_createMenuAppShortcut->setChecked(ReKonfig::createMenuAppShortcut());
@@ -737,17 +747,18 @@ void Application::createWebAppShortcut()
IconManager::self()->saveDesktopIconForUrl(u);
QString iconPath = KStandardDirs::locateLocal("cache" , "favicons/" , true) + h + QL1S("_WEBAPPICON.png");
+ if (!wAppWidget.nameLineEdit->text().isEmpty())
+ webAppTitle = wAppWidget.nameLineEdit->text();
+
+ QString webAppDescription;
+ if (!wAppWidget.descriptionLineEdit->text().isEmpty())
+ webAppDescription = wAppWidget.descriptionLineEdit->text();
+
QString shortcutString = QL1S("#!/usr/bin/env xdg-open\n")
+ QL1S("[Desktop Entry]\n")
- + QL1S("Name=")
- + (wAppWidget.nameLineEdit->text().isEmpty()
- ? QL1S("rekonq")
- : wAppWidget.nameLineEdit->text())
+ + QL1S("Name=") + webAppTitle
+ QL1S("\n")
- + QL1S("GenericName=")
- + (wAppWidget.descriptionLineEdit->text().isEmpty()
- ? QL1S("")
- : wAppWidget.descriptionLineEdit->text())
+ + QL1S("GenericName=") + webAppDescription
+ QL1S("\n")
+ QL1S("Icon=") + iconPath + QL1S("\n")
+ QL1S("Exec=rekonq --webapp ") + u.url() + QL1S("\n")
@@ -758,7 +769,7 @@ void Application::createWebAppShortcut()
if (ReKonfig::createDesktopAppShortcut())
{
QString desktop = KGlobalSettings::desktopPath();
- QFile wAppFile(desktop + QL1C('/') + title);
+ QFile wAppFile(desktop + QL1C('/') + webAppTitle);
if (!wAppFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
@@ -777,7 +788,7 @@ void Application::createWebAppShortcut()
if (ReKonfig::createMenuAppShortcut())
{
QString appMenuDir = KStandardDirs::locateLocal("xdgdata-apps", QString());
- QFile wAppFile(appMenuDir + QL1C('/') + title + QL1S(".desktop"));
+ QFile wAppFile(appMenuDir + QL1C('/') + webAppTitle + QL1S(".desktop"));
if (!wAppFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
diff --git a/src/application.h b/src/application.h
index 3750547c..679c3aad 100644
--- a/src/application.h
+++ b/src/application.h
@@ -92,6 +92,8 @@ public Q_SLOTS:
TabWindow *newTabWindow(bool withTab = true, bool PrivateBrowsingMode = false);
+ WebTab *newWebApp();
+
protected:
// This is used to track which window was activated most recently
bool eventFilter(QObject *watched, QEvent *event);