This repository has been archived by the owner on Dec 4, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:pcbsd/pcbsd
- Loading branch information
Showing
7 changed files
with
329 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#include "LPMessages.h" | ||
#include "ui_LPMessages.h" | ||
|
||
LPMessages::LPMessages(QWidget *parent) : QDialog(parent), ui(new Ui::LPMessages){ | ||
ui->setupUi(this); | ||
logsAvailable=false; | ||
connect(ui->push_close, SIGNAL(clicked()), this, SLOT(closeDialog()) ); | ||
connect(ui->combo_logs, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChangeLog()) ); | ||
} | ||
|
||
LPMessages::~LPMessages(){ | ||
//no special cleanup | ||
} | ||
|
||
// ------------------------------ | ||
// PUBLIC FUNCTIONS | ||
// ------------------------------ | ||
void LPMessages::setMessages(QString msg){ | ||
if(msg.isEmpty()){ msg = tr("No recent messages"); } | ||
ui->label_messages->setText(msg); | ||
//Make sure that the messages tab is visible | ||
ui->tabWidget->setCurrentWidget(ui->tab_messages); | ||
} | ||
|
||
void LPMessages::setErrors(QString err){ | ||
ui->label_errors->setText(err); | ||
ui->label_errors->setVisible( !err.isEmpty() ); | ||
} | ||
|
||
void LPMessages::setLogFiles(QStringList logs){ | ||
ui->combo_logs->clear(); | ||
logsAvailable = !logs.isEmpty(); | ||
if(!logsAvailable){ logs << tr("No Log Files Available"); } | ||
ui->combo_logs->addItems(logs); | ||
ui->text_log->setVisible(logsAvailable); | ||
ui->combo_logs->setCurrentIndex(0); | ||
} | ||
|
||
// ------------------------------- | ||
// PRIVATE FUNCTIONS | ||
// ------------------------------- | ||
void LPMessages::displayLogFile(QString logFile){ | ||
QString msg = tr("(Life Preserver) No file contents to display"); | ||
//Read the log file if it exists | ||
QStringList contents; | ||
QFile file(logFile); | ||
if(!file.exists()){ contents << QString(tr("(Life Preserver) File does not exist: %1")).arg(logFile); } | ||
else{ | ||
if(file.open(QIODevice::ReadOnly | QIODevice::Text)){ | ||
QTextStream in(&file); | ||
while(!in.atEnd()){ | ||
contents << QString( in.readLine() ); | ||
} | ||
file.close(); | ||
}else{ | ||
contents << QString(tr("(Life Preserver) File could not be opened: %1")).arg(logFile); | ||
} | ||
} | ||
//Now put the contents into a single message | ||
if(!contents.isEmpty()){ msg = contents.join("\n"); } | ||
//display the contents of the file | ||
ui->text_log->setText(msg); | ||
} | ||
|
||
// ----------------------- | ||
// PRIVATE SLOTS | ||
// ----------------------- | ||
void LPMessages::slotChangeLog(){ | ||
qDebug() << "Change Visible Log File"; | ||
if(!logsAvailable){ return; } | ||
//Get the logfile path from the text | ||
QString logfile = ui->combo_logs->currentText().section("<",1,1,QString::SectionSkipEmpty).section(">",0,0); | ||
//Now run the function to display the file's contents | ||
displayLogFile(logfile); | ||
} | ||
|
||
void LPMessages::closeDialog(){ | ||
qDebug() << "Closing down the message dialog"; | ||
//no cleanup necessary for this dialog | ||
this->close(); | ||
} | ||
|
||
// ------------------ | ||
// PROTECTED | ||
// ------------------ | ||
void LPMessages::closeEvent(QCloseEvent *event){ | ||
//Make sure this window only gets hidden rather than closed | ||
// this prevents the entire tray application from closing down as well | ||
event->ignore(); | ||
this->hide(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#ifndef _LP_MESSAGES_H | ||
#define _LP_MESSAGES_H | ||
|
||
#include <QDialog> | ||
#include <QStringList> | ||
#include <QString> | ||
#include <QFile> | ||
#include <QTextStream> | ||
#include <QDebug> | ||
#include <QCloseEvent> | ||
|
||
namespace Ui{ | ||
class LPMessages; | ||
}; | ||
|
||
class LPMessages : public QDialog{ | ||
Q_OBJECT | ||
public: | ||
LPMessages(QWidget *parent=0); | ||
~LPMessages(); | ||
|
||
void setMessages(QString msg); | ||
void setErrors(QString err); | ||
void setLogFiles(QStringList logs); | ||
|
||
private: | ||
Ui::LPMessages *ui; | ||
bool logsAvailable; | ||
void displayLogFile(QString logfile); | ||
|
||
private slots: | ||
void slotChangeLog(); | ||
void closeDialog(); | ||
|
||
protected: | ||
void closeEvent(QCloseEvent*); | ||
|
||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>LPMessages</class> | ||
<widget class="QDialog" name="LPMessages"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>464</width> | ||
<height>207</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Life Preserver Messages</string> | ||
</property> | ||
<property name="windowIcon"> | ||
<iconset resource="lPreserve.qrc"> | ||
<normaloff>:/images/tray-icon-error.png</normaloff>:/images/tray-icon-error.png</iconset> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QTabWidget" name="tabWidget"> | ||
<property name="currentIndex"> | ||
<number>0</number> | ||
</property> | ||
<widget class="QWidget" name="tab_messages"> | ||
<attribute name="icon"> | ||
<iconset resource="lPreserve.qrc"> | ||
<normaloff>:/images/view.png</normaloff>:/images/view.png</iconset> | ||
</attribute> | ||
<attribute name="title"> | ||
<string>Messages</string> | ||
</attribute> | ||
<layout class="QVBoxLayout" name="verticalLayout_4"> | ||
<item> | ||
<widget class="QLabel" name="label_messages"> | ||
<property name="text"> | ||
<string notr="true">Normal Messages</string> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="label_errors"> | ||
<property name="styleSheet"> | ||
<string notr="true">background-color: rgba(220,10,10,70); border-radius: 5px;</string> | ||
</property> | ||
<property name="text"> | ||
<string notr="true">Error Messages</string> | ||
</property> | ||
<property name="wordWrap"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="verticalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>40</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</widget> | ||
<widget class="QWidget" name="tab_files"> | ||
<attribute name="icon"> | ||
<iconset resource="lPreserve.qrc"> | ||
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset> | ||
</attribute> | ||
<attribute name="title"> | ||
<string>Log Files</string> | ||
</attribute> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<widget class="QComboBox" name="combo_logs"> | ||
<property name="frame"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QTextEdit" name="text_log"> | ||
<property name="lineWrapMode"> | ||
<enum>QTextEdit::NoWrap</enum> | ||
</property> | ||
<property name="readOnly"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="verticalSpacer_2"> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>10</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</widget> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="push_close"> | ||
<property name="text"> | ||
<string>Close</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="lPreserve.qrc"> | ||
<normaloff>:/images/application-exit.png</normaloff>:/images/application-exit.png</iconset> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources> | ||
<include location="lPreserve.qrc"/> | ||
</resources> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.