summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2017-12-15 14:12:44 +0100
committerSimon Rettberg2017-12-15 14:12:44 +0100
commit024855948c923bd40ffaf526c1300dd8c0377698 (patch)
treea737e0a84e0b9f817bd67819f4bbaa39720a09cb /src
parentOLDSRC WEG! (diff)
downloadbeamergui-024855948c923bd40ffaf526c1300dd8c0377698.tar.gz
beamergui-024855948c923bd40ffaf526c1300dd8c0377698.tar.xz
beamergui-024855948c923bd40ffaf526c1300dd8c0377698.zip
Update to CMAKE, fix timeout dialog on Qt5, fix menu getting covered by window
Diffstat (limited to 'src')
-rw-r--r--src/beamergui.pro25
-rw-r--r--src/main.cpp2
-rw-r--r--src/timeoutdialog.cpp3
-rw-r--r--src/timeoutdialog.h1
-rw-r--r--src/widget.cpp35
-rw-r--r--src/widget.ui2
-rw-r--r--src/x.cpp2
-rw-r--r--src/x.h6
8 files changed, 31 insertions, 45 deletions
diff --git a/src/beamergui.pro b/src/beamergui.pro
deleted file mode 100644
index 1b9ee2a..0000000
--- a/src/beamergui.pro
+++ /dev/null
@@ -1,25 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2013-10-14T14:24:40
-#
-#-------------------------------------------------
-
-
-QT += core gui # qt4
-QT += widgets # qt5
-
-TARGET = beamergui
-TEMPLATE = app
-
-SOURCES += main.cpp\
- widget.cpp \
- timeoutdialog.cpp
-
-HEADERS += widget.h \
- timeoutdialog.h
-
-FORMS += widget.ui
-
-LIBS += -lXrandr -lX11
-
-RESOURCES +=
diff --git a/src/main.cpp b/src/main.cpp
index 8f90cd7..7ae6558 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,7 +1,7 @@
// Copyright 2013, University of Freiburg,
// Author: Manuel Schneider <ms1144>
-#include <QtWidgets/QApplication> // for Qt4
+#include <QtWidgets/QApplication> // for Qt5
#include "widget.h"
int main(int argc, char *argv[])
diff --git a/src/timeoutdialog.cpp b/src/timeoutdialog.cpp
index 719fddd..418d791 100644
--- a/src/timeoutdialog.cpp
+++ b/src/timeoutdialog.cpp
@@ -13,11 +13,10 @@ TimeOutDialog::TimeOutDialog(int time, QWidget *parent)
// QProgressDialog takes ownership of QProgressBar
QProgressBar *qbar = new QProgressBar(this);
- qbar->setFormat("%v seconds");
+ qbar->setFormat(trUtf8("%v seconds"));
qbar->setMaximum(_time);
qbar->setMinimum(0);
qbar->setValue(_time);
- qbar->setLayoutDirection(Qt::RightToLeft);
setBar(qbar);
_timer.start(1000);
}
diff --git a/src/timeoutdialog.h b/src/timeoutdialog.h
index 4961e6f..eb0f969 100644
--- a/src/timeoutdialog.h
+++ b/src/timeoutdialog.h
@@ -13,6 +13,7 @@ class TimeOutDialog : public QProgressDialog
public:
TimeOutDialog(int time, QWidget *parent = 0);
+ bool isActive() const { return _timer.isActive(); }
private:
int _time;
diff --git a/src/widget.cpp b/src/widget.cpp
index b3a559f..887249f 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -244,6 +244,7 @@ Widget::Widget(QWidget *parent) :
void Widget::bringToTopTimer()
{
+ if (_ui->comboBox->isVisible()) return;
raise();
}
@@ -346,8 +347,9 @@ void Widget::handleButton(){
// First disconnect all crts to avoid conflicts
for(CrtcMap::iterator it = _crtcMap.begin(); it != _crtcMap.end(); ++it) {
- XRRSetCrtcConfig(_display, _screenResources, it.key(), CurrentTime,
+ Status st = XRRSetCrtcConfig(_display, _screenResources, it.key(), CurrentTime,
0, 0, None, RR_Rotate_0, NULL, 0);
+ qDebug() << "Disconnecting" << it.key() << ":" << st;
}
// Set screensize
@@ -357,27 +359,28 @@ void Widget::handleButton(){
25.4 * monitorMode->height / 96); // standard dpi that X uses
// Apply the modes
- XRRSetCrtcConfig(_display,
- _screenResources,
+ Status stMon = XRRSetCrtcConfig(_display,
+ _screenResources,
_outputMap[_monitor]->crtc,
CurrentTime,
0, 0, monitorMode->id,
RR_Rotate_0,
&_monitor, 1);
- XRRSetCrtcConfig(_display,
+ Status stBem = XRRSetCrtcConfig(_display,
_screenResources,
_outputMap[_beamer]->crtc,
CurrentTime,
0, 0, beamerMode->id,
RR_Rotate_0,
- &_beamer, 1);
+ &_beamer, 1);
// Sync... whatever...
XSync (_display, False);
+ qDebug() << "Monitor set:" << stMon << ", beamer set: " << stBem;
// Center widget on screenbottom
this->move( monitorMode->width/2 - this->width()/2,
- monitorMode->height - this->height());
+ monitorMode->height - this->height() );
// Set the mouse pointer in the middle of the screen
QCursor::setPos(monitorMode->width/2, monitorMode->height/2);
@@ -385,16 +388,22 @@ void Widget::handleButton(){
/*************************** ASK for confirmtion ****************************/
// Show a dialog asking if the res should be kept
- TimeOutDialog *keepDialog = new TimeOutDialog(15, this);
- keepDialog->setWindowTitle(" ");
- keepDialog->setLabelText("Do you want to keep this resolution?");
- keepDialog->setCancelButtonText("Keep");
- keepDialog->move(monitorMode->width/2 - this->width()/2,
+ TimeOutDialog keepDialog(15, this);
+ keepDialog.setWindowModality(Qt::ApplicationModal);
+ keepDialog.setWindowTitle(" ");
+ keepDialog.setLabelText(trUtf8("Do you want to keep this resolution?"));
+ keepDialog.setCancelButtonText(trUtf8("Keep"));
+ keepDialog.move(monitorMode->width/2 - this->width()/2,
monitorMode->height/2 - this->height());
- keepDialog->exec();
+ keepDialog.show();
+
+ while (keepDialog.isActive()) {
+ QCoreApplication::processEvents();
+ }
// If the dialog was not canceled revert the resolution
- if ( ! keepDialog->wasCanceled()) {
+ if ( !keepDialog.wasCanceled()) {
+ qDebug() << "User did not cancel timeout, reverting!";
/**************************** Apply the backup ****************************/
diff --git a/src/widget.ui b/src/widget.ui
index 3755397..6086eae 100644
--- a/src/widget.ui
+++ b/src/widget.ui
@@ -25,7 +25,7 @@
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
- <string>Anwenden</string>
+ <string>Apply</string>
</property>
</widget>
</item>
diff --git a/src/x.cpp b/src/x.cpp
index 82c07fc..e0aa12f 100644
--- a/src/x.cpp
+++ b/src/x.cpp
@@ -192,7 +192,7 @@ namespace X
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
- Crtc::Crtc(XID id = None, Screen * parent = NULL)
+ Crtc::Crtc(XID id, Screen * parent)
: XElement(id), _parent(parent)
{
// Get the information from XRROutputInfo
diff --git a/src/x.h b/src/x.h
index 855a05c..4ca54a1 100644
--- a/src/x.h
+++ b/src/x.h
@@ -87,8 +87,9 @@ namespace X
///////////////////////////////////////////////////////////////////////////
- struct XElement
+ class XElement
{
+ public:
XElement(XID = 0);
XID _id;
bool _validity;
@@ -100,8 +101,9 @@ namespace X
///////////////////////////////////////////////////////////////////////////
- struct Mode : public XElement
+ class Mode : public XElement
{
+ public:
Mode(XRRModeInfo* = NULL);
// Xlib internal stuff