Commit 8f96293a authored by Nicolas Fella's avatar Nicolas Fella

Port from KPassivePopup to KNotification

Summary: KPassivePopup is hideous and shouldn't be used any more. Replace it with a persistent KNotification

Test Plan: Click on tray icon: Notification appears. Start a tea: Notification changes content. Click tray again, notification disappears

Reviewers: sboehmann, dakon, broulik, fb, dfaure, davidedmundson

Reviewed By: davidedmundson

Subscribers: kde-utils-devel

Differential Revision: https://phabricator.kde.org/D22542
parent 9415da9c
......@@ -312,3 +312,8 @@ Comment[zh_CN]=茶都凉了。
Comment[zh_TW]=茶煮好了,怎麼沒人喝。
Sound=Oxygen-Sys-App-Special.ogg
Action=Sound
[Event/popup]
Name=The Tea Cooker
Comment=The Tea Cooker
Action=Popup
......@@ -39,13 +39,12 @@
#include <KIconLoader>
#include <KNotification>
#include <KNotifyConfigWidget>
#include <KPassivePopup>
#include <KSharedConfig>
TopLevel::TopLevel(const KAboutData *aboutData, const QString &icon, QWidget *parent)
: QSystemTrayIcon( parent ),
m_popup( new KPassivePopup ),
m_popup(),
m_iconName(icon),
m_runningTeaTime( 0 ),
m_pausedRemainingTeaTime( 0 ),
......@@ -142,7 +141,6 @@ TopLevel::~TopLevel()
{
delete m_helpMenu;
delete m_timer;
delete m_popup;
delete m_teaActionGroup;
}
......@@ -405,33 +403,29 @@ void TopLevel::showPopup(QSystemTrayIcon::ActivationReason reason)
if ( reason != QSystemTrayIcon::Trigger ) {
return;
}
if ( m_popup->isVisible() )
if ( m_popup )
{
m_popup->hide();
m_popup->close();
}
else
{
QPoint p = geometry().topLeft();
QRect r = QApplication::desktop()->screenGeometry( p );
QSize popupSize = m_popup->minimumSizeHint();
if ( p.x() + popupSize.width() > r.right() )
{
p.rx() -= popupSize.width();
}
if ( p.y() + popupSize.height() > r.bottom() )
{
p.ry() -= popupSize.height();
}
m_popup->show( p );
m_popup = new KNotification(QStringLiteral("popup"), KNotification::Persistent, this);
m_popup->setComponentName(QStringLiteral("kteatime"));
m_popup->setTitle(i18n( "The Tea Cooker" ));
m_popup->setText(toolTip());
m_popup->setIconName(m_iconName);
m_popup->sendEvent();
}
}
void TopLevel::setTooltipText(const QString& content)
{
const QString title = i18n( "The Tea Cooker" );
setToolTip( content );
m_popup->setView( title, content, KIconLoader::global()->loadIcon( m_iconName, KIconLoader::MainToolbar ) );
if (m_popup)
{
m_popup->setText(content);
}
}
......
......@@ -22,6 +22,7 @@
#include "tea.h"
#include <QSystemTrayIcon>
#include <QPointer>
class QAction;
......@@ -30,7 +31,7 @@ class QTimer;
class KAboutData;
class KActionCollection;
class KHelpMenu;
class KPassivePopup;
class KNotification;
/**
* @short the main class for KTeatime
......@@ -68,7 +69,7 @@ class TopLevel : public QSystemTrayIcon
KHelpMenu *m_helpMenu;
QTimer *m_timer;
KPassivePopup *m_popup;
QPointer<KNotification> m_popup;
QString m_iconName;
int m_runningTeaTime;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment