diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/application.cpp | 87 | ||||
-rw-r--r-- | src/rekonq.kcfg | 6 | ||||
-rw-r--r-- | src/webappcreation.ui | 85 |
4 files changed, 162 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d31b98f7..ced397c7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,6 +102,7 @@ KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS adblock/settings_adblock.ui cleardata.ui sslinfo.ui + webappcreation.ui useragent/useragentsettings.ui ) diff --git a/src/application.cpp b/src/application.cpp index ea0a65e6..d29324c4 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -33,6 +33,9 @@ // Auto Includes #include "rekonq.h" +// Ui Includes +#include "ui_webappcreation.h" + // Local Includes #include "adblockmanager.h" #include "bookmarkprovider.h" @@ -61,6 +64,7 @@ #include <KWindowInfo> #include <KGlobal> #include <KCharsets> +#include <KPushButton> // Qt Includes #include <QVBoxLayout> @@ -771,28 +775,77 @@ void Application::createWebAppShortcut() KUrl u = mainWindow()->currentTab()->url(); QString h = u.host(); - QString desktop = KGlobalSettings::desktopPath(); - QFile wAppFile(desktop + QL1C('/') + h + QL1S(".desktop")); + QPointer<KDialog> dialog = new KDialog(mainWindow()); + dialog->setCaption(i18nc("@title:window", "Create Application Shortcut")); + dialog->setButtons(KDialog::Ok | KDialog::Cancel); + dialog->button(KDialog::Ok)->setText(i18n("Create")); + + Ui::webAppCreation wAppWidget; + QWidget widget; + wAppWidget.setupUi(&widget); + + wAppWidget.iconLabel->setPixmap(iconManager()->iconForUrl(u).pixmap(32)); + wAppWidget.titleLabel->setText(h); + wAppWidget.kcfg_createDesktopAppShortcut->setChecked(ReKonfig::createDesktopAppShortcut()); + wAppWidget.kcfg_createMenuAppShortcut->setChecked(ReKonfig::createMenuAppShortcut()); - if (!wAppFile.open(QIODevice::WriteOnly | QIODevice::Text)) + dialog->setMainWidget(&widget); + dialog->exec(); + + if (dialog->result() == QDialog::Accepted) { - kDebug() << "oops! " << wAppFile.errorString(); - return; - } + ReKonfig::setCreateDesktopAppShortcut(wAppWidget.kcfg_createDesktopAppShortcut->isChecked()); + ReKonfig::setCreateMenuAppShortcut(wAppWidget.kcfg_createMenuAppShortcut->isChecked()); + + iconManager()->saveDesktopIconForUrl(u); + QString iconPath = KStandardDirs::locateLocal("cache" , "favicons/" , true) + h + QL1S("_WEBAPPICON.png"); + + QString shortcutString = QL1S("#!/usr/bin/env xdg-open\n") + + QL1S("[Desktop Entry]\n") + + QL1S("name=kwebapp\n") + + QL1S("Icon=") + iconPath + QL1S("\n") + + QL1S("Exec=kwebapp ") + u.url() + QL1S("\n") + + QL1S("Type=Application\n") + + QL1S("Categories=Application;Network;WebBrowser\n") + ; + + if (ReKonfig::createDesktopAppShortcut()) + { + QString desktop = KGlobalSettings::desktopPath(); + QFile wAppFile(desktop + QL1C('/') + h + QL1S(".desktop")); + + if (!wAppFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + kDebug() << "Unable to open file: " << wAppFile.errorString(); + return; + } - iconManager()->saveDesktopIconForUrl(u); + QTextStream out(&wAppFile); + out.setCodec("UTF-8"); + out << shortcutString; - QString iconPath = KStandardDirs::locateLocal("cache" , "favicons/" , true) + h + QL1S("_WEBAPPICON.png"); + wAppFile.close(); + } - QTextStream out(&wAppFile); - out.setCodec("UTF-8"); + if (ReKonfig::createMenuAppShortcut()) + { + QString appMenuDir = KStandardDirs::locateLocal("xdgdata-apps", QString()); + QFile wAppFile(appMenuDir + QL1C('/') + h + QL1S(".desktop")); - 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"); + if (!wAppFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + kDebug() << "Unable to open file: " << wAppFile.errorString(); + return; + } + + QTextStream out(&wAppFile); + out.setCodec("UTF-8"); + out << shortcutString; + + wAppFile.close(); + } + + } - wAppFile.close(); + dialog->deleteLater(); } diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index f0fc3766..96e71f00 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -30,6 +30,12 @@ <entry name="recoverOnCrash" type="Int"> <default>0</default> </entry> + <entry name="createDesktopAppShortcut" type="Bool"> + <default>true</default> + </entry> + <entry name="createMenuAppShortcut" type="Bool"> + <default>false</default> + </entry> </group> diff --git a/src/webappcreation.ui b/src/webappcreation.ui new file mode 100644 index 00000000..60fc841d --- /dev/null +++ b/src/webappcreation.ui @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>webAppCreation</class> + <widget class="QWidget" name="webAppCreation"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>445</width> + <height>151</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="iconLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>ICON</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="titleLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>TITLE</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Create Application shortcuts in:</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="kcfg_createDesktopAppShortcut"> + <property name="text"> + <string>Desktop</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="kcfg_createMenuAppShortcut"> + <property name="text"> + <string>Application MenĂ¹</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> |