Changeset View
Changeset View
Standalone View
Standalone View
tabbox/tabbox.cpp
Show First 20 Lines • Show All 809 Lines • ▼ Show 20 Line(s) | 807 | foreach (const QString &s, list) { | |||
---|---|---|---|---|---|
810 | if (!ok) | 810 | if (!ok) | ||
811 | continue; | 811 | continue; | ||
812 | borders->append(ElectricBorder(i)); | 812 | borders->append(ElectricBorder(i)); | ||
813 | ScreenEdges::self()->reserve(ElectricBorder(i), this, "toggle"); | 813 | ScreenEdges::self()->reserve(ElectricBorder(i), this, "toggle"); | ||
814 | } | 814 | } | ||
815 | borders = &m_borderAlternativeActivate; | 815 | borders = &m_borderAlternativeActivate; | ||
816 | borderConfig = QStringLiteral("BorderAlternativeActivate"); | 816 | borderConfig = QStringLiteral("BorderAlternativeActivate"); | ||
817 | } | 817 | } | ||
818 | | ||||
819 | auto touchConfig = [this, config] (const QString &key, QHash<ElectricBorder, QAction *> &actions, TabBoxMode mode) { | ||||
820 | // fist erase old config | ||||
821 | for (auto it = actions.begin(); it != actions.end(); ) { | ||||
822 | delete it.value(); | ||||
823 | it = actions.erase(it); | ||||
824 | } | ||||
825 | // now new config | ||||
826 | const QStringList list = config.readEntry(key, QStringList()); | ||||
827 | for (const auto &s : list) { | ||||
828 | bool ok; | ||||
829 | const int i = s.toInt(&ok); | ||||
830 | if (!ok) { | ||||
831 | continue; | ||||
832 | } | ||||
833 | QAction *a = new QAction(this); | ||||
834 | connect(a, &QAction::triggered, this, std::bind(&TabBox::toggleMode, this, mode)); | ||||
835 | ScreenEdges::self()->reserveTouch(ElectricBorder(i), a); | ||||
836 | actions.insert(ElectricBorder(i), a); | ||||
837 | } | ||||
838 | }; | ||||
839 | touchConfig(QStringLiteral("TouchBorderActivate"), m_touchActivate, TabBoxWindowsMode); | ||||
840 | touchConfig(QStringLiteral("TouchBorderAlternativeActivate"), m_touchAlternativeActivate, TabBoxWindowsAlternativeMode); | ||||
818 | } | 841 | } | ||
819 | 842 | | |||
820 | void TabBox::loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig) | 843 | void TabBox::loadConfig(const KConfigGroup& config, TabBoxConfig& tabBoxConfig) | ||
821 | { | 844 | { | ||
822 | tabBoxConfig.setClientDesktopMode(TabBoxConfig::ClientDesktopMode( | 845 | tabBoxConfig.setClientDesktopMode(TabBoxConfig::ClientDesktopMode( | ||
823 | config.readEntry<int>("DesktopMode", TabBoxConfig::defaultDesktopMode()))); | 846 | config.readEntry<int>("DesktopMode", TabBoxConfig::defaultDesktopMode()))); | ||
824 | tabBoxConfig.setClientActivitiesMode(TabBoxConfig::ClientActivitiesMode( | 847 | tabBoxConfig.setClientActivitiesMode(TabBoxConfig::ClientActivitiesMode( | ||
825 | config.readEntry<int>("ActivitiesMode", TabBoxConfig::defaultActivitiesMode()))); | 848 | config.readEntry<int>("ActivitiesMode", TabBoxConfig::defaultActivitiesMode()))); | ||
▲ Show 20 Lines • Show All 390 Lines • ▼ Show 20 Line(s) | |||||
1216 | void TabBox::shadeActivate(AbstractClient *c) | 1239 | void TabBox::shadeActivate(AbstractClient *c) | ||
1217 | { | 1240 | { | ||
1218 | if ((c->shadeMode() == ShadeNormal || c->shadeMode() == ShadeHover) && options->isShadeHover()) | 1241 | if ((c->shadeMode() == ShadeNormal || c->shadeMode() == ShadeHover) && options->isShadeHover()) | ||
1219 | c->setShade(ShadeActivated); | 1242 | c->setShade(ShadeActivated); | ||
1220 | } | 1243 | } | ||
1221 | 1244 | | |||
1222 | bool TabBox::toggle(ElectricBorder eb) | 1245 | bool TabBox::toggle(ElectricBorder eb) | ||
1223 | { | 1246 | { | ||
1247 | if (m_borderAlternativeActivate.contains(eb)) { | ||||
1248 | return toggleMode(TabBoxWindowsAlternativeMode); | ||||
1249 | } else { | ||||
1250 | return toggleMode(TabBoxWindowsMode); | ||||
1251 | } | ||||
1252 | } | ||||
1253 | | ||||
1254 | bool TabBox::toggleMode(TabBoxMode mode) | ||||
1255 | { | ||||
1224 | if (!options->focusPolicyIsReasonable()) | 1256 | if (!options->focusPolicyIsReasonable()) | ||
1225 | return false; // not supported. | 1257 | return false; // not supported. | ||
1226 | if (isDisplayed()) { | 1258 | if (isDisplayed()) { | ||
1227 | accept(); | 1259 | accept(); | ||
1228 | return true; | 1260 | return true; | ||
1229 | } | 1261 | } | ||
1230 | if (!establishTabBoxGrab()) | 1262 | if (!establishTabBoxGrab()) | ||
1231 | return false; | 1263 | return false; | ||
1232 | m_noModifierGrab = m_tabGrab = true; | 1264 | m_noModifierGrab = m_tabGrab = true; | ||
1233 | if (m_borderAlternativeActivate.contains(eb)) | 1265 | setMode(mode); | ||
1234 | setMode(TabBoxWindowsAlternativeMode); | | |||
1235 | else | | |||
1236 | setMode(TabBoxWindowsMode); | | |||
1237 | reset(); | 1266 | reset(); | ||
1238 | show(); | 1267 | show(); | ||
1239 | return true; | 1268 | return true; | ||
1240 | } | 1269 | } | ||
1241 | 1270 | | |||
1242 | bool TabBox::startKDEWalkThroughWindows(TabBoxMode mode) | 1271 | bool TabBox::startKDEWalkThroughWindows(TabBoxMode mode) | ||
1243 | { | 1272 | { | ||
1244 | if (!establishTabBoxGrab()) | 1273 | if (!establishTabBoxGrab()) | ||
▲ Show 20 Lines • Show All 432 Lines • Show Last 20 Lines |