1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-13 05:17:48 +03:00
latte-dock/app/dockview.h

160 lines
4.5 KiB
C
Raw Normal View History

/*
2017-01-03 01:05:30 +03:00
* Copyright 2016 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 NOWDOCKVIEW_H
#define NOWDOCKVIEW_H
#include "plasmaquick/configview.h"
#include "plasmaquick/containmentview.h"
#include "visibilitymanager.h"
#include <QQuickView>
#include <QQmlListProperty>
#include <QMenu>
#include <QScreen>
#include <QPointer>
#include <QTimer>
namespace Plasma {
class Types;
class Corona;
class Containment;
}
2016-12-30 10:20:06 +03:00
namespace Latte {
2016-12-31 00:25:27 +03:00
class DockView : public PlasmaQuick::ContainmentView {
Q_OBJECT
2017-01-16 22:07:49 +03:00
Q_PROPERTY(int docksCount READ docksCount NOTIFY docksCountChanged)
2017-01-13 02:54:23 +03:00
Q_PROPERTY(int width READ width NOTIFY widthChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged)
Q_PROPERTY(int normalThickness READ normalThickness WRITE setNormalThickness NOTIFY normalThicknessChanged)
Q_PROPERTY(int shadow READ shadow WRITE setShadow NOTIFY shadowChanged)
Q_PROPERTY(QStringList debugFlags READ debugFlags NOTIFY debugFlagsChanged)
2017-01-16 22:07:49 +03:00
Q_PROPERTY(QRect maskArea READ maskArea WRITE setMaskArea NOTIFY maskAreaChanged)
Q_PROPERTY(VisibilityManager *visibility READ visibility NOTIFY visibilityChanged)
Q_PROPERTY(QQmlListProperty<QScreen> screens READ screens)
2017-01-16 22:07:49 +03:00
public:
2016-12-31 00:25:27 +03:00
DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr);
virtual ~DockView();
2017-01-16 22:07:49 +03:00
void init();
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void adaptToScreen(QScreen *screen);
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void resizeWindow();
void syncGeometry();
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
int currentThickness() const;
void updateAbsDockGeometry();
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
int docksCount() const;
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
int maxThickness() const;
void setMaxThickness(int thickness);
2017-01-16 22:07:49 +03:00
int normalThickness() const;
void setNormalThickness(int thickness);
int shadow() const;
void setShadow(int shadow);
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
QRect maskArea() const;
void setMaskArea(QRect area);
2017-01-16 22:07:49 +03:00
QStringList debugFlags() const;
2017-01-13 02:54:23 +03:00
VisibilityManager *visibility();
2017-01-16 22:07:49 +03:00
QQmlListProperty<QScreen> screens();
static int countScreens(QQmlListProperty<QScreen> *property);
static QScreen *atScreens(QQmlListProperty<QScreen> *property, int index);
2017-01-16 22:07:49 +03:00
public slots:
Q_INVOKABLE void addNewDock();
2016-12-25 17:18:31 +03:00
Q_INVOKABLE void removeDock();
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
Q_INVOKABLE QList<int> freeEdges() const;
Q_INVOKABLE QVariantList containmentActions();
2016-12-31 03:26:48 +03:00
Q_INVOKABLE void setLocalDockGeometry(const QRect &geometry);
Q_INVOKABLE bool tasksPresent();
2017-01-16 22:07:49 +03:00
Q_INVOKABLE void closeApplication();
2017-01-16 22:07:49 +03:00
protected slots:
void showConfigurationInterface(Plasma::Applet *applet) override;
2017-01-16 22:07:49 +03:00
protected:
bool event(QEvent *ev) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
2017-01-16 22:07:49 +03:00
signals:
2016-12-29 16:41:00 +03:00
void addInternalViewSplitter();
2017-01-13 02:54:23 +03:00
void removeInternalViewSplitter();
void eventTriggered(QEvent *ev);
2017-01-16 22:07:49 +03:00
void debugFlagsChanged();
void dockLocationChanged();
2017-01-13 02:54:23 +03:00
void docksCountChanged();
void widthChanged();
void heightChanged();
void maxThicknessChanged();
void normalThicknessChanged();
void visibilityChanged();
2017-01-13 02:54:23 +03:00
void maskAreaChanged();
void shadowChanged();
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void localDockGeometryChanged();
2017-01-16 22:07:49 +03:00
private slots:
void menuAboutToHide();
void statusChanged(Plasma::Types::ItemStatus);
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
private:
void initWindow();
2017-01-16 22:07:49 +03:00
2017-01-13 02:54:23 +03:00
void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event);
void addContainmentActions(QMenu *desktopMenu, QEvent *event);
void updatePosition();
void updateFormFactor();
2017-01-16 22:07:49 +03:00
private:
2017-01-27 21:03:24 +03:00
Plasma::Containment *containmentById(int id);
2017-01-13 02:54:23 +03:00
int m_maxThickness{24};
int m_normalThickness{24};
int m_shadow{0};
2017-01-16 22:07:49 +03:00
QRect m_localDockGeometry;
QRect m_maskArea;
QMenu *m_contextMenu;
2017-01-13 02:54:23 +03:00
QPointer<PlasmaQuick::ConfigView> m_configView;
QPointer<VisibilityManager> m_visibility;
};
2016-12-30 10:20:06 +03:00
}
#endif