Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 1 | /* -*- 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 Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 27 | #include <QDebug> |
| 28 | #include <QProcess> |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 29 | #include <QSettings> |
| 30 | #include <QDir> |
| 31 | #include <QFileDialog> |
| 32 | #include <QCloseEvent> |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 33 | #include <QMessageBox> |
Jared Lindblom | 9d8a5b1 | 2013-01-20 15:21:17 -0800 | [diff] [blame] | 34 | #include <QApplication> |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 35 | |
| 36 | class ChronoShareGui : public QWidget |
| 37 | { |
| 38 | Q_OBJECT |
| 39 | |
| 40 | public: |
| 41 | // constructor |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 42 | explicit ChronoShareGui(QWidget* parent = 0); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 43 | |
| 44 | // destructor |
| 45 | ~ChronoShareGui(); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 46 | |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 47 | private slots: |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 48 | // open the shared folder |
| 49 | void openSharedFolder(); |
| 50 | |
| 51 | // open file dialog |
| 52 | void openFileDialog(); |
| 53 | |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 54 | // handle left click of tray icon |
| 55 | void trayIconClicked(QSystemTrayIcon::ActivationReason reason); |
| 56 | |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 57 | // view chronoshare settings |
| 58 | void viewSettings(); |
| 59 | |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 60 | private: |
| 61 | // create actions that result from clicking a menu option |
| 62 | void createActions(); |
| 63 | |
| 64 | // create tray icon |
| 65 | void createTrayIcon(); |
| 66 | |
| 67 | // set icon image |
| 68 | void setIcon(); |
| 69 | |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 70 | // load persistent settings |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 71 | bool loadSettings(); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 72 | |
| 73 | // save persistent settings |
| 74 | void saveSettings(); |
| 75 | |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 76 | // prompt user dialog box |
| 77 | void openMessageBox(QString title, QString text); |
| 78 | |
| 79 | // overload |
| 80 | void openMessageBox(QString title, QString text, QString infotext); |
| 81 | |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 82 | // capture close event |
| 83 | void closeEvent(QCloseEvent* event); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 84 | |
| 85 | private: |
| 86 | QSystemTrayIcon* m_trayIcon; // tray icon |
| 87 | QMenu* m_trayIconMenu; // tray icon menu |
| 88 | |
| 89 | QAction* m_openFolder; // open the shared folder action |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 90 | QAction* m_viewSettings; // chronoShare settings |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 91 | QAction* m_changeFolder; // change the shared folder action |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 92 | QAction* m_quitProgram; // quit program action |
| 93 | |
| 94 | QString m_dirPath; // shared directory |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 95 | |
| 96 | QString m_settingsFilePath; // settings file path |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | #endif // CHRONOSHAREGUI_H |