PasteURL sent to clipboard
This commit is contained in:
parent
a2c930a714
commit
186c065b4c
@ -15,6 +15,8 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
namespace CalamaresUtils
|
namespace CalamaresUtils
|
||||||
{
|
{
|
||||||
@ -22,7 +24,8 @@ namespace CalamaresUtils
|
|||||||
QString
|
QString
|
||||||
sendLogToPastebin( QObject* parent, const QString& ficheHost, quint16 fichePort )
|
sendLogToPastebin( QObject* parent, const QString& ficheHost, quint16 fichePort )
|
||||||
{
|
{
|
||||||
QString pasteUrlFmt = parent->tr( "Install log posted to:\n%1" );
|
QString pasteUrlFmt = parent->tr( "Install log posted to\n\n%1\n\nLink copied to clipboard" );
|
||||||
|
|
||||||
QFile pasteSourceFile( Logger::logFile() );
|
QFile pasteSourceFile( Logger::logFile() );
|
||||||
if ( !pasteSourceFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
if ( !pasteSourceFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||||
{
|
{
|
||||||
@ -78,6 +81,14 @@ sendLogToPastebin( QObject* parent, const QString& ficheHost, quint16 fichePort
|
|||||||
QRegularExpression pasteUrlRegex( "^http[s]?://" + ficheHost );
|
QRegularExpression pasteUrlRegex( "^http[s]?://" + ficheHost );
|
||||||
QString pasteUrlMsg = QString( pasteUrlFmt ).arg( pasteUrlStr );
|
QString pasteUrlMsg = QString( pasteUrlFmt ).arg( pasteUrlStr );
|
||||||
|
|
||||||
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
clipboard->setText(pasteUrlStr, QClipboard::Clipboard);
|
||||||
|
|
||||||
|
if (clipboard->supportsSelection())
|
||||||
|
{
|
||||||
|
clipboard->setText(pasteUrlStr, QClipboard::Selection);
|
||||||
|
}
|
||||||
|
|
||||||
if ( nBytesRead < 8 || !pasteUrl.isValid() || !pasteUrlRegex.match( pasteUrlStr ).hasMatch() )
|
if ( nBytesRead < 8 || !pasteUrl.isValid() || !pasteUrlRegex.match( pasteUrlStr ).hasMatch() )
|
||||||
{
|
{
|
||||||
cError() << "No data from paste server";
|
cError() << "No data from paste server";
|
||||||
|
Loading…
Reference in New Issue
Block a user