File indexing completed on 2024-11-10 04:56:52

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2009 Martin Gräßlin <mgraesslin@kde.org>
0006     SPDX-FileCopyrightText: 2020 Cyril Rossi <cyril.rossi@enioka.com>
0007     SPDX-FileCopyrightText: 2023 Ismael Asensio <isma.af@gmail.com>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #pragma once
0013 
0014 #include <QStandardItemModel>
0015 #include <QWidget>
0016 
0017 #include "tabbox/tabboxconfig.h"
0018 
0019 namespace Ui
0020 {
0021 class KWinTabBoxConfigForm;
0022 }
0023 
0024 namespace KWin
0025 {
0026 
0027 namespace TabBox
0028 {
0029 class TabBoxSettings;
0030 class ShortcutSettings;
0031 }
0032 
0033 class KWinTabBoxConfigForm : public QWidget
0034 {
0035     Q_OBJECT
0036 
0037 public:
0038     enum class TabboxType {
0039         Main,
0040         Alternative,
0041     };
0042 
0043     enum EffectComboRole {
0044         LayoutPath = Qt::UserRole + 1,
0045         AddonEffect, // i.e not builtin effects
0046     };
0047 
0048     explicit KWinTabBoxConfigForm(TabboxType type, TabBox::TabBoxSettings *config, TabBox::ShortcutSettings *shortcutsConfig, QWidget *parent = nullptr);
0049     ~KWinTabBoxConfigForm() override;
0050 
0051     TabBox::TabBoxSettings *config() const;
0052     bool highlightWindows() const;
0053 
0054     void updateUiFromConfig();
0055     void setDefaultIndicatorVisible(bool visible);
0056 
0057     // EffectCombo Data Model
0058     void setEffectComboModel(QStandardItemModel *model);
0059     QVariant effectComboCurrentData(int role = Qt::UserRole) const;
0060 
0061 Q_SIGNALS:
0062     void configChanged();
0063     void effectConfigButtonClicked();
0064 
0065 private Q_SLOTS:
0066     void tabBoxToggled(bool on);
0067     void onFilterScreen();
0068     void onFilterDesktop();
0069     void onFilterActivites();
0070     void onFilterMinimization();
0071     void onApplicationMode();
0072     void onOrderMinimizedMode();
0073     void onShowDesktopMode();
0074     void onSwitchingMode();
0075     void onEffectCombo();
0076     void onShortcutChanged(const QKeySequence &seq);
0077     void updateDefaultIndicators();
0078 
0079 private:
0080     void setEnabledUi();
0081     void applyDefaultIndicator(QList<QWidget *> widgets, bool visible);
0082 
0083     // UI property getters
0084     bool showTabBox() const;
0085     int filterScreen() const;
0086     int filterDesktop() const;
0087     int filterActivities() const;
0088     int filterMinimization() const;
0089     int applicationMode() const;
0090     int orderMinimizedMode() const;
0091     int showDesktopMode() const;
0092     int switchingMode() const;
0093     QString layoutName() const;
0094 
0095     // UI property setters
0096     void setFilterScreen(TabBox::TabBoxConfig::ClientMultiScreenMode mode);
0097     void setFilterDesktop(TabBox::TabBoxConfig::ClientDesktopMode mode);
0098     void setFilterActivities(TabBox::TabBoxConfig::ClientActivitiesMode mode);
0099     void setFilterMinimization(TabBox::TabBoxConfig::ClientMinimizedMode mode);
0100     void setApplicationMode(TabBox::TabBoxConfig::ClientApplicationsMode mode);
0101     void setOrderMinimizedMode(TabBox::TabBoxConfig::OrderMinimizedMode mode);
0102     void setShowDesktopMode(TabBox::TabBoxConfig::ShowDesktopMode mode);
0103     void setSwitchingModeChanged(TabBox::TabBoxConfig::ClientSwitchingMode mode);
0104     void setLayoutName(const QString &layoutName);
0105 
0106 private:
0107     TabBox::TabBoxSettings *m_config = nullptr;
0108     TabBox::ShortcutSettings *m_shortcuts = nullptr;
0109     bool m_showDefaultIndicator = false;
0110 
0111     bool m_isHighlightWindowsEnabled = true;
0112     Ui::KWinTabBoxConfigForm *ui;
0113 };
0114 
0115 } // namespace