blob: 48e2bc3cb9d17a71f3815a08fda8bf010e5bfc62 [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 Lindblom06405c42013-01-17 20:48:39 -080034
35class ChronoShareGui : public QWidget
36{
37 Q_OBJECT
38
39public:
40 // constructor
Jared Lindblomb4032e22013-01-17 23:50:51 -080041 explicit ChronoShareGui(QWidget* parent = 0);
Jared Lindblom06405c42013-01-17 20:48:39 -080042
43 // destructor
44 ~ChronoShareGui();
Jared Lindblomb4032e22013-01-17 23:50:51 -080045
Jared Lindblom06405c42013-01-17 20:48:39 -080046private slots:
Jared Lindblomb4032e22013-01-17 23:50:51 -080047 // open the shared folder
48 void openSharedFolder();
49
50 // open file dialog
51 void openFileDialog();
52
Jared Lindblom06405c42013-01-17 20:48:39 -080053 // handle left click of tray icon
54 void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
55
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080056 // view chronoshare settings
57 void viewSettings();
58
Jared Lindblom06405c42013-01-17 20:48:39 -080059private:
60 // create actions that result from clicking a menu option
61 void createActions();
62
63 // create tray icon
64 void createTrayIcon();
65
66 // set icon image
67 void setIcon();
68
Jared Lindblomb4032e22013-01-17 23:50:51 -080069 // load persistent settings
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080070 bool loadSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -080071
72 // save persistent settings
73 void saveSettings();
74
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080075 // prompt user dialog box
76 void openMessageBox(QString title, QString text);
77
78 // overload
79 void openMessageBox(QString title, QString text, QString infotext);
80
Jared Lindblomb4032e22013-01-17 23:50:51 -080081 // capture close event
82 void closeEvent(QCloseEvent* event);
Jared Lindblom06405c42013-01-17 20:48:39 -080083
84private:
85 QSystemTrayIcon* m_trayIcon; // tray icon
86 QMenu* m_trayIconMenu; // tray icon menu
87
88 QAction* m_openFolder; // open the shared folder action
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080089 QAction* m_viewSettings; // chronoShare settings
Jared Lindblomb4032e22013-01-17 23:50:51 -080090 QAction* m_changeFolder; // change the shared folder action
Jared Lindblom06405c42013-01-17 20:48:39 -080091 QAction* m_quitProgram; // quit program action
92
93 QString m_dirPath; // shared directory
Jared Lindblomb4032e22013-01-17 23:50:51 -080094
95 QString m_settingsFilePath; // settings file path
Jared Lindblom06405c42013-01-17 20:48:39 -080096};
97
98#endif // CHRONOSHAREGUI_H