mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-08 13:18:09 +03:00
avoid white spaces with astyle
This commit is contained in:
parent
2307efd4c4
commit
c42250d9bb
@ -31,12 +31,10 @@ namespace Latte {
|
||||
AbstractWindowInterface::AbstractWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
: QObject(parent), m_view(view)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AbstractWindowInterface::~AbstractWindowInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AbstractWindowInterface *AbstractWindowInterface::getInstance(QQuickWindow *const view, QObject *parent)
|
||||
@ -45,7 +43,7 @@ AbstractWindowInterface *AbstractWindowInterface::getInstance(QQuickWindow *cons
|
||||
//! TODO: WaylandWindowInterface
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
/* if(KWindowSystem::isPlatformX11) */
|
||||
return new XWindowInterface(view, parent);
|
||||
}
|
||||
|
@ -40,31 +40,31 @@ class XWindowInterface;
|
||||
|
||||
class AbstractWindowInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
explicit AbstractWindowInterface(QQuickWindow *const view, QObject *parent = nullptr);
|
||||
virtual ~AbstractWindowInterface();
|
||||
|
||||
|
||||
virtual void setDockDefaultFlags() = 0;
|
||||
|
||||
|
||||
virtual WId activeWindow() const = 0;
|
||||
virtual WindowInfoWrap requestInfo(WId wid) const = 0;
|
||||
virtual WindowInfoWrap requestInfoActive() const = 0;
|
||||
virtual bool isOnCurrentDesktop(WId wid) const = 0;
|
||||
virtual const std::list<WId> &windows() const = 0;
|
||||
|
||||
|
||||
virtual void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) const = 0;
|
||||
virtual void removeDockStruts() const = 0;
|
||||
|
||||
|
||||
static AbstractWindowInterface *getInstance(QQuickWindow *const view, QObject *parent = nullptr);
|
||||
|
||||
|
||||
signals:
|
||||
void activeWindowChanged(WId wid);
|
||||
void windowChanged(WId winfo);
|
||||
void windowAdded(WId wid);
|
||||
void windowRemoved(WId wid);
|
||||
void currentDesktopChanged(int desktop);
|
||||
|
||||
|
||||
protected:
|
||||
QQuickWindow *const m_view;
|
||||
std::list<WId> m_windows;
|
||||
|
@ -42,12 +42,9 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
|
||||
m_dockView(dockView)
|
||||
{
|
||||
connections << connect(dockView, &QObject::destroyed, this, &QObject::deleteLater);
|
||||
|
||||
m_screenSyncTimer.setSingleShot(true);
|
||||
m_screenSyncTimer.setInterval(100);
|
||||
|
||||
connections << connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start()));
|
||||
|
||||
connections << connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() {
|
||||
setScreen(m_dockView->screen());
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
@ -55,12 +52,10 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
|
||||
syncGeometry();
|
||||
syncSlideEffect();
|
||||
});
|
||||
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
KWindowSystem::setState(winId(), NET::KeepAbove);
|
||||
setFlags(wFlags());
|
||||
KWindowSystem::forceActiveWindow(winId());
|
||||
|
||||
connections << connect(dockView->visibility(), &VisibilityManager::modeChanged, this, &DockConfigView::syncGeometry);
|
||||
connections << connect(containment, &Plasma::Containment::immutabilityChanged, this, &DockConfigView::immutabilityChanged);
|
||||
connections << connect(containment, &Plasma::Containment::locationChanged, [&]() {
|
||||
@ -97,47 +92,43 @@ void DockConfigView::syncGeometry()
|
||||
{
|
||||
if (!m_containment || !rootObject())
|
||||
return;
|
||||
|
||||
|
||||
const auto location = m_containment->location();
|
||||
const auto sGeometry = screen()->geometry();
|
||||
|
||||
|
||||
switch (m_containment->formFactor()) {
|
||||
case Plasma::Types::Horizontal: {
|
||||
const QSize size(rootObject()->width(), rootObject()->height());
|
||||
setMaximumSize(size);
|
||||
setMinimumSize(size);
|
||||
resize(size);
|
||||
|
||||
|
||||
if (location == Plasma::Types::TopEdge) {
|
||||
setPosition(sGeometry.center().x() - size.width() / 2
|
||||
, m_dockView->currentThickness());
|
||||
|
||||
} else if (location == Plasma::Types::BottomEdge) {
|
||||
setPosition(sGeometry.center().x() - size.width() / 2
|
||||
, sGeometry.height() - m_dockView->currentThickness() - size.height());
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::Vertical: {
|
||||
const QSize size(rootObject()->width(), rootObject()->height());
|
||||
setMaximumSize(size);
|
||||
setMinimumSize(size);
|
||||
resize(size);
|
||||
|
||||
|
||||
if (location == Plasma::Types::LeftEdge) {
|
||||
setPosition(m_dockView->currentThickness()
|
||||
, sGeometry.center().y() - size.height() / 2);
|
||||
|
||||
} else if (location == Plasma::Types::RightEdge) {
|
||||
setPosition(sGeometry.width() - m_dockView->currentThickness() - size.width()
|
||||
, sGeometry.center().y() - size.height() / 2);
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
qWarning() << "no sync geometry, wrong formFactor";
|
||||
break;
|
||||
@ -148,52 +139,49 @@ void DockConfigView::syncSlideEffect()
|
||||
{
|
||||
if (!m_containment)
|
||||
return;
|
||||
|
||||
|
||||
KWindowEffects::SlideFromLocation slideLocation{KWindowEffects::NoEdge};
|
||||
|
||||
|
||||
switch (m_containment->location()) {
|
||||
case Plasma::Types::TopEdge:
|
||||
slideLocation = KWindowEffects::TopEdge;
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::RightEdge:
|
||||
slideLocation = KWindowEffects::RightEdge;
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::BottomEdge:
|
||||
slideLocation = KWindowEffects::BottomEdge;
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
slideLocation = KWindowEffects::LeftEdge;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
qDebug() << staticMetaObject.className() << "wrong location";// << qEnumToStr(m_containment->location());
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
KWindowEffects::slideWindow(winId(), slideLocation, -1);
|
||||
}
|
||||
|
||||
void DockConfigView::showEvent(QShowEvent *ev)
|
||||
{
|
||||
QQuickWindow::showEvent(ev);
|
||||
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
setFlags(wFlags());
|
||||
KWindowSystem::setState(winId(), NET::KeepAbove | NET::SkipPager | NET::SkipTaskbar);
|
||||
KWindowSystem::forceActiveWindow(winId());
|
||||
KWindowEffects::enableBlurBehind(winId(), true);
|
||||
|
||||
syncGeometry();
|
||||
syncSlideEffect();
|
||||
|
||||
|
||||
if (m_containment)
|
||||
m_containment->setUserConfiguring(true);
|
||||
|
||||
|
||||
m_screenSyncTimer.start();
|
||||
|
||||
QTimer::singleShot(400, this, &DockConfigView::syncGeometry);
|
||||
}
|
||||
|
||||
@ -202,7 +190,7 @@ void DockConfigView::hideEvent(QHideEvent *ev)
|
||||
if (m_containment && m_dockView) {
|
||||
m_containment->setUserConfiguring(false);
|
||||
}
|
||||
|
||||
|
||||
QQuickWindow::hideEvent(ev);
|
||||
}
|
||||
|
||||
@ -210,10 +198,10 @@ void DockConfigView::focusOutEvent(QFocusEvent *ev)
|
||||
{
|
||||
Q_UNUSED(ev);
|
||||
const auto *focusWindow = qGuiApp->focusWindow();
|
||||
|
||||
|
||||
if (focusWindow && focusWindow->flags().testFlag(Qt::Popup))
|
||||
return;
|
||||
|
||||
|
||||
if (!m_blockFocusLost) {
|
||||
hide();
|
||||
}
|
||||
@ -231,7 +219,7 @@ void DockConfigView::setSticker(bool blockFocusLost)
|
||||
if (m_blockFocusLost == blockFocusLost) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_blockFocusLost = blockFocusLost;
|
||||
}
|
||||
|
||||
|
@ -41,36 +41,36 @@ class DockView;
|
||||
|
||||
class DockConfigView : public PlasmaQuick::ConfigView {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
DockConfigView(Plasma::Containment *containment, DockView *dockView, QWindow *parent = nullptr);
|
||||
~DockConfigView() override;
|
||||
|
||||
|
||||
void init() override;
|
||||
Qt::WindowFlags wFlags() const;
|
||||
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void setSticker(bool blockFocusLost);
|
||||
Q_INVOKABLE void syncGeometry();
|
||||
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *ev) override;
|
||||
void hideEvent(QHideEvent *ev) override;
|
||||
void focusOutEvent(QFocusEvent *ev) override;
|
||||
|
||||
|
||||
void syncSlideEffect();
|
||||
|
||||
|
||||
private slots:
|
||||
void immutabilityChanged(Plasma::Types::ImmutabilityType type);
|
||||
|
||||
|
||||
private:
|
||||
bool m_blockFocusLost;
|
||||
|
||||
|
||||
Plasma::Containment *m_containment{nullptr};
|
||||
QPointer<DockView> m_dockView;
|
||||
QTimer m_screenSyncTimer;
|
||||
|
||||
|
||||
QList<QMetaObject::Connection> connections;
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ DockCorona::DockCorona(QObject *parent)
|
||||
m_activityConsumer(new KActivities::Consumer(this))
|
||||
{
|
||||
KPackage::Package package(new DockPackage(this));
|
||||
|
||||
|
||||
if (!package.isValid()) {
|
||||
qWarning() << staticMetaObject.className()
|
||||
<< "the package" << package.metadata().rawData() << "is invalid!";
|
||||
@ -53,10 +53,9 @@ DockCorona::DockCorona(QObject *parent)
|
||||
qDebug() << staticMetaObject.className()
|
||||
<< "the package" << package.metadata().rawData() << "is valid!";
|
||||
}
|
||||
|
||||
|
||||
setKPackage(package);
|
||||
qmlRegisterTypes();
|
||||
|
||||
connect(this, &Corona::containmentAdded, this, &DockCorona::addDock);
|
||||
connect(m_activityConsumer, &KActivities::Consumer::serviceStatusChanged, this, &DockCorona::load);
|
||||
}
|
||||
@ -67,15 +66,13 @@ DockCorona::~DockCorona()
|
||||
//deleting a containment will remove it from the list due to QObject::destroyed connect in Corona
|
||||
delete containments().first();
|
||||
}
|
||||
|
||||
|
||||
qDeleteAll(m_dockViews);
|
||||
qDeleteAll(m_waitingDockViews);
|
||||
m_dockViews.clear();
|
||||
m_waitingDockViews.clear();
|
||||
|
||||
disconnect(m_activityConsumer, &KActivities::Consumer::serviceStatusChanged, this, &DockCorona::load);
|
||||
delete m_activityConsumer;
|
||||
|
||||
qDebug() << "deleted" << this;
|
||||
}
|
||||
|
||||
@ -92,51 +89,50 @@ int DockCorona::numScreens() const
|
||||
QRect DockCorona::screenGeometry(int id) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
|
||||
|
||||
if (id >= 0 && id < screens.count()) {
|
||||
return screens[id]->geometry();
|
||||
}
|
||||
|
||||
|
||||
return qGuiApp->primaryScreen()->geometry();
|
||||
}
|
||||
|
||||
QRegion DockCorona::availableScreenRegion(int id) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
|
||||
|
||||
if (id >= 0 && id < screens.count()) {
|
||||
return screens[id]->geometry();
|
||||
}
|
||||
|
||||
|
||||
return qGuiApp->primaryScreen()->availableGeometry();
|
||||
}
|
||||
|
||||
QRect DockCorona::availableScreenRect(int id) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
|
||||
|
||||
if (id >= 0 && id < screens.count()) {
|
||||
return screens[id]->availableGeometry();
|
||||
}
|
||||
|
||||
|
||||
return qGuiApp->primaryScreen()->availableGeometry();
|
||||
}
|
||||
|
||||
int DockCorona::primaryScreenId() const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
|
||||
int id = -1;
|
||||
|
||||
|
||||
for (int i = 0; i < screens.size(); ++i) {
|
||||
auto *scr = screens.at(i);
|
||||
|
||||
|
||||
if (scr == qGuiApp->primaryScreen()) {
|
||||
id = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -144,9 +140,9 @@ int DockCorona::docksCount(int screen) const
|
||||
{
|
||||
if (screen == -1)
|
||||
return 0;
|
||||
|
||||
|
||||
int docks{0};
|
||||
|
||||
|
||||
for (const auto &view : m_dockViews) {
|
||||
if (view && view->containment()
|
||||
&& view->containment()->screen() == screen
|
||||
@ -154,9 +150,8 @@ int DockCorona::docksCount(int screen) const
|
||||
++docks;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qDebug() << docks << "docks on screen:" << screen;
|
||||
|
||||
return docks;
|
||||
}
|
||||
|
||||
@ -170,17 +165,16 @@ QList<Plasma::Types::Location> DockCorona::freeEdges(int screen) const
|
||||
using Plasma::Types;
|
||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
||||
Types::TopEdge, Types::RightEdge};
|
||||
|
||||
//when screen=-1 is passed then the primaryScreenid is used
|
||||
int fixedScreen = (screen == -1) ? primaryScreenId() : screen;
|
||||
|
||||
|
||||
for (auto *view : m_dockViews) {
|
||||
if (view && view->containment()
|
||||
&& view->containment()->screen() == fixedScreen) {
|
||||
edges.removeOne(view->location());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return edges;
|
||||
}
|
||||
|
||||
@ -191,7 +185,7 @@ int DockCorona::screenForContainment(const Plasma::Containment *containment) con
|
||||
if (view->screen())
|
||||
return qGuiApp->screens().indexOf(view->screen());
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -201,58 +195,54 @@ void DockCorona::addDock(Plasma::Containment *containment)
|
||||
qWarning() << "the requested containment plugin can not be located or loaded";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
auto metadata = containment->kPackage().metadata();
|
||||
|
||||
|
||||
// the system tray is a containment that behaves as an applet
|
||||
// so a dockview shouldnt be created for it
|
||||
if (metadata.pluginId() != "org.kde.latte.containment")
|
||||
return;
|
||||
|
||||
|
||||
for (auto *dock : m_dockViews) {
|
||||
if (dock->containment() == containment)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Adding dock for container...";
|
||||
|
||||
auto dockView = new DockView(this);
|
||||
dockView->init();
|
||||
dockView->setContainment(containment);
|
||||
connect(containment, &QObject::destroyed, this, &DockCorona::dockContainmentDestroyed);
|
||||
connect(containment, &Plasma::Applet::destroyedChanged, this, &DockCorona::destroyedChanged);
|
||||
|
||||
dockView->show();
|
||||
|
||||
m_dockViews[containment] = dockView;
|
||||
|
||||
emit docksCountChanged();
|
||||
}
|
||||
|
||||
void DockCorona::destroyedChanged(bool destroyed)
|
||||
{
|
||||
Plasma::Containment *sender = qobject_cast<Plasma::Containment *>(QObject::sender());
|
||||
|
||||
|
||||
if (!sender) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (destroyed) {
|
||||
m_waitingDockViews[sender] = m_dockViews.take(static_cast<Plasma::Containment *>(sender));
|
||||
} else {
|
||||
m_dockViews[sender] = m_waitingDockViews.take(static_cast<Plasma::Containment *>(sender));
|
||||
}
|
||||
|
||||
|
||||
emit docksCountChanged();
|
||||
}
|
||||
|
||||
void DockCorona::dockContainmentDestroyed(QObject *cont)
|
||||
{
|
||||
auto view = m_waitingDockViews.take(static_cast<Plasma::Containment *>(cont));
|
||||
|
||||
|
||||
if (view)
|
||||
view->destroy();
|
||||
|
||||
|
||||
//view->deleteLater();
|
||||
emit docksCountChanged();
|
||||
}
|
||||
@ -262,38 +252,33 @@ void DockCorona::loadDefaultLayout()
|
||||
qDebug() << "loading default layout";
|
||||
//! Settting mutable for create a containment
|
||||
setImmutability(Plasma::Types::Mutable);
|
||||
|
||||
QVariantList args;
|
||||
auto defaultContainment = createContainmentDelayed("org.kde.latte.containment", args);
|
||||
|
||||
defaultContainment->setContainmentType(Plasma::Types::PanelContainment);
|
||||
defaultContainment->init();
|
||||
|
||||
|
||||
if (!defaultContainment || !defaultContainment->kPackage().isValid()) {
|
||||
qWarning() << "the requested containment plugin can not be located or loaded";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
auto config = defaultContainment->config();
|
||||
defaultContainment->restore(config);
|
||||
|
||||
QList<Plasma::Types::Location> edges = freeEdges(defaultContainment->screen());
|
||||
|
||||
|
||||
if (edges.count() > 0) {
|
||||
defaultContainment->setLocation(edges.at(0));
|
||||
} else {
|
||||
defaultContainment->setLocation(Plasma::Types::BottomEdge);
|
||||
}
|
||||
|
||||
|
||||
defaultContainment->updateConstraints(Plasma::Types::StartupCompletedConstraint);
|
||||
defaultContainment->save(config);
|
||||
requestConfigSync();
|
||||
defaultContainment->flushPendingConstraintsEvents();
|
||||
emit containmentAdded(defaultContainment);
|
||||
emit containmentCreated(defaultContainment);
|
||||
|
||||
addDock(defaultContainment);
|
||||
|
||||
defaultContainment->createApplet(QStringLiteral("org.kde.latte.plasmoid"));
|
||||
defaultContainment->createApplet(QStringLiteral("org.kde.plasma.analogclock"));
|
||||
}
|
||||
|
@ -39,44 +39,44 @@ 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 docksCount(int screen) const;
|
||||
int screenForContainment(const Plasma::Containment *containment) const override;
|
||||
|
||||
|
||||
void addDock(Plasma::Containment *containment);
|
||||
|
||||
|
||||
void closeApplication();
|
||||
|
||||
|
||||
public slots:
|
||||
void loadDefaultLayout() override;
|
||||
void dockContainmentDestroyed(QObject *cont);
|
||||
|
||||
|
||||
signals:
|
||||
void configurationShown(PlasmaQuick::ConfigView *configView);
|
||||
void docksCountChanged();
|
||||
|
||||
|
||||
private slots:
|
||||
void destroyedChanged(bool destroyed);
|
||||
void load();
|
||||
|
||||
|
||||
private:
|
||||
void qmlRegisterTypes() const;
|
||||
int primaryScreenId() const;
|
||||
|
||||
|
||||
QHash<const Plasma::Containment *, DockView *> m_dockViews;
|
||||
QHash<const Plasma::Containment *, DockView *> m_waitingDockViews;
|
||||
|
||||
|
||||
KActivities::Consumer *m_activityConsumer;
|
||||
};
|
||||
|
||||
|
235
app/dockview.cpp
235
app/dockview.cpp
@ -51,44 +51,38 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
|
||||
setVisible(false);
|
||||
setTitle(corona->kPackage().metadata().name());
|
||||
setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName()));
|
||||
|
||||
setResizeMode(QuickViewSharedEngine::SizeRootObjectToView);
|
||||
setClearBeforeRendering(true);
|
||||
|
||||
|
||||
if (targetScreen)
|
||||
adaptToScreen(targetScreen);
|
||||
else
|
||||
adaptToScreen(qGuiApp->primaryScreen());
|
||||
|
||||
|
||||
connect(this, &DockView::containmentChanged
|
||||
, this, [&]() {
|
||||
if (!containment())
|
||||
return;
|
||||
|
||||
|
||||
if (!m_visibility) {
|
||||
m_visibility = new VisibilityManager(this);
|
||||
}
|
||||
|
||||
|
||||
QAction *lockWidgetsAction = containment()->actions()->action("lock widgets");
|
||||
containment()->actions()->removeAction(lockWidgetsAction);
|
||||
|
||||
QAction *removeAction = containment()->actions()->action("remove");
|
||||
removeAction->setVisible(false);
|
||||
//containment()->actions()->removeAction(removeAction);
|
||||
|
||||
//FIX: hide and not delete in order to disable a nasty behavior from
|
||||
//ContainmentInterface. If only one action exists for containment the
|
||||
//this action is triggered directly
|
||||
QAction *addWidgetsAction = containment()->actions()->action("add widgets");
|
||||
addWidgetsAction->setVisible(false);
|
||||
//containment()->actions()->removeAction(addWidgetsAction);
|
||||
|
||||
connect(containment(), SIGNAL(statusChanged(Plasma::Types::ItemStatus)), SLOT(statusChanged(Plasma::Types::ItemStatus)));
|
||||
|
||||
}, Qt::DirectConnection);
|
||||
|
||||
auto *dockCorona = qobject_cast<DockCorona *>(this->corona());
|
||||
|
||||
|
||||
if (dockCorona) {
|
||||
connect(dockCorona, &DockCorona::docksCountChanged, this, &DockView::docksCountChanged);
|
||||
}
|
||||
@ -97,13 +91,13 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
|
||||
DockView::~DockView()
|
||||
{
|
||||
qDebug() << "dock view deleting...";
|
||||
|
||||
|
||||
foreach (auto &var, connections) {
|
||||
QObject::disconnect(var);
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "dock view connections deleted...";
|
||||
|
||||
|
||||
if (m_visibility) {
|
||||
delete m_visibility.data();
|
||||
m_visibility.clear();
|
||||
@ -121,14 +115,10 @@ void DockView::init()
|
||||
updateFormFactor();
|
||||
syncGeometry();
|
||||
});
|
||||
|
||||
|
||||
engine()->rootContext()->setContextObject(new KLocalizedContext(this));
|
||||
rootContext()->setContextProperty(QStringLiteral("dock"), this);
|
||||
setSource(corona()->kPackage().filePath("lattedockui"));
|
||||
|
||||
setVisible(true);
|
||||
|
||||
syncGeometry();
|
||||
qDebug() << "SOURCE:" << source();
|
||||
}
|
||||
@ -136,22 +126,22 @@ void DockView::init()
|
||||
void DockView::adaptToScreen(QScreen *screen)
|
||||
{
|
||||
setScreen(screen);
|
||||
|
||||
|
||||
if (formFactor() == Plasma::Types::Vertical)
|
||||
m_maxLength = screen->size().height();
|
||||
else
|
||||
m_maxLength = screen->size().width();
|
||||
|
||||
|
||||
if (containment())
|
||||
containment()->reactToScreenChange();
|
||||
|
||||
|
||||
syncGeometry();
|
||||
}
|
||||
|
||||
void DockView::addNewDock()
|
||||
{
|
||||
auto *dockCorona = qobject_cast<DockCorona *>(this->corona());
|
||||
|
||||
|
||||
if (dockCorona) {
|
||||
dockCorona->loadDefaultLayout();
|
||||
}
|
||||
@ -161,7 +151,7 @@ void DockView::removeDock()
|
||||
{
|
||||
if (docksCount() > 1) {
|
||||
QAction *removeAct = containment()->actions()->action(QStringLiteral("remove"));
|
||||
|
||||
|
||||
if (removeAct) {
|
||||
removeAct->trigger();
|
||||
}
|
||||
@ -189,16 +179,16 @@ void DockView::showConfigurationInterface(Plasma::Applet *applet)
|
||||
{
|
||||
if (!applet || !applet->containment())
|
||||
return;
|
||||
|
||||
|
||||
Plasma::Containment *c = qobject_cast<Plasma::Containment *>(applet);
|
||||
|
||||
|
||||
if (m_configView && c && c->isContainment() && c == containment()) {
|
||||
if (m_configView->isVisible()) {
|
||||
m_configView->hide();
|
||||
} else {
|
||||
m_configView->show();
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
} else if (m_configView) {
|
||||
if (m_configView->applet() == applet) {
|
||||
@ -210,18 +200,18 @@ void DockView::showConfigurationInterface(Plasma::Applet *applet)
|
||||
m_configView->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool delayConfigView = false;
|
||||
|
||||
|
||||
if (c && containment() && c->isContainment() && c->id() == containment()->id()) {
|
||||
m_configView = new DockConfigView(c, this);
|
||||
delayConfigView = true;
|
||||
} else {
|
||||
m_configView = new PlasmaQuick::ConfigView(applet);
|
||||
}
|
||||
|
||||
|
||||
m_configView.data()->init();
|
||||
|
||||
|
||||
if (!delayConfigView) {
|
||||
m_configView.data()->show();
|
||||
} else {
|
||||
@ -235,7 +225,7 @@ void DockView::showConfigurationInterface(Plasma::Applet *applet)
|
||||
void DockView::resizeWindow()
|
||||
{
|
||||
QSize screenSize = screen()->size();
|
||||
|
||||
|
||||
if (formFactor() == Plasma::Types::Vertical) {
|
||||
const QSize size{maxThickness(), screenSize.height()};
|
||||
setMinimumSize(size);
|
||||
@ -254,9 +244,8 @@ void DockView::setLocalDockGeometry(const QRect &geometry)
|
||||
if (geometry == m_localDockGeometry) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_localDockGeometry = geometry;
|
||||
|
||||
emit localDockGeometryChanged();
|
||||
}
|
||||
|
||||
@ -264,7 +253,7 @@ void DockView::updateAbsDockGeometry()
|
||||
{
|
||||
if (!m_visibility)
|
||||
return;
|
||||
|
||||
|
||||
QRect absoluteGeometry {x() + m_localDockGeometry.x(), y() + m_localDockGeometry.y(), m_localDockGeometry.width(), m_localDockGeometry.height()};
|
||||
m_visibility->updateDockGeometry(absoluteGeometry);
|
||||
}
|
||||
@ -273,38 +262,33 @@ void DockView::updatePosition()
|
||||
{
|
||||
if (!containment())
|
||||
return;
|
||||
|
||||
|
||||
const QRect screenGeometry = screen()->geometry();
|
||||
QPoint position;
|
||||
|
||||
position = {0, 0};
|
||||
|
||||
|
||||
switch (location()) {
|
||||
case Plasma::Types::TopEdge:
|
||||
position = {screenGeometry.x(), screenGeometry.y()};
|
||||
m_maxLength = screenGeometry.width();
|
||||
break;
|
||||
|
||||
case Plasma::Types::BottomEdge:
|
||||
position = {screenGeometry.x(), screenGeometry.y() + screenGeometry.height() - height()};
|
||||
m_maxLength = screenGeometry.width();
|
||||
break;
|
||||
|
||||
case Plasma::Types::RightEdge:
|
||||
position = {screenGeometry.x() + screenGeometry.width() - width(), screenGeometry.y()};
|
||||
m_maxLength = screenGeometry.height();
|
||||
break;
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
position = {screenGeometry.x(), screenGeometry.y()};
|
||||
m_maxLength = screenGeometry.height();
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning() << "wrong location, couldn't update the panel position"
|
||||
<< location();
|
||||
}
|
||||
|
||||
|
||||
emit maxLengthChanged();
|
||||
setPosition(position);
|
||||
}
|
||||
@ -314,7 +298,6 @@ inline void DockView::syncGeometry()
|
||||
resizeWindow();
|
||||
updatePosition();
|
||||
updateAbsDockGeometry();
|
||||
|
||||
qDebug() << "dock geometry:" << qRectToStr(geometry());
|
||||
}
|
||||
|
||||
@ -340,10 +323,10 @@ int DockView::currentThickness() const
|
||||
int DockView::docksCount() const
|
||||
{
|
||||
auto dockCorona = qobject_cast<DockCorona *>(corona());
|
||||
|
||||
|
||||
if (!dockCorona || !containment())
|
||||
return 0;
|
||||
|
||||
|
||||
return dockCorona->docksCount(containment()->screen());
|
||||
}
|
||||
|
||||
@ -351,18 +334,18 @@ void DockView::updateFormFactor()
|
||||
{
|
||||
if (!containment())
|
||||
return;
|
||||
|
||||
|
||||
switch (location()) {
|
||||
case Plasma::Types::TopEdge:
|
||||
case Plasma::Types::BottomEdge:
|
||||
containment()->setFormFactor(Plasma::Types::Horizontal);
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
case Plasma::Types::RightEdge:
|
||||
containment()->setFormFactor(Plasma::Types::Vertical);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
qWarning() << "wrong location, couldn't update the panel position" << location();
|
||||
}
|
||||
@ -377,7 +360,7 @@ void DockView::setMaxThickness(int thickness)
|
||||
{
|
||||
if (m_maxThickness == thickness)
|
||||
return;
|
||||
|
||||
|
||||
m_maxThickness = thickness;
|
||||
syncGeometry();
|
||||
emit maxThicknessChanged();
|
||||
@ -392,7 +375,7 @@ void DockView::setMaxLength(int maxLength)
|
||||
{
|
||||
if (m_maxLength == maxLength)
|
||||
return;
|
||||
|
||||
|
||||
m_maxLength = maxLength;
|
||||
emit maxLengthChanged();
|
||||
}
|
||||
@ -406,10 +389,9 @@ void DockView::setMaskArea(QRect area)
|
||||
{
|
||||
if (m_maskArea == area)
|
||||
return;
|
||||
|
||||
|
||||
m_maskArea = area;
|
||||
setMask(m_maskArea);
|
||||
|
||||
//qDebug() << "dock mask set:" << m_maskArea;
|
||||
emit maskAreaChanged();
|
||||
}
|
||||
@ -423,7 +405,7 @@ void DockView::setShadow(int shadow)
|
||||
{
|
||||
if (m_shadow == shadow)
|
||||
return;
|
||||
|
||||
|
||||
m_shadow = shadow;
|
||||
emit shadowChanged();
|
||||
}
|
||||
@ -432,11 +414,11 @@ bool DockView::tasksPresent()
|
||||
{
|
||||
foreach (Plasma::Applet *applet, containment()->applets()) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
|
||||
|
||||
if (meta.pluginId() == "org.kde.latte.plasmoid")
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -448,32 +430,30 @@ VisibilityManager *DockView::visibility()
|
||||
bool DockView::event(QEvent *e)
|
||||
{
|
||||
emit eventTriggered(e);
|
||||
|
||||
return ContainmentView::event(e);
|
||||
}
|
||||
|
||||
QList<int> DockView::freeEdges() const
|
||||
{
|
||||
const auto edges = corona()->freeEdges(containment()->screen());
|
||||
|
||||
QList<int> edgesInt;
|
||||
|
||||
|
||||
foreach (Plasma::Types::Location edge, edges) {
|
||||
edgesInt.append(static_cast<int>(edge));
|
||||
}
|
||||
|
||||
|
||||
return edgesInt;
|
||||
}
|
||||
|
||||
void DockView::closeApplication()
|
||||
{
|
||||
DockCorona *dockCorona = qobject_cast<DockCorona *>(this->corona());
|
||||
|
||||
|
||||
if (dockCorona) {
|
||||
//m_configView->hide();
|
||||
if (m_configView)
|
||||
m_configView->deleteLater();
|
||||
|
||||
|
||||
dockCorona->closeApplication();
|
||||
}
|
||||
}
|
||||
@ -481,35 +461,31 @@ void DockView::closeApplication()
|
||||
QVariantList DockView::containmentActions()
|
||||
{
|
||||
QVariantList actions;
|
||||
|
||||
/*if (containment()->corona()->immutability() != Plasma::Types::Mutable) {
|
||||
return actions;
|
||||
}*/
|
||||
|
||||
//FIXME: the trigger string it should be better to be supported this way
|
||||
//const QString trigger = Plasma::ContainmentActions::eventToString(event);
|
||||
const QString trigger = "RightButton;NoModifier";
|
||||
|
||||
Plasma::ContainmentActions *plugin = containment()->containmentActions().value(trigger);
|
||||
|
||||
|
||||
if (!plugin) {
|
||||
return actions;
|
||||
}
|
||||
|
||||
|
||||
if (plugin->containment() != containment()) {
|
||||
plugin->setContainment(containment());
|
||||
|
||||
// now configure it
|
||||
KConfigGroup cfg(containment()->corona()->config(), "ActionPlugins");
|
||||
cfg = KConfigGroup(&cfg, QString::number(containment()->containmentType()));
|
||||
KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
|
||||
plugin->restore(pluginConfig);
|
||||
}
|
||||
|
||||
|
||||
foreach (QAction *ac, plugin->contextualActions()) {
|
||||
actions << QVariant::fromValue<QAction *>(ac);
|
||||
}
|
||||
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
@ -518,22 +494,22 @@ QVariantList DockView::containmentActions()
|
||||
void DockView::addAppletItem(QObject *item)
|
||||
{
|
||||
PlasmaQuick::AppletQuickItem *dynItem = qobject_cast<PlasmaQuick::AppletQuickItem *>(item);
|
||||
|
||||
|
||||
if (!dynItem || m_appletItems.contains(dynItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_appletItems.append(dynItem);
|
||||
}
|
||||
|
||||
void DockView::removeAppletItem(QObject *item)
|
||||
{
|
||||
PlasmaQuick::AppletQuickItem *dynItem = qobject_cast<PlasmaQuick::AppletQuickItem *>(item);
|
||||
|
||||
|
||||
if (!dynItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_appletItems.removeAll(dynItem);
|
||||
}
|
||||
|
||||
@ -549,9 +525,8 @@ void DockView::mouseReleaseEvent(QMouseEvent *event)
|
||||
if (!event || !containment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PlasmaQuick::ContainmentView::mouseReleaseEvent(event);
|
||||
|
||||
event->setAccepted(containment()->containmentActions().contains(Plasma::ContainmentActions::eventToString(event)));
|
||||
}
|
||||
|
||||
@ -560,9 +535,9 @@ void DockView::mousePressEvent(QMouseEvent *event)
|
||||
if (!event || !containment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// PlasmaQuick::ContainmentView::mousePressEvent(event);
|
||||
|
||||
|
||||
//even if the menu is executed synchronously, other events may be processed
|
||||
//by the qml incubator when plasma is loading, so we need to guard there
|
||||
if (m_contextMenu) {
|
||||
@ -570,20 +545,19 @@ void DockView::mousePressEvent(QMouseEvent *event)
|
||||
PlasmaQuick::ContainmentView::mousePressEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << "1...";
|
||||
const QString trigger = Plasma::ContainmentActions::eventToString(event);
|
||||
|
||||
|
||||
if (trigger == "RightButton;NoModifier") {
|
||||
Plasma::ContainmentActions *plugin = containment()->containmentActions().value(trigger);
|
||||
|
||||
|
||||
if (!plugin || plugin->contextualActions().isEmpty()) {
|
||||
event->setAccepted(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << "2...";
|
||||
|
||||
//the plugin can be a single action or a context menu
|
||||
//Don't have an action list? execute as single action
|
||||
//and set the event position as action data
|
||||
@ -594,12 +568,10 @@ void DockView::mousePressEvent(QMouseEvent *event)
|
||||
event->accept();
|
||||
return;
|
||||
}*/
|
||||
|
||||
//qDebug() << "3...";
|
||||
|
||||
//FIXME: very inefficient appletAt() implementation
|
||||
Plasma::Applet *applet = 0;
|
||||
|
||||
|
||||
foreach (PlasmaQuick::AppletQuickItem *ai, m_appletItems) {
|
||||
if (ai && ai->isVisible() && ai->contains(ai->mapFromItem(contentItem(), event->pos()))) {
|
||||
applet = ai->applet();
|
||||
@ -608,36 +580,33 @@ void DockView::mousePressEvent(QMouseEvent *event)
|
||||
ai = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (applet) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
|
||||
|
||||
if ((meta.pluginId() != "org.kde.plasma.systemtray") &&
|
||||
(meta.pluginId() != "org.kde.latte.plasmoid")) {
|
||||
|
||||
//qDebug() << "4...";
|
||||
|
||||
QMenu *desktopMenu = new QMenu;
|
||||
desktopMenu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
m_contextMenu = desktopMenu;
|
||||
|
||||
|
||||
if (this->mouseGrabberItem()) {
|
||||
//workaround, this fixes for me most of the right click menu behavior
|
||||
if (applet) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
|
||||
|
||||
//gives the systemtray direct right click behavior for its applets
|
||||
if (meta.pluginId() != "org.kde.plasma.systemtray") {
|
||||
this->mouseGrabberItem()->ungrabMouse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << "5...";
|
||||
|
||||
|
||||
if (applet) {
|
||||
emit applet->contextualActionsAboutToShow();
|
||||
addAppletActions(desktopMenu, applet, event);
|
||||
@ -645,60 +614,54 @@ void DockView::mousePressEvent(QMouseEvent *event)
|
||||
emit containment()->contextualActionsAboutToShow();
|
||||
addContainmentActions(desktopMenu, event);
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << "6...";
|
||||
|
||||
//this is a workaround where Qt now creates the menu widget
|
||||
//in .exec before oxygen can polish it and set the following attribute
|
||||
desktopMenu->setAttribute(Qt::WA_TranslucentBackground);
|
||||
//end workaround
|
||||
|
||||
QPoint pos = event->globalPos();
|
||||
|
||||
|
||||
if (applet) {
|
||||
desktopMenu->adjustSize();
|
||||
|
||||
|
||||
if (screen()) {
|
||||
const QRect scr = screen()->geometry();
|
||||
|
||||
int smallStep = 3;
|
||||
|
||||
int x = event->globalPos().x() + smallStep;
|
||||
int y = event->globalPos().y() + smallStep;
|
||||
|
||||
|
||||
//qDebug()<<x << " - "<<y;
|
||||
|
||||
|
||||
if (event->globalPos().x() > scr.center().x()) {
|
||||
x = event->globalPos().x() - desktopMenu->width() - smallStep;
|
||||
}
|
||||
|
||||
|
||||
if (event->globalPos().y() > scr.center().y()) {
|
||||
y = event->globalPos().y() - desktopMenu->height() - smallStep;
|
||||
}
|
||||
|
||||
|
||||
pos = QPoint(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << "7...";
|
||||
|
||||
|
||||
if (desktopMenu->isEmpty()) {
|
||||
delete desktopMenu;
|
||||
event->accept();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
connect(desktopMenu, SIGNAL(aboutToHide()), this, SLOT(menuAboutToHide()));
|
||||
m_visibility->setBlockHiding(true);
|
||||
desktopMenu->popup(pos);
|
||||
|
||||
event->setAccepted(true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PlasmaQuick::ContainmentView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
@ -707,51 +670,51 @@ void DockView::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEve
|
||||
if (!containment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
foreach (QAction *action, applet->contextualActions()) {
|
||||
if (action) {
|
||||
desktopMenu->addAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!applet->failedToLaunch()) {
|
||||
QAction *runAssociatedApplication = applet->actions()->action(QStringLiteral("run associated application"));
|
||||
|
||||
|
||||
if (runAssociatedApplication && runAssociatedApplication->isEnabled()) {
|
||||
desktopMenu->addAction(runAssociatedApplication);
|
||||
}
|
||||
|
||||
|
||||
QAction *configureApplet = applet->actions()->action(QStringLiteral("configure"));
|
||||
|
||||
|
||||
if (configureApplet && configureApplet->isEnabled()) {
|
||||
desktopMenu->addAction(configureApplet);
|
||||
}
|
||||
|
||||
|
||||
QAction *appletAlternatives = applet->actions()->action(QStringLiteral("alternatives"));
|
||||
|
||||
|
||||
if (appletAlternatives && appletAlternatives->isEnabled()) {
|
||||
desktopMenu->addAction(appletAlternatives);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMenu *containmentMenu = new QMenu(i18nc("%1 is the name of the containment", "%1 Options", containment()->title()), desktopMenu);
|
||||
addContainmentActions(containmentMenu, event);
|
||||
|
||||
|
||||
if (!containmentMenu->isEmpty()) {
|
||||
int enabled = 0;
|
||||
//count number of real actions
|
||||
QListIterator<QAction *> actionsIt(containmentMenu->actions());
|
||||
|
||||
|
||||
while (enabled < 3 && actionsIt.hasNext()) {
|
||||
QAction *action = actionsIt.next();
|
||||
|
||||
|
||||
if (action->isVisible() && !action->isSeparator()) {
|
||||
++enabled;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
desktopMenu->addSeparator();
|
||||
|
||||
|
||||
if (enabled) {
|
||||
//if there is only one, don't create a submenu
|
||||
if (enabled < 2) {
|
||||
@ -765,17 +728,17 @@ void DockView::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEve
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (containment()->immutability() == Plasma::Types::Mutable &&
|
||||
(containment()->containmentType() != Plasma::Types::PanelContainment || containment()->isUserConfiguring())) {
|
||||
QAction *closeApplet = applet->actions()->action(QStringLiteral("remove"));
|
||||
|
||||
|
||||
//qDebug() << "checking for removal" << closeApplet;
|
||||
if (closeApplet) {
|
||||
if (!desktopMenu->isEmpty()) {
|
||||
desktopMenu->addSeparator();
|
||||
}
|
||||
|
||||
|
||||
//qDebug() << "adding close action" << closeApplet->isEnabled() << closeApplet->isVisible();
|
||||
desktopMenu->addAction(closeApplet);
|
||||
}
|
||||
@ -788,34 +751,33 @@ void DockView::addContainmentActions(QMenu *desktopMenu, QEvent *event)
|
||||
if (!containment()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (containment()->corona()->immutability() != Plasma::Types::Mutable &&
|
||||
!KAuthorized::authorizeAction(QStringLiteral("plasma/containment_actions"))) {
|
||||
//qDebug() << "immutability";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//this is what ContainmentPrivate::prepareContainmentActions was
|
||||
const QString trigger = Plasma::ContainmentActions::eventToString(event);
|
||||
//"RightButton;NoModifier"
|
||||
Plasma::ContainmentActions *plugin = containment()->containmentActions().value(trigger);
|
||||
|
||||
|
||||
if (!plugin) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (plugin->containment() != containment()) {
|
||||
plugin->setContainment(containment());
|
||||
|
||||
// now configure it
|
||||
KConfigGroup cfg(containment()->corona()->config(), "ActionPlugins");
|
||||
cfg = KConfigGroup(&cfg, QString::number(containment()->containmentType()));
|
||||
KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger);
|
||||
plugin->restore(pluginConfig);
|
||||
}
|
||||
|
||||
|
||||
QList<QAction *> actions = plugin->contextualActions();
|
||||
|
||||
|
||||
if (actions.isEmpty()) {
|
||||
//it probably didn't bother implementing the function. give the user a chance to set
|
||||
//a better plugin. note that if the user sets no-plugin this won't happen...
|
||||
@ -827,10 +789,9 @@ void DockView::addContainmentActions(QMenu *desktopMenu, QEvent *event)
|
||||
} else {
|
||||
desktopMenu->addActions(actions);
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//!END overriding context menus behavior
|
||||
|
||||
}
|
||||
|
@ -44,79 +44,79 @@ namespace Latte {
|
||||
|
||||
class DockView : public PlasmaQuick::ContainmentView {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Q_PROPERTY(int docksCount READ docksCount NOTIFY docksCountChanged)
|
||||
Q_PROPERTY(int width READ width NOTIFY widthChanged)
|
||||
Q_PROPERTY(int height READ height NOTIFY heightChanged)
|
||||
Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength NOTIFY maxLengthChanged)
|
||||
Q_PROPERTY(int maxThickness READ maxThickness WRITE setMaxThickness NOTIFY maxThicknessChanged)
|
||||
Q_PROPERTY(int shadow READ shadow WRITE setShadow NOTIFY shadowChanged)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
public:
|
||||
DockView(Plasma::Corona *corona, QScreen *targetScreen = nullptr);
|
||||
virtual ~DockView();
|
||||
|
||||
|
||||
void init();
|
||||
|
||||
|
||||
void adaptToScreen(QScreen *screen);
|
||||
|
||||
|
||||
void resizeWindow();
|
||||
void syncGeometry();
|
||||
|
||||
|
||||
int currentThickness() const;
|
||||
void updateAbsDockGeometry();
|
||||
|
||||
|
||||
int docksCount() const;
|
||||
|
||||
|
||||
int maxLength() const;
|
||||
void setMaxLength(int maxLength);
|
||||
|
||||
|
||||
int maxThickness() const;
|
||||
void setMaxThickness(int thickness);
|
||||
|
||||
|
||||
int shadow() const;
|
||||
void setShadow(int shadow);
|
||||
|
||||
|
||||
QRect maskArea() const;
|
||||
void setMaskArea(QRect area);
|
||||
|
||||
|
||||
VisibilityManager *visibility();
|
||||
|
||||
|
||||
QQmlListProperty<QScreen> screens();
|
||||
static int countScreens(QQmlListProperty<QScreen> *property);
|
||||
static QScreen *atScreens(QQmlListProperty<QScreen> *property, int index);
|
||||
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void addAppletItem(QObject *item);
|
||||
Q_INVOKABLE void removeAppletItem(QObject *item);
|
||||
|
||||
|
||||
Q_INVOKABLE void addNewDock();
|
||||
Q_INVOKABLE void removeDock();
|
||||
|
||||
|
||||
Q_INVOKABLE QList<int> freeEdges() const;
|
||||
Q_INVOKABLE QVariantList containmentActions();
|
||||
Q_INVOKABLE void setLocalDockGeometry(const QRect &geometry);
|
||||
Q_INVOKABLE bool tasksPresent();
|
||||
|
||||
|
||||
Q_INVOKABLE void closeApplication();
|
||||
|
||||
|
||||
protected slots:
|
||||
void showConfigurationInterface(Plasma::Applet *applet) override;
|
||||
|
||||
|
||||
protected:
|
||||
bool event(QEvent *ev) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
||||
|
||||
signals:
|
||||
void addInternalViewSplitter();
|
||||
void removeInternalViewSplitter();
|
||||
void eventTriggered(QEvent *ev);
|
||||
|
||||
|
||||
void docksCountChanged();
|
||||
void widthChanged();
|
||||
void heightChanged();
|
||||
@ -125,26 +125,26 @@ signals:
|
||||
void visibilityChanged();
|
||||
void maskAreaChanged();
|
||||
void shadowChanged();
|
||||
|
||||
|
||||
void localDockGeometryChanged();
|
||||
|
||||
|
||||
private slots:
|
||||
void menuAboutToHide();
|
||||
void statusChanged(Plasma::Types::ItemStatus);
|
||||
|
||||
|
||||
private:
|
||||
void initWindow();
|
||||
|
||||
|
||||
void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event);
|
||||
void addContainmentActions(QMenu *desktopMenu, QEvent *event);
|
||||
void updatePosition();
|
||||
void updateFormFactor();
|
||||
|
||||
|
||||
private:
|
||||
int m_maxLength{INT_MAX};
|
||||
int m_maxThickness{24};
|
||||
int m_shadow{0};
|
||||
|
||||
|
||||
QRect m_localDockGeometry;
|
||||
QRect m_maskArea;
|
||||
QMenu *m_contextMenu;
|
||||
|
@ -44,15 +44,12 @@ static const char version[] = "0.1";
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationVersion(version);
|
||||
|
||||
app.setOrganizationDomain(QStringLiteral("latte-dock"));
|
||||
KLocalizedString::setApplicationDomain("latte-dock");
|
||||
app.setApplicationName(QStringLiteral("Latte Dock"));
|
||||
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("latte-dock")));
|
||||
|
||||
//! set pattern for debug messages
|
||||
//! [%{type}] [%{function}:%{line}] - %{message} [%{backtrace}]
|
||||
qSetMessagePattern(QStringLiteral(
|
||||
@ -63,9 +60,7 @@ int main(int argc, char **argv)
|
||||
CICYAN " - " CNORMAL "%{message}"
|
||||
CIRED "%{if-fatal}\n%{backtrace depth=8 separator=\"\n\"}%{endif}"
|
||||
"%{if-critical}\n%{backtrace depth=8 separator=\"\n\"}%{endif}" CNORMAL));
|
||||
|
||||
// qputenv("QT_QUICK_CONTROLS_1_STYLE", "Desktop");
|
||||
Latte::DockCorona corona;
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class ConfigView : public QQuickView {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(PlasmaQuick::ConfigModel *configModel READ configModel CONSTANT)
|
||||
Q_PROPERTY(QString appletGlobalShortcut READ appletGlobalShortcut WRITE setAppletGlobalShortcut NOTIFY appletGlobalShortcutChanged)
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param applet the applet of this ConfigView
|
||||
@ -55,29 +55,29 @@ public:
|
||||
**/
|
||||
ConfigView(Plasma::Applet *applet, QWindow *parent = 0);
|
||||
~ConfigView() override;
|
||||
|
||||
|
||||
virtual void init();
|
||||
|
||||
|
||||
Plasma::Applet *applet();
|
||||
|
||||
|
||||
QString appletGlobalShortcut() const;
|
||||
void setAppletGlobalShortcut(const QString &shortcut);
|
||||
|
||||
|
||||
/**
|
||||
* @return the ConfigModel of the ConfigView
|
||||
**/
|
||||
PlasmaQuick::ConfigModel *configModel() const;
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void appletGlobalShortcutChanged();
|
||||
|
||||
|
||||
protected:
|
||||
void hideEvent(QHideEvent *ev) override;
|
||||
void resizeEvent(QResizeEvent *re) override;
|
||||
|
||||
|
||||
private:
|
||||
ConfigViewPrivate *const d;
|
||||
|
||||
|
||||
Q_PRIVATE_SLOT(d, void updateMinimumWidth())
|
||||
Q_PRIVATE_SLOT(d, void updateMinimumHeight())
|
||||
Q_PRIVATE_SLOT(d, void updateMaximumWidth())
|
||||
|
@ -44,7 +44,7 @@ class ContainmentView : public KQuickAddons::QuickViewSharedEngine {
|
||||
Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
|
||||
Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
||||
Q_PROPERTY(QRectF screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param corona the corona of this view
|
||||
@ -52,76 +52,76 @@ public:
|
||||
**/
|
||||
explicit ContainmentView(Plasma::Corona *corona, QWindow *parent = 0);
|
||||
~ContainmentView() override;
|
||||
|
||||
|
||||
/**
|
||||
* @return the corona of this view
|
||||
**/
|
||||
Plasma::Corona *corona() const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the KConfigGroup of this view
|
||||
**/
|
||||
virtual KConfigGroup config() const;
|
||||
|
||||
|
||||
/**
|
||||
* sets the containment for this view
|
||||
* @param cont the containment of this view
|
||||
**/
|
||||
void setContainment(Plasma::Containment *cont);
|
||||
|
||||
|
||||
/**
|
||||
* @return the containment of this ContainmentView
|
||||
**/
|
||||
Plasma::Containment *containment() const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the location of this ContainmentView
|
||||
**/
|
||||
Plasma::Types::Location location() const;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the location of the ContainmentView
|
||||
* @param location the location of the ContainmentView
|
||||
**/
|
||||
void setLocation(Plasma::Types::Location location);
|
||||
|
||||
|
||||
/**
|
||||
* @return the formfactor of the ContainmentView
|
||||
**/
|
||||
Plasma::Types::FormFactor formFactor() const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the screenGeometry of the ContainmentView
|
||||
**/
|
||||
QRectF screenGeometry();
|
||||
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* It will be called when the configuration is requested
|
||||
*/
|
||||
virtual void showConfigurationInterface(Plasma::Applet *applet);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* emitted when the location is changed
|
||||
**/
|
||||
void locationChanged(Plasma::Types::Location location);
|
||||
|
||||
|
||||
/**
|
||||
* emitted when the formfactor is changed
|
||||
**/
|
||||
void formFactorChanged(Plasma::Types::FormFactor formFactor);
|
||||
|
||||
|
||||
/**
|
||||
* emitted when the containment is changed
|
||||
**/
|
||||
void containmentChanged();
|
||||
|
||||
|
||||
/**
|
||||
* emitted when the screenGeometry is changed
|
||||
**/
|
||||
void screenGeometryChanged();
|
||||
|
||||
|
||||
private:
|
||||
ContainmentViewPrivate *const d;
|
||||
Q_PRIVATE_SLOT(d, void updateDestroyed(bool))
|
||||
|
@ -44,7 +44,7 @@ class View : public QQuickView {
|
||||
Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
|
||||
Q_PROPERTY(Plasma::Types::FormFactor formFactor READ formFactor NOTIFY formFactorChanged)
|
||||
Q_PROPERTY(QRectF screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
|
||||
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param corona the corona of this view
|
||||
@ -52,76 +52,76 @@ public:
|
||||
**/
|
||||
explicit View(Plasma::Corona *corona, QWindow *parent = 0);
|
||||
~View() override;
|
||||
|
||||
|
||||
/**
|
||||
* @return the corona of this view
|
||||
**/
|
||||
Plasma::Corona *corona() const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the KConfigGroup of this view
|
||||
**/
|
||||
virtual KConfigGroup config() const;
|
||||
|
||||
|
||||
/**
|
||||
* sets the containment for this view
|
||||
* @param cont the containment of this view
|
||||
**/
|
||||
void setContainment(Plasma::Containment *cont);
|
||||
|
||||
|
||||
/**
|
||||
* @return the containment of this View
|
||||
**/
|
||||
Plasma::Containment *containment() const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the location of this View
|
||||
**/
|
||||
Plasma::Types::Location location() const;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the location of the View
|
||||
* @param location the location of the View
|
||||
**/
|
||||
void setLocation(Plasma::Types::Location location);
|
||||
|
||||
|
||||
/**
|
||||
* @return the formfactor of the View
|
||||
**/
|
||||
Plasma::Types::FormFactor formFactor() const;
|
||||
|
||||
|
||||
/**
|
||||
* @return the screenGeometry of the View
|
||||
**/
|
||||
QRectF screenGeometry();
|
||||
|
||||
|
||||
protected Q_SLOTS:
|
||||
/**
|
||||
* It will be called when the configuration is requested
|
||||
*/
|
||||
virtual void showConfigurationInterface(Plasma::Applet *applet);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* emitted when the location is changed
|
||||
**/
|
||||
void locationChanged(Plasma::Types::Location location);
|
||||
|
||||
|
||||
/**
|
||||
* emitted when the formfactor is changed
|
||||
**/
|
||||
void formFactorChanged(Plasma::Types::FormFactor formFactor);
|
||||
|
||||
|
||||
/**
|
||||
* emitted when the containment is changed
|
||||
**/
|
||||
void containmentChanged();
|
||||
|
||||
|
||||
/**
|
||||
* emitted when the screenGeometry is changed
|
||||
**/
|
||||
void screenGeometryChanged();
|
||||
|
||||
|
||||
private:
|
||||
ViewPrivate *const d;
|
||||
friend class ViewPrivate;
|
||||
|
@ -33,17 +33,15 @@ VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView
|
||||
: QObject(q), q(q), view(view), wm(AbstractWindowInterface::getInstance(view, nullptr))
|
||||
{
|
||||
DockView *dockView = qobject_cast<DockView *>(view);
|
||||
|
||||
|
||||
if (dockView) {
|
||||
connect(dockView, &DockView::eventTriggered, this, &VisibilityManagerPrivate::event);
|
||||
}
|
||||
|
||||
|
||||
timerCheckWindows.setInterval(350);
|
||||
timerCheckWindows.setSingleShot(true);
|
||||
|
||||
timerShow.setSingleShot(true);
|
||||
timerHide.setSingleShot(true);
|
||||
|
||||
connect(&timerCheckWindows, &QTimer::timeout, this, &VisibilityManagerPrivate::checkAllWindows);
|
||||
connect(&timerShow, &QTimer::timeout, this, [this]() {
|
||||
if (isHidden) {
|
||||
@ -57,7 +55,6 @@ VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView
|
||||
emit this->q->mustBeHide();
|
||||
}
|
||||
});
|
||||
|
||||
wm->setDockDefaultFlags();
|
||||
}
|
||||
|
||||
@ -71,47 +68,44 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
{
|
||||
if (this->mode == mode)
|
||||
return;
|
||||
|
||||
|
||||
// clear mode
|
||||
if (this->mode == Dock::AlwaysVisible)
|
||||
wm->removeDockStruts();
|
||||
|
||||
|
||||
for (auto &c : connections) {
|
||||
disconnect(c);
|
||||
}
|
||||
|
||||
|
||||
timerShow.stop();
|
||||
timerHide.stop();
|
||||
timerCheckWindows.stop();
|
||||
|
||||
this->mode = mode;
|
||||
|
||||
|
||||
switch (this->mode) {
|
||||
case Dock::AlwaysVisible: {
|
||||
if (view->containment() && !view->containment()->isUserConfiguring())
|
||||
wm->setDockStruts(dockRect, view->location());
|
||||
|
||||
|
||||
connections[0] = connect(view->containment(), &Plasma::Containment::locationChanged
|
||||
, this, [&]() {
|
||||
if (view->containment()->isUserConfiguring())
|
||||
wm->removeDockStruts();
|
||||
});
|
||||
|
||||
connections[1] = connect(view->containment(), &Plasma::Containment::userConfiguringChanged
|
||||
, this, [&](bool configuring) {
|
||||
if (!configuring)
|
||||
wm->setDockStruts(dockRect, view->containment()->location());
|
||||
});
|
||||
|
||||
raiseDock(true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Dock::AutoHide: {
|
||||
raiseDock(containsMouse);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Dock::DodgeActive: {
|
||||
connections[0] = connect(wm.get(), &AbstractWindowInterface::activeWindowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeActive);
|
||||
@ -121,11 +115,10 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
, this, [&](int) {
|
||||
dodgeActive(wm->activeWindow());
|
||||
});
|
||||
|
||||
dodgeActive(wm->activeWindow());
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Dock::DodgeMaximized: {
|
||||
connections[0] = connect(wm.get(), &AbstractWindowInterface::activeWindowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeMaximized);
|
||||
@ -135,19 +128,17 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
, this, [&](int) {
|
||||
dodgeMaximized(wm->activeWindow());
|
||||
});
|
||||
|
||||
dodgeMaximized(wm->activeWindow());
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case Dock::DodgeAllWindows: {
|
||||
for (const auto &wid : wm->windows()) {
|
||||
windows.insert({wid, wm->requestInfo(wid)});
|
||||
}
|
||||
|
||||
|
||||
connections[0] = connect(wm.get(), &AbstractWindowInterface::windowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeWindows);
|
||||
|
||||
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowRemoved
|
||||
, this, [&](WId wid) {
|
||||
windows.erase(wid);
|
||||
@ -162,13 +153,11 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
, this, [&](int) {
|
||||
timerCheckWindows.start();
|
||||
});
|
||||
|
||||
timerCheckWindows.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
saveConfig();
|
||||
|
||||
emit q->modeChanged();
|
||||
}
|
||||
|
||||
@ -176,12 +165,12 @@ inline void VisibilityManagerPrivate::setIsHidden(bool isHidden)
|
||||
{
|
||||
if (this->isHidden == isHidden)
|
||||
return;
|
||||
|
||||
|
||||
if (blockHiding) {
|
||||
qWarning() << "isHidden property is blocked, ignoring update";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this->isHidden = isHidden;
|
||||
emit q->isHiddenChanged();
|
||||
}
|
||||
@ -190,24 +179,22 @@ void VisibilityManagerPrivate::setBlockHiding(bool blockHiding)
|
||||
{
|
||||
if (this->blockHiding == blockHiding)
|
||||
return;
|
||||
|
||||
|
||||
this->blockHiding = blockHiding;
|
||||
|
||||
qDebug() << "blockHiding:" << blockHiding;
|
||||
|
||||
|
||||
if (this->blockHiding) {
|
||||
timerHide.stop();
|
||||
|
||||
|
||||
if (isHidden) {
|
||||
isHidden = false;
|
||||
|
||||
emit q->isHiddenChanged();
|
||||
emit q->mustBeShown();
|
||||
}
|
||||
} else {
|
||||
updateHiddenState();
|
||||
}
|
||||
|
||||
|
||||
emit q->blockHidingChanged();
|
||||
}
|
||||
|
||||
@ -229,13 +216,13 @@ inline void VisibilityManagerPrivate::raiseDock(bool raise)
|
||||
{
|
||||
if (raise) {
|
||||
timerHide.stop();
|
||||
|
||||
|
||||
if (!timerShow.isActive()) {
|
||||
timerShow.start();
|
||||
}
|
||||
} else if (!blockHiding && !dragEnter) {
|
||||
timerShow.stop();
|
||||
|
||||
|
||||
if (!timerHide.isActive())
|
||||
timerHide.start();
|
||||
}
|
||||
@ -245,20 +232,20 @@ void VisibilityManagerPrivate::updateHiddenState()
|
||||
{
|
||||
if (dragEnter)
|
||||
return;
|
||||
|
||||
|
||||
switch (mode) {
|
||||
case Dock::AutoHide:
|
||||
raiseDock(containsMouse);
|
||||
break;
|
||||
|
||||
|
||||
case Dock::DodgeActive:
|
||||
dodgeActive(wm->activeWindow());
|
||||
break;
|
||||
|
||||
|
||||
case Dock::DodgeMaximized:
|
||||
dodgeMaximized(wm->activeWindow());
|
||||
break;
|
||||
|
||||
|
||||
case Dock::DodgeAllWindows:
|
||||
dodgeWindows(wm->activeWindow());
|
||||
break;
|
||||
@ -269,9 +256,9 @@ inline void VisibilityManagerPrivate::setDockRect(const QRect &dockRect)
|
||||
{
|
||||
if (!view->containment() || this->dockRect == dockRect)
|
||||
return;
|
||||
|
||||
|
||||
this->dockRect = dockRect;
|
||||
|
||||
|
||||
if (mode == Dock::AlwaysVisible && !view->containment()->isUserConfiguring()) {
|
||||
wm->setDockStruts(this->dockRect, view->containment()->location());
|
||||
}
|
||||
@ -280,34 +267,34 @@ inline void VisibilityManagerPrivate::setDockRect(const QRect &dockRect)
|
||||
void VisibilityManagerPrivate::dodgeActive(WId wid)
|
||||
{
|
||||
auto winfo = wm->requestInfo(wid);
|
||||
|
||||
|
||||
if (!winfo.isValid())
|
||||
return;
|
||||
|
||||
|
||||
if (!winfo.isActive()) {
|
||||
if (winfo.isPlasmaDesktop())
|
||||
raiseDock(true);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
raiseDock(wm->isOnCurrentDesktop(wid) && !intersects(winfo));
|
||||
}
|
||||
|
||||
void VisibilityManagerPrivate::dodgeMaximized(WId wid)
|
||||
{
|
||||
auto winfo = wm->requestInfo(wid);
|
||||
|
||||
|
||||
if (!winfo.isValid())
|
||||
return;
|
||||
|
||||
|
||||
if (!winfo.isActive()) {
|
||||
if (winfo.isPlasmaDesktop())
|
||||
raiseDock(true);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
raiseDock(wm->isOnCurrentDesktop(wid) && !winfo.isMaximized());
|
||||
}
|
||||
|
||||
@ -315,13 +302,13 @@ void VisibilityManagerPrivate::dodgeWindows(WId wid)
|
||||
{
|
||||
if (windows.find(wid) == std::end(windows))
|
||||
return;
|
||||
|
||||
|
||||
auto winfo = wm->requestInfo(wid);
|
||||
windows[wid] = winfo;
|
||||
|
||||
|
||||
if (!winfo.isValid() || !wm->isOnCurrentDesktop(wid))
|
||||
return;
|
||||
|
||||
|
||||
if (intersects(winfo))
|
||||
raiseDock(false);
|
||||
else
|
||||
@ -331,22 +318,21 @@ void VisibilityManagerPrivate::dodgeWindows(WId wid)
|
||||
void VisibilityManagerPrivate::checkAllWindows()
|
||||
{
|
||||
bool raise{true};
|
||||
|
||||
|
||||
for (const auto &winfo : windows) {
|
||||
//! std::pair<WId, WindowInfoWrap>
|
||||
if (!std::get<1>(winfo).isValid() || !wm->isOnCurrentDesktop(std::get<0>(winfo)))
|
||||
continue;
|
||||
|
||||
|
||||
if (std::get<1>(winfo).isFullscreen()) {
|
||||
raise = false;
|
||||
break;
|
||||
|
||||
} else if (intersects(std::get<1>(winfo))) {
|
||||
raise = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
raiseDock(raise);
|
||||
}
|
||||
|
||||
@ -359,13 +345,11 @@ inline void VisibilityManagerPrivate::saveConfig()
|
||||
{
|
||||
if (!view->containment())
|
||||
return;
|
||||
|
||||
|
||||
auto config = view->containment()->config();
|
||||
|
||||
config.writeEntry("visibility", static_cast<int>(mode));
|
||||
config.writeEntry("timerShow", timerShow.interval());
|
||||
config.writeEntry("timerHide", timerHide.interval());
|
||||
|
||||
view->containment()->configNeedsSaving();
|
||||
}
|
||||
|
||||
@ -373,17 +357,13 @@ inline void VisibilityManagerPrivate::restoreConfig()
|
||||
{
|
||||
if (!view->containment())
|
||||
return;
|
||||
|
||||
|
||||
auto config = view->containment()->config();
|
||||
|
||||
timerShow.setInterval(config.readEntry("timerShow", 200));
|
||||
timerHide.setInterval(config.readEntry("timerHide", 700));
|
||||
|
||||
auto mode = static_cast<Dock::Visibility>(config.readEntry("visibility", static_cast<int>(Dock::DodgeActive)));
|
||||
|
||||
emit q->timerShowChanged();
|
||||
emit q->timerHideChanged();
|
||||
|
||||
setMode(mode);
|
||||
}
|
||||
|
||||
@ -393,45 +373,41 @@ bool VisibilityManagerPrivate::event(QEvent *ev)
|
||||
case QEvent::Enter:
|
||||
if (containsMouse)
|
||||
break;
|
||||
|
||||
|
||||
containsMouse = true;
|
||||
emit q->containsMouseChanged();
|
||||
|
||||
|
||||
if (mode != Dock::AlwaysVisible)
|
||||
raiseDock(true);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case QEvent::Leave:
|
||||
if (!containsMouse)
|
||||
break;
|
||||
|
||||
|
||||
containsMouse = false;
|
||||
emit q->containsMouseChanged();
|
||||
updateHiddenState();
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case QEvent::DragEnter:
|
||||
dragEnter = true;
|
||||
emit q->mustBeShown();
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case QEvent::DragLeave:
|
||||
case QEvent::Drop:
|
||||
dragEnter = false;
|
||||
updateHiddenState();
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case QEvent::Show:
|
||||
wm->setDockDefaultFlags();
|
||||
restoreConfig();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return QObject::event(ev);
|
||||
}
|
||||
//! END: VisibilityManagerPrivate implementation
|
||||
@ -444,7 +420,6 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view)
|
||||
|
||||
VisibilityManager::~VisibilityManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Dock::Visibility VisibilityManager::mode() const
|
||||
|
@ -35,51 +35,51 @@ class VisibilityManagerPrivate;
|
||||
|
||||
class VisibilityManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Q_PROPERTY(Latte::Dock::Visibility mode READ mode WRITE setMode NOTIFY modeChanged)
|
||||
Q_PROPERTY(bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged)
|
||||
Q_PROPERTY(bool blockHiding READ blockHiding WRITE setBlockHiding NOTIFY blockHidingChanged)
|
||||
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
|
||||
Q_PROPERTY(int timerShow READ timerShow WRITE setTimerShow NOTIFY timerShowChanged)
|
||||
Q_PROPERTY(int timerHide READ timerHide WRITE setTimerHide NOTIFY timerHideChanged)
|
||||
|
||||
|
||||
public:
|
||||
explicit VisibilityManager(PlasmaQuick::ContainmentView *view);
|
||||
virtual ~VisibilityManager();
|
||||
|
||||
|
||||
Latte::Dock::Visibility mode() const;
|
||||
void setMode(Latte::Dock::Visibility mode);
|
||||
|
||||
|
||||
bool isHidden() const;
|
||||
void setIsHidden(bool isHidden);
|
||||
|
||||
|
||||
bool blockHiding() const;
|
||||
void setBlockHiding(bool blockHiding);
|
||||
|
||||
|
||||
bool containsMouse() const;
|
||||
|
||||
|
||||
int timerShow() const;
|
||||
void setTimerShow(int msec);
|
||||
|
||||
|
||||
int timerHide() const;
|
||||
void setTimerHide(int msec);
|
||||
|
||||
|
||||
/**
|
||||
* @brief updateDockGeometry, the window geometry in absolute coordinates.
|
||||
*/
|
||||
void updateDockGeometry(const QRect &geometry);
|
||||
|
||||
|
||||
signals:
|
||||
void mustBeShown();
|
||||
void mustBeHide();
|
||||
|
||||
|
||||
void modeChanged();
|
||||
void isHiddenChanged();
|
||||
void blockHidingChanged();
|
||||
void containsMouseChanged();
|
||||
void timerShowChanged();
|
||||
void timerHideChanged();
|
||||
|
||||
|
||||
private:
|
||||
VisibilityManagerPrivate *const d;
|
||||
};
|
||||
|
@ -23,35 +23,35 @@ class VisibilityManager;
|
||||
*/
|
||||
class VisibilityManagerPrivate : public QObject {
|
||||
Q_GADGET
|
||||
|
||||
|
||||
public:
|
||||
VisibilityManagerPrivate(PlasmaQuick::ContainmentView *view, VisibilityManager *q);
|
||||
~VisibilityManagerPrivate();
|
||||
|
||||
|
||||
void setMode(Dock::Visibility mode);
|
||||
void setIsHidden(bool isHidden);
|
||||
void setBlockHiding(bool blockHiding);
|
||||
void setTimerShow(int msec);
|
||||
void setTimerHide(int msec);
|
||||
|
||||
|
||||
void raiseDock(bool raise);
|
||||
void updateHiddenState();
|
||||
|
||||
|
||||
void setDockRect(const QRect &rect);
|
||||
|
||||
|
||||
void windowAdded(WId id);
|
||||
void dodgeActive(WId id);
|
||||
void dodgeMaximized(WId id);
|
||||
void dodgeWindows(WId id);
|
||||
void checkAllWindows();
|
||||
|
||||
|
||||
bool intersects(const WindowInfoWrap &winfo);
|
||||
|
||||
|
||||
void saveConfig();
|
||||
void restoreConfig();
|
||||
|
||||
|
||||
bool event(QEvent *ev) override;
|
||||
|
||||
|
||||
VisibilityManager *q;
|
||||
PlasmaQuick::ContainmentView *view;
|
||||
std::unique_ptr<AbstractWindowInterface> wm;
|
||||
|
@ -31,7 +31,6 @@ WindowInfoWrap::WindowInfoWrap()
|
||||
, m_isPlasmaDesktop(false)
|
||||
, m_wid(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WindowInfoWrap::WindowInfoWrap(const WindowInfoWrap &other)
|
||||
@ -49,7 +48,6 @@ WindowInfoWrap &WindowInfoWrap::operator=(const WindowInfoWrap &rhs)
|
||||
m_isPlasmaDesktop = rhs.m_isPlasmaDesktop;
|
||||
m_geometry = rhs.m_geometry;
|
||||
m_wid = rhs.m_wid;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -32,37 +32,37 @@ class WindowInfoWrap {
|
||||
public:
|
||||
explicit WindowInfoWrap();
|
||||
WindowInfoWrap(const WindowInfoWrap &other);
|
||||
|
||||
|
||||
WindowInfoWrap &operator=(const WindowInfoWrap &rhs);
|
||||
|
||||
|
||||
bool operator==(const WindowInfoWrap &rhs) const;
|
||||
bool operator<(const WindowInfoWrap &rhs) const;
|
||||
bool operator>(const WindowInfoWrap &rhs) const;
|
||||
|
||||
|
||||
bool isValid() const;
|
||||
void setIsValid(bool isValid);
|
||||
|
||||
|
||||
bool isActive() const;
|
||||
void setIsActive(bool isActive);
|
||||
|
||||
|
||||
bool isMinimized() const;
|
||||
void setIsMinimized(bool isMinimized);
|
||||
|
||||
|
||||
bool isMaximized() const;
|
||||
void setIsMaximized(bool isMaximized);
|
||||
|
||||
|
||||
bool isFullscreen() const;
|
||||
void setIsFullscreen(bool isFullscreen);
|
||||
|
||||
|
||||
bool isPlasmaDesktop() const;
|
||||
void setIsPlasmaDesktop(bool isPlasmaDesktop);
|
||||
|
||||
|
||||
QRect geometry() const;
|
||||
void setGeometry(const QRect &geometry);
|
||||
|
||||
|
||||
WId wid() const;
|
||||
void setWid(WId wid);
|
||||
|
||||
|
||||
private:
|
||||
bool m_isValid : 1;
|
||||
bool m_isActive : 1;
|
||||
|
@ -34,15 +34,12 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
: AbstractWindowInterface(view, parent)
|
||||
{
|
||||
Q_ASSERT(view != nullptr);
|
||||
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged
|
||||
, this, &AbstractWindowInterface::activeWindowChanged);
|
||||
|
||||
connections << connect(KWindowSystem::self()
|
||||
, static_cast<void (KWindowSystem::*)(WId, NET::Properties, NET::Properties2)>
|
||||
(&KWindowSystem::windowChanged)
|
||||
, this, &XWindowInterface::windowChangedProxy);
|
||||
|
||||
auto addWindow = [&](WId wid) {
|
||||
if (std::find(m_windows.cbegin(), m_windows.cend(), wid) == m_windows.cend()) {
|
||||
if (isValidWindow(KWindowInfo(wid, NET::WMWindowType))) {
|
||||
@ -51,19 +48,16 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, addWindow);
|
||||
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, [this](WId wid) {
|
||||
if (std::find(m_windows.cbegin(), m_windows.cend(), wid) != m_windows.end()) {
|
||||
m_windows.remove(wid);
|
||||
emit windowRemoved(wid);
|
||||
}
|
||||
});
|
||||
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged
|
||||
, this, &AbstractWindowInterface::currentDesktopChanged);
|
||||
|
||||
|
||||
// fill windows list
|
||||
foreach (const auto &wid, KWindowSystem::self()->windows()) {
|
||||
addWindow(wid);
|
||||
@ -73,11 +67,11 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
XWindowInterface::~XWindowInterface()
|
||||
{
|
||||
qDebug() << "x window interface deleting...";
|
||||
|
||||
|
||||
foreach (auto var, connections) {
|
||||
QObject::disconnect(var);
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "x window interface connections removed...";
|
||||
}
|
||||
|
||||
@ -87,12 +81,10 @@ void XWindowInterface::setDockDefaultFlags()
|
||||
| Qt::WindowStaysOnTopHint
|
||||
| Qt::NoDropShadowWindowHint
|
||||
| Qt::WindowDoesNotAcceptFocus);
|
||||
|
||||
NETWinInfo winfo(QX11Info::connection()
|
||||
, static_cast<xcb_window_t>(m_view->winId())
|
||||
, static_cast<xcb_window_t>(m_view->winId())
|
||||
, 0, 0);
|
||||
|
||||
winfo.setAllowedActions(NET::ActionChangeDesktop);
|
||||
KWindowSystem::setType(m_view->winId(), NET::Dock);
|
||||
KWindowSystem::setState(m_view->winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||
@ -113,38 +105,37 @@ const std::list<WId> &XWindowInterface::windows() const
|
||||
void XWindowInterface::setDockStruts(const QRect &dockRect, Plasma::Types::Location location) const
|
||||
{
|
||||
NETExtendedStrut strut;
|
||||
|
||||
|
||||
switch (location) {
|
||||
case Plasma::Types::TopEdge:
|
||||
strut.top_width = dockRect.height();
|
||||
strut.top_start = dockRect.x();
|
||||
strut.top_end = dockRect.x() + dockRect.width() - 1;
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::BottomEdge:
|
||||
strut.bottom_width = dockRect.height();
|
||||
strut.bottom_start = dockRect.x();
|
||||
strut.bottom_end = dockRect.x() + dockRect.width() - 1;
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
strut.left_width = dockRect.width();
|
||||
strut.left_start = dockRect.y();
|
||||
strut.left_end = dockRect.y() + dockRect.height() - 1;
|
||||
break;
|
||||
|
||||
|
||||
case Plasma::Types::RightEdge:
|
||||
strut.right_width = dockRect.width();
|
||||
strut.right_start = dockRect.y();
|
||||
strut.right_end = dockRect.y() + dockRect.height() - 1;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
qWarning() << "wrong location:" << qEnumToStr(location);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
KWindowSystem::setExtendedStrut(m_view->winId(),
|
||||
strut.left_width, strut.left_start, strut.left_end,
|
||||
strut.right_width, strut.right_start, strut.right_end,
|
||||
@ -171,12 +162,10 @@ bool XWindowInterface::isOnCurrentDesktop(WId wid) const
|
||||
WindowInfoWrap XWindowInterface::requestInfo(WId wid) const
|
||||
{
|
||||
const KWindowInfo winfo{wid, NET::WMFrameExtents | NET::WMWindowType | NET::WMGeometry | NET::WMState};
|
||||
|
||||
WindowInfoWrap winfoWrap;
|
||||
|
||||
|
||||
if (!winfo.valid()) {
|
||||
return winfoWrap;
|
||||
|
||||
} else if (isValidWindow(winfo)) {
|
||||
winfoWrap.setIsValid(true);
|
||||
winfoWrap.setWid(wid);
|
||||
@ -185,14 +174,12 @@ WindowInfoWrap XWindowInterface::requestInfo(WId wid) const
|
||||
winfoWrap.setIsMaximized(winfo.hasState(NET::Max));
|
||||
winfoWrap.setIsFullscreen(winfo.hasState(NET::FullScreen));
|
||||
winfoWrap.setGeometry(winfo.geometry());
|
||||
|
||||
} else if (m_desktopId == wid) {
|
||||
winfoWrap.setIsValid(true);
|
||||
winfoWrap.setIsPlasmaDesktop(true);
|
||||
winfoWrap.setWid(wid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return winfoWrap;
|
||||
}
|
||||
|
||||
@ -202,10 +189,10 @@ bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
|
||||
const auto winType = winfo.windowType(NET::DockMask
|
||||
| NET::MenuMask | NET::SplashMask
|
||||
| NET::NormalMask);
|
||||
|
||||
|
||||
if (winType == -1 || (winType & NET::Menu) || (winType & NET::Dock) || (winType & NET::Splash))
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -214,23 +201,23 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P
|
||||
//! if the dock changed is ignored
|
||||
if (wid == m_view->winId())
|
||||
return;
|
||||
|
||||
|
||||
//! ignore when, eg: the user presses a key
|
||||
const auto winType = KWindowInfo(wid, NET::WMWindowType).windowType(NET::DesktopMask);
|
||||
|
||||
|
||||
if (winType != -1 && (winType & NET::Desktop)) {
|
||||
m_desktopId = wid;
|
||||
emit windowChanged(wid);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (prop1 == 0 && prop2 == NET::WM2UserTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (prop1 && !(prop1 & NET::WMState || prop1 & NET::WMGeometry || prop1 & NET::ActiveWindow))
|
||||
return;
|
||||
|
||||
|
||||
emit windowChanged(wid);
|
||||
}
|
||||
|
||||
|
@ -32,29 +32,29 @@ namespace Latte {
|
||||
|
||||
class XWindowInterface : public AbstractWindowInterface {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
XWindowInterface(QQuickWindow *const view, QObject *parent);
|
||||
virtual ~XWindowInterface();
|
||||
|
||||
|
||||
void setDockDefaultFlags() override;
|
||||
|
||||
|
||||
WId activeWindow() const override;
|
||||
WindowInfoWrap requestInfo(WId wid) const override;
|
||||
WindowInfoWrap requestInfoActive() const override;
|
||||
bool isOnCurrentDesktop(WId wid) const override;
|
||||
const std::list<WId> &windows() const override;
|
||||
|
||||
|
||||
void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) const override;
|
||||
void removeDockStruts() const override;
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
bool isValidWindow(const KWindowInfo &winfo) const;
|
||||
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
|
||||
|
||||
|
||||
WId m_desktopId;
|
||||
|
||||
|
||||
QList<QMetaObject::Connection> connections;
|
||||
};
|
||||
|
||||
|
5
astylerc
5
astylerc
@ -13,11 +13,10 @@
|
||||
|
||||
#FormattingOptions
|
||||
--convert-tabs
|
||||
--max-code-length=80
|
||||
--max-code-length=200
|
||||
--keep-one-line-blocks
|
||||
--keep-one-line-statements
|
||||
--close-templates
|
||||
--max-code-length=200
|
||||
|
||||
#IndentationOptions
|
||||
--indent-switches
|
||||
@ -31,9 +30,9 @@
|
||||
--pad-oper
|
||||
--unpad-paren
|
||||
--pad-header
|
||||
--fill-empty-lines
|
||||
--align-pointer=name
|
||||
--align-reference=name
|
||||
--delete-empty-lines
|
||||
|
||||
#Others
|
||||
--preserve-date
|
||||
|
@ -29,11 +29,11 @@ namespace Latte {
|
||||
|
||||
class Dock {
|
||||
Q_GADGET
|
||||
|
||||
|
||||
public:
|
||||
Dock() = delete;
|
||||
~Dock() {}
|
||||
|
||||
|
||||
enum Visibility {
|
||||
None = -1,
|
||||
AlwaysVisible = 0,
|
||||
@ -43,7 +43,7 @@ public:
|
||||
DodgeAllWindows
|
||||
};
|
||||
Q_ENUM(Visibility)
|
||||
|
||||
|
||||
enum Alignment {
|
||||
Center = 0,
|
||||
Left,
|
||||
@ -53,7 +53,7 @@ public:
|
||||
Justify = 10
|
||||
};
|
||||
Q_ENUM(Alignment)
|
||||
|
||||
|
||||
};
|
||||
|
||||
}//end of namespace
|
||||
|
@ -45,22 +45,16 @@ IconItem::IconItem(QQuickItem *parent)
|
||||
m_sizeChanged(false)
|
||||
{
|
||||
setFlag(ItemHasContents, true);
|
||||
|
||||
connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()),
|
||||
this, SIGNAL(implicitWidthChanged()));
|
||||
|
||||
connect(KIconLoader::global(), SIGNAL(iconLoaderSettingsChanged()),
|
||||
this, SIGNAL(implicitHeightChanged()));
|
||||
|
||||
connect(this, &QQuickItem::enabledChanged,
|
||||
this, &IconItem::enabledChanged);
|
||||
|
||||
connect(this, &QQuickItem::windowChanged,
|
||||
this, &IconItem::schedulePixmapUpdate);
|
||||
|
||||
connect(this, SIGNAL(overlaysChanged()),
|
||||
this, SLOT(schedulePixmapUpdate()));
|
||||
|
||||
//initialize implicit size to the Dialog size
|
||||
setImplicitWidth(KIconLoader::global()->currentSize(KIconLoader::Dialog));
|
||||
setImplicitHeight(KIconLoader::global()->currentSize(KIconLoader::Dialog));
|
||||
@ -75,19 +69,19 @@ void IconItem::setSource(const QVariant &source)
|
||||
if (source == m_source) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_source = source;
|
||||
QString sourceString = source.toString();
|
||||
|
||||
|
||||
// If the QIcon was created with QIcon::fromTheme(), try to load it as svg
|
||||
if (source.canConvert<QIcon>() && !source.value<QIcon>().name().isEmpty()) {
|
||||
sourceString = source.value<QIcon>().name();
|
||||
}
|
||||
|
||||
|
||||
if (!sourceString.isEmpty()) {
|
||||
//If a url in the form file:// is passed, take the image pointed by that from disk
|
||||
QUrl url(sourceString);
|
||||
|
||||
|
||||
if (url.isLocalFile()) {
|
||||
m_icon = QIcon();
|
||||
m_imageIcon = QImage(url.path());
|
||||
@ -101,23 +95,22 @@ void IconItem::setSource(const QVariant &source)
|
||||
m_svgIcon->setDevicePixelRatio((window() ? window()->devicePixelRatio() : qApp->devicePixelRatio()));
|
||||
connect(m_svgIcon.get(), &Plasma::Svg::repaintNeeded, this, &IconItem::schedulePixmapUpdate);
|
||||
}
|
||||
|
||||
|
||||
//success?
|
||||
if (m_svgIcon->isValid() && m_svgIcon->hasElement(sourceString)) {
|
||||
m_icon = QIcon();
|
||||
m_svgIconName = sourceString;
|
||||
|
||||
//ok, svg not available from the plasma theme
|
||||
} else {
|
||||
//try to load from iconloader an svg with Plasma::Svg
|
||||
const auto *iconTheme = KIconLoader::global()->theme();
|
||||
QString iconPath;
|
||||
|
||||
|
||||
if (iconTheme) {
|
||||
iconPath = iconTheme->iconPath(sourceString + QLatin1String(".svg")
|
||||
, static_cast<int>(qMin(width(), height()))
|
||||
, KIconLoader::MatchBest);
|
||||
|
||||
|
||||
if (iconPath.isEmpty()) {
|
||||
iconPath = iconTheme->iconPath(sourceString + QLatin1String(".svgz")
|
||||
, static_cast<int>(qMin(width(), height()))
|
||||
@ -126,7 +119,7 @@ void IconItem::setSource(const QVariant &source)
|
||||
} else {
|
||||
qWarning() << "KIconLoader has no theme set";
|
||||
}
|
||||
|
||||
|
||||
if (!iconPath.isEmpty()) {
|
||||
m_svgIcon->setImagePath(iconPath);
|
||||
m_svgIconName = sourceString;
|
||||
@ -134,18 +127,17 @@ void IconItem::setSource(const QVariant &source)
|
||||
} else {
|
||||
//if we started with a QIcon use that.
|
||||
m_icon = source.value<QIcon>();
|
||||
|
||||
|
||||
if (m_icon.isNull()) {
|
||||
m_icon = QIcon::fromTheme(sourceString);
|
||||
}
|
||||
|
||||
|
||||
m_svgIconName.clear();
|
||||
m_svgIcon.reset();
|
||||
m_imageIcon = QImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (source.canConvert<QIcon>()) {
|
||||
m_icon = source.value<QIcon>();
|
||||
m_imageIcon = QImage();
|
||||
@ -162,11 +154,11 @@ void IconItem::setSource(const QVariant &source)
|
||||
m_svgIconName.clear();
|
||||
m_svgIcon.reset();
|
||||
}
|
||||
|
||||
|
||||
if (width() > 0 && height() > 0) {
|
||||
schedulePixmapUpdate();
|
||||
}
|
||||
|
||||
|
||||
emit sourceChanged();
|
||||
emit validChanged();
|
||||
}
|
||||
@ -181,7 +173,7 @@ void IconItem::setOverlays(const QStringList &overlays)
|
||||
if (overlays == m_overlays) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_overlays = overlays;
|
||||
emit overlaysChanged();
|
||||
}
|
||||
@ -202,13 +194,13 @@ void IconItem::setActive(bool active)
|
||||
if (m_active == active) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_active = active;
|
||||
|
||||
|
||||
if (isComponentComplete()) {
|
||||
schedulePixmapUpdate();
|
||||
}
|
||||
|
||||
|
||||
emit activeChanged();
|
||||
}
|
||||
|
||||
@ -217,7 +209,7 @@ void IconItem::setSmooth(const bool smooth)
|
||||
if (smooth == m_smooth) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_smooth = smooth;
|
||||
update();
|
||||
}
|
||||
@ -251,32 +243,31 @@ void IconItem::updatePolish()
|
||||
QSGNode *IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData)
|
||||
{
|
||||
Q_UNUSED(updatePaintNodeData)
|
||||
|
||||
|
||||
if (m_iconPixmap.isNull() || width() < 1.0 || height() < 1.0) {
|
||||
delete oldNode;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
ManagedTextureNode *textureNode = dynamic_cast<ManagedTextureNode *>(oldNode);
|
||||
|
||||
|
||||
if (!textureNode || m_textureChanged) {
|
||||
if (oldNode)
|
||||
delete oldNode;
|
||||
|
||||
|
||||
textureNode = new ManagedTextureNode;
|
||||
textureNode->setTexture(QSharedPointer<QSGTexture>(window()->createTextureFromImage(m_iconPixmap.toImage())));
|
||||
m_sizeChanged = true;
|
||||
m_textureChanged = false;
|
||||
}
|
||||
|
||||
|
||||
if (m_sizeChanged) {
|
||||
const auto iconSize = qMin(boundingRect().size().width(), boundingRect().size().height());
|
||||
const QRectF destRect(QPointF(boundingRect().center() - QPointF(iconSize / 2, iconSize / 2)), QSizeF(iconSize, iconSize));
|
||||
|
||||
textureNode->setRect(destRect);
|
||||
m_sizeChanged = false;
|
||||
}
|
||||
|
||||
|
||||
return textureNode;
|
||||
}
|
||||
|
||||
@ -295,30 +286,29 @@ void IconItem::loadPixmap()
|
||||
if (!isComponentComplete()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const auto size = static_cast<int>(qMin(width(), height()));
|
||||
|
||||
//final pixmap to paint
|
||||
QPixmap result;
|
||||
|
||||
|
||||
if (size <= 0) {
|
||||
m_iconPixmap = QPixmap();
|
||||
update();
|
||||
return;
|
||||
} else if (m_svgIcon) {
|
||||
m_svgIcon->resize(size, size);
|
||||
|
||||
|
||||
if (m_svgIcon->hasElement(m_svgIconName)) {
|
||||
result = m_svgIcon->pixmap(m_svgIconName);
|
||||
} else if (!m_svgIconName.isEmpty()) {
|
||||
const auto *iconTheme = KIconLoader::global()->theme();
|
||||
QString iconPath;
|
||||
|
||||
|
||||
if (iconTheme) {
|
||||
iconPath = iconTheme->iconPath(m_svgIconName + QLatin1String(".svg")
|
||||
, static_cast<int>(qMin(width(), height()))
|
||||
, KIconLoader::MatchBest);
|
||||
|
||||
|
||||
if (iconPath.isEmpty()) {
|
||||
iconPath = iconTheme->iconPath(m_svgIconName + QLatin1String(".svgz"),
|
||||
static_cast<int>(qMin(width(), height()))
|
||||
@ -327,11 +317,11 @@ void IconItem::loadPixmap()
|
||||
} else {
|
||||
qWarning() << "KIconLoader has no theme set";
|
||||
}
|
||||
|
||||
|
||||
if (!iconPath.isEmpty()) {
|
||||
m_svgIcon->setImagePath(iconPath);
|
||||
}
|
||||
|
||||
|
||||
result = m_svgIcon->pixmap();
|
||||
}
|
||||
} else if (!m_icon.isNull()) {
|
||||
@ -343,7 +333,7 @@ void IconItem::loadPixmap()
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Strangely KFileItem::overlays() returns empty string-values, so
|
||||
// we need to check first whether an overlay must be drawn at all.
|
||||
// It is more efficient to do it here, as KIconLoader::drawOverlays()
|
||||
@ -357,16 +347,15 @@ void IconItem::loadPixmap()
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isEnabled()) {
|
||||
result = KIconLoader::global()->iconEffect()->apply(result, KIconLoader::Desktop, KIconLoader::DisabledState);
|
||||
} else if (m_active) {
|
||||
result = KIconLoader::global()->iconEffect()->apply(result, KIconLoader::Desktop, KIconLoader::ActiveState);
|
||||
}
|
||||
|
||||
|
||||
m_iconPixmap = result;
|
||||
m_textureChanged = true;
|
||||
|
||||
//don't animate initial setting
|
||||
update();
|
||||
}
|
||||
@ -380,21 +369,21 @@ void IconItem::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeome
|
||||
{
|
||||
if (newGeometry.size() != oldGeometry.size()) {
|
||||
m_sizeChanged = true;
|
||||
|
||||
|
||||
if (newGeometry.width() > 1 && newGeometry.height() > 1) {
|
||||
schedulePixmapUpdate();
|
||||
} else {
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
const auto oldSize = qMin(oldGeometry.size().width(), oldGeometry.size().height());
|
||||
const auto newSize = qMin(newGeometry.size().width(), newGeometry.size().height());
|
||||
|
||||
|
||||
if (!almost_equal(oldSize, newSize, 2)) {
|
||||
emit paintedSizeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QQuickItem::geometryChanged(newGeometry, oldGeometry);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
namespace Latte {
|
||||
class IconItem : public QQuickItem {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
/**
|
||||
* Sets the icon to be displayed. Source can be one of:
|
||||
* - iconName (as a string)
|
||||
@ -51,67 +51,67 @@ class IconItem : public QQuickItem {
|
||||
* - load the icon as normal
|
||||
*/
|
||||
Q_PROPERTY(QVariant source READ source WRITE setSource NOTIFY sourceChanged)
|
||||
|
||||
|
||||
/**
|
||||
* Specifies the overlay(s) for this icon
|
||||
*/
|
||||
Q_PROPERTY(QStringList overlays READ overlays WRITE setOverlays NOTIFY overlaysChanged)
|
||||
|
||||
|
||||
/**
|
||||
* See QQuickItem::smooth
|
||||
*/
|
||||
Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged)
|
||||
|
||||
|
||||
/**
|
||||
* Apply a visual indication that this icon is active.
|
||||
* Typically used to indicate that it is hovered
|
||||
*/
|
||||
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
|
||||
|
||||
|
||||
/**
|
||||
* True if a valid icon is set. False otherwise.
|
||||
*/
|
||||
Q_PROPERTY(bool valid READ isValid NOTIFY validChanged)
|
||||
|
||||
|
||||
/**
|
||||
* The width of the icon that is actually painted
|
||||
*/
|
||||
Q_PROPERTY(int paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
|
||||
|
||||
|
||||
/**
|
||||
* The height of the icon actually being drawn.
|
||||
*/
|
||||
Q_PROPERTY(int paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
|
||||
|
||||
|
||||
public:
|
||||
IconItem(QQuickItem *parent = nullptr);
|
||||
virtual ~IconItem();
|
||||
|
||||
|
||||
void setSource(const QVariant &source);
|
||||
QVariant source() const;
|
||||
|
||||
|
||||
void setOverlays(const QStringList &overlays);
|
||||
QStringList overlays() const;
|
||||
|
||||
|
||||
bool isActive() const;
|
||||
void setActive(bool active);
|
||||
|
||||
|
||||
void setSmooth(const bool smooth);
|
||||
bool smooth() const;
|
||||
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
|
||||
int paintedWidth() const;
|
||||
int paintedHeight() const;
|
||||
|
||||
|
||||
void updatePolish() Q_DECL_OVERRIDE;
|
||||
QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override;
|
||||
|
||||
|
||||
void itemChange(ItemChange change, const ItemChangeData &value) override;
|
||||
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
|
||||
|
||||
|
||||
void componentComplete() Q_DECL_OVERRIDE;
|
||||
|
||||
|
||||
signals:
|
||||
void overlaysChanged();
|
||||
void activeChanged();
|
||||
@ -119,14 +119,14 @@ signals:
|
||||
void smoothChanged();
|
||||
void validChanged();
|
||||
void paintedSizeChanged();
|
||||
|
||||
|
||||
private slots:
|
||||
void schedulePixmapUpdate();
|
||||
void enabledChanged();
|
||||
|
||||
|
||||
private:
|
||||
void loadPixmap();
|
||||
|
||||
|
||||
QIcon m_icon;
|
||||
QPixmap m_iconPixmap;
|
||||
QImage m_imageIcon;
|
||||
@ -135,12 +135,12 @@ private:
|
||||
QStringList m_overlays;
|
||||
//this contains the raw variant it was passed
|
||||
QVariant m_source;
|
||||
|
||||
|
||||
QSizeF m_implicitSize;
|
||||
|
||||
|
||||
bool m_smooth;
|
||||
bool m_active;
|
||||
|
||||
|
||||
bool m_textureChanged;
|
||||
bool m_sizeChanged;
|
||||
};
|
||||
|
@ -28,9 +28,7 @@
|
||||
void LatteDockPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.latte"));
|
||||
|
||||
qmlRegisterUncreatableType<Latte::Dock>(uri, 0, 1, "Dock", "Latte Dock Types uncreatable");
|
||||
|
||||
qmlRegisterType<Latte::WindowSystem>(uri, 0, 1, "WindowSystem");
|
||||
qmlRegisterType<Latte::IconItem>(uri, 0, 1, "IconItem");
|
||||
}
|
||||
|
@ -26,7 +26,7 @@
|
||||
class LatteDockPlugin : public QQmlExtensionPlugin {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||
|
||||
|
||||
public:
|
||||
void registerTypes(const char *uri);
|
||||
};
|
||||
|
@ -27,23 +27,23 @@ namespace Latte {
|
||||
|
||||
class WindowSystem : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Q_PROPERTY(bool compositingActive READ compositingActive NOTIFY compositingChanged)
|
||||
|
||||
|
||||
public:
|
||||
explicit WindowSystem(QObject *parent = nullptr);
|
||||
~WindowSystem();
|
||||
|
||||
|
||||
static WindowSystem &self();
|
||||
|
||||
|
||||
bool compositingActive() const;
|
||||
|
||||
|
||||
signals:
|
||||
void compositingChanged();
|
||||
|
||||
|
||||
private slots:
|
||||
void compositingChangedProxy(bool state);
|
||||
|
||||
|
||||
private:
|
||||
bool m_compositing{false};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user