[libcalamaresui] Factor out the pastebin UI
- offer a convenience method for showing a popup and URL information and copying the URL to the clipboard - use that from ViewManager (on failure) and DebugWindow (on demand)
This commit is contained in:
parent
981e96ea7f
commit
779e5ecf8f
@ -216,7 +216,7 @@ DebugWindow::DebugWindow()
|
||||
|
||||
// Send Log button only if it would be useful
|
||||
m_ui->sendLogButton->setVisible( CalamaresUtils::Paste::isEnabled() );
|
||||
connect( m_ui->sendLogButton, &QPushButton::clicked, [this]() { CalamaresUtils::Paste::doLogUpload( this ); } );
|
||||
connect( m_ui->sendLogButton, &QPushButton::clicked, [this]() { CalamaresUtils::Paste::doLogUploadUI( this ); } );
|
||||
|
||||
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); setWindowTitle( tr( "Debug information" ) ); );
|
||||
}
|
||||
|
@ -190,26 +190,7 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
|
||||
connect( msgBox, &QMessageBox::buttonClicked, [msgBox]( QAbstractButton* button ) {
|
||||
if ( msgBox->buttonRole( button ) == QMessageBox::ButtonRole::YesRole )
|
||||
{
|
||||
QString pasteUrl = CalamaresUtils::Paste::doLogUpload( msgBox );
|
||||
QString pasteUrlMessage;
|
||||
if ( pasteUrl.isEmpty() )
|
||||
{
|
||||
pasteUrlMessage = tr( "The upload was unsuccessful. No web-paste was done." );
|
||||
}
|
||||
else
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
clipboard->setText( pasteUrl, QClipboard::Clipboard );
|
||||
|
||||
if ( clipboard->supportsSelection() )
|
||||
{
|
||||
clipboard->setText( pasteUrl, QClipboard::Selection );
|
||||
}
|
||||
QString pasteUrlFmt = tr( "Install log posted to\n\n%1\n\nLink copied to clipboard" );
|
||||
pasteUrlMessage = pasteUrlFmt.arg( pasteUrl );
|
||||
}
|
||||
|
||||
QMessageBox::critical( nullptr, tr( "Install Log Paste URL" ), pasteUrlMessage );
|
||||
CalamaresUtils::Paste::doLogUploadUI( msgBox );
|
||||
}
|
||||
QApplication::quit();
|
||||
} );
|
||||
|
@ -14,10 +14,14 @@
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Units.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QTcpSocket>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace CalamaresUtils::Units;
|
||||
|
||||
@ -127,6 +131,37 @@ CalamaresUtils::Paste::doLogUpload( QObject* parent )
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString
|
||||
CalamaresUtils::Paste::doLogUploadUI( QWidget* parent )
|
||||
{
|
||||
// These strings originated in the ViewManager class
|
||||
QString pasteUrl = CalamaresUtils::Paste::doLogUpload( parent );
|
||||
QString pasteUrlMessage;
|
||||
if ( pasteUrl.isEmpty() )
|
||||
{
|
||||
pasteUrlMessage = QCoreApplication::translate( "Calamares::ViewManager",
|
||||
"The upload was unsuccessful. No web-paste was done." );
|
||||
}
|
||||
else
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
clipboard->setText( pasteUrl, QClipboard::Clipboard );
|
||||
|
||||
if ( clipboard->supportsSelection() )
|
||||
{
|
||||
clipboard->setText( pasteUrl, QClipboard::Selection );
|
||||
}
|
||||
QString pasteUrlFmt = QCoreApplication::translate( "Calamares::ViewManager",
|
||||
"Install log posted to\n\n%1\n\nLink copied to clipboard" );
|
||||
pasteUrlMessage = pasteUrlFmt.arg( pasteUrl );
|
||||
}
|
||||
|
||||
QMessageBox::critical(
|
||||
nullptr, QCoreApplication::translate( "Calamares::ViewManager", "Install Log Paste URL" ), pasteUrlMessage );
|
||||
return pasteUrl;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
CalamaresUtils::Paste::isEnabled()
|
||||
{
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QString>
|
||||
|
||||
class QObject;
|
||||
class QWidget;
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
@ -24,6 +25,13 @@ namespace Paste
|
||||
*/
|
||||
QString doLogUpload( QObject* parent );
|
||||
|
||||
/** @brief Send the current log file to a pastebin
|
||||
*
|
||||
* As doLogUpload(), but also sets the clipboard and displays
|
||||
* a message saying it's been done.
|
||||
*/
|
||||
QString doLogUploadUI( QWidget* parent );
|
||||
|
||||
/** @brief Is paste enabled?
|
||||
*
|
||||
* Checks the branding instance if paste can be done.
|
||||
|
Loading…
Reference in New Issue
Block a user