shell: Readability, remove uses of QWeakPointer::data()

the operator-> is smart enough to know what to call.
wilder-5.24
Aleix Pol 5 years ago committed by Aleix Pol Gonzalez
parent 9aa0bc24ec
commit 86a7bf786f
  1. 6
      shell/desktopview.cpp
  2. 12
      shell/panelview.cpp
  3. 31
      shell/scripting/containment.cpp
  4. 26
      shell/scripting/widget.cpp

@ -301,9 +301,9 @@ void DesktopView::showConfigurationInterface(Plasma::Applet *applet)
} else {
m_configView = new PlasmaQuick::ConfigView(applet);
}
m_configView.data()->init();
m_configView.data()->setTransientParent(this);
m_configView.data()->show();
m_configView->init();
m_configView->setTransientParent(this);
m_configView->show();
m_configView->requestActivate();
auto window = qobject_cast<QWindow *>(m_configView);

@ -673,12 +673,12 @@ void PanelView::showConfigurationInterface(Plasma::Applet *applet)
m_panelConfigView = new PlasmaQuick::ConfigView(applet);
}
m_panelConfigView.data()->init();
m_panelConfigView.data()->show();
m_panelConfigView.data()->requestActivate();
m_panelConfigView->init();
m_panelConfigView->show();
m_panelConfigView->requestActivate();
if (isPanelConfig) {
KWindowSystem::setState(m_panelConfigView.data()->winId(), NET::SkipTaskbar | NET::SkipPager);
KWindowSystem::setState(m_panelConfigView->winId(), NET::SkipTaskbar | NET::SkipPager);
}
}
@ -997,8 +997,8 @@ bool PanelView::event(QEvent *e)
}
case QEvent::Hide: {
if (m_panelConfigView && m_panelConfigView.data()->isVisible()) {
m_panelConfigView.data()->hide();
if (m_panelConfigView && m_panelConfigView->isVisible()) {
m_panelConfigView->hide();
}
m_containsMouse = false;
break;

@ -54,9 +54,8 @@ Containment::Containment(Plasma::Containment *containment, ScriptEngine *engine)
Containment::~Containment()
{
if (d->containment) {
Plasma::Containment *containment = d->containment.data();
if (d->oldWallpaperPlugin != d->wallpaperPlugin || d->oldWallpaperMode != d->wallpaperMode) {
containment->setWallpaper(d->wallpaperPlugin);
d->containment->setWallpaper(d->wallpaperPlugin);
}
}
@ -76,7 +75,7 @@ int Containment::screen() const
return -1;
}
return d->containment.data()->screen();
return d->containment->screen();
}
QString Containment::wallpaperPlugin() const
@ -105,7 +104,7 @@ QString Containment::formFactor() const
return QStringLiteral("Planar");
}
switch (d->containment.data()->formFactor()) {
switch (d->containment->formFactor()) {
case Plasma::Types::Planar:
return QStringLiteral("planar");
case Plasma::Types::MediaCenter:
@ -128,7 +127,7 @@ QList<int> Containment::widgetIds() const
QList<int> w;
if (d->containment) {
foreach (const Plasma::Applet *applet, d->containment.data()->applets()) {
foreach (const Plasma::Applet *applet, d->containment->applets()) {
w.append(applet->id());
}
}
@ -145,7 +144,7 @@ QJSValue Containment::widgetById(const QJSValue &paramId) const
const uint id = paramId.toInt();
if (d->containment) {
foreach (Plasma::Applet *w, d->containment.data()->applets()) {
foreach (Plasma::Applet *w, d->containment->applets()) {
if (w->id() == id) {
return engine()->wrap(w);
}
@ -173,7 +172,7 @@ QJSValue Containment::addWidget(const QJSValue &v, qreal x, qreal y, qreal w, qr
QQuickItem *containmentItem = nullptr;
if (geometry.x() >= 0 && geometry.y() >= 0) {
containmentItem = d->containment.data()->property("_plasma_graphicObject").value<QQuickItem *>();
containmentItem = d->containment->property("_plasma_graphicObject").value<QQuickItem *>();
if (containmentItem) {
QMetaObject::invokeMethod(containmentItem,
@ -193,7 +192,7 @@ QJSValue Containment::addWidget(const QJSValue &v, qreal x, qreal y, qreal w, qr
// Case in which either:
// * a geometry wasn't provided
// * containmentItem wasn't found
applet = d->containment.data()->createApplet(v.toString(), args);
applet = d->containment->createApplet(v.toString(), args);
if (applet) {
return engine()->wrap(applet);
@ -202,7 +201,7 @@ QJSValue Containment::addWidget(const QJSValue &v, qreal x, qreal y, qreal w, qr
return engine()->newError(i18n("Could not create the %1 widget!", v.toString()));
} else if (Widget *widget = qobject_cast<Widget *>(v.toQObject())) {
applet = widget->applet();
d->containment.data()->addApplet(applet);
d->containment->addApplet(applet);
return v;
}
@ -218,7 +217,7 @@ QJSValue Containment::widgets(const QString &widgetType) const
QJSValue widgets = engine()->newArray();
int count = 0;
foreach (Plasma::Applet *widget, d->containment.data()->applets()) {
foreach (Plasma::Applet *widget, d->containment->applets()) {
if (widgetType.isEmpty() || widget->pluginMetaData().pluginId() == widgetType) {
widgets.setProperty(count, engine()->wrap(widget));
++count;
@ -235,7 +234,7 @@ uint Containment::id() const
return 0;
}
return d->containment.data()->id();
return d->containment->id();
}
QString Containment::type() const
@ -244,20 +243,20 @@ QString Containment::type() const
return QString();
}
return d->containment.data()->pluginMetaData().pluginId();
return d->containment->pluginMetaData().pluginId();
}
void Containment::remove()
{
if (d->containment) {
d->containment.data()->destroy();
d->containment->destroy();
}
}
void Containment::showConfigurationInterface()
{
if (d->containment) {
QAction *configAction = d->containment.data()->actions()->action(QStringLiteral("configure"));
QAction *configAction = d->containment->actions()->action(QStringLiteral("configure"));
if (configAction && configAction->isEnabled()) {
configAction->trigger();
}
@ -266,12 +265,12 @@ void Containment::showConfigurationInterface()
Plasma::Applet *Containment::applet() const
{
return d->containment.data();
return d->containment;
}
Plasma::Containment *Containment::containment() const
{
return d->containment.data();
return d->containment;
}
}

@ -45,7 +45,7 @@ Widget::~Widget()
uint Widget::id() const
{
if (d->applet) {
return d->applet.data()->id();
return d->applet->id();
}
return 0;
@ -54,7 +54,7 @@ uint Widget::id() const
QString Widget::type() const
{
if (d->applet) {
return d->applet.data()->pluginMetaData().pluginId();
return d->applet->pluginMetaData().pluginId();
}
return QString();
@ -63,7 +63,7 @@ QString Widget::type() const
void Widget::remove()
{
if (d->applet) {
d->applet.data()->destroy();
d->applet->destroy();
d->applet.clear();
}
}
@ -71,14 +71,14 @@ void Widget::remove()
void Widget::setGlobalShortcut(const QString &shortcut)
{
if (d->applet) {
d->applet.data()->setGlobalShortcut(QKeySequence(shortcut));
d->applet->setGlobalShortcut(QKeySequence(shortcut));
}
}
QString Widget::globalShorcut() const
{
if (d->applet) {
return d->applet.data()->globalShortcut().toString();
return d->applet->globalShortcut().toString();
}
return QString();
@ -86,7 +86,7 @@ QString Widget::globalShorcut() const
Plasma::Applet *Widget::applet() const
{
return d->applet.data();
return d->applet;
}
int Widget::index() const
@ -95,8 +95,7 @@ int Widget::index() const
return -1;
}
Plasma::Applet *applet = d->applet.data();
Plasma::Containment *c = applet->containment();
Plasma::Containment *c = d->applet->containment();
if (!c) {
return -1;
}
@ -123,8 +122,7 @@ void Widget::setIndex(int index)
return;
}
Plasma::Applet *applet = d->applet.data();
Plasma::Containment *c = applet->containment();
Plasma::Containment *c = d->applet->containment();
if (!c) {
return;
}
@ -139,7 +137,7 @@ void Widget::setIndex(int index)
QJSValue Widget::geometry() const
{
QQuickItem *appletItem = d->applet.data()->property("_plasma_graphicObject").value<QQuickItem *>();
QQuickItem *appletItem = d->applet->property("_plasma_graphicObject").value<QQuickItem *>();
if (appletItem) {
QJSValue rect = engine()->newObject();
@ -158,8 +156,8 @@ void Widget::setGeometry(const QJSValue &geometry)
{
Q_UNUSED(geometry)
/*if (d->applet) {
d->applet.data()->setGeometry(geometry);
KConfigGroup cg = d->applet.data()->config().parent();
d->applet->setGeometry(geometry);
KConfigGroup cg = d->applet->config().parent();
if (cg.isValid()) {
cg.writeEntry("geometry", geometry);
}
@ -169,7 +167,7 @@ void Widget::setGeometry(const QJSValue &geometry)
void Widget::showConfigurationInterface()
{
/* if (d->applet) {
d->applet.data()->showConfigurationInterface();
d->applet->showConfigurationInterface();
}*/
}

Loading…
Cancel
Save