source: src-qt4/pc-bugreport/toolbox.cpp @ a238837

releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since a238837 was a238837, checked in by Ken Moore <ken@…>, 7 months ago

Add the diagnostic sheet generation functionality to pc-bugreport

  • Property mode set to 100644
File size: 2.8 KB
Line 
1#include "toolbox.h"
2#include "ui_toolbox.h"
3#include "showinfodialog.h"
4
5#include <QFile>
6#include <QDir>
7#include <QProcess>
8#include <QDate>
9
10#define PREFIX "/usr/local/"
11static const QString KSANPSHOT_FILE(PREFIX"bin/ksnapshot");
12static const QString GNOME_PANEL_SCREENSHOT_FILE(PREFIX"bin/gnome-panel-screenshot");
13
14Toolbox::Toolbox(QWidget *parent) :
15    QWidget(parent),
16    ui(new Ui::Toolbox)
17{
18    ui->setupUi(this);
19
20        ui->LogsButton->addAction(ui->actionDiagnostic_report);
21        ui->LogsButton->addAction(ui->actionUname);
22        ui->LogsButton->addAction(ui->actionDmesg);
23        ui->LogsButton->addAction(ui->actionXorg_version);
24        ui->LogsButton->addAction(ui->actionXorg_log_file);
25
26        ui->HardwareButton->addAction(ui->actionPCIConf);
27
28        // Setup screenshot button. Check for present screenshot tools
29        ui->ScreenshotButton->setVisible(false);
30        if (QFile::exists(KSANPSHOT_FILE))
31        {
32                mScreenshotCommand= KSANPSHOT_FILE;
33                ui->ScreenshotButton->setVisible(true);
34        }
35        else if (QFile::exists(GNOME_PANEL_SCREENSHOT_FILE))
36        {
37                mScreenshotCommand= GNOME_PANEL_SCREENSHOT_FILE;
38                ui->ScreenshotButton->setVisible(true);
39        }
40}
41
42Toolbox::~Toolbox()
43{
44    delete ui;
45}
46
47void Toolbox::changeEvent(QEvent *e)
48{
49    QWidget::changeEvent(e);
50    switch (e->type()) {
51    case QEvent::LanguageChange:
52        ui->retranslateUi(this);
53        break;
54    default:
55        break;
56    }
57}
58
59void Toolbox::on_actionXorg_log_file_triggered()
60{
61        ShowInfoDialog* dlg = new ShowInfoDialog(this);
62        dlg->show(QString("/var/log/Xorg.0.log"));
63}
64
65void Toolbox::on_actionDmesg_triggered()
66{
67        ShowInfoDialog* dlg = new ShowInfoDialog(this);
68        dlg->show("dmesg", QStringList());
69}
70
71void Toolbox::on_actionDiagnostic_report_triggered()
72{
73        //Generate the diagnostic file on the user desktop
74        QString filename = QDir::homePath()+"/Desktop/diagnostic-"+QDate::currentDate().toString("yyyyMMdd")+".txt";
75        QString username = getenv("LOGNAME");
76        QString cmd = "/usr/local/share/pcbsd/scripts/GetDiagSheet.sh "+filename+" "+username;
77        QProcess p;
78        p.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
79        p.start(cmd);
80        while(p.waitForFinished(200)){
81          QApplication::processEvents();
82        }
83        //Now show the info dialog for the newly generated diagnostic file
84        ShowInfoDialog *dlg = new ShowInfoDialog(this);
85        dlg->show(filename);
86       
87}
88
89void Toolbox::on_actionPCIConf_triggered()
90{
91        ShowInfoDialog* dlg = new ShowInfoDialog(this);
92        dlg->show("pciconf", QStringList()<<"-l"<<"-v");
93}
94
95void Toolbox::on_ScreenshotButton_clicked()
96{
97        if (mScreenshotCommand.length())
98        {
99                QProcess proc;
100                proc.startDetached(mScreenshotCommand);
101        }
102}
103
104void Toolbox::on_actionXorg_version_triggered()
105{
106        ShowInfoDialog* dlg = new ShowInfoDialog(this);
107        dlg->show("Xorg", QStringList()<<"-version");
108}
109
110void Toolbox::on_actionUname_triggered()
111{
112        ShowInfoDialog* dlg = new ShowInfoDialog(this);
113        dlg->show("uname", QStringList()<<"-a");
114}
Note: See TracBrowser for help on using the repository browser.