~ubuntu-branches/ubuntu/wily/kdebase-workspace/wily

« back to all changes in this revision

Viewing changes to .pc/plasma_netbook_fix_autostart.diff/kcontrol/workspaceoptions/workspaceoptions.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas, Jonathan Thomas, Tarun Kumar Mall, Philip Muškovac, Stéphane Graber, James Hunt
  • Date: 2011-06-01 02:09:54 UTC
  • mfrom: (0.1.21 sid)
  • Revision ID: james.westby@ubuntu.com-20110601020954-id2t0x9rwxwrmjn2
Tags: 4:4.6.3-1ubuntu1
[ Jonathan Thomas ]
* Merge with Debian Unstable, remaining changes:
  - Add kdebase-workspace-wallpapers.{links, install}
  - Add kdebase-workspace-data.links
  - kdebase-workspace-data.install: don't add wallpapers that are in
    kdebase-workspace-wallpapers.install
  - Add kdm.{links, upstart}
  - kdm.logrotate: rotate 2 -> rotate 7
  - Make kdm work with upstart in kdm.prerm, kdm.postrm, kdm.postinst
  - debian/control:
    - don't build against libggadget-1.0-dev, libggadget-qt-1.0-dev
      (they are in Universe)
    - Build against libbost1.46-dev instead of libboost-dev
    - Add libxml2-dev, libpolkit-qt-1-dev to build-deps
    - Add python-kde4, python-sip, python-qt4 to build-dependencies
    - Keep bumped our replaces/breaks
    - plasma-netbook replaces plasma-widgets-workspace (<= 4:4.5.2-1ubuntu1)
    - kdebase-workspace-bin suggests plasma-scriptengines instead of
      recommend
    - kdebase-workspace-data depends on oxygen-cursor-theme instead of oxygencursors
    - Keep kdebase-workspace-wallpapers
    - plasma-dataengines-workspace replaces plasma-widget-workspace (<= 4:4.5.2-1ubuntu1)
    - plasma-widgets-workspace depends on akonadi-server and kdepim-runtime
    - plasma-scriptengines not depends on plasma-scriptengine-googlegadgets
    - plasma-scriptengine-ruby depends on libkde4-ruby
    - Don't build plasma-scriptengine-googlegadgets
    - freespacenotifier replaces kdebase-workspace-data (<= 4:4.5.2-1ubuntu1)
      and kdebase-workspace-bin (<= 4:4.5.2-1ubuntu1)
    - kinfocenter replaces kdebase-workspace-bin and systemsettings
    - libplasmagenericshell4 replaces plasma-widgets-workspace (<= 4:4.5.2-1ubuntu1)
  - debian/patches:
    - Use 07_kdmrc_defaults_kubuntu.diff instead of 07_kdmrc_defaults.diff
    - Don't add be_better_at_honouring_user_kdm_theming
    - Don't add use_dejavu_as_default_font
    - Don't add fix_target_link_libraries
    - Keep our patches
* Try a polkit-kde-1 | policykit-gnome-1 or-dependency again to see if policykit-1-gnome
  is a suitable policykit solution a year later.

[ Tarun Kumar Mall ]
* New uptream release
* Bumped kde-sc-dev-latest version to 4.6.3
* Removed patches kubuntu_120_ksysguard_sensors.diff and
  kubuntu_121_kdm_halt_cmd.diff, applied upstream
* Refreshed kubuntu_122_akonadi_calendar_dataengine.diff 

[ Philip Muškovac ]
* drop kubuntu_123_effectframe_glflush.diff, applied upstream
* Refresh symbol files 

[ Stéphane Graber ]
* Updated Vcs fields to point to kubuntu-uploaders instead of
  kubuntu-members

