mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-19 06:03:42 +03:00
9a69323293
--with this commit now Latte is able to identify what are the global shortcuts used for each activation entry and also to not show at all any badge for activation entries that are disabled from the user BUG: 397128
181 lines
5.6 KiB
C++
181 lines
5.6 KiB
C++
/*
|
|
* Copyright 2017 Smith AR <audoban@openmailbox.org>
|
|
* Michail Vourlakos <mvourlakos@gmail.com>
|
|
*
|
|
* This file is part of Latte-Dock
|
|
*
|
|
* Latte-Dock is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of
|
|
* the License, or (at your option) any later version.
|
|
*
|
|
* Latte-Dock is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef UNIVERSALSETTINGS_H
|
|
#define UNIVERSALSETTINGS_H
|
|
|
|
#include <QObject>
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <KConfigGroup>
|
|
#include <KSharedConfig>
|
|
|
|
#include "../liblattedock/dock.h"
|
|
|
|
class SortedActivitiesModel;
|
|
|
|
namespace Latte {
|
|
|
|
class LayoutManager;
|
|
|
|
//! This class holds all the settings that are universally available
|
|
//! independent of layouts
|
|
class UniversalSettings : public QObject
|
|
{
|
|
Q_OBJECT
|
|
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
|
Q_PROPERTY(bool showInfoWindow READ showInfoWindow WRITE setShowInfoWindow NOTIFY showInfoWindowChanged)
|
|
Q_PROPERTY(QString currentLayoutName READ currentLayoutName WRITE setCurrentLayoutName NOTIFY currentLayoutNameChanged)
|
|
|
|
Q_PROPERTY(QStringList badgesForActivate READ badgesForActivate NOTIFY badgesForActivateChanged)
|
|
Q_PROPERTY(QStringList launchers READ launchers WRITE setLaunchers NOTIFY launchersChanged)
|
|
|
|
Q_PROPERTY(Latte::Dock::MouseSensitivity mouseSensitivity READ mouseSensitivity WRITE setMouseSensitivity NOTIFY mouseSensitivityChanged)
|
|
|
|
Q_PROPERTY(QAbstractItemModel *runningActivitiesModel READ runningActivitiesModel NOTIFY runningActivitiesModelChanged)
|
|
public:
|
|
UniversalSettings(KSharedConfig::Ptr config, QObject *parent = nullptr);
|
|
~UniversalSettings() override;
|
|
|
|
void load();
|
|
|
|
bool autostart() const;
|
|
void setAutostart(bool state);
|
|
|
|
bool canDisableBorders() const;
|
|
void setCanDisableBorders(bool enable);
|
|
|
|
bool metaForwardedToLatte() const;
|
|
void forwardMetaToLatte(bool forward);
|
|
|
|
bool showInfoWindow() const;
|
|
void setShowInfoWindow(bool show);
|
|
|
|
int version() const;
|
|
void setVersion(int ver);
|
|
|
|
int screenTrackerInterval() const;
|
|
void setScreenTrackerInterval(int duration);
|
|
|
|
QString currentLayoutName() const;
|
|
void setCurrentLayoutName(QString layoutName);
|
|
|
|
QString lastNonAssignedLayoutName() const;
|
|
void setLastNonAssignedLayoutName(QString layoutName);
|
|
|
|
QSize downloadWindowSize() const;
|
|
void setDownloadWindowSize(QSize size);
|
|
|
|
QSize layoutsWindowSize() const;
|
|
void setLayoutsWindowSize(QSize size);
|
|
|
|
QStringList badgesForActivate() const;
|
|
|
|
QStringList layoutsColumnWidths() const;
|
|
void setLayoutsColumnWidths(QStringList widths);
|
|
|
|
QStringList launchers() const;
|
|
void setLaunchers(QStringList launcherList);
|
|
|
|
Dock::MouseSensitivity mouseSensitivity() const;
|
|
void setMouseSensitivity(Dock::MouseSensitivity sensitivity);
|
|
|
|
QAbstractItemModel *runningActivitiesModel() const;
|
|
void setRunningActivitiesModel(SortedActivitiesModel *model);
|
|
void enableActivitiesModel();
|
|
void disableActivitiesModel();
|
|
|
|
public slots:
|
|
Q_INVOKABLE QString splitterIconPath();
|
|
Q_INVOKABLE QString trademarkIconPath();
|
|
|
|
Q_INVOKABLE float luminasFromFile(QString imageFile, int edge);
|
|
|
|
signals:
|
|
void autostartChanged();
|
|
void badgesForActivateChanged();
|
|
void canDisableBordersChanged();
|
|
void currentLayoutNameChanged();
|
|
void downloadWindowSizeChanged();
|
|
void lastNonAssignedLayoutNameChanged();
|
|
void layoutsColumnWidthsChanged();
|
|
void layoutsWindowSizeChanged();
|
|
void launchersChanged();
|
|
void layoutsMemoryUsageChanged();
|
|
void mouseSensitivityChanged();
|
|
void runningActivitiesModelChanged();
|
|
void screenTrackerIntervalChanged();
|
|
void showInfoWindowChanged();
|
|
void versionChanged();
|
|
|
|
private slots:
|
|
void loadConfig();
|
|
void saveConfig();
|
|
|
|
void shortcutsFileChanged(const QString &file);
|
|
|
|
private:
|
|
void cleanupSettings();
|
|
|
|
void initGlobalShortcutsWatcher();
|
|
//! access user set global shortcuts for activate entries
|
|
void parseGlobalShortcuts();
|
|
|
|
bool kwin_metaForwardedToLatte() const;
|
|
void kwin_forwardMetaToLatte(bool forward);
|
|
|
|
Dock::LayoutsMemoryUsage layoutsMemoryUsage() const;
|
|
void setLayoutsMemoryUsage(Dock::LayoutsMemoryUsage layoutsMemoryUsage);
|
|
|
|
private:
|
|
bool m_canDisableBorders{false};
|
|
bool m_showInfoWindow{true};
|
|
|
|
//when there isnt a version it is an old universal file
|
|
int m_version{1};
|
|
|
|
int m_screenTrackerInterval{2500};
|
|
|
|
QString m_currentLayoutName;
|
|
QString m_lastNonAssignedLayoutName;
|
|
QSize m_downloadWindowSize{800, 550};
|
|
QSize m_layoutsWindowSize{700, 450};
|
|
|
|
QStringList m_badgesForActivate{"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "z", "x", "c", "v", "b", "n", "m", ",", "."};
|
|
QStringList m_layoutsColumnWidths;
|
|
QStringList m_launchers;
|
|
|
|
Dock::LayoutsMemoryUsage m_memoryUsage;
|
|
Dock::MouseSensitivity m_mouseSensitivity{Dock::HighSensitivity};
|
|
|
|
KConfigGroup m_universalGroup;
|
|
KSharedConfig::Ptr m_config;
|
|
KSharedConfig::Ptr m_shortcutsConfigPtr;
|
|
|
|
SortedActivitiesModel *m_runningActivitiesModel{nullptr};
|
|
|
|
friend class LayoutManager;
|
|
friend class DockCorona;
|
|
};
|
|
|
|
}
|
|
|
|
#endif //UNIVERSALSETTINGS_H
|