generic: adjust to KNotification changes

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-25 08:17:25 +03:00
parent a6e35cf230
commit 41fc99edb1
21 changed files with 133 additions and 115 deletions

View file

@ -353,13 +353,12 @@ void Timer::setSeconds(int secs)
void Timer::slotCountDone() void Timer::slotCountDone()
{ {
if (m_showMessage){ if (m_showMessage){
QPixmap icon = KIconLoader::global()->loadIcon("chronometer", KIconLoader::Dialog); KNotification *notification = new KNotification();
notification->setEventID("kde/notification");
KNotification *notification = KNotification::event(KNotification::Notification); notification->setIcon("chronometer");
notification->setPixmap(icon);
notification->setTitle(i18n("Plasma Timer Applet")); notification->setTitle(i18n("Plasma Timer Applet"));
notification->setText(m_title->isVisible() ? m_title->text() + " - " + m_message : m_message); notification->setText(m_title->isVisible() ? m_title->text() + " - " + m_message : m_message);
notification->sendEvent(); notification->send();
} }
if (m_runCommand && !m_command.isEmpty()){ if (m_runCommand && !m_command.isEmpty()){

View file

@ -210,7 +210,6 @@ target_link_libraries(kget
KDE4::kdeui KDE4::kdeui
KDE4::kio KDE4::kio
KDE4::kcmutils KDE4::kcmutils
KDE4::knotifyconfig
KDE4::kpasswdstore KDE4::kpasswdstore
kgetcore kgetcore
) )
@ -228,7 +227,7 @@ install(
install( install(
FILES kget.notifyrc FILES kget.notifyrc
DESTINATION ${KDE4_DATA_INSTALL_DIR}/kget DESTINATION ${KDE4_CONFIG_INSTALL_DIR}/notifications
) )
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})

View file

@ -244,7 +244,7 @@ TransferHandler * KGet::addTransfer(KUrl srcUrl, QString destDir, QString sugges
TransferHandler *transfer = createTransfer(srcUrl, destUrl, groupName, start); TransferHandler *transfer = createTransfer(srcUrl, destUrl, groupName, start);
if (transfer) { if (transfer) {
KGet::showNotification(m_mainWindow, "added", KGet::showNotification(m_mainWindow, "kget/added",
i18n("<p>The following transfer has been added to the download list:</p><p style=\"font-size: small;\">%1</p>", transfer->source().pathOrUrl()), i18n("<p>The following transfer has been added to the download list:</p><p style=\"font-size: small;\">%1</p>", transfer->source().pathOrUrl()),
"kget", i18n("Download added")); "kget", i18n("Download added"));
} }
@ -343,7 +343,7 @@ const QList<TransferHandler *> KGet::addTransfer(KUrl::List srcUrls, QString des
message = i18n("<p>The following transfers have been added to the download list:</p>"); message = i18n("<p>The following transfers have been added to the download list:</p>");
} }
const QString content = QString("<p style=\"font-size: small;\">%1</p>").arg(urls); const QString content = QString("<p style=\"font-size: small;\">%1</p>").arg(urls);
KGet::showNotification(m_mainWindow, "added", message + content, "kget", i18n("Download added")); KGet::showNotification(m_mainWindow, "kget/added", message + content, "kget", i18n("Download added"));
} }
return transfers; return transfers;
@ -569,7 +569,7 @@ void KGet::save( QString filename, bool plain ) // krazy:exclude=passbyvalue
if ( !file.open( QIODevice::WriteOnly ) ) if ( !file.open( QIODevice::WriteOnly ) )
{ {
// kWarning() << "Unable to open output file when saving"; // kWarning() << "Unable to open output file when saving";
KGet::showNotification(m_mainWindow, "error", KGet::showNotification(m_mainWindow, "kget/error",
i18n("Unable to save to: %1", filename)); i18n("Unable to save to: %1", filename));
return; return;
} }
@ -881,7 +881,7 @@ QList<TransferHandler*> KGet::createTransfers(const QList<TransferData> &dataIte
} }
content = QString("<p style=\"font-size: small;\">%1</p>").arg(content); content = QString("<p style=\"font-size: small;\">%1</p>").arg(content);
KGet::showNotification(m_mainWindow, "error", message + content, "dialog-error", i18n("Protocol unsupported")); KGet::showNotification(m_mainWindow, "kget/error", message + content, "dialog-error", i18n("Protocol unsupported"));
} }
//add the created transfers to the model and start them if specified //add the created transfers to the model and start them if specified
@ -982,14 +982,14 @@ bool KGet::isValidSource(const KUrl &source)
{ {
// Check if the URL is well formed // Check if the URL is well formed
if (!source.isValid()) { if (!source.isValid()) {
KGet::showNotification(m_mainWindow, "error", KGet::showNotification(m_mainWindow, "kget/error",
i18n("Malformed URL:\n%1", source.prettyUrl())); i18n("Malformed URL:\n%1", source.prettyUrl()));
return false; return false;
} }
// Check if the URL contains the protocol // Check if the URL contains the protocol
if (source.protocol().isEmpty()){ if (source.protocol().isEmpty()){
KGet::showNotification(m_mainWindow, "error", KGet::showNotification(m_mainWindow, "kget/error",
i18n("Malformed URL, protocol missing:\n%1", source.prettyUrl())); i18n("Malformed URL, protocol missing:\n%1", source.prettyUrl()));
return false; return false;
@ -1194,12 +1194,12 @@ void KGet::setHasNetworkConnection(bool hasConnection)
if (initialState != finalState) { if (initialState != finalState) {
if (hasConnection) { if (hasConnection) {
KGet::showNotification(m_mainWindow, "notification", KGet::showNotification(m_mainWindow, "kget/notification",
i18n("Internet connection established, resuming transfers."), i18n("Internet connection established, resuming transfers."),
"dialog-info"); "dialog-info");
} else { } else {
KGet::showNotification(m_mainWindow, "notification", KGet::showNotification(m_mainWindow, "kget/notification",
i18n("No internet connection, stopping transfers."), i18n("No internet connection, stopping transfers."),
"dialog-info"); "dialog-info");
} }
@ -1214,7 +1214,7 @@ KGetPlugin * KGet::createPluginFromService( const KService::Ptr &service )
if (!factory) if (!factory)
{ {
KGet::showNotification(m_mainWindow, "error", KGet::showNotification(m_mainWindow, "kget/error",
i18n("Plugin loader could not load the plugin: %1.", service->library()), i18n("Plugin loader could not load the plugin: %1.", service->library()),
"dialog-info"); "dialog-info");
kError() << "KPluginFactory could not load the plugin:" << service->library() << loader.errorString(); kError() << "KPluginFactory could not load the plugin:" << service->library() << loader.errorString();
@ -1232,7 +1232,7 @@ bool KGet::safeDeleteFile( const KUrl& url )
QFileInfo info( url.toLocalFile() ); QFileInfo info( url.toLocalFile() );
if ( info.isDir() ) if ( info.isDir() )
{ {
KGet::showNotification(m_mainWindow, "notification", KGet::showNotification(m_mainWindow, "kget/notification",
i18n("Not deleting\n%1\nas it is a directory.", url.prettyUrl()), i18n("Not deleting\n%1\nas it is a directory.", url.prettyUrl()),
"dialog-info"); "dialog-info");
return false; return false;
@ -1242,7 +1242,7 @@ bool KGet::safeDeleteFile( const KUrl& url )
} }
else else
KGet::showNotification(m_mainWindow, "notification", KGet::showNotification(m_mainWindow, "kget/notification",
i18n("Not deleting\n%1\nas it is not a local file.", url.prettyUrl()), i18n("Not deleting\n%1\nas it is not a local file.", url.prettyUrl()),
"dialog-info"); "dialog-info");
return false; return false;
@ -1251,7 +1251,7 @@ bool KGet::safeDeleteFile( const KUrl& url )
KNotification *KGet::showNotification(QWidget *parent, const QString &eventType, KNotification *KGet::showNotification(QWidget *parent, const QString &eventType,
const QString &text, const QString &icon, const QString &title, const KNotification::NotificationFlags &flags) const QString &text, const QString &icon, const QString &title, const KNotification::NotificationFlags &flags)
{ {
return KNotification::event(eventType, title, text, KIcon(icon).pixmap(KIconLoader::SizeMedium), parent, flags); return KNotification::event(eventType, title, text, icon, parent, flags);
} }
GenericObserver::GenericObserver(QObject *parent) GenericObserver::GenericObserver(QObject *parent)
@ -1353,23 +1353,36 @@ void GenericObserver::transfersChangedEvent(QMap<TransferHandler*, Transfer::Cha
if (transferFlags & Transfer::Tc_Status) { if (transferFlags & Transfer::Tc_Status) {
if ((transfer->status() == Job::Finished) && (transfer->startStatus() != Job::Finished)) { if ((transfer->status() == Job::Finished) && (transfer->startStatus() != Job::Finished)) {
KGet::showNotification(KGet::m_mainWindow, "finished", KGet::showNotification(
i18n("<p>The following file has finished downloading:</p><p style=\"font-size: small;\">%1</p>", transfer->dest().fileName()), KGet::m_mainWindow, "kget/finished",
"kget", i18n("Download completed")); i18n("<p>The following file has finished downloading:</p><p style=\"font-size: small;\">%1</p>", transfer->dest().fileName()),
"kget", i18n("Download completed")
);
} else if (transfer->status() == Job::Running) { } else if (transfer->status() == Job::Running) {
KGet::showNotification(KGet::m_mainWindow, "started", KGet::showNotification(
i18n("<p>The following transfer has been started:</p><p style=\"font-size: small;\">%1</p>", transfer->source().pathOrUrl()), KGet::m_mainWindow, "kget/started",
"kget", i18n("Download started")); i18n("<p>The following transfer has been started:</p><p style=\"font-size: small;\">%1</p>", transfer->source().pathOrUrl()),
"kget", i18n("Download started")
);
} else if (transfer->status() == Job::Aborted && transfer->error().type != Job::AutomaticRetry) { } else if (transfer->status() == Job::Aborted && transfer->error().type != Job::AutomaticRetry) {
KNotification * notification = KNotification::event("error", i18n("Error"), i18n("<p>There has been an error in the following transfer:</p><p style=\"font-size: small;\">%1</p>" KNotification* notification = new KNotification(this);
"<p>The error message is:</p><p style=\"font-size: small;\">%2</p>", transfer->source().pathOrUrl(), transfer->error().text), notification->setEventID("kget/error");
transfer->error().pixmap, KGet::m_mainWindow, KNotification::CloseOnTimeout); notification->setTitle(i18n("Error"));
notification->setText(
i18n(
"<p>There has been an error in the following transfer:</p><p style=\"font-size: small;\">%1</p>"
"<p>The error message is:</p><p style=\"font-size: small;\">%2</p>", transfer->source().pathOrUrl(), transfer->error().text
)
);
notification->setIcon("kget");
notification->setWidget(KGet::m_mainWindow);
if (transfer->error().type == Job::ManualSolve) { if (transfer->error().type == Job::ManualSolve) {
m_notifications.insert(notification, transfer); m_notifications.insert(notification, transfer);
notification->setActions(QStringList() << i18n("Resolve")); notification->setActions(QStringList() << i18n("Resolve"));
connect(notification, SIGNAL(action1Activated()), SLOT(slotResolveTransferError())); connect(notification, SIGNAL(action1Activated()), SLOT(slotResolveTransferError()));
connect(notification, SIGNAL(closed()), SLOT(slotNotificationClosed())); connect(notification, SIGNAL(closed()), SLOT(slotNotificationClosed()));
} }
notification->send();
} }
} }
@ -1418,18 +1431,18 @@ void GenericObserver::transfersChangedEvent(QMap<TransferHandler*, Transfer::Cha
switch (Settings::afterFinishAction()) { switch (Settings::afterFinishAction()) {
case KGet::Quit: case KGet::Quit:
notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("KGet is now closing, as all downloads have completed."), "kget", "KGet", KNotification::Persistent | KNotification::CloseWhenWidgetActivated); notification = KGet::showNotification(KGet::m_mainWindow, "kget/notification", i18n("KGet is now closing, as all downloads have completed."), "kget", "KGet", KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
break; break;
#ifdef HAVE_KWORKSPACE #ifdef HAVE_KWORKSPACE
case KGet::Shutdown: case KGet::Shutdown:
notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now turn off, as all downloads have completed."), "system-shutdown", i18nc("Shutting down computer", "Shutdown"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated); notification = KGet::showNotification(KGet::m_mainWindow, "kget/notification", i18n("The computer will now turn off, as all downloads have completed."), "system-shutdown", i18nc("Shutting down computer", "Shutdown"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
break; break;
#endif #endif
case KGet::Hibernate: case KGet::Hibernate:
notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now suspend to disk, as all downloads have completed."), "system-suspend-hibernate", i18nc("Hibernating computer", "Hibernating"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated); notification = KGet::showNotification(KGet::m_mainWindow, "kget/notification", i18n("The computer will now suspend to disk, as all downloads have completed."), "system-suspend-hibernate", i18nc("Hibernating computer", "Hibernating"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
break; break;
case KGet::Suspend: case KGet::Suspend:
notification = KGet::showNotification(KGet::m_mainWindow, "notification", i18n("The computer will now suspend to RAM, as all downloads have completed."), "system-suspend", i18nc("Suspending computer", "Suspending"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated); notification = KGet::showNotification(KGet::m_mainWindow, "kget/notification", i18n("The computer will now suspend to RAM, as all downloads have completed."), "system-suspend", i18nc("Suspending computer", "Suspending"), KNotification::Persistent | KNotification::CloseWhenWidgetActivated);
break; break;
default: default:
break; break;
@ -1446,7 +1459,7 @@ void GenericObserver::transfersChangedEvent(QMap<TransferHandler*, Transfer::Cha
} }
} else if (allFinished && !m_allFinished) { } else if (allFinished && !m_allFinished) {
m_allFinished = true; m_allFinished = true;
KGet::showNotification(KGet::m_mainWindow, "finishedall", KGet::showNotification(KGet::m_mainWindow, "kget/finishedall",
i18n("<p>All transfers have been finished.</p>"), i18n("<p>All transfers have been finished.</p>"),
"kget", i18n("Downloads completed")); "kget", i18n("Downloads completed"));
} }

View file

@ -166,7 +166,7 @@ UrlChecker::UrlError UrlChecker::checkSource(const KUrl &src, bool showNotificat
if (showNotification && (error != NoError)) { if (showNotification && (error != NoError)) {
kDebug() << "Source:" << src << "has error:" << error; kDebug() << "Source:" << src << "has error:" << error;
KGet::showNotification(KGet::m_mainWindow, "error", message(src, Source, error)); KGet::showNotification(KGet::m_mainWindow, "kget/error", message(src, Source, error));
} }
return error; return error;
@ -194,7 +194,7 @@ UrlChecker::UrlError UrlChecker::checkDestination(const KUrl &destination, bool
if (showNotification && (error != NoError)) { if (showNotification && (error != NoError)) {
kDebug() << "Destination:" << destination << "has error:" << error; kDebug() << "Destination:" << destination << "has error:" << error;
KGet::showNotification(KGet::m_mainWindow, "error", message(destination, Destination, error)); KGet::showNotification(KGet::m_mainWindow, "kget/error", message(destination, Destination, error));
} }
return error; return error;
@ -225,7 +225,7 @@ UrlChecker::UrlError UrlChecker::checkFolder(const KUrl &folder, bool showNotifi
if (showNotification && (error != NoError)) { if (showNotification && (error != NoError)) {
kDebug() << "Folder:" << folder << "has error:" << error; kDebug() << "Folder:" << folder << "has error:" << error;
KGet::showNotification(KGet::m_mainWindow, "error", message(folder, Folder, error)); KGet::showNotification(KGet::m_mainWindow, "kget/error", message(folder, Folder, error));
} }
return error; return error;
@ -847,7 +847,7 @@ void UrlChecker::displayErrorMessages()
} }
if (!m.isEmpty()) { if (!m.isEmpty()) {
KGet::showNotification(KGet::m_mainWindow, "error", m); KGet::showNotification(KGet::m_mainWindow, "kget/error", m);
} }
} }
} }

View file

@ -40,19 +40,19 @@ HttpServer::HttpServer(QWidget *parent)
const QString pwd = m_passwdstore->getPasswd("Webinterface", parent->winId()); const QString pwd = m_passwdstore->getPasswd("Webinterface", parent->winId());
if (!setAuthenticate(usr.toUtf8(), pwd.toUtf8())) { if (!setAuthenticate(usr.toUtf8(), pwd.toUtf8())) {
KGet::showNotification(parent, KGet::showNotification(parent,
"error", i18nc("@info", "Unable to set the WebInterface authorization: %1", errorString()) "kget/error", i18nc("@info", "Unable to set the WebInterface authorization: %1", errorString())
); );
return; return;
} }
if (!start(QHostAddress::Any, Settings::webinterfacePort())) { if (!start(QHostAddress::Any, Settings::webinterfacePort())) {
KGet::showNotification(parent, KGet::showNotification(parent,
"error", i18nc("@info", "Unable to start WebInterface: %1", errorString()) "kget/error", i18nc("@info", "Unable to start WebInterface: %1", errorString())
); );
return; return;
} }
} else { } else {
KGet::showNotification(parent, KGet::showNotification(parent,
"error", i18n("Unable to start WebInterface: Could not open KPasswdStore") "kget/error", i18n("Unable to start WebInterface: Could not open KPasswdStore")
); );
} }
} }
@ -71,14 +71,14 @@ void HttpServer::settingsChanged()
if (!setAuthenticate(usr.toUtf8(), pwd.toUtf8())) { if (!setAuthenticate(usr.toUtf8(), pwd.toUtf8())) {
KGet::showNotification( KGet::showNotification(
parentwidget, parentwidget,
"error", i18nc("@info", "Unable to set the WebInterface authorization: %1", errorString()) "kget/error", i18nc("@info", "Unable to set the WebInterface authorization: %1", errorString())
); );
return; return;
} }
if (!start(QHostAddress::Any, Settings::webinterfacePort())) { if (!start(QHostAddress::Any, Settings::webinterfacePort())) {
KGet::showNotification( KGet::showNotification(
parentwidget, parentwidget,
"error", i18nc("@info", "Unable to restart WebInterface: %1", errorString()) "kget/error", i18nc("@info", "Unable to restart WebInterface: %1", errorString())
); );
return; return;
} }

View file

@ -1,4 +1,4 @@
[Global] [kget]
IconName=kget IconName=kget
Comment=KGet Download Manager Comment=KGet Download Manager
Comment[bg]=Изтегляне на файлове (KGet) Comment[bg]=Изтегляне на файлове (KGet)
@ -54,7 +54,7 @@ Comment[x-test]=xxKGet Download Managerxx
Comment[zh_CN]=KGet 下载管理器 Comment[zh_CN]=KGet 下载管理器
Comment[zh_TW]=KGet 下載管理員 Comment[zh_TW]=KGet 下載管理員
[Event/added] [kget/added]
Name=Transfer Added Name=Transfer Added
Name[ar]=التحويل أضيف Name[ar]=التحويل أضيف
Name[ast]=Tresferencia Amestada Name[ast]=Tresferencia Amestada
@ -180,9 +180,9 @@ Comment[zh_CN]=添加了新下载
Comment[zh_HK]=已新增新的下載 Comment[zh_HK]=已新增新的下載
Comment[zh_TW]=已新增新的傳輸 Comment[zh_TW]=已新增新的傳輸
Sound=KDE-K3B-Insert-Medium.ogg Sound=KDE-K3B-Insert-Medium.ogg
Action=None Actions=
[Event/started] [kget/started]
Name=Download Started Name=Download Started
Name[ar]=التنزيل بدأ Name[ar]=التنزيل بدأ
Name[ast]=Anicióse Baxada Name[ast]=Anicióse Baxada
@ -312,9 +312,9 @@ Comment[zh_CN]=下载已开始
Comment[zh_HK]=下載已開始 Comment[zh_HK]=下載已開始
Comment[zh_TW]=下載已開始 Comment[zh_TW]=下載已開始
Sound=KDE-K3B-Insert-Medium.ogg Sound=KDE-K3B-Insert-Medium.ogg
Action=None Actions=
[Event/finished] [kget/finished]
Name=Download Finished Name=Download Finished
Name[ar]=التنزيل انتهى Name[ar]=التنزيل انتهى
Name[ast]=Baxada finada Name[ast]=Baxada finada
@ -442,9 +442,9 @@ Comment[zh_CN]=下载已完成
Comment[zh_HK]=下載已完成 Comment[zh_HK]=下載已完成
Comment[zh_TW]=下載已完成 Comment[zh_TW]=下載已完成
Sound=KDE-K3B-Finish-Success.ogg Sound=KDE-K3B-Finish-Success.ogg
Action=Popup Actions=Popup
[Event/finishedall] [kget/finishedall]
Name=All Downloads Finished Name=All Downloads Finished
Name[ar]=كل التنزيلات انتهت Name[ar]=كل التنزيلات انتهت
Name[ast]=Fináronse toles baxaes Name[ast]=Fináronse toles baxaes
@ -571,9 +571,9 @@ Comment[zh_CN]=所有下载都已完成
Comment[zh_HK]=所有下載已完成 Comment[zh_HK]=所有下載已完成
Comment[zh_TW]=所有下載均已完成 Comment[zh_TW]=所有下載均已完成
Sound=KDE-K3B-Finish-Success.ogg Sound=KDE-K3B-Finish-Success.ogg
Action=Popup Actions=Popup
[Event/error] [kget/error]
Name=Error Occurred Name=Error Occurred
Name[ast]=Hebo un Fallu Name[ast]=Hebo un Fallu
Name[bg]=Възникна грешка Name[bg]=Възникна грешка
@ -684,9 +684,9 @@ Comment[x-test]=xxAn Error has Occurredxx
Comment[zh_CN]=发生了一个错误 Comment[zh_CN]=发生了一个错误
Comment[zh_TW]=發生錯誤 Comment[zh_TW]=發生錯誤
Sound=KDE-Sys-App-Error.ogg Sound=KDE-Sys-App-Error.ogg
Action=Popup|Sound Actions=Popup,Sound
[Event/notification] [kget/notification]
Name=Information Name=Information
Name[ar]=معلومة Name[ar]=معلومة
Name[ast]=Información Name[ast]=Información
@ -804,4 +804,4 @@ Comment[x-test]=xxUser Notified of Informationxx
Comment[zh_CN]=用户收到消息通知 Comment[zh_CN]=用户收到消息通知
Comment[zh_TW]=使用者資訊通知 Comment[zh_TW]=使用者資訊通知
Sound=KDE-Sys-App-Message.ogg Sound=KDE-Sys-App-Message.ogg
Action=Popup|Sound Actions=Popup,Sound

View file

@ -42,7 +42,7 @@
#include <kstandarddirs.h> #include <kstandarddirs.h>
#include <KInputDialog> #include <KInputDialog>
#include <kmessagebox.h> #include <kmessagebox.h>
#include <knotifyconfigwidget.h> #include <knotificationconfigwidget.h>
#include <kfiledialog.h> #include <kfiledialog.h>
#include <ktoolinvocation.h> #include <ktoolinvocation.h>
#include <kiconloader.h> #include <kiconloader.h>
@ -915,7 +915,7 @@ void MainWindow::slotDeleteFinished()
void MainWindow::slotConfigureNotifications() void MainWindow::slotConfigureNotifications()
{ {
KNotifyConfigWidget::configure(this); KNotificationConfigWidget::configure("kget", this);
} }
void MainWindow::slotNewToolbarConfig() void MainWindow::slotNewToolbarConfig()

View file

@ -77,12 +77,10 @@ void KGetRunner::run(const Plasma::RunnerContext& /*context*/, const Plasma::Que
connection->startService(KGET_DBUS_SERVICE); connection->startService(KGET_DBUS_SERVICE);
if(connection->lastError().type() != QDBusError::NoError) { if(connection->lastError().type() != QDBusError::NoError) {
KNotification::event( KNotification::event(
KNotification::Error, "kget/error",
i18n( i18n("KGet Runner"),
"<p>KGet Runner could not communicate with KGet.</p><p style=\"font-size: small;\">Response from DBus:<br/>%1</p>", i18n("Could not communicate with KGet, response from DBus:<br/><p style=\"font-size: small;\">%1</p>", connection->lastError().message()),
connection->lastError().message() "dialog-warning"
),
KIcon("dialog-warning").pixmap(KIconLoader::SizeSmall)
); );
return; return;
} }
@ -109,9 +107,12 @@ void KGetRunner::callFinished(QDBusPendingCallWatcher* call)
// TODO Remove the check for QDBusError::NoReply when NewTransferDialog is fixed to show asynchronously. // TODO Remove the check for QDBusError::NoReply when NewTransferDialog is fixed to show asynchronously.
if(!reply.isValid() && (reply.error().type() != QDBusError::NoReply)) { if(!reply.isValid() && (reply.error().type() != QDBusError::NoReply)) {
// Send a notification about the error to the user. // Send a notification about the error to the user.
KNotification::event(KNotification::Error, KNotification::event(
i18n("<p>KGet Runner could not communicate with KGet.</p><p style=\"font-size: small;\">Response from DBus:<br/>%1</p>", reply.error().message()), "kget/error",
KIcon("dialog-warning").pixmap(KIconLoader::SizeSmall)/*, 0, KNotification::Persistent*/); i18n("KGet Runner"),
i18n("Could not communicate with KGet, response from DBus:<br/><p style=\"font-size: small;\">%1</p>", reply.error().message()),
"dialog-warning"
);
} }
} }

View file

@ -923,7 +923,7 @@ KMixWindow::unplugged(const QString& udi)
if (mixer->udi() == udi) if (mixer->udi() == udi)
{ {
kDebug() << "Unplugged Match: Removing udi=" << udi << "\n"; kDebug() << "Unplugged Match: Removing udi=" << udi << "\n";
//KMixToolBox::notification("MasterFallback", "aaa"); //KMixToolBox::notification("kmix/MasterFallback", "aaa");
bool globalMasterMixerDestroyed = (mixer == Mixer::getGlobalMasterMixer()); bool globalMasterMixerDestroyed = (mixer == Mixer::getGlobalMasterMixer());
// Part 1) Remove Tab // Part 1) Remove Tab
for (int i = 0; i < m_wsMixers->count(); ++i) for (int i = 0; i < m_wsMixers->count(); ++i)
@ -958,7 +958,7 @@ KMixWindow::unplugged(const QString& udi)
"The soundcard containing the master device was unplugged. Changing to control %1 on card %2.", "The soundcard containing the master device was unplugged. Changing to control %1 on card %2.",
master->readableName(), master->readableName(),
((Mixer::mixers())[0])->readableName()); ((Mixer::mixers())[0])->readableName());
KMixToolBox::notification("MasterFallback", text); KMixToolBox::notification("kmix/MasterFallback", text);
} }
} }
} }
@ -966,7 +966,7 @@ KMixWindow::unplugged(const QString& udi)
{ {
QString text; QString text;
text = i18n("The last soundcard was unplugged."); text = i18n("The last soundcard was unplugged.");
KMixToolBox::notification("MasterFallback", text); KMixToolBox::notification("kmix/MasterFallback", text);
} }
recreateGUI(true); recreateGUI(true);
break; break;

