blob: c1ae9b2c186f477db2f05c8eba3fcbff06a56488 [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 Lindblom06405c42013-01-17 20:48:39 -080033
34class ChronoShareGui : public QWidget
35{
36 Q_OBJECT
37
38public:
39 // constructor
Jared Lindblomb4032e22013-01-17 23:50:51 -080040 explicit ChronoShareGui(QWidget* parent = 0);
Jared Lindblom06405c42013-01-17 20:48:39 -080041
42 // destructor
43 ~ChronoShareGui();
Jared Lindblomb4032e22013-01-17 23:50:51 -080044
Jared Lindblom06405c42013-01-17 20:48:39 -080045private slots:
Jared Lindblomb4032e22013-01-17 23:50:51 -080046 // open the shared folder
47 void openSharedFolder();
48
49 // open file dialog
50 void openFileDialog();
51
Jared Lindblom06405c42013-01-17 20:48:39 -080052 // handle left click of tray icon
53 void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
54
55private:
56 // create actions that result from clicking a menu option
57 void createActions();
58
59 // create tray icon
60 void createTrayIcon();
61
62 // set icon image
63 void setIcon();
64
Jared Lindblomb4032e22013-01-17 23:50:51 -080065 // load persistent settings
66 void loadSettings();
67
68 // save persistent settings
69 void saveSettings();
70
71 // capture close event
72 void closeEvent(QCloseEvent* event);
Jared Lindblom06405c42013-01-17 20:48:39 -080073
74private:
75 QSystemTrayIcon* m_trayIcon; // tray icon
76 QMenu* m_trayIconMenu; // tray icon menu
77
78 QAction* m_openFolder; // open the shared folder action
Jared Lindblomb4032e22013-01-17 23:50:51 -080079 QAction* m_changeFolder; // change the shared folder action
Jared Lindblom06405c42013-01-17 20:48:39 -080080 QAction* m_quitProgram; // quit program action
81
82 QString m_dirPath; // shared directory
Jared Lindblomb4032e22013-01-17 23:50:51 -080083
84 QString m_settingsFilePath; // settings file path
85
86 QWidget* m_fileDialogWidget; // file dialog widget
Jared Lindblom06405c42013-01-17 20:48:39 -080087};
88
89#endif // CHRONOSHAREGUI_H