init the panels only when desktops are ready

This commit is contained in:
Marco Martin 2013-08-12 14:35:02 +02:00
parent daf4f9daa9
commit ebe6bbe1ab
3 changed files with 31 additions and 19 deletions

View File

@ -50,12 +50,6 @@ DesktopCorona::DesktopCorona(QObject *parent)
connect(m_appConfigSyncTimer, &QTimer::timeout,
this, &DesktopCorona::syncAppConfig);
m_waitingPanelsTimer = new QTimer(this);
m_waitingPanelsTimer->setSingleShot(true);
connect(m_waitingPanelsTimer, &QTimer::timeout,
this, &DesktopCorona::createWaitingPanels);
connect(m_desktopWidget, SIGNAL(resized(int)),
this, SLOT(screenResized(int)));
connect(m_desktopWidget, SIGNAL(screenCountChanged(int)),
@ -257,15 +251,24 @@ void DesktopCorona::checkViews()
}
}
void DesktopCorona::createWaitingPanels()
void DesktopCorona::checkLoadingDesktopsComplete()
{
Plasma::Containment *c = qobject_cast<Plasma::Containment *>(sender());
if (c) {
disconnect(c, &Plasma::Containment::uiReadyChanged,
this, &DesktopCorona::checkLoadingDesktopsComplete);
m_loadingDesktops.remove(c);
}
if (m_loadingDesktops.isEmpty()) {
foreach (Plasma::Containment *cont, m_waitingPanels) {
m_panelViews[cont] = new PanelView(this);
m_panelViews[cont]->setContainment(cont);
m_panelViews[cont]->show();
}
m_waitingPanels.clear();
}
}
void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Containment *containment)
{
@ -276,7 +279,6 @@ void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Conta
if (isScreen >= 0) {
m_waitingPanels << containment;
m_waitingPanelsTimer->start(250);
} else {
if (m_panelViews.contains(containment)) {
m_panelViews[containment]->setContainment(0);
@ -288,9 +290,14 @@ void DesktopCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Conta
//Desktop view
} else {
if (m_waitingPanelsTimer->isActive()) {
m_waitingPanelsTimer->start(250);
if (containment->isUiReady()) {
checkLoadingDesktopsComplete();
} else {
m_loadingDesktops.insert(containment);
connect(containment, &Plasma::Containment::uiReadyChanged,
this, &DesktopCorona::checkLoadingDesktopsComplete);
}
if (isScreen < 0 || m_views.count() < isScreen + 1) {
qWarning() << "Invalid screen";
return;

View File

@ -99,17 +99,17 @@ private Q_SLOTS:
void handleContainmentAdded(Plasma::Containment *c);
void showWidgetExplorer();
void syncAppConfig();
void createWaitingPanels();
void checkLoadingDesktopsComplete();
private:
QDesktopWidget *m_desktopWidget;
QList <View *> m_views;
WidgetExplorerView *m_widgetExplorerView;
QList<Plasma::Containment *> m_waitingPanels;
QSet<Plasma::Containment *> m_loadingDesktops;
QHash<Plasma::Containment *, PanelView *> m_panelViews;
KConfigGroup m_desktopDefaultsConfig;
QTimer *m_appConfigSyncTimer;
QTimer *m_waitingPanelsTimer;
};
#endif

View File

@ -47,6 +47,7 @@ PanelView::PanelView(DesktopCorona *corona, QWindow *parent)
setColor(QColor(Qt::transparent));
setFlags(Qt::FramelessWindowHint);
KWindowSystem::setType(winId(), NET::Dock);
setVisible(false);
//TODO: how to take the shape from the framesvg?
KWindowEffects::enableBlurBehind(winId(), true);
@ -326,6 +327,10 @@ void PanelView::restore()
return;
}
setVisible(containment()->isUiReady());
connect(containment(), &Plasma::Containment::uiReadyChanged,
this, &PanelView::setVisible);
static const int MINSIZE = 10;
m_offset = config().readEntry<int>("offset", 0);