From 21aa80032f685b3ded10fe293ca083d2f46ae18c Mon Sep 17 00:00:00 2001 From: Manuel Schneider Date: Thu, 21 Nov 2013 15:38:19 +0100 Subject: alpha --- src/widget.cpp | 201 ++++++++++++++++++++++----------------------------------- 1 file changed, 77 insertions(+), 124 deletions(-) (limited to 'src/widget.cpp') diff --git a/src/widget.cpp b/src/widget.cpp index 7867f92..994f3d1 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -1,145 +1,98 @@ #include "widget.h" #include "ui_widget.h" -#include "displaymanager.h" - - -//#include -//#include -//#include -#include -using namespace std; +#include +#include #include + Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { - ui->setupUi(this); - - DisplayManager* DM = DisplayManager::Inst(); - - for (std::vector::iterator i = DM->getConnectedOutputs().begin(); i != DM->getConnectedOutputs().end(); ++i) + 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() << "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 modes = (*i).getSupportedModes(); - for ( QSet::iterator i = modes.begin(); i != modes.end(); ++i ) - { - qDebug() << "---- " << (*i).width << (*i).height; - } + 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 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::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; + } + /*************************************************************************/ -// 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 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::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::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()); - } + // Remove borders and stuff COMMENT FOR DEBUIGGIN + //setWindowFlags(windowFlags() | Qt::FramelessWindowHint); - Widget::~Widget() - { - delete ui; - } + // Resize widget to its content + resize(sizeHint()); - void Widget::configureWidgetForBeamerWithEDID() - { - } + // Center dialog on screenbottom + const QRect desktopRect = QApplication::desktop()->screenGeometry(); + this->move( desktopRect.width()/2-this->width()/2, + desktopRect.height()-this->height()); +} - void Widget::configureWidgetForBeamerWithOUTEDID() - { - } +Widget::~Widget() +{ + delete ui; +} -- cgit v1.2.3-55-g7522