blob: 038f05a6051b7ab1a22d49ed6894226409ce67f1 [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>
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -080019 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
20 * Zhenkai Zhu <zhenkai@cs.ucla.edu>
21 * Ilya Moiseenko <iliamo@ucla.edu>
Jared Lindblom06405c42013-01-17 20:48:39 -080022 */
23
24#include "chronosharegui.h"
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -080025
Alexander Afanasyev83a53002013-01-24 11:12:01 -080026#include "logging.h"
Alexander Afanasyev9ca444e2013-01-25 16:29:35 -080027#include "ccnx-wrapper.h"
Zhenkai Zhuf3ea97a2013-01-30 15:20:52 -080028#include <QValidator>
Zhenkai Zhuce04cb42013-02-25 15:29:31 -080029#include <QDir>
30#include <QDesktopServices>
Alexander Afanasyev9ca444e2013-01-25 16:29:35 -080031
32#include <boost/make_shared.hpp>
33
34using namespace boost;
35using namespace Ccnx;
Jared Lindblom06405c42013-01-17 20:48:39 -080036
Zhenkai Zhud9429222013-02-25 22:34:09 -080037static const string HTTP_SERVER_ADDRESS = "localhost";
38static const string HTTP_SERVER_PORT = "9001";
39static const string DOC_ROOT = ":/html";
40static const QString ICON_PICTURE_QSTRING(":/images/friends-group-icon.png");
41
Alexander Afanasyev83a53002013-01-24 11:12:01 -080042INIT_LOGGER ("Gui");
43
44ChronoShareGui::ChronoShareGui(QWidget *parent)
Jared Lindblomc8ffd592013-01-25 00:00:30 -080045 : QDialog(parent)
Zhenkai Zhud5756312013-01-31 13:49:45 -080046 , m_watcher(0)
47 , m_dispatcher(0)
Zhenkai Zhud9429222013-02-25 22:34:09 -080048 , m_httpServer(0)
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -080049#ifdef ADHOC_SUPPORTED
50 , m_executor (1)
51#endif
Jared Lindblom06405c42013-01-17 20:48:39 -080052{
Jared Lindblomf4b900e2013-02-07 18:08:47 -080053 setWindowTitle("Settings");
Jared Lindblomc8ffd592013-01-25 00:00:30 -080054
Jared Lindblomd8b76ad2013-02-07 20:37:37 -080055 labelUsername = new QLabel("Username (hint: /<username>)");
Jared Lindblomc8ffd592013-01-25 00:00:30 -080056 labelSharedFolder = new QLabel("Shared Folder Name");
57 labelSharedFolderPath = new QLabel("Shared Folder Path");
Zhenkai Zhuf3ea97a2013-01-30 15:20:52 -080058
Zhenkai Zhud5756312013-01-31 13:49:45 -080059 QRegExp regex("(/[^/]+)+$");
Zhenkai Zhuf3ea97a2013-01-30 15:20:52 -080060 QValidator *prefixValidator = new QRegExpValidator(regex, this);
61
Jared Lindblomc8ffd592013-01-25 00:00:30 -080062 editUsername = new QLineEdit();
Zhenkai Zhuf3ea97a2013-01-30 15:20:52 -080063 editUsername->setValidator(prefixValidator);
64
65 QRegExp noPureWhiteSpace("^\\S+.*$");
66 QValidator *wsValidator = new QRegExpValidator(noPureWhiteSpace, this);
Jared Lindblomc8ffd592013-01-25 00:00:30 -080067 editSharedFolder = new QLineEdit();
Zhenkai Zhuf3ea97a2013-01-30 15:20:52 -080068 editSharedFolder->setValidator(wsValidator);
69
Jared Lindblomc8ffd592013-01-25 00:00:30 -080070 editSharedFolderPath = new QLineEdit();
71 editSharedFolderPath->setReadOnly(true);
72 QPalette pal = editSharedFolderPath->palette();
73 pal.setColor(QPalette::Active, QPalette::Base, pal.color(QPalette::Disabled, QPalette::Base));
74 editSharedFolderPath->setPalette(pal);
75 button = new QPushButton("Submit");
76 label = new QLabel();
77
78 connect(button, SIGNAL(clicked()), this, SLOT(changeSettings()));
79
80 mainLayout = new QVBoxLayout; //vertically
81 mainLayout->addWidget(labelUsername);
82 mainLayout->addWidget(editUsername);
83 mainLayout->addWidget(labelSharedFolder);
84 mainLayout->addWidget(editSharedFolder);
85 mainLayout->addWidget(labelSharedFolderPath);
86 mainLayout->addWidget(editSharedFolderPath);
87 mainLayout->addWidget(button);
88 mainLayout->addWidget(label);
89 setLayout(mainLayout);
90
Alexander Afanasyev83a53002013-01-24 11:12:01 -080091 // create actions that result from clicking a menu option
92 createActions();
Jared Lindblomb4032e22013-01-17 23:50:51 -080093
Alexander Afanasyev83a53002013-01-24 11:12:01 -080094 // create tray icon
95 createTrayIcon();
Jared Lindblomb4032e22013-01-17 23:50:51 -080096
Alexander Afanasyev83a53002013-01-24 11:12:01 -080097 // set icon image
98 setIcon();
Jared Lindblom06405c42013-01-17 20:48:39 -080099
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800100 // show tray icon
101 m_trayIcon->show();
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -0800102
103 // Dispatcher(const boost::filesystem::path &path, const std::string &localUserName, const Ccnx::Name &localPrefix,
104 // const std::string &sharedFolder, const boost::filesystem::path &rootDir,
105 // Ccnx::CcnxWrapperPtr ccnx, SchedulerPtr scheduler, int poolSize = 2);
106
Zhenkai Zhud5756312013-01-31 13:49:45 -0800107 // load settings
108 if(!loadSettings())
109 {
110 // prompt user to choose folder
111 openMessageBox("First Time Setup", "Please enter a username, shared folder name and choose the shared folder path on your local filesystem.");
112 viewSettings();
113 openFileDialog();
114 viewSettings();
115 }
116 else
117 {
118 startBackend();
119 }
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800120
121#ifdef ADHOC_SUPPORTED
122 m_executor.start ();
123#endif
Zhenkai Zhud5756312013-01-31 13:49:45 -0800124}
125
126void
127ChronoShareGui::startBackend()
128{
129 if (m_watcher != 0 && m_dispatcher != 0)
130 {
131 return;
132 }
133
Alexander Afanasyev9ca444e2013-01-25 16:29:35 -0800134 m_dispatcher = new Dispatcher (m_username.toStdString (), m_sharedFolderName.toStdString (),
135 m_dirPath.toStdString (), make_shared<CcnxWrapper> ());
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800136
137 // Alex: this **must** be here, otherwise m_dirPath will be uninitialized
Alexander Afanasyev9ca444e2013-01-25 16:29:35 -0800138 m_watcher = new FsWatcher (m_dirPath,
139 bind (&Dispatcher::Did_LocalFile_AddOrModify, m_dispatcher, _1),
Zhenkai Zhud1756272013-02-01 17:02:18 -0800140 bind (&Dispatcher::Did_LocalFile_Delete, m_dispatcher, _1));
Zhenkai Zhud9429222013-02-25 22:34:09 -0800141 QFileInfo indexHtmlInfo(":/html/index.html");
142 if (indexHtmlInfo.exists())
143 {
144 m_httpServer = new http::server::server(HTTP_SERVER_ADDRESS, HTTP_SERVER_PORT, DOC_ROOT);
145 m_httpServerThread = boost::thread(&http::server::server::run, m_httpServer);
146 }
147 else
148 {
149 _LOG_ERROR ("Http server doc root dir does not exist!");
150 // shall we bail here?
151 }
Jared Lindblom06405c42013-01-17 20:48:39 -0800152}
153
154ChronoShareGui::~ChronoShareGui()
155{
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800156#ifdef ADHOC_SUPPORTED
157 m_executor.shutdown ();
158#endif
159
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800160 delete m_watcher; // stop filewatching ASAP
Alexander Afanasyev9ca444e2013-01-25 16:29:35 -0800161 delete m_dispatcher; // stop dispatcher ASAP, but after watcher (to prevent triggering callbacks on deleted object)
Zhenkai Zhud9429222013-02-25 22:34:09 -0800162 delete m_httpServer;
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -0800163
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800164 // cleanup
165 delete m_trayIcon;
166 delete m_trayIconMenu;
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800167#ifdef ADHOC_SUPPORTED
168 delete m_wifiAction;
169#endif
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800170 delete m_openFolder;
171 delete m_viewSettings;
172 delete m_changeFolder;
173 delete m_quitProgram;
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800174
175 delete labelUsername;
176 delete labelSharedFolder;
177 delete editUsername;
178 delete editSharedFolder;
179 delete button;
180 delete label;
181 delete mainLayout;
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800182}
183
184void ChronoShareGui::openMessageBox(QString title, QString text)
185{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800186 QMessageBox messageBox(this);
187 messageBox.setWindowTitle(title);
188 messageBox.setText(text);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800189
Zhenkai Zhud9429222013-02-25 22:34:09 -0800190 messageBox.setIconPixmap(QPixmap(ICON_PICTURE_QSTRING));
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800191
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800192 messageBox.exec();
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800193}
194
195void ChronoShareGui::openMessageBox(QString title, QString text, QString infotext)
196{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800197 QMessageBox messageBox(this);
198 messageBox.setWindowTitle(title);
199 messageBox.setText(text);
200 messageBox.setInformativeText(infotext);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800201
Zhenkai Zhud9429222013-02-25 22:34:09 -0800202 messageBox.setIconPixmap(QPixmap(ICON_PICTURE_QSTRING));
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800203
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800204 messageBox.exec();
Jared Lindblom06405c42013-01-17 20:48:39 -0800205}
206
207void ChronoShareGui::createActions()
208{
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800209 _LOG_DEBUG ("Create actions");
210
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800211 // create the "open folder" action
212 m_openFolder = new QAction(tr("&Open Folder"), this);
213 connect(m_openFolder, SIGNAL(triggered()), this, SLOT(openSharedFolder()));
Jared Lindblom06405c42013-01-17 20:48:39 -0800214
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800215 // create the "view settings" action
216 m_viewSettings = new QAction(tr("&View Settings"), this);
217 connect(m_viewSettings, SIGNAL(triggered()), this, SLOT(viewSettings()));
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800218
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800219 // create the "change folder" action
220 m_changeFolder = new QAction(tr("&Change Folder"), this);
221 connect(m_changeFolder, SIGNAL(triggered()), this, SLOT(openFileDialog()));
Jared Lindblomb4032e22013-01-17 23:50:51 -0800222
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800223#ifdef ADHOC_SUPPORTED
224 // create "AdHoc Wifi" action
225 m_wifiAction = new QAction (tr("Enable AdHoc &WiFI"), m_trayIconMenu);
226 m_wifiAction->setChecked (false);
227 m_wifiAction->setCheckable (true);
228 connect (m_wifiAction, SIGNAL (toggled(bool)), this, SLOT(onAdHocChange(bool)));
229#endif
230
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800231 // create the "quit program" action
232 m_quitProgram = new QAction(tr("&Quit"), this);
233 connect(m_quitProgram, SIGNAL(triggered()), qApp, SLOT(quit()));
Jared Lindblom06405c42013-01-17 20:48:39 -0800234}
235
236void ChronoShareGui::createTrayIcon()
237{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800238 // create a new icon menu
239 m_trayIconMenu = new QMenu(this);
Jared Lindblom06405c42013-01-17 20:48:39 -0800240
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800241 // add actions to the menu
242 m_trayIconMenu->addAction(m_openFolder);
243 m_trayIconMenu->addSeparator();
244 m_trayIconMenu->addAction(m_viewSettings);
245 m_trayIconMenu->addAction(m_changeFolder);
246 m_trayIconMenu->addSeparator();
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800247 m_trayIconMenu->addAction(m_wifiAction);
248 m_trayIconMenu->addSeparator();
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800249 m_trayIconMenu->addAction(m_quitProgram);
Jared Lindblom06405c42013-01-17 20:48:39 -0800250
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800251 // create new tray icon
252 m_trayIcon = new QSystemTrayIcon(this);
Jared Lindblomb4032e22013-01-17 23:50:51 -0800253
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800254#ifdef ADHOC_SUPPORTED
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800255 // associate the menu with the tray icon
256 m_trayIcon->setContextMenu(m_trayIconMenu);
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800257#endif
Jared Lindblomb4032e22013-01-17 23:50:51 -0800258
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800259 // handle left click of icon
260 connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
Jared Lindblom06405c42013-01-17 20:48:39 -0800261}
262
Alexander Afanasyev85a4ba02013-02-24 16:30:17 -0800263void
264ChronoShareGui::onAdHocChange (bool state)
265{
266#ifdef ADHOC_SUPPORTED
267 if (m_wifiAction->isChecked ())
268 {
269 QMessageBox msgBox;
270 msgBox.setText ("WARNING: your WiFi will be disconnected");
271 msgBox.setIcon (QMessageBox::Warning);
272 msgBox.setInformativeText("AdHoc WiFi will disconnect your current WiFi.\n Are you sure that you are OK with that?");
273 msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
274 msgBox.setDefaultButton(QMessageBox::Cancel);
275 int ret = msgBox.exec();
276
277 if (ret == QMessageBox::Cancel)
278 {
279 m_wifiAction->setChecked (false);
280 }
281 else
282 {
283
284 m_wifiAction->setText (tr("Disable AdHoc WiFI"));
285
286 // create adhoc
287 m_executor.execute (Adhoc::CreateAdhoc);
288 }
289 }
290 else
291 {
292 m_wifiAction->setText (tr("Enable AdHoc WiFI"));
293
294 // disable adhoc
295 m_executor.execute (Adhoc::DestroyAdhoc);
296
297 // a trick in DestroyAdhoc ensures that WiFi will be reconnected to a default WiFi
298 }
299#endif
300}
301
Jared Lindblom06405c42013-01-17 20:48:39 -0800302void ChronoShareGui::setIcon()
303{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800304 // set the icon image
Zhenkai Zhud9429222013-02-25 22:34:09 -0800305 m_trayIcon->setIcon(QIcon(ICON_PICTURE_QSTRING));
Jared Lindblom06405c42013-01-17 20:48:39 -0800306}
307
308void ChronoShareGui::openSharedFolder()
309{
Zhenkai Zhuce04cb42013-02-25 15:29:31 -0800310 QString path = QDir::toNativeSeparators(m_dirPath);
311 QDesktopServices::openUrl(QUrl("file:///" + path));
Jared Lindblom06405c42013-01-17 20:48:39 -0800312}
Jared Lindblomb4032e22013-01-17 23:50:51 -0800313
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800314void ChronoShareGui::changeSettings()
315{
316 if(!editUsername->text().isEmpty())
Zhenkai Zhuf3ea97a2013-01-30 15:20:52 -0800317 m_username = editUsername->text().trimmed();
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800318 else
319 editUsername->setText(m_username);
320
321 if(!editSharedFolder->text().isEmpty())
Zhenkai Zhuf3ea97a2013-01-30 15:20:52 -0800322 m_sharedFolderName = editSharedFolder->text().trimmed();
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800323 else
324 editSharedFolder->setText(m_sharedFolderName);
325
326 saveSettings();
327 this->hide();
Zhenkai Zhud5756312013-01-31 13:49:45 -0800328
329 startBackend();
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800330}
331
Jared Lindblomb4032e22013-01-17 23:50:51 -0800332void ChronoShareGui::openFileDialog()
333{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800334 // prompt user for new directory
335 QString tempPath = QFileDialog::getExistingDirectory(this, tr("Choose a new folder"),
Alexander Afanasyev9e5a4702013-01-24 13:15:23 -0800336 m_dirPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
337 QFileInfo qFileInfo (tempPath);
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800338
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800339 if(qFileInfo.isDir())
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800340 {
341 m_dirPath = tempPath;
342 editSharedFolderPath->setText(m_dirPath);
343 }
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800344 else
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800345 {
346 openMessageBox ("Error", "Not a valid folder, Ignoring.");
347 }
Jared Lindblomb4032e22013-01-17 23:50:51 -0800348
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800349 _LOG_DEBUG ("Selected path: " << m_dirPath.toStdString ());
Jared Lindblomb4032e22013-01-17 23:50:51 -0800350
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800351 // save settings
352 saveSettings();
Jared Lindblomb4032e22013-01-17 23:50:51 -0800353}
354
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800355void ChronoShareGui::trayIconClicked (QSystemTrayIcon::ActivationReason reason)
Jared Lindblomb4032e22013-01-17 23:50:51 -0800356{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800357 // if double clicked, open shared folder
358 if(reason == QSystemTrayIcon::DoubleClick)
Jared Lindblomb4032e22013-01-17 23:50:51 -0800359 {
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800360 openSharedFolder();
Jared Lindblomb4032e22013-01-17 23:50:51 -0800361 }
362}
363
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800364void ChronoShareGui::viewSettings()
Jared Lindblomb4032e22013-01-17 23:50:51 -0800365{
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800366 //simple for now
367 this->show();
Zhenkai Zhud5756312013-01-31 13:49:45 -0800368 this->raise();
369 this->activateWindow();
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800370}
371
372bool ChronoShareGui::loadSettings()
373{
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800374 bool successful = true;
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800375
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800376 // Load Settings
377 // QSettings settings(m_settingsFilePath, QSettings::NativeFormat);
378 QSettings settings (QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare");
Jared Lindblom5d7e51e2013-01-18 00:59:34 -0800379
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800380 // _LOG_DEBUG (lexical_cast<string> (settings.allKeys()));
381
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800382 if(settings.contains("username"))
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800383 {
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800384 m_username = settings.value("username", "admin").toString();
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800385 }
386 else
387 {
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800388 successful = false;
389 }
390
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800391 editUsername->setText(m_username);
392
393 if(settings.contains("sharedfoldername"))
394 {
395 m_sharedFolderName = settings.value("sharedfoldername", "shared").toString();
396 }
397 else
398 {
399 successful = false;
400 }
401
402 editSharedFolder->setText(m_sharedFolderName);
403
404 if(settings.contains("dirPath"))
405 {
406 m_dirPath = settings.value("dirPath", QDir::homePath()).toString();
407 }
408 else
409 {
410 successful = false;
411 }
412
413 editSharedFolderPath->setText(m_dirPath);
414
415 _LOG_DEBUG ("Found configured path: " << (successful ? m_dirPath.toStdString () : std::string("no")));
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800416
417 return successful;
Jared Lindblomb4032e22013-01-17 23:50:51 -0800418}
419
420void ChronoShareGui::saveSettings()
421{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800422 // Save Settings
423 // QSettings settings(m_settingsFilePath, QSettings::NativeFormat);
424 QSettings settings (QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare");
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800425
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800426 settings.setValue("dirPath", m_dirPath);
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800427 settings.setValue("username", m_username);
428 settings.setValue("sharedfoldername", m_sharedFolderName);
Jared Lindblomb4032e22013-01-17 23:50:51 -0800429}
430
431void ChronoShareGui::closeEvent(QCloseEvent* event)
432{
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800433 _LOG_DEBUG ("Close Event")
Jared Lindblomc8ffd592013-01-25 00:00:30 -0800434 this->hide();
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800435 event->ignore(); // don't let the event propagate to the base class
Jared Lindblomb4032e22013-01-17 23:50:51 -0800436}
Jared Lindblomdc845f02013-01-18 17:29:40 -0800437
438#if WAF
439#include "chronosharegui.moc"
440#include "chronosharegui.cpp.moc"
Alexander Afanasyev83a53002013-01-24 11:12:01 -0800441#endif