~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/kephal/service/configurationscreens.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2008 Aike J Sommer <dev@aikesommer.name>
 
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
 
6
 *   published by the Free Software Foundation; either version 2,
 
7
 *   or (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 Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
 
 
21
#include "configurationscreens.h"
 
22
 
 
23
#include "configurations.h"
 
24
#include "backendconfigurations.h"
 
25
 
 
26
#include "KDebug"
 
27
 
 
28
namespace Kephal {
 
29
 
 
30
    ConfigurationScreens::ConfigurationScreens(QObject * parent)
 
31
        : OutputScreens(parent)
 
32
    {
 
33
        connect(Configurations::self(), SIGNAL(configurationActivated(Kephal::Configuration *)), this, SLOT(configurationActivated(Kephal::Configuration *)));
 
34
    }
 
35
 
 
36
    void ConfigurationScreens::configurationActivated(Configuration * configuration) {
 
37
        Q_UNUSED(configuration)
 
38
        kDebug();
 
39
        triggerRebuildScreens();
 
40
    }
 
41
 
 
42
    void ConfigurationScreens::prepareScreens(QMap<int, OutputScreen *> & screens) {
 
43
        BackendConfiguration * config = BackendConfigurations::self()->activeBackendConfiguration();
 
44
        if (! config) {
 
45
            return;
 
46
        }
 
47
 
 
48
        if (config->name() == "external") {
 
49
            screens.clear();
 
50
            return;
 
51
        }
 
52
 
 
53
        QMap<int, QRect> layout = config->realLayout();
 
54
        for (QMap<int, QRect>::const_iterator i = layout.constBegin(); i != layout.constEnd(); ++i) {
 
55
            if (screens.contains(i.key())) {
 
56
                screens[i.key()]->_setGeom(i.value());
 
57
            } else {
 
58
                OutputScreen * screen = new OutputScreen(this);
 
59
                screen->_setId(i.key());
 
60
                screen->_setGeom(i.value());
 
61
                screens.insert(screen->id(), screen);
 
62
            }
 
63
        }
 
64
 
 
65
        for (QMap<int, OutputScreen *>::iterator i = screens.begin(); i != screens.end();) {
 
66
            if (! layout.contains(i.key())) {
 
67
                i = screens.erase(i);
 
68
            } else {
 
69
                ++i;
 
70
            }
 
71
        }
 
72
    }
 
73
 
 
74
}
 
75