blob: f0cbe76253b03f36a66787bfb230485c8ae69368 [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
36class ChronoShareGui : public QWidget
37{
Alexander Afanasyev83a53002013-01-24 11:12:01 -080038 Q_OBJECT
Jared Lindblom06405c42013-01-17 20:48:39 -080039
Alexander Afanasyev83a53002013-01-24 11:12:01 -080040 public:
41 // constructor
42 explicit ChronoShareGui(QWidget* parent = 0);
43
44 // destructor
45 ~ChronoShareGui();
Jared Lindblomb4032e22013-01-17 23:50:51 -080046
Jared Lindblom06405c42013-01-17 20:48:39 -080047private slots:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080048 // open the shared folder
49 void openSharedFolder();
Jared Lindblomb4032e22013-01-17 23:50:51 -080050
Alexander Afanasyev83a53002013-01-24 11:12:01 -080051 // open file dialog
52 void openFileDialog();
Jared Lindblomb4032e22013-01-17 23:50:51 -080053
Alexander Afanasyev83a53002013-01-24 11:12:01 -080054 // handle left click of tray icon
55 void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
Jared Lindblom06405c42013-01-17 20:48:39 -080056
Alexander Afanasyev83a53002013-01-24 11:12:01 -080057 // view chronoshare settings
58 void viewSettings();
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080059
Jared Lindblom06405c42013-01-17 20:48:39 -080060private:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080061 // create actions that result from clicking a menu option
62 void createActions();
Jared Lindblom06405c42013-01-17 20:48:39 -080063
Alexander Afanasyev83a53002013-01-24 11:12:01 -080064 // create tray icon
65 void createTrayIcon();
Jared Lindblom06405c42013-01-17 20:48:39 -080066
Alexander Afanasyev83a53002013-01-24 11:12:01 -080067 // set icon image
68 void setIcon();
Jared Lindblom06405c42013-01-17 20:48:39 -080069
Alexander Afanasyev83a53002013-01-24 11:12:01 -080070 // load persistent settings
71 bool loadSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -080072
Alexander Afanasyev83a53002013-01-24 11:12:01 -080073 // save persistent settings
74 void saveSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -080075
Alexander Afanasyev83a53002013-01-24 11:12:01 -080076 // prompt user dialog box
77 void openMessageBox(QString title, QString text);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080078
Alexander Afanasyev83a53002013-01-24 11:12:01 -080079 // overload
80 void openMessageBox(QString title, QString text, QString infotext);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080081
Alexander Afanasyev83a53002013-01-24 11:12:01 -080082 // capture close event
83 void closeEvent(QCloseEvent* event);
Jared Lindblom06405c42013-01-17 20:48:39 -080084
85private:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080086 QSystemTrayIcon* m_trayIcon; // tray icon
87 QMenu* m_trayIconMenu; // tray icon menu
Jared Lindblom06405c42013-01-17 20:48:39 -080088
Alexander Afanasyev83a53002013-01-24 11:12:01 -080089 QAction* m_openFolder; // open the shared folder action
90 QAction* m_viewSettings; // chronoShare settings
91 QAction* m_changeFolder; // change the shared folder action
92 QAction* m_quitProgram; // quit program action
Jared Lindblom06405c42013-01-17 20:48:39 -080093
Alexander Afanasyev83a53002013-01-24 11:12:01 -080094 QString m_dirPath; // shared directory
Jared Lindblomb4032e22013-01-17 23:50:51 -080095
Alexander Afanasyev83a53002013-01-24 11:12:01 -080096 // QString m_settingsFilePath; // settings file path
97 // QString m_settings;
Jared Lindblom06405c42013-01-17 20:48:39 -080098};
99
100#endif // CHRONOSHAREGUI_H