blob: b0d459e42b78ad3b42806557f2e614cd358aa26d [file] [log] [blame]
Jared Lindblom06405c42013-01-17 20:48:39 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012-2013 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Jared Lindblom <lindblom@cs.ucla.edu>
19 */
20
21#ifndef CHRONOSHAREGUI_H
22#define CHRONOSHAREGUI_H
23
24#include <QWidget>
25#include <QSystemTrayIcon>
26#include <QMenu>
Jared Lindblom06405c42013-01-17 20:48:39 -080027#include <QDebug>
28#include <QProcess>
Jared Lindblomb4032e22013-01-17 23:50:51 -080029#include <QSettings>
30#include <QDir>
31#include <QFileDialog>
32#include <QCloseEvent>
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080033#include <QMessageBox>
Jared Lindblom9d8a5b12013-01-20 15:21:17 -080034#include <QApplication>
Jared Lindblom06405c42013-01-17 20:48:39 -080035
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -080036#include "fs-watcher.h"
37
Jared Lindblom06405c42013-01-17 20:48:39 -080038class ChronoShareGui : public QWidget
39{
Alexander Afanasyev83a53002013-01-24 11:12:01 -080040 Q_OBJECT
Jared Lindblom06405c42013-01-17 20:48:39 -080041
Alexander Afanasyev83a53002013-01-24 11:12:01 -080042 public:
43 // constructor
44 explicit ChronoShareGui(QWidget* parent = 0);
45
46 // destructor
47 ~ChronoShareGui();
Jared Lindblomb4032e22013-01-17 23:50:51 -080048
Jared Lindblom06405c42013-01-17 20:48:39 -080049private slots:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080050 // open the shared folder
51 void openSharedFolder();
Jared Lindblomb4032e22013-01-17 23:50:51 -080052
Alexander Afanasyev83a53002013-01-24 11:12:01 -080053 // open file dialog
54 void openFileDialog();
Jared Lindblomb4032e22013-01-17 23:50:51 -080055
Alexander Afanasyev83a53002013-01-24 11:12:01 -080056 // handle left click of tray icon
57 void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
Jared Lindblom06405c42013-01-17 20:48:39 -080058
Alexander Afanasyev83a53002013-01-24 11:12:01 -080059 // view chronoshare settings
60 void viewSettings();
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080061
Jared Lindblom06405c42013-01-17 20:48:39 -080062private:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080063 // create actions that result from clicking a menu option
64 void createActions();
Jared Lindblom06405c42013-01-17 20:48:39 -080065
Alexander Afanasyev83a53002013-01-24 11:12:01 -080066 // create tray icon
67 void createTrayIcon();
Jared Lindblom06405c42013-01-17 20:48:39 -080068
Alexander Afanasyev83a53002013-01-24 11:12:01 -080069 // set icon image
70 void setIcon();
Jared Lindblom06405c42013-01-17 20:48:39 -080071
Alexander Afanasyev83a53002013-01-24 11:12:01 -080072 // load persistent settings
73 bool loadSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -080074
Alexander Afanasyev83a53002013-01-24 11:12:01 -080075 // save persistent settings
76 void saveSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -080077
Alexander Afanasyev83a53002013-01-24 11:12:01 -080078 // prompt user dialog box
79 void openMessageBox(QString title, QString text);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080080
Alexander Afanasyev83a53002013-01-24 11:12:01 -080081 // overload
82 void openMessageBox(QString title, QString text, QString infotext);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080083
Alexander Afanasyev83a53002013-01-24 11:12:01 -080084 // capture close event
85 void closeEvent(QCloseEvent* event);
Jared Lindblom06405c42013-01-17 20:48:39 -080086
87private:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080088 QSystemTrayIcon* m_trayIcon; // tray icon
89 QMenu* m_trayIconMenu; // tray icon menu
Jared Lindblom06405c42013-01-17 20:48:39 -080090
Alexander Afanasyev83a53002013-01-24 11:12:01 -080091 QAction* m_openFolder; // open the shared folder action
92 QAction* m_viewSettings; // chronoShare settings
93 QAction* m_changeFolder; // change the shared folder action
94 QAction* m_quitProgram; // quit program action
Jared Lindblom06405c42013-01-17 20:48:39 -080095
Alexander Afanasyev83a53002013-01-24 11:12:01 -080096 QString m_dirPath; // shared directory
Jared Lindblomb4032e22013-01-17 23:50:51 -080097
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -080098 FsWatcher *m_watcher;
Alexander Afanasyev83a53002013-01-24 11:12:01 -080099 // QString m_settingsFilePath; // settings file path
100 // QString m_settings;
Jared Lindblom06405c42013-01-17 20:48:39 -0800101};
102
103#endif // CHRONOSHAREGUI_H