diff --git a/browserappconfig.cpp b/browserappconfig.cpp index a97fed1..e068ceb 100644 --- a/browserappconfig.cpp +++ b/browserappconfig.cpp @@ -1,192 +1,195 @@ /* This file is part of KDevelop Copyright 2009 Andreas Pakulat Copyright 2009 Niko Sams This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "browserappconfig.h" #include #include #include #include #include #include #include #include "browserappjob.h" #include "executebrowserplugin.h" QIcon BrowserAppConfigPage::icon() const { return QIcon::fromTheme("system-run"); } void BrowserAppConfigPage::loadFromConfiguration(const KConfigGroup& cfg, KDevelop::IProject* project ) { Q_UNUSED(project); bool b = blockSignals( true ); server->setText( cfg.readEntry( ExecuteBrowserPlugin::serverEntry, "localhost" ) ); path->setText( cfg.readEntry( ExecuteBrowserPlugin::pathEntry, "" ) ); + port->setValue( cfg.readEntry( ExecuteBrowserPlugin::portEntry, 80 ) ); arguments->setText( cfg.readEntry( ExecuteBrowserPlugin::argumentsEntry, "" ) ); browser->setText( cfg.readEntry( ExecuteBrowserPlugin::browserEntry, "" ) ); blockSignals( b ); } BrowserAppConfigPage::BrowserAppConfigPage( QWidget* parent ) : LaunchConfigurationPage( parent ) { setupUi(this); selectBrowserButton->setIcon(QIcon::fromTheme("system-run")); //connect signals to changed signal connect(server, &KLineEdit::textEdited, this, &BrowserAppConfigPage::changed); - connect(path, &KLineEdit::textEdited, this, &BrowserAppConfigPage::changed); + connect(path, &KLineEdit::textEdited, this, &BrowserAppConfigPage::changed); + connect(port, QOverload::of(&QSpinBox::valueChanged), this, &BrowserAppConfigPage::changed); connect(arguments, &KLineEdit::textEdited, this, &BrowserAppConfigPage::changed); connect(browser, &KLineEdit::textEdited, this, &BrowserAppConfigPage::changed); connect(selectBrowserButton, &QPushButton::pressed, this, &BrowserAppConfigPage::selectDialog); } void BrowserAppConfigPage::saveToConfiguration( KConfigGroup cfg, KDevelop::IProject* project ) const { Q_UNUSED( project ); cfg.writeEntry( ExecuteBrowserPlugin::serverEntry, server->text() ); cfg.writeEntry( ExecuteBrowserPlugin::pathEntry, path->text() ); + cfg.writeEntry( ExecuteBrowserPlugin::portEntry, port->value() ); cfg.writeEntry( ExecuteBrowserPlugin::argumentsEntry, arguments->text() ); cfg.writeEntry( ExecuteBrowserPlugin::browserEntry, browser->text() ); } QString BrowserAppConfigPage::title() const { return i18n("Configure Browser Application"); } void BrowserAppConfigPage::selectDialog() { KOpenWithDialog *dialog = new KOpenWithDialog(); dialog->hideNoCloseOnExit(); dialog->hideRunInTerminal(); if(dialog->exec()) { browser->setText(dialog->text().replace(QStringLiteral(" %u"), QStringLiteral(""), Qt::CaseSensitivity::CaseInsensitive)); dialog->deleteLater(); emit changed(); } } QList< KDevelop::LaunchConfigurationPageFactory* > BrowserAppLauncher::configPages() const { return QList(); } QString BrowserAppLauncher::description() const { return "Executes Browser Applications"; } QString BrowserAppLauncher::id() { return "browserAppLauncher"; } QString BrowserAppLauncher::name() const { return i18n("Browser Application"); } BrowserAppLauncher::BrowserAppLauncher() { } KJob* BrowserAppLauncher::start(const QString& launchMode, KDevelop::ILaunchConfiguration* cfg) { Q_ASSERT(cfg); if( !cfg ) { return nullptr; } if( launchMode == "execute" ) { return new BrowserAppJob( KDevelop::ICore::self()->runController(), cfg ); } qCWarning(KDEV_EXECUTEBROWSER) << "Unknown launch mode " << launchMode << "for config:" << cfg->name(); return nullptr; } QStringList BrowserAppLauncher::supportedModes() const { return QStringList() << "execute"; } KDevelop::LaunchConfigurationPage* BrowserAppPageFactory::createWidget(QWidget* parent) { return new BrowserAppConfigPage( parent ); } BrowserAppPageFactory::BrowserAppPageFactory() { } BrowserAppConfigType::BrowserAppConfigType() { factoryList.append( new BrowserAppPageFactory() ); } QString BrowserAppConfigType::name() const { return i18n("Browser Application"); } QList BrowserAppConfigType::configPages() const { return factoryList; } QString BrowserAppConfigType::id() const { return ExecuteBrowserPlugin::_browserAppConfigTypeId; } QIcon BrowserAppConfigType::icon() const { return QIcon::fromTheme("system-run"); } bool BrowserAppConfigType::canLaunch(const QUrl& /*file*/) const { return false; } bool BrowserAppConfigType::canLaunch(KDevelop::ProjectBaseItem* /*item*/) const { return false; } void BrowserAppConfigType::configureLaunchFromItem(KConfigGroup /*config*/, KDevelop::ProjectBaseItem* /*item*/) const { } void BrowserAppConfigType::configureLaunchFromCmdLineArguments(KConfigGroup /*config*/, const QStringList &/*args*/) const { } diff --git a/browserappconfig.ui b/browserappconfig.ui index 4d45b86..b4e5096 100644 --- a/browserappconfig.ui +++ b/browserappconfig.ui @@ -1,119 +1,136 @@ - + BrowserAppPage 0 0 - 512 - 180 + 621 + 254 URL Server: localhost 25 true - + Path: - + Enter the path - + - Arguments: + Ar&guments: arguments - + Enter arguments to give to the executable Enter arguments to give to the URL - + Browser: - + Leave empty to use system default - + 0 0 Select a browser + + + + Port: + + + + + + + 65535 + + + 80 + + + KLineEdit QLineEdit
klineedit.h
diff --git a/executebrowserplugin.cpp b/executebrowserplugin.cpp index 256f7ec..2850342 100644 --- a/executebrowserplugin.cpp +++ b/executebrowserplugin.cpp @@ -1,110 +1,112 @@ /* * This file is part of KDevelop * * Copyright 2007 Hamish Rodda * Copyright 2009 Niko Sams * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "executebrowserplugin.h" #include #include #include #include #include #include #include #include "browserappconfig.h" QString ExecuteBrowserPlugin::_browserAppConfigTypeId = "Browser Application"; QString ExecuteBrowserPlugin::serverEntry = "Server"; QString ExecuteBrowserPlugin::pathEntry = "Path"; +QString ExecuteBrowserPlugin::portEntry = "Port"; QString ExecuteBrowserPlugin::argumentsEntry = "Arguments"; QString ExecuteBrowserPlugin::browserEntry = "Browser"; using namespace KDevelop; //KPluginFactory stuff to load the plugin dynamically at runtime K_PLUGIN_FACTORY_WITH_JSON(KDevExecuteFactory, "kdevexecutebrowser.json", registerPlugin();) ExecuteBrowserPlugin::ExecuteBrowserPlugin(QObject *parent, const QVariantList&) : KDevelop::IPlugin("kdevexecutebrowser", parent) { BrowserAppConfigType* t = new BrowserAppConfigType(); t->addLauncher( new BrowserAppLauncher() ); qCDebug(KDEV_EXECUTEBROWSER) << "adding script launch config"; core()->runController()->addConfigurationType( t ); } ExecuteBrowserPlugin::~ExecuteBrowserPlugin() { } void ExecuteBrowserPlugin::unload() { } QUrl ExecuteBrowserPlugin::url( KDevelop::ILaunchConfiguration* cfg, QString& err_ ) const { QUrl url; if( !cfg ) { return url; } KConfigGroup grp = cfg->config(); QString host = grp.readEntry( ExecuteBrowserPlugin::serverEntry, "" ); if( host.isEmpty() ) { err_ = i18n("No valid server specified"); qCWarning(KDEV_EXECUTEBROWSER) << "Launch Configuration:" << cfg->name() << "no valid server specified"; return url; } url.setScheme("http"); url.setHost(host); auto path = grp.readEntry( ExecuteBrowserPlugin::pathEntry, "" ); if ( !path.startsWith("/") ) { path.prepend("/"); } url.setPath(path); + url.setPort(grp.readEntry( ExecuteBrowserPlugin::portEntry, 80 )); { QString q = grp.readEntry( ExecuteBrowserPlugin::argumentsEntry, "" ); if (!q.isEmpty()) { url.setQuery(q); } } return url; } QString ExecuteBrowserPlugin::browser( ILaunchConfiguration* cfg ) const { return cfg->config().readEntry( ExecuteBrowserPlugin::browserEntry, "" ); } QString ExecuteBrowserPlugin::browserAppConfigTypeId() const { return _browserAppConfigTypeId; } #include "executebrowserplugin.moc" diff --git a/executebrowserplugin.h b/executebrowserplugin.h index 020ad5e..2719224 100644 --- a/executebrowserplugin.h +++ b/executebrowserplugin.h @@ -1,57 +1,58 @@ /* * This file is part of KDevelop * * Copyright 2007 Hamish Rodda * Copyright 2009 Niko Sams * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef EXECUTEBROWSERPLUGIN_H #define EXECUTEBROWSERPLUGIN_H #include #include #include "iexecutebrowserplugin.h" class QUrl; class KJob; class ExecuteBrowserPlugin : public KDevelop::IPlugin, public IExecuteBrowserPlugin { Q_OBJECT Q_INTERFACES( IExecuteBrowserPlugin ) public: ExecuteBrowserPlugin(QObject *parent, const QVariantList & = QVariantList() ); ~ExecuteBrowserPlugin() override; static QString _browserAppConfigTypeId; static QString serverEntry; static QString pathEntry; + static QString portEntry; static QString argumentsEntry; static QString browserEntry; void unload() override; QUrl url( KDevelop::ILaunchConfiguration*, QString& err ) const override; QString browser(KDevelop::ILaunchConfiguration* ) const override; QString browserAppConfigTypeId() const override; }; #endif // EXECUTEBROWSERPLUGIN_H // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on