~ubuntu-branches/ubuntu/raring/plasma-mobile/raring-proposed

« back to all changes in this revision

Viewing changes to shell/activityconfiguration/activityconfiguration.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-07-17 12:04:43 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120717120443-q3ig9u2fnltx67yg
Tags: 2.0+git2012071701-0ubuntu1
* New upstream snapshot
* Remove build-dep on kde-runtime-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
 
53
53
ActivityConfiguration::ActivityConfiguration(QGraphicsWidget *parent)
54
54
    : Plasma::DeclarativeWidget(parent),
55
 
      m_containment(0),
56
55
      m_mainWidget(0),
57
56
      m_model(0),
58
57
      m_wallpaperIndex(-1),
59
 
      m_newContainment(false)
 
58
      m_newContainment(false),
 
59
      m_encrypted(false)
60
60
{
61
61
    Plasma::PackageStructure::Ptr structure = Plasma::PackageStructure::load("Plasma/Generic");
62
62
    m_package = new Plasma::Package(QString(), "org.kde.active.activityconfiguration", structure);
108
108
                                                       "org.kde.plasma.VirtualKeyboard",
109
109
                                                       "hide");
110
110
    QDBusConnection::sessionBus().asyncCall(call);
111
 
    deleteLater();
 
111
    //FIXME: should be enough any delay that will cause it to be exectued at least two loops after in the event loop
 
112
    QTimer::singleShot(100, this, SLOT(deleteLater()));
112
113
}
113
114
 
114
115
void ActivityConfiguration::ensureContainmentExistence()
117
118
        return;
118
119
    }
119
120
 
 
121
    QString id;
120
122
#ifndef NO_ACTIVITIES
121
 
    const QString id = m_activityController->addActivity(m_activityName);
 
123
    id = m_activityController->addActivity(m_activityName);
122
124
    m_activityController->setCurrentActivity(id);
123
125
#endif
124
126
    Plasma::Corona *corona = qobject_cast<Plasma::Corona *>(scene());
130
132
 
131
133
    if (corona) {
132
134
        setContainment(corona->containmentForScreen(0));
 
135
#ifndef NO_ACTIVITIES
 
136
        m_activityController->setActivityEncrypted(id, m_encrypted);
 
137
#endif
133
138
    }
134
139
}
135
140
 
143
148
    }
144
149
 
145
150
    if (m_containment) {
146
 
        m_activityName = m_containment->activity();
 
151
        m_activityName = m_containment.data()->activity();
147
152
        emit activityNameChanged();
 
153
#ifndef NO_ACTIVITIES
 
154
        KActivities::Info *info = new KActivities::Info(m_containment.data()->context()->currentActivityId());
 
155
        if (m_encrypted != info->isEncrypted()) {
 
156
            m_encrypted = info->isEncrypted();
 
157
            emit encryptedChanged();
 
158
        }
 
159
        delete info;
 
160
#endif
148
161
    }
149
162
 
150
163
    if (m_newContainment) {
157
170
    }
158
171
 
159
172
    ensureContainmentHasWallpaperPlugin();
160
 
    m_model->setTargetSizeHint(m_containment->size().toSize());
 
173
    m_model->setTargetSizeHint(m_containment.data()->size().toSize());
161
174
 
162
175
    // save the wallpaper config so we can find the proper index later in modelCountChanged
163
 
    Plasma::Wallpaper *wp = m_containment->wallpaper();
 
176
    Plasma::Wallpaper *wp = m_containment.data()->wallpaper();
