Commit a4ec8102 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Show number of unseen nick mentions & query messages on launcher entry

BUG: 398047
FIXED-IN: 1.9.22040
parent fd0b52e6
Pipeline #139613 passed with stage
in 1 minute and 58 seconds
......@@ -7,7 +7,7 @@ set (RELEASE_SERVICE_VERSION_MICRO "70")
set (RELEASE_SERVICE_COMPACT_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}${RELEASE_SERVICE_VERSION_MINOR}${RELEASE_SERVICE_VERSION_MICRO}")
# Bump KONVERSATION_BASE_VERSION once new features are added
set(KONVERSATION_BASE_VERSION "1.8")
set(KONVERSATION_BASE_VERSION "1.9")
set(KONVERSATION_VERSION "${KONVERSATION_BASE_VERSION}.${RELEASE_SERVICE_COMPACT_VERSION}")
project(konversation VERSION ${KONVERSATION_VERSION})
......
......@@ -20,6 +20,7 @@ set(core_SRCS
scriptlauncher.cpp
konsolepanel.cpp
notificationhandler.cpp
launcherentryhandler.cpp
awaymanager.cpp
connectionmanager.cpp
connectionsettings.cpp
......@@ -87,6 +88,7 @@ set(config_SRCS
config/dcc_config.cpp
config/highlight_config.cpp
config/ignore_config.cpp
config/launcherentry_config.cpp
config/nicklistbehavior_config.cpp
config/osd_config.cpp
config/tabs_config.cpp
......@@ -109,6 +111,7 @@ ki18n_wrap_ui(config_SRCS
config/generalbehavior_configui.ui
config/highlight_configui.ui
config/ignore_configui.ui
config/launcherentry_config.ui
config/log_config.ui
config/nicklistbehavior_configui.ui
config/osd_configui.ui
......
......@@ -25,6 +25,7 @@
#include "channel.h"
#include "images.h"
#include "notificationhandler.h"
#include "launcherentryhandler.h"
#include "awaymanager.h"
#include "konversation_log.h"
#include "konversation_state.h"
......@@ -74,6 +75,7 @@ Application::Application(int &argc, char **argv)
m_sound = nullptr;
m_dccTransferManager = nullptr;
m_notificationHandler = nullptr;
m_launcherEntryHandler = nullptr;
m_urlModel = nullptr;
dbusObject = nullptr;
identDBus = nullptr;
......@@ -274,6 +276,7 @@ QT_WARNING_POP
}
m_notificationHandler = new Konversation::NotificationHandler(this);
m_launcherEntryHandler = new Konversation::LauncherEntryHandler(this);
connect(this, &Application::appearanceChanged, this, &Application::updateProxySettings);
}
......
......@@ -40,6 +40,7 @@ namespace Konversation
class IdentDBus;
class Sound;
class NotificationHandler;
class LauncherEntryHandler;
namespace DCC
{
......@@ -114,6 +115,7 @@ class Application : public QApplication
Images* images() const { return m_images; }
Konversation::NotificationHandler* notificationHandler() const { return m_notificationHandler; }
Konversation::LauncherEntryHandler* launcherEntryHandler() const { return m_launcherEntryHandler; }
// auto replacement for input or output lines
QPair<QString, int> doAutoreplace(const QString& text, bool output, int cursorPos = -1) const;
......@@ -197,6 +199,7 @@ class Application : public QApplication
bool m_restartScheduled;
Konversation::NotificationHandler* m_notificationHandler;
Konversation::LauncherEntryHandler* m_launcherEntryHandler;
KWallet::Wallet* m_wallet;
......
......@@ -14,6 +14,13 @@
<include>QApplication</include>
<kcfgfile name="konversationrc" />
<!--
See comment for ShowLauncherEntryCount
<signal name="showLauncherEntryCountChanged">
<argument type="Bool">ShowLauncherEntryCount</argument>
</signal>
-->
<group name="Appearance">
<entry key="ShowMenuBar" type="Bool">
<default>true</default>
......@@ -414,6 +421,60 @@
<whatsthis></whatsthis>
</entry>
</group>
<group name="LauncherEntry">
<!--
kconfigcompiler 5.91 cannot generate code with signals for ItemAccessors=true
So Preferences currently manually adds the entry for now.
<entry key="ShowLauncherEntryCount" type="Bool">
<default>true</default>
<label></label>
<whatsthis></whatsthis>
<emit signal="showLauncherEntryCountChanged"/>
</entry>
-->
<entry name="LauncherEntryCountMode" type="Enum">
<label></label>
<choices>
<choice name="CountEvents">
<label>All events</label>
</choice>
<choice name="CountChannelAndQueries">
<label>Channels and queries with events</label>
</choice>
<default>CountEvents</default>
</choices>
</entry>
<entry key="LauncherEntryCountUseNick" type="Bool">
<default>true</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="LauncherEntryCountUseHighlights" type="Bool">
<default>false</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="LauncherEntryCountUsePrivate" type="Bool">
<default>true</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="LauncherEntryCountUseMsgs" type="Bool">
<default>false</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="LauncherEntryCountUseSystem" type="Bool">
<default>false</default>
<label></label>
<whatsthis></whatsthis>
</entry>
<entry key="LauncherEntryCountUseChannelEvents" type="Bool">
<default>false</default>
<label></label>
<whatsthis></whatsthis>
</entry>
</group>
<group name="OSD">
<entry key="UseOSD" type="Bool">
<default>false</default>
......
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
*/
#include "launcherentry_config.h"
#include "preferences.h"
#include "osd.h"
#include "application.h"
#include "mainwindow.h"
#include "viewcontainer.h"
#include "launcherentryhandler.h"
LauncherEntry_Config::LauncherEntry_Config( QWidget* parent, const char* name)
: QWidget(parent)
{
setObjectName(QString::fromLatin1(name));
setupUi(this);
}
LauncherEntry_Config::~LauncherEntry_Config() = default;
void LauncherEntry_Config::loadSettings()
{
}
void LauncherEntry_Config::restorePageToDefaults()
{
}
void LauncherEntry_Config::saveSettings()
{
}
bool LauncherEntry_Config::hasChanged()
{
// follow the interface, no Non-KConfigXT settings here, so none have changed
return false;
}
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
*/
#ifndef LAUNCHERENTRY_CONFIG_H
#define LAUNCHERENTRY_CONFIG_H
#include "ui_launcherentry_config.h"
#include "settingspage.h"
class LauncherEntry_Config : public QWidget,
public KonviSettingsPage,
private Ui::LauncherEntry_Config
{
Q_OBJECT
public:
explicit LauncherEntry_Config(QWidget* parent = nullptr, const char* name = nullptr);
~LauncherEntry_Config() override;
void restorePageToDefaults() override;
void saveSettings() override;
void loadSettings() override;
bool hasChanged() override; // implement the interface, will not be used here, though
private:
Q_DISABLE_COPY(LauncherEntry_Config)
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>LauncherEntry_Config</class>
<widget class="QWidget" name="LauncherEntry_Config">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>447</width>
<height>525</height>
</rect>
</property>
<layout class="QVBoxLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="kcfg_ShowLauncherEntryCount">
<property name="text">
<string>&amp;Enable Display of Unseen Events Count On Launcher Entry</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="generalGroupBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>General</string>
</property>
<layout class="QFormLayout">
<item row="0" column="0">
<widget class="QLabel" name="modeLbl">
<property name="text">
<string>Count &amp;mode:</string>
</property>
<property name="buddy">
<cstring>kcfg_LauncherEntryCountMode</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="kcfg_LauncherEntryCountMode">
<item>
<property name="text">
<string>All events</string>
</property>
</item>
<item>
<property name="text">
<string>Channels and queries with events</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="countedEventsGroupBox">
<property name="title">
<string>Counted Events</string>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QVBoxLayout">
<item>
<widget class="QCheckBox" name="kcfg_LauncherEntryCountUseMsgs">
<property name="text">
<string>Message</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_LauncherEntryCountUsePrivate">
<property name="text">
<string>Private message</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_LauncherEntryCountUseNick">
<property name="text">
<string>Current nick used</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_LauncherEntryCountUseHighlights">
<property name="text">
<string>Highlight</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_LauncherEntryCountUseChannelEvents">
<property name="whatsThis">
<string>Channel events are mode changes or users joining/leaving a channel.</string>
</property>
<property name="text">
<string>Channel event</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_LauncherEntryCountUseSystem">
<property name="whatsThis">
<string>Application events occur in Konsole tabs, the DCC Status tab and other application tabs not used directly for chatting.</string>
</property>
<property name="text">
<string>Application event</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="spacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>kcfg_ShowLauncherEntryCount</sender>
<signal>toggled(bool)</signal>
<receiver>generalGroupBox</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>kcfg_ShowLauncherEntryCount</sender>
<signal>toggled(bool)</signal>
<receiver>countedEventsGroupBox</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
</ui>
......@@ -40,6 +40,17 @@ Preferences *Preferences::self()
Preferences::Preferences()
{
// kconfigcompiler 5.91 cannot generate code with signals for ItemAccessors=true
// manually add the item for now
setCurrentGroup(QStringLiteral("LauncherEntry"));
auto notifyFunction = static_cast<KConfigCompilerSignallingItem::NotifyFunction>(&Preferences::itemChanged);
auto* innerItemShowLauncherEntryCount = new KConfigSkeleton::ItemBool(currentGroup(), QStringLiteral("ShowLauncherEntryCount"), mShowLauncherEntryCount, true);
mShowLauncherEntryCountItem = new KConfigCompilerSignallingItem(innerItemShowLauncherEntryCount, this, notifyFunction, signalShowLauncherEntryCountChanged);
addItem(mShowLauncherEntryCountItem);
// end manual item addition
// create default identity
mIdentity=new Identity();
mIdentity->setName(i18n("Default Identity"));
......@@ -587,3 +598,40 @@ void Preferences::slotSetUseOSD(bool use)
}
void Preferences::setShowLauncherEntryCount(bool value)
{
if ((value != mShowLauncherEntryCount) && !isShowLauncherEntryCountImmutable()) {
mShowLauncherEntryCount = value;
mSettingsChanged |= signalShowLauncherEntryCountChanged;
}
}
bool Preferences::showLauncherEntryCount() const
{
return mShowLauncherEntryCount;
}
bool Preferences::isShowLauncherEntryCountImmutable() const
{
return isImmutable(QStringLiteral("ShowLauncherEntryCount"));
}
bool Preferences::usrSave()
{
if (!PreferencesBase::usrSave()) {
return false;
}
if (mSettingsChanged & signalShowLauncherEntryCountChanged) {
Q_EMIT showLauncherEntryCountChanged(mShowLauncherEntryCount);
}
mSettingsChanged = 0;
return true;
}
void Preferences::itemChanged(quint64 flags)
{
mSettingsChanged |= flags;
}
......@@ -131,8 +131,28 @@ class Preferences : public PreferencesBase
Q_SIGNALS:
void notifyListStarted(int serverGroupId);
void updateTrayIcon();
void showLauncherEntryCountChanged(bool showLauncherEntryCount);
public:
void setShowLauncherEntryCount(bool value);
bool showLauncherEntryCount() const;
bool isShowLauncherEntryCountImmutable() const;
enum {
signalShowLauncherEntryCountChanged = 0x1
};
private:
void itemChanged(quint64 flags);
protected:
bool usrSave() override;
private:
uint mSettingsChanged = 0;
KConfigCompilerSignallingItem *mShowLauncherEntryCountItem;
bool mShowLauncherEntryCount;
IdentityPtr mIdentity;
Konversation::ServerGroupHash mServerGroupHash;
QList<Ignore*> mIgnoreList;
......
......@@ -23,6 +23,7 @@
#include "ui_generalbehavior_configui.h"
#include "dcc_config.h"
#include "osd_config.h"
#include "launcherentry_config.h"
#include "theme_config.h"
#include "alias_config.h"
#include "ignore_config.h"
......@@ -174,6 +175,12 @@ KonviSettingsDialog::KonviSettingsDialog( QWidget *parent) :
//no modified connection needed - it's all kcfg widgets
m_pages.append(m_confOSDWdg);
//Notification/Launcher Entry
m_confLauncherEntryWdg = new LauncherEntry_Config(this, "Launcher Entry");
konviAddSubPage(notificationGroup, m_confLauncherEntryWdg, i18n("Launcher Entry"), QStringLiteral("application-menu"));
//no modified connection needed - it's all kcfg widgets
m_pages.append(m_confLauncherEntryWdg);
//Notification/Warning Dialogs
m_confWarningsWdg = new Warnings_Config( this, "Warnings" );
konviAddSubPage(notificationGroup, m_confWarningsWdg, i18n("Warning Dialogs"), QStringLiteral("dialog-warning"));
......
......@@ -24,6 +24,7 @@ class Autoreplace_Config;
class DCC_Config;
class Highlight_Config;
class OSD_Config;
class LauncherEntry_Config;
class Ignore_Config;
......@@ -56,6 +57,7 @@ class KonviSettingsDialog : public ConfigDialog
DCC_Config* m_confDCCWdg;
Highlight_Config* m_confHighlightWdg;
OSD_Config* m_confOSDWdg;
LauncherEntry_Config* m_confLauncherEntryWdg;
Ignore_Config* m_confIgnoreWdg;
bool m_modified;
......
/*
SPDX-License-Identifier: GPL-2.0-or-later
SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org>
*/
#include "launcherentryhandler.h"
#include "konversation_log.h"
#include "preferences.h"
#include <QApplication>
#include <QDBusConnection>
#include <QDBusConnectionInterface>
#include <QDBusServiceWatcher>
#include <QDBusPendingReply>
#include <QDBusInterface>
#include <QDBusMessage>
namespace Konversation
{
LauncherEntryHandler::LauncherEntryHandler(QObject* parent)
: QObject(parent)
, m_unityServiceWatcher(new QDBusServiceWatcher(this))
, m_enabled(Preferences::self()->showLauncherEntryCount())
{
m_unityServiceWatcher->setConnection(QDBusConnection::sessionBus());
m_unityServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration | QDBusServiceWatcher::WatchForRegistration);
m_unityServiceWatcher->addWatchedService(QStringLiteral("com.canonical.Unity"));
connect(m_unityServiceWatcher, &QDBusServiceWatcher::serviceRegistered,
this, &LauncherEntryHandler::handleServiceRegistered);
connect(m_unityServiceWatcher, &QDBusServiceWatcher::serviceUnregistered,
this, &LauncherEntryHandler::handleServiceUnregistered);
QDBusPendingCall listNamesCall = QDBusConnection::sessionBus().interface()->asyncCall(QStringLiteral("ListNames"));
auto callWatcher = new QDBusPendingCallWatcher(listNamesCall, this);
connect(callWatcher, &QDBusPendingCallWatcher::finished,
this, &LauncherEntryHandler::handleListNamesReply);
connect(Preferences::self(), &Preferences::showLauncherEntryCountChanged, this, &LauncherEntryHandler::setEnabled);
}
LauncherEntryHandler::~LauncherEntryHandler() = default;
void LauncherEntryHandler::setEnabled(bool enabled)
{
if (m_enabled == enabled) {
return;
}
m_enabled = enabled;
if (m_launcherEntryConnected) {
emitNumber(m_enabled ? m_number : 0);
}
}
void LauncherEntryHandler::handleListNamesReply(QDBusPendingCallWatcher* watcher)
{
QDBusPendingReply<QStringList> reply = *watcher;
watcher->deleteLater();
if (reply.isError()) {
qCWarning(KONVERSATION_LOG) << "D-Bus error on ListNames call:" << reply.error().message();
return;
}
const QStringList &services = reply.value();
m_launcherEntryConnected = services.contains(QStringLiteral("com.canonical.Unity"));
if (m_launcherEntryConnected && m_enabled) {