[ James Hunt ]
* Updated kdm.conf to fix kdm in single user mode (LP: #436936)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2009 Marco Martin <notmart@gmail.com>
 
3
 *
 
4
 *  This program is free software; you can redistribute it and/or modify
 
5
 *  it under the terms of the GNU General Public License as published by
 
6
 *  the Free Software Foundation; either version 2 of the License, or
 
7
 *  (at your option) any later version.
 
8
 *
 
9
 *  This program is distributed in the hope that it will be useful,
 
10
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *  GNU General Public License for more details.
 
13
 *
 
14
 *  You should have received a copy of the GNU General Public License
 
15
 *  along with this program; if not, write to the Free Software
 
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
17
 *
 
18
 */
 
19
#include "workspaceoptions.h"
 
20
 
 
21
#include "ui_mainpage.h"
 
22
 
 
23
#include <QDBusInterface>
 
24
 
 
25
#include <kmessagebox.h>
 
26
#include <kpluginfactory.h>
 
27
#include <kaboutdata.h>
 
28
#include <KStandardDirs>
 
29
#include <KRun>
 
30
#include <KUrl>
 
31
 
 
32
using namespace KAuth;
 
33
 
 
34
K_PLUGIN_FACTORY(WorkspaceOptionsModuleFactory, registerPlugin<WorkspaceOptionsModule>();)
 
35
K_EXPORT_PLUGIN(WorkspaceOptionsModuleFactory("kcmworkspaceoptions"))
 
36
 
 
37
 
 
38
WorkspaceOptionsModule::WorkspaceOptionsModule(QWidget *parent, const QVariantList &)
 
39
  : KCModule(WorkspaceOptionsModuleFactory::componentData(), parent),
 
40
    m_kwinConfig( KSharedConfig::openConfig("kwinrc")),
 
41
    m_ownConfig( KSharedConfig::openConfig("workspaceoptionsrc")),
 
42
    m_plasmaDesktopAutostart("plasma-desktop"),
 
43
    m_plasmaNetbookAutostart("plasma-netbook"),
 
44
    m_krunnerAutostart("krunner"),
 
45
    m_ui(new Ui::MainPage)
 
46
{
 
47
    KAboutData *about =
 
48
    new KAboutData("kcmworkspaceoptions", 0, ki18n("Global options for the Plasma Workspace"),
 
49
                   0, KLocalizedString(), KAboutData::License_GPL,
 
50
                   ki18n("(c) 2009 Marco Martin"));
 
51
 
 
52
    about->addAuthor(ki18n("Marco Martin"), ki18n("Maintainer"), "notmart@gmail.com");
 
53
 
 
54
    setAboutData(about);
 
55
 
 
56
    setButtons(Help|Apply);
 
57
 
 
58
    m_ui->setupUi(this);
 
59
 
 
60
    connect(m_ui->formFactor, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
 
61
    connect(m_ui->dashboardMode, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
 
62
    connect(m_ui->showToolTips, SIGNAL(toggled(bool)), this, SLOT(changed()));
 
63
    connect(m_ui->formFactor, SIGNAL(currentIndexChanged(int)), this, SLOT(formFactorChanged(int)));
 
64
 
 
65
    //enable the combobox if both plasma-desktop and plasma-netbook are present
 
66
    if (KStandardDirs::findExe("plasma-desktop").isNull() || KStandardDirs::findExe("plasma-netbook").isNull()) {
 
67
        m_ui->formFactor->setEnabled(false);
 
68
    }
 
69
}
 
70
 
 
71
WorkspaceOptionsModule::~WorkspaceOptionsModule()
 
72
{
 
73
    delete m_ui;
 
74
}
 
75
 
 
76
 
 
77
void WorkspaceOptionsModule::save()
 
78
{
 
79
    {
 
80
        KConfig config("plasmarc");
 
81
        KConfigGroup cg(&config, "PlasmaToolTips");
 
82
        cg.writeEntry("Delay", m_ui->showToolTips->isChecked() ? 0.7 : -1);
 
83
    }
 
84
 
 
85
    const bool isDesktop = m_ui->formFactor->currentIndex() == 0;
 
86
 
 
87
    m_plasmaDesktopAutostart.setAutostarts(isDesktop);
 
88
    m_plasmaDesktopAutostart.setStartPhase(KAutostart::BaseDesktop);
 
89
    m_plasmaDesktopAutostart.setCommand("plasma-desktop");
 
90
    m_plasmaDesktopAutostart.setAllowedEnvironments(QStringList()<<"KDE");
 
91
 
 
92
    m_plasmaNetbookAutostart.setAutostarts(!isDesktop);
 
93
    m_plasmaNetbookAutostart.setStartPhase(KAutostart::BaseDesktop);
 
94
    m_plasmaNetbookAutostart.setCommand("plasma-netbook");
 
95
    m_plasmaNetbookAutostart.setAllowedEnvironments(QStringList()<<"KDE");
 
96
 
 
97
    m_krunnerAutostart.setAutostarts(isDesktop);
 
98
    m_krunnerAutostart.setStartPhase(KAutostart::BaseDesktop);
 
99
    m_krunnerAutostart.setCommand("krunner");
 
100
    m_krunnerAutostart.setAllowedEnvironments(QStringList()<<"KDE");
 
101
 
 
102
    KConfigGroup winCg(m_kwinConfig, "Windows");
 
103
 
 
104
    winCg.writeEntry("BorderlessMaximizedWindows", !isDesktop);
 
105
    if (!isDesktop) {
 
106
        winCg.writeEntry("Placement", "Maximizing");
 
107
    } else {
 
108
        winCg.writeEntry("Placement", "Smart");
 
109
    }
 
110
    winCg.sync();
 
111
 
 
112
    KConfigGroup ownButtonsCg(m_ownConfig, "TitleBarButtons");
 
113
    KConfigGroup ownPresentWindowsCg(m_ownConfig, "Effect-PresentWindows");
 
114
    KConfigGroup kwinStyleCg(m_kwinConfig, "Style");
 
115
    KConfigGroup kwinPresentWindowsCg(m_kwinConfig, "Effect-PresentWindows");
 
116
 
 
117
 
 
118
    QString desktopTitleBarButtonsLeft = ownButtonsCg.readEntry("DesktopLeft", "MS");
 
119
    QString desktopTitleBarButtonsRight = ownButtonsCg.readEntry("DesktopRight", "HIA__X");
 
120
 
 
121
    QString netbookTitleBarButtonsLeft = ownButtonsCg.readEntry("NetbookLeft", "MS");
 
122
    QString netbookTitleBarButtonsRight = ownButtonsCg.readEntry("NetbookRight", "HA__X");
 
123
 
 
124
 
 
125
    bool desktopPresentWindowsTabbox = false;
 
126
    bool desktopBoxSwitchTabbox = true;
 
127
    bool desktopCoverSwitchTabbox = false;
 
128
    bool desktopFlipSwitchTabbox = false;
 
129
 
 
130
    bool netbookPresentWindowsTabbox = true;
 
131
    bool netbookBoxSwitchTabbox = false;
 
132
    bool netbookCoverSwitchTabbox = false;
 
133
    bool netbookFlipSwitchTabbox = false;
 
134
 
 
135
 
 
136
    int desktopPresentWindowsLayoutMode = 0;
 
137
    int netbookPresentWindowsLayoutMode = 1;
 
138
 
 
139
    if (m_currentlyIsDesktop) {
 
140
        //save the user preferences on titlebar buttons
 
141
        desktopTitleBarButtonsLeft = kwinStyleCg.readEntry("ButtonsOnLeft", "MS");
 
142
        desktopTitleBarButtonsRight = kwinStyleCg.readEntry("ButtonsOnRight", "HIA__X");
 
143
        ownButtonsCg.writeEntry("DesktopLeft", desktopTitleBarButtonsLeft);
 
144
        ownButtonsCg.writeEntry("DesktopRight", desktopTitleBarButtonsRight);
 
145
 
 
146
        //desktop grid effect
 
147
        desktopPresentWindowsLayoutMode = kwinPresentWindowsCg.readEntry("LayoutMode", 0);
 
148
        ownPresentWindowsCg.writeEntry("DesktopLayoutMode", desktopPresentWindowsLayoutMode);
 
149
 
 
150
        //box switch effect
 
151
        desktopPresentWindowsTabbox = kwinPresentWindowsCg.readEntry("TabBox", false);
 
152
        ownPresentWindowsCg.writeEntry("DesktopTabBox", desktopPresentWindowsTabbox);
 
153
 
 
154
        KConfigGroup ownBoxSwitchCg( m_ownConfig, "Effect-BoxSwitch" );
 
155
        KConfigGroup kwinBoxSwitchCg( m_kwinConfig, "Effect-BoxSwitch" );
 
156
        desktopBoxSwitchTabbox = kwinBoxSwitchCg.readEntry("TabBox", desktopBoxSwitchTabbox);
 
157
        ownBoxSwitchCg.writeEntry( "DesktopTabBox", desktopBoxSwitchTabbox );
 
158
        ownBoxSwitchCg.sync();
 
159
 
 
160
        KConfigGroup ownCoverSwitchCg( m_ownConfig, "Effect-CoverSwitch" );
 
161
        KConfigGroup kwinCoverSwitchCg( m_kwinConfig, "Effect-CoverSwitch" );
 
162
        desktopCoverSwitchTabbox = kwinCoverSwitchCg.readEntry("TabBox", desktopCoverSwitchTabbox);
 
163
        ownCoverSwitchCg.writeEntry( "DesktopTabBox", desktopCoverSwitchTabbox );
 
164
        ownCoverSwitchCg.sync();
 
165
 
 
166
        KConfigGroup ownFlipSwitchCg( m_ownConfig, "Effect-FlipSwitch" );
 
167
        KConfigGroup kwinFlipSwitchCg( m_kwinConfig, "Effect-FlipSwitch" );
 
168
        desktopFlipSwitchTabbox = kwinFlipSwitchCg.readEntry("TabBox", desktopFlipSwitchTabbox);
 
169
        ownFlipSwitchCg.writeEntry( "DesktopTabBox", desktopFlipSwitchTabbox );
 
170
        ownFlipSwitchCg.sync();
 
171
 
 
172
    } else {
 
173
        //save the user preferences on titlebar buttons
 
174
        netbookTitleBarButtonsLeft = kwinStyleCg.readEntry("ButtonsOnLeft", "MS");
 
175
        netbookTitleBarButtonsRight = kwinStyleCg.readEntry("ButtonsOnRight", "HA__X");
 
176
        ownButtonsCg.writeEntry("NetbookLeft", netbookTitleBarButtonsLeft);
 
177
        ownButtonsCg.writeEntry("NetbookRight", netbookTitleBarButtonsRight);
 
178
 
 
179
        //desktop grid effect
 
180
        desktopPresentWindowsLayoutMode = kwinPresentWindowsCg.readEntry("LayoutMode", 0);
 
181
        ownPresentWindowsCg.writeEntry("NetbookLayoutMode", desktopPresentWindowsLayoutMode);
 
182
 
 
183
 
 
184
        //box switch effect
 
185
        netbookPresentWindowsTabbox = kwinPresentWindowsCg.readEntry("TabBox", false);
 
186
        ownPresentWindowsCg.writeEntry("NetbookTabBox", netbookPresentWindowsTabbox);
 
187
 
 
188
        KConfigGroup ownBoxSwitchCg( m_ownConfig, "Effect-BoxSwitch" );
 
189
        KConfigGroup kwinBoxSwitchCg( m_kwinConfig, "Effect-BoxSwitch" );
 
190
        netbookBoxSwitchTabbox = kwinBoxSwitchCg.readEntry("TabBox", netbookBoxSwitchTabbox);
 
191
        ownBoxSwitchCg.writeEntry( "NetbookTabBox", netbookBoxSwitchTabbox );
 
192
        ownBoxSwitchCg.sync();
 
193
 
 
194
        KConfigGroup ownCoverSwitchCg( m_ownConfig, "Effect-CoverSwitch" );
 
195
        KConfigGroup kwinCoverSwitchCg( m_kwinConfig, "Effect-CoverSwitch" );
 
196
        netbookCoverSwitchTabbox = kwinCoverSwitchCg.readEntry("TabBox", netbookCoverSwitchTabbox);
 
197
        ownCoverSwitchCg.writeEntry( "NetbookTabBox", netbookCoverSwitchTabbox );
 
198
        ownCoverSwitchCg.sync();
 
199
 
 
200
        KConfigGroup ownFlipSwitchCg( m_ownConfig, "Effect-FlipSwitch" );
 
201
        KConfigGroup kwinFlipSwitchCg( m_kwinConfig, "Effect-FlipSwitch" );
 
202
        netbookFlipSwitchTabbox = kwinFlipSwitchCg.readEntry("TabBox", netbookFlipSwitchTabbox);
 
203
        ownFlipSwitchCg.writeEntry( "NetbookTabBox", netbookFlipSwitchTabbox );
 
204
        ownFlipSwitchCg.sync();
 
205
    }
 
206
    ownButtonsCg.sync();
 
207
    ownPresentWindowsCg.sync();
 
208
 
 
209
    kwinStyleCg.writeEntry("CustomButtonPositions", true);
 
210
    if (isDesktop) {
 
211
        //kill/enable the minimize button, unless configured differently
 
212
        kwinStyleCg.writeEntry("ButtonsOnLeft", desktopTitleBarButtonsLeft);
 
213
        kwinStyleCg.writeEntry("ButtonsOnRight", desktopTitleBarButtonsRight);
 
214
 
 
215
        //present windows mode
 
216
        kwinPresentWindowsCg.writeEntry("LayoutMode", desktopPresentWindowsLayoutMode);
 
217
 
 
218
        //what to use as tabbox
 
219
        kwinPresentWindowsCg.writeEntry("TabBox", desktopPresentWindowsTabbox);
 
220
 
 
221
        KConfigGroup kwinBoxSwitchCg( m_kwinConfig, "Effect-BoxSwitch" );
 
222
        kwinBoxSwitchCg.writeEntry( "TabBox", desktopBoxSwitchTabbox );
 
223
        kwinBoxSwitchCg.sync();
 
224
 
 
225
        KConfigGroup kwinCoverSwitchCg( m_kwinConfig, "Effect-CoverSwitch" );
 
226
        kwinCoverSwitchCg.writeEntry( "TabBox", desktopCoverSwitchTabbox );
 
227
        kwinCoverSwitchCg.sync();
 
228
 
 
229
        KConfigGroup kwinFlipSwitchCg( m_kwinConfig, "Effect-FlipSwitch" );
 
230
        kwinFlipSwitchCg.writeEntry( "TabBox", desktopFlipSwitchTabbox );
 
231
        kwinFlipSwitchCg.sync();
 
232
    } else {
 
233
        //kill/enable the minimize button, unless configured differently
 
234
        kwinStyleCg.writeEntry("ButtonsOnLeft", netbookTitleBarButtonsLeft);
 
235
        kwinStyleCg.writeEntry("ButtonsOnRight", netbookTitleBarButtonsRight);
 
236
 
 
237
        //present windows mode
 
238
        kwinPresentWindowsCg.writeEntry("LayoutMode", netbookPresentWindowsLayoutMode);
 
239
 
 
240
        //what to use as tabbox
 
241
        kwinPresentWindowsCg.writeEntry("TabBox", netbookPresentWindowsTabbox);
 
242
 
 
243
        KConfigGroup kwinBoxSwitchCg( m_kwinConfig, "Effect-BoxSwitch" );
 
244
        kwinBoxSwitchCg.writeEntry( "TabBox", netbookBoxSwitchTabbox );
 
245
        kwinBoxSwitchCg.sync();
 
246
 
 
247
        KConfigGroup kwinCoverSwitchCg( m_kwinConfig, "Effect-CoverSwitch" );
 
248
        kwinCoverSwitchCg.writeEntry( "TabBox", netbookCoverSwitchTabbox );
 
249
        kwinCoverSwitchCg.sync();
 
250
 
 
251
        KConfigGroup kwinFlipSwitchCg( m_kwinConfig, "Effect-FlipSwitch" );
 
252
        kwinFlipSwitchCg.writeEntry( "TabBox", netbookFlipSwitchTabbox );
 
253
        kwinFlipSwitchCg.sync();
 
254
    }
 
255
 
 
256
    kwinStyleCg.sync();
 
257
    kwinPresentWindowsCg.sync();
 
258
 
 
259
    // Reload KWin.
 
260
    QDBusMessage message = QDBusMessage::createSignal( "/KWin", "org.kde.KWin", "reloadConfig" );
 
261
    QDBusConnection::sessionBus().send(message);
 
262
 
 
263
 
 
264
    if (isDesktop && !m_currentlyIsDesktop) {
 
265
        if (KRun::run("plasma-desktop", KUrl::List(), 0)) {
 
266
            QDBusInterface interface("org.kde.plasma-netbook", "/MainApplication");
 
267
            interface.call("quit");
 
268
            KRun::run("krunner", KUrl::List(), 0);
 
269
        }
 
270
    } else if (!isDesktop && m_currentlyIsDesktop) {
 
271
        if (KRun::run("plasma-netbook", KUrl::List(), 0)) {
 
272
            QDBusInterface interface("org.kde.plasma-desktop", "/MainApplication");
 
273
            interface.call("quit");
 
274
            QDBusInterface krunnerInterface("org.kde.krunner", "/MainApplication");
 
275
            krunnerInterface.call("quit");
 
276
        }
 
277
    }
 
278
    m_currentlyIsDesktop = isDesktop;
 
279
 
 
280
    QDBusInterface interface("org.kde.plasma-desktop", "/App");
 
281
    interface.call("setFixedDashboard", (m_ui->dashboardMode->currentIndex() == 1));
 
282
}
 
283
 
 
284
void WorkspaceOptionsModule::load()
 
285
{
 
286
    if (m_plasmaDesktopAutostart.autostarts()) {
 
287
        m_ui->formFactor->setCurrentIndex(0);
 
288
    } else {
 
289
        m_ui->formFactor->setCurrentIndex(1);
 
290
    }
 
291
 
 
292
    m_currentlyIsDesktop = m_plasmaDesktopAutostart.autostarts();
 
293
 
 
294
    QDBusInterface interface("org.kde.plasma-desktop", "/App");
 
295
    bool fixedDashboard = false;
 
296
 
 
297
    if (interface.isValid()) {
 
298
        fixedDashboard = interface.call("fixedDashboard").arguments().first().toBool();
 
299
    }
 
300
 
 
301
    if (fixedDashboard) {
 
302
        m_ui->dashboardMode->setCurrentIndex(1);
 
303
    } else {
 
304
        m_ui->dashboardMode->setCurrentIndex(0);
 
305
    }
 
306
 
 
307
    KConfig config("plasmarc");
 
308
    KConfigGroup cg(&config, "PlasmaToolTips");
 
309
    m_ui->showToolTips->setChecked(cg.readEntry("Delay", 0.7) > 0);
 
310
}
 
311
 
 
312
void WorkspaceOptionsModule::defaults()
 
313
{
 
314
    m_ui->formFactor->setCurrentIndex(0);
 
315
    m_ui->dashboardMode->setCurrentIndex(0);
 
316
}
 
317
 
 
318
void WorkspaceOptionsModule::formFactorChanged(int newFormFactorIndex)
 
319
{
 
320
    m_ui->dashboardMode->setEnabled(newFormFactorIndex == 0);
 
321
    m_ui->dashboardLabel->setEnabled(newFormFactorIndex == 0);
 
322
}
 
323
 
 
324
#include "workspaceoptions.moc"