blob: 098a48ebd9e75a562ed36c40f058a74638f537ee [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
Jared Lindblomc8ffd592013-01-25 00:00:30 -080024#include <QtGui>
Jared Lindblom06405c42013-01-17 20:48:39 -080025#include <QWidget>
26#include <QSystemTrayIcon>
27#include <QMenu>
Jared Lindblom06405c42013-01-17 20:48:39 -080028#include <QDebug>
29#include <QProcess>
Jared Lindblomb4032e22013-01-17 23:50:51 -080030#include <QSettings>
31#include <QDir>
32#include <QFileDialog>
33#include <QCloseEvent>
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080034#include <QMessageBox>
Jared Lindblom9d8a5b12013-01-20 15:21:17 -080035#include <QApplication>
Jared Lindblom06405c42013-01-17 20:48:39 -080036
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -080037#include "fs-watcher.h"
38
Jared Lindblomc8ffd592013-01-25 00:00:30 -080039class ChronoShareGui : public QDialog
Jared Lindblom06405c42013-01-17 20:48:39 -080040{
Alexander Afanasyev83a53002013-01-24 11:12:01 -080041 Q_OBJECT
Jared Lindblom06405c42013-01-17 20:48:39 -080042
Alexander Afanasyev83a53002013-01-24 11:12:01 -080043 public:
44 // constructor
45 explicit ChronoShareGui(QWidget* parent = 0);
46
47 // destructor
48 ~ChronoShareGui();
Jared Lindblomb4032e22013-01-17 23:50:51 -080049
Jared Lindblom06405c42013-01-17 20:48:39 -080050private slots:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080051 // open the shared folder
52 void openSharedFolder();
Jared Lindblomb4032e22013-01-17 23:50:51 -080053
Alexander Afanasyev83a53002013-01-24 11:12:01 -080054 // open file dialog
55 void openFileDialog();
Jared Lindblomb4032e22013-01-17 23:50:51 -080056
Alexander Afanasyev83a53002013-01-24 11:12:01 -080057 // handle left click of tray icon
58 void trayIconClicked(QSystemTrayIcon::ActivationReason reason);
Jared Lindblom06405c42013-01-17 20:48:39 -080059
Alexander Afanasyev83a53002013-01-24 11:12:01 -080060 // view chronoshare settings
61 void viewSettings();
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080062
Jared Lindblomc8ffd592013-01-25 00:00:30 -080063 // change chronoshare settings
64 void changeSettings();
65
Jared Lindblom06405c42013-01-17 20:48:39 -080066private:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080067 // create actions that result from clicking a menu option
68 void createActions();
Jared Lindblom06405c42013-01-17 20:48:39 -080069
Alexander Afanasyev83a53002013-01-24 11:12:01 -080070 // create tray icon
71 void createTrayIcon();
Jared Lindblom06405c42013-01-17 20:48:39 -080072
Alexander Afanasyev83a53002013-01-24 11:12:01 -080073 // set icon image
74 void setIcon();
Jared Lindblom06405c42013-01-17 20:48:39 -080075
Alexander Afanasyev83a53002013-01-24 11:12:01 -080076 // load persistent settings
77 bool loadSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -080078
Alexander Afanasyev83a53002013-01-24 11:12:01 -080079 // save persistent settings
80 void saveSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -080081
Alexander Afanasyev83a53002013-01-24 11:12:01 -080082 // prompt user dialog box
83 void openMessageBox(QString title, QString text);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080084
Alexander Afanasyev83a53002013-01-24 11:12:01 -080085 // overload
86 void openMessageBox(QString title, QString text, QString infotext);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -080087
Alexander Afanasyev83a53002013-01-24 11:12:01 -080088 // capture close event
89 void closeEvent(QCloseEvent* event);
Jared Lindblom06405c42013-01-17 20:48:39 -080090
91private:
Alexander Afanasyev83a53002013-01-24 11:12:01 -080092 QSystemTrayIcon* m_trayIcon; // tray icon
93 QMenu* m_trayIconMenu; // tray icon menu
Jared Lindblom06405c42013-01-17 20:48:39 -080094
Alexander Afanasyev83a53002013-01-24 11:12:01 -080095 QAction* m_openFolder; // open the shared folder action
96 QAction* m_viewSettings; // chronoShare settings
97 QAction* m_changeFolder; // change the shared folder action
98 QAction* m_quitProgram; // quit program action
Jared Lindblom06405c42013-01-17 20:48:39 -080099
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800100 QString m_dirPath; // shared directory
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800101 QString m_username; // username
102 QString m_sharedFolderName; // shared folder name
Jared Lindblomb4032e22013-01-17 23:50:51 -0800103
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800104 FsWatcher* m_watcher;
105
106 QLabel* labelUsername;
107 QPushButton* button;
108 QLabel* labelSharedFolder;
109 QLabel* labelSharedFolderPath;
110 QLineEdit* editUsername;
111 QLineEdit* editSharedFolder;
112 QLineEdit* editSharedFolderPath;
113 QLabel *label;
114 QVBoxLayout *mainLayout;
115
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800116 // QString m_settingsFilePath; // settings file path
117 // QString m_settings;
Jared Lindblom06405c42013-01-17 20:48:39 -0800118};
119
120#endif // CHRONOSHAREGUI_H