diff options
-rw-r--r-- | qt-lightdm-greeter.qrc | 1 | ||||
-rw-r--r-- | resources/gnome-face-tired.svg | 376 | ||||
-rw-r--r-- | src/main.cpp | 32 | ||||
-rw-r--r-- | src/mainwindow.cpp | 26 | ||||
-rw-r--r-- | src/mainwindow.h | 4 |
5 files changed, 438 insertions, 1 deletions
diff --git a/qt-lightdm-greeter.qrc b/qt-lightdm-greeter.qrc index 93e3e45..d632f53 100644 --- a/qt-lightdm-greeter.qrc +++ b/qt-lightdm-greeter.qrc @@ -3,5 +3,6 @@ <file>resources/dropdown.svg</file> <file>resources/leaveIcon.svg</file> <file>resources/bwlp.svg</file> + <file>resources/gnome-face-tired.svg</file> </qresource> </RCC> diff --git a/resources/gnome-face-tired.svg b/resources/gnome-face-tired.svg new file mode 100644 index 0000000..de43b1a --- /dev/null +++ b/resources/gnome-face-tired.svg @@ -0,0 +1,376 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + viewBox="0 0 47.001228 49.000003" + version="1.0" + id="svg2" + height="52.26667" + width="50.134644"> + <defs + id="defs4"> + <linearGradient + id="linearGradient8431"> + <stop + id="stop8433" + offset="0" + style="stop-color:#ffffff;stop-opacity:1;" /> + <stop + id="stop8435" + offset="1" + style="stop-color:#ffffff;stop-opacity:0;" /> + </linearGradient> + <linearGradient + id="linearGradient4487"> + <stop + style="stop-color:#ffffff;stop-opacity:1;" + offset="0" + id="stop4489" /> + <stop + id="stop4491" + offset="0.58888888" + style="stop-color:#ffffff;stop-opacity:1;" /> + <stop + style="stop-color:#ffffff;stop-opacity:0;" + offset="1" + id="stop4493" /> + </linearGradient> + <linearGradient + id="linearGradient3752"> + <stop + style="stop-color:white;stop-opacity:1" + offset="0" + id="stop3754" /> + <stop + id="stop3756" + offset="0.80000001" + style="stop-color:#fce94f;stop-opacity:1;" /> + <stop + style="stop-color:#edd400;stop-opacity:1" + offset="1" + id="stop3758" /> + </linearGradient> + <linearGradient + id="linearGradient3734"> + <stop + id="stop3736" + offset="0" + style="stop-color:black;stop-opacity:1;" /> + <stop + id="stop3738" + offset="1" + style="stop-color:black;stop-opacity:0;" /> + </linearGradient> + <linearGradient + id="linearGradient3712"> + <stop + style="stop-color:white;stop-opacity:1;" + offset="0" + id="stop3714" /> + <stop + style="stop-color:white;stop-opacity:0.50570345" + offset="1" + id="stop3716" /> + </linearGradient> + <linearGradient + id="linearGradient3704"> + <stop + id="stop3706" + offset="0" + style="stop-color:white;stop-opacity:1;" /> + <stop + id="stop3708" + offset="1" + style="stop-color:white;stop-opacity:0;" /> + </linearGradient> + <radialGradient + r="10.049342" + fy="7.8025141" + fx="9.3747082" + cy="7.8025141" + cx="9.3747082" + gradientTransform="matrix(1.200799,0,0,1.200799,-1.921023,-1.565398)" + gradientUnits="userSpaceOnUse" + id="radialGradient4412" + xlink:href="#linearGradient3752" /> + <radialGradient + r="10.108456" + fy="3.2659137" + fx="5.3851099" + cy="3.2659137" + cx="5.3851099" + gradientTransform="matrix(1.242401,0,0,1.242401,-1.281477,-0.839422)" + gradientUnits="userSpaceOnUse" + id="radialGradient4414" + xlink:href="#linearGradient3712" /> + <linearGradient + y2="-134.38734" + x2="19.23638" + y1="-140.43388" + x1="18.825819" + gradientUnits="userSpaceOnUse" + id="linearGradient8741" + xlink:href="#linearGradient8431" /> + <radialGradient + r="9.546875" + fy="10.046875" + fx="12.046875" + cy="10.046875" + cx="12.046875" + gradientUnits="userSpaceOnUse" + id="radialGradient7956" + xlink:href="#linearGradient3734" /> + <radialGradient + r="7.0416665" + fy="50.736225" + fx="-84.320526" + cy="50.736225" + cx="-84.320526" + gradientTransform="matrix(0.86849,0,0,0.86849,-11.05505,6.701792)" + gradientUnits="userSpaceOnUse" + id="radialGradient2230" + xlink:href="#linearGradient4487" /> + <radialGradient + r="7.0416665" + fy="50.736225" + fx="-84.320526" + cy="50.736225" + cx="-84.320526" + gradientTransform="matrix(0.86849,0,0,0.86849,-11.05505,6.701792)" + gradientUnits="userSpaceOnUse" + id="radialGradient2232" + xlink:href="#linearGradient4487" /> + <radialGradient + r="11.89852" + fy="66.5" + fx="-79.065781" + cy="66.5" + cx="-79.065781" + gradientTransform="matrix(1.172092,0,0,0.779118,114.2479,-215.3113)" + gradientUnits="userSpaceOnUse" + id="radialGradient2234" + xlink:href="#linearGradient3704" /> + <linearGradient + id="linearGradient2967"> + <stop + style="stop-color:#729fcf;stop-opacity:1;" + offset="0" + id="stop2969" /> + <stop + style="stop-color:white;stop-opacity:1" + offset="1" + id="stop2971" /> + </linearGradient> + <linearGradient + id="linearGradient2982"> + <stop + style="stop-color:#8db1d8;stop-opacity:1;" + offset="0" + id="stop2984" /> + <stop + style="stop-color:#3465a4;stop-opacity:1;" + offset="1" + id="stop2986" /> + </linearGradient> + <linearGradient + y2="-1.7008253" + x2="16" + y1="4.5018396" + x1="17.763865" + gradientTransform="translate(12,15)" + gradientUnits="userSpaceOnUse" + id="linearGradient3394" + xlink:href="#linearGradient2967" /> + <linearGradient + y2="9.2939177" + x2="46.404255" + y1="1.9139081" + x1="40.416721" + gradientTransform="scale(1.032655,0.968377)" + gradientUnits="userSpaceOnUse" + id="linearGradient3397" + xlink:href="#linearGradient2982" /> + <linearGradient + y2="5.7135463" + x2="31.59153" + y1="13.15625" + x1="32.875" + gradientUnits="userSpaceOnUse" + id="linearGradient3399" + xlink:href="#linearGradient2967" /> + </defs> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + <dc:creator> + <cc:Agent> + <dc:title>Lapo Calamandrei</dc:title> + </cc:Agent> + </dc:creator> + <cc:license + rdf:resource="http://creativecommons.org/licenses/GPL/2.0/" /> + <dc:relation>emoticon, emots, smiley, saint, angel, smile</dc:relation> + </cc:Work> + <cc:License + rdf:about="http://creativecommons.org/licenses/GPL/2.0/"> + <cc:permits + rdf:resource="http://web.resource.org/cc/Reproduction" /> + <cc:permits + rdf:resource="http://web.resource.org/cc/Distribution" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/Notice" /> + <cc:permits + rdf:resource="http://web.resource.org/cc/DerivativeWorks" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/ShareAlike" /> + <cc:requires + rdf:resource="http://web.resource.org/cc/SourceCode" /> + </cc:License> + </rdf:RDF> + </metadata> + <g + transform="translate(-1.0000003)" + style="display:inline" + id="layer1"> + <g + transform="translate(-106,-6)" + id="g7909" /> + <g + id="g3901"> + <circle + style="display:inline;opacity:0.4;fill:url(#radialGradient7956);fill-opacity:1;stroke:none;stroke-width:0.46570092;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path7954" + transform="matrix(2.4091653,0,0,1.2045827,-5.022913,25.39771)" + cx="12.046875" + cy="10.046875" + r="9.546875" /> + <circle + style="display:inline;fill:url(#radialGradient4412);fill-opacity:1;stroke:#c4a000;stroke-width:0.46570092;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path4380" + transform="matrix(2.1473,0,0,2.1473,-1.8687,3.4268)" + cx="12.046875" + cy="10.046875" + r="9.546875" /> + <ellipse + style="display:inline;fill:url(#linearGradient8741);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0.69999993;stroke-opacity:1" + id="path8739" + transform="matrix(2.2078305,-0.5915864,0.4553048,1.6992208,40.743051,260.37364)" + cx="19.5625" + cy="-135.96875" + rx="6.125" + ry="5.96875" /> + <circle + style="display:inline;fill:none;fill-opacity:1;stroke:url(#radialGradient4414);stroke-width:0.48958337;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + id="path4382" + transform="matrix(2.042553,0,0,2.042553,-0.6064,4.4787)" + cx="12.046875" + cy="10.046875" + r="9.546875" /> + <g + id="g4499" + transform="translate(0,-22)" + style="opacity:0.65"> + <circle + transform="matrix(0.923077,0,0,0.923077,95.6154,0.57692)" + id="path4481" + style="display:inline;opacity:1;fill:url(#radialGradient2230);fill-opacity:1;stroke:none;stroke-width:1.08333337;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + cx="-83" + cy="53" + r="6.5" /> + <circle + transform="matrix(0.923077,0,0,0.923077,105.6154,0.57692)" + id="path4495" + style="display:inline;opacity:1;fill:url(#radialGradient2232);fill-opacity:1;stroke:none;stroke-width:1.08333337;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" + cx="-83" + cy="53" + r="6.5" /> + </g> + <g + id="g7846" + transform="translate(0,205)"> + <path + id="path4515" + d="m 15.5,-176.5 c 1.962489,1.29412 3.958976,1.41533 6,0" + style="display:inline;opacity:0.81226059;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + <path + id="path4517" + d="m 31.5,-176.5 c -1.962489,1.29412 -3.958976,1.41533 -6,0" + style="display:inline;opacity:0.81226059;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + <path + id="path4509" + d="m 15.5,-175.5 c 1.962489,1.29412 3.958976,1.41533 6,0" + style="fill:none;fill-rule:evenodd;stroke:#888a85;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + <path + id="path4513" + d="m 31.5,-175.5 c -1.962489,1.29412 -3.958976,1.41533 -6,0" + style="display:inline;fill:none;fill-rule:evenodd;stroke:#888a85;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <g + id="g4531" + transform="matrix(0.3112951,0,0,1,17.520421,204)"> + <path + id="path4527" + d="M 15.557761,-163.5 H 32.435777" + style="display:inline;opacity:0.8;fill:none;fill-rule:evenodd;stroke:url(#radialGradient2234);stroke-width:1.79231215px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <path + style="fill:none;fill-rule:evenodd;stroke:#c4a000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" + d="m 22.5,39.5 h 5" + id="path5373" /> + <path + id="path2898" + d="m 28.5,15.5 v 2 h 2 l -2,2.5 v 1.5 h 5 v -2 h -2 l 2,-2.5 v -1.5 z" + style="fill:url(#linearGradient3394);fill-opacity:1;stroke:#3465a4;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + <g + id="g1975" + transform="translate(3.000005)"> + <path + id="path2946" + d="m 31,9 4.999995,2e-6 v 1.053572 L 32.79543,14 H 36 l -5e-6,1.000004 h -5 L 31,13.946429 34.210006,10.000002 31,10 Z" + style="font-style:normal;font-weight:bold;font-size:11.05665684px;font-family:'Bitstream Vera Sans Mono';fill:#729fcf;fill-opacity:1;stroke:#3465a4;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + id="text2929" + d="m 31,9 4.999995,2e-6 v 1.053572 L 32.79543,14 H 36 l -5e-6,1.000004 h -5 L 31,13.946429 34.210006,10.000002 31,10 V 9" + style="font-style:normal;font-weight:bold;font-size:11.05665684px;font-family:'Bitstream Vera Sans Mono';fill:url(#linearGradient3399);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + </g> + <g + id="g1967" + transform="translate(-0.005991)"> + <path + id="path2949" + d="m 40,1 7.000003,-6.5e-7 0.006,2.07142925 L 43,7 h 4 l 3e-6,2.0000161 h -7.000019 l -2e-6,-2.0714448 L 44,3 l -3.994011,7e-7 z" + style="font-style:normal;font-weight:bold;font-size:15.10630894px;font-family:'Bitstream Vera Sans Mono';fill:#729fcf;fill-opacity:1;stroke:#3465a4;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + <path + id="text2933" + d="m 40,1 7.000003,-6.5e-7 0.006,2.07142925 L 43,7 h 4 l 3e-6,2.0000161 h -7.000019 l -2e-6,-2.0714448 L 44,3 l -3.994011,7e-7 L 40,1" + style="font-style:normal;font-weight:bold;font-size:15.10630894px;font-family:'Bitstream Vera Sans Mono';fill:url(#linearGradient3397);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + <g + style="opacity:0.5" + id="g3008"> + <path + style="opacity:1;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:1px;stroke-linecap:square;stroke-linejoin:miter;stroke-opacity:1" + d="m 40.5,2.5 v -1 h 6" + id="path2951" /> + <path + style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" + d="M 43.0625,7 C 42.786358,7.0258883 42.583487,7.2707326 42.609375,7.546875 42.635263,7.8230174 42.880108,8.0258883 43.15625,8 H 47 V 7 H 43.15625 C 43.12507,6.99706 43.09368,6.99706 43.0625,7 Z" + id="path2953" /> + <path + style="opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:round;stroke-linejoin:miter;stroke-opacity:1" + d="M 44.09375,3 C 44.00794,3.03114 43.932288,3.085176 43.875,3.15625 L 40.15625,6.78125 40,6.9375 V 7.15625 9 h 1 V 7.34375 l 3.5625,-3.5 C 44.724254,3.6862744 44.760437,3.4399497 44.650803,3.2426093 44.54117,3.0452688 44.31291,2.9458567 44.09375,3 Z" + id="path2955" /> + </g> + </g> + </g> + </g> +</svg> diff --git a/src/main.cpp b/src/main.cpp index 7ba8758..a5fa5db 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,9 +13,13 @@ #include <QIcon> #include <QPainter> #include <QMap> +#include <QSocketNotifier> #include <fcntl.h> /* Obtain O_* constant definitions */ #include <unistd.h> +#include <signal.h> +#include <sys/types.h> +#include <sys/socket.h> #include <iostream> @@ -24,8 +28,12 @@ #include "x11util.h" #include "global.h" +static int sockets[2]; + static void createSimpleBackground(); +static void sigUsr1(int); + static void messageHandler(QtMsgType type, const QMessageLogContext&, const QString& msg) { std::cerr << type << ": " << msg.toUtf8().constData() << '\n'; @@ -112,6 +120,21 @@ int main(int argc, char *argv[]) primary = screens.begin().key(); } + struct sigaction usr1; + + usr1.sa_handler = &sigUsr1; + sigemptyset(&usr1.sa_mask); + usr1.sa_flags = SA_RESTART; + + QSocketNotifier *sn = NULL; + if (sigaction(SIGUSR1, &usr1, 0) == 0 && ::socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == 0) { + sn = new QSocketNotifier(sockets[1], QSocketNotifier::Read); + QObject::connect(sn, &QSocketNotifier::activated, [](int fd) { + char tmp[1000]; + read(fd, tmp, sizeof tmp); + }); + } + // Now set up all the screens QPainter painter(&entire); MainWindow *focusWindow = 0; @@ -120,6 +143,9 @@ int main(int argc, char *argv[]) it.next(); MainWindow *w = new MainWindow(primary == it.key(), it.key(), it.value()); w->show(); + if (sn != NULL) { + QObject::connect(sn, SIGNAL(activated(int)), w, SLOT(showStandby())); + } if (w->showLoginForm()) { focusWindow = w; } @@ -152,3 +178,9 @@ static void createSimpleBackground() img = img.scaled(QApplication::desktop()->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); AddPixmapToBackground(img.constBits(), img.width(), img.height(), 24, img.bytesPerLine(), img.byteCount()); } + +static void sigUsr1(int) +{ + char a = 1; + ::write(sockets[0], &a, sizeof(a)); +} diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d58b7f6..0e6a5e7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -18,6 +18,9 @@ #include <QSvgRenderer> #include <QAbstractTextDocumentLayout> +#include <sys/types.h> +#include <sys/socket.h> + #include "mainwindow.h" #include "loginform.h" #include "settings.h" @@ -29,6 +32,7 @@ MainWindow::MainWindow(bool primary, int screen, const QRect &screenRect, QWidge QWidget(parent), m_ScreenRect(screenRect), m_Primary(primary), + m_LoginForm(NULL), m_messages(nullptr) { setObjectName(QString("MainWindow_%1").arg(screen)); @@ -254,4 +258,24 @@ void MainWindow::setBackground() this->setPalette(palette); } - +void MainWindow::showStandby() +{ + if (m_LoginForm != NULL) { + m_LoginForm->hide(); + } + QSvgWidget *img = new QSvgWidget(":/resources/gnome-face-tired.svg", this); + if (img->renderer()->isValid()) { + QSize sh = img->sizeHint().scaled(this->width() / 2, this->height() / 2, Qt::KeepAspectRatio); + img->setGeometry((this->width() - sh.width()) / 2, (this->height() - sh.height()) / 2, sh.width(), sh.height()); + img->show(); + } else { + qWarning() << "Shice!"; + } + QTimer::singleShot(8000, [this, img]() { + img->hide(); + img->deleteLater(); + if (this->m_LoginForm != NULL) { + m_LoginForm->show(); + } + }); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 53c54e0..e136540 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -43,6 +43,10 @@ public: QImage& getBackground() { return m_background; } LoginForm* loginForm() { return m_LoginForm; } + +public slots: + void showStandby(); + private: int getOffset(QString offset, int maxVal, int defaultVal); void setBackground(); |