1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-24 05:33:50 +03:00

files and class renamed

This commit is contained in:
Johan Smith Agudelo Rodriguez 2016-12-30 16:25:27 -05:00 committed by Michail Vourlakos
parent 146f9e3a14
commit 7fc5aa55f6
11 changed files with 190 additions and 253 deletions

View File

@ -17,9 +17,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "nowdockconfigview.h"
#include "nowdockview.h"
#include "nowdockcorona.h"
#include "dockconfigview.h"
#include "dockview.h"
#include "dockcorona.h"
#include <QQuickItem>
#include <QQmlContext>
@ -30,11 +30,11 @@
#include <KWindowSystem>
#include <KWindowEffects>
#include <plasma/package.h>
#include <Plasma/Package>
namespace Latte {
NowDockConfigView::NowDockConfigView(Plasma::Containment *containment, NowDockView *dockView, QWindow *parent)
DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockView, QWindow *parent)
: PlasmaQuick::ConfigView(containment, parent), m_containment(containment), m_dockView(dockView)
{
m_deleterTimer.setSingleShot(true);
@ -54,13 +54,14 @@ NowDockConfigView::NowDockConfigView(Plasma::Containment *containment, NowDockVi
syncSlideEffect();
});
connect(containment, &Plasma::Containment::immutabilityChanged, this, &NowDockConfigView::immutabilityChanged);
connect(containment, &Plasma::Containment::immutabilityChanged, this, &DockConfigView::immutabilityChanged);
NowDockCorona *corona = dynamic_cast<NowDockCorona *>(m_containment->corona());
//! NOTE: This is not necesesary if focusOutEvent is implemented
/*NowDockCorona *corona = qobject_cast<NowDockCorona *>(m_containment->corona());
if (corona) {
connect(corona, &NowDockCorona::configurationShown, this, &NowDockConfigView::configurationShown);
}
connect(corona, &NowDockCorona::configurationShown, this, &DockConfigView::configurationShown);
}*/
/* connect(containment, &Plasma::Containment::immutabilityChanged
, [&](Plasma::Types::ImmutabilityType type) {
@ -69,27 +70,27 @@ NowDockConfigView::NowDockConfigView(Plasma::Containment *containment, NowDockVi
});*/
}
NowDockConfigView::~NowDockConfigView()
DockConfigView::~DockConfigView()
{
}
void NowDockConfigView::init()
void DockConfigView::init()
{
setDefaultAlphaBuffer(true);
setColor(Qt::transparent);
rootContext()->setContextProperty(QStringLiteral("dock"), m_dockView);
engine()->rootContext()->setContextObject(new KLocalizedContext(this));
auto source = QUrl::fromLocalFile(m_containment->corona()->kPackage().filePath("nowdockconfigurationui"));
auto source = QUrl::fromLocalFile(m_containment->corona()->kPackage().filePath("lattedockconfigurationui"));
setSource(source);
syncSlideEffect();
}
inline Qt::WindowFlags NowDockConfigView::wFlags() const
inline Qt::WindowFlags DockConfigView::wFlags() const
{
return (flags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) & ~Qt::WindowDoesNotAcceptFocus;
}
void NowDockConfigView::syncGeometry()
void DockConfigView::syncGeometry()
{
if (!m_containment || !rootObject())
return;
@ -137,7 +138,7 @@ void NowDockConfigView::syncGeometry()
}
}
void NowDockConfigView::syncSlideEffect()
void DockConfigView::syncSlideEffect()
{
if (!m_containment)
return;
@ -169,7 +170,7 @@ void NowDockConfigView::syncSlideEffect()
KWindowEffects::slideWindow(winId(), slideLocation, -1);
}
void NowDockConfigView::showEvent(QShowEvent *ev)
void DockConfigView::showEvent(QShowEvent *ev)
{
KWindowSystem::setType(winId(), NET::Dock);
setFlags(wFlags());
@ -183,8 +184,6 @@ void NowDockConfigView::showEvent(QShowEvent *ev)
if (m_containment)
m_containment->setUserConfiguring(true);
// m_dockView->visibility()->forceShow(true);
// m_dockView->visibility()->showImmediately();
m_screenSyncTimer.start();
m_deleterTimer.stop();
@ -192,17 +191,16 @@ void NowDockConfigView::showEvent(QShowEvent *ev)
//trigger showing configuration window through corona
//in order to hide all alternative configuration windows
NowDockCorona *corona = dynamic_cast<NowDockCorona *>(m_containment->corona());
//! NOTE: This is not necesesary if focusOutEvent is implemented
// NowDockCorona *corona = qobject_cast<NowDockCorona *>(m_containment->corona());
if (corona) {
emit corona->configurationShown(this);
}
// if (corona) {
// emit corona->configurationShown(this);
// }
}
void NowDockConfigView::hideEvent(QHideEvent *ev)
void DockConfigView::hideEvent(QHideEvent *ev)
{
// m_dockView->visibility()->forceShow(false);
// m_dockView->visibility()->restore();
m_deleterTimer.start();
if (m_containment) {
@ -213,27 +211,25 @@ void NowDockConfigView::hideEvent(QHideEvent *ev)
ConfigView::hideEvent(ev);
}
void NowDockConfigView::focusOutEvent(QFocusEvent *ev)
void DockConfigView::focusOutEvent(QFocusEvent *ev)
{
//FIXME: I can understand why we need to hide on focus out
Q_UNUSED(ev);
const auto *focusWindow = qGuiApp->focusWindow();
if (focusWindow && focusWindow->flags().testFlag(Qt::Popup))
return;
// hide();
hide();
}
void NowDockConfigView::configurationShown(PlasmaQuick::ConfigView *configView)
void DockConfigView::configurationShown(PlasmaQuick::ConfigView *configView)
{
if ((configView != this) && isVisible()) {
hide();
}
}
void NowDockConfigView::immutabilityChanged(Plasma::Types::ImmutabilityType type)
void DockConfigView::immutabilityChanged(Plasma::Types::ImmutabilityType type)
{
if (type != Plasma::Types::Mutable && isVisible()) {
hide();

View File

@ -36,13 +36,13 @@ class Types;
namespace Latte {
class NowDockView;
class DockView;
class DockConfigView : public PlasmaQuick::ConfigView {
Q_OBJECT
public:
DockConfigView(Plasma::Containment *containment, NowDockView *dockView, QWindow *parent = nullptr);
DockConfigView(Plasma::Containment *containment, DockView *dockView, QWindow *parent = nullptr);
~DockConfigView() override;
void init() override;
@ -56,13 +56,13 @@ protected:
void syncGeometry();
void syncSlideEffect();
private Q_SLOTS:
private slots:
void immutabilityChanged(Plasma::Types::ImmutabilityType type);
void configurationShown(PlasmaQuick::ConfigView *configView);
private:
Plasma::Containment *m_containment{nullptr};
QPointer<NowDockView> m_dockView;
QPointer<DockView> m_dockView;
QTimer m_deleterTimer;
QTimer m_screenSyncTimer;

View File

@ -19,31 +19,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "nowdockcorona.h"
#include "nowdockview.h"
//#include "visibilitymanager.h"
#include "packageplugins/shell/nowdockpackage.h"
#include "dockcorona.h"
#include "dockview.h"
#include "packageplugins/shell/dockpackage.h"
#include <QAction>
#include <QScreen>
#include <QDebug>
#include <KActionCollection>
#include <KPluginMetaData>
#include <Plasma>
#include <Plasma/Corona>
#include <Plasma/Containment>
#include <KActionCollection>
#include <KPluginMetaData>
#include <KLocalizedString>
#include <KPackage/Package>
#include <KPackage/PackageLoader>
namespace Latte {
NowDockCorona::NowDockCorona(QObject *parent)
DockCorona::DockCorona(QObject *parent)
: Plasma::Corona(parent)
{
KPackage::Package package(new NowDockPackage(this));
KPackage::Package package(new DockPackage(this));
if (!package.isValid()) {
qWarning() << staticMetaObject.className()
@ -57,7 +55,7 @@ NowDockCorona::NowDockCorona(QObject *parent)
setKPackage(package);
qmlRegisterTypes();
connect(this, &Corona::containmentAdded, this, &NowDockCorona::addDock);
connect(this, &Corona::containmentAdded, this, &DockCorona::addDock);
loadLayout();
@ -75,7 +73,7 @@ NowDockCorona::NowDockCorona(QObject *parent)
addDock->setShortcutContext(Qt::ApplicationShortcut);*/
}
NowDockCorona::~NowDockCorona()
DockCorona::~DockCorona()
{
for (auto c : m_containments)
c->deleteLater();
@ -83,12 +81,12 @@ NowDockCorona::~NowDockCorona()
qDebug() << "deleted" << this;
}
int NowDockCorona::numScreens() const
int DockCorona::numScreens() const
{
return qGuiApp->screens().count();
}
QRect NowDockCorona::screenGeometry(int id) const
QRect DockCorona::screenGeometry(int id) const
{
const auto screens = qGuiApp->screens();
@ -99,7 +97,7 @@ QRect NowDockCorona::screenGeometry(int id) const
return qGuiApp->primaryScreen()->geometry();
}
QRegion NowDockCorona::availableScreenRegion(int id) const
QRegion DockCorona::availableScreenRegion(int id) const
{
const auto screens = qGuiApp->screens();
@ -110,7 +108,7 @@ QRegion NowDockCorona::availableScreenRegion(int id) const
return qGuiApp->primaryScreen()->availableGeometry();
}
QRect NowDockCorona::availableScreenRect(int id) const
QRect DockCorona::availableScreenRect(int id) const
{
const auto screens = qGuiApp->screens();
@ -121,7 +119,7 @@ QRect NowDockCorona::availableScreenRect(int id) const
return qGuiApp->primaryScreen()->availableGeometry();
}
int NowDockCorona::primaryScreenId() const
int DockCorona::primaryScreenId() const
{
const auto screens = qGuiApp->screens();
@ -139,7 +137,7 @@ int NowDockCorona::primaryScreenId() const
return id;
}
QList<Plasma::Types::Location> NowDockCorona::freeEdges(int screen) const
QList<Plasma::Types::Location> DockCorona::freeEdges(int screen) const
{
using Plasma::Types;
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
@ -148,7 +146,7 @@ QList<Plasma::Types::Location> NowDockCorona::freeEdges(int screen) const
//when screen=-1 is passed then the primaryScreenid is used
int fixedScreen = (screen == -1) ? primaryScreenId() : screen;
for (const NowDockView *cont : m_containments) {
for (const DockView *cont : m_containments) {
if (cont && cont->containment()->screen() == fixedScreen)
edges.removeOne(cont->location());
}
@ -156,7 +154,7 @@ QList<Plasma::Types::Location> NowDockCorona::freeEdges(int screen) const
return edges;
}
int NowDockCorona::screenForContainment(const Plasma::Containment *containment) const
int DockCorona::screenForContainment(const Plasma::Containment *containment) const
{
for (auto *view : m_containments) {
if (view && view->containment() && view->containment()->id() == containment->id())
@ -167,7 +165,7 @@ int NowDockCorona::screenForContainment(const Plasma::Containment *containment)
return -1;
}
void NowDockCorona::addDock(Plasma::Containment *containment)
void DockCorona::addDock(Plasma::Containment *containment)
{
if (!containment || !containment->kPackage().isValid()) {
qWarning() << "the requested containment plugin can not be located or loaded";
@ -182,24 +180,23 @@ void NowDockCorona::addDock(Plasma::Containment *containment)
return;
}
foreach (NowDockView *dock, m_containments) {
foreach (DockView *dock, m_containments) {
if (dock->containment() == containment) {
return;
}
}
qWarning() << "Adding dock for container...";
qDebug() << "Adding dock for container...";
auto dockView = new NowDockView(this);
auto dockView = new DockView(this);
dockView->init();
dockView->setContainment(containment);
dockView->show();
//dockView->showNormal();
m_containments.push_back(dockView);
}
void NowDockCorona::loadDefaultLayout()
void DockCorona::loadDefaultLayout()
{
qDebug() << "loading default layout";
@ -241,9 +238,9 @@ void NowDockCorona::loadDefaultLayout()
defaultContainment->createApplet(QStringLiteral("org.kde.plasma.analogclock"));
}
inline void NowDockCorona::qmlRegisterTypes() const
inline void DockCorona::qmlRegisterTypes() const
{
constexpr auto uri = "org.kde.nowdock.shell";
constexpr auto uri = "org.kde.latte.shell";
constexpr auto vMajor = 0;
constexpr auto vMinor = 2;

49
app/dockcorona.h Normal file
View File

@ -0,0 +1,49 @@
#ifndef NOWDOCKCORONA_H
#define NOWDOCKCORONA_H
#include "dockview.h"
#include <QObject>
namespace Plasma {
class Corona;
class Containment;
class Types;
}
namespace Latte {
class DockCorona : public Plasma::Corona {
Q_OBJECT
public:
DockCorona(QObject *parent = nullptr);
virtual ~DockCorona();
int numScreens() const override;
QRect screenGeometry(int id) const override;
QRegion availableScreenRegion(int id) const override;
QRect availableScreenRect(int id) const override;
QList<Plasma::Types::Location> freeEdges(int screen) const;
int screenForContainment(const Plasma::Containment *containment) const override;
void addDock(Plasma::Containment *containment);
public slots:
void loadDefaultLayout() override;
signals:
void configurationShown(PlasmaQuick::ConfigView *configView);
private:
void qmlRegisterTypes() const;
int primaryScreenId() const;
std::vector<DockView *> m_containments;
};
}
#endif

View File

@ -19,9 +19,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include "nowdockview.h"
#include "nowdockconfigview.h"
#include "dockview.h"
#include "dockcorona.h"
#include "dockconfigview.h"
#include "visibilitymanager.h"
#include "../liblattedock/windowsystem.h"
#include <QAction>
#include <QQmlContext>
@ -29,38 +31,23 @@
#include <QQmlProperty>
#include <QQuickItem>
#include <QMetaEnum>
//#include <QtX11Extras/QX11Info>
#include <NETWM>
#include <KWindowSystem>
#include <Plasma/Containment>
#include <KActionCollection>
#include <KLocalizedContext>
#include "nowdockcorona.h"
namespace Latte {
NowDockView::NowDockView(Plasma::Corona *corona, QScreen *targetScreen)
DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
: PlasmaQuick::ContainmentView(corona),
m_corona(corona)
{
KWindowSystem::setType(winId(), NET::Dock);
KWindowSystem::setState(winId(), NET::SkipTaskbar | NET::SkipPager);
setVisible(false);
setTitle(corona->kPackage().metadata().name());
setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName()));
setResizeMode(QuickViewSharedEngine::SizeRootObjectToView);
setClearBeforeRendering(true);
/* setFlags(Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint
| Qt::NoDropShadowWindowHint
| Qt::WindowDoesNotAcceptFocus);*/
// NETWinInfo winfo(QX11Info::connection(), winId(), winId(), 0, 0);
// winfo.setAllowedActions(NET::ActionChangeDesktop);
if (targetScreen)
adaptToScreen(targetScreen);
@ -73,7 +60,7 @@ NowDockView::NowDockView(Plasma::Corona *corona, QScreen *targetScreen)
m_lockGeometry.setSingleShot(true);
m_lockGeometry.setInterval(700);
connect(this, &NowDockView::containmentChanged
connect(this, &DockView::containmentChanged
, this, [&]() {
if (!containment())
return;
@ -85,14 +72,14 @@ NowDockView::NowDockView(Plasma::Corona *corona, QScreen *targetScreen)
}, Qt::DirectConnection);
}
NowDockView::~NowDockView()
DockView::~DockView()
{
}
void NowDockView::init()
void DockView::init()
{
connect(this, &NowDockView::screenChanged
, this, &NowDockView::adaptToScreen
connect(this, &DockView::screenChanged
, this, &DockView::adaptToScreen
, Qt::QueuedConnection);
@ -100,18 +87,18 @@ void NowDockView::init()
initWindow();
});
connect(this, &NowDockView::locationChanged, [&]() {
connect(this, &DockView::locationChanged, [&]() {
//! avoid glitches
m_timerGeometry.start();
});
connect(KWindowSystem::self(), &KWindowSystem::compositingChanged
connect(&WindowSystem::self(), &WindowSystem::compositingChanged
, this, [&]() {
emit compositingChanged();
} , Qt::QueuedConnection);
connect(this, &NowDockView::screenGeometryChanged
, this, &NowDockView::updateDockPosition
connect(this, &DockView::screenGeometryChanged
, this, &DockView::updateDockPosition
, Qt::QueuedConnection);
connect(this, SIGNAL(widthChanged(int)), this, SIGNAL(widthChanged()));
@ -120,9 +107,9 @@ void NowDockView::init()
rootContext()->setContextProperty(QStringLiteral("dock"), this);
engine()->rootContext()->setContextObject(new KLocalizedContext(this));
// FIXME: We need find a better solution
// engine()->rootContext()->setContextProperty(QStringLiteral("dock"), this);
setSource(corona()->kPackage().filePath("nowdockui"));
setSource(corona()->kPackage().filePath("lattedockui"));
connect(this, SIGNAL(xChanged(int)), this, SLOT(updateDockPositionSlot()));
connect(this, SIGNAL(yChanged(int)), this, SLOT(updateDockPositionSlot()));
@ -133,17 +120,17 @@ void NowDockView::init()
qDebug() << "SOURCE:" << source();
initialize();
//initialize();
}
void NowDockView::initialize()
void DockView::initialize()
{
m_secondInitPass = true;
m_timerGeometry.start();
}
void NowDockView::initWindow()
void DockView::initWindow()
{
// m_visibility->updateVisibilityFlags();
@ -160,7 +147,7 @@ void NowDockView::initWindow()
}
}
void NowDockView::updateDockPositionSlot()
void DockView::updateDockPositionSlot()
{
if (!m_lockGeometry.isActive()) {
m_lockGeometry.start();
@ -168,7 +155,7 @@ void NowDockView::updateDockPositionSlot()
}
//!BEGIN SLOTS
void NowDockView::adaptToScreen(QScreen *screen)
void DockView::adaptToScreen(QScreen *screen)
{
setScreen(screen);
@ -177,27 +164,24 @@ void NowDockView::adaptToScreen(QScreen *screen)
else
m_maxLength = screen->size().width();
// KWindowSystem::setOnAllDesktops(winId(), true);
// KWindowSystem::setType(winId(), NET::Dock);
if (containment())
containment()->reactToScreenChange();
m_timerGeometry.start();
}
void NowDockView::addNewDock()
void DockView::addNewDock()
{
NowDockCorona *corona = dynamic_cast<NowDockCorona *>(m_corona);
DockCorona *corona = dynamic_cast<DockCorona *>(m_corona);
if (corona) {
corona->loadDefaultLayout();
}
}
void NowDockView::removeDock()
void DockView::removeDock()
{
NowDockCorona *corona = dynamic_cast<NowDockCorona *>(m_corona);
DockCorona *corona = dynamic_cast<DockCorona *>(m_corona);
if (corona->containments().count() > 1) {
QAction *removeAct = containment()->actions()->action(QStringLiteral("remove"));
@ -208,24 +192,24 @@ void NowDockView::removeDock()
}
}
QQmlListProperty<QScreen> NowDockView::screens()
QQmlListProperty<QScreen> DockView::screens()
{
return QQmlListProperty<QScreen>(this, nullptr, &countScreens, &atScreens);
}
int NowDockView::countScreens(QQmlListProperty<QScreen> *property)
int DockView::countScreens(QQmlListProperty<QScreen> *property)
{
Q_UNUSED(property)
return qGuiApp->screens().count();
}
QScreen *NowDockView::atScreens(QQmlListProperty<QScreen> *property, int index)
QScreen *DockView::atScreens(QQmlListProperty<QScreen> *property, int index)
{
Q_UNUSED(property)
return qGuiApp->screens().at(index);
}
void NowDockView::showConfigurationInterface(Plasma::Applet *applet)
void DockView::showConfigurationInterface(Plasma::Applet *applet)
{
if (!applet || !applet->containment())
return;
@ -263,7 +247,7 @@ void NowDockView::showConfigurationInterface(Plasma::Applet *applet)
m_configView->requestActivate();
}
void NowDockView::resizeWindow()
void DockView::resizeWindow()
{
setVisible(true);
@ -286,7 +270,7 @@ void NowDockView::resizeWindow()
}
}
inline void NowDockView::updateDockPosition()
inline void DockView::updateDockPosition()
{
if (!containment())
return;
@ -337,7 +321,7 @@ inline void NowDockView::updateDockPosition()
qDebug() << "dock position:" << position;
}
int NowDockView::currentThickness() const
int DockView::currentThickness() const
{
if (containment()->formFactor() == Plasma::Types::Vertical) {
return m_maskArea.isNull() ? width() : m_maskArea.width();
@ -346,9 +330,9 @@ int NowDockView::currentThickness() const
}
}
bool NowDockView::compositing() const
bool DockView::compositing() const
{
return KWindowSystem::compositingActive();
return WindowSystem::self().compositingActive();
}
/*Candil::VisibilityManager *NowDockView::visibility()
@ -356,12 +340,12 @@ bool NowDockView::compositing() const
return m_visibility.data();
}*/
int NowDockView::maxThickness() const
int DockView::maxThickness() const
{
return m_maxThickness;
}
void NowDockView::setMaxThickness(int thickness)
void DockView::setMaxThickness(int thickness)
{
if (m_maxThickness == thickness)
return;
@ -371,12 +355,12 @@ void NowDockView::setMaxThickness(int thickness)
emit maxThicknessChanged();
}
int NowDockView::length() const
int DockView::length() const
{
return m_length;
}
void NowDockView::setLength(int length)
void DockView::setLength(int length)
{
if (m_length == length)
return;
@ -390,12 +374,12 @@ void NowDockView::setLength(int length)
emit lengthChanged();
}
int NowDockView::maxLength() const
int DockView::maxLength() const
{
return m_maxLength;
}
void NowDockView::setMaxLength(int maxLength)
void DockView::setMaxLength(int maxLength)
{
if (m_maxLength == maxLength)
return;
@ -405,12 +389,12 @@ void NowDockView::setMaxLength(int maxLength)
}
QRect NowDockView::maskArea() const
QRect DockView::maskArea() const
{
return m_maskArea;
}
void NowDockView::setMaskArea(QRect area)
void DockView::setMaskArea(QRect area)
{
if (m_maskArea == area) {
return;
@ -438,12 +422,12 @@ void NowDockView::setAlignment(Dock::Alignment align)
emit alignmentChanged();
}
*/
int NowDockView::offset() const
int DockView::offset() const
{
return m_offset;
}
void NowDockView::setOffset(int offset)
void DockView::setOffset(int offset)
{
if (m_offset == offset)
return;
@ -453,7 +437,7 @@ void NowDockView::setOffset(int offset)
emit offsetChanged();
}
void NowDockView::updateOffset()
void DockView::updateOffset()
{
if (!containment())
return;
@ -468,12 +452,12 @@ void NowDockView::updateOffset()
emit offsetChanged();
}
VisibilityManager *NowDockView::visibility()
VisibilityManager *DockView::visibility()
{
return m_visibility;
}
bool NowDockView::event(QEvent *e)
bool DockView::event(QEvent *e)
{
emit eventTriggered(e);
@ -489,7 +473,7 @@ bool NowDockView::event(QEvent *e)
ContainmentView::showEvent(ev);
}*/
bool NowDockView::containmentContainsPosition(const QPointF &point) const
bool DockView::containmentContainsPosition(const QPointF &point) const
{
QQuickItem *containmentItem = containment()->property("_plasma_graphicObject").value<QQuickItem *>();
@ -500,7 +484,7 @@ bool NowDockView::containmentContainsPosition(const QPointF &point) const
return QRectF(containmentItem->mapToScene(QPoint(0, 0)), QSizeF(containmentItem->width(), containmentItem->height())).contains(point);
}
QPointF NowDockView::positionAdjustedForContainment(const QPointF &point) const
QPointF DockView::positionAdjustedForContainment(const QPointF &point) const
{
QQuickItem *containmentItem = containment()->property("_plasma_graphicObject").value<QQuickItem *>();
@ -514,7 +498,7 @@ QPointF NowDockView::positionAdjustedForContainment(const QPointF &point) const
qBound(containmentRect.top() + 2, point.y(), containmentRect.bottom() - 2));
}
QList<int> NowDockView::freeEdges() const
QList<int> DockView::freeEdges() const
{
QList<Plasma::Types::Location> edges = m_corona->freeEdges(containment()->screen());
@ -527,7 +511,7 @@ QList<int> NowDockView::freeEdges() const
return edgesInt;
}
void NowDockView::saveConfig()
void DockView::saveConfig()
{
if (!containment())
return;
@ -545,7 +529,7 @@ void NowDockView::saveConfig()
// writeEntry("alignment", static_cast<int>(m_alignment));
}
void NowDockView::restoreConfig()
void DockView::restoreConfig()
{
if (!containment())
return;

View File

@ -22,8 +22,6 @@
#ifndef NOWDOCKVIEW_H
#define NOWDOCKVIEW_H
#include <climits>
#include "plasmaquick/configview.h"
#include "plasmaquick/containmentview.h"
#include "visibilitymanager.h"
@ -49,7 +47,7 @@ class VisibilityManager;
namespace Latte {
class NowDockView : public PlasmaQuick::ContainmentView {
class DockView : public PlasmaQuick::ContainmentView {
Q_OBJECT
Q_PROPERTY(bool compositing READ compositing NOTIFY compositingChanged)
@ -65,8 +63,8 @@ class NowDockView : public PlasmaQuick::ContainmentView {
Q_PROPERTY(QQmlListProperty<QScreen> screens READ screens)
public:
NowDockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr);
virtual ~NowDockView();
DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr);
virtual ~DockView();
void init();
@ -139,7 +137,7 @@ signals:
void visibilityChanged();
void widthChanged();
public Q_SLOTS:
public slots:
void updateDockPositionSlot();
void updateAbsDockGeometry();

View File

@ -1,32 +1,11 @@
/*
* Copyright 2014 Bhushan Shah <bhush94@gmail.com>
* Copyright 2014 Marco Martin <notmart@gmail.com>
*
* This program 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) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program 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/>
*/
#include "nowdockcorona.h"
#include "dockcorona.h"
#include <memory>
#include <QApplication>
#include <QQuickWindow>
#include <qcommandlineparser.h>
#include <qcommandlineoption.h>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
#include <KLocalizedString>
@ -62,7 +41,7 @@ int main(int argc, char **argv)
//! set pattern for debug messages
//! [%{type}] [%{function}:%{line}] - %{message} [%{backtrace}]
qSetMessagePattern(QStringLiteral(
CIGREEN "[%{type} " CGREEN "%{time h:mm:ss.zzzz}" CIGREEN "]" CNORMAL
CIGREEN "[%{type} " CGREEN "%{time h:mm:ss.zz}" CIGREEN "]" CNORMAL
#ifndef QT_NO_DEBUG
CIRED " [" CCYAN "%{function}" CIRED ":" CCYAN "%{line}" CIRED "]"
#endif
@ -72,7 +51,7 @@ int main(int argc, char **argv)
"%{if-critical}\n%{backtrace depth=" DEPTH " separator=\"\n\"}%{endif}" CNORMAL));
// qputenv("QT_QUICK_CONTROLS_1_STYLE", "Desktop");
Latte::NowDockCorona corona;
Latte::DockCorona corona;
return app.exec();
}

View File

@ -1,71 +0,0 @@
/*
* Copyright 2014 Bhushan Shah <bhush94@gmail.com>
* Copyright 2014 Marco Martin <notmart@gmail.com>
*
* This program 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) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program 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 NOWDOCKCORONA_H
#define NOWDOCKCORONA_H
#include <QObject>
#include "nowdockview.h"
namespace Plasma {
class Corona;
class Containment;
class Types;
}
namespace Latte {
class NowDockCorona : public Plasma::Corona {
Q_OBJECT
public:
NowDockCorona(QObject *parent = nullptr);
~NowDockCorona() override;
int numScreens() const override;
QRect screenGeometry(int id) const override;
QRegion availableScreenRegion(int id) const override;
QRect availableScreenRect(int id) const override;
QList<Plasma::Types::Location> freeEdges(int screen) const;
int screenForContainment(const Plasma::Containment *containment) const override;
void addDock(Plasma::Containment *containment);
public slots:
void loadDefaultLayout() override;
signals:
void configurationShown(PlasmaQuick::ConfigView *configView);
private:
void qmlRegisterTypes() const;
int primaryScreenId() const;
std::vector<NowDockView *> m_containments;
};
}
#endif

View File

@ -33,19 +33,6 @@ public:
};
Q_ENUM(Alignment)
enum VisibilityState {
/*!
* @brief the dock is visible
*/
Visible = 1,
/*!
* @brief the dock is hidden
*/
Hidden = 0
};
Q_ENUM(VisibilityState)
};
}//end of namespace

View File

@ -7,7 +7,19 @@ namespace Latte {
WindowSystem::WindowSystem(QObject *parent) :
QObject(parent)
{
connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), this, SLOT(compositingChanged(bool)));
if (KWindowSystem::isPlatformWayland()) {
//! TODO: Wayland compositing
} else {
compositingChangedProxy(KWindowSystem::self()->compositingActive());
connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool))
, this, SLOT(compositingChangedProxy(bool)));
}
}
WindowSystem &WindowSystem::self()
{
static WindowSystem wm;
return wm;
}
WindowSystem::~WindowSystem()
@ -16,11 +28,12 @@ WindowSystem::~WindowSystem()
bool WindowSystem::compositingActive() const
{
return KWindowSystem::compositingActive();
return m_enabled;
}
void WindowSystem::compositingChanged(bool state)
void WindowSystem::compositingChangedProxy(bool enabled)
{
m_enabled = enabled;
emit compositingChanged();
}

View File

@ -11,16 +11,21 @@ class WindowSystem : public QObject {
Q_PROPERTY(bool compositingActive READ compositingActive NOTIFY compositingChanged)
public:
explicit WindowSystem(QObject *parent = Q_NULLPTR);
explicit WindowSystem(QObject *parent = nullptr);
static WindowSystem &self();
~WindowSystem();
bool compositingActive() const;
Q_SIGNALS:
signals:
void compositingChanged();
private Q_SLOTS:
void compositingChanged(bool state);
private slots:
void compositingChangedProxy(bool enabled);
private:
bool m_enabled{false};
};
}//LatteDock namespace