summaryrefslogblamecommitdiffstats
path: root/src/loginform.h
blob: 6a05ea9c52d199a0d468448031230ba2ba679043 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16















                                                             
                 
                           
 


                     





                
              

              
 



                                
       
                                                  



                                                  
                                        
                                           
                                                                            


                                                                               
                       



                                                               
                          

                                             


                   

          

                                                                      
                                                      


                      
                     


                                                                                       
                                                  
                     
                                   

                      
                                                               

                            
                            
                          



                             

                     

                  
               
                  


                     
/*
* Copyright (c) 2012-2015 Christian Surlykke
*
* This file is part of qt-lightdm-greeter 
* It is distributed under the LGPL 2.1 or later license.
* Please refer to the LICENSE file for a copy of the license.
*/
#ifndef LOGINFORM_H
#define LOGINFORM_H

#include <QWidget>
#include <QProcess>
#include <QDialog>
#include <QKeyEvent>
#include <QGraphicsOpacityEffect>
#include <QMap>
#include <QTimer>
#include <QLightDM/Greeter>

namespace QLightDM {
class PowerInterface;
}

namespace Ui
{
class LoginForm;
}

class WebView;
class QLabel;
class QrLogin;

class LoginForm : public QWidget
{
    Q_OBJECT

public:
    explicit LoginForm(QWidget *parent = nullptr);
    ~LoginForm();
    virtual void setFocus(Qt::FocusReason reason);

public slots:
    void startFormBasedAuthentication();
    void leaveDropDownActivated(int index);
    void onPrompt(QString prompt, QLightDM::Greeter::PromptType promptType);
    void onMessage(QString prompt, QLightDM::Greeter::MessageType messageType);
    void onAuthenticationComplete();
    void cancelLogin();
    void hideMessage();
    void startAuthAs(const QString &user, const QString &pass);

private slots:
    void setBrowserSize();
    void showShibWindow();
    void showQrWindow();
    void showLowPrioMessage(QString message);

signals:
    void resized();

protected:
    virtual void keyPressEvent(QKeyEvent *event) override;
    virtual bool eventFilter(QObject *object, QEvent *event) override;
    virtual void resizeEvent(QResizeEvent *) override;

private:
    void initialize();
    void checkCaps();
    void addLeaveEntry(bool canDo, QString iconName, QString text, QString actionName);
    QString currentSession();
    void setCurrentSession(QString session);
    void showMessage(QString message, bool error);
    void resetForm();
    void enableInputs(bool enable);
    Ui::LoginForm *ui;

    QMap<int, void (QLightDM::PowerInterface::*)()> powerSlots;

    QTimer cancelLoginTimer;
    QTimer hideMessageTimer;
    QTimer resetFormTimer;
    QString password;
    QSize shibSize, origSize;

    WebView *browser;
    QLabel *qrcode;
    QrLogin *qrlogin;

    bool clearMsg;
    int capsOn;
    int pageCount;
};

#endif // LOGINFORM_H