Permalink
Browse files

Add a completely working life-preserver-tray application.

This will be the first part of the "life-preserver" application chain, and is started as a normal user (not root).
  • Loading branch information...
1 parent 0ab0f41 commit 06d440136e53c982de83702f8a285dac93bab6ca Ken Moore committed Oct 3, 2013
Showing with 17,291 additions and 0 deletions.
  1. +95 −0 lp-tray/LPMessages.cpp
  2. +38 −0 lp-tray/LPMessages.h
  3. +150 −0 lp-tray/LPMessages.ui
  4. +165 −0 lp-tray/LPTray.cpp
  5. +37 −0 lp-tray/LPTray.h
  6. +522 −0 lp-tray/LPWatcher.cpp
  7. +66 −0 lp-tray/LPWatcher.h
  8. +308 −0 lp-tray/Makefile
  9. +237 −0 lp-tray/i18n/LifePreserverTray_af.ts
  10. +237 −0 lp-tray/i18n/LifePreserverTray_ar.ts
  11. +237 −0 lp-tray/i18n/LifePreserverTray_az.ts
  12. +237 −0 lp-tray/i18n/LifePreserverTray_bg.ts
  13. +237 −0 lp-tray/i18n/LifePreserverTray_bn.ts
  14. +237 −0 lp-tray/i18n/LifePreserverTray_bs.ts
  15. +237 −0 lp-tray/i18n/LifePreserverTray_ca.ts
  16. +237 −0 lp-tray/i18n/LifePreserverTray_cs.ts
  17. +237 −0 lp-tray/i18n/LifePreserverTray_cy.ts
  18. +237 −0 lp-tray/i18n/LifePreserverTray_da.ts
  19. +237 −0 lp-tray/i18n/LifePreserverTray_de.ts
  20. +237 −0 lp-tray/i18n/LifePreserverTray_el.ts
  21. +237 −0 lp-tray/i18n/LifePreserverTray_en_GB.ts
  22. +237 −0 lp-tray/i18n/LifePreserverTray_en_US.ts
  23. +237 −0 lp-tray/i18n/LifePreserverTray_en_ZA.ts
  24. +237 −0 lp-tray/i18n/LifePreserverTray_es.ts
  25. +237 −0 lp-tray/i18n/LifePreserverTray_et.ts
  26. +237 −0 lp-tray/i18n/LifePreserverTray_eu.ts
  27. +237 −0 lp-tray/i18n/LifePreserverTray_fa.ts
  28. +237 −0 lp-tray/i18n/LifePreserverTray_fi.ts
  29. +237 −0 lp-tray/i18n/LifePreserverTray_fr.ts
  30. +237 −0 lp-tray/i18n/LifePreserverTray_fr_CA.ts
  31. +237 −0 lp-tray/i18n/LifePreserverTray_fur.ts
  32. +237 −0 lp-tray/i18n/LifePreserverTray_gl.ts
  33. +237 −0 lp-tray/i18n/LifePreserverTray_he.ts
  34. +237 −0 lp-tray/i18n/LifePreserverTray_hi.ts
  35. +237 −0 lp-tray/i18n/LifePreserverTray_hr.ts
  36. +237 −0 lp-tray/i18n/LifePreserverTray_hu.ts
  37. +237 −0 lp-tray/i18n/LifePreserverTray_id.ts
  38. +237 −0 lp-tray/i18n/LifePreserverTray_is.ts
  39. +237 −0 lp-tray/i18n/LifePreserverTray_it.ts
  40. +237 −0 lp-tray/i18n/LifePreserverTray_ja.ts
  41. +237 −0 lp-tray/i18n/LifePreserverTray_ka.ts
  42. +237 −0 lp-tray/i18n/LifePreserverTray_ko.ts
  43. +237 −0 lp-tray/i18n/LifePreserverTray_lt.ts
  44. +237 −0 lp-tray/i18n/LifePreserverTray_lv.ts
  45. +237 −0 lp-tray/i18n/LifePreserverTray_mk.ts
  46. +237 −0 lp-tray/i18n/LifePreserverTray_mn.ts
  47. +237 −0 lp-tray/i18n/LifePreserverTray_ms.ts
  48. +237 −0 lp-tray/i18n/LifePreserverTray_mt.ts
  49. +237 −0 lp-tray/i18n/LifePreserverTray_nb.ts
  50. +237 −0 lp-tray/i18n/LifePreserverTray_ne.ts
  51. +237 −0 lp-tray/i18n/LifePreserverTray_nl.ts
  52. +237 −0 lp-tray/i18n/LifePreserverTray_pa.ts
  53. +237 −0 lp-tray/i18n/LifePreserverTray_pl.ts
  54. +237 −0 lp-tray/i18n/LifePreserverTray_pt.ts
  55. +237 −0 lp-tray/i18n/LifePreserverTray_pt_BR.ts
  56. +237 −0 lp-tray/i18n/LifePreserverTray_ro.ts
  57. +237 −0 lp-tray/i18n/LifePreserverTray_ru.ts
  58. +237 −0 lp-tray/i18n/LifePreserverTray_sa.ts
  59. +237 −0 lp-tray/i18n/LifePreserverTray_sk.ts
  60. +237 −0 lp-tray/i18n/LifePreserverTray_sl.ts
  61. +237 −0 lp-tray/i18n/LifePreserverTray_sr.ts
  62. +237 −0 lp-tray/i18n/LifePreserverTray_sv.ts
  63. +237 −0 lp-tray/i18n/LifePreserverTray_sw.ts
  64. +237 −0 lp-tray/i18n/LifePreserverTray_ta.ts
  65. +237 −0 lp-tray/i18n/LifePreserverTray_tg.ts
  66. +237 −0 lp-tray/i18n/LifePreserverTray_th.ts
  67. +237 −0 lp-tray/i18n/LifePreserverTray_tr.ts
  68. +237 −0 lp-tray/i18n/LifePreserverTray_uk.ts
  69. +237 −0 lp-tray/i18n/LifePreserverTray_uz.ts
  70. +237 −0 lp-tray/i18n/LifePreserverTray_vi.ts
  71. +237 −0 lp-tray/i18n/LifePreserverTray_zh_CN.ts
  72. +237 −0 lp-tray/i18n/LifePreserverTray_zh_HK.ts
  73. +237 −0 lp-tray/i18n/LifePreserverTray_zh_TW.ts
  74. +237 −0 lp-tray/i18n/LifePreserverTray_zu.ts
  75. +4 −0 lp-tray/images/.directory
  76. BIN lp-tray/images/application-exit.png
  77. BIN lp-tray/images/backup-failed.png
  78. BIN lp-tray/images/backup-ok.png
  79. BIN lp-tray/images/configure.png
  80. BIN lp-tray/images/lifepreserver.png
  81. BIN lp-tray/images/list-add.png
  82. BIN lp-tray/images/list-remove.png
  83. BIN lp-tray/images/tray-icon-error.png
  84. BIN lp-tray/images/tray-icon-failed.png
  85. BIN lp-tray/images/tray-icon-idle.png
  86. BIN lp-tray/images/tray-icon-working.png
  87. +15 −0 lp-tray/lPreserve.qrc
  88. +102 −0 lp-tray/lifepreserver.desktop
  89. +105 −0 lp-tray/lp-tray.pro
  90. +42 −0 lp-tray/main.cpp
View
@@ -0,0 +1,95 @@
+#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, QString err){
+ //standard messages
+ if(msg.isEmpty()){ ui->label_messages->setText(tr("No recent messages")); }
+ else{ ui->label_messages->setText(msg); }
+ //error messages
+ ui->label_errors->setText(err);
+ if(msg.isEmpty() && !err.isEmpty()){
+ ui->label_messages->setVisible(false);
+ }else{
+ ui->label_messages->setVisible(true);
+ }
+ ui->label_errors->setVisible( !err.isEmpty() );
+ //Make sure that the messages tab is visible
+ ui->tabWidget->setCurrentWidget(ui->tab_messages);
+}
+
+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();
+}
View
@@ -0,0 +1,38 @@
+#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, 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
View
@@ -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>
Oops, something went wrong.

0 comments on commit 06d4401

Please sign in to comment.