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
















                                                                           
                    


                   

                     
                                

                    

                   






                  
                                                
 
                         



































                                                                                           

                                                         
      

                                                           








                                                         


                                                                         

 
/*
 * Copyright (c) 2010,2011 - RZ Uni Freiburg
 * Copyright (c) 2010,2011 - OpenSLX Project
 *
 * This program/file is free software distributed under the GPL version 2.
 * See http://gpl.openslx.org/
 *
 * If you have any feedback please consult http://feedback.openslx.org/ and
 * send your feedback to feedback@openslx.org
 *
 * General information about OpenSLX - libChooser can be found under
 * http://openslx.org
 *
 */

#include <QtGui>
#include <QSizeGrip>
#include <QSettings>
#include <QRect>
#include <QWebView>

#include <VSession.h>

#include "JavaScriptInterface.h"
#include "Globals.h"

#include "Dialog.h"

void
Dialog::setTheme()
{

}

void
Dialog::addItems(const QList<Session *> entries)
{
  jsi->addItems(entries);
}

void
Dialog::center()
{
  QRect desktopRect = QApplication::desktop()->availableGeometry(this);
  QPoint center = desktopRect.center();
  move(center.x() - width() * 0.5, center.y() - height() * 0.5);
}

void
Dialog::createLayout()
{
  layout = new QVBoxLayout(this);
  layout->setSpacing(0);
  layout->setContentsMargins(0, 0, 0, 0);
  layout->setMargin(0);
}

Dialog::Dialog(QWidget *parent) :
    QDialog(parent)
{
  setMinimumSize(940, 740);
  //setStyleSheet("border-color:lightgray");
  setWindowFlags(Qt::FramelessWindowHint);

  createLayout();
  QWebView *webView = new QWebView(parent);

#ifdef DEBUG
  QWebSettings::globalSettings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
#else
  webView->setContextMenuPolicy(Qt::NoContextMenu);
#endif

#if QT_VERSION >= 0x040700
  QWebSettings::globalSettings()->setAttribute(
      QWebSettings::LocalContentCanAccessFileUrls, true);
#endif
  QWebSettings::globalSettings()->setAttribute(
      QWebSettings::LocalContentCanAccessRemoteUrls, true);

  //QWebSettings::globalSettings()->setAttribute(, true);
  webView->setUrl(QUrl("qrc:/html/index.html"));
  webView->show();
  layout->addWidget(webView);

  setLayout(layout);

  jsi = new JavaScriptInterface(webView);
  QObject::connect(webView->page()->mainFrame(),
      SIGNAL(javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM()));
  QObject::connect(jsi, SIGNAL(hideMainWindow()), this, SLOT(hide()));
}