Esempio n. 1
0
void InterruptRouter::init() {
  if (initialized) {
    return;
  }

  listener = NULL;
  prepareBusInterrupts();
  prepareTimer();
  initialized = true;
}
/*!
*/
void TNxSpooler::openOptions()
{
   // As this is a slot that can be called by Qt code (in response to a pushed button, for example), we
   // don't allow exceptions to go out from here. So we use a "try" block.
   try
   {
      QDEBUG_METHOD_NAME;

      TOptions options(&m_settings, this);

      // When the restore button is pushed, the the program is configured
      // with its default values.
      bool isConnected = connect(&options, SIGNAL(pushedRestore()),
                    this, SLOT(restoreSettings()));
      if (!isConnected)
      {
            // If the connection could not be restored, throw an exception
            QString message = tr("2208095 - Internal error when connecting.");
            throw runtime_error(message.toStdString());
      }

      // The options dialog is updated with the actual options
      isConnected = connect(this, SIGNAL(settingsRestored()),
          &options, SLOT(updateOptionsRows()));
      if (!isConnected)
      {
            // If the connection could not be restored, throw an exception
            QString message = tr("2208096 - Internal error when connecting.");
            throw runtime_error(message.toStdString());
      }

      do
      {
          options.exec();  // The returned value is not important here
          prepareSharedFolder();
          prepareTimer();
      }
      while(!syst.existsProgram(m_settings.value("apps").toString()));
   }
   catch(std::exception &excep)
   {
      syst.exitBecauseException(excep);
   }
   catch(...)
   {
      syst.exitBecauseException();
   }
}
/*!
   If there are no exceptions to stop it, the TNxSpooler object is constructed.
   \param qwidgetParent If "qwidgetParent" is not specified, the TNxSpooler will be an independent window.
*/
TNxSpooler::TNxSpooler(QWidget *qwidgetParent)
   : QDialog(qwidgetParent)
{
   QDEBUG_METHOD_NAME;

   // "Adopt" member objects that need this
   m_settings.setParent(this);
   m_sys_tray_icon.setParent(this);
   m_timer.setParent(this);

   // Define constant values by default
   m_default_interval = 3;
   m_special_extension = ".nxspooler-open"; // A special extension for files that contain a path to be opened by NxSpooler
   m_default_formats.append("pdf");
   m_default_formats.append("ods");
   m_default_formats.append("sxc");
   m_default_shared_resource = "nxspooler$";
   m_default_folder = QDir::toNativeSeparators(QDir::homePath().append(QDir::separator()).append(".nxspooler"));

   setupUi(this);
   prepareTrayIconOrShowProgram();

   try
   {
      initializeSettings();
      prepareSharedFolder();
   }
   catch (std::exception &excep)
   {
      // If the path did not exist and the path could not be created, show the options dialog
      if (QString(excep.what()).startsWith("2805093"))
      {
         syst.showWarning(excep.what());
         show();
         openOptions();
      }
      else
      {
         throw excep;
      }
   }

   prepareTimer();
}