forked from qt-creator/qt-creator
CodePaster: Clean up configuration checks, part II
Point user to settings if something goes wrong.
This commit is contained in:
@@ -71,17 +71,17 @@ unsigned CodePasterProtocol::capabilities() const
|
|||||||
return ListCapability|PostCommentCapability|PostDescriptionCapability;
|
return ListCapability|PostCommentCapability|PostDescriptionCapability;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CodePasterProtocol::isValidHostName(const QString& hostName)
|
bool CodePasterProtocol::checkConfiguration(QString *errorMessage) const
|
||||||
{
|
{
|
||||||
if (hostName.isEmpty()) {
|
if (m_page->hostName().isEmpty()) {
|
||||||
Core::ICore::instance()->messageManager()->printToOutputPane(
|
if (errorMessage) {
|
||||||
|
*errorMessage =
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
tr("No Server defined in the CodePaster preferences."),
|
tr("No Server defined in the CodePaster preferences.");
|
||||||
#else
|
#else
|
||||||
tr("No Server defined in the CodePaster options."),
|
tr("No Server defined in the CodePaster options.");
|
||||||
#endif
|
#endif
|
||||||
true /*error*/);
|
}
|
||||||
Core::ICore::instance()->messageManager()->showOutputPane();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -92,8 +92,6 @@ void CodePasterProtocol::fetch(const QString &id)
|
|||||||
QTC_ASSERT(!m_fetchReply, return; )
|
QTC_ASSERT(!m_fetchReply, return; )
|
||||||
|
|
||||||
QString hostName = m_page->hostName();
|
QString hostName = m_page->hostName();
|
||||||
if (!isValidHostName(hostName))
|
|
||||||
return;
|
|
||||||
QString link = "http://";
|
QString link = "http://";
|
||||||
link.append(hostName);
|
link.append(hostName);
|
||||||
link.append("/?format=raw&id=");
|
link.append("/?format=raw&id=");
|
||||||
@@ -108,8 +106,6 @@ void CodePasterProtocol::list()
|
|||||||
QTC_ASSERT(!m_listReply, return; )
|
QTC_ASSERT(!m_listReply, return; )
|
||||||
|
|
||||||
QString hostName = m_page->hostName();
|
QString hostName = m_page->hostName();
|
||||||
if (!isValidHostName(hostName))
|
|
||||||
return;
|
|
||||||
QString link = QLatin1String("http://");
|
QString link = QLatin1String("http://");
|
||||||
link += hostName;
|
link += hostName;
|
||||||
link += QLatin1String("/?command=browse&format=raw");
|
link += QLatin1String("/?command=browse&format=raw");
|
||||||
@@ -125,8 +121,6 @@ void CodePasterProtocol::paste(const QString &text,
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(!m_pasteReply, return; )
|
QTC_ASSERT(!m_pasteReply, return; )
|
||||||
const QString hostName = m_page->hostName();
|
const QString hostName = m_page->hostName();
|
||||||
if (!isValidHostName(hostName))
|
|
||||||
return;
|
|
||||||
|
|
||||||
QByteArray data = "command=processcreate&submit=submit&highlight_type=0&description=";
|
QByteArray data = "command=processcreate&submit=submit&highlight_type=0&description=";
|
||||||
data += QUrl::toPercentEncoding(description);
|
data += QUrl::toPercentEncoding(description);
|
||||||
@@ -165,7 +159,7 @@ bool CodePasterProtocol::hasSettings() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IOptionsPage *CodePasterProtocol::settingsPage()
|
Core::IOptionsPage *CodePasterProtocol::settingsPage() const
|
||||||
{
|
{
|
||||||
return m_page;
|
return m_page;
|
||||||
}
|
}
|
||||||
|
@@ -51,8 +51,9 @@ public:
|
|||||||
|
|
||||||
virtual unsigned capabilities() const;
|
virtual unsigned capabilities() const;
|
||||||
bool hasSettings() const;
|
bool hasSettings() const;
|
||||||
Core::IOptionsPage *settingsPage();
|
Core::IOptionsPage *settingsPage() const;
|
||||||
|
|
||||||
|
virtual bool checkConfiguration(QString *errorMessage = 0) const;
|
||||||
void fetch(const QString &id);
|
void fetch(const QString &id);
|
||||||
void list();
|
void list();
|
||||||
void paste(const QString &text,
|
void paste(const QString &text,
|
||||||
@@ -66,7 +67,6 @@ public slots:
|
|||||||
void pasteFinished();
|
void pasteFinished();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isValidHostName(const QString& hostName);
|
|
||||||
CodePasterSettingsPage *m_page;
|
CodePasterSettingsPage *m_page;
|
||||||
QNetworkReply *m_pasteReply;
|
QNetworkReply *m_pasteReply;
|
||||||
QNetworkReply *m_fetchReply;
|
QNetworkReply *m_fetchReply;
|
||||||
|
Reference in New Issue
Block a user