blob: 994f3d1fe1062cf3ac0813bac9f7fdd39eb0d46c (
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
|
#include "widget.h"
#include "ui_widget.h"
#include <QString>
#include <QSet>
#include <algorithm>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
X::OutputList outputs = X::Screen::inst()->getConnectedOutputList();
switch ( X::Screen::inst()->getConnectedOutputList().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)
//X::Screen::inst()->getOutputMap()[outputs[0]]->isProjector()
// || X::Screen::inst()->getOutputMap()[outputs[1]]->isProjector() )
{
qDebug() << "Cloned output";
/*****************************************************************/
// If the beamer transmits no reliable EDID data add modes
if ( ! ( X::Screen::inst()->getOutputMap()[outputs[0]]->hasReliableEDID()
&& X::Screen::inst()->getOutputMap()[outputs[1]]->hasReliableEDID() ) )
{
// TODO ADD MODES
qDebug() << "Normal output";
}
// Get a set of unique modes as string. Ugly but same resolutions may
// have different ids. This means modes are compared by name which is
X::ModeSet ModeSet1 = X::Screen::inst()->getOutputMap()[outputs[0]]->getModeSet();
X::ModeSet ModeSet2 = X::Screen::inst()->getOutputMap()[outputs[1]]->getModeSet();
QSet<QString> ModeNames1, ModeNames2;
for (X::ModeSet::iterator i = ModeSet1.begin();
i != ModeSet1.end(); ++i)
ModeNames1.insert(X::Screen::inst()->getModeMap()[*i]._name);
for (X::ModeSet::iterator i = ModeSet2.begin();
i != ModeSet2.end(); ++i)
ModeNames2.insert(X::Screen::inst()->getModeMap()[*i]._name);
ModeNames1.intersect(ModeNames2);
// Fill widget with data
for ( QSet<QString>::iterator i = ModeNames1.begin(); i != ModeNames1.end(); ++i )
ui->comboBox->addItem(*i);
}
/*********************************************************************/
// If NEITHER of the outputs is a beamer (likely dualscreen setup)
else
{
// TODO(manuel): Furture feature. Setup dualscreen
qDebug() << "Dual output";
exit(0);
}
break;
/*************************************************************************/
default:
// If there are more than 3 outputs
// its up to the user. Quit.
qDebug() << ">2 outputs. Quit.";
exit(0);
break;
}
/*************************************************************************/
// Remove borders and stuff COMMENT FOR DEBUIGGIN
//setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
// 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;
}
|