Port KMess to KF6 and Qt6
This commit is contained in:
@@ -28,16 +28,14 @@
|
||||
#include <QRegExp>
|
||||
#include <QSize>
|
||||
#include <QDateTime>
|
||||
#include <QTabWidget>
|
||||
#include <QTextCodec>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <kdeversion.h>
|
||||
#include <KFileDialog>
|
||||
#include <KLocale>
|
||||
#include <QFileDialog>
|
||||
#include <KLocalizedString>
|
||||
#include <KMessageBox>
|
||||
#include <KTabWidget>
|
||||
#include <KTextBrowser>
|
||||
#include <kdeversion.h>
|
||||
|
||||
|
||||
// Declare the instance
|
||||
@@ -99,7 +97,7 @@ void _kmessNetSent(QObject *connection, const QByteArray &message)
|
||||
|
||||
// Constructor
|
||||
NetworkWindow::NetworkWindow( QWidget *parent )
|
||||
: KDialog( parent, Qt::Dialog ) // Explicitly set the window type to disable the destructive close behavior
|
||||
: KMessDialog( parent, Qt::Dialog ) // Explicitly set the window type to disable the destructive close behavior
|
||||
, Ui::NetworkWindow()
|
||||
{
|
||||
// Set up the dialog and its buttons
|
||||
@@ -114,13 +112,12 @@ NetworkWindow::NetworkWindow( QWidget *parent )
|
||||
setupUi( mainWidget );
|
||||
setMainWidget( mainWidget );
|
||||
|
||||
// Set up the behavior of the Tab Widget
|
||||
#if KDE_IS_VERSION(4,1,0)
|
||||
connectionTabs_->setCloseButtonEnabled( true );
|
||||
#else
|
||||
connectionTabs_->setHoverCloseButton( true );
|
||||
#endif
|
||||
connect( connectionTabs_, SIGNAL( closeRequest(QWidget*) ), this, SLOT( closeTab(QWidget*) ) );
|
||||
// Set up the behavior of the tab widget
|
||||
connectionTabs_->setTabsClosable( true );
|
||||
connect( connectionTabs_, &QTabWidget::tabCloseRequested, this, [this]( int index )
|
||||
{
|
||||
closeTab( connectionTabs_->widget( index ) );
|
||||
} );
|
||||
connect( connectionTabs_, SIGNAL( currentChanged(int) ), this, SLOT( slotUpdateWidgets(int) ) );
|
||||
|
||||
// Set up the behavior of the Send button
|
||||
@@ -130,9 +127,9 @@ NetworkWindow::NetworkWindow( QWidget *parent )
|
||||
setButtonText( User1, i18n("S&ave Tab") );
|
||||
setButtonText( User2, i18n("C&lear Tab") );
|
||||
setButtonText( User3, i18n("C&lose All Tabs") );
|
||||
setButtonIcon( User1, KIcon("document-save") );
|
||||
setButtonIcon( User2, KIcon("edit-clear-list") );
|
||||
setButtonIcon( User3, KIcon("edit-clear") );
|
||||
setButtonIcon( User1, QIcon::fromTheme( "document-save" ) );
|
||||
setButtonIcon( User2, QIcon::fromTheme( "edit-clear-list" ) );
|
||||
setButtonIcon( User3, QIcon::fromTheme( "edit-clear" ) );
|
||||
connect( this, SIGNAL( user1Clicked() ), this, SLOT( saveCurrentTab() ) );
|
||||
connect( this, SIGNAL( user2Clicked() ), this, SLOT( clearCurrentTab() ) );
|
||||
connect( this, SIGNAL( user3Clicked() ), this, SLOT( closeAllTabs() ) );
|
||||
@@ -376,8 +373,8 @@ NetworkWindow::~NetworkWindow()
|
||||
}
|
||||
|
||||
// Default
|
||||
// return QString::null;
|
||||
return formatDescription( QString::null ); // always add time.
|
||||
// return QString();
|
||||
return formatDescription( QString() ); // always add time.
|
||||
}
|
||||
|
||||
|
||||
@@ -399,8 +396,8 @@ NetworkWindow::~NetworkWindow()
|
||||
}
|
||||
else
|
||||
{
|
||||
// return QString::null;
|
||||
return formatDescription( QString::null ); // always add time.
|
||||
// return QString();
|
||||
return formatDescription( QString() ); // always add time.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -858,7 +855,7 @@ NetworkWindow::~NetworkWindow()
|
||||
// Convert to HTML.
|
||||
// Remove last <br> because KTextBrowser::append() already adds it.
|
||||
logMessage = formatString( utf8Message );
|
||||
logMessage = logMessage.replace(QRegExp("<br>$"), QString::null);
|
||||
logMessage = logMessage.replace(QRegExp("<br>$"), QString());
|
||||
|
||||
if( entry->type == TYPE_FTP
|
||||
|| entry->type == TYPE_NS
|
||||
@@ -1091,7 +1088,7 @@ NetworkWindow::~NetworkWindow()
|
||||
connectionViews_.insert( connection, entry );
|
||||
|
||||
// Add new tab
|
||||
connectionTabs_->addTab( entry->logView, KIcon( "edit-select-all" ), connection->objectName() );
|
||||
connectionTabs_->addTab( entry->logView, QIcon::fromTheme( "edit-select-all" ), connection->objectName() );
|
||||
|
||||
// Enable the Close All Tabs button
|
||||
enableButton( User3, ( connectionViews_.count() > 1 ) );
|
||||
@@ -1141,7 +1138,7 @@ NetworkWindow::~NetworkWindow()
|
||||
return;
|
||||
}
|
||||
|
||||
KDialog::show();
|
||||
KMessDialog::show();
|
||||
}
|
||||
|
||||
|
||||
@@ -1155,7 +1152,7 @@ NetworkWindow::~NetworkWindow()
|
||||
QString path;
|
||||
QString name( connectionTabs_->tabText( connectionTabs_->currentIndex() ) );
|
||||
|
||||
path = KFileDialog::getSaveFileName( KUrl(), "*.html" );
|
||||
path = QFileDialog::getSaveFileName( this, QString(), QString(), "*.html" );
|
||||
if( path.isEmpty() )
|
||||
return;
|
||||
|
||||
@@ -1181,7 +1178,7 @@ NetworkWindow::~NetworkWindow()
|
||||
|
||||
if( failed || ! file.exists() )
|
||||
{
|
||||
KMessageBox::sorry( this, i18n("Could not save the Network Window log. Make sure you have permission to write in the folder where it is being saved.") );
|
||||
KMessageBox::error( this, i18n("Could not save the Network Window log. Make sure you have permission to write in the folder where it is being saved.") );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1353,16 +1350,16 @@ NetworkWindow::~NetworkWindow()
|
||||
else if( ! payload.endsWith( "\r\n" ) )
|
||||
{
|
||||
// Warn the developer that the payloads must end with a newline
|
||||
int result = KMessageBox::warningYesNo( this,
|
||||
int result = KMessageBox::warningTwoActions( this,
|
||||
i18n( "The payload you are trying to send does not end with the "
|
||||
"required newline ('\\r\\n')!<br />"
|
||||
"Do you want KMess to add it for you?" ),
|
||||
i18n( "Network Window" ),
|
||||
KStandardGuiItem::yes(),
|
||||
KStandardGuiItem::no(),
|
||||
KGuiItem( i18n( "Yes" ) ),
|
||||
KGuiItem( i18n( "No" ) ),
|
||||
"noPayloadWarning" );
|
||||
// Append the missing newline to the payload
|
||||
if( result == KMessageBox::Yes )
|
||||
if( result == KMessageBox::PrimaryAction )
|
||||
{
|
||||
payload.append( "\r\n" );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user