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 | #include "chronosharegui.h" |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 22 | #include "logging.h" |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 23 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 24 | INIT_LOGGER ("Gui"); |
| 25 | |
| 26 | ChronoShareGui::ChronoShareGui(QWidget *parent) |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 27 | : QDialog(parent) |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 28 | { |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 29 | |
| 30 | setWindowTitle("Preferences"); |
| 31 | |
| 32 | labelUsername = new QLabel("Username"); |
| 33 | labelSharedFolder = new QLabel("Shared Folder Name"); |
| 34 | labelSharedFolderPath = new QLabel("Shared Folder Path"); |
| 35 | editUsername = new QLineEdit(); |
| 36 | editSharedFolder = new QLineEdit(); |
| 37 | editSharedFolderPath = new QLineEdit(); |
| 38 | editSharedFolderPath->setReadOnly(true); |
| 39 | QPalette pal = editSharedFolderPath->palette(); |
| 40 | pal.setColor(QPalette::Active, QPalette::Base, pal.color(QPalette::Disabled, QPalette::Base)); |
| 41 | editSharedFolderPath->setPalette(pal); |
| 42 | button = new QPushButton("Submit"); |
| 43 | label = new QLabel(); |
| 44 | |
| 45 | connect(button, SIGNAL(clicked()), this, SLOT(changeSettings())); |
| 46 | |
| 47 | mainLayout = new QVBoxLayout; //vertically |
| 48 | mainLayout->addWidget(labelUsername); |
| 49 | mainLayout->addWidget(editUsername); |
| 50 | mainLayout->addWidget(labelSharedFolder); |
| 51 | mainLayout->addWidget(editSharedFolder); |
| 52 | mainLayout->addWidget(labelSharedFolderPath); |
| 53 | mainLayout->addWidget(editSharedFolderPath); |
| 54 | mainLayout->addWidget(button); |
| 55 | mainLayout->addWidget(label); |
| 56 | setLayout(mainLayout); |
| 57 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 58 | // load settings |
| 59 | if(!loadSettings()) |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 60 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 61 | // prompt user to choose folder |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 62 | openMessageBox("First Time Setup", "Please enter a username, shared folder name and choose the shared folder path on your local filesystem."); |
| 63 | viewSettings(); |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 64 | openFileDialog(); |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 65 | viewSettings(); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 66 | } |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 67 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 68 | // create actions that result from clicking a menu option |
| 69 | createActions(); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 70 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 71 | // create tray icon |
| 72 | createTrayIcon(); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 73 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 74 | // set icon image |
| 75 | setIcon(); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 76 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 77 | // show tray icon |
| 78 | m_trayIcon->show(); |
Alexander Afanasyev | 9e5a470 | 2013-01-24 13:15:23 -0800 | [diff] [blame] | 79 | |
| 80 | // Dispatcher(const boost::filesystem::path &path, const std::string &localUserName, const Ccnx::Name &localPrefix, |
| 81 | // const std::string &sharedFolder, const boost::filesystem::path &rootDir, |
| 82 | // Ccnx::CcnxWrapperPtr ccnx, SchedulerPtr scheduler, int poolSize = 2); |
| 83 | |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 84 | |
| 85 | // Alex: this **must** be here, otherwise m_dirPath will be uninitialized |
Alexander Afanasyev | 9e5a470 | 2013-01-24 13:15:23 -0800 | [diff] [blame] | 86 | m_watcher = new FsWatcher (m_dirPath); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | ChronoShareGui::~ChronoShareGui() |
| 90 | { |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 91 | delete m_watcher; // stop filewatching ASAP |
Alexander Afanasyev | 9e5a470 | 2013-01-24 13:15:23 -0800 | [diff] [blame] | 92 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 93 | // cleanup |
| 94 | delete m_trayIcon; |
| 95 | delete m_trayIconMenu; |
| 96 | delete m_openFolder; |
| 97 | delete m_viewSettings; |
| 98 | delete m_changeFolder; |
| 99 | delete m_quitProgram; |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 100 | |
| 101 | delete labelUsername; |
| 102 | delete labelSharedFolder; |
| 103 | delete editUsername; |
| 104 | delete editSharedFolder; |
| 105 | delete button; |
| 106 | delete label; |
| 107 | delete mainLayout; |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | void ChronoShareGui::openMessageBox(QString title, QString text) |
| 111 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 112 | QMessageBox messageBox(this); |
| 113 | messageBox.setWindowTitle(title); |
| 114 | messageBox.setText(text); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 115 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 116 | messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png")); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 117 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 118 | messageBox.exec(); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | void ChronoShareGui::openMessageBox(QString title, QString text, QString infotext) |
| 122 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 123 | QMessageBox messageBox(this); |
| 124 | messageBox.setWindowTitle(title); |
| 125 | messageBox.setText(text); |
| 126 | messageBox.setInformativeText(infotext); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 127 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 128 | messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png")); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 129 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 130 | messageBox.exec(); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | void ChronoShareGui::createActions() |
| 134 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 135 | // create the "open folder" action |
| 136 | m_openFolder = new QAction(tr("&Open Folder"), this); |
| 137 | connect(m_openFolder, SIGNAL(triggered()), this, SLOT(openSharedFolder())); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 138 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 139 | // create the "view settings" action |
| 140 | m_viewSettings = new QAction(tr("&View Settings"), this); |
| 141 | connect(m_viewSettings, SIGNAL(triggered()), this, SLOT(viewSettings())); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 142 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 143 | // create the "change folder" action |
| 144 | m_changeFolder = new QAction(tr("&Change Folder"), this); |
| 145 | connect(m_changeFolder, SIGNAL(triggered()), this, SLOT(openFileDialog())); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 146 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 147 | // create the "quit program" action |
| 148 | m_quitProgram = new QAction(tr("&Quit"), this); |
| 149 | connect(m_quitProgram, SIGNAL(triggered()), qApp, SLOT(quit())); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | void ChronoShareGui::createTrayIcon() |
| 153 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 154 | // create a new icon menu |
| 155 | m_trayIconMenu = new QMenu(this); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 156 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 157 | // add actions to the menu |
| 158 | m_trayIconMenu->addAction(m_openFolder); |
| 159 | m_trayIconMenu->addSeparator(); |
| 160 | m_trayIconMenu->addAction(m_viewSettings); |
| 161 | m_trayIconMenu->addAction(m_changeFolder); |
| 162 | m_trayIconMenu->addSeparator(); |
| 163 | m_trayIconMenu->addAction(m_quitProgram); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 164 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 165 | // create new tray icon |
| 166 | m_trayIcon = new QSystemTrayIcon(this); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 167 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 168 | // associate the menu with the tray icon |
| 169 | m_trayIcon->setContextMenu(m_trayIconMenu); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 170 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 171 | // handle left click of icon |
| 172 | connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason))); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | void ChronoShareGui::setIcon() |
| 176 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 177 | // set the icon image |
| 178 | m_trayIcon->setIcon(QIcon(":/images/friends-group-icon.png")); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | void ChronoShareGui::openSharedFolder() |
| 182 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 183 | // Alex: isn't there an OS-independent way in QT for this? |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 184 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 185 | // tell Finder to open the shared folder |
| 186 | QStringList scriptArgs; |
| 187 | scriptArgs << QLatin1String("-e") |
| 188 | << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"") |
| 189 | .arg(m_dirPath); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 190 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 191 | // execute the commands to make it happen |
| 192 | QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 193 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 194 | // clear command arguments |
| 195 | scriptArgs.clear(); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 196 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 197 | // tell Finder to appear |
| 198 | scriptArgs << QLatin1String("-e") |
| 199 | << QLatin1String("tell application \"Finder\" to activate"); |
| 200 | |
| 201 | // execute the commands to make it happen |
| 202 | QProcess::execute("/usr/bin/osascript", scriptArgs); |
Jared Lindblom | 06405c4 | 2013-01-17 20:48:39 -0800 | [diff] [blame] | 203 | } |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 204 | |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 205 | void ChronoShareGui::changeSettings() |
| 206 | { |
| 207 | if(!editUsername->text().isEmpty()) |
| 208 | m_username = editUsername->text(); |
| 209 | else |
| 210 | editUsername->setText(m_username); |
| 211 | |
| 212 | if(!editSharedFolder->text().isEmpty()) |
| 213 | m_sharedFolderName = editSharedFolder->text(); |
| 214 | else |
| 215 | editSharedFolder->setText(m_sharedFolderName); |
| 216 | |
| 217 | saveSettings(); |
| 218 | this->hide(); |
| 219 | } |
| 220 | |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 221 | void ChronoShareGui::openFileDialog() |
| 222 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 223 | // prompt user for new directory |
| 224 | QString tempPath = QFileDialog::getExistingDirectory(this, tr("Choose a new folder"), |
Alexander Afanasyev | 9e5a470 | 2013-01-24 13:15:23 -0800 | [diff] [blame] | 225 | m_dirPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); |
| 226 | QFileInfo qFileInfo (tempPath); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 227 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 228 | if(qFileInfo.isDir()) |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 229 | { |
| 230 | m_dirPath = tempPath; |
| 231 | editSharedFolderPath->setText(m_dirPath); |
| 232 | } |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 233 | else |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 234 | { |
| 235 | openMessageBox ("Error", "Not a valid folder, Ignoring."); |
| 236 | } |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 237 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 238 | _LOG_DEBUG ("Selected path: " << m_dirPath.toStdString ()); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 239 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 240 | // save settings |
| 241 | saveSettings(); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 244 | void ChronoShareGui::trayIconClicked (QSystemTrayIcon::ActivationReason reason) |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 245 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 246 | // if double clicked, open shared folder |
| 247 | if(reason == QSystemTrayIcon::DoubleClick) |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 248 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 249 | openSharedFolder(); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 250 | } |
| 251 | } |
| 252 | |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 253 | void ChronoShareGui::viewSettings() |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 254 | { |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 255 | //simple for now |
| 256 | this->show(); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | bool ChronoShareGui::loadSettings() |
| 260 | { |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 261 | bool successful = true; |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 262 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 263 | // Load Settings |
| 264 | // QSettings settings(m_settingsFilePath, QSettings::NativeFormat); |
| 265 | QSettings settings (QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare"); |
Jared Lindblom | 5d7e51e | 2013-01-18 00:59:34 -0800 | [diff] [blame] | 266 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 267 | // _LOG_DEBUG (lexical_cast<string> (settings.allKeys())); |
| 268 | |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 269 | if(settings.contains("username")) |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 270 | { |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 271 | m_username = settings.value("username", "admin").toString(); |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 272 | } |
| 273 | else |
| 274 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 275 | successful = false; |
| 276 | } |
| 277 | |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 278 | editUsername->setText(m_username); |
| 279 | |
| 280 | if(settings.contains("sharedfoldername")) |
| 281 | { |
| 282 | m_sharedFolderName = settings.value("sharedfoldername", "shared").toString(); |
| 283 | } |
| 284 | else |
| 285 | { |
| 286 | successful = false; |
| 287 | } |
| 288 | |
| 289 | editSharedFolder->setText(m_sharedFolderName); |
| 290 | |
| 291 | if(settings.contains("dirPath")) |
| 292 | { |
| 293 | m_dirPath = settings.value("dirPath", QDir::homePath()).toString(); |
| 294 | } |
| 295 | else |
| 296 | { |
| 297 | successful = false; |
| 298 | } |
| 299 | |
| 300 | editSharedFolderPath->setText(m_dirPath); |
| 301 | |
| 302 | _LOG_DEBUG ("Found configured path: " << (successful ? m_dirPath.toStdString () : std::string("no"))); |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 303 | |
| 304 | return successful; |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | void ChronoShareGui::saveSettings() |
| 308 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 309 | // Save Settings |
| 310 | // QSettings settings(m_settingsFilePath, QSettings::NativeFormat); |
| 311 | QSettings settings (QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare"); |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 312 | |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 313 | settings.setValue("dirPath", m_dirPath); |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 314 | settings.setValue("username", m_username); |
| 315 | settings.setValue("sharedfoldername", m_sharedFolderName); |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | void ChronoShareGui::closeEvent(QCloseEvent* event) |
| 319 | { |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 320 | _LOG_DEBUG ("Close Event") |
Jared Lindblom | c8ffd59 | 2013-01-25 00:00:30 -0800 | [diff] [blame] | 321 | this->hide(); |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 322 | event->ignore(); // don't let the event propagate to the base class |
Jared Lindblom | b4032e2 | 2013-01-17 23:50:51 -0800 | [diff] [blame] | 323 | } |
Jared Lindblom | dc845f0 | 2013-01-18 17:29:40 -0800 | [diff] [blame] | 324 | |
| 325 | #if WAF |
| 326 | #include "chronosharegui.moc" |
| 327 | #include "chronosharegui.cpp.moc" |
Alexander Afanasyev | 83a5300 | 2013-01-24 11:12:01 -0800 | [diff] [blame] | 328 | #endif |