1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-01-28 10:03:52 +03:00
latte-dock/app/dockcorona.h

172 lines
5.0 KiB
C
Raw Normal View History

2017-01-02 17:05:30 -05: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 DOCKCORONA_H
#define DOCKCORONA_H
2016-12-30 16:25:27 -05:00
#include "dockview.h"
#include "globalsettings.h"
#include "globalshortcuts.h"
#include "layoutmanager.h"
#include "universalsettings.h"
#include "../liblattedock/dock.h"
2016-12-30 16:25:27 -05:00
#include <QObject>
2017-01-29 00:16:28 -05:00
#include <KAboutApplicationDialog>
#include <KDeclarative/QmlObject>
2017-01-29 00:16:28 -05:00
2017-02-24 20:58:21 +02:00
class ScreenPool;
class GlobalSettings;
class GlobalShortcuts;
class UniversalSettings;
class LayoutManager;
2017-02-24 20:58:21 +02:00
namespace KActivities {
class Consumer;
}
namespace Plasma {
class Corona;
class Containment;
class Types;
}
namespace KWayland {
namespace Client {
class PlasmaShell;
}
}
2016-12-30 16:25:27 -05:00
namespace Latte {
class DockCorona : public Plasma::Corona {
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.LatteDock")
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
public:
2017-02-26 12:37:46 -05:00
DockCorona(QObject *parent = nullptr);
2016-12-30 16:25:27 -05:00
virtual ~DockCorona();
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
int numScreens() const override;
QRect screenGeometry(int id) const override;
QRegion availableScreenRegion(int id) const override;
QRect availableScreenRect(int id) const override;
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
QList<Plasma::Types::Location> freeEdges(int screen) const;
QList<Plasma::Types::Location> freeEdges(QScreen *screen) const;
2017-01-16 14:07:49 -05:00
void loadLatteLayout(QString layoutPath);
2017-06-26 22:16:42 +03:00
bool reloadLayout(QString path);
int docksCount() const;
int docksCount(int screen) const;
int docksCount(QScreen *screen) const;
int noDocksWithTasks() const;
2016-12-30 16:25:27 -05:00
int screenForContainment(const Plasma::Containment *containment) const override;
2017-01-16 14:07:49 -05:00
void addDock(Plasma::Containment *containment, int expDockScreen = -1);
void recreateDock(Plasma::Containment *containment);
2017-06-05 23:52:49 +03:00
void copyDock(Plasma::Containment *containment);
2017-01-16 14:07:49 -05:00
2017-01-29 00:16:28 -05:00
void aboutApplication();
void closeApplication();
2017-01-16 14:07:49 -05:00
2017-02-24 20:58:21 +02:00
ScreenPool *screenPool() const;
GlobalSettings *globalSettings() const;
UniversalSettings *universalSettings() const;
LayoutManager *layoutManager() const;
2017-02-24 20:58:21 +02:00
KWayland::Client::PlasmaShell *waylandDockCoronaInterface() const;
2016-12-30 16:25:27 -05:00
public slots:
void activateLauncherMenu();
2016-12-30 16:25:27 -05:00
void loadDefaultLayout() override;
void dockContainmentDestroyed(QObject *cont);
void updateDockItemBadge(QString identifier, QString value);
2017-01-16 14:07:49 -05:00
2016-12-30 16:25:27 -05:00
signals:
void configurationShown(PlasmaQuick::ConfigView *configView);
2017-01-16 13:24:46 -05:00
void docksCountChanged();
void dockLocationChanged();
void raiseDocksTemporaryChanged();
2017-01-16 14:07:49 -05:00
private slots:
void destroyedChanged(bool destroyed);
void showAlternativesForApplet(Plasma::Applet *applet);
void alternativesVisibilityChanged(bool visible);
void load();
void updateConfigs();
2017-01-16 14:07:49 -05:00
2017-02-24 20:58:21 +02:00
void addOutput(QScreen *screen);
void primaryOutputChanged();
void screenRemoved(QScreen *screen);
void screenCountChanged();
2017-02-27 22:52:22 +02:00
void syncDockViews();
2017-02-24 20:58:21 +02:00
2016-12-30 16:25:27 -05:00
private:
void cleanConfig();
void qmlRegisterTypes() const;
void setupWaylandIntegration();
2017-06-26 22:16:42 +03:00
void unload();
bool appletExists(uint containmentId, uint appletId) const;
bool containmentContainsTasks(Plasma::Containment *cont);
2017-02-05 20:55:41 -05:00
bool containmentExists(uint id) const;
bool heuresticForLoadingDockWithTasks();
int noOfDocks();
2016-12-30 16:25:27 -05:00
int primaryScreenId() const;
2017-01-16 14:07:49 -05:00
bool m_activitiesStarting{true};
//! this is used to check if a dock with tasks in it will be loaded on startup
bool m_tasksWillBeLoaded{false};
//! this is used to record the first dock having tasks in it. It is used
//! to specify which dock will be loaded on startup if a case that no "dock
//! with tasks" will be loaded otherwise. Currently the older one dock wins
int m_firstContainmentWithTasks{ -1};
2017-06-26 22:16:42 +03:00
QString m_layoutDir;
QHash<const Plasma::Containment *, DockView *> m_dockViews;
QHash<const Plasma::Containment *, DockView *> m_waitingDockViews;
QList<KDeclarative::QmlObject *> m_alternativesObjects;
2017-01-16 14:07:49 -05:00
QTimer m_docksScreenSyncTimer;
KActivities::Consumer *m_activityConsumer;
2017-01-29 00:16:28 -05:00
QPointer<KAboutApplicationDialog> aboutDialog;
2017-02-24 20:58:21 +02:00
ScreenPool *m_screenPool{nullptr};
GlobalSettings *m_globalSettings{nullptr};
GlobalShortcuts *m_globalShortcuts{nullptr};
UniversalSettings *m_universalSettings{nullptr};
LayoutManager *m_layoutManager{nullptr};
KWayland::Client::PlasmaShell *m_waylandDockCorona{nullptr};
friend class GlobalShortcuts;
friend class LayoutManager;
2016-12-30 16:25:27 -05:00
};
}
#endif // DOCKCORONA_H