forked from qt-creator/qt-creator
CPaster: Use new message manager API
Only show the panel if an error occurs, or if the user opted to have the paste link shown to him. Task-number: QTCREATORBUG-24430 Change-Id: Ie474acbe2b4d3b6d3332111bdd7ae18b16bd8618 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -326,7 +326,10 @@ void CodePasterPluginPrivate::finishPost(const QString &link)
|
|||||||
{
|
{
|
||||||
if (m_settings.copyToClipboard)
|
if (m_settings.copyToClipboard)
|
||||||
QApplication::clipboard()->setText(link);
|
QApplication::clipboard()->setText(link);
|
||||||
MessageManager::write(link, m_settings.displayOutput ? MessageManager::ModeSwitch : MessageManager::Silent);
|
if (m_settings.displayOutput)
|
||||||
|
MessageManager::writeDisrupting(link);
|
||||||
|
else
|
||||||
|
MessageManager::writeSilently(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract the characters that can be used for a file name from a title
|
// Extract the characters that can be used for a file name from a title
|
||||||
@@ -369,11 +372,12 @@ void CodePasterPluginPrivate::finishFetch(const QString &titleDescription,
|
|||||||
{
|
{
|
||||||
// Failure?
|
// Failure?
|
||||||
if (error) {
|
if (error) {
|
||||||
MessageManager::write(content);
|
MessageManager::writeDisrupting(content);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (content.isEmpty()) {
|
if (content.isEmpty()) {
|
||||||
MessageManager::write(tr("Empty snippet received for \"%1\".").arg(titleDescription));
|
MessageManager::writeDisrupting(
|
||||||
|
tr("Empty snippet received for \"%1\".").arg(titleDescription));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If the mime type has a preferred suffix (cpp/h/patch...), use that for
|
// If the mime type has a preferred suffix (cpp/h/patch...), use that for
|
||||||
@@ -393,7 +397,7 @@ void CodePasterPluginPrivate::finishFetch(const QString &titleDescription,
|
|||||||
saver.setAutoRemove(false);
|
saver.setAutoRemove(false);
|
||||||
saver.write(byteContent);
|
saver.write(byteContent);
|
||||||
if (!saver.finalize()) {
|
if (!saver.finalize()) {
|
||||||
MessageManager::write(saver.errorString());
|
MessageManager::writeDisrupting(saver.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const QString fileName = saver.fileName();
|
const QString fileName = saver.fileName();
|
||||||
|
@@ -59,7 +59,7 @@ void DPasteDotComProtocol::fetchFinished(const QString &id, QNetworkReply * cons
|
|||||||
const QString location = QString::fromUtf8(reply->rawHeader("Location"));
|
const QString location = QString::fromUtf8(reply->rawHeader("Location"));
|
||||||
if (status == 301 || status == 308) {
|
if (status == 301 || status == 308) {
|
||||||
const QString m = QString("HTTP redirect (%1) to \"%2\"").arg(status).arg(location);
|
const QString m = QString("HTTP redirect (%1) to \"%2\"").arg(status).arg(location);
|
||||||
Core::MessageManager::write(m, Core::MessageManager::ModeSwitch);
|
Core::MessageManager::writeSilently(m);
|
||||||
}
|
}
|
||||||
QNetworkReply * const newRep = httpGet(location);
|
QNetworkReply * const newRep = httpGet(location);
|
||||||
connect(newRep, &QNetworkReply::finished, this, [this, id, newRep] {
|
connect(newRep, &QNetworkReply::finished, this, [this, id, newRep] {
|
||||||
@@ -150,7 +150,7 @@ bool DPasteDotComProtocol::checkConfiguration(QString *errorMessage)
|
|||||||
void DPasteDotComProtocol::reportError(const QString &message)
|
void DPasteDotComProtocol::reportError(const QString &message)
|
||||||
{
|
{
|
||||||
const QString fullMessage = tr("%1: %2").arg(protocolName(), message);
|
const QString fullMessage = tr("%1: %2").arg(protocolName(), message);
|
||||||
Core::MessageManager::write(fullMessage, Core::MessageManager::ModeSwitch);
|
Core::MessageManager::writeDisrupting(fullMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace CodePaster
|
} // namespace CodePaster
|
||||||
|
@@ -206,10 +206,10 @@ void FileShareProtocol::paste(
|
|||||||
saver.setResult(&writer);
|
saver.setResult(&writer);
|
||||||
}
|
}
|
||||||
if (!saver.finalize()) {
|
if (!saver.finalize()) {
|
||||||
Core::MessageManager::write(saver.errorString());
|
Core::MessageManager::writeDisrupting(saver.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::MessageManager::write(tr("Pasted: %1").arg(saver.fileName()));
|
Core::MessageManager::writeSilently(tr("Pasted: %1").arg(saver.fileName()));
|
||||||
}
|
}
|
||||||
} // namespace CodePaster
|
} // namespace CodePaster
|
||||||
|
Reference in New Issue
Block a user