Commit 646fc6f6 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

CPaster: Make Pastebin.Com default

Change order of protocols and default accordingly.
parent 28c3941c
......@@ -43,15 +43,17 @@
#include <QtCore/QDebug>
#include <QtCore/QVariant>
using namespace CodePaster;
static const char settingsGroupC[] = "CodePasterSettings";
static const char serverKeyC[] = "Server";
namespace CodePaster {
CodePasterSettingsPage::CodePasterSettingsPage()
{
m_settings = Core::ICore::instance()->settings();
if (m_settings) {
m_settings->beginGroup("CodePasterSettings");
m_host = m_settings->value("Server", "").toString();
m_settings->endGroup();
const QString keyRoot = QLatin1String(settingsGroupC) + QLatin1Char('/');
m_host = m_settings->value(keyRoot + QLatin1String(serverKeyC), QString()).toString();
}
}
......@@ -109,8 +111,8 @@ void CodePasterSettingsPage::apply()
if (!m_settings)
return;
m_settings->beginGroup("CodePasterSettings");
m_settings->setValue("Server", m_host);
m_settings->beginGroup(QLatin1String(settingsGroupC));
m_settings->setValue(QLatin1String(serverKeyC), m_host);
m_settings->endGroup();
}
......@@ -123,3 +125,4 @@ QString CodePasterSettingsPage::hostName() const
{
return m_host;
}
} // namespace CodePaster
......@@ -92,11 +92,12 @@ bool CodepasterPlugin::initialize(const QStringList &arguments, QString *error_m
// Create the protocols and append them to the Settings
const QSharedPointer<NetworkAccessManagerProxy> networkAccessMgrProxy(new NetworkAccessManagerProxy);
Protocol *protos[] = { new CodePasterProtocol(networkAccessMgrProxy),
new PasteBinDotComProtocol(networkAccessMgrProxy),
Protocol *protos[] = { new PasteBinDotComProtocol(networkAccessMgrProxy),
new PasteBinDotCaProtocol(networkAccessMgrProxy),
0};
for(int i=0; protos[i] != 0; ++i) {
new CodePasterProtocol(networkAccessMgrProxy)
};
const int count = sizeof(protos) / sizeof(Protocol *);
for(int i = 0; i < count; ++i) {
connect(protos[i], SIGNAL(pasteDone(QString)), this, SLOT(finishPost(QString)));
connect(protos[i], SIGNAL(fetchDone(QString,QString,bool)),
this, SLOT(finishFetch(QString,QString,bool)));
......
......@@ -59,6 +59,11 @@ PasteBinDotComProtocol::PasteBinDotComProtocol(const NetworkAccessManagerProxyPt
{
}
QString PasteBinDotComProtocol::protocolName()
{
return QLatin1String("Pastebin.Com");
}
unsigned PasteBinDotComProtocol::capabilities() const
{
return ListCapability;
......
......@@ -41,7 +41,8 @@ class PasteBinDotComProtocol : public NetworkProtocol
public:
explicit PasteBinDotComProtocol(const NetworkAccessManagerProxyPtr &nw);
QString name() const { return QLatin1String("Pastebin.Com"); }
static QString protocolName();
QString name() const { return protocolName(); }
virtual unsigned capabilities() const;
bool hasSettings() const { return true; }
......
......@@ -28,6 +28,7 @@
**************************************************************************/
#include "settings.h"
#include "pastebindotcomprotocol.h"
#include <QtCore/QVariant>
#include <QtCore/QSettings>
......@@ -37,7 +38,6 @@ static const char userNameKeyC[] = "UserName";
static const char defaultProtocolKeyC[] = "DefaultProtocol";
static const char copyToClipboardKeyC[] = "CopyToClipboard";
static const char displayOutputKeyC[] = "DisplayOutput";
static const char defaultProtocolC[] = "CodePaster";
namespace CodePaster {
......@@ -70,7 +70,7 @@ void Settings::fromSettings(const QSettings *settings)
const QString defaultUser = qgetenv("USER");
#endif
username = settings->value(rootKey + QLatin1String(userNameKeyC), defaultUser).toString();
protocol = settings->value(rootKey + QLatin1String(defaultProtocolKeyC), QLatin1String(defaultProtocolC)).toString();
protocol = settings->value(rootKey + QLatin1String(defaultProtocolKeyC), PasteBinDotComProtocol::protocolName()).toString();
copyToClipboard = settings->value(rootKey + QLatin1String(copyToClipboardKeyC), true).toBool();
displayOutput = settings->value(rootKey + QLatin1String(displayOutputKeyC), true).toBool();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment