1 /*****************************************************************************
2 * main.cpp - QStarDict, a StarDict clone written with using Qt *
3 * Copyright (C) 2007 Alexander Rodin *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License along *
16 * with this program; if not, write to the Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
18 *****************************************************************************/
20 #include "application.h"
28 #elif defined(Q_OS_WIN) // Q_OS_UNIX
30 #include <QMessageBox>
33 #ifdef QSTARDICT_WITH_TRANSLATIONS
35 #include <QTranslator>
36 #endif // QSTARDICT_WITH_TRANSLATIONS
38 int main(int argc, char *argv[])
40 QStarDict::Application app(argc, argv);
42 QSettings lockFile(QDir::homePath() + "/.qstardict/qstardict.pid", QSettings::IniFormat);
43 QString lastPid = lockFile.value("LastStart/pid").toString();
44 if (lastPid.length() && QDir("/proc/" + lastPid).exists() &&
45 lockFile.value("LastStart/time").toDateTime() == QFileInfo("/proc/" + lastPid).created())
47 qDebug("qstardict: already running");
50 lockFile.setValue("LastStart/pid", getpid());
51 lockFile.setValue("LastStart/time", QFileInfo("/proc/" + QString::number(getpid())).created());
53 #elif defined(Q_OS_WIN) // Q_OS_UNIX
54 HANDLE hMutex = CreateMutex(NULL, true, (LPCTSTR)"qstardict");
55 if (GetLastError() == ERROR_ALREADY_EXISTS)
57 QMessageBox::information(0, "Warning", "QStarDict is already running");
58 // Strange encoding issue...
59 // MessageBox(0, (LPCWSTR)"Warning", (LPCWSTR)"QStarDict is already running", MB_ICONWARNING);
64 app.setProperty("FingerScrollable", true);
65 app.setProperty("FingerScrollBars", true);
69 // vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab cindent textwidth=120 formatoptions=tc