Abstract startup semantics in the startupfeedback effect
This commit is contained in:
parent
0f8813671b
commit
3c7290b722
3 changed files with 36 additions and 20 deletions
|
@ -74,13 +74,28 @@ StartupFeedbackEffect::StartupFeedbackEffect()
|
||||||
, m_configWatcher(KConfigWatcher::create(KSharedConfig::openConfig("klaunchrc", KConfig::NoGlobals)))
|
, m_configWatcher(KConfigWatcher::create(KSharedConfig::openConfig("klaunchrc", KConfig::NoGlobals)))
|
||||||
, m_splashVisible(false)
|
, m_splashVisible(false)
|
||||||
{
|
{
|
||||||
|
// TODO: move somewhere that is x11-specific
|
||||||
if (KWindowSystem::isPlatformX11()) {
|
if (KWindowSystem::isPlatformX11()) {
|
||||||
m_selection = new KSelectionOwner("_KDE_STARTUP_FEEDBACK", xcbConnection(), x11RootWindow(), this);
|
m_selection = new KSelectionOwner("_KDE_STARTUP_FEEDBACK", xcbConnection(), x11RootWindow(), this);
|
||||||
m_selection->claim(true);
|
m_selection->claim(true);
|
||||||
}
|
}
|
||||||
connect(m_startupInfo, &KStartupInfo::gotNewStartup, this, &StartupFeedbackEffect::gotNewStartup);
|
connect(m_startupInfo, &KStartupInfo::gotNewStartup, this, [](const KStartupInfoId &id, const KStartupInfoData &data) {
|
||||||
connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, this, &StartupFeedbackEffect::gotRemoveStartup);
|
const auto icon = QIcon::fromTheme(data.findIcon(), QIcon::fromTheme(QStringLiteral("system-run")));
|
||||||
connect(m_startupInfo, &KStartupInfo::gotStartupChange, this, &StartupFeedbackEffect::gotStartupChange);
|
Q_EMIT effects->startupAdded(id.id(), icon);
|
||||||
|
});
|
||||||
|
connect(m_startupInfo, &KStartupInfo::gotRemoveStartup, this, [](const KStartupInfoId &id, const KStartupInfoData &data) {
|
||||||
|
Q_UNUSED(data);
|
||||||
|
Q_EMIT effects->startupRemoved(id.id());
|
||||||
|
});
|
||||||
|
connect(m_startupInfo, &KStartupInfo::gotStartupChange, this, [](const KStartupInfoId &id, const KStartupInfoData &data) {
|
||||||
|
const auto icon = QIcon::fromTheme(data.findIcon(), QIcon::fromTheme(QStringLiteral("system-run")));
|
||||||
|
Q_EMIT effects->startupChanged(id.id(), icon);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(effects, &EffectsHandler::startupAdded, this, &StartupFeedbackEffect::gotNewStartup);
|
||||||
|
connect(effects, &EffectsHandler::startupRemoved, this, &StartupFeedbackEffect::gotRemoveStartup);
|
||||||
|
connect(effects, &EffectsHandler::startupChanged, this, &StartupFeedbackEffect::gotStartupChange);
|
||||||
|
|
||||||
connect(effects, &EffectsHandler::mouseChanged, this, &StartupFeedbackEffect::slotMouseChanged);
|
connect(effects, &EffectsHandler::mouseChanged, this, &StartupFeedbackEffect::slotMouseChanged);
|
||||||
connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this]() {
|
connect(m_configWatcher.data(), &KConfigWatcher::configChanged, this, [this]() {
|
||||||
reconfigure(ReconfigureAll);
|
reconfigure(ReconfigureAll);
|
||||||
|
@ -95,7 +110,7 @@ StartupFeedbackEffect::StartupFeedbackEffect()
|
||||||
});
|
});
|
||||||
connect(serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, [this] {
|
connect(serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, [this] {
|
||||||
m_splashVisible = false;
|
m_splashVisible = false;
|
||||||
gotRemoveStartup(KStartupInfoId(), KStartupInfoData()); // Start the next feedback
|
gotRemoveStartup({}); // Start the next feedback
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,20 +249,18 @@ void StartupFeedbackEffect::slotMouseChanged(const QPoint& pos, const QPoint& ol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartupFeedbackEffect::gotNewStartup(const KStartupInfoId& id, const KStartupInfoData& data)
|
void StartupFeedbackEffect::gotNewStartup(const QString &id, const QIcon &icon)
|
||||||
{
|
{
|
||||||
const QString& icon = data.findIcon();
|
|
||||||
m_currentStartup = id;
|
m_currentStartup = id;
|
||||||
m_startups[ id ] = icon;
|
m_startups[ id ] = icon;
|
||||||
start(icon);
|
start(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartupFeedbackEffect::gotRemoveStartup(const KStartupInfoId& id, const KStartupInfoData& data)
|
void StartupFeedbackEffect::gotRemoveStartup(const QString &id)
|
||||||
{
|
{
|
||||||
Q_UNUSED( data )
|
|
||||||
m_startups.remove(id);
|
m_startups.remove(id);
|
||||||
if (m_startups.isEmpty()) {
|
if (m_startups.isEmpty()) {
|
||||||
m_currentStartup = KStartupInfoId(); // null
|
m_currentStartup.clear();
|
||||||
stop();
|
stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -255,18 +268,17 @@ void StartupFeedbackEffect::gotRemoveStartup(const KStartupInfoId& id, const KSt
|
||||||
start(m_startups[ m_currentStartup ]);
|
start(m_startups[ m_currentStartup ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartupFeedbackEffect::gotStartupChange(const KStartupInfoId& id, const KStartupInfoData& data)
|
void StartupFeedbackEffect::gotStartupChange(const QString &id, const QIcon &icon)
|
||||||
{
|
{
|
||||||
if (m_currentStartup == id) {
|
if (m_currentStartup == id) {
|
||||||
const QString& icon = data.findIcon();
|
if (!icon.isNull() && icon.name() != m_startups[m_currentStartup].name()) {
|
||||||
if (!icon.isEmpty() && icon != m_startups[ m_currentStartup ]) {
|
|
||||||
m_startups[ id ] = icon;
|
m_startups[ id ] = icon;
|
||||||
start(icon);
|
start(icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartupFeedbackEffect::start(const QString& icon)
|
void StartupFeedbackEffect::start(const QIcon &icon)
|
||||||
{
|
{
|
||||||
if (m_type == NoFeedback || m_splashVisible)
|
if (m_type == NoFeedback || m_splashVisible)
|
||||||
return;
|
return;
|
||||||
|
@ -285,7 +297,7 @@ void StartupFeedbackEffect::start(const QString& icon)
|
||||||
// get ratio for bouncing cursor so we don't need to manually calculate the sizes for each icon size
|
// get ratio for bouncing cursor so we don't need to manually calculate the sizes for each icon size
|
||||||
if (m_type == BouncingFeedback)
|
if (m_type == BouncingFeedback)
|
||||||
m_bounceSizesRatio = iconSize / 16.0;
|
m_bounceSizesRatio = iconSize / 16.0;
|
||||||
const QPixmap iconPixmap = QIcon::fromTheme(icon, QIcon::fromTheme(QStringLiteral("system-run"))).pixmap(iconSize);
|
const QPixmap iconPixmap = icon.pixmap(iconSize);
|
||||||
prepareTextures(iconPixmap);
|
prepareTextures(iconPixmap);
|
||||||
m_dirtyRect = m_currentGeometry = feedbackRect();
|
m_dirtyRect = m_currentGeometry = feedbackRect();
|
||||||
effects->addRepaint(m_dirtyRect);
|
effects->addRepaint(m_dirtyRect);
|
||||||
|
|
|
@ -45,9 +45,9 @@ public:
|
||||||
static bool supported();
|
static bool supported();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void gotNewStartup(const KStartupInfoId& id, const KStartupInfoData& data);
|
void gotNewStartup(const QString &id, const QIcon &icon);
|
||||||
void gotRemoveStartup(const KStartupInfoId& id, const KStartupInfoData& data);
|
void gotRemoveStartup(const QString &id);
|
||||||
void gotStartupChange(const KStartupInfoId& id, const KStartupInfoData& data);
|
void gotStartupChange(const QString &id, const QIcon &icon);
|
||||||
void slotMouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
void slotMouseChanged(const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -57,7 +57,7 @@ private:
|
||||||
BlinkingFeedback,
|
BlinkingFeedback,
|
||||||
PassiveFeedback
|
PassiveFeedback
|
||||||
};
|
};
|
||||||
void start(const QString& icon);
|
void start(const QIcon &icon);
|
||||||
void stop();
|
void stop();
|
||||||
QImage scalePixmap(const QPixmap& pm, const QSize& size) const;
|
QImage scalePixmap(const QPixmap& pm, const QSize& size) const;
|
||||||
void prepareTextures(const QPixmap& pix);
|
void prepareTextures(const QPixmap& pix);
|
||||||
|
@ -66,8 +66,8 @@ private:
|
||||||
qreal m_bounceSizesRatio;
|
qreal m_bounceSizesRatio;
|
||||||
KStartupInfo* m_startupInfo;
|
KStartupInfo* m_startupInfo;
|
||||||
KSelectionOwner* m_selection;
|
KSelectionOwner* m_selection;
|
||||||
KStartupInfoId m_currentStartup;
|
QString m_currentStartup;
|
||||||
QMap< KStartupInfoId, QString > m_startups; // QString == pixmap
|
QMap<QString, QIcon> m_startups; // QString == pixmap
|
||||||
bool m_active;
|
bool m_active;
|
||||||
int m_frame;
|
int m_frame;
|
||||||
int m_progress;
|
int m_progress;
|
||||||
|
|
|
@ -1843,6 +1843,10 @@ Q_SIGNALS:
|
||||||
*/
|
*/
|
||||||
void windowExpandedGeometryChanged(KWin::EffectWindow *window);
|
void windowExpandedGeometryChanged(KWin::EffectWindow *window);
|
||||||
|
|
||||||
|
void startupAdded(const QString &id, const QIcon &icon);
|
||||||
|
void startupChanged(const QString &id, const QIcon &icon);
|
||||||
|
void startupRemoved(const QString &id);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVector< EffectPair > loaded_effects;
|
QVector< EffectPair > loaded_effects;
|
||||||
//QHash< QString, EffectFactory* > effect_factories;
|
//QHash< QString, EffectFactory* > effect_factories;
|
||||||
|
|
Loading…
Reference in a new issue