//-----------------------------------------------------------------------------------------
FormatConverterApp::FormatConverterApp(QWidget* parent /* = 0*/)
    : QMainWindow(parent)
    , m_Settings(configFileName, QSettings::IniFormat)
{
    ui.setupUi(this);

    connect(ui.actionSelect_files,		SIGNAL(triggered()),	this, SLOT(onBrowseClicked()));
    connect(ui.actionSelect_directory,	SIGNAL(triggered()),	this, SLOT(onBrowseClicked()));
    connect(ui.convertButton,			SIGNAL(clicked()),		this, SLOT(onConvertClicked()));
}
SettingsForm::SettingsForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SettingsForm)
{
    ui->setupUi(this);

    ui->cbxAutocheckUpdates->setChecked(
        Settings->value("autocheck_updates", QVariant(true)).toBool());

    ui->sbxDownloads->setValue(
        Settings->value("sim_downloads", QVariant(4)).toInt());

    ui->cbxAutostart->setChecked(
        Settings->value("autostart", QVariant(true)).toBool());

    ui->txtSavepath->setText(Settings->value("download_path").toString());


    connect (ui->btnBrowse, SIGNAL(clicked()), this, SLOT(onBrowseClicked()));
    connect (ui->btnSave, SIGNAL(clicked()), this, SLOT(onSaveClicked()));


    // Load languages found in languages directory

    QDir directory (QString("translations"), QString("*.qm"));
    QStringList languages = directory.entryList();
    foreach (QString language, languages)
    {
        QString languageName = language.replace(".qm","");
        ui->cbxLanguage->addItem(languageName);
    }
QgsOSMDownloadDialog::QgsOSMDownloadDialog( QWidget* parent )
    : QDialog( parent )
    , mDownload( new QgsOSMDownload )
{
  setupUi( this );

  editXMin->setValidator( new QDoubleValidator( -180.0, 180.0, 6, this ) );
  editXMax->setValidator( new QDoubleValidator( -180.0, 180.0, 6, this ) );
  editYMin->setValidator( new QDoubleValidator( -90.0, 90.0, 6, this ) );
  editYMax->setValidator( new QDoubleValidator( -90.0, 90.0, 6, this ) );

  populateLayers();
  onExtentCanvas();

  connect( radExtentCanvas, SIGNAL( clicked() ), this, SLOT( onExtentCanvas() ) );
  connect( radExtentLayer, SIGNAL( clicked() ), this, SLOT( onExtentLayer() ) );
  connect( radExtentManual, SIGNAL( clicked() ), this, SLOT( onExtentManual() ) );
  connect( cboLayers, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onCurrentLayerChanged( int ) ) );
  connect( btnBrowse, SIGNAL( clicked() ), this, SLOT( onBrowseClicked() ) );
  connect( buttonBox, SIGNAL( accepted() ), this, SLOT( onOK() ) );
  connect( buttonBox, SIGNAL( rejected() ), this, SLOT( onClose() ) );

  connect( mDownload, SIGNAL( finished() ), this, SLOT( onFinished() ) );
  connect( mDownload, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( onDownloadProgress( qint64, qint64 ) ) );
}
OfferStorageDialog::OfferStorageDialog(IncClient* client, QString clusterName, QObject* parent) : QObject(parent)
{
    dialog = new QDialog();
    ui = new Ui::CreateClusterDialog();
    ui->setupUi(dialog);

    this->client = client;
    this->clusterName = clusterName;

    dialog->setWindowTitle(QString("Offer storage to: %1").arg(clusterName));
    ui->clusterNameLineEdit->setText(clusterName);
    ui->clusterNameLineEdit->setEnabled(false);

    //Set some default values:
    ui->locationLineEdit->setText(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
    double size = 11111111111;
    ui->sizeLineEdit->setText("11111111111");
    ui->sizeIndicatorLabel->setText(FileSizeUtils::getAppropriateFileSizeFor(size));

    connect(ui->saveButton, SIGNAL(clicked()),this, SLOT(onOfferClicked()));
    connect(ui->browseButton, SIGNAL(clicked()),this, SLOT(onBrowseClicked()));
    connect(ui->cancelButton, SIGNAL(clicked()),this, SLOT(onCancelClicked()));
    connect(ui->sizeLineEdit, SIGNAL(textChanged(QString)), this, SLOT(onSizeChanged(QString)));
    dialog->exec();
}
// -----------------------------------------------------------------------------
SettingsDialog::SettingsDialog(QWidget *pp, bool track_en, bool track_btn_en,
        const TrackSettings &track, const QString &logfile, const int logbufsize)
: QDialog(pp), m_devctrls(0), m_rotation(90), m_colortrack_en(track_en)
{
    setupUi(this);

    // label the color tracking button appropriately
    if (m_colortrack_en)
        btnToggleTracking->setText("Disable Tracking");
    else
        btnToggleTracking->setText("Enable Tracking");

    //btnToggleTracking->setEnabled(track_btn_en);

    // add a vertical spacer at some absurdly high row index
    ((QGridLayout *)deviceControlScrollAreaContents->layout())->addItem(
        new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding),
        99999, 0, 1, 1);

    // connect primary button events
    connect(btnLogFile, SIGNAL(released()), this, SLOT(onBrowseClicked()));
    connect(btnCancel, SIGNAL(released()), this, SLOT(onCancelClicked()));
    connect(btnOK, SIGNAL(released()), this, SLOT(onOkClicked()));
    connect(btnApply, SIGNAL(released()), this, SLOT(onApplyClicked()));
    connect(btnNewColor, SIGNAL(released()), this, SLOT(onNewColorClicked()));

    // assign specified color and threshold values to dialog widgets
    /*
    sbR->setValue(track.color.red());
    sbG->setValue(track.color.green());
    sbB->setValue(track.color.blue());
    sbHt->setValue(track.ht);
    sbSt->setValue(track.st);
    sbFt->setValue(track.ft);
    
    //Set Initial Tracking FPS
    sbTrackingFps->setValue(10);
    */
        
    //TODO: Set LogFile Value       
    editLogFileName->setText(logfile);
    sbLogBuffer->setValue(logbufsize);
}