View file

@ -228,7 +228,7 @@ void KMixD::unplugged( const QString& udi)
// kDebug(67100) << "Try Match with:" << mixer->udi() << "\n"; // kDebug(67100) << "Try Match with:" << mixer->udi() << "\n";
if (mixer->udi() == udi ) { if (mixer->udi() == udi ) {
kDebug(67100) << "Unplugged Match: Removing udi=" <<udi << "\n"; kDebug(67100) << "Unplugged Match: Removing udi=" <<udi << "\n";
//KMixToolBox::notification("MasterFallback", "aaa"); //KMixToolBox::notification("kmix/MasterFallback", "aaa");
bool globalMasterMixerDestroyed = ( mixer == Mixer::getGlobalMasterMixer() ); bool globalMasterMixerDestroyed = ( mixer == Mixer::getGlobalMasterMixer() );
MixerToolBox::instance()->removeMixer(mixer); MixerToolBox::instance()->removeMixer(mixer);
@ -248,14 +248,14 @@ void KMixD::unplugged( const QString& udi)
master->readableName(), master->readableName(),
((Mixer::mixers())[0])->readableName() ((Mixer::mixers())[0])->readableName()
); );
// KMixToolBox::notification("MasterFallback", text); // KMixToolBox::notification("kmix/MasterFallback", text);
} }
} }
} }
if ( Mixer::mixers().count() == 0 ) { if ( Mixer::mixers().count() == 0 ) {
QString text; QString text;
text = i18n("The last soundcard was unplugged."); text = i18n("The last soundcard was unplugged.");
// KMixToolBox::notification("MasterFallback", text); // KMixToolBox::notification("kmix/MasterFallback", text);
} }
break; break;
} }

