1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-12 01:17:55 +03:00

send a notification when switching layouts dynamic

This commit is contained in:
Michail Vourlakos 2017-07-23 22:31:18 +03:00
parent ecf67a2a9d
commit 0a53646847
3 changed files with 23 additions and 7 deletions

View File

@ -24,3 +24,7 @@ Action=Popup
Name[el]=Αποτυχία εξαγωγής ρυθμίσεων
Name=Failed to export configuration
Action=Popup
[Event/switch-layout]
Name=Switch to layout
Action=Popup

View File

@ -53,7 +53,7 @@ LayoutManager::LayoutManager(QObject *parent)
connect(m_corona->universalSettings(), &UniversalSettings::currentLayoutNameChanged, this, &LayoutManager::currentLayoutNameChanged);
m_dynamicSwitchTimer.setSingleShot(true);
m_dynamicSwitchTimer.setInterval(3000);
m_dynamicSwitchTimer.setInterval(2000);
connect(&m_dynamicSwitchTimer, &QTimer::timeout, this, &LayoutManager::confirmDynamicSwitch);
}
}
@ -207,14 +207,22 @@ void LayoutManager::confirmDynamicSwitch()
{
QString tempShouldSwitch = shouldSwitchToLayout(m_corona->m_activityConsumer->currentActivity());
if (m_shouldSwitchToLayout == tempShouldSwitch) {
if (tempShouldSwitch.isEmpty()) {
return;
}
if (m_shouldSwitchToLayout == tempShouldSwitch && m_shouldSwitchToLayout != currentLayoutName()) {
qDebug() << "dynamic switch to layout :: " << m_shouldSwitchToLayout;
//NOTE: The pointer is automatically deleted when the event is closed
auto notification = new KNotification("dynamic-switch", KNotification::CloseOnTimeout);
notification->setText(i18nc("dynamic-switch-layout", "Changing to layout <b>%0</b>...").arg(m_shouldSwitchToLayout));
notification->sendEvent();
switchToLayout(m_shouldSwitchToLayout);
QTimer::singleShot(1000, [this, tempShouldSwitch]() {
//NOTE: The pointer is automatically deleted when the event is closed
KNotification *notification = new KNotification("switch-layout", KNotification::CloseOnTimeout);
notification->setTitle(i18nc("switch layouts", "Switching..."));
notification->setText(i18nc("switch layout", "Changing to layout <b>%0</b>...").arg(tempShouldSwitch));
notification->sendEvent();
});
} else {
m_shouldSwitchToLayout = tempShouldSwitch;
m_dynamicSwitchTimer.start();
@ -285,7 +293,7 @@ bool LayoutManager::switchToLayout(QString layoutName)
//! also from qml (Tasks plasmoid). This change fixes a very important
//! crash when switching sessions through the Tasks plasmoid Context menu
//! Latte was unstable and was crashing very often during changing
//! sessions
//! sessions.
QTimer::singleShot(0, [this, layoutName, lPath]() {
qDebug() << layoutName << " - " << lPath;

View File

@ -18,3 +18,7 @@ Action=Popup
[Event/export-fail]
Name=Failed to export configuration
Action=Popup
[Event/switch-layout]
Name=Switch to layout
Action=Popup