forked from qt-creator/qt-creator
Added "Open URL" action.
It was implemented in CodepasterPlugin because it provides facility to fetch files from network into editor with proper error reporting. Change-Id: I1ea7f1799dfa3ca8423a06a64b43b419f23046eb Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
f17ad97997
commit
338524baab
@@ -42,6 +42,7 @@
|
||||
#include "pasteselectdialog.h"
|
||||
#include "settingspage.h"
|
||||
#include "settings.h"
|
||||
#include "urlopenprotocol.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -66,6 +67,8 @@
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
#include <QMainWindow>
|
||||
#include <QInputDialog>
|
||||
#include <QUrl>
|
||||
|
||||
using namespace Core;
|
||||
using namespace TextEditor;
|
||||
@@ -152,6 +155,10 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
m_protocols.append(protos[i]);
|
||||
}
|
||||
|
||||
m_urlOpen = new UrlOpenProtocol(networkAccessMgrProxy);
|
||||
connect(m_urlOpen, SIGNAL(fetchDone(QString,QString,bool)),
|
||||
this, SLOT(finishFetch(QString,QString,bool)));
|
||||
|
||||
//register actions
|
||||
Core::ActionManager *actionManager = ICore::actionManager();
|
||||
|
||||
@@ -182,6 +189,11 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
connect(m_fetchAction, SIGNAL(triggered()), this, SLOT(fetch()));
|
||||
cpContainer->addAction(command);
|
||||
|
||||
m_fetchUrlAction = new QAction(tr("Fetch from URL..."), this);
|
||||
command = actionManager->registerAction(m_fetchUrlAction, "CodePaster.FetchUrl", globalcontext);
|
||||
connect(m_fetchUrlAction, SIGNAL(triggered()), this, SLOT(fetchUrl()));
|
||||
cpContainer->addAction(command);
|
||||
|
||||
addAutoReleasedObject(new CodePasterService);
|
||||
|
||||
return true;
|
||||
@@ -268,6 +280,18 @@ void CodepasterPlugin::post(QString data, const QString &mimeType)
|
||||
}
|
||||
}
|
||||
|
||||
void CodepasterPlugin::fetchUrl()
|
||||
{
|
||||
QUrl url;
|
||||
do {
|
||||
bool ok = true;
|
||||
url = QUrl(QInputDialog::getText(0, tr("Fetch from URL"), tr("Enter URL:"), QLineEdit::Normal, QString(), &ok));
|
||||
if (!ok)
|
||||
return;
|
||||
} while (!url.isValid());
|
||||
m_urlOpen->fetch(url.toString());
|
||||
}
|
||||
|
||||
void CodepasterPlugin::fetch()
|
||||
{
|
||||
PasteSelectDialog dialog(m_protocols, ICore::mainWindow());
|
||||
|
||||
Reference in New Issue
Block a user