Port KMess to KF6 and Qt6

This commit is contained in:
Mario Fetka
2026-07-06 07:16:41 +02:00
parent 91626a9c87
commit f2fbc7463b
195 changed files with 3260 additions and 2887 deletions
+39 -43
View File
@@ -35,20 +35,21 @@
#include <QStringList>
#include <QTimer>
#include <QAction>
#include <KActionMenu>
#include <KConfig>
#include <KGlobal>
#include <KHelpMenu>
#include <KLocale>
#include <KMenu>
#include <KMenuBar>
#include <QIcon>
#include <KLocalizedString>
#include <QMenu>
#include <QMenuBar>
#include <KMessageBox>
#include <KSelectAction>
#include <KStandardGuiItem>
#include <KStandardAction>
#include <KStatusBar>
#include <QStatusBar>
#include <KToggleAction>
#include <KToolInvocation>
#include <KUrl>
#include <QUrl>
@@ -154,17 +155,17 @@ void KMessInterface::showTransferWindow()
// Create the menus
void KMessInterface::createMenus()
{
KAction *close, *quit;
KAction *newAccount;
QAction *close, *quit;
QAction *newAccount;
QStringList states;
QStringList viewModes, listPictureSizes;
// Create the actions for "Connect" menu
status_ = MsnStatus::getStatusMenu();
connectActionMenu_ = new KActionMenu ( KIcon("network-connect"), i18n("&Connect"), this );
disconnect_ = new KAction ( KIcon("network-disconnect"), i18n("&Disconnect"), this );
showProfile_ = new KAction ( KIcon("preferences-desktop-user"), i18n("Show My &Profile"), this );
connectActionMenu_ = new KActionMenu ( QIcon::fromTheme( "network-connect" ), i18n("&Connect"), this );
disconnect_ = new QAction ( QIcon::fromTheme( "network-disconnect" ), i18n("&Disconnect"), this );
showProfile_ = new QAction ( QIcon::fromTheme( "preferences-desktop-user" ), i18n("Show My &Profile"), this );
close = KStandardAction::close( this, SLOT( menuClose() ), actionCollection_ );
quit = KStandardAction::quit ( this, SLOT( menuQuit() ), actionCollection_ );
@@ -172,24 +173,24 @@ void KMessInterface::createMenus()
showAllowedAction_ = new KToggleAction( i18n("Show &Allowed Contacts"), this );
showOfflineAction_ = new KToggleAction( i18n("Show &Offline Contacts"), this );
showRemovedAction_ = new KToggleAction( i18n("Show &Removed Contacts"), this );
showHistoryBoxAction_ = new KToggleAction( KIcon("chronometer"), i18n("Show &History Box"), this );
showSearchAction_ = new KToggleAction( KIcon("edit-find-user"), i18n("&Show Search Bar"), this );
showHistoryBoxAction_ = new KToggleAction( QIcon::fromTheme( "chronometer" ), i18n("Show &History Box"), this );
showSearchAction_ = new KToggleAction( QIcon::fromTheme( "edit-find-user" ), i18n("&Show Search Bar"), this );
showEmptyAction_ = new KToggleAction( i18n("Show &Empty Groups"), this );
listPictureSize_ = new KSelectAction( KIcon("view-list-tree"), i18n("&Display Pictures Size"), this );
viewMode_ = new KSelectAction( KIcon("view-list-tree"), i18n("&Sort Contacts by"), this );
showTransferAction_ = new KAction ( KIcon("document-open-remote"), i18n("Show &Transfer Window..."), this );
listPictureSize_ = new KSelectAction( QIcon::fromTheme( "view-list-tree" ), i18n("&Display Pictures Size"), this );
viewMode_ = new KSelectAction( QIcon::fromTheme( "view-list-tree" ), i18n("&Sort Contacts by"), this );
showTransferAction_ = new QAction ( QIcon::fromTheme( "document-open-remote" ), i18n("Show &Transfer Window..."), this );
showStatusBar_ = KStandardAction::showStatusbar( this, SLOT( showStatusBar() ), this );
showMenuBar_ = KStandardAction::showMenubar ( this, SLOT( showMenuBar() ), this );
// Create the actions for "Actions" menu
newContact_ = new KAction( KIcon("list-add-user"), i18n("New &Contact..."), this );
newGroup_ = new KAction( KIcon("user-group-new"), i18n("New &Group..."), this );
exportList_ = new KAction( KIcon("document-export"),i18n("&Export Contact List..."), this );
showHistory_ = new KAction( KIcon("chronometer"), i18n("Show Chat &History..."), this );
newAccount = new KAction( KIcon("user-identity"), i18n("New &Account..."), this );
showSettingsAction_ = new KAction( KIcon("configure"), i18n("Configure Account..."), this );
globalSettings_ = new KAction( KIcon("kmess"), i18n("Configure &KMess..."), this );
contextMenuAction_ = new KAction( KIcon("preferences-contact-list"), i18n("Show Selection &Menu"), this );
newContact_ = new QAction( QIcon::fromTheme( "list-add-user" ), i18n("New &Contact..."), this );
newGroup_ = new QAction( QIcon::fromTheme( "user-group-new" ), i18n("New &Group..."), this );
exportList_ = new QAction( QIcon::fromTheme( "document-export" ),i18n("&Export Contact List..."), this );
showHistory_ = new QAction( QIcon::fromTheme( "chronometer" ), i18n("Show Chat &History..."), this );
newAccount = new QAction( QIcon::fromTheme( "user-identity" ), i18n("New &Account..."), this );
showSettingsAction_ = new QAction( QIcon::fromTheme( "configure" ), i18n("Configure Account..."), this );
globalSettings_ = new QAction( QIcon::fromTheme( "kmess" ), i18n("Configure &KMess..."), this );
contextMenuAction_ = new QAction( QIcon::fromTheme( "preferences-contact-list" ), i18n("Show Selection &Menu"), this );
// Populate PictureSize select
listPictureSizes << i18n( "Do Not Display" )
@@ -291,7 +292,7 @@ void KMessInterface::createMenus()
#ifdef KMESS_NETWORK_WINDOW
showNetworkAction_ = new KAction( KIcon("network-workgroup"), i18n("Show &Network Window..."), this );
showNetworkAction_ = new QAction( QIcon::fromTheme( "network-workgroup" ), i18n("Show &Network Window..."), this );
connect( showNetworkAction_, SIGNAL( triggered(bool) ),
this, SLOT ( showNetworkWindow() ) );
@@ -322,12 +323,12 @@ void KMessInterface::enableMenus(bool connected)
{
if ( connected )
{
disconnect_->setIcon( KIcon("network-connect") );
disconnect_->setIcon( QIcon::fromTheme( "network-connect" ) );
stateChanged("connected");
}
else
{
disconnect_->setIcon( KIcon("network-disconnect") );
disconnect_->setIcon( QIcon::fromTheme( "network-disconnect" ) );
stateChanged("disconnected");
}
}
@@ -389,12 +390,8 @@ bool KMessInterface::initialize()
setupGUI( ( Keys | Create | Save ), "kmessinterfaceui.rc" );
// Autosave all GUI settings
#if KDE_IS_VERSION(4,0,70)
setAutoSaveSettings( KMessConfig::instance()->getGlobalConfig( "ContactListWindow" ),
true /* save WindowSize */ );
#else
setAutoSaveSettings( "ContactListWindow", true /* save WindowSize */ );
#endif
// Autosave all GUI settings
setAutoSaveSettings( "KMessInterface", true /* save WindowSize */ );
@@ -473,7 +470,7 @@ void KMessInterface::menuQuit()
#endif
// Tell the application manager we want to quit
KMessApplication *app = static_cast<KMessApplication *>(kapp);
KMessApplication *app = static_cast<KMessApplication *>(QApplication::instance());
app->setQuitSelected(true);
close(); // Close this window, initiates quit
@@ -484,7 +481,7 @@ void KMessInterface::menuQuit()
// Reject quitting unless the quit menu was pressed Called automatically by KMainWindow::closeEvent
bool KMessInterface::queryExit()
{
KMessApplication *kmessApp = static_cast<KMessApplication *>(kapp);
KMessApplication *kmessApp = static_cast<KMessApplication *>(QApplication::instance());
// With KDE 4 this function is also called when another KMainWindow (like the network window) closes.
// Reject an attempt to quit if the user didn't select quit manually, or is logging out from KDE.
@@ -516,11 +513,11 @@ bool KMessInterface::queryExit()
// Tell the user that KMess hides in the systray Called automatically by KMainWindow::closeEvent
bool KMessInterface::queryClose()
{
KMessApplication *kmessApp = static_cast<KMessApplication *>(kapp);
KMessApplication *kmessApp = static_cast<KMessApplication *>(QApplication::instance());
// Only allow KMess to quit if:
// - the "quit" option was used from the menu
// - the session manager wants to quit (we're called from KApplication::commitData())
// - the session manager wants to quit
if( kmessApp->quitSelected() ||
kmessApp->sessionSaving() )
{
@@ -575,7 +572,6 @@ void KMessInterface::readProperties( const KConfigGroup &config )
// Resize the window to decent dimensions if there's no saved state.
resize( 300, 500 );
restoreWindowSize( group );
// Pull in the window size and position
QSize windowsize = group.readEntry( "Size", QSize() );
@@ -671,18 +667,18 @@ void KMessInterface::showMenuBar()
// Ask the user if he/she really wants to hide the menubar, to avoid mistakes
// TODO: If the user disables the shortcut for the menu action, no shortcuts will be shown
int res = KMessageBox::questionYesNo( this,
int res = KMessageBox::questionTwoActions( this,
i18nc( "Question dialog box message",
"<html>Are you sure you want to hide the menu bar? "
"You will be able to show it again by using this "
"keyboard shortcut: <b>%1</b></html>",
showMenuBar_->shortcut().primary().toString( QKeySequence::NativeText ) ),
showMenuBar_->shortcut().toString( QKeySequence::NativeText ) ),
i18nc( "Dialog box caption: hiding the menu bar", "Hiding the Menu" ),
KStandardGuiItem::yes(),
KStandardGuiItem::no(),
KGuiItem( i18n( "Yes" ) ),
KGuiItem( i18n( "No" ) ),
"hideMenuBarQuestion" );
if( res == KMessageBox::Yes )
if( res == KMessageBox::PrimaryAction )
{
menuBar()->setVisible( showMenuBar_->isChecked() );
}
@@ -812,7 +808,7 @@ void KMessInterface::updateOnlineTimer()
onlineTime_ ++;
timeText.sprintf( "%02i:%02i", onlineTime_ / 60, onlineTime_ % 60 );
timeText = QString::asprintf( "%02i:%02i", onlineTime_ / 60, onlineTime_ % 60 );
statusTimer_->setText( timeText );
}