summaryrefslogblamecommitdiffstats
path: root/src/main.cpp
blob: 6a5fa7c286dfb95aed96c96d212ee1e027b11e47 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                                          
 
                             

                   
                   


                                











                                                                         




                             
 













































































































































































































































































































                                                                                                                                            
// Copyright 2013, University of Freiburg,
// Author: Manuel Schneider <ms1144>

#include <QtGui/QApplication>
#include <fstream>
#include <iostream>
#include "widget.h"

int main(int argc, char *argv[])
{
  //if (argc != 2) {
  //  std::cout << "Usage: " << argv[0] << " <config file>" << std::endl;
  //} else {
  //  // Check  if file exists
  //  std::ifstream f(argv[1]);
  //  if (!f) {
  //    std::cerr << "The config file does not exist."  << std::endl;
  //    exit(1);
  //  }
  //  else
  //    f.close();
  //}

  QApplication a(argc, argv);
  Widget w;
  w.show();
  return a.exec();
}




////////////////////////////////////////// CODE MÜLLEIMER


      // eine datei


//Widget::Widget(QWidget *parent) :
//    QWidget(parent),
//    ui(new Ui::Widget)
//{
//    ui->setupUi(this);

//    for (std::vector<Output>::iterator i = DisplayManager::Inst()->getConnectedOutputs().begin();
//         i != DisplayManager::Inst()->getConnectedOutputs().end();
//         ++i)
//    {
//        qDebug() << "EDID?" << ( (*i).hasEDID() ? "true" :  "false");
//        qDebug() << "Proj?" << ( (*i).isProjector() ? "true" :  "false");
//        qDebug() << "Current?"
//                  <<  DisplayManager::Inst()->getResolution((*i).getCurrentMode()).width
//                  <<  DisplayManager::Inst()->getResolution((*i).getCurrentMode()).height;
//        Resolution res;
//        if ((*i).getPreferredMode())
//            qDebug() << "Preferred?"
//                     <<  DisplayManager::Inst()->getResolution((*i).getPreferredMode()).width
//                     <<  DisplayManager::Inst()->getResolution((*i).getPreferredMode()).height;

//        QSet<RRMode> modes =   (*i).getSupportedModes();

//        for ( QSet<RRMode>::iterator i = modes.begin(); i != modes.end(); ++i )
//        {
//            qDebug() << "---- "
//                     <<  DisplayManager::Inst()->getResolution(*i).width
//                     <<  DisplayManager::Inst()->getResolution(*i).height;
//        }
//    }


//    switch ( DisplayManager::Inst()->getConnectedOutputs().size() ){
//    /*************************************************************************/
//    case 1:// In case of one connected output - xrandr --auto
//        qDebug() << "Normal output";
//        exit(0);
//        break;
//    /*************************************************************************/
//    case 2: // In case of two connected outputs

//        /*********************************************************************/
//        // If one of the two connected outputs is a beamer

//        if ( true)//DisplayManager::Inst()->isProjectorConnected() )
//        {
//            /*
//              Here the usecases have to be listed theoretically there are two
//              in this case. 2 Projectors, 1 projectors and on monitor. Only the
//              latter is asumed here.
//              */

//            // Remember which one is the projector
//            int ProjectorIndex;
//            DisplayManager::Inst()->getConnectedOutputs().at(0).isProjector()
//                    ? ProjectorIndex = 0 : ProjectorIndex = 0;

//            /*****************************************************************/
//            // If the beamer transmits reliable EDID data.
//            if( DisplayManager::Inst()->getConnectedOutputs().at(ProjectorIndex).hasEDID() )
//            {
//                // Now we can assume that the preferred mode of the projector to be correnct
//                // to be correct.

//                // Get the AR of the beamer
//                Resolution res;
//                if ( DisplayManager::Inst()->getConnectedOutputs().at(ProjectorIndex).getPreferredMode() )
//                    fprintf(stderr, "Beamer has EDID but no preferred mode.");

//                float AR = res.width/res.height;

//                QSet<RRMode> BeamerModes =
//                        DisplayManager::Inst()->getConnectedOutputs().at(ProjectorIndex).getSupportedModes();

//                QSet<RRMode> MonitorModes =
//                        DisplayManager::Inst()->getConnectedOutputs().at(1-ProjectorIndex).getSupportedModes();

//                QSet<RRMode>  CommonModes = BeamerModes.unite(MonitorModes);

//                CommonModes.intersect(BeamerModes);
//                CommonModes.intersect(MonitorModes);

//                // Fill treewidget with data from cups dests;
//                for ( QSet<RRMode>::iterator i = CommonModes.begin(); i != CommonModes.end(); ++i )
//                {
//                    char * ModeString;
//                    sprintf(ModeString, "%dx%d",
//                            DisplayManager::Inst()->getResolution(*i).width,
//                            DisplayManager::Inst()->getResolution(*i).height
//                            );

//                    qDebug() << ModeString;
//                    ui->comboBox->addItem(ModeString, QVariant((unsigned long long int)*i));
//                }
//            }
//            /*****************************************************************/
//            // If the beamer DOES NOT transmits reliable EDID data.
//            else
//            {
//                qDebug() << "beamer output no reliable EDID ";
//                configureWidgetForBeamerWithEDID();
//            }
//            /*****************************************************************/

//        }
//        /*********************************************************************/
//        // If NEITHER of the outputs is a beamer (likely dualscreen setup)
//        else
//        {
//            // Just apply preferred settings

//            qDebug() << "dualscreen output";

//        }
//        break;
//    /*************************************************************************/
//    default:
//        // If there are more than 3 outputs
//        // its up to the user. Quit.
//        exit(0);
//        break;
//    }
//    /*************************************************************************/






