Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 77 lines (66 sloc) 2.574 kb
d05ffa3 @surlykke Copyright headers in razor-lightdm-greeter source files
surlykke authored
1 /* BEGIN_COMMON_COPYRIGHT_HEADER
2 * (c)LGPL2+
3 *
4 * Razor - a lightweight, Qt based, desktop toolset
5 * http://razor-qt.org
6 *
7 * Copyright: 2012 Christian Surlykke
8 *
9 * This program or library is free software; you can redistribute it
10 * and/or modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18
19 * You should have received a copy of the GNU Lesser General
20 * Public License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA
23 *
24 * END_COMMON_COPYRIGHT_HEADER */
25
9b48747 add module names to includes
GabrielYYZ authored
26 #include <QtCore/QRect>
27 #include <QtGui/QApplication>
28 #include <QtGui/QDesktopWidget>
29 #include <QtGui/QPalette>
6139d95 @pvanek lightdm: move cursor to the center of screen for miltiple screens sea…
pvanek authored
30 #include <QtGui/QX11Info>
7d3e01a @amoskvin Greeter: Un-hardcode background image
amoskvin authored
31 #include <razorqt/razorsettings.h>
6139d95 @pvanek lightdm: move cursor to the center of screen for miltiple screens sea…
pvanek authored
32
922f71a @surlykke Added razorqt-lightdm-greeter - a razor frontend to lightdm
surlykke authored
33 #include "mainwindow.h"
34 #include "loginform.h"
35
6139d95 @pvanek lightdm: move cursor to the center of screen for miltiple screens sea…
pvanek authored
36
d59d55d @pvanek lightdm-greeter: proper displaying in multiple screens environment
pvanek authored
37 MainWindow::MainWindow(int screen, QWidget *parent)
38 : QWidget(parent)
39 {
c3d6d79 @pvanek lightdm: Ensure we set the primary screen's widget as active when the…
pvanek authored
40 setObjectName(QString("MainWindow_%1").arg(screen));
41
d59d55d @pvanek lightdm-greeter: proper displaying in multiple screens environment
pvanek authored
42 QRect screenRect = QApplication::desktop()->screenGeometry(screen);
43 setGeometry(screenRect);
7d3e01a @amoskvin Greeter: Un-hardcode background image
amoskvin authored
44 QImage image(razorTheme.desktopBackground(screen));
922f71a @surlykke Added razorqt-lightdm-greeter - a razor frontend to lightdm
surlykke authored
45
46 QPalette palette;
d59d55d @pvanek lightdm-greeter: proper displaying in multiple screens environment
pvanek authored
47 palette.setBrush(this->backgroundRole(), QBrush(image.scaled(screenRect.width(), screenRect.right())));
922f71a @surlykke Added razorqt-lightdm-greeter - a razor frontend to lightdm
surlykke authored
48 this->setPalette(palette);
49
d59d55d @pvanek lightdm-greeter: proper displaying in multiple screens environment
pvanek authored
50 // display login dialog only in the main screen
c3d6d79 @pvanek lightdm: Ensure we set the primary screen's widget as active when the…
pvanek authored
51 m_main = screen == QApplication::desktop()->primaryScreen();
52 if (m_main)
922f71a @surlykke Added razorqt-lightdm-greeter - a razor frontend to lightdm
surlykke authored
53 {
d59d55d @pvanek lightdm-greeter: proper displaying in multiple screens environment
pvanek authored
54 LoginForm *loginForm = new LoginForm(this);
55 int offsetX = 2*screenRect.width()/5 - loginForm->width()/2;
56 if (offsetX < 40)
57 {
58 offsetX = 40;
59 }
60 int offsetY = screenRect.height()/2 - loginForm->height()/2;
922f71a @surlykke Added razorqt-lightdm-greeter - a razor frontend to lightdm
surlykke authored
61 loginForm->move(offsetX, offsetY);
d59d55d @pvanek lightdm-greeter: proper displaying in multiple screens environment
pvanek authored
62 loginForm->show();
6139d95 @pvanek lightdm: move cursor to the center of screen for miltiple screens sea…
pvanek authored
63
64 // This hack ensures that the primary screen will have focus
65 // if there are more screens (move the mouse cursor in the center
66 // of primary screen - not in the center of all X area). It
67 // won't affect single-screen environments.
68 int centerX = screenRect.width()/2 + screenRect.x();
69 int centerY = screenRect.height()/2 + screenRect.y();
70 QCursor::setPos(centerX, centerY);
d59d55d @pvanek lightdm-greeter: proper displaying in multiple screens environment
pvanek authored
71 }
922f71a @surlykke Added razorqt-lightdm-greeter - a razor frontend to lightdm
surlykke authored
72 }
73
74 MainWindow::~MainWindow()
75 {
76 }
Something went wrong with that request. Please try again.