void wepConfig::on_buttonBox_clicked(QAbstractButton *button)
{
    if (buttonBox->standardButton(button) == QDialogButtonBox::Ok) {
        saveAndClose();
    } else { // the cancel button
        close();
    }
}
Exemple #2
0
MashEditor::MashEditor(QWidget* parent) : QDialog(parent), mashObs(0)
{
   setupUi(this);

   connect(pushButton_fromEquipment, SIGNAL(clicked()), this, SLOT(fromEquipment()) );
   connect(this, SIGNAL(accepted()), this, SLOT(saveAndClose()) );
   connect(this, SIGNAL(rejected()), this, SLOT(closeEditor()) );

}
void SettingsDialog::createLayout() {
  QFormLayout *formLayout = new QFormLayout();
  formLayout->addRow(QString::fromUtf8("Приложение"), appIdEdit);
  formLayout->addRow(QString::fromUtf8("Права доступа"), permissionsEdit);
  formLayout->addRow(QString::fromUtf8("База данных"), dbpathEdit);
  QHBoxLayout *actionsLayout = new QHBoxLayout();
  actionsLayout->addStretch();
  QPushButton *applyButton = new QPushButton(QString::fromUtf8("Принять"));
  applyButton->setDefault(true);
  connect(applyButton, SIGNAL(clicked()), this, SLOT(saveAndClose()));
  QPushButton *cancelButton = new QPushButton(QString::fromUtf8("Отмена"));
  connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancelAndClose()));
  actionsLayout->addWidget(applyButton);
  actionsLayout->addWidget(cancelButton);
  QVBoxLayout *mainLayout = new QVBoxLayout(this);
  mainLayout->addLayout(formLayout);
  mainLayout->addLayout(actionsLayout);
}
Exemple #4
0
ConfigurationDialog::ConfigurationDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ConfigurationDialog)
{
    ui->setupUi(this);

    ui->menuTree->setCurrentItem(ui->menuTree->topLevelItem(0));

    connect(ui->buttonBox,SIGNAL(accepted()),this,SLOT(saveAndClose()));
    connect(ui->buttonBox,SIGNAL(rejected()),this,SLOT(close()));
    connect(ui->menuTree, SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged()));

    Configuration *config = Configuration::getInstance();
    ui->horizontalSpinBox->setValue(config->getHorizontalSlots());
    ui->verticalSpinBox->setValue(config->getVerticalSlots());
    ui->playerSpinBox->setValue(config->getPlayer());
    ui->playlistFadeSpinBox->setValue(config->getPlaylistFade());
    ui->slotFadeSpinBox->setValue(config->getSlotFade());
    ui->bufferSpinBox->setValue(config->getSlotBuffer());
    ui->keyboardSyncCheckBox->setChecked(config->getLayerKeyboardSync());
    ui->playlistFadePosSpinBox->setValue(config->getPlaylistFPos());
    ui->layerSpinBox->setValue(config->getLayer());
    ui->deviceSelectWidget->setNewTitel(tr("PFL"));
    ui->deviceSelectWidget->selectDevice(config->getPFLDriver(),config->getPFLDevice(),config->getPFLChannel());
    ui->defaultDeviceWidget->setNewTitel(tr("Standard Audiogerät"));
    ui->defaultDeviceWidget->selectDevice(config->getDefaultDriver(),config->getDefaultDevice(),config->getDefaultChannel());
    ui->slotTimeSpinBox->setValue(config->getSlotTimeSize());
    ui->pauseCheckBox->setChecked(config->getPauseButton());

    QTreeWidgetItem *layerItem = ui->menuTree->topLevelItem(1);
    for (int i=0;i<config->getLayer();i++) {
        QTreeWidgetItem *item = new QTreeWidgetItem();
        item->setText(0,"Layer "+QString::number(i+1));
        layerItem->addChild(item);
    }
    layerItem->setExpanded(true);
    connect(ui->layerSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateLayerCount(int)));
}
// This is the main constructor.
PropertiesDialog::PropertiesDialog(QWidget *parent, const QVector<QString> Qheader, const QString sourceInput, const QString targetInput) : QDialog(parent) {
  // We first set up the standard elements of the interface, which are only two labels and two buttons.
  sourceLabel = new QLabel(sourceInput);
  targetLabel = new QLabel(targetInput);
  saveCloseButton = new QPushButton(tr("Save and Close"));
  cancelButton = new QPushButton(tr("Cancel"));

  // We dynamically create two lists of checkboxes as well, which represent potential properties.
  // Only variables that were not already selected as source and target nodes are included as options.
  QVectorIterator<QString> it(Qheader);
  while (it.hasNext()) {
    QPointer<QCheckBox> tempBoxOne = new QCheckBox(it.peekNext(), this);
    QPointer<QCheckBox> tempBoxTwo = new QCheckBox(it.next(), this);
    if (tempBoxOne->text() != sourceInput && tempBoxOne->text() != targetInput) {
      sourceVector.push_back(tempBoxOne);
    } else {
      delete tempBoxOne;
    }
    if (tempBoxTwo->text() != targetInput && tempBoxTwo->text() != sourceInput) {
      targetVector.push_back(tempBoxTwo);
      if (sourceInput == targetInput) {
	tempBoxTwo->setEnabled(false);
      }
    } else {
      delete tempBoxTwo;
    }
  }
  
  // We then set up the signals. Basically, save and close is the only signal that will send information from the properties dialog
  // to the main dialog.
  connect(saveCloseButton, SIGNAL(clicked()), this, SLOT(saveAndClose()));
  connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); // In case the user decides not to set properties.
  
  // Then we create our layout. 
  QPointer<QVBoxLayout> mainLayout = new QVBoxLayout;
  QPointer<QHBoxLayout> mainBodyLayout = new QHBoxLayout;
  QPointer<QVBoxLayout> mainBodyLeft = new QVBoxLayout;
  QPointer<QVBoxLayout> mainBodyRight = new QVBoxLayout;

  mainBodyLeft->addWidget(sourceLabel);
  QVectorIterator<QPointer<QCheckBox> > sI(sourceVector);
  while (sI.hasNext()) {
    mainBodyLeft->addWidget(sI.next());
  }
  
  mainBodyRight->addWidget(targetLabel);
  QVectorIterator<QPointer<QCheckBox> > tI(targetVector);
  while (tI.hasNext()) {
    mainBodyRight->addWidget(tI.next());
  }
  
  mainBodyLayout->addLayout(mainBodyLeft);
  mainBodyLayout->addLayout(mainBodyRight);
  mainLayout->addLayout(mainBodyLayout);
  QPointer<QHBoxLayout> lowerLayout = new QHBoxLayout;
  lowerLayout->addWidget(saveCloseButton);
  lowerLayout->addWidget(cancelButton);
  mainLayout->addLayout(lowerLayout);

  setLayout(mainLayout);
  setWindowTitle(tr("Set Properties"));
  setFixedHeight(sizeHint().height());
  // And that finishes our constructor
}
OptionDialog::OptionDialog(QWidget* parent)
{
   int i;

   // I need a lot of control over what is displayed on the DbConfig dialog.
   // Maybe designer can do it? No idea. So I did this hybrid model, and I
   // think it will end up biting my ...
   // anyway. It isn't pretty
   setupUi(this);
   createPostgresElements();
   createSQLiteElements();

   if( parent != 0 )
   {
      setWindowIcon(parent->windowIcon());
   }

   ndxToLangCode <<
      "ca" <<
      "cs" <<
      "da" <<
      "de" <<
      "el" <<
      "en" <<
      "es" <<
      "et" <<
      "eu" <<
      "fr" <<
      "gl" <<
      "hu" <<
      "it" <<
      "lv" <<
      "nb" <<
      "nl" <<
      "pl" <<
      "pt" <<
      "ru" <<
      "sr" <<
      "sv" <<
      "tr" <<
      "zh";

   // Do this just to have model indices to set icons.
   comboBox_lang->addItems(ndxToLangCode);
   // MUST correspond to ndxToLangCode.
   langIcons <<
      /*ca*/ QIcon(":images/flagCatalonia.svg") <<
      /*cs*/ QIcon(":images/flagCzech.svg") <<
      /*da*/ QIcon() <<
      /*de*/ QIcon(":images/flagGermany.svg") <<
      /*el*/ QIcon(":images/flagGreece.svg") <<
      /*en*/ QIcon(":images/flagUK.svg") <<
      /*es*/ QIcon(":images/flagSpain.svg") <<
      /*et*/ QIcon() <<
      /*eu*/ QIcon() <<
      /*fr*/ QIcon(":images/flagFrance.svg") <<
      /*gl*/ QIcon() <<
      /*hu*/ QIcon() <<
      /*it*/ QIcon(":images/flagItaly.svg") <<
      /*lv*/ QIcon() <<
      /*nb*/ QIcon() <<
      /*nl*/ QIcon(":images/flagNetherlands.svg") <<
      /*pl*/ QIcon(":images/flagPoland.svg") <<
      /*pt*/ QIcon(":images/flagBrazil.svg") <<
      /*ru*/ QIcon(":images/flagRussia.svg") <<
      /*sr*/ QIcon() <<
      /*sv*/ QIcon() <<
      /*tr*/ QIcon() <<
      /*zh*/ QIcon(":images/flagChina.svg");
   // Set icons.
   for( i = 0; i < langIcons.size(); ++i )
      comboBox_lang->setItemIcon(i, langIcons[i]);

   // Call this here to set up translatable strings.
   retranslate();

   // Populate combo boxes on the "Units" tab
   weightComboBox->addItem(tr("SI units"), QVariant(SI));
   weightComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   weightComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   temperatureComboBox->addItem(tr("Celsius"), QVariant(Celsius));
   temperatureComboBox->addItem(tr("Fahrenheit"), QVariant(Fahrenheit));

   volumeComboBox->addItem(tr("SI units"), QVariant(SI));
   volumeComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   volumeComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   gravityComboBox->addItem(tr("20C/20C Specific Gravity"), QVariant(Brewtarget::SG));
   gravityComboBox->addItem(tr("Plato/Brix/Balling"), QVariant(Brewtarget::PLATO));

   dateComboBox->addItem(tr("mm-dd-YYYY"), QVariant(Unit::displayUS));
   dateComboBox->addItem(tr("dd-mm-YYYY"), QVariant(Unit::displayImp));
   dateComboBox->addItem(tr("YYYY-mm-dd"), QVariant(Unit::displaySI));

   colorComboBox->addItem(tr("SRM"), QVariant(Brewtarget::SRM));
   colorComboBox->addItem(tr("EBC"), QVariant(Brewtarget::EBC));

   // Populate combo boxes on the "Formulas" tab
   ibuFormulaComboBox->addItem(tr("Tinseth's approximation"), QVariant(Brewtarget::TINSETH));
   ibuFormulaComboBox->addItem(tr("Rager's approximation"), QVariant(Brewtarget::RAGER));
   ibuFormulaComboBox->addItem(tr("Noonan's approximation"), QVariant(Brewtarget::NOONAN));

   colorFormulaComboBox->addItem(tr("Mosher's approximation"), QVariant(Brewtarget::MOSHER));
   colorFormulaComboBox->addItem(tr("Daniel's approximation"), QVariant(Brewtarget::DANIEL));
   colorFormulaComboBox->addItem(tr("Morey's approximation"), QVariant(Brewtarget::MOREY));

   connect( buttonBox, SIGNAL( accepted() ), this, SLOT( saveAndClose() ) );
   connect( buttonBox, SIGNAL( rejected() ), this, SLOT( cancel() ) );

   // database panel stuff
   comboBox_engine->addItem( tr("SQLite (default)"), QVariant(Brewtarget::SQLITE));
   comboBox_engine->addItem( tr("PostgreSQL"), QVariant(Brewtarget::PGSQL));
   connect( comboBox_engine, SIGNAL( currentIndexChanged(int) ), this, SLOT( setEngine(int) ) );
   connect( pushButton_testConnection, SIGNAL( clicked() ), this, SLOT(testConnection()));

   // figure out which database we have
   setDbDialog((Brewtarget::DBTypes)Brewtarget::option("dbType", Brewtarget::SQLITE).toInt());

   // Set the signals
   connect( checkBox_savePassword, SIGNAL(clicked(bool)), this, SLOT(savePassword(bool)));

   connect( btStringEdit_hostname, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_portnum, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_schema, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_dbname, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_username, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_password, SIGNAL( textModified() ), this, SLOT(testRequired()));

   connect( pushButton_browseDataDir, SIGNAL( clicked() ), this, SLOT( setDataDir() ) );
   connect( pushButton_browseBackupDir, SIGNAL( clicked() ), this, SLOT( setBackupDir() ) );
   connect( pushButton_resetToDefault, SIGNAL( clicked() ), this, SLOT( resetToDefault() ) );
   pushButton_testConnection->setEnabled(false);

}
OptionDialog::OptionDialog(QWidget* parent)
{
   int i;
   setupUi(this);

   if( parent != 0 )
   {
      setWindowIcon(parent->windowIcon());
   }

   ndxToLangCode <<
      "ca" <<
      "cs" <<
      "da" <<
      "de" <<
      "el" <<
      "en" <<
      "es" <<
      "et" <<
      "eu" <<
      "fr" <<
      "gl" <<
      "hu" <<
      "it" <<
      "lv" <<
      "nb" <<
      "nl" <<
      "pl" <<
      "pt" <<
      "ru" <<
      "sr" <<
      "sv" <<
      "tr" <<
      "zh";

   // Do this just to have model indices to set icons.
   comboBox_lang->addItems(ndxToLangCode);
   // MUST correspond to ndxToLangCode.
   langIcons <<
      /*ca*/ QIcon(":images/flagCatalonia.svg") <<
      /*cs*/ QIcon(":images/flagCzech.svg") <<
      /*da*/ QIcon() <<
      /*de*/ QIcon(":images/flagGermany.svg") <<
      /*el*/ QIcon(":images/flagGreece.svg") <<
      /*en*/ QIcon(":images/flagUK.svg") <<
      /*es*/ QIcon(":images/flagSpain.svg") <<
      /*et*/ QIcon() <<
      /*eu*/ QIcon() <<
      /*fr*/ QIcon(":images/flagFrance.svg") <<
      /*gl*/ QIcon() <<
      /*hu*/ QIcon() <<
      /*it*/ QIcon(":images/flagItaly.svg") <<
      /*lv*/ QIcon() <<
      /*nb*/ QIcon() <<
      /*nl*/ QIcon(":images/flagNetherlands.svg") <<
      /*pl*/ QIcon(":images/flagPoland.svg") <<
      /*pt*/ QIcon(":images/flagBrazil.svg") <<
      /*ru*/ QIcon(":images/flagRussia.svg") <<
      /*sr*/ QIcon() <<
      /*sv*/ QIcon() <<
      /*tr*/ QIcon() <<
      /*zh*/ QIcon(":images/flagChina.svg");
   // Set icons.
   for( i = 0; i < langIcons.size(); ++i )
      comboBox_lang->setItemIcon(i, langIcons[i]);

   // Call this here to set up translatable strings.
   retranslate();

   // Populate combo boxes on the "Units" tab
   weightComboBox->addItem(tr("SI units"), QVariant(SI));
   weightComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   weightComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   temperatureComboBox->addItem(tr("Celsius"), QVariant(Celsius));
   temperatureComboBox->addItem(tr("Fahrenheit"), QVariant(Fahrenheit));

   volumeComboBox->addItem(tr("SI units"), QVariant(SI));
   volumeComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   volumeComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   gravityComboBox->addItem(tr("20C/20C Specific Gravity"), QVariant(Brewtarget::SG));
   gravityComboBox->addItem(tr("Plato/Brix/Balling"), QVariant(Brewtarget::PLATO));

   dateComboBox->addItem(tr("mm-dd-YYYY"), QVariant(Unit::displayUS));
   dateComboBox->addItem(tr("dd-mm-YYYY"), QVariant(Unit::displayImp));
   dateComboBox->addItem(tr("YYYY-mm-dd"), QVariant(Unit::displaySI));

   colorComboBox->addItem(tr("SRM"), QVariant(Brewtarget::SRM));
   colorComboBox->addItem(tr("EBC"), QVariant(Brewtarget::EBC));

   // Populate combo boxes on the "Formulas" tab
   ibuFormulaComboBox->addItem(tr("Tinseth's approximation"), QVariant(Brewtarget::TINSETH));
   ibuFormulaComboBox->addItem(tr("Rager's approximation"), QVariant(Brewtarget::RAGER));
   ibuFormulaComboBox->addItem(tr("Noonan's approximation"), QVariant(Brewtarget::NOONAN));

   colorFormulaComboBox->addItem(tr("Mosher's approximation"), QVariant(Brewtarget::MOSHER));
   colorFormulaComboBox->addItem(tr("Daniel's approximation"), QVariant(Brewtarget::DANIEL));
   colorFormulaComboBox->addItem(tr("Morey's approximation"), QVariant(Brewtarget::MOREY));

   connect( buttonBox, SIGNAL( accepted() ), this, SLOT( saveAndClose() ) );
   connect( buttonBox, SIGNAL( rejected() ), this, SLOT( cancel() ) );
   connect( pushButton_dbDirBrowse, SIGNAL( clicked() ), this, SLOT( setDataDir() ) );
   connect( pushButton_dbDirDefault, SIGNAL( clicked() ), this, SLOT( defaultDataDir() ) );

}
Exemple #8
0
SettingsDialog::SettingsDialog(QWidget *parent)
              : QDialog(parent)
{
    wallphiller = qobject_cast<Wallphiller*>(parent);

    //Layout
    QVBoxLayout *vbox_main = new QVBoxLayout;
    setLayout(vbox_main);
    setWindowTitle(tr("Settings"));

    //Selection frame
    QGroupBox *grp_routine = new QGroupBox(tr("Wallpaper change routine"));
    vbox_main->addWidget(grp_routine);
    QVBoxLayout *vbox_routine = new QVBoxLayout;
    grp_routine->setLayout(vbox_routine);

    //Radio buttons
    QString auto_title = tr("Auto");
    QString auto_title_info;
    switch (wallphiller->desktopEnvironment())
    {
        case DE::Gnome:
        auto_title_info = "Gnome";
        break;

        case DE::Mate:
        auto_title_info = "Mate";
        break;

        case DE::Cinnamon:
        auto_title_info = "Cinnamon";
        break;

        case DE::KDE:
        auto_title_info = "KDE";
        break;

        case DE::XFCE:
        auto_title_info = "XFCE";
        break;

        case DE::LXDE:
        auto_title_info = "LXDE";
        break;

        case DE::Windows:
        auto_title_info = "Windows";
        break;

        case DE::None:
        auto_title_info = tr("not detected");
        break;
    }
    if (!auto_title_info.isEmpty())
    {
        auto_title += " (" + auto_title_info + ")";
    }
    opt_auto = new QRadioButton(auto_title);
    vbox_routine->addWidget(opt_auto);
    opt_command = new QRadioButton(tr("Custom command"));
    vbox_routine->addWidget(opt_command);

    //Radio button actions
    connect(opt_auto,
            SIGNAL(toggled(bool)),
            SLOT(enableRoutineAuto(bool)));
    connect(opt_command,
            SIGNAL(toggled(bool)),
            SLOT(enableRoutineCommand(bool)));

    //Custom command field
    txt_command = new QLineEdit;
    txt_command->setPlaceholderText(tr("command --option %f"));
    txt_command->setToolTip(tr(
        "Enter a custom command that will be run to change your wallpaper. "
        "%f will be replaced with a local file path, "
        "%u will be replaced with the path formatted as url - both quoted."));
    txt_command->setEnabled(false);
    vbox_routine->addWidget(txt_command);
    QString saved_command = wallphiller->changeRoutineCommand();
    connect(txt_command,
            SIGNAL(editingFinished()),
            SLOT(checkRoutineCommand()));
    txt_command->setText(saved_command);

    //Saved routine
    QString saved_routine = wallphiller->changeRoutine();
    if (saved_routine == "command")
    {
        opt_command->setChecked(true);
    }
    else
    {
        opt_auto->setChecked(true);
    }

    //Interval frame
    QGroupBox *grp_interval = new QGroupBox(tr("Interval"));
    vbox_main->addWidget(grp_interval);
    QFormLayout *interval_form_layout = new QFormLayout;
    grp_interval->setLayout(interval_form_layout);

    //Interval field
    QHBoxLayout *hbox_interval = new QHBoxLayout;
    interval_form_layout->addRow(tr("Interval"), hbox_interval);
    txt_interval_value = new QSpinBox;
    txt_interval_value->setMinimum(0);
    txt_interval_value->setMaximum(999);
    new_interval_value = wallphiller->intervalValue();
    txt_interval_value->setValue(new_interval_value);
    hbox_interval->addWidget(txt_interval_value);
    connect(txt_interval_value,
            SIGNAL(valueChanged(int)),
            SLOT(checkIntervalValue(int)));
    cmb_interval_unit = new QComboBox;
    cmb_interval_unit->addItem(tr("startup/manual"), "ONCE");
    cmb_interval_unit->addItem(tr("minutes"), "MINUTES");
    cmb_interval_unit->addItem(tr("hours"), "HOURS");
    cmb_interval_unit->addItem(tr("New York minutes"), "NYMINUTES");
    cmb_interval_unit->addItem(tr("nanocenturies"), "NANOCENTURIES");
    cmb_interval_unit->setToolTip(tr(
        "Define how often your wallpaper should be changed automatically. "
        "Select \"startup\" to only have it changed once "
        "on program startup."));
    cmb_interval_unit->setCurrentIndex(
        cmb_interval_unit->findData(wallphiller->intervalUnit()));
    hbox_interval->addWidget(cmb_interval_unit);
    connect(cmb_interval_unit,
            SIGNAL(currentIndexChanged(int)),
            SLOT(checkIntervalUnit(int)));
    checkIntervalUnit(cmb_interval_unit->currentIndex());

    //Cache frame
    QGroupBox *grp_cache = new QGroupBox(tr("Cache"));
    vbox_main->addWidget(grp_cache);
    QFormLayout *cache_layout = new QFormLayout;
    grp_cache->setLayout(cache_layout);

    //Cache limit
    txt_cache_limit = new QSpinBox;
    txt_cache_limit->setMinimum(1);
    txt_cache_limit->setMaximum(10 * 1024); //10 GB limit
    new_cache_limit = wallphiller->cacheLimit(); //limit in MB
    txt_cache_limit->setValue(new_cache_limit);
    txt_cache_limit->setToolTip(tr(
        "Enter the total amount of memory (in MB) that may be used "
        "for the previews. At least 10 MB are recommended. "
        "A low value will save some memory while the program is running."));
    cache_layout->addRow(tr("Cache limit (MB)"), txt_cache_limit);
    connect(txt_cache_limit,
            SIGNAL(valueChanged(int)),
            SLOT(checkCacheLimit(int)));

    //Horizontal line
    QFrame *hline = new QFrame;
    hline->setFrameShape(QFrame::HLine);
    vbox_main->addWidget(hline);

    //Buttons
    button_box = new QDialogButtonBox;
    vbox_main->addWidget(button_box);
    QPushButton *btn_ok = button_box->addButton(QDialogButtonBox::Ok);
    connect(btn_ok, SIGNAL(clicked()), SLOT(saveAndClose()));
    QPushButton *btn_cancel =
        button_box->addButton(QDialogButtonBox::Cancel);
    connect(btn_cancel, SIGNAL(clicked()), SLOT(cancel()));

    //Quit on close (don't keep running invisibly by default)
    setAttribute(Qt::WA_DeleteOnClose); //quit on close

}