Update style to (almost) conform to ndn-cxx style using clang-format
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
index d9c4409..781127e 100644
--- a/gui/chronosharegui.cpp
+++ b/gui/chronosharegui.cpp
@@ -21,12 +21,12 @@
#include "chronosharegui.hpp"
#include "core/chronoshare-config.hpp"
-#include "logging.hpp"
#include "ccnx-wrapper.hpp"
-#include <QValidator>
+#include "logging.hpp"
+#include <QDesktopServices>
#include <QDir>
#include <QFileInfo>
-#include <QDesktopServices>
+#include <QValidator>
#include <boost/make_shared.hpp>
@@ -43,35 +43,36 @@
static const QString ICON_BIG_FILE(":/images/chronoshare-big.png");
static const QString ICON_TRAY_FILE(":/images/" TRAY_ICON);
-INIT_LOGGER ("Gui");
+INIT_LOGGER("Gui");
-ChronoShareGui::ChronoShareGui(QWidget *parent)
+ChronoShareGui::ChronoShareGui(QWidget* parent)
: QDialog(parent)
, m_watcher(0)
, m_dispatcher(0)
, m_httpServer(0)
#ifdef ADHOC_SUPPORTED
- , m_executor (1)
+ , m_executor(1)
#endif
#ifdef SPARKLE_SUPPORTED
- , m_autoUpdate(new SparkleAutoUpdate(tr("http://irl.cs.ucla.edu/~zhenkai/chronoshare_dist/chronoshare.xml")))
+ , m_autoUpdate(
+ new SparkleAutoUpdate(tr("http://irl.cs.ucla.edu/~zhenkai/chronoshare_dist/chronoshare.xml")))
#endif
{
setWindowTitle("Settings");
- setMinimumWidth (600);
+ setMinimumWidth(600);
labelUsername = new QLabel("Username (hint: /<username>)");
labelSharedFolder = new QLabel("Shared Folder Name");
labelSharedFolderPath = new QLabel("Shared Folder Path");
QRegExp regex("(/[^/]+)+$");
- QValidator *prefixValidator = new QRegExpValidator(regex, this);
+ QValidator* prefixValidator = new QRegExpValidator(regex, this);
editUsername = new QLineEdit();
editUsername->setValidator(prefixValidator);
QRegExp noPureWhiteSpace("^\\S+.*$");
- QValidator *wsValidator = new QRegExpValidator(noPureWhiteSpace, this);
+ QValidator* wsValidator = new QRegExpValidator(noPureWhiteSpace, this);
editSharedFolder = new QLineEdit();
editSharedFolder->setValidator(wsValidator);
@@ -111,109 +112,100 @@
m_trayIcon->show();
// load settings
- if(!loadSettings())
- {
- // prompt user to choose folder
- openMessageBox("First Time Setup", "Please enter a username, shared folder name and choose the shared folder path on your local filesystem.");
- viewSettings();
- openFileDialog();
+ if (!loadSettings()) {
+ // prompt user to choose folder
+ openMessageBox("First Time Setup",
+ "Please enter a username, shared folder name and choose the shared folder path on your local filesystem.");
+ viewSettings();
+ openFileDialog();
+ viewSettings();
+ }
+ else {
+ if (m_username.isNull() || m_username == "" || m_sharedFolderName.isNull() ||
+ m_sharedFolderName == "") {
+ openMessageBox("First Time Setup",
+ "To activate ChronoShare, please configure your username and shared folder name.");
viewSettings();
}
- else
- {
- if (m_username.isNull () || m_username == "" ||
- m_sharedFolderName.isNull () || m_sharedFolderName == "")
- {
- openMessageBox("First Time Setup", "To activate ChronoShare, please configure your username and shared folder name.");
- viewSettings();
- }
- else
- {
- startBackend();
- }
+ else {
+ startBackend();
}
+ }
#ifdef ADHOC_SUPPORTED
- m_executor.start ();
+ m_executor.start();
#endif
}
void
-ChronoShareGui::startBackend (bool restart/*=false*/)
+ChronoShareGui::startBackend(bool restart /*=false*/)
{
- if (m_username.isNull () || m_username=="" ||
- m_sharedFolderName.isNull () || m_sharedFolderName=="" ||
- m_dirPath.isNull () || m_dirPath=="")
- {
- _LOG_DEBUG ("Don't start backend, because settings are in progress or incomplete");
+ if (m_username.isNull() || m_username == "" || m_sharedFolderName.isNull() ||
+ m_sharedFolderName == "" || m_dirPath.isNull() || m_dirPath == "") {
+ _LOG_DEBUG("Don't start backend, because settings are in progress or incomplete");
+ return;
+ }
+
+ if (m_watcher != 0 && m_dispatcher != 0) {
+ if (!restart) {
return;
}
- if (m_watcher != 0 && m_dispatcher != 0)
- {
- if (!restart)
- {
- return;
- }
-
- _LOG_DEBUG ("Restarting Dispatcher and FileWatcher for the new location or new username");
+ _LOG_DEBUG("Restarting Dispatcher and FileWatcher for the new location or new username");
delete m_watcher; // stop filewatching ASAP
delete m_dispatcher; // stop dispatcher ASAP, but after watcher (to prevent triggering callbacks on deleted object)
}
- filesystem::path realPathToFolder (m_dirPath.toStdString ());
- realPathToFolder /= m_sharedFolderName.toStdString ();
+ filesystem::path realPathToFolder(m_dirPath.toStdString());
+ realPathToFolder /= m_sharedFolderName.toStdString();
- m_dispatcher = new Dispatcher (m_username.toStdString (), m_sharedFolderName.toStdString (),
- realPathToFolder, make_shared<NdnxWrapper> ());
+ m_dispatcher = new Dispatcher(m_username.toStdString(), m_sharedFolderName.toStdString(),
+ realPathToFolder, make_shared<CcnxWrapper>());
// Alex: this **must** be here, otherwise m_dirPath will be uninitialized
- m_watcher = new FsWatcher (realPathToFolder.string ().c_str (),
- bind (&Dispatcher::Did_LocalFile_AddOrModify, m_dispatcher, _1),
- bind (&Dispatcher::Did_LocalFile_Delete, m_dispatcher, _1));
+ m_watcher = new FsWatcher(realPathToFolder.string().c_str(),
+ bind(&Dispatcher::Did_LocalFile_AddOrModify, m_dispatcher, _1),
+ bind(&Dispatcher::Did_LocalFile_Delete, m_dispatcher, _1));
- if (m_httpServer != 0)
- {
- // no need to restart webserver if it already exists
- return;
- }
+ if (m_httpServer != 0) {
+ // no need to restart webserver if it already exists
+ return;
+ }
QFileInfo indexHtmlInfo(":/html/index.html");
- if (indexHtmlInfo.exists())
- {
- try
- {
+ if (indexHtmlInfo.exists()) {
+ try {
m_httpServer = new http::server::server(HTTP_SERVER_ADDRESS, HTTP_SERVER_PORT, DOC_ROOT);
m_httpServerThread = boost::thread(&http::server::server::run, m_httpServer);
}
- catch (std::exception &e)
- {
- _LOG_ERROR ("Start http server failed");
+ catch (std::exception& e) {
+ _LOG_ERROR("Start http server failed");
m_httpServer = 0; // just to make sure
QMessageBox msgBox;
- msgBox.setText ("WARNING: Cannot start http server!");
- msgBox.setIcon (QMessageBox::Warning);
- msgBox.setInformativeText(QString("Starting http server failed. You will not be able to check history from web brower. Exception caused: %1").arg(e.what()));
+ msgBox.setText("WARNING: Cannot start http server!");
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setInformativeText(
+ QString(
+ "Starting http server failed. You will not be able to check history from web brower. Exception caused: %1")
+ .arg(e.what()));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.exec();
}
}
- else
- {
- _LOG_ERROR ("Http server doc root dir does not exist!");
+ else {
+ _LOG_ERROR("Http server doc root dir does not exist!");
}
}
ChronoShareGui::~ChronoShareGui()
{
#ifdef ADHOC_SUPPORTED
- m_executor.shutdown ();
+ m_executor.shutdown();
#endif
delete m_watcher; // stop filewatching ASAP
delete m_dispatcher; // stop dispatcher ASAP, but after watcher (to prevent triggering callbacks on deleted object)
- if (m_httpServer != 0)
- {
+ if (m_httpServer != 0) {
m_httpServer->handle_stop();
m_httpServerThread.join();
delete m_httpServer;
@@ -243,7 +235,8 @@
delete mainLayout;
}
-void ChronoShareGui::openMessageBox(QString title, QString text)
+void
+ChronoShareGui::openMessageBox(QString title, QString text)
{
QMessageBox messageBox(this);
messageBox.setWindowTitle(title);
@@ -254,7 +247,8 @@
messageBox.exec();
}
-void ChronoShareGui::openMessageBox(QString title, QString text, QString infotext)
+void
+ChronoShareGui::openMessageBox(QString title, QString text, QString infotext)
{
QMessageBox messageBox(this);
messageBox.setWindowTitle(title);
@@ -266,9 +260,10 @@
messageBox.exec();
}
-void ChronoShareGui::createActionsAndMenu()
+void
+ChronoShareGui::createActionsAndMenu()
{
- _LOG_DEBUG ("Create actions");
+ _LOG_DEBUG("Create actions");
// create the "open folder" action
m_openFolder = new QAction(tr("&Open Folder"), this);
@@ -278,8 +273,7 @@
connect(m_openWeb, SIGNAL(triggered()), this, SLOT(openInWebBrowser()));
m_recentFilesMenu = new QMenu(tr("Recently Changed Files"), this);
- for (int i = 0; i < 5; i++)
- {
+ for (int i = 0; i < 5; i++) {
m_fileActions[i] = new QAction(this);
m_fileActions[i]->setVisible(false);
connect(m_fileActions[i], SIGNAL(triggered()), this, SLOT(openFile()));
@@ -297,15 +291,15 @@
#ifdef ADHOC_SUPPORTED
// create "AdHoc Wifi" action
- m_wifiAction = new QAction (tr("Enable AdHoc &WiFI"), m_trayIconMenu);
- m_wifiAction->setChecked (false);
- m_wifiAction->setCheckable (true);
- connect (m_wifiAction, SIGNAL (toggled(bool)), this, SLOT(onAdHocChange(bool)));
+ m_wifiAction = new QAction(tr("Enable AdHoc &WiFI"), m_trayIconMenu);
+ m_wifiAction->setChecked(false);
+ m_wifiAction->setCheckable(true);
+ connect(m_wifiAction, SIGNAL(toggled(bool)), this, SLOT(onAdHocChange(bool)));
#endif
#ifdef SPARKLE_SUPPORTED
- m_checkForUpdates = new QAction (tr("Check For Updates"), this);
- connect (m_checkForUpdates, SIGNAL(triggered()), this, SLOT(onCheckForUpdates()));
+ m_checkForUpdates = new QAction(tr("Check For Updates"), this);
+ connect(m_checkForUpdates, SIGNAL(triggered()), this, SLOT(onCheckForUpdates()));
#endif
// create the "quit program" action
@@ -313,7 +307,8 @@
connect(m_quitProgram, SIGNAL(triggered()), qApp, SLOT(quit()));
}
-void ChronoShareGui::createTrayIcon()
+void
+ChronoShareGui::createTrayIcon()
{
// create a new icon menu
m_trayIconMenu = new QMenu(this);
@@ -346,45 +341,42 @@
m_trayIcon->setContextMenu(m_trayIconMenu);
// handle left click of icon
- connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
+ connect(m_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this,
+ SLOT(trayIconClicked(QSystemTrayIcon::ActivationReason)));
}
void
-ChronoShareGui::onAdHocChange (bool state)
+ChronoShareGui::onAdHocChange(bool state)
{
#ifdef ADHOC_SUPPORTED
- if (m_wifiAction->isChecked ())
- {
- QMessageBox msgBox;
- msgBox.setText ("WARNING: your WiFi will be disconnected");
- msgBox.setIcon (QMessageBox::Warning);
- msgBox.setInformativeText("AdHoc WiFi will disconnect your current WiFi.\n Are you sure that you are OK with that?");
- msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
- msgBox.setDefaultButton(QMessageBox::Cancel);
- int ret = msgBox.exec();
+ if (m_wifiAction->isChecked()) {
+ QMessageBox msgBox;
+ msgBox.setText("WARNING: your WiFi will be disconnected");
+ msgBox.setIcon(QMessageBox::Warning);
+ msgBox.setInformativeText(
+ "AdHoc WiFi will disconnect your current WiFi.\n Are you sure that you are OK with that?");
+ msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
+ msgBox.setDefaultButton(QMessageBox::Cancel);
+ int ret = msgBox.exec();
- if (ret == QMessageBox::Cancel)
- {
- m_wifiAction->setChecked (false);
- }
- else
- {
-
- m_wifiAction->setText (tr("Disable AdHoc WiFI"));
-
- // create adhoc
- m_executor.execute (Adhoc::CreateAdhoc);
- }
+ if (ret == QMessageBox::Cancel) {
+ m_wifiAction->setChecked(false);
}
- else
- {
- m_wifiAction->setText (tr("Enable AdHoc WiFI"));
+ else {
+ m_wifiAction->setText(tr("Disable AdHoc WiFI"));
- // disable adhoc
- m_executor.execute (Adhoc::DestroyAdhoc);
-
- // a trick in DestroyAdhoc ensures that WiFi will be reconnected to a default WiFi
+ // create adhoc
+ m_executor.execute(Adhoc::CreateAdhoc);
}
+ }
+ else {
+ m_wifiAction->setText(tr("Enable AdHoc WiFI"));
+
+ // disable adhoc
+ m_executor.execute(Adhoc::DestroyAdhoc);
+
+ // a trick in DestroyAdhoc ensures that WiFi will be reconnected to a default WiFi
+ }
#endif
}
@@ -398,38 +390,43 @@
#endif
}
-void ChronoShareGui::setIcon()
+void
+ChronoShareGui::setIcon()
{
// set the icon image
m_trayIcon->setIcon(QIcon(ICON_TRAY_FILE));
}
-void ChronoShareGui::openSharedFolder()
+void
+ChronoShareGui::openSharedFolder()
{
- filesystem::path realPathToFolder (m_dirPath.toStdString ());
- realPathToFolder /= m_sharedFolderName.toStdString ();
+ filesystem::path realPathToFolder(m_dirPath.toStdString());
+ realPathToFolder /= m_sharedFolderName.toStdString();
QString path = QDir::toNativeSeparators(realPathToFolder.string().c_str());
QDesktopServices::openUrl(QUrl("file:///" + path));
}
-void ChronoShareGui::openInWebBrowser()
+void
+ChronoShareGui::openInWebBrowser()
{
- QUrl url ("http://localhost:9001/");
- url.setFragment ("folderHistory&"
- "user=" + QUrl::toPercentEncoding (m_username) + "&"
- "folder=" + QUrl::toPercentEncoding (m_sharedFolderName));
+ QUrl url("http://localhost:9001/");
+ url.setFragment("folderHistory&"
+ "user=" +
+ QUrl::toPercentEncoding(m_username) + "&"
+ "folder=" +
+ QUrl::toPercentEncoding(m_sharedFolderName));
// i give up. there is double encoding and I have no idea how to fight it...
- QDesktopServices::openUrl (url);
+ QDesktopServices::openUrl(url);
}
-void ChronoShareGui::openFile()
+void
+ChronoShareGui::openFile()
{
// figure out who sent the signal
- QAction *pAction = qobject_cast<QAction*>(sender());
- if (pAction->isEnabled())
- {
- // we stored full path of the file in this toolTip field
+ QAction* pAction = qobject_cast<QAction*>(sender());
+ if (pAction->isEnabled()) {
+// we stored full path of the file in this toolTip field
#ifdef Q_WS_MAC
// we do some hack so we could show the file in Finder highlighted
QStringList args;
@@ -449,30 +446,31 @@
}
}
-void ChronoShareGui::updateRecentFilesMenu()
+void
+ChronoShareGui::updateRecentFilesMenu()
{
- for (int i = 0; i < 5; i++)
- {
+ for (int i = 0; i < 5; i++) {
m_fileActions[i]->setVisible(false);
}
- m_dispatcher->LookupRecentFileActions(boost::bind(&ChronoShareGui::checkFileAction, this, _1, _2, _3), 5);
+ m_dispatcher->LookupRecentFileActions(boost::bind(&ChronoShareGui::checkFileAction, this, _1, _2,
+ _3),
+ 5);
}
-void ChronoShareGui::checkFileAction (const std::string &filename, int action, int index)
+void
+ChronoShareGui::checkFileAction(const std::string& filename, int action, int index)
{
- filesystem::path realPathToFolder (m_dirPath.toStdString ());
- realPathToFolder /= m_sharedFolderName.toStdString ();
+ filesystem::path realPathToFolder(m_dirPath.toStdString());
+ realPathToFolder /= m_sharedFolderName.toStdString();
realPathToFolder /= filename;
- QString fullPath = realPathToFolder.string().c_str();
+ QString fullPath = realPathToFolder.string().c_str();
QFileInfo fileInfo(fullPath);
- if (fileInfo.exists())
- {
+ if (fileInfo.exists()) {
// This is a hack, we just use some field to store the path
m_fileActions[index]->setToolTip(fileInfo.absolutePath());
m_fileActions[index]->setEnabled(true);
}
- else
- {
+ else {
// after half an hour frustrating test and search around,
// I think it's the problem of Qt.
// According to the Qt doc, the action cannot be clicked
@@ -483,8 +481,7 @@
// Give up at least for now
m_fileActions[index]->setEnabled(false);
// UPDATE, file not fetched yet
- if (action == 0)
- {
+ if (action == 0) {
QFont font;
// supposed by change the font, didn't happen
font.setWeight(QFont::Light);
@@ -492,8 +489,7 @@
m_fileActions[index]->setToolTip(tr("Fetching..."));
}
// DELETE
- else
- {
+ else {
QFont font;
// supposed by change the font, didn't happen
font.setStrikeOut(true);
@@ -505,100 +501,95 @@
m_fileActions[index]->setVisible(true);
}
-void ChronoShareGui::changeSettings()
+void
+ChronoShareGui::changeSettings()
{
QString oldUsername = m_username;
QString oldSharedFolderName = m_sharedFolderName;
- if(!editUsername->text().isEmpty())
+ if (!editUsername->text().isEmpty())
m_username = editUsername->text().trimmed();
else
editUsername->setText(m_username);
- if(!editSharedFolder->text().isEmpty())
+ if (!editSharedFolder->text().isEmpty())
m_sharedFolderName = editSharedFolder->text().trimmed();
else
editSharedFolder->setText(m_sharedFolderName);
- if (m_username.isNull () || m_username=="" ||
- m_sharedFolderName.isNull () || m_sharedFolderName=="")
- {
- openMessageBox ("Error",
- "Username and shared folder name cannot be empty");
- }
- else
- {
- saveSettings();
- this->hide();
+ if (m_username.isNull() || m_username == "" || m_sharedFolderName.isNull() ||
+ m_sharedFolderName == "") {
+ openMessageBox("Error", "Username and shared folder name cannot be empty");
+ }
+ else {
+ saveSettings();
+ this->hide();
- if (m_username != oldUsername ||
- oldSharedFolderName != m_sharedFolderName)
- {
- startBackend (true); // restart dispatcher/fswatcher
- }
+ if (m_username != oldUsername || oldSharedFolderName != m_sharedFolderName) {
+ startBackend(true); // restart dispatcher/fswatcher
}
+ }
}
-void ChronoShareGui::openFileDialog()
+void
+ChronoShareGui::openFileDialog()
{
- while (true)
- {
- // prompt user for new directory
- QString tempPath = QFileDialog::getExistingDirectory(this, tr("Choose ChronoShare folder"),
- m_dirPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
- if (tempPath.isNull ())
- {
- if (m_dirPath.isNull ())
- {
- openMessageBox ("Notice", "ChronoShare will use [" + QDir::homePath () + "/ChronoShare]. \n\nYou can change it later selecting \"Change Folder\" menu.");
+ while (true) {
+ // prompt user for new directory
+ QString tempPath =
+ QFileDialog::getExistingDirectory(this, tr("Choose ChronoShare folder"), m_dirPath,
+ QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+ if (tempPath.isNull()) {
+ if (m_dirPath.isNull()) {
+ openMessageBox("Notice",
+ "ChronoShare will use [" + QDir::homePath() +
+ "/ChronoShare]. \n\nYou can change it later selecting \"Change Folder\" menu.");
- m_dirPath = QDir::homePath () + "/ChronoShare";
- editSharedFolderPath->setText (m_dirPath);
- break;
- }
- else
- {
- // user just cancelled, no need to do anything else
- return;
- }
- }
-
- QFileInfo qFileInfo (tempPath);
-
- if (!qFileInfo.isDir())
- {
- openMessageBox ("Error", "Please select an existing folder or create a new one.");
- continue;
- }
-
- if (m_dirPath == tempPath)
- {
- // user selected the same directory, no need to do anything
- return;
- }
-
- m_dirPath = tempPath;
- editSharedFolderPath->setText(m_dirPath);
- break;
+ m_dirPath = QDir::homePath() + "/ChronoShare";
+ editSharedFolderPath->setText(m_dirPath);
+ break;
+ }
+ else {
+ // user just cancelled, no need to do anything else
+ return;
+ }
}
- _LOG_DEBUG ("Selected path: " << m_dirPath.toStdString ());
- // save settings
- saveSettings ();
+ QFileInfo qFileInfo(tempPath);
- startBackend (true); // restart dispatcher/fswatcher
+ if (!qFileInfo.isDir()) {
+ openMessageBox("Error", "Please select an existing folder or create a new one.");
+ continue;
+ }
+
+ if (m_dirPath == tempPath) {
+ // user selected the same directory, no need to do anything
+ return;
+ }
+
+ m_dirPath = tempPath;
+ editSharedFolderPath->setText(m_dirPath);
+ break;
+ }
+
+ _LOG_DEBUG("Selected path: " << m_dirPath.toStdString());
+ // save settings
+ saveSettings();
+
+ startBackend(true); // restart dispatcher/fswatcher
}
-void ChronoShareGui::trayIconClicked (QSystemTrayIcon::ActivationReason reason)
+void
+ChronoShareGui::trayIconClicked(QSystemTrayIcon::ActivationReason reason)
{
// if double clicked, open shared folder
- if(reason == QSystemTrayIcon::DoubleClick)
- {
- openSharedFolder();
- }
+ if (reason == QSystemTrayIcon::DoubleClick) {
+ openSharedFolder();
+ }
}
-void ChronoShareGui::viewSettings()
+void
+ChronoShareGui::viewSettings()
{
//simple for now
this->show();
@@ -606,80 +597,77 @@
this->activateWindow();
}
-bool ChronoShareGui::loadSettings()
+bool
+ChronoShareGui::loadSettings()
{
bool successful = true;
// Load Settings
// QSettings settings(m_settingsFilePath, QSettings::NativeFormat);
- QSettings settings (QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare");
+ QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare");
// _LOG_DEBUG (lexical_cast<string> (settings.allKeys()));
- if(settings.contains("username"))
- {
- m_username = settings.value("username", "admin").toString();
- }
- else
- {
- successful = false;
- }
+ if (settings.contains("username")) {
+ m_username = settings.value("username", "admin").toString();
+ }
+ else {
+ successful = false;
+ }
editUsername->setText(m_username);
- if(settings.contains("sharedfoldername"))
- {
- m_sharedFolderName = settings.value("sharedfoldername", "shared").toString();
- }
- else
- {
- successful = false;
- }
+ if (settings.contains("sharedfoldername")) {
+ m_sharedFolderName = settings.value("sharedfoldername", "shared").toString();
+ }
+ else {
+ successful = false;
+ }
editSharedFolder->setText(m_sharedFolderName);
- if(settings.contains("dirPath"))
- {
- m_dirPath = settings.value("dirPath", QDir::homePath()).toString();
- }
- else
- {
- successful = false;
- }
+ if (settings.contains("dirPath")) {
+ m_dirPath = settings.value("dirPath", QDir::homePath()).toString();
+ }
+ else {
+ successful = false;
+ }
editSharedFolderPath->setText(m_dirPath);
- _LOG_DEBUG ("Found configured path: " << (successful ? m_dirPath.toStdString () : std::string("no")));
+ _LOG_DEBUG("Found configured path: " << (successful ? m_dirPath.toStdString() : std::string("no")));
return successful;
}
-void ChronoShareGui::saveSettings()
+void
+ChronoShareGui::saveSettings()
{
// Save Settings
// QSettings settings(m_settingsFilePath, QSettings::NativeFormat);
- QSettings settings (QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare");
+ QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "irl.cs.ucla.edu", "ChronoShare");
settings.setValue("dirPath", m_dirPath);
settings.setValue("username", m_username);
settings.setValue("sharedfoldername", m_sharedFolderName);
}
-void ChronoShareGui::closeEvent(QCloseEvent* event)
+void
+ChronoShareGui::closeEvent(QCloseEvent* event)
{
- _LOG_DEBUG ("Close Event");
+ _LOG_DEBUG("Close Event");
- if (m_username.isNull () || m_username == "" ||
- m_sharedFolderName.isNull () || m_sharedFolderName == "")
- {
- openMessageBox ("ChronoShare is not active", "Username and/or shared folder name are not set.\n\n To activate ChronoShare, open Settings menu and configure your username and shared folder name");
- }
+ if (m_username.isNull() || m_username == "" || m_sharedFolderName.isNull() ||
+ m_sharedFolderName == "") {
+ openMessageBox("ChronoShare is not active",
+ "Username and/or shared folder name are not set.\n\n To activate ChronoShare, open Settings menu and configure your username and shared folder name");
+ }
this->hide();
event->ignore(); // don't let the event propagate to the base class
}
#if WAF
-#include "chronosharegui.moc"
#include "chronosharegui.cpp.moc"
+#include "chronosharegui.moc"
#endif