Exemplo n.º 1
0
int main(int argc, char *argv[])
{
  Q_INIT_RESOURCE(QtSESAM);
  checkPortable();
  QSettings settings(QSettings::IniFormat, QSettings::UserScope, AppCompanyName, AppName);
  const bool forceStart = argc > 1 && qstrcmp(argv[1], "--force-start") == 0;
  int exitCode = 0;
  do {
    QApplication a(argc, argv);
    a.setOrganizationName(AppCompanyName);
    a.setOrganizationDomain(AppCompanyDomain);
    a.setApplicationName(AppName);
    a.setApplicationVersion(AppVersion);
    a.setQuitOnLastWindowClosed(true);
    const QString &language = settings.value("mainwindow/language", MainWindow::defaultLocale()).toString();
    QTranslator translator;
    bool ok = translator.load(QString(":/translations/QtSESAM_%1.qm").arg(language));
    if (ok) {
      a.installTranslator(&translator);
    }
    MainWindow w(forceStart);
    w.activateWindow();
    exitCode = a.exec();
  } while (exitCode == MainWindow::EXIT_CODE_RESTART_APP);
  return exitCode;
}
Exemplo n.º 2
0
int main(int argc, char *argv[])
{
  Q_INIT_RESOURCE(QtSESAM);

  checkPortable();

  QApplication a(argc, argv);
  a.setOrganizationName(AppCompanyName);
  a.setOrganizationDomain(AppCompanyDomain);
  a.setApplicationName(AppName);
  a.setApplicationVersion(AppVersion);

  QTranslator translator;
  bool ok = translator.load(QLocale::system(),
			    AppName,
			    "_",
#ifdef WIN32
			    ":/translations"
#else
			    QLibraryInfo::location(QLibraryInfo::TranslationsPath)
#endif
			    );
#ifdef QT_DEBUG
  if (!ok)
    qWarning() << "Could not load translations for" << QLocale::system().name() << "locale";
#endif
  if (ok)
    a.installTranslator(&translator);

  MainWindow w;
  w.activateWindow();
  return a.exec();
}
Exemplo n.º 3
0
MainApplication::MainApplication(int &argc, char **argv)
  : QtSingleApplication(argc, argv)
  , isPortable_(false)
  , isPortableAppsCom_(false)
  , isClosing_(false)
  , dbFileExists_(false)
  , mainWindow_(0)
  , networkManager_(0)
  , cookieJar_(0)
  , diskCache_(0)
  , downloadManager_(0)
{
  QString message = arguments().value(1);
  if (isRunning()) {
    if (argc == 1) {
      sendMessage("--show");
    } else {
      for (int i = 2; i < argc; ++i)
        message += '\n' + arguments().value(i);
      sendMessage(message);
    }
    isClosing_ = true;
    return;
  } else {
    if (message.contains("--exit", Qt::CaseInsensitive)) {
      isClosing_ = true;
      return;
    }
  }

  setApplicationName("QuiteRss");
  setOrganizationName("QuiteRss");
  setApplicationVersion(STRPRODUCTVER);
  setWindowIcon(QIcon(":/images/quiterss32"));
  setQuitOnLastWindowClosed(false);
  QSettings::setDefaultFormat(QSettings::IniFormat);

  checkPortable();

  checkDir();

  createSettings();

  qWarning() << "Run application!";

  setStyleApplication();

  showSplashScreen();

  connectDatabase();
  setProgressSplashScreen(30);
  qWarning() << "Run application 2";
  mainWindow_ = new MainWindow();
  qWarning() << "Run application 3";
  setProgressSplashScreen(60);

  loadSettings();
  qWarning() << "Run application 4";
  updateFeeds_ = new UpdateFeeds(mainWindow_);
  setProgressSplashScreen(90);
  qWarning() << "Run application 5";
  mainWindow_->restoreFeedsOnStartUp();
  setProgressSplashScreen(100);
  qWarning() << "Run application 6";
  if (!mainWindow_->startingTray_ || !mainWindow_->showTrayIcon_) {
    mainWindow_->show();
  }
  mainWindow_->isMinimizeToTray_ = false;

  closeSplashScreen();

  if (mainWindow_->showTrayIcon_) {
    QTimer::singleShot(0, mainWindow_->traySystem, SLOT(show()));
  }

  if (updateFeedsStartUp_) {
    QTimer::singleShot(0, mainWindow_, SLOT(slotGetAllFeeds()));
  }

  receiveMessage(message);
  connect(this, SIGNAL(messageReceived(QString)), SLOT(receiveMessage(QString)));
}