//        //Remove borders and stuff
//        setWindowFlags(windowFlags() | Qt::FramelessWindowHint);




//    //    QSet<RRMode> outputs0, outputs1;
//    //    for (int i = 0; i < XManager::Inst()->getOutputInfos()[0]->nmode; ++i)
//    //        outputs0.insert(XManager::Inst()->getOutputInfos()[0]->modes[i]);
//    //    for (int i = 0; i < XManager::Inst()->getOutputInfos()[1]->nmode; ++i)
//    //        outputs1.insert(XManager::Inst()->getOutputInfos()[1]->modes[i]);
//    //    outputs0.intersect(outputs1);

//    //    // Fill treewidget with data from cups dests;
//    //    for ( QSet<RRMode>::iterator it = outputs0.begin(); it != outputs0.end(); ++it )
//    //    {
//    //        qDebug() << *it;
//    //        qDebug() << XManager::Inst()->getModeMap()[*it];
//    //        ui->comboBox->addItem(XManager::Inst()->getModeMap().at(*it), (unsigned long long int)*it);
//    //    }

//    //    // Fill treewidget with data from cups dests;
//    //    for ( map<XID, char *>::iterator it = XManager::Inst()->getModeMap().begin(); it != XManager::Inst()->getModeMap().end(); ++it )
//    //    {
//    //        qDebug() << it->first ;
//    ////        qDebug() << XManager::getInstance()->getModeMap()[*it];
//    ////        ui->comboBox->addItem(XManager::getInstance()->getModeMap().at(*it), (unsigned long long int)*it);
//    //    }

//        // Resize widget to its content
//        resize(sizeHint());

//        // Center dialog on screenbottom
//        const QRect desktopRect = QApplication::desktop()->screenGeometry();
//        this->move( desktopRect.width()/2-this->width()/2,
//                    desktopRect.height()-this->height());
//    }

//    Widget::~Widget()
//    {
//        delete ui;
//    }

//    void Widget::configureWidgetForBeamerWithEDID()
//    {
//    }

//    void Widget::configureWidgetForBeamerWithOUTEDID()
//    {
//    }





   // eine andre datei






//Widget::Widget(QWidget *parent) :
//    QWidget(parent),
//    ui(new Ui::Widget)
//{
//    ui->setupUi(this);


//    X11::XManager * XM = X11::XManager::getInstance();


//   switch ( XM->getOutputInfos().size() ){
//   /*************************************************************************/
//   case 1:// In case of one connected output - xrandr --auto
//       qDebug() << "Normal output";
//       exit(0);
//       break;
//   /*************************************************************************/
//   case 2: // In case of two connected outputs

//       /*********************************************************************/
//       // If one of the two connected outputs is a beamer
//       if ( true ) //( XM->getOutputInfos()[0]->mm_width == 0 && XM->getOutputInfos()[0]->mm_height == 0 )
//              // || ( XM->getOutputInfos()[1]->mm_width == 0 && XM->getOutputInfos()[1]->mm_height == 0 ) )
//       {
//           /*****************************************************************/
//           // If the beamer transmits reliable EDID data.
//           if( isReliableEDIDpresent() )
//           {
//               qDebug() << "beamer output reliable EDID ";
//               configureWidgetForBeamerWithEDID();
//           }
//           /*****************************************************************/
//           // If the beamer DOES NOT transmits reliable EDID data.
//           else
//           {
//               qDebug() << "beamer output no reliable EDID ";
//               configureWidgetForBeamerWithEDID();
//           }
//           /*****************************************************************/

//       }
//       /*********************************************************************/
//       // If NEITHER of the outputs is a beamer (likely dualscreen setup)
//       else
//       {
//           // Just apply preferred settings
//           qDebug() << "dualscreen output";

//       }
//       break;
//   /*************************************************************************/
//   default:
//       // If there are more than 3 outputs
//       // its up to the user. Quit.
//       exit(0);
//       break;
//   }
//   /*************************************************************************/




//    Remove borders and stuff
//   setWindowFlags(windowFlags() | Qt::FramelessWindowHint);




//   QSet<RRMode> outputs0, outputs1;
//   for (int i = 0; i < XManager::Inst()->getOutputInfos()[0]->nmode; ++i)
//       outputs0.insert(XManager::Inst()->getOutputInfos()[0]->modes[i]);
//   for (int i = 0; i < XManager::Inst()->getOutputInfos()[1]->nmode; ++i)
//       outputs1.insert(XManager::Inst()->getOutputInfos()[1]->modes[i]);
//   outputs0.intersect(outputs1);

//   // Fill treewidget with data from cups dests;
//   for ( QSet<RRMode>::iterator it = outputs0.begin(); it != outputs0.end(); ++it )
//   {
//       qDebug() << *it;
//       qDebug() << XManager::Inst()->getModeMap()[*it];
//       ui->comboBox->addItem(XManager::Inst()->getModeMap().at(*it), (unsigned long long int)*it);
//   }

//   // Fill treewidget with data from cups dests;
//   for ( map<XID, char *>::iterator it = XManager::Inst()->getModeMap().begin(); it != XManager::Inst()->getModeMap().end(); ++it )
//   {
//       qDebug() << it->first ;
////        qDebug() << XManager::getInstance()->getModeMap()[*it];
////        ui->comboBox->addItem(XManager::getInstance()->getModeMap().at(*it), (unsigned long long int)*it);
//   }

//   // Resize widget to its content
//   resize(sizeHint());

//   // Center dialog on screenbottom
//   const QRect desktopRect = QApplication::desktop()->screenGeometry();
//   this->move( desktopRect.width()/2-this->width()/2,
//               desktopRect.height()-this->height());
//}