Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Clean up the auto-login display, so now it loads the default PCDM bac…
Browse files Browse the repository at this point in the history
…kground image on all screens as well as center the login delay dialog on the primary screen.
  • Loading branch information
Ken Moore committed Feb 12, 2015
1 parent 77386e3 commit 9e95a2e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src-qt5/PCDM/src/main.cpp
Expand Up @@ -107,7 +107,8 @@ int runSingleSession(int argc, char *argv[]){
QString user = Backend::getALUsername();
QString pwd = Backend::getALPassword();
QString dsk = Backend::getLastDE(user);
if( user.isEmpty() || dsk.isEmpty() ){
if( user.isEmpty() || dsk.isEmpty() || QFile::exists("/var/db/personacrypt/"+user+".key") ){
//Invalid inputs (or a PersonaCrypt user)
goodAL=false;
}else{
//Run the time delay for the autologin attempt
Expand Down
36 changes: 32 additions & 4 deletions src-qt5/PCDM/src/pcdm-logindelay.cpp
Expand Up @@ -4,7 +4,7 @@
#include <QPoint>
#include <QDesktopWidget>

loginDelay::loginDelay(int seconds, QString username) : QDialog(), ui(new Ui::loginDelay){
loginDelay::loginDelay(int seconds, QString username) : QDialog(0, Qt::Dialog | Qt::WindowStaysOnTopHint), ui(new Ui::loginDelay){
ui->setupUi(this); //load the designer files
continueLogin = false; //in case it is closed early somehow
//Now setup the display
Expand All @@ -19,16 +19,19 @@ loginDelay::loginDelay(int seconds, QString username) : QDialog(), ui(new Ui::lo
connect(ui->pushCancel, SIGNAL(clicked()), this, SLOT(cancelLogin()) );
connect(ui->pushContinue, SIGNAL(clicked()), this, SLOT(startLogin()) );
//Center the dialog on the screen
QPoint center = QApplication::desktop()->availableGeometry().center();
this->move(center.x()-(this->width()/2), center.y()-(this->height()/2));
fillScreens();
}

loginDelay::~loginDelay(){

//Also clean up all the background fillers
for(int i=0; i<screens.length(); i++){
delete screens[i];
}
}

void loginDelay::start(){
this->show();
this->raise();
delay->start();
}

Expand All @@ -52,3 +55,28 @@ void loginDelay::startLogin(){
continueLogin = true;
this->close();
}

void loginDelay::fillScreens(){
//Set a background image on any other available screens
QDesktopWidget *DE = QApplication::desktop();
screens.clear();
//Generate the background style sheet
QString tmpIcon = ":/images/backgroundimage.jpg"; //always use the defult PCDM image (don't load theme for auto-login)
QString bgstyle = "QWidget#BGSCREEN{border-image: url(BGIMAGE) stretch;}";
bgstyle.replace("BGIMAGE", tmpIcon);
//Now apply the background to all the screens

for(int i=0; i<DE->screenCount(); i++){
//Just show a generic QWidget with the proper background image on every screen
QWidget *screen = new QWidget(0, Qt::Window | Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus | Qt::WindowStaysOnBottomHint);
screen->setObjectName("BGSCREEN");
screen->setGeometry( DE->screenGeometry(i) );
screen->setStyleSheet(bgstyle);
screen->show();
screens << screen;
}
//Now center the login delay widget on the screen
QPoint ctr = DE->screenGeometry(0).center();
this->move( ctr.x()-(this->width()/2), ctr.y()-(this->height()/2) );
QCursor::setPos( ctr );
}
5 changes: 4 additions & 1 deletion src-qt5/PCDM/src/pcdm-logindelay.h
Expand Up @@ -4,7 +4,7 @@
#include <QDialog>
#include <QTimer>
#include <QString>

#include <QList>

namespace Ui{
class loginDelay;
Expand All @@ -23,6 +23,9 @@ class loginDelay : public QDialog{
private:
Ui::loginDelay *ui; //designer file
QTimer *delay;
QList<QWidget*> screens;

void fillScreens();

private slots:
void updateTimer();
Expand Down

0 comments on commit 9e95a2e

Please sign in to comment.