View file

@ -78,14 +78,12 @@ void KMixToolBox::notification(const char *notificationName, const QString &text
const QStringList &actions, QObject *receiver, const QStringList &actions, QObject *receiver,
const char *actionSlot) const char *actionSlot)
{ {
KNotification *notification = new KNotification(notificationName); KNotification *notification = new KNotification();
//notification->setComponentData(componentData()); notification->setEventID(notificationName);
notification->setText(text); notification->setText(text);
//notification->setPixmap(...);
notification->addContext(QLatin1String("Application"), KGlobal::mainComponent().componentName());
if (!actions.isEmpty() && receiver && actionSlot) { if (!actions.isEmpty() && receiver && actionSlot) {
notification->setActions(actions); notification->setActions(actions);
QObject::connect(notification, SIGNAL(activated(uint)), receiver, actionSlot); QObject::connect(notification, SIGNAL(activated(uint)), receiver, actionSlot);
} }
notification->sendEvent(); notification->send();
} }

View file

@ -1,4 +1,4 @@
[Global] [kmix]
IconName=kmix IconName=kmix
Comment=Sound Mixer Comment=Sound Mixer
Comment[bg]=Звуков смесител Comment[bg]=Звуков смесител
@ -52,7 +52,7 @@ Comment[x-test]=xxSound Mixerxx
Comment[zh_CN]=混音器 Comment[zh_CN]=混音器
Comment[zh_TW]=音效混音器 Comment[zh_TW]=音效混音器
[Event/MasterFallback] [kmix/MasterFallback]
Name=Audio Device Fallback Name=Audio Device Fallback
Name[bg]=Резервно звуково устройство Name[bg]=Резервно звуково устройство
Name[bs]=Rezervni zvučni uređaj Name[bs]=Rezervni zvučni uređaj
@ -152,5 +152,4 @@ Comment[uk]=Сповіщення про автоматичне повернен
Comment[x-test]=xxNotification on automatic fallback if the preferred device is unavailablexx Comment[x-test]=xxNotification on automatic fallback if the preferred device is unavailablexx
Comment[zh_CN]=如果首选设备不可用,在自动使用备用设备时进行通知 Comment[zh_CN]=如果首选设备不可用,在自动使用备用设备时进行通知
Comment[zh_TW]=若是選用的裝置無法使用時,通知會自動使用預設的裝置 Comment[zh_TW]=若是選用的裝置無法使用時,通知會自動使用預設的裝置
Contexts=Application Actions=Popup
Action=Popup

