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

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 1620346 was 1620346, checked in by Kris Moore <kris@…>, 17 months ago

Initial import of PC-BSD /current/ SVN repo

  • Property mode set to 100644
File size: 2.5 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    exit(0);
77}
78
79
80void dialogConfirm::slotNo()
81{
82    exit(1);
83}
84
85
86void dialogConfirm::checkTime()
87{
88    timeLeft--;
89    if ( timeLeft <= 0 )
90    {
91        exit(1);
92    }
93    QString tmp;
94    tmp.setNum(timeLeft);
95    textAutoClose->setText(tr("Auto-close in ") + tmp + tr(" seconds...") );
96     QTimer::singleShot( 1000, this, SLOT(checkTime()) );
97}
Note: See TracBrowser for help on using the repository browser.