Merge branch 'master' of git.irl.cs.ucla.edu:ndn/chronoshare
diff --git a/gui/ChronoShareGui.pro b/gui/ChronoShareGui.pro
new file mode 100644
index 0000000..e2cad8e
--- /dev/null
+++ b/gui/ChronoShareGui.pro
@@ -0,0 +1,23 @@
+#-------------------------------------------------
+#
+# Project created by QtCreator 2013-01-17T18:25:59
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = ChronoShareGui
+TEMPLATE = app
+
+
+SOURCES += main.cpp\
+ chronosharegui.cpp
+
+HEADERS += chronosharegui.h
+
+FORMS += chronosharegui.ui
+
+RESOURCES += \
+ images.qrc
diff --git a/gui/ChronoShareGui.pro.user b/gui/ChronoShareGui.pro.user
new file mode 100644
index 0000000..a40f863
--- /dev/null
+++ b/gui/ChronoShareGui.pro.user
@@ -0,0 +1,239 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE QtCreatorProject>
+<!-- Written by Qt Creator 2.6.0, 2013-01-18T00:57:47. -->
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
+ <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
+ <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
+ <value type="QString" key="language">Cpp</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QString" key="CurrentPreferences">CppGlobal</value>
+ </valuemap>
+ </valuemap>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
+ <value type="QString" key="language">QmlJS</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
+ </valuemap>
+ </valuemap>
+ <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
+ <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
+ <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
+ <value type="int" key="EditorConfiguration.IndentSize">4</value>
+ <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
+ <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
+ <value type="int" key="EditorConfiguration.PaddingMode">1</value>
+ <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
+ <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
+ <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
+ <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
+ <value type="int" key="EditorConfiguration.TabSize">8</value>
+ <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
+ <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
+ <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
+ <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
+ <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
+ <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.PluginSettings</variable>
+ <valuemap type="QVariantMap"/>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">{ec4ff4f3-f12d-4e42-870d-b8c64ad3c1a3}</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/Users/jared/Documents/Gui/Release</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory">/Users/jared/Documents/Gui/Debug</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
+ <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
+ <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
+ <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
+ <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
+ <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
+ <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
+ <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
+ <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
+ <value type="int">0</value>
+ <value type="int">1</value>
+ <value type="int">2</value>
+ <value type="int">3</value>
+ <value type="int">4</value>
+ <value type="int">5</value>
+ <value type="int">6</value>
+ <value type="int">7</value>
+ <value type="int">8</value>
+ <value type="int">9</value>
+ <value type="int">10</value>
+ <value type="int">11</value>
+ <value type="int">12</value>
+ <value type="int">13</value>
+ <value type="int">14</value>
+ </valuelist>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ChronoShareGui</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QByteArray" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/Users/jared/Documents/Gui/ChronoShareGui/ChronoShareGui.pro</value>
+ <value type="int" key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase">2</value>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">ChronoShareGui.pro</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
+ <valuelist type="QVariantList" key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
+ <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
+ <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
+ <value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
+ <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
+ <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
+ <value type="QString">{b042c0d4-4358-4d33-867e-7a86081b2fe9}</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">12</value>
+ </data>
+</qtcreator>
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
new file mode 100644
index 0000000..6faa80b
--- /dev/null
+++ b/gui/chronosharegui.cpp
@@ -0,0 +1,220 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Jared Lindblom <lindblom@cs.ucla.edu>
+ */
+
+#include "chronosharegui.h"
+#include "ui_chronosharegui.h"
+
+ChronoShareGui::ChronoShareGui(QWidget *parent) :
+ QWidget(parent),
+ m_settingsFilePath(QDir::homePath() + ".cronoShare")
+{
+ // load settings
+ if(!loadSettings())
+ {
+ // prompt user to choose folder
+ openMessageBox("First Time Setup", "Please select your shared folder location.");
+ openFileDialog();
+ }
+
+ // create actions that result from clicking a menu option
+ createActions();
+
+ // create tray icon
+ createTrayIcon();
+
+ // set icon image
+ setIcon();
+
+ // show tray icon
+ m_trayIcon->show();
+}
+
+ChronoShareGui::~ChronoShareGui()
+{
+ // cleanup
+ delete m_trayIcon;
+ delete m_trayIconMenu;
+ delete m_openFolder;
+ delete m_viewSettings;
+ delete m_changeFolder;
+ delete m_quitProgram;
+}
+
+void ChronoShareGui::openMessageBox(QString title, QString text)
+{
+ QMessageBox messageBox(this);
+ messageBox.setWindowTitle(title);
+ messageBox.setText(text);
+
+ messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png"));
+
+ messageBox.exec();
+}
+
+void ChronoShareGui::openMessageBox(QString title, QString text, QString infotext)
+{
+ QMessageBox messageBox(this);
+ messageBox.setWindowTitle(title);
+ messageBox.setText(text);
+ messageBox.setInformativeText(infotext);
+
+ messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png"));
+
+ messageBox.exec();
+}
+
+void ChronoShareGui::createActions()
+{
+ // create the "open folder" action
+ m_openFolder = new QAction(tr("&Open Folder"), this);
+ connect(m_openFolder, SIGNAL(triggered()), this, SLOT(openSharedFolder()));
+
+ // create the "view settings" action
+ m_viewSettings = new QAction(tr("&View Settings"), this);
+ connect(m_viewSettings, SIGNAL(triggered()), this, SLOT(viewSettings()));
+
+ // create the "change folder" action
+ m_changeFolder = new QAction(tr("&Change Folder"), this);
+ connect(m_changeFolder, SIGNAL(triggered()), this, SLOT(openFileDialog()));
+
+ // create the "quit program" action
+ m_quitProgram = new QAction(tr("&Quit"), this);
+ connect(m_quitProgram, SIGNAL(triggered()), qApp, SLOT(quit()));
+
+}
+
+void ChronoShareGui::createTrayIcon()
+{
+ // create a new icon menu
+ m_trayIconMenu = new QMenu(this);
+
+ // add actions to the menu
+ m_trayIconMenu->addAction(m_openFolder);
+ m_trayIconMenu->addSeparator();
+ m_trayIconMenu->addAction(m_viewSettings);
+ m_trayIconMenu->addAction(m_changeFolder);
+ m_trayIconMenu->addSeparator();
+ m_trayIconMenu->addAction(m_quitProgram);
+
+ // create new tray icon
+ m_trayIcon = new QSystemTrayIcon(this);
+
+ // associate the menu with the tray icon
+ m_trayIcon->setContextMenu(m_trayIconMenu);
+
+ // handle left click of icon
+ connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
+}
+
+void ChronoShareGui::setIcon()
+{
+ // set the icon image
+ m_trayIcon->setIcon(QIcon(":/images/friends-group-icon.png"));
+}
+
+void ChronoShareGui::openSharedFolder()
+{
+ // tell Finder to open the shared folder
+ QStringList scriptArgs;
+ scriptArgs << QLatin1String("-e")
+ << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
+ .arg(m_dirPath);
+
+ // execute the commands to make it happen
+ QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
+
+ // clear command arguments
+ scriptArgs.clear();
+
+ // tell Finder to appear
+ scriptArgs << QLatin1String("-e")
+ << QLatin1String("tell application \"Finder\" to activate");
+
+ // execute the commands to make it happen
+ QProcess::execute("/usr/bin/osascript", scriptArgs);
+}
+
+void ChronoShareGui::openFileDialog()
+{
+ // prompt user for new directory
+ QString tempPath = QFileDialog::getExistingDirectory(this, tr("Choose a new folder"),
+ m_dirPath, QFileDialog::ShowDirsOnly |
+ QFileDialog::DontResolveSymlinks);
+ QFileInfo qFileInfo(tempPath);
+
+ if(qFileInfo.isDir())
+ m_dirPath = tempPath;
+ else
+ openMessageBox("Error", "Not a valid folder, Ignoring.");
+
+ qDebug() << m_dirPath;
+ openMessageBox("Current Folder", "Current Shared Folder:\n" + m_dirPath, "You may change the folder by selecting \"change folder\" from the icon in the system tray.");
+
+ // save settings
+ saveSettings();
+}
+
+void ChronoShareGui::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
+{
+ // if double clicked, open shared folder
+ if(reason == QSystemTrayIcon::DoubleClick)
+ {
+ openSharedFolder();
+ }
+}
+
+void ChronoShareGui::viewSettings()
+{
+ // simple for now
+ openMessageBox("Chronoshare Settings", "CurrentFolder:\n" + m_dirPath);
+}
+
+bool ChronoShareGui::loadSettings()
+{
+ bool successful = false;
+
+ // Load Settings
+ QSettings settings(m_settingsFilePath, QSettings::NativeFormat);
+ if(settings.contains("dirPath"))
+ {
+ m_dirPath = settings.value("dirPath", QDir::homePath()).toString();
+ successful = true;
+ }
+ else
+ {
+ m_dirPath = QDir::homePath();
+ successful = false;
+ }
+
+ return successful;
+}
+
+void ChronoShareGui::saveSettings()
+{
+ // Save Settings
+ QSettings settings(m_settingsFilePath, QSettings::NativeFormat);
+ settings.setValue("dirPath", m_dirPath);
+}
+
+void ChronoShareGui::closeEvent(QCloseEvent* event)
+{
+ qDebug() << "Close Event.";
+ event->ignore(); // don't let the event propagate to the base class
+}
diff --git a/gui/chronosharegui.h b/gui/chronosharegui.h
new file mode 100644
index 0000000..48e2bc3
--- /dev/null
+++ b/gui/chronosharegui.h
@@ -0,0 +1,98 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Jared Lindblom <lindblom@cs.ucla.edu>
+ */
+
+#ifndef CHRONOSHAREGUI_H
+#define CHRONOSHAREGUI_H
+
+#include <QWidget>
+#include <QSystemTrayIcon>
+#include <QMenu>
+#include <QDebug>
+#include <QProcess>
+#include <QSettings>
+#include <QDir>
+#include <QFileDialog>
+#include <QCloseEvent>
+#include <QMessageBox>
+
+class ChronoShareGui : public QWidget
+{
+ Q_OBJECT
+
+public:
+ // constructor
+ explicit ChronoShareGui(QWidget* parent = 0);
+
+ // destructor
+ ~ChronoShareGui();
+
+private slots:
+ // open the shared folder
+ void openSharedFolder();
+
+ // open file dialog
+ void openFileDialog();
+
+ // handle left click of tray icon
+ void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
+
+ // view chronoshare settings
+ void viewSettings();
+
+private:
+ // create actions that result from clicking a menu option
+ void createActions();
+
+ // create tray icon
+ void createTrayIcon();
+
+ // set icon image
+ void setIcon();
+
+ // load persistent settings
+ bool loadSettings();
+
+ // save persistent settings
+ void saveSettings();
+
+ // prompt user dialog box
+ void openMessageBox(QString title, QString text);
+
+ // overload
+ void openMessageBox(QString title, QString text, QString infotext);
+
+ // capture close event
+ void closeEvent(QCloseEvent* event);
+
+private:
+ QSystemTrayIcon* m_trayIcon; // tray icon
+ QMenu* m_trayIconMenu; // tray icon menu
+
+ QAction* m_openFolder; // open the shared folder action
+ QAction* m_viewSettings; // chronoShare settings
+ QAction* m_changeFolder; // change the shared folder action
+ QAction* m_quitProgram; // quit program action
+
+ QString m_dirPath; // shared directory
+
+ QString m_settingsFilePath; // settings file path
+};
+
+#endif // CHRONOSHAREGUI_H
diff --git a/gui/chronosharegui.ui b/gui/chronosharegui.ui
new file mode 100644
index 0000000..685ec22
--- /dev/null
+++ b/gui/chronosharegui.ui
@@ -0,0 +1,20 @@
+<ui version="4.0">
+ <class>ChronoShareGui</class>
+ <widget class="QWidget" name="ChronoShareGui" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>ChronoShareGui</string>
+ </property>
+ </widget>
+ <layoutDefault spacing="6" margin="11" />
+ <pixmapfunction></pixmapfunction>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/gui/friends-group-icon.png b/gui/friends-group-icon.png
new file mode 100644
index 0000000..a6ae00c
--- /dev/null
+++ b/gui/friends-group-icon.png
Binary files differ
diff --git a/gui/images.qrc b/gui/images.qrc
new file mode 100644
index 0000000..15d4acf
--- /dev/null
+++ b/gui/images.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/images">
+ <file>friends-group-icon.png</file>
+ </qresource>
+</RCC>
diff --git a/gui/main.cpp b/gui/main.cpp
new file mode 100644
index 0000000..0b9a176
--- /dev/null
+++ b/gui/main.cpp
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Jared Lindblom <lindblom@cs.ucla.edu>
+ */
+
+#include "chronosharegui.h"
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ // do not quit when last window closes
+ app.setQuitOnLastWindowClosed(false);
+
+ // invoke gui
+ ChronoShareGui gui;
+
+ return app.exec();
+}