Exemple #1
0
/*! check to see if userDirectory() exists. If not, give options to
   create it.

   returns true if directory exists or was created; false if program
   should exit.
 */
bool So2sdrBandmap::checkUserDirectory()
{
    QDir dir;
    if (dir.exists(userDirectory())) return(true);

    QMessageBox msg;
    msg.setWindowTitle("Error");
    msg.setText("User data directory " + userDirectory() + " does not exist.");
    msg.setInformativeText("Create it?");
    msg.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
    msg.setDefaultButton(QMessageBox::Yes);
    int ret = msg.exec();
    switch (ret) {
    case QMessageBox::Yes:

        // create directory
        if (dir.mkdir(userDirectory())) {
            return(true);
        } else {
            msg.setText("Could not create directory <" + userDirectory() + ">");
            msg.exec();
            return(false);
        }
        break;
    case QMessageBox::Cancel:
        // this will abort the program (return false)
        break;
    default:
        // never reached
        break;
    }
    return(false);
}
void OptionDialog::saveAndClose()
{
   bool okay = false;
   bool saveDbConfig = true;

   // TODO:: FIX THIS UI. I am really not sure what the best approach is here.
   if ( status == OptionDialog::NEEDSTEST || status == OptionDialog::TESTFAILED ) {
      QMessageBox::critical(0,
            tr("Test connection or cancel"),
            tr("Saving the options without testing the connection can cause brewtarget to not restart. Your changes have been discarded, which is likely really, really crappy UX. Please open a bug explaining exactly how you got to this message.")
            );
      return;
   }

   if ( status == OptionDialog::TESTPASSED ) {
      // This got unpleasant. There are multiple possible transer paths.
      // SQLite->Pgsql, Pgsql->Pgsql and Pgsql->SQLite. This will ensure we
      // preserve the information required.
      try {
         QString theQuestion = tr("Would you like brewtarget to transfer your data to the new database? NOTE: If you've already loaded the data, say No");
         if ( QMessageBox::Yes == QMessageBox::question(this, tr("Transfer database"), theQuestion) )
            Database::instance().convertDatabase(btStringEdit_hostname->text(), btStringEdit_dbname->text(),
                                                 btStringEdit_username->text(), btStringEdit_password->text(),
                                                 btStringEdit_portnum->text().toInt(),
                                                 (Brewtarget::DBTypes)comboBox_engine->currentIndex());
         // Database engine stuff
         Brewtarget::setOption("dbType", comboBox_engine->currentIndex());
         Brewtarget::setOption("dbHostname", btStringEdit_hostname->text());
         Brewtarget::setOption("dbPortnum", btStringEdit_portnum->text());
         Brewtarget::setOption("dbSchema", btStringEdit_schema->text());
         Brewtarget::setOption("dbName", btStringEdit_dbname->text());
         Brewtarget::setOption("dbUsername", btStringEdit_username->text());
         QMessageBox::information(this, tr("Restart"), tr("Please restart brewtarget to connect to the new database"));
      }
      catch (QString e) {
         Brewtarget::logE(QString("%1 %2").arg(Q_FUNC_INFO).arg(e));
         saveDbConfig = false;
      }
   }

   if ( saveDbConfig && checkBox_savePassword->checkState() == Qt::Checked ) {
      Brewtarget::setOption("dbPassword", btStringEdit_password->text());
   }
   else {
      Brewtarget::removeOption("dbPassword");
   }

   switch (weightComboBox->itemData(weightComboBox->currentIndex()).toInt(&okay))
   {
      case SI:
      default:
         Brewtarget::weightUnitSystem = SI;
         Brewtarget::thingToUnitSystem.insert(Unit::Mass, UnitSystems::siWeightUnitSystem());
         break;
      case USCustomary:
         Brewtarget::weightUnitSystem  = USCustomary;
         Brewtarget::thingToUnitSystem.insert(Unit::Mass, UnitSystems::usWeightUnitSystem());
         break;
      case Imperial:
         Brewtarget::weightUnitSystem  = Imperial;
         Brewtarget::thingToUnitSystem.insert(Unit::Mass, UnitSystems::usWeightUnitSystem());
         break;
   }

   switch (temperatureComboBox->itemData(temperatureComboBox->currentIndex()).toInt(&okay))
   {
      case Celsius:
      default:
         Brewtarget::tempScale = Celsius;
         Brewtarget::thingToUnitSystem.insert(Unit::Temp,UnitSystems::celsiusTempUnitSystem());
         break;
      case Fahrenheit:
         Brewtarget::tempScale = Fahrenheit;
         Brewtarget::thingToUnitSystem.insert(Unit::Temp,UnitSystems::fahrenheitTempUnitSystem());
         break;
   }

   switch (volumeComboBox->itemData(volumeComboBox->currentIndex()).toInt(&okay))
   {
      case SI:
      default:
         Brewtarget::volumeUnitSystem = SI;
         Brewtarget::thingToUnitSystem.insert(Unit::Volume,UnitSystems::siVolumeUnitSystem());
         break;
      case USCustomary:
         Brewtarget::volumeUnitSystem = USCustomary;
         Brewtarget::thingToUnitSystem.insert(Unit::Volume,UnitSystems::usVolumeUnitSystem());
         break;
      case Imperial:
         Brewtarget::volumeUnitSystem = Imperial;
         Brewtarget::thingToUnitSystem.insert(Unit::Volume,UnitSystems::imperialVolumeUnitSystem());
         break;
   }

   switch (gravityComboBox->itemData(gravityComboBox->currentIndex()).toInt(&okay))
   {
      case Brewtarget::SG:
      default:
         Brewtarget::densityUnit = Brewtarget::SG;
         Brewtarget::thingToUnitSystem.insert(Unit::Density, UnitSystems::sgDensityUnitSystem());
         break;
      case Brewtarget::PLATO:
         Brewtarget::densityUnit = Brewtarget::PLATO;
         Brewtarget::thingToUnitSystem.insert(Unit::Density, UnitSystems::platoDensityUnitSystem());
         break;
   }

   switch (dateComboBox->itemData(dateComboBox->currentIndex()).toInt(&okay))
   {
      case Unit::displayUS:
      default:
         Brewtarget::dateFormat = Unit::displayUS;
         break;
      case Unit::displayImp:
         Brewtarget::dateFormat = Unit::displayImp;
         break;
      case Unit::displaySI:
         Brewtarget::dateFormat = Unit::displaySI;
         break;
   }

   switch (colorComboBox->itemData(colorComboBox->currentIndex()).toInt(&okay))
   {
      case Brewtarget::SRM:
      default:
         Brewtarget::thingToUnitSystem.insert(Unit::Color,UnitSystems::srmColorUnitSystem());
         Brewtarget::colorUnit = Brewtarget::SRM;
         break;
      case Brewtarget::EBC:
         Brewtarget::thingToUnitSystem.insert(Unit::Color,UnitSystems::ebcColorUnitSystem());
         Brewtarget::colorUnit = Brewtarget::EBC;
         break;
   }

   int ndx = ibuFormulaComboBox->itemData(ibuFormulaComboBox->currentIndex()).toInt(&okay);
   Brewtarget::ibuFormula = static_cast<Brewtarget::IbuType>(ndx);
   ndx = colorFormulaComboBox->itemData(colorFormulaComboBox->currentIndex()).toInt(&okay);
   Brewtarget::colorFormula = static_cast<Brewtarget::ColorType>(ndx);

   // Set the right language.
   Brewtarget::setLanguage( ndxToLangCode[ comboBox_lang->currentIndex() ] );

   // Check the new userDataDir.
   Brewtarget::DBTypes dbEngine = (Brewtarget::DBTypes)comboBox_engine->currentIndex();
   if ( dbEngine == Brewtarget::SQLITE ) {
      QString newUserDataDir = btStringEdit_dataDir->text();
      QDir userDirectory(newUserDataDir);

      // I think this is redundant and could be handled as just a simple db
      // transfer using the testPassed loop above.
      if( userDirectory != Brewtarget::getUserDataDir() )
      {
         // If there are no data files present...
         if( ! QFileInfo(userDirectory, "database.sqlite").exists() )
         {
            // ...tell user we will copy old data files to new location.
            QMessageBox::information(this,
                                    tr("Copy Data"),
                                    tr("There do not seem to be any data files in this directory, so we will copy your old data here.")
                                    );
            Brewtarget::copyDataFiles(newUserDataDir);
         }

         Brewtarget::userDataDir = newUserDataDir;
         Brewtarget::setOption("user_data_dir", newUserDataDir);
         QMessageBox::information(
            this,
            tr("Restart"),
            tr("Please restart Brewtarget.")
         );
      }

      Brewtarget::setOption("maximum", spinBox_numBackups->value(), "backups");
      Brewtarget::setOption("frequency", spinBox_frequency->value(), "backups");
      Brewtarget::setOption("directory", btStringEdit_backupDir->text(), "backups");
   }

   Brewtarget::setOption("mashHopAdjustment", ibuAdjustmentMashHopDoubleSpinBox->value() / 100);
   Brewtarget::setOption("firstWortHopAdjustment", ibuAdjustmentFirstWortDoubleSpinBox->value() / 100);

   // Make sure the main window updates.
   if( Brewtarget::mainWindow() )
      Brewtarget::mainWindow()->showChanges();

   setVisible(false);
}
void OptionDialog::saveAndClose()
{
   bool okay = false;

   switch (weightComboBox->itemData(weightComboBox->currentIndex()).toInt(&okay))
   {
      case SI:
      default:
         Brewtarget::weightUnitSystem = SI;
         Brewtarget::thingToUnitSystem.insert(Unit::Mass, UnitSystems::siWeightUnitSystem());
         break;
      case USCustomary:
         Brewtarget::weightUnitSystem  = USCustomary;
         Brewtarget::thingToUnitSystem.insert(Unit::Mass, UnitSystems::usWeightUnitSystem());
         break;
      case Imperial:
         Brewtarget::weightUnitSystem  = Imperial;
         Brewtarget::thingToUnitSystem.insert(Unit::Mass, UnitSystems::usWeightUnitSystem());
         break;
   }

   switch (temperatureComboBox->itemData(temperatureComboBox->currentIndex()).toInt(&okay))
   {
      case Celsius:
      default:
         Brewtarget::tempScale = Celsius;
         Brewtarget::thingToUnitSystem.insert(Unit::Temp,UnitSystems::celsiusTempUnitSystem());
         break;
      case Fahrenheit:
         Brewtarget::tempScale = Fahrenheit;
         Brewtarget::thingToUnitSystem.insert(Unit::Temp,UnitSystems::fahrenheitTempUnitSystem());
         break;
   }


   switch (volumeComboBox->itemData(volumeComboBox->currentIndex()).toInt(&okay))
   {
      case SI:
      default:
         Brewtarget::volumeUnitSystem = SI;
         Brewtarget::thingToUnitSystem.insert(Unit::Volume,UnitSystems::siVolumeUnitSystem());
         break;
      case USCustomary:
         Brewtarget::volumeUnitSystem = USCustomary;
         Brewtarget::thingToUnitSystem.insert(Unit::Volume,UnitSystems::usVolumeUnitSystem());
         break;
      case Imperial:
         Brewtarget::volumeUnitSystem = Imperial;
         Brewtarget::thingToUnitSystem.insert(Unit::Volume,UnitSystems::imperialVolumeUnitSystem());
         break;
   }

   switch (gravityComboBox->itemData(gravityComboBox->currentIndex()).toInt(&okay))
   {
      case Brewtarget::SG:
      default:
         Brewtarget::densityUnit = Brewtarget::SG;
         Brewtarget::thingToUnitSystem.insert(Unit::Density, UnitSystems::sgDensityUnitSystem());
         break;
      case Brewtarget::PLATO:
         Brewtarget::densityUnit = Brewtarget::PLATO;
         Brewtarget::thingToUnitSystem.insert(Unit::Density, UnitSystems::platoDensityUnitSystem());
         break;
   }

   switch (dateComboBox->itemData(dateComboBox->currentIndex()).toInt(&okay))
   {
      case Unit::displayUS:
      default:
         Brewtarget::dateFormat = Unit::displayUS;
         break;
      case Unit::displayImp:
         Brewtarget::dateFormat = Unit::displayImp;
         break;
      case Unit::displaySI:
         Brewtarget::dateFormat = Unit::displaySI;
         break;
   }

   switch (colorComboBox->itemData(colorComboBox->currentIndex()).toInt(&okay))
   {
      case Brewtarget::SRM:
      default:
         Brewtarget::thingToUnitSystem.insert(Unit::Color,UnitSystems::srmColorUnitSystem());
         Brewtarget::colorUnit = Brewtarget::SRM;
         break;
      case Brewtarget::EBC:
         Brewtarget::thingToUnitSystem.insert(Unit::Color,UnitSystems::ebcColorUnitSystem());
         Brewtarget::colorUnit = Brewtarget::EBC;
         break;
   }

   Brewtarget::ibuFormula = Brewtarget::IbuType(
           ibuFormulaComboBox->itemData(ibuFormulaComboBox->currentIndex()).toInt(&okay));

   Brewtarget::colorFormula = Brewtarget::ColorType(
           colorFormulaComboBox->itemData(colorFormulaComboBox->currentIndex()).toInt(&okay));

   // Set the right language.
   Brewtarget::setLanguage( ndxToLangCode[ comboBox_lang->currentIndex() ] );

   // Check the new userDataDir.
   QString newUserDataDir = lineEdit_dbDir->text();

   QDir userDirectory(newUserDataDir);

   if( userDirectory != Brewtarget::getUserDataDir() )
   {
      // If there are no data files present...
      if( ! QFileInfo(userDirectory, "database.sqlite").exists() )
      {
         // ...tell user we will copy old data files to new location.
         QMessageBox::information(this,
                                  tr("Copy Data"),
                                  tr("There do not seem to be any data files in this directory, so we will copy your old data here.")
                                 );
         Brewtarget::copyDataFiles(newUserDataDir);
      }

      Brewtarget::userDataDir = newUserDataDir;
      Brewtarget::setOption("user_data_dir", newUserDataDir);
      QMessageBox::information(
         this,
         tr("Restart"),
         tr("Please restart Brewtarget.")
      );
   }

   Brewtarget::setOption("mashHopAdjustment", ibuAdjustmentMashHopDoubleSpinBox->value() / 100);
   Brewtarget::setOption("firstWortHopAdjustment", ibuAdjustmentFirstWortDoubleSpinBox->value() / 100);

   // Make sure the main window updates.
   if( Brewtarget::mainWindow() )
      Brewtarget::mainWindow()->showChanges();

   setVisible(false);
}
Exemple #4
0
void SDRDialog::findConfig2()
{
    fileGetter("So2sdr-bandmap config file",userDirectory()+"/so2sdr-bandmap2.ini",
            "ini files (*.ini)",s_sdr_config[1],labelConfig2);
}
Exemple #5
0
So2sdrBandmap::So2sdrBandmap(QStringList args, QWidget *parent) : QMainWindow(parent)
{
    setupUi(this);
    initPointers();
    initVariables();

    // check to see if user directory exists
    initialized = checkUserDirectory();
    settingsFile = userDirectory()+"/so2sdr-bandmap.ini";

    // check for optional command argument giving station config file name
    if (args.size() > 1) {
        settingsFile = args[1].trimmed();
        // Qt doesn't understand that ~/... implies home directory...
        if (settingsFile.left(1)=="~") {
            if (settingsFile.left(2)=="~/") {
                settingsFile=QDir::homePath()+settingsFile.right(settingsFile.size()-1);
            } else {
                // for cases like ~name : no easy way to parse, give up
                QMessageBox msgBox;
                msgBox.setText("Please use the complete path to the settings file.");
                msgBox.setInformativeText(settingsFile);
                msgBox.setStandardButtons(QMessageBox::Ok);
                msgBox.setDefaultButton(QMessageBox::Ok);
                msgBox.exec();
                close();
            }
        }
    }
    QFileInfo fi(settingsFile);
    if (!fi.exists()) {
        QMessageBox msgBox;
        msgBox.setText("The settings file "+settingsFile+" does not exist.");
        msgBox.setInformativeText("Do you want to create it?");
        msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Cancel);
        msgBox.setDefaultButton(QMessageBox::Save);
        if (msgBox.exec()==QMessageBox::Cancel) {
            close();
        }
        firstTime=true;
    }
    settings = new  QSettings(settingsFile,QSettings::IniFormat,this);
    if (settings->status()!=QSettings::NoError) {
        errorBox.showMessage("ERROR: problem starting qsettings");
    }
    // if run the first time with default settings file for second radio,
    // set second radio
    if (firstTime && settingsFile.right(19)=="so2sdr-bandmap2.ini") {
        settings->setValue(s_sdr_nrig,1);
    }
    // restore window size and position
    QString tmp="BandmapWindow";
    settings->beginGroup(tmp);
    resize(settings->value("size", QSize(400, 594)).toSize());
    move(settings->value("pos", QPoint(200, 200)).toPoint());
    settings->endGroup();

    directory.setCurrent(dataDirectory());
    setWindowIcon(QIcon("icon24x24.png"));

    if (settings->value(s_sdr_reverse_scroll,s_sdr_reverse_scroll_def).toBool()) {
        horizontalLayout->removeWidget(CallLabel);
        horizontalLayout->removeWidget(FreqLabel);
        horizontalLayout->removeWidget(display);
        horizontalLayout->insertWidget(0,CallLabel);
        horizontalLayout->insertWidget(1,FreqLabel);
        horizontalLayout->insertWidget(2,display);
    }

    freqPixmap      = QPixmap(FreqLabel->width(), settings->value(s_sdr_fft,s_sdr_fft_def).toInt());
    callPixmap      = QPixmap(CallLabel->width(), settings->value(s_sdr_fft,s_sdr_fft_def).toInt());

    ipAddress= QHostAddress(QHostAddress::LocalHost).toString();
    if (!server.listen(QHostAddress::LocalHost,
                        settings->value(s_sdr_bandmap_tcp_port,s_sdr_bandmap_tcp_port_def).toInt())) {
        qDebug("couldn't start tcp server");
    }
    connect(&server, SIGNAL(newConnection()), this, SLOT(startConnection()));

    setFocusPolicy(Qt::StrongFocus);
    setFocusPolicy(Qt::NoFocus);
    display->setFocusPolicy(Qt::NoFocus);
    CallLabel->setFocusPolicy(Qt::NoFocus);
    FreqLabel->setFocusPolicy(Qt::NoFocus);

    checkBoxMark.setText("Mark");
    checkBoxMark.setToolTip("Enables signal detection.");
    toolBar->setMovable(false);
    QWidget* spacer1 = new QWidget();
    spacer1->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    toolBar->addWidget(spacer1);
    toolBar->addWidget(&checkBoxMark);
    txLabel.clear();
    txLabel.setText("<font color=#000000>TX");
    toolBar->addWidget(&txLabel);
    slider.setToolTip("Gain for signal detection. To the right is LESS sensitive.");
    slider.setOrientation(Qt::Horizontal);
    connect(&slider,SIGNAL(valueChanged(int)),this,SLOT(updateLevel(int)));
    slider.setFixedWidth(60);
    slider.setMaximum(200);
    slider.setMinimum(0);
    slider.setSingleStep(10);
    slider.setPageStep(50);
    slider.setValue(settings->value(s_sdr_level,s_sdr_level_def).toInt());
    toolBar->addWidget(&slider);
    QWidget* spacer2 = new QWidget();
    spacer2->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
    toolBar->addWidget(spacer2);
    toolBar->addAction("&Help",this,SLOT(showHelp()));

    iqDialog  = new IQBalance(this, Qt::Window);
    iqDialog->clearPlots();
    showToolBar = new QAction("&toolbar",this);
    scaleX1   = new QAction("Zoom x&1", this);
    scaleX2   = new QAction("Zoom x&2", this);
    deleteAct = new QAction("&Delete Call", this);
    checkBoxMark.setChecked(settings->value(s_sdr_peakdetect,s_sdr_peakdetect_def).toBool());

    iqShowData = new QAction("IQ Balance", this);
    connect(iqShowData, SIGNAL(triggered()), this, SLOT(showIQData()));
    connect(&checkBoxMark, SIGNAL(clicked()), this, SLOT(emitParams()));
    connect(deleteAct, SIGNAL(triggered()), this, SLOT(deleteCallMouse()));
    showToolBar->setCheckable(true);
    showToolBar->setChecked(true);
    connect(showToolBar,SIGNAL(triggered(bool)),this,SLOT(setShowToolbar(bool)));
    scaleX1->setCheckable(true);
    scaleX2->setCheckable(true);
    scaleX2->setChecked(false);
    scaleX1->setChecked(true);
    connect(scaleX1, SIGNAL(triggered()), this, SLOT(setScaleX1()));
    connect(scaleX2, SIGNAL(triggered()), this, SLOT(setScaleX2()));
    connect(actionRun,SIGNAL(triggered()),this,SLOT(start()));

    sdrSetup = new SDRDialog(*settings,this);
    connect(actionSetup,SIGNAL(triggered()),sdrSetup,SLOT(show()));
    connect(actionSetup,SIGNAL(triggered()),this,SLOT(disconnectSignals()));
    connect(sdrSetup,SIGNAL(setupErrors(QString)),&errorBox,SLOT(showMessage(QString)));
    connect(sdrSetup,SIGNAL(update()),this,SLOT(setSdrType()));
    connect(sdrSetup,SIGNAL(restartSdr()),this,SLOT(restartSdr()));
    connect(display, SIGNAL(displayMouseQSY(int)), this, SLOT(mouseQSYDelta(int)));
    toolBarHeight = toolBar->height();

    // select type of SDR, create data source sdrSource
    spectrumProcessor = new Spectrum(this,*settings,userDirectory());
    switch ((SdrType)settings->value(s_sdr_type,s_sdr_type_def).toInt()) {
    case soundcard_t:
        sdrSource = new AudioReaderPortAudio(settingsFile);
        break;
    case afedri_t:
        sdrSource = new Afedri(settingsFile);
        break;
    case network_t:
        sdrSource = new NetworkSDR(settingsFile);
        break;
    }
    setSdrType();
    sdrSource->moveToThread(&sdrThread);
    connect(actionSetup,SIGNAL(triggered()),sdrSource,SLOT(stop()),Qt::DirectConnection);
    connect(&sdrThread,SIGNAL(started()),sdrSource,SLOT(initialize()));
    connect(sdrSource,SIGNAL(stopped()),&sdrThread,SLOT(quit()));
    connect(sdrSource,SIGNAL(stopped()),this,SLOT(disconnectSignals()));
    connect(sdrSource,SIGNAL(error(QString)),&errorBox,SLOT(showMessage(QString)));

    connect(spectrumProcessor, SIGNAL(spectrumReady(unsigned char*, unsigned char)), display,
            SLOT(plotSpectrum(unsigned char*, unsigned char)));
    connect(sdrSource, SIGNAL(ready(unsigned char *, unsigned char)),spectrumProcessor,
            SLOT(processData(unsigned char *, unsigned char)),Qt::QueuedConnection);
    connect(iqDialog, SIGNAL(closed(bool)), spectrumProcessor, SLOT(setPlotPoints(bool)));
    connect(iqDialog, SIGNAL(restart()), spectrumProcessor, SLOT(clearIQ()));
    connect(spectrumProcessor, SIGNAL(qsy(int)), this, SLOT(findQsy(int)));
    connect(spectrumProcessor, SIGNAL(clearPlot()), iqDialog, SLOT(clearPlots()));
    connect(spectrumProcessor, SIGNAL(gainPoint(int, double)), iqDialog, SLOT(plotGainPoint(int, double)));
    connect(spectrumProcessor, SIGNAL(phasePoint(int, double)), iqDialog, SLOT(plotPhasePoint(int, double)));
    connect(spectrumProcessor, SIGNAL(gainScale(double, double)), iqDialog, SLOT(setGainScale(double, double)));
    connect(spectrumProcessor, SIGNAL(phaseScale(double, double)), iqDialog, SLOT(setPhaseScale(double, double)));
    connect(spectrumProcessor, SIGNAL(plotGainFunc(double, double, double, double)), iqDialog,
           SLOT(plotGainFunc(double, double, double, double)));
    connect(spectrumProcessor, SIGNAL(plotPhaseFunc(double, double, double, double)), iqDialog,
           SLOT(plotPhaseFunc(double, double, double, double)));

    // vfoPos is the position of the red line indicating center
    vfoPos          = (height()-toolBarHeight)/ 2;
    dragPos         = vfoPos;
    display->setVfoPos(vfoPos);

    makeFreqScaleAbsolute();
    FreqLabel->setPixmap(freqPixmap);
    FreqLabel->update();

    startTimers();
    show();
}
Exemple #6
0
status_t
DecorInfoUtility::ScanDecorators()
{
	status_t result;

	BPath systemPath;
	result = find_directory(B_SYSTEM_ADDONS_DIRECTORY, &systemPath);
	if (result == B_OK)
		result = systemPath.Append("decorators");

	if (result == B_OK) {
		BDirectory systemDirectory(systemPath.Path());
		result = systemDirectory.InitCheck();
		if (result == B_OK) {
			result = _ScanDecorators(systemDirectory);
			if (result != B_OK) {
				fprintf(stderr, "DecorInfoUtility::ScanDecorators()\tERROR: %s\n",
					strerror(result));
				return result;
			}
		}
	}

	BPath systemNonPackagedPath;
	result = find_directory(B_SYSTEM_NONPACKAGED_ADDONS_DIRECTORY,
		&systemNonPackagedPath);
	if (result == B_OK)
		result = systemNonPackagedPath.Append("decorators");

	if (result == B_OK) {
		BDirectory systemNonPackagedDirectory(systemNonPackagedPath.Path());
		result = systemNonPackagedDirectory.InitCheck();
		if (result == B_OK) {
			result = _ScanDecorators(systemNonPackagedDirectory);
			if (result != B_OK) {
				fprintf(stderr, "DecorInfoUtility::ScanDecorators()\tERROR: %s\n",
					strerror(result));
				return result;
			}
		}
	}

	BPath userPath;
	result = find_directory(B_USER_ADDONS_DIRECTORY, &userPath);
	if (result == B_OK)
		result = userPath.Append("decorators");

	if (result == B_OK) {
		BDirectory userDirectory(userPath.Path());
		result = userDirectory.InitCheck();
		if (result == B_OK) {
			result = _ScanDecorators(userDirectory);
			if (result != B_OK) {
				fprintf(stderr, "DecorInfoUtility::ScanDecorators()\tERROR: %s\n",
					strerror(result));
				return result;
			}
		}
	}

	BPath userNonPackagedPath;
	result = find_directory(B_USER_NONPACKAGED_ADDONS_DIRECTORY,
		&userNonPackagedPath);
	if (result == B_OK)
		result = userNonPackagedPath.Append("decorators");

	if (result == B_OK) {
		BDirectory userNonPackagedDirectory(userNonPackagedPath.Path());
		result = userNonPackagedDirectory.InitCheck();
		if (result == B_OK) {
			result = _ScanDecorators(userNonPackagedDirectory);
			if (result != B_OK) {
				fprintf(stderr, "DecorInfoUtility::ScanDecorators()\tERROR: %s\n",
					strerror(result));
				return result;
			}
		}
	}

	fHasScanned = true;

	return B_OK;
}