summaryrefslogtreecommitdiffstats
path: root/oldsrc/widget.cpp
blob: 7867f9255760e93a778cb8744687e273d4ec3521 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include "widget.h"
#include "ui_widget.h"
#include "displaymanager.h"


//#include <QString>
//#include <QSet>
//#include <QDebug>
#include <vector>
using namespace std;

#include <algorithm>

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

    DisplayManager* DM = DisplayManager::Inst();

    for (std::vector<Output>::iterator i = DM->getConnectedOutputs().begin(); i != DM->getConnectedOutputs().end(); ++i)
    {
        qDebug() << "EDID?" << ( (*i).hasEDID() ? "true" :  "false");
        qDebug() << "Proj?" << ( (*i).isProjector() ? "true" :  "false");
        qDebug() << "Current?" <<  (*i).getCurrentMode().width<< (*i).getCurrentMode().height;
        qDebug() << "Preferred?" <<   (*i).getPreferredMode().width << (*i).getPreferredMode().height;
        QSet<Resolution> modes =   (*i).getSupportedModes();
        for ( QSet<Resolution>::iterator i = modes.begin(); i != modes.end(); ++i )
        {
            qDebug() << "---- " << (*i).width << (*i).height;
        }
    }





//    XManager * XM = XManager::Inst();


//    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());
    }

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

    void Widget::configureWidgetForBeamerWithEDID()
    {
    }

    void Widget::configureWidgetForBeamerWithOUTEDID()
    {
    }