source: src-qt4/pc-xgui/dialogconfirm.cpp @ 6f68384

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 6f68384 was 6f68384, checked in by Kris Moore <kris@…>, 11 months ago

When we confirm that we want a resolution, remove the trigger file automatically

This well help some cases with Intel chips, where it crashes at Xorg close, so at least
at next bootup they will move into the desktop or next wizard.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/****************************************************************************
2** ui.h extension file, included from the uic-generated form implementation.
3**
4** If you want to add, delete, or rename functions or slots, use
5** Qt Designer to update this file, preserving your code.
6**
7** You should not define a constructor or destructor in this file.
8** Instead, write your code in functions called init() and destroy().
9** These will automatically be called by the form's constructor and
10** destructor.
11*****************************************************************************/
12#include <QFileInfo>
13#include <QProcess>
14#include <QTextStream>
15#include "dialogconfirm.h"
16
17
18void dialogConfirm::ProgramInit(QString txt, bool ac, bool yesno) 
19{
20   labelText->setText(txt);
21 
22   if ( ! yesno ) {
23     pushNo->setEnabled(false);
24     pushNo->setVisible(false);
25     pushYes->setText(tr("&Ok"));
26   } else {
27
28     // If we are not auto-closing, Display the X resolution
29     if ( ! ac ) {
30       QString tmp, res, driver;
31       QProcess d;
32       d.start(QString("xdpyinfo"), QStringList());
33       while(d.state() == QProcess::Starting || d.state() == QProcess::Running) {
34          d.waitForFinished(200);
35          QCoreApplication::processEvents();
36       }
37
38       while (d.canReadLine()) {
39         tmp = d.readLine().simplified();
40         if ( tmp.indexOf("dimensions:") != -1 ) {
41           res = tmp.section(" ", 1, 1);
42           break;
43         }
44       }
45
46       // Figure out the driver
47       QFile file("/var/log/Xorg.0.log");
48       if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
49         QTextStream in(&file);
50         while (!in.atEnd()) {
51            QString line = in.readLine();
52            if ( line.indexOf("Loading /usr/local/lib/xorg/modules/drivers/") != -1 ) {
53               QFileInfo fi(line);
54               driver = fi.fileName();
55               driver = driver.section("_", 0, 0);
56               break;
57            } 
58         }
59         file.close();
60       }
61
62       textAutoClose->setText(tr("Resolution:") + " " + res + "\n" + tr("Driver:") + " " + driver  );
63     }
64   }
65
66   if ( ac ) {
67     timeLeft = 10;
68     textAutoClose->setText(tr("Auto-close in 10 seconds...") );
69     QTimer::singleShot( 2000, this, SLOT(checkTime()) );
70   }
71}
72
73
74void dialogConfirm::slotYes()
75{
76    system("rm /var/.runxsetup 2>/dev/null");
77    system("sync");
78    exit(0);
79}
80
81
82void dialogConfirm::slotNo()
83{
84    exit(1);
85}
86
87
88void dialogConfirm::checkTime()
89{
90    timeLeft--;
91    if ( timeLeft <= 0 )
92    {
93        exit(1);
94    }
95    QString tmp;
96    tmp.setNum(timeLeft);
97    textAutoClose->setText(tr("Auto-close in ") + tmp + tr(" seconds...") );
98     QTimer::singleShot( 1000, this, SLOT(checkTime()) );
99}
Note: See TracBrowser for help on using the repository browser.