Add per-tool settings and gesture customization
This commit is contained in:
@@ -36,6 +36,23 @@ constexpr auto configFile = "plasma-org.kde.plasma.desktop-appletsrc";
|
||||
constexpr auto componentId = "se.ajpanton.plasma-task-group-shortcuts";
|
||||
constexpr auto stateFile = "plasma-task-group-shortcutsrc";
|
||||
|
||||
struct ShortcutSettings {
|
||||
bool startWithFirst = true;
|
||||
bool initialShiftOpensNewInstance = true;
|
||||
bool shiftCyclesBackward = true;
|
||||
};
|
||||
|
||||
ShortcutSettings shortcutSettings()
|
||||
{
|
||||
const auto config = KSharedConfig::openConfig(QString::fromLatin1(stateFile));
|
||||
const KConfigGroup group(config, QStringLiteral("Settings"));
|
||||
return {
|
||||
group.readEntry("StartWithFirstWindow", true),
|
||||
group.readEntry("InitialShiftOpensNewInstance", true),
|
||||
group.readEntry("ShiftCyclesBackward", true),
|
||||
};
|
||||
}
|
||||
|
||||
KConfigGroup displacedShortcutGroup(int number)
|
||||
{
|
||||
const auto config = KSharedConfig::openConfig(QString::fromLatin1(stateFile));
|
||||
@@ -282,15 +299,20 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
const ShortcutSettings settings = shortcutSettings();
|
||||
const bool continuing = row == m_lastShortcut;
|
||||
if (!continuing) {
|
||||
m_cyclePosition = 0;
|
||||
const bool backwards = shifted
|
||||
&& settings.shiftCyclesBackward
|
||||
&& !settings.initialShiftOpensNewInstance;
|
||||
m_cyclePosition = initialCyclePosition(
|
||||
m_model, tasks.at(row), settings.startWithFirst, backwards);
|
||||
} else {
|
||||
m_cyclePosition += shifted ? -1 : 1;
|
||||
m_cyclePosition += shifted && settings.shiftCyclesBackward ? -1 : 1;
|
||||
}
|
||||
m_lastShortcut = row;
|
||||
|
||||
if (shifted && !continuing) {
|
||||
if (shifted && !continuing && settings.initialShiftOpensNewInstance) {
|
||||
m_model.requestNewInstance(m_model.index(tasks.at(row), 0));
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user