Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinrules/ruleswidget.cpp
Show All 18 Lines | |||||
19 | #include "ruleswidget.h" | 19 | #include "ruleswidget.h" | ||
20 | 20 | | |||
21 | #include <klineedit.h> | 21 | #include <klineedit.h> | ||
22 | #include <kcombobox.h> | 22 | #include <kcombobox.h> | ||
23 | #include <kcolorschememanager.h> | 23 | #include <kcolorschememanager.h> | ||
24 | #include <QCheckBox> | 24 | #include <QCheckBox> | ||
25 | #include <QFileInfo> | 25 | #include <QFileInfo> | ||
26 | #include <QLabel> | 26 | #include <QLabel> | ||
27 | #include <kwindowsystem.h> | | |||
28 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
29 | #include <QRegExp> | 28 | #include <QRegExp> | ||
30 | 29 | | |||
31 | #ifdef KWIN_BUILD_ACTIVITIES | 30 | #ifdef KWIN_BUILD_ACTIVITIES | ||
32 | #include <kactivities/consumer.h> | 31 | #include <kactivities/consumer.h> | ||
33 | #endif | 32 | #endif | ||
34 | 33 | | |||
35 | #include <assert.h> | 34 | #include <assert.h> | ||
▲ Show 20 Lines • Show All 699 Lines • ▼ Show 20 Line(s) | 733 | { \ | |||
735 | Ui::RulesWidgetBase::var->uimethod( func( info )); \ | 734 | Ui::RulesWidgetBase::var->uimethod( func( info )); \ | ||
736 | } | 735 | } | ||
737 | 736 | | |||
738 | #define CHECKBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setChecked ) | 737 | #define CHECKBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setChecked ) | ||
739 | #define LINEEDIT_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setText ) | 738 | #define LINEEDIT_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setText ) | ||
740 | #define COMBOBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setCurrentIndex ) | 739 | #define COMBOBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setCurrentIndex ) | ||
741 | #define SPINBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setValue ) | 740 | #define SPINBOX_PREFILL( var, func, info ) GENERIC_PREFILL( var, func, info, setValue ) | ||
742 | 741 | | |||
743 | void RulesWidget::prefillUnusedValues(const KWindowInfo& info) | | |||
744 | { | | |||
745 | LINEEDIT_PREFILL(position, positionToStr, info.frameGeometry().topLeft()); | | |||
746 | LINEEDIT_PREFILL(size, sizeToStr, info.frameGeometry().size()); | | |||
747 | COMBOBOX_PREFILL(desktop, desktopToCombo, info.desktop()); | | |||
748 | // COMBOBOX_PREFILL(activity, activityToCombo, info.activity()); // TODO: ivan | | |||
749 | CHECKBOX_PREFILL(maximizehoriz, , info.state() & NET::MaxHoriz); | | |||
750 | CHECKBOX_PREFILL(maximizevert, , info.state() & NET::MaxVert); | | |||
751 | CHECKBOX_PREFILL(minimize, , info.isMinimized()); | | |||
752 | CHECKBOX_PREFILL(shade, , info.state() & NET::Shaded); | | |||
753 | CHECKBOX_PREFILL(fullscreen, , info.state() & NET::FullScreen); | | |||
754 | //COMBOBOX_PREFILL( placement, placementToCombo ); | | |||
755 | CHECKBOX_PREFILL(above, , info.state() & NET::KeepAbove); | | |||
756 | CHECKBOX_PREFILL(below, , info.state() & NET::KeepBelow); | | |||
757 | // noborder is only internal KWin information, so let's guess | | |||
758 | CHECKBOX_PREFILL(noborder, , info.frameGeometry() == info.geometry()); | | |||
759 | CHECKBOX_PREFILL(skiptaskbar, , info.state() & NET::SkipTaskbar); | | |||
760 | CHECKBOX_PREFILL(skippager, , info.state() & NET::SkipPager); | | |||
761 | CHECKBOX_PREFILL(skipswitcher, , info.state() & NET::SkipSwitcher); | | |||
762 | //CHECKBOX_PREFILL( acceptfocus, ); | | |||
763 | //CHECKBOX_PREFILL( closeable, ); | | |||
764 | //CHECKBOX_PREFILL( autogroup, ); | | |||
765 | //CHECKBOX_PREFILL( autogroupfg, ); | | |||
766 | //LINEEDIT_PREFILL( autogroupid, ); | | |||
767 | SPINBOX_PREFILL(opacityactive, , 100 /*get the actual opacity somehow*/); | | |||
768 | SPINBOX_PREFILL(opacityinactive, , 100 /*get the actual opacity somehow*/); | | |||
769 | //LINEEDIT_PREFILL( shortcut, ); | | |||
770 | //COMBOBOX_PREFILL( fsplevel, ); | | |||
771 | //COMBOBOX_PREFILL( fpplevel, ); | | |||
772 | COMBOBOX_PREFILL(type, typeToCombo, info.windowType(SUPPORTED_MANAGED_WINDOW_TYPES_MASK)); | | |||
773 | //CHECKBOX_PREFILL( ignoregeometry, ); | | |||
774 | LINEEDIT_PREFILL(minsize, sizeToStr, info.frameGeometry().size()); | | |||
775 | LINEEDIT_PREFILL(maxsize, sizeToStr, info.frameGeometry().size()); | | |||
776 | //CHECKBOX_PREFILL( strictgeometry, ); | | |||
777 | //CHECKBOX_PREFILL( disableglobalshortcuts, ); | | |||
778 | //CHECKBOX_PREFILL( blockcompositing, ); | | |||
779 | LINEEDIT_PREFILL(desktopfile, , info.desktopFileName()); | | |||
780 | } | | |||
781 | | ||||
782 | void RulesWidget::prefillUnusedValues(const QVariantMap& info) | 742 | void RulesWidget::prefillUnusedValues(const QVariantMap& info) | ||
783 | { | 743 | { | ||
784 | const QSize windowSize{info.value("width").toInt(), info.value("height").toInt()}; | 744 | const QSize windowSize{info.value("width").toInt(), info.value("height").toInt()}; | ||
785 | LINEEDIT_PREFILL(position, positionToStr, QPoint(info.value("x").toInt(), info.value("y").toInt())); | 745 | LINEEDIT_PREFILL(position, positionToStr, QPoint(info.value("x").toInt(), info.value("y").toInt())); | ||
786 | LINEEDIT_PREFILL(size, sizeToStr, windowSize); | 746 | LINEEDIT_PREFILL(size, sizeToStr, windowSize); | ||
787 | COMBOBOX_PREFILL(desktop, desktopToCombo, info.value("x11DesktopNumber").toInt()); | 747 | COMBOBOX_PREFILL(desktop, desktopToCombo, info.value("x11DesktopNumber").toInt()); | ||
788 | // COMBOBOX_PREFILL(activity, activityToCombo, info.activity()); // TODO: ivan | 748 | // COMBOBOX_PREFILL(activity, activityToCombo, info.activity()); // TODO: ivan | ||
789 | CHECKBOX_PREFILL(maximizehoriz, , info.value("maximizeHorizontal").toBool()); | 749 | CHECKBOX_PREFILL(maximizehoriz, , info.value("maximizeHorizontal").toBool()); | ||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 803 | i18n("You have specified the window class as unimportant.\n" | |||
844 | "This means the settings will possibly apply to windows from all applications. " | 804 | "This means the settings will possibly apply to windows from all applications. " | ||
845 | "If you really want to create a generic setting, it is recommended you at least " | 805 | "If you really want to create a generic setting, it is recommended you at least " | ||
846 | "limit the window types to avoid special window types.")) != KMessageBox::Continue) | 806 | "limit the window types to avoid special window types.")) != KMessageBox::Continue) | ||
847 | return false; | 807 | return false; | ||
848 | } | 808 | } | ||
849 | return true; | 809 | return true; | ||
850 | } | 810 | } | ||
851 | 811 | | |||
852 | void RulesWidget::prepareWindowSpecific(WId window) | 812 | void RulesWidget::prepareWindowSpecific(const QVariantMap &info) | ||
853 | { | 813 | { | ||
854 | // TODO: adjust for Wayland | | |||
855 | tabs->setCurrentIndex(1); // geometry tab, skip tab for window identification | 814 | tabs->setCurrentIndex(1); // geometry tab, skip tab for window identification | ||
856 | KWindowInfo info(window, NET::WMAllProperties, NET::WM2AllProperties); // read everything | | |||
857 | prefillUnusedValues(info); | 815 | prefillUnusedValues(info); | ||
858 | } | 816 | } | ||
859 | 817 | | |||
860 | void RulesWidget::shortcutEditClicked() | 818 | void RulesWidget::shortcutEditClicked() | ||
861 | { | 819 | { | ||
862 | QPointer<EditShortcutDialog> dlg = new EditShortcutDialog(window()); | 820 | QPointer<EditShortcutDialog> dlg = new EditShortcutDialog(window()); | ||
863 | dlg->setShortcut(shortcut->text()); | 821 | dlg->setShortcut(shortcut->text()); | ||
864 | if (dlg->exec() == QDialog::Accepted) | 822 | if (dlg->exec() == QDialog::Accepted) | ||
Show All 16 Lines | 829 | { | |||
881 | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | 839 | QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this); | ||
882 | connect(buttons, SIGNAL(accepted()), SLOT(accept())); | 840 | connect(buttons, SIGNAL(accepted()), SLOT(accept())); | ||
883 | connect(buttons, SIGNAL(rejected()), SLOT(reject())); | 841 | connect(buttons, SIGNAL(rejected()), SLOT(reject())); | ||
884 | layout()->addWidget(buttons); | 842 | layout()->addWidget(buttons); | ||
885 | } | 843 | } | ||
886 | 844 | | |||
887 | // window is set only for Alt+F3/Window-specific settings, because the dialog | 845 | // window is set only for Alt+F3/Window-specific settings, because the dialog | ||
888 | // is then related to one specific window | 846 | // is then related to one specific window | ||
889 | Rules* RulesDialog::edit(Rules* r, WId window, bool show_hints) | 847 | Rules* RulesDialog::edit(Rules* r, const QVariantMap& info, bool show_hints) | ||
890 | { | 848 | { | ||
891 | rules = r; | 849 | rules = r; | ||
892 | widget->setRules(rules); | 850 | widget->setRules(rules); | ||
893 | if (window != 0) | 851 | if (!info.isEmpty()) | ||
894 | widget->prepareWindowSpecific(window); | 852 | { | ||
853 | widget->prepareWindowSpecific(info); | ||||
854 | } | ||||
895 | if (show_hints) | 855 | if (show_hints) | ||
896 | QTimer::singleShot(0, this, SLOT(displayHints())); | 856 | QTimer::singleShot(0, this, SLOT(displayHints())); | ||
897 | exec(); | 857 | exec(); | ||
898 | return rules; | 858 | return rules; | ||
899 | } | 859 | } | ||
900 | 860 | | |||
901 | void RulesDialog::displayHints() | 861 | void RulesDialog::displayHints() | ||
902 | { | 862 | { | ||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |