Added Warnings and settings information
diff --git a/gui/chronosharegui.cpp b/gui/chronosharegui.cpp
index 0285f78..6faa80b 100644
--- a/gui/chronosharegui.cpp
+++ b/gui/chronosharegui.cpp
@@ -23,10 +23,15 @@
ChronoShareGui::ChronoShareGui(QWidget *parent) :
QWidget(parent),
- m_fileDialogWidget(new QWidget())
+ m_settingsFilePath(QDir::homePath() + ".cronoShare")
{
// load settings
- loadSettings();
+ if(!loadSettings())
+ {
+ // prompt user to choose folder
+ openMessageBox("First Time Setup", "Please select your shared folder location.");
+ openFileDialog();
+ }
// create actions that result from clicking a menu option
createActions();
@@ -47,9 +52,32 @@
delete m_trayIcon;
delete m_trayIconMenu;
delete m_openFolder;
+ delete m_viewSettings;
delete m_changeFolder;
delete m_quitProgram;
- delete m_fileDialogWidget;
+}
+
+void ChronoShareGui::openMessageBox(QString title, QString text)
+{
+ QMessageBox messageBox(this);
+ messageBox.setWindowTitle(title);
+ messageBox.setText(text);
+
+ messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png"));
+
+ messageBox.exec();
+}
+
+void ChronoShareGui::openMessageBox(QString title, QString text, QString infotext)
+{
+ QMessageBox messageBox(this);
+ messageBox.setWindowTitle(title);
+ messageBox.setText(text);
+ messageBox.setInformativeText(infotext);
+
+ messageBox.setIconPixmap(QPixmap(":/images/friends-group-icon.png"));
+
+ messageBox.exec();
}
void ChronoShareGui::createActions()
@@ -58,6 +86,10 @@
m_openFolder = new QAction(tr("&Open Folder"), this);
connect(m_openFolder, SIGNAL(triggered()), this, SLOT(openSharedFolder()));
+ // create the "view settings" action
+ m_viewSettings = new QAction(tr("&View Settings"), this);
+ connect(m_viewSettings, SIGNAL(triggered()), this, SLOT(viewSettings()));
+
// create the "change folder" action
m_changeFolder = new QAction(tr("&Change Folder"), this);
connect(m_changeFolder, SIGNAL(triggered()), this, SLOT(openFileDialog()));
@@ -75,6 +107,8 @@
// add actions to the menu
m_trayIconMenu->addAction(m_openFolder);
+ m_trayIconMenu->addSeparator();
+ m_trayIconMenu->addAction(m_viewSettings);
m_trayIconMenu->addAction(m_changeFolder);
m_trayIconMenu->addSeparator();
m_trayIconMenu->addAction(m_quitProgram);
@@ -120,11 +154,18 @@
void ChronoShareGui::openFileDialog()
{
// prompt user for new directory
- m_dirPath = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
+ QString tempPath = QFileDialog::getExistingDirectory(this, tr("Choose a new folder"),
m_dirPath, QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks);
+ QFileInfo qFileInfo(tempPath);
+
+ if(qFileInfo.isDir())
+ m_dirPath = tempPath;
+ else
+ openMessageBox("Error", "Not a valid folder, Ignoring.");
qDebug() << m_dirPath;
+ openMessageBox("Current Folder", "Current Shared Folder:\n" + m_dirPath, "You may change the folder by selecting \"change folder\" from the icon in the system tray.");
// save settings
saveSettings();
@@ -139,11 +180,30 @@
}
}
-void ChronoShareGui::loadSettings()
+void ChronoShareGui::viewSettings()
{
+ // simple for now
+ openMessageBox("Chronoshare Settings", "CurrentFolder:\n" + m_dirPath);
+}
+
+bool ChronoShareGui::loadSettings()
+{
+ bool successful = false;
+
// Load Settings
QSettings settings(m_settingsFilePath, QSettings::NativeFormat);
- m_dirPath = settings.value("dirPath", QDir::homePath()).toString();
+ if(settings.contains("dirPath"))
+ {
+ m_dirPath = settings.value("dirPath", QDir::homePath()).toString();
+ successful = true;
+ }
+ else
+ {
+ m_dirPath = QDir::homePath();
+ successful = false;
+ }
+
+ return successful;
}
void ChronoShareGui::saveSettings()