View file

@ -63,7 +63,7 @@ add_executable(krdc ${krdc_SRCS})
target_link_libraries(krdc target_link_libraries(krdc
KDE4::kfile KDE4::kfile
KDE4::kio KDE4::kio
KDE4::knotifyconfig KDE4::kdeui
KDE4::kcmutils KDE4::kcmutils
krdccore krdccore
) )

View file

@ -45,7 +45,7 @@
#include <KLocale> #include <KLocale>
#include <KMenu> #include <KMenu>
#include <KMessageBox> #include <KMessageBox>
#include <KNotifyConfigWidget> #include <KNotificationConfigWidget>
#include <KPluginInfo> #include <KPluginInfo>
#include <KPushButton> #include <KPushButton>
#include <KStatusBar> #include <KStatusBar>
@ -940,7 +940,7 @@ void MainWindow::quit(bool systemEvent)
void MainWindow::configureNotifications() void MainWindow::configureNotifications()
{ {
KNotifyConfigWidget::configure(this); KNotificationConfigWidget::configure("krdc", this);
} }
void MainWindow::showMenubar() void MainWindow::showMenubar()

View file

@ -96,6 +96,6 @@ install(
install( install(
FILES krfb.notifyrc FILES krfb.notifyrc
DESTINATION ${KDE4_DATA_INSTALL_DIR}/krfb DESTINATION ${KDE4_CONFIG_INSTALL_DIR}/notifications
) )

View file

@ -63,15 +63,20 @@ void PendingInvitationsRfbClient::processNewClient()
if (d->askOnConnect == false) { if (d->askOnConnect == false) {
KNotification::event("NewConnectionAutoAccepted", KNotification::event(
i18n("Accepted connection from %1", host)); "krfb/NewConnectionAutoAccepted",
QString(),
i18n("Accepted connection from %1", host)
);
accept(new InvitationsRfbClient(m_rfbClient, parent())); accept(new InvitationsRfbClient(m_rfbClient, parent()));
} else { } else {
KNotification::event("NewConnectionOnHold", KNotification::event(
i18n("Received connection from %1, on hold (waiting for confirmation)", "krfb/NewConnectionOnHold",
host)); QString(),
i18n("Received connection from %1, on hold (waiting for confirmation)", host)
);
InvitationsConnectionDialog *dialog = new InvitationsConnectionDialog(0); InvitationsConnectionDialog *dialog = new InvitationsConnectionDialog(0);
dialog->setRemoteHost(host); dialog->setRemoteHost(host);

View file

@ -26,7 +26,6 @@
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtNetwork/QHostInfo> #include <QtNetwork/QHostInfo>
#include <KNotification>
#include <KLocale> #include <KLocale>
#include <KMessageBox> #include <KMessageBox>
#include <KUser> #include <KUser>

View file

@ -1,4 +1,4 @@
[Global] [krfb]
IconName=krfb IconName=krfb
Comment=Desktop Sharing Comment=Desktop Sharing
Comment[af]=Werkskerm Deeling Comment[af]=Werkskerm Deeling
@ -72,7 +72,7 @@ Comment[zh_CN]=桌面共享
Comment[zh_HK]=桌面分享 Comment[zh_HK]=桌面分享
Comment[zh_TW]=桌面分享 Comment[zh_TW]=桌面分享
[Event/UserAcceptsConnection] [krfb/UserAcceptsConnection]
Name=User Accepts Connection Name=User Accepts Connection
Name[ar]=المستخدم يقبل الاتصال Name[ar]=المستخدم يقبل الاتصال
Name[ast]=L'usuariu aceuta la conexón Name[ast]=L'usuariu aceuta la conexón
@ -203,9 +203,9 @@ Comment[x-test]=xxUser accepts connectionxx
Comment[zh_CN]=用户接受连接 Comment[zh_CN]=用户接受连接
Comment[zh_HK]=用戶接受連線 Comment[zh_HK]=用戶接受連線
Comment[zh_TW]=使用者接受連線 Comment[zh_TW]=使用者接受連線
Action=Popup Actions=Popup
[Event/UserRefusesConnection] [krfb/UserRefusesConnection]
Name=User Refuses Connection Name=User Refuses Connection
Name[ar]=المستخدم يرفض الاتصال Name[ar]=المستخدم يرفض الاتصال
Name[ast]=L'usuariu refuga la conexón Name[ast]=L'usuariu refuga la conexón
@ -336,9 +336,9 @@ Comment[x-test]=xxUser refuses connectionxx
Comment[zh_CN]=用户拒绝连接 Comment[zh_CN]=用户拒绝连接
Comment[zh_HK]=用戶拒絕連線 Comment[zh_HK]=用戶拒絕連線
Comment[zh_TW]=使用者拒絕連線使用者 Comment[zh_TW]=使用者拒絕連線使用者
Action=Popup Actions=Popup
[Event/ConnectionClosed] [krfb/ConnectionClosed]
Name=Connection Closed Name=Connection Closed
Name[ar]=الاتصال أغلق Name[ar]=الاتصال أغلق
Name[ast]=Conexón zarrada Name[ast]=Conexón zarrada
@ -475,9 +475,9 @@ Comment[x-test]=xxConnection closedxx
Comment[zh_CN]=连接关闭 Comment[zh_CN]=连接关闭
Comment[zh_HK]=連線已關閉 Comment[zh_HK]=連線已關閉
Comment[zh_TW]=連線已關閉 Comment[zh_TW]=連線已關閉
Action=Popup Actions=Popup
[Event/InvalidPassword] [krfb/InvalidPassword]
Name=Invalid Password Name=Invalid Password
Name[ar]=كلمة المرور غير صحيحة Name[ar]=كلمة المرور غير صحيحة
Name[ast]=Contraseña incorreuta Name[ast]=Contraseña incorreuta
@ -617,9 +617,9 @@ Comment[x-test]=xxInvalid passwordxx
Comment[zh_CN]=无效密码 Comment[zh_CN]=无效密码
Comment[zh_HK]=無效的密碼 Comment[zh_HK]=無效的密碼
Comment[zh_TW]=不正確的密碼 Comment[zh_TW]=不正確的密碼
Action=Popup Actions=Popup
[Event/InvalidPasswordInvitations] [krfb/InvalidPasswordInvitations]
Name=Invalid Password Invitations Name=Invalid Password Invitations
Name[ar]=كلمة المرور الدعوات غير صحيحة Name[ar]=كلمة المرور الدعوات غير صحيحة
Name[ast]=Contraseñas d'invitaciones incorreutes Name[ast]=Contraseñas d'invitaciones incorreutes
@ -748,9 +748,9 @@ Comment[x-test]=xxThe invited party sent an invalid password. Connection refused
Comment[zh_CN]=受邀请方发送的密码不对。连接被拒绝。 Comment[zh_CN]=受邀请方发送的密码不对。连接被拒绝。
Comment[zh_HK]=被邀請的一方送出無效的密碼。已拒絕連線。 Comment[zh_HK]=被邀請的一方送出無效的密碼。已拒絕連線。
Comment[zh_TW]=邀請的人送出了不合法的密碼邀請。連線已拒絕。 Comment[zh_TW]=邀請的人送出了不合法的密碼邀請。連線已拒絕。
Action=Popup Actions=Popup
[Event/NewConnectionOnHold] [krfb/NewConnectionOnHold]
Name=New Connection on Hold Name=New Connection on Hold
Name[ar]=اتصال جديد على التوقف Name[ar]=اتصال جديد على التوقف
Name[ast]=Conexón nueva a la espera Name[ast]=Conexón nueva a la espera
@ -879,9 +879,9 @@ Comment[x-test]=xxConnection requested, user must acceptxx
Comment[zh_CN]=连接已请求,用户必须接受 Comment[zh_CN]=连接已请求,用户必须接受
Comment[zh_HK]=已請求連線,用戶必須接受 Comment[zh_HK]=已請求連線,用戶必須接受
Comment[zh_TW]=連線已要求,必須等使用者接受 Comment[zh_TW]=連線已要求,必須等使用者接受
Action=Popup Actions=Popup
[Event/NewConnectionAutoAccepted] [krfb/NewConnectionAutoAccepted]
Name=New Connection Auto Accepted Name=New Connection Auto Accepted
Name[ar]=اتصال جديد مقبول تلقائيا Name[ar]=اتصال جديد مقبول تلقائيا
Name[ast]=Conexón nueva aceutada automáticamente Name[ast]=Conexón nueva aceutada automáticamente
@ -1010,9 +1010,9 @@ Comment[x-test]=xxNew connection automatically establishedxx
Comment[zh_CN]=自动建立新连接 Comment[zh_CN]=自动建立新连接
Comment[zh_HK]=已自動建立新連線 Comment[zh_HK]=已自動建立新連線
Comment[zh_TW]=新連線自動建立 Comment[zh_TW]=新連線自動建立
Action=Popup Actions=Popup
[Event/TooManyConnections] [krfb/TooManyConnections]
Name=Too Many Connections Name=Too Many Connections
Name[ar]=اتصالات عديدة Name[ar]=اتصالات عديدة
Name[ast]=Abondes conexones Name[ast]=Abondes conexones
@ -1144,9 +1144,9 @@ Comment[x-test]=xxBusy, connection refusedxx
Comment[zh_CN]=对方处于忙碌状态,连接被拒绝 Comment[zh_CN]=对方处于忙碌状态,连接被拒绝
Comment[zh_HK]=忙碌,已拒絕連線 Comment[zh_HK]=忙碌,已拒絕連線
Comment[zh_TW]=忙碌,連線被拒 Comment[zh_TW]=忙碌,連線被拒
Action=Popup Actions=Popup
[Event/UnexpectedConnection] [krfb/UnexpectedConnection]
Name=Unexpected Connection Name=Unexpected Connection
Name[ar]=الاتصال غير متوقّع Name[ar]=الاتصال غير متوقّع
Name[ast]=Conexón inesperada Name[ast]=Conexón inesperada
@ -1275,4 +1275,4 @@ Comment[x-test]=xxReceived unexpected connection, abortxx
Comment[zh_CN]=收到意外连接,已中止 Comment[zh_CN]=收到意外连接,已中止
Comment[zh_HK]=接收到非預期的連線,中止 Comment[zh_HK]=接收到非預期的連線,中止
Comment[zh_TW]=已接收到未知的連線,中止。 Comment[zh_TW]=已接收到未知的連線,中止。
Action=Popup Actions=Popup

View file

@ -27,7 +27,6 @@
#include <KDebug> #include <KDebug>
#include <KLocale> #include <KLocale>
#include <KMessageBox> #include <KMessageBox>
#include <KNotification>
#include <kdeversion.h> #include <kdeversion.h>
#include <QtGui/QPixmap> #include <QtGui/QPixmap>

View file

@ -24,7 +24,6 @@
#include "events.h" #include "events.h"
#include <QtCore/QSocketNotifier> #include <QtCore/QSocketNotifier>
#include <KDebug> #include <KDebug>
#include <KNotification>
#include <poll.h> #include <poll.h>
#include <strings.h> //for bzero() #include <strings.h> //for bzero()

View file

@ -212,8 +212,11 @@ void RfbServerManager::addClient(RfbClient* cc)
} }
d->clients.insert(cc); d->clients.insert(cc);
KNotification::event("UserAcceptsConnection", KNotification::event(
i18n("The remote user %1 is now connected.", cc->name())); "krfb/UserAcceptsConnection",
QString(),
i18n("The remote user %1 is now connected.", cc->name())
);
Q_EMIT clientConnected(cc); Q_EMIT clientConnected(cc);
} }
@ -227,7 +230,11 @@ void RfbServerManager::removeClient(RfbClient* cc)
d->rfbUpdateTimer.stop(); d->rfbUpdateTimer.stop();
} }
KNotification::event("ConnectionClosed", i18n("The remote user %1 disconnected.", cc->name())); KNotification::event(
"krfb/ConnectionClosed",
QString(),
i18n("The remote user %1 disconnected.", cc->name())
);
Q_EMIT clientDisconnected(cc); Q_EMIT clientDisconnected(cc);
} }