summaryrefslogblamecommitdiffstats
path: root/src/dialog.h
blob: cc7f50ed5085366b91a83b0f450f143c96d4f791 (plain) (tree)
1
2
3
4
5
6
7
8
9
10






                      
                        

                    

                             
                               
 
 






                               




                                       
                                    
                                            

                                     
 
                           
                                               
              
                                                   

                                              
                                                              
                                 

                                           
                                                  
 
                         
                                
                                             

                                                     
                                            
 
                                    
                   

                                        


                            
                   
                  
                         
                              
                               

                                     
                                               
                              
 

                          
                

                                      
                                         
                                                             
                                                        


                                          
                                    
                                     
                                                                                   
                                     
                         
                                                            
 


                       


                  
#ifndef DIALOG_H
#define DIALOG_H

#include <QDialog>
#include <QModelIndex>
#include <QList>
#include <QSettings>
#include <QNetworkReply>
#include <QKeyEvent>

#include "session.h"
#include "sessiontreemodel.h"
#include "sessionsiconholder.h"


namespace Ui {
    class Dialog;
}
class QTimer;

class Dialog : public QDialog {
    Q_OBJECT
  private: // Constants
    static const int STR_LOADING = 0;
    static const int STR_URL_ERROR = 1;
    static const int STR_NO_ITEMS = 2;
    static const int STR__MAX = 3;
    static const int TAB_NATIVE = 0;
    static const int TAB_RECENT_COURSES = 1;
    static const int TAB_ALL_VMS = 2;
    static const int TAB_COUNT = 3;

  public: // Public methods
    explicit Dialog(QWidget *parent = nullptr);
    ~Dialog();
    void addItems(const QList<Session*>&, int tab);
    void addStatusString(const int status);
    void removeStatusString(const int status);
    bool selectSession(const QString& name, int lastTab = -1);
    void selectPreviousSession();
    void setTheme();
    void startSession(const QString& name);
    void downloadData(const QString& locationIds);

  protected: // Overrides
    void changeEvent(QEvent *e);
    void mousePressEvent(QMouseEvent *event);
    bool eventFilter(QObject *target, QEvent *event);
    void keyPressEvent(QKeyEvent * e);
    void showEvent(QShowEvent * e) override;

  private: // Private vars n methods
    Ui::Dialog *ui;
    SessionTreeModel *model_[TAB_COUNT];
    QPushButton *tabs_[TAB_COUNT];
    QPoint oldCenter_;
    QTimer *centerTimer_;
    QString autoStartEntry_;
    int activeTab_;
    int autoQuit_;
    bool userInteracted_;
    bool genericExpandedOnce_;
    QString strings_[STR__MAX];
    void onTabButtonChanged(int tab);
    void configClearButton();
    void setListModel(SessionTreeModel *model);
    void selectFirstElement();

    void checkAutostart();

  private slots:
    void on_pushButtonStart_clicked();
    void on_pushButtonAbort_clicked();
	void on_btnScreenSetup_clicked();
    void on_treeView_doubleClicked(const QModelIndex& index);
    void on_treeView_expanded(const QModelIndex& index);
    void on_tabButtonLocal_clicked();
    void on_tabButtonMyClasses_clicked();
    void on_tabButtonAllClasses_clicked();
    void on_filterEdit_textEdited();
    void on_filterEdit_textChanged();
    void treeView_selectionChanged(const QModelIndex& current, const QModelIndex&);
    void on_helpNewsButton_clicked();
    void onCenterTimer();
    void iconDownloaded(const QUrl& url, const QIcon& icon);

    void on_leftKey();
    void on_rightKey();
    void on_spaceKey();
};

#endif // DIALOG_H