Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinoptions/windows.cpp
Show All 31 Lines | |||||
32 | #include <QtDBus> | 32 | #include <QtDBus> | ||
33 | #include <QGroupBox> | 33 | #include <QGroupBox> | ||
34 | 34 | | |||
35 | #include <KConfig> | 35 | #include <KConfig> | ||
36 | #include <KConfigGroup> | 36 | #include <KConfigGroup> | ||
37 | #include <KLocalizedString> | 37 | #include <KLocalizedString> | ||
38 | 38 | | |||
39 | #include "windows.h" | 39 | #include "windows.h" | ||
40 | #include "kwinoptions_settings.h" | ||||
40 | #include <effect_builtins.h> | 41 | #include <effect_builtins.h> | ||
41 | #include <kwin_effects_interface.h> | 42 | #include <kwin_effects_interface.h> | ||
42 | 43 | | |||
43 | // kwin config keywords | 44 | // kwin config keywords | ||
44 | #define KWIN_FOCUS "FocusPolicy" | 45 | #define KWIN_FOCUS "FocusPolicy" | ||
45 | #define KWIN_PLACEMENT "Placement" | 46 | #define KWIN_PLACEMENT "Placement" | ||
46 | #define KWIN_GEOMETRY "GeometryTip" | | |||
47 | #define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval" | 47 | #define KWIN_AUTORAISE_INTERVAL "AutoRaiseInterval" | ||
48 | #define KWIN_AUTORAISE "AutoRaise" | 48 | #define KWIN_AUTORAISE "AutoRaise" | ||
49 | #define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval" | 49 | #define KWIN_DELAYFOCUS_INTERVAL "DelayFocusInterval" | ||
50 | #define KWIN_CLICKRAISE "ClickRaise" | 50 | #define KWIN_CLICKRAISE "ClickRaise" | ||
51 | #define KWIN_SHADEHOVER "ShadeHover" | 51 | #define KWIN_SHADEHOVER "ShadeHover" | ||
52 | #define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval" | 52 | #define KWIN_SHADEHOVER_INTERVAL "ShadeHoverInterval" | ||
53 | #define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel" | 53 | #define KWIN_FOCUS_STEALING "FocusStealingPreventionLevel" | ||
54 | #define KWIN_HIDE_UTILITY "HideUtilityWindowsForInactive" | 54 | #define KWIN_HIDE_UTILITY "HideUtilityWindowsForInactive" | ||
55 | #define KWIN_INACTIVE_SKIP_TASKBAR "InactiveTabsSkipTaskbar" | 55 | #define KWIN_INACTIVE_SKIP_TASKBAR "InactiveTabsSkipTaskbar" | ||
56 | #define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus" | 56 | #define KWIN_SEPARATE_SCREEN_FOCUS "SeparateScreenFocus" | ||
57 | #define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen" | 57 | #define KWIN_ACTIVE_MOUSE_SCREEN "ActiveMouseScreen" | ||
58 | 58 | | |||
59 | //CT 15mar 98 - magics | | |||
60 | #define KWM_BRDR_SNAP_ZONE "BorderSnapZone" | | |||
61 | #define KWM_BRDR_SNAP_ZONE_DEFAULT 10 | | |||
62 | #define KWM_WNDW_SNAP_ZONE "WindowSnapZone" | | |||
63 | #define KWM_WNDW_SNAP_ZONE_DEFAULT 10 | | |||
64 | #define KWM_CNTR_SNAP_ZONE "CenterSnapZone" | | |||
65 | #define KWM_CNTR_SNAP_ZONE_DEFAULT 0 | | |||
66 | | ||||
67 | #define MAX_BRDR_SNAP 100 | | |||
68 | #define MAX_WNDW_SNAP 100 | | |||
69 | #define MAX_CNTR_SNAP 100 | | |||
70 | #define MAX_EDGE_RES 1000 | | |||
71 | | ||||
72 | #define CLICK_TO_FOCUS 0 | 59 | #define CLICK_TO_FOCUS 0 | ||
73 | #define FOCUS_FOLLOWS_MOUSE 2 | 60 | #define FOCUS_FOLLOWS_MOUSE 2 | ||
74 | #define FOCUS_UNDER_MOUSE 4 | 61 | #define FOCUS_UNDER_MOUSE 4 | ||
75 | #define FOCUS_STRICTLY_UNDER_MOUSE 5 | 62 | #define FOCUS_STRICTLY_UNDER_MOUSE 5 | ||
76 | 63 | | |||
77 | 64 | | |||
78 | KFocusConfig::~KFocusConfig() | 65 | KFocusConfig::~KFocusConfig() | ||
79 | { | 66 | { | ||
▲ Show 20 Lines • Show All 411 Lines • ▼ Show 20 Line(s) | |||||
491 | } | 478 | } | ||
492 | 479 | | |||
493 | KMovingConfig::~KMovingConfig() | 480 | KMovingConfig::~KMovingConfig() | ||
494 | { | 481 | { | ||
495 | if (standAlone) | 482 | if (standAlone) | ||
496 | delete config; | 483 | delete config; | ||
497 | } | 484 | } | ||
498 | 485 | | |||
499 | KMovingConfig::KMovingConfig(bool _standAlone, KConfig *_config, QWidget *parent) | 486 | KMovingConfig::KMovingConfig(bool _standAlone, QWidget *parent) | ||
500 | : KCModule(parent), config(_config), standAlone(_standAlone) | 487 | : KCModule(parent), config(new KWinOptionsSettings), standAlone(_standAlone) | ||
501 | , m_ui(new KWinMovingConfigForm(this)) | 488 | , m_ui(new KWinMovingConfigForm(this)) | ||
502 | { | 489 | { | ||
503 | // Any changes goes to slotChanged() | 490 | addConfig(config, m_ui); | ||
504 | connect(m_ui->geometryTipOn, SIGNAL(clicked()), SLOT(changed())); | | |||
505 | connect(m_ui->borderSnap, SIGNAL(valueChanged(int)), SLOT(changed())); | | |||
506 | connect(m_ui->windowSnap, SIGNAL(valueChanged(int)), SLOT(changed())); | | |||
507 | connect(m_ui->centerSnap, SIGNAL(valueChanged(int)), SLOT(changed())); | | |||
508 | connect(m_ui->OverlapSnap, SIGNAL(clicked()), SLOT(changed())); | | |||
509 | | ||||
510 | load(); | 491 | load(); | ||
511 | } | 492 | } | ||
512 | 493 | | |||
513 | void KMovingConfig::setGeometryTip(bool showGeometryTip) | | |||
514 | { | | |||
515 | m_ui->geometryTipOn->setChecked(showGeometryTip); | | |||
516 | } | | |||
517 | | ||||
518 | bool KMovingConfig::getGeometryTip() | | |||
519 | { | | |||
520 | return m_ui->geometryTipOn->isChecked(); | | |||
521 | } | | |||
522 | | ||||
523 | void KMovingConfig::showEvent(QShowEvent *ev) | 494 | void KMovingConfig::showEvent(QShowEvent *ev) | ||
524 | { | 495 | { | ||
525 | if (!standAlone) { | 496 | if (!standAlone) { | ||
526 | QWidget::showEvent(ev); | 497 | QWidget::showEvent(ev); | ||
527 | return; | 498 | return; | ||
528 | } | 499 | } | ||
529 | KCModule::showEvent(ev); | 500 | KCModule::showEvent(ev); | ||
530 | } | 501 | } | ||
531 | 502 | | |||
532 | void KMovingConfig::load(void) | | |||
533 | { | | |||
534 | QString key; | | |||
535 | | ||||
536 | KConfigGroup cg(config, "Windows"); | | |||
537 | | ||||
538 | //KS 10Jan2003 - Geometry Tip during window move/resize | | |||
539 | bool showGeomTip = cg.readEntry(KWIN_GEOMETRY, false); | | |||
540 | setGeometryTip(showGeomTip); | | |||
541 | | ||||
542 | | ||||
543 | int v; | | |||
544 | | ||||
545 | v = cg.readEntry(KWM_BRDR_SNAP_ZONE, KWM_BRDR_SNAP_ZONE_DEFAULT); | | |||
546 | if (v > MAX_BRDR_SNAP) setBorderSnapZone(MAX_BRDR_SNAP); | | |||
547 | else if (v < 0) setBorderSnapZone(0); | | |||
548 | else setBorderSnapZone(v); | | |||
549 | | ||||
550 | v = cg.readEntry(KWM_WNDW_SNAP_ZONE, KWM_WNDW_SNAP_ZONE_DEFAULT); | | |||
551 | if (v > MAX_WNDW_SNAP) setWindowSnapZone(MAX_WNDW_SNAP); | | |||
552 | else if (v < 0) setWindowSnapZone(0); | | |||
553 | else setWindowSnapZone(v); | | |||
554 | | ||||
555 | v = cg.readEntry(KWM_CNTR_SNAP_ZONE, KWM_CNTR_SNAP_ZONE_DEFAULT); | | |||
556 | if (v > MAX_CNTR_SNAP) setCenterSnapZone(MAX_CNTR_SNAP); | | |||
557 | else if (v < 0) setCenterSnapZone(0); | | |||
558 | else setCenterSnapZone(v); | | |||
559 | | ||||
560 | m_ui->OverlapSnap->setChecked(cg.readEntry("SnapOnlyWhenOverlapping", false)); | | |||
561 | emit KCModule::changed(false); | | |||
562 | } | | |||
563 | | ||||
564 | void KMovingConfig::save(void) | 503 | void KMovingConfig::save(void) | ||
565 | { | 504 | { | ||
566 | KConfigGroup cg(config, "Windows"); | 505 | config->save(); | ||
567 | cg.writeEntry(KWIN_GEOMETRY, getGeometryTip()); | | |||
568 | | ||||
569 | | ||||
570 | cg.writeEntry(KWM_BRDR_SNAP_ZONE, getBorderSnapZone()); | | |||
571 | cg.writeEntry(KWM_WNDW_SNAP_ZONE, getWindowSnapZone()); | | |||
572 | cg.writeEntry(KWM_CNTR_SNAP_ZONE, getCenterSnapZone()); | | |||
573 | cg.writeEntry("SnapOnlyWhenOverlapping", m_ui->OverlapSnap->isChecked()); | | |||
574 | | ||||
575 | const bool geometryTip = getGeometryTip(); | | |||
576 | KConfigGroup(config, "Plugins").writeEntry("windowgeometryEnabled", geometryTip); | | |||
577 | 506 | | |||
578 | if (standAlone) { | 507 | if (standAlone) { | ||
579 | config->sync(); | | |||
580 | // Send signal to all kwin instances | 508 | // Send signal to all kwin instances | ||
zzag: Please don't commit commented code unless there is a reason, in which case the reason must be… | |||||
581 | QDBusMessage message = | 509 | QDBusMessage message = | ||
582 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | 510 | QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | ||
583 | QDBusConnection::sessionBus().send(message); | 511 | QDBusConnection::sessionBus().send(message); | ||
584 | } | 512 | } | ||
585 | // and reconfigure the effect | 513 | // and reconfigure the effect | ||
586 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | 514 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | ||
587 | QStringLiteral("/Effects"), | 515 | QStringLiteral("/Effects"), | ||
588 | QDBusConnection::sessionBus()); | 516 | QDBusConnection::sessionBus()); | ||
589 | if (geometryTip) { | 517 | if (config->geometryTip()) { | ||
590 | interface.loadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); | 518 | interface.loadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); | ||
591 | } else { | 519 | } else { | ||
592 | interface.unloadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); | 520 | interface.unloadEffect(KWin::BuiltInEffects::nameForEffect(KWin::BuiltInEffect::WindowGeometry)); | ||
593 | } | 521 | } | ||
594 | emit KCModule::changed(false); | | |||
595 | } | | |||
596 | | ||||
597 | void KMovingConfig::defaults() | | |||
598 | { | | |||
599 | setGeometryTip(false); | | |||
600 | | ||||
601 | //copied from kcontrol/konq/kwindesktop, aleXXX | | |||
602 | setWindowSnapZone(KWM_WNDW_SNAP_ZONE_DEFAULT); | | |||
603 | setBorderSnapZone(KWM_BRDR_SNAP_ZONE_DEFAULT); | | |||
604 | setCenterSnapZone(KWM_CNTR_SNAP_ZONE_DEFAULT); | | |||
605 | m_ui->OverlapSnap->setChecked(false); | | |||
606 | | ||||
607 | emit KCModule::changed(true); | | |||
608 | } | | |||
609 | | ||||
610 | int KMovingConfig::getBorderSnapZone() | | |||
611 | { | | |||
612 | return m_ui->borderSnap->value(); | | |||
613 | } | | |||
614 | | ||||
615 | void KMovingConfig::setBorderSnapZone(int pxls) | | |||
616 | { | | |||
617 | m_ui->borderSnap->setValue(pxls); | | |||
618 | } | 522 | } | ||
619 | | ||||
620 | int KMovingConfig::getWindowSnapZone() | | |||
621 | { | | |||
622 | return m_ui->windowSnap->value(); | | |||
623 | } | | |||
624 | | ||||
625 | void KMovingConfig::setWindowSnapZone(int pxls) | | |||
626 | { | | |||
627 | m_ui->windowSnap->setValue(pxls); | | |||
628 | } | | |||
629 | | ||||
630 | int KMovingConfig::getCenterSnapZone() | | |||
631 | { | | |||
632 | return m_ui->centerSnap->value(); | | |||
633 | } | | |||
634 | | ||||
635 | void KMovingConfig::setCenterSnapZone(int pxls) | | |||
636 | { | | |||
637 | m_ui->centerSnap->setValue(pxls); | | |||
638 | } | | |||
639 | |
Please don't commit commented code unless there is a reason, in which case the reason must be stated in a comment or something.