option/define who will be used at global shortcuts

--add an option in Tweaks page in order for the user
to define which dock/panel will have the highest priority
for global shortcuts activation. This option can be
used is per layout basis. Each layout can have its own
high priority dock/panel for Latte unified shortcuts.

BUG: 398914
pull/2/head
Michail Vourlakos 6 years ago
parent 4732f7f1b1
commit 64a40429a4

@ -213,8 +213,10 @@ void DockView::init()
connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry);
connect(this, &DockView::offsetChanged, this, &DockView::syncGeometry);
connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders);
connect(this, &DockView::dockWinBehaviorChanged, this, &DockView::saveConfig);
connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig);
connect(this, &DockView::isPreferredForShortcutsChanged, this, &DockView::saveConfig);
connect(this, &DockView::locationChanged, this, [&]() {
updateFormFactor();
@ -1151,6 +1153,32 @@ void DockView::setInEditMode(bool edit)
emit inEditModeChanged();
}
bool DockView::isPreferredForShortcuts() const
{
return m_isPreferredForShortcuts;
}
void DockView::setIsPreferredForShortcuts(bool preferred)
{
if (m_isPreferredForShortcuts == preferred) {
return;
}
m_isPreferredForShortcuts = preferred;
emit isPreferredForShortcutsChanged();
if (m_isPreferredForShortcuts && m_managedLayout) {
emit m_managedLayout->preferredViewForShortcutsChanged(this);
}
}
void DockView::preferredViewForShortcutsChangedSlot(DockView *view)
{
if (view != this) {
setIsPreferredForShortcuts(false);
}
}
bool DockView::onPrimary() const
{
@ -1445,12 +1473,14 @@ void DockView::setManagedLayout(Layout *layout)
emit activitiesChanged();
}
});
connectionsManagedLayout[0] = connect(m_managedLayout, &Layout::preferredViewForShortcutsChanged, this, &DockView::preferredViewForShortcutsChangedSlot);
}
DockCorona *dockCorona = qobject_cast<DockCorona *>(this->corona());
if (dockCorona->layoutManager()->memoryUsage() == Dock::MultipleLayouts) {
connectionsManagedLayout[0] = connect(dockCorona->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged, this, [&]() {
connectionsManagedLayout[1] = connect(dockCorona->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged, this, [&]() {
if (m_managedLayout && m_visibility) {
qDebug() << "DOCK VIEW FROM LAYOUT (runningActivitiesChanged) ::: " << m_managedLayout->name()
<< " - activities: " << m_managedLayout->appliedActivities();
@ -1459,14 +1489,14 @@ void DockView::setManagedLayout(Layout *layout)
}
});
connectionsManagedLayout[1] = connect(m_managedLayout, &Layout::activitiesChanged, this, [&]() {
connectionsManagedLayout[2] = connect(m_managedLayout, &Layout::activitiesChanged, this, [&]() {
if (m_managedLayout) {
applyActivitiesToWindows();
emit activitiesChanged();
}
});
connectionsManagedLayout[2] = connect(dockCorona->layoutManager(), &LayoutManager::layoutsChanged, this, [&]() {
connectionsManagedLayout[3] = connect(dockCorona->layoutManager(), &LayoutManager::layoutsChanged, this, [&]() {
if (m_managedLayout) {
applyActivitiesToWindows();
emit activitiesChanged();
@ -1475,7 +1505,7 @@ void DockView::setManagedLayout(Layout *layout)
//!IMPORTANT!!! ::: This fixes a bug when closing an Activity all docks from all Activities are
//! disappearing! With this they reappear!!!
connectionsManagedLayout[3] = connect(this, &QWindow::visibleChanged, this, [&]() {
connectionsManagedLayout[4] = connect(this, &QWindow::visibleChanged, this, [&]() {
if (!isVisible() && m_managedLayout) {
QTimer::singleShot(100, [this]() {
if (m_managedLayout && containment() && !containment()->destroyed()) {
@ -1934,6 +1964,7 @@ void DockView::saveConfig()
auto config = this->containment()->config();
config.writeEntry("onPrimary", onPrimary());
config.writeEntry("dockWindowBehavior", dockWinBehavior());
config.writeEntry("isPreferredForShortcuts", isPreferredForShortcuts());
config.sync();
}
@ -1945,6 +1976,7 @@ void DockView::restoreConfig()
auto config = this->containment()->config();
m_onPrimary = config.readEntry("onPrimary", true);
m_dockWinBehavior = config.readEntry("dockWindowBehavior", true);
m_isPreferredForShortcuts = config.readEntry("isPreferredForShortcuts", false);
//! Send changed signals at the end in order to be sure that saveConfig
//! wont rewrite default/invalid values

@ -73,6 +73,7 @@ class DockView : public PlasmaQuick::ContainmentView
//! Because Latte uses animations, changing to edit mode it may be different than
//! when the isUserConfiguring changes value
Q_PROPERTY(bool inEditMode READ inEditMode WRITE setInEditMode NOTIFY inEditModeChanged)
Q_PROPERTY(bool isPreferredForShortcuts READ isPreferredForShortcuts WRITE setIsPreferredForShortcuts NOTIFY isPreferredForShortcutsChanged)
Q_PROPERTY(bool themeHasShadow READ themeHasShadow NOTIFY themeHasShadowChanged)
Q_PROPERTY(bool onPrimary READ onPrimary WRITE setOnPrimary NOTIFY onPrimaryChanged)
@ -151,6 +152,9 @@ public:
bool inEditMode() const;
void setInEditMode(bool edit);
bool isPreferredForShortcuts() const;
void setIsPreferredForShortcuts(bool preferred);
bool themeHasShadow() const;
float maxLength() const;
@ -286,6 +290,7 @@ signals:
void widthChanged();
void heightChanged();
void inEditModeChanged();
void isPreferredForShortcutsChanged();
void localGeometryChanged();
void managedLayoutChanged();
void maxLengthChanged();
@ -308,6 +313,7 @@ signals:
private slots:
void availableScreenRectChanged();
void hideWindowsForSlidingOut();
void preferredViewForShortcutsChangedSlot(DockView *view);
void statusChanged(Plasma::Types::ItemStatus);
void screenChanged(QScreen *screen);
void updateEffects();
@ -339,6 +345,7 @@ private:
bool m_forceDrawCenteredBorders{false};
bool m_inDelete{false};
bool m_inEditMode{false};
bool m_isPreferredForShortcuts{false};
bool m_onPrimary{true};
int m_dockTransparency{100};
int m_fontPixelSize{ -1};
@ -370,7 +377,7 @@ private:
QTimer m_validateGeometryTimer;
//! Connections to release and bound for the managed layout
std::array<QMetaObject::Connection, 4> connectionsManagedLayout;
std::array<QMetaObject::Connection, 5> connectionsManagedLayout;
//!used at sliding out/in animation
QString m_moveToLayout;

@ -802,10 +802,24 @@ QList<DockView *> GlobalShortcuts::sortedViewsList(QHash<const Plasma::Containme
}
}
DockView *highestPriorityView{nullptr};
for (int i = 0; i < docks.size(); ++i) {
if (docks[i]->isPreferredForShortcuts()) {
highestPriorityView = docks[i];
docks.removeAt(i);
break;
}
}
if (highestPriorityView) {
docks.prepend(highestPriorityView);
}
qDebug() << " -------- sorted -----";
for (int i = 0; i < docks.count(); ++i) {
qDebug() << i << ". " << docks[i]->screen()->name() << " - " << docks[i]->location();
qDebug() << i << ". " << docks[i]->isPreferredForShortcuts() << " - " << docks[i]->screen()->name() << " - " << docks[i]->location();
}
return docks;

@ -164,6 +164,10 @@ signals:
void showInMenuChanged();
void textColorChanged();
//! used from DockView(s) in order to exist only one each time that has the highest priority
//! to use the global shortcuts activations
void preferredViewForShortcutsChanged(DockView *view);
private slots:
void loadConfig();
void saveConfig();

@ -166,7 +166,7 @@ PlasmaComponents.Page {
text: i18n("Activate KWin edge after hiding")
checked: dock.visibility.enableKWinEdges
onCheckedChanged: {
onClicked: {
dock.visibility.enableKWinEdges = checked;
}
}
@ -194,6 +194,18 @@ PlasmaComponents.Page {
}
}
PlasmaComponents.CheckBox {
Layout.leftMargin: units.smallSpacing * 2
text: i18n("Prefer for global shortcuts activation")
checked: dock.isPreferredForShortcuts
tooltip: i18n("Enable highest priority for global shortcuts activation")
onClicked: {
dock.isPreferredForShortcuts = checked
}
}
PlasmaComponents.CheckBox {
Layout.leftMargin: units.smallSpacing * 2
text: i18n("Behave as a normal dock window")

Loading…
Cancel
Save