diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2012-08-08 14:25:40 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2012-12-10 02:48:04 +0100 |
commit | a118af29f0d10e732baa7fe364be4091ada06765 (patch) | |
tree | 88e1249b111cd20169cc817f2ce9e522fda30f2c /src | |
parent | User agent management restored (diff) | |
download | rekonq-a118af29f0d10e732baa7fe364be4091ada06765.tar.xz |
Tools actions restored
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/application.cpp | 96 | ||||
-rw-r--r-- | src/application.h | 2 | ||||
-rw-r--r-- | src/webappcreation.ui | 96 | ||||
-rw-r--r-- | src/webwindow/webwindow.cpp | 39 | ||||
-rw-r--r-- | src/webwindow/webwindow.h | 2 |
6 files changed, 231 insertions, 5 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9cdccb5d..6c41fef6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -146,6 +146,7 @@ KDE4_ADD_UI_FILES( rekonq_KDEINIT_SRCS webtab/sslinfo.ui # ---------------------------------------- cleardata.ui + webappcreation.ui ) diff --git a/src/application.cpp b/src/application.cpp index 57aaa0f8..161ef5c6 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -31,6 +31,9 @@ // Auto Includes #include "rekonq.h" +// Ui Includes +#include "ui_webappcreation.h" + // Local Includes #include "searchengine.h" #include "tabwindow.h" @@ -620,3 +623,96 @@ void Application::clearPrivateData() dialog->deleteLater(); } + + +void Application::createWebAppShortcut() +{ + KUrl u = tabWindow()->currentWebWindow()->url(); + QString h = u.host(); + + QPointer<KDialog> dialog = new KDialog(tabWindow()); + dialog->setCaption(i18nc("@title:window", "Create Application Shortcut")); + dialog->setButtons(KDialog::Ok | KDialog::Cancel); + dialog->button(KDialog::Ok)->setText(i18n("Create")); + dialog->setMinimumSize(400, 50); + dialog->setWindowIcon( QIcon(IconManager::self()->iconForUrl(u).pixmap(16)) ); + + Ui::webAppCreation wAppWidget; + QWidget widget; + wAppWidget.setupUi(&widget); + + const QString title = tabWindow()->currentWebWindow()->title().remove('&'); + wAppWidget.nameLineEdit->setText(title); + wAppWidget.kcfg_createDesktopAppShortcut->setChecked(ReKonfig::createDesktopAppShortcut()); + wAppWidget.kcfg_createMenuAppShortcut->setChecked(ReKonfig::createMenuAppShortcut()); + + dialog->setMainWidget(&widget); + dialog->exec(); + + if (dialog->result() == QDialog::Accepted) + { + ReKonfig::setCreateDesktopAppShortcut(wAppWidget.kcfg_createDesktopAppShortcut->isChecked()); + ReKonfig::setCreateMenuAppShortcut(wAppWidget.kcfg_createMenuAppShortcut->isChecked()); + + IconManager::self()->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=") + + (wAppWidget.nameLineEdit->text().isEmpty() + ? QL1S("kwebapp") + : wAppWidget.nameLineEdit->text()) + + QL1S("\n") + + QL1S("GenericName=") + + (wAppWidget.descriptionLineEdit->text().isEmpty() + ? QL1S("") + : wAppWidget.descriptionLineEdit->text()) + + QL1S("\n") + + QL1S("Icon=") + iconPath + QL1S("\n") + + QL1S("Exec=kwebapp ") + u.url() + QL1S("\n") + + QL1S("Type=Application\n") + + QL1S("Categories=Application;Network\n") + ; + + if (ReKonfig::createDesktopAppShortcut()) + { + QString desktop = KGlobalSettings::desktopPath(); + QFile wAppFile(desktop + QL1C('/') + title); + + 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.setPermissions(QFile::ReadUser | QFile::WriteUser | QFile::ExeUser | QFile::ReadGroup | QFile::ReadOther); + wAppFile.close(); + } + + if (ReKonfig::createMenuAppShortcut()) + { + QString appMenuDir = KStandardDirs::locateLocal("xdgdata-apps", QString()); + QFile wAppFile(appMenuDir + QL1C('/') + title + QL1S(".desktop")); + + 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(); + } + + } + + dialog->deleteLater(); +} diff --git a/src/application.h b/src/application.h index 760854b4..4934540e 100644 --- a/src/application.h +++ b/src/application.h @@ -102,6 +102,8 @@ private Q_SLOTS: void queryQuit(); + void createWebAppShortcut(); + private: TabWindowList m_tabWindows; }; diff --git a/src/webappcreation.ui b/src/webappcreation.ui new file mode 100644 index 00000000..1e688290 --- /dev/null +++ b/src/webappcreation.ui @@ -0,0 +1,96 @@ +<?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>461</width> + <height>143</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="nameLineEdit"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Description:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="descriptionLineEdit"> + <property name="text"> + <string/> + </property> + <property name="placeholderText"> + <string>(optional)</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </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 Menu</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> diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp index 72bdc1e8..2dc476c1 100644 --- a/src/webwindow/webwindow.cpp +++ b/src/webwindow/webwindow.cpp @@ -29,8 +29,10 @@ #include "application.h" +#include "adblockmanager.h" #include "bookmarkmanager.h" #include "iconmanager.h" +#include "syncmanager.h" #include "useragentmanager.h" #include "webpage.h" @@ -179,6 +181,7 @@ void WebWindow::setupActions() KStandardAction::open(this, SLOT(fileOpen()), actionCollection()); KStandardAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); KStandardAction::print(_tab, SLOT(printFrame()), actionCollection()); + KStandardAction::preferences(this, SLOT(preferences()), actionCollection()); KStandardAction::quit(rApp, SLOT(queryQuit()), actionCollection()); a = KStandardAction::fullScreen(this, SLOT(viewFullScreen(bool)), this, actionCollection()); @@ -235,6 +238,26 @@ void WebWindow::setupActions() a->setMenu(uaMenu); connect(uaMenu, SIGNAL(aboutToShow()), this, SLOT(populateUserAgentMenu())); + // Editable Page + a = new KAction(KIcon("document-edit"), i18n("Set Editable"), this); + a->setCheckable(true); + actionCollection()->addAction(QL1S("set_editable"), a); + connect(a, SIGNAL(triggered(bool)), this, SLOT(setEditable(bool))); + + // Adblock + a = new KAction(KIcon("preferences-web-browser-adblock"), i18n("Ad Block"), this); + actionCollection()->addAction(QL1S("adblock"), a); + connect(a, SIGNAL(triggered(bool)), AdBlockManager::self(), 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())); + + // Sync action + a = new KAction(KIcon("tools-wizard"), i18n("Sync"), this); // FIXME sync icon!! + actionCollection()->addAction(QL1S("sync"), a); + connect(a, SIGNAL(triggered(bool)), SyncManager::self(), SLOT(showSettings())); // <Menu name="rekonqMenu" noMerge="1"> // <Action name="new_tab" /> --- @@ -252,15 +275,15 @@ void WebWindow::setupActions() // <text>&Tools</text> // <Action name="clear_private_data" /> + // <Separator/> -// <Action name="webapp_shortcut" /> ------- +// <Action name="webapp_shortcut" /> + // <Action name="web_inspector" /> --------- // <Action name="page_source" /> + // <Action name="net_analyzer" /> xxxxxxxxxxx -// <Action name="set_editable" /> ------- +// <Action name="set_editable" /> + // <Separator/> -// <Action name="useragent" /> -// <Action name="sync" /> -// <Action name="adblock" /> +// <Action name="useragent" /> + +// <Action name="sync" /> + +// <Action name="adblock" /> + // </Menu> // // <Separator/> @@ -759,3 +782,9 @@ void WebWindow::populateUserAgentMenu() UserAgentManager::self()->populateUAMenuForTabUrl(uaMenu, this); } + + +void WebWindow::setEditable(bool on) +{ + page()->setContentEditable(on); +} diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h index ed8a7f2b..ef8a502b 100644 --- a/src/webwindow/webwindow.h +++ b/src/webwindow/webwindow.h @@ -108,10 +108,12 @@ private Q_SLOTS: void fileOpen(); void fileSaveAs(); + // Tools Menu slots void viewPageSource(); void viewFullScreen(bool enable); void populateUserAgentMenu(); + void setEditable(bool); Q_SIGNALS: void titleChanged(QString); |