Added notice indicating why program will exit if another instance is

running.

Also, minor changes to what OwnCloudSync class sends to the log.
This commit is contained in:
Juan Carlos Cornejo 2011-11-09 10:27:54 -05:00 committed by Klaas Freitag
parent dce757f94f
commit c1568f52ed
4 changed files with 19 additions and 8 deletions

View file

@ -138,8 +138,8 @@ void OwnCloudSync::directoryListingError(QString url)
{
if(mSettingsCheck) {
qDebug() << "Something wrong with the settings, please check.";
emit toLog("Settings could not be confirmed. Please "
"confirm your settings and try again.");
emit toLog(tr("Settings could not be confirmed for account %1. Please "
"confirm your settings and try again.").arg(mAccountName));
}
}
@ -201,7 +201,7 @@ void OwnCloudSync::sync()
mBusy = true;
mSyncTimer->stop();
emit toLog(tr("Synchronizing %1 on: %2")
emit toLog(tr("\nSynchronizing %1 on: %2")
.arg(mAccountName)
.arg(QDateTime::currentDateTime().toString()));

View file

@ -44,8 +44,6 @@
#include <QMessageBox>
#include <QCloseEvent>
#define OCS_VERSION "0.3"
SyncWindow::SyncWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::SyncWindow)

View file

@ -29,6 +29,8 @@
#include <QModelIndex>
#include <QItemSelection>
#define OCS_VERSION "0.3"
class QTimer;
class OwnCloudSync;
class QSignalMapper;

View file

@ -19,23 +19,34 @@
#include <QtGui/QApplication>
#include "SyncWindow.h"
#include <QSharedMemory>
#include <QMessageBox>
int quitOtherInstanceRunning()
{
QMessageBox box;
box.setText(QMessageBox::tr("Another instance is already running. "
"Please quit that instance before trying again."));
box.setDefaultButton(QMessageBox::Ok);
box.exec();
return -1;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// Technique for having only one application running at the same time per
// computer.
QSharedMemory sharedMemory;
sharedMemory.setKey("8SyGEyz2kcI0UNrqxc7wcuKLjD1pSL8GezlBM1W0QckgpjMon0");
if(sharedMemory.attach()) {
return -1;
return quitOtherInstanceRunning();
}
if (!sharedMemory.create(1)) {
return -1; // Exit already a process running
return quitOtherInstanceRunning();
}
// Great. No other instance is running, so we can run the program.
QApplication a(argc, argv);
SyncWindow w;
//w.show();