164
177
    if (wp) {
165
178
        // shoulw always be true:
166
179
        // can only be false on a broken system with no wallpapers able to show images
173
186
 
174
187
KConfigGroup ActivityConfiguration::wallpaperConfig()
175
188
{
176
 
    if (!m_containment || !m_containment->wallpaper()) {
 
189
    if (!m_containment || !m_containment.data()->wallpaper()) {
177
190
        return KConfigGroup();
178
191
    }
179
192
 
180
 
    KConfigGroup wpConfig = m_containment->config();
 
193
    KConfigGroup wpConfig = m_containment.data()->config();
181
194
    wpConfig = KConfigGroup(&wpConfig, "Wallpaper");
182
 
    wpConfig = KConfigGroup(&wpConfig, m_containment->wallpaper()->pluginName());
 
195
    wpConfig = KConfigGroup(&wpConfig, m_containment.data()->wallpaper()->pluginName());
183
196
    return wpConfig;
184
197
}
185
198
 
200
213
 
201
214
Plasma::Containment *ActivityConfiguration::containment() const
202
215
{
203
 
    return m_containment;
 
216
    return m_containment.data();
204
217
}
205
218
 
206
219
void ActivityConfiguration::setActivityName(const QString &name)
217
230
        return;
218
231
    }
219
232
 
220
 
    m_containment->setActivity(name);
 
233
    m_containment.data()->setActivity(name);
221
234
    emit activityNameChanged();
222
235
}
223
236
 
226
239
    return m_activityName;
227
240
}
228
241
 
 
242
bool ActivityConfiguration::isEncrypted() const
 
243
{
 
244
    return m_encrypted;
 
245
}
 
246
 
 
247
void ActivityConfiguration::setEncrypted(bool encrypted)
 
248
{
 
249
    if (m_encrypted == encrypted) {
 
250
        return;
 
251
    }
 
252
#ifndef NO_ACTIVITIES
 
253
    if (m_containment) {
 
254
        m_activityController->setActivityEncrypted(activityId(), encrypted);
 
255
    }
 
256
#endif
 
257
    m_encrypted = encrypted;
 
258
    emit encryptedChanged();
 
259
}
 
260
 
 
261
 
229
262
QString ActivityConfiguration::activityId() const
230
263
{
231
264
    if (!m_containment) {
232
265
        return QString();
233
266
    }
234
267
 
235
 
    return m_containment->context()->currentActivityId();
 
268
    return m_containment.data()->context()->currentActivityId();
236
269
}
237
270
 
238
271
bool ActivityConfiguration::isActivityNameConfigurable() const
282
315
 
283
316
    kDebug()<<"Setting new wallpaper path:"<<wallpaper;
284
317
 
285
 
    if (!m_containment->wallpaper()) {
 
318
    if (!m_containment.data()->wallpaper()) {
286
319
        const QString mimetype = KMimeType::findByUrl(wallpaper).data()->name();
287
320
        ensureContainmentHasWallpaperPlugin(mimetype);
288
321
    }
289
322
 
290
 
    if (m_containment->wallpaper()) {
291
 
        m_containment->wallpaper()->setUrls(KUrl::List() << wallpaper);
 
323
    if (m_containment.data()->wallpaper()) {
 
324
        m_containment.data()->wallpaper()->setUrls(KUrl::List() << wallpaper);
292
325
        KConfigGroup wpConfig = wallpaperConfig();
293
326
        if (wpConfig.isValid()) {
294
327
            wpConfig.writeEntry("wallpaper", wallpaper);
295
 
            //m_containment->wallpaper()->save(wpConfig);
 
328
            //m_containment.data()->wallpaper()->save(wpConfig);
296
329
        }
297
330
 
298
 
        emit containmentWallpaperChanged(m_containment);
 
331
        emit containmentWallpaperChanged(m_containment.data());
299
332
    }
300
333
 
301
334
    emit wallpaperIndexChanged();
322
355
 
323
356
void ActivityConfiguration::ensureContainmentHasWallpaperPlugin(const QString &mimetype)
324
357
{
325
 
    if (m_containment && (!m_containment->wallpaper() || !m_containment->wallpaper()->supportsMimetype(mimetype))) {
326
 
        m_containment->setWallpaper(bestWallpaperPluginAvailable());
 
358
    if (m_containment && (!m_containment.data()->wallpaper() || !m_containment.data()->wallpaper()->supportsMimetype(mimetype))) {
 
359
        m_containment.data()->setWallpaper(bestWallpaperPluginAvailable());
327
360
    }
328
361
}
329
362