1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-03-07 08:58:17 +03:00

fix #50, update config window location

--fix also some crashes concerning the existence
of multiple config windows from different docks.
This commit is contained in:
Michail Vourlakos 2017-01-11 02:30:35 +02:00
parent 8fa6225cdb
commit fba9d62ee2
4 changed files with 36 additions and 31 deletions

View File

@ -41,17 +41,14 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
m_dockView(dockView),
m_blockFocusLost(false)
{
m_deleterTimer.setSingleShot(true);
m_deleterTimer.setInterval(10 * 1000);
connect(&m_deleterTimer, &QTimer::timeout, this, &QObject::deleteLater);
connect(dockView, &QObject::destroyed, this, &QObject::deleteLater);
connections << connect(dockView, &QObject::destroyed, this, &QObject::deleteLater);
m_screenSyncTimer.setSingleShot(true);
m_screenSyncTimer.setInterval(100);
connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start()));
connections << connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start()));
connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() {
connections << connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() {
setScreen(m_dockView->screen());
KWindowSystem::setType(winId(), NET::Dock);
setFlags(wFlags());
@ -64,19 +61,13 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
setFlags(wFlags());
KWindowSystem::forceActiveWindow(winId());
connect(dockView, &QQuickView::widthChanged, this, &DockConfigView::syncGeometry);
connect(dockView, &QQuickView::heightChanged, this, &DockConfigView::syncGeometry);
connect(dockView->visibility(), &VisibilityManager::modeChanged, this, &DockConfigView::syncGeometry);
connections << connect(dockView, &QQuickView::widthChanged, this, &DockConfigView::syncGeometry);
connections << connect(dockView, &QQuickView::heightChanged, this, &DockConfigView::syncGeometry);
connections << connect(containment, &Plasma::Containment::locationChanged, this, &DockConfigView::syncGeometry);
connections << connect(dockView->visibility(), &VisibilityManager::modeChanged, this, &DockConfigView::syncGeometry);
connect(containment, &Plasma::Containment::immutabilityChanged, this, &DockConfigView::immutabilityChanged);
}
connections << connect(containment, &Plasma::Containment::immutabilityChanged, this, &DockConfigView::immutabilityChanged);
DockConfigView::~DockConfigView()
{
}
void DockConfigView::init()
{
setDefaultAlphaBuffer(true);
setColor(Qt::transparent);
rootContext()->setContextProperty(QStringLiteral("dock"), m_dockView);
@ -87,6 +78,17 @@ void DockConfigView::init()
syncSlideEffect();
}
DockConfigView::~DockConfigView()
{
foreach (auto var, connections) {
QObject::disconnect(var);
}
}
void DockConfigView::init()
{
}
inline Qt::WindowFlags DockConfigView::wFlags() const
{
return (flags() | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) & ~Qt::WindowDoesNotAcceptFocus;
@ -191,7 +193,6 @@ void DockConfigView::showEvent(QShowEvent *ev)
m_containment->setUserConfiguring(true);
m_screenSyncTimer.start();
m_deleterTimer.stop();
QTimer::singleShot(400, this, &DockConfigView::syncGeometry);
@ -199,14 +200,12 @@ void DockConfigView::showEvent(QShowEvent *ev)
void DockConfigView::hideEvent(QHideEvent *ev)
{
QQuickWindow::hideEvent(ev);
m_deleterTimer.start();
if (m_containment) {
if (m_containment && m_dockView) {
m_dockView->saveConfig();
m_containment->setUserConfiguring(false);
}
QQuickWindow::hideEvent(ev);
}
void DockConfigView::focusOutEvent(QFocusEvent *ev)

View File

@ -68,8 +68,9 @@ private:
Plasma::Containment *m_containment{nullptr};
QPointer<DockView> m_dockView;
QTimer m_deleterTimer;
QTimer m_screenSyncTimer;
QList<QMetaObject::Connection> connections;
};
}

View File

@ -154,7 +154,7 @@ 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;
@ -215,7 +215,8 @@ void DockCorona::addDock(Plasma::Containment *containment)
void DockCorona::dockContainmentDestroyed(QObject *cont)
{
auto view = m_dockViews.take(static_cast<Plasma::Containment *>(cont));
view->deleteLater();
delete view;
//view->deleteLater();
emit containmentsNoChanged();
}
@ -267,9 +268,9 @@ inline void DockCorona::qmlRegisterTypes() const
constexpr auto vMajor = 0;
constexpr auto vMinor = 2;
// qmlRegisterUncreatableType<Candil::Dock>(uri, vMajor, vMinor, "Dock", "class Dock uncreatable");
// qmlRegisterUncreatableType<Candil::VisibilityManager>(uri, vMajor, vMinor, "VisibilityManager", "class VisibilityManager uncreatable");
// qmlRegisterUncreatableType<NowDockView>(uri, vMajor, vMinor, "DockView", "class DockView uncreatable");
// qmlRegisterUncreatableType<Candil::Dock>(uri, vMajor, vMinor, "Dock", "class Dock uncreatable");
// qmlRegisterUncreatableType<Candil::VisibilityManager>(uri, vMajor, vMinor, "VisibilityManager", "class VisibilityManager uncreatable");
// qmlRegisterUncreatableType<NowDockView>(uri, vMajor, vMinor, "DockView", "class DockView uncreatable");
qmlRegisterType<QScreen>();
}

View File

@ -113,7 +113,7 @@ DockView::~DockView()
qDebug() << "dock view connections deleted...";
if (m_visibility) {
m_visibility->deleteLater();
delete m_visibility;
}
}
@ -524,7 +524,11 @@ void DockView::closeApplication()
DockCorona *corona = qobject_cast<DockCorona *>(this->corona());
if (corona) {
m_configView->hide();
//m_configView->hide();
if (m_configView) {
m_configView->deleteLater();
}
corona->closeApplication();
}
}