Exemplo n.º 1
0
AuthorEditor::AuthorEditor(QWidget *parent) :
    QLineEdit(parent)
{
    // Setup the note title editor
    QPalette pal;
    //pal.setColor(QPalette::Text, QColor(102,153,255));
    //pal.setColor(QPalette::Text, QColor(14,28,209));
    pal.setColor(backgroundRole(), QPalette::Base);
    setPalette(pal);

    QFont f = font();
    f.setPointSize(8);
    setFont(f);

    inactiveColor = "QLineEdit {background-color: transparent; border-radius: 0px;} ";
    activeColor = "QLineEdit {border: 1px solid #808080; background-color: white; border-radius: 4px;} ";
    this->setCursor(Qt::PointingHandCursor);
    this->setStyleSheet(inactiveColor);

    defaultText = QString(tr("Click to set Author..."));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(textModified(QString)));
    //this->textModified(defaultText);

    connect(this, SIGNAL(focussed(bool)), this, SLOT(gainedFocus(bool)));
    hide();
}
Exemplo n.º 2
0
//****************************************************
//* Constructor
//****************************************************
TagEditorNewTag::TagEditorNewTag(QWidget *parent) :
    QLineEdit(parent)
{
    account = 0;
    this->setCursor(Qt::PointingHandCursor);
    // Setup the note title editor
    QPalette pal;
    pal.setColor(backgroundRole(), QPalette::Base);
    setPalette(pal);

    QFont f = font();
    f.setPointSize(8);
    setFont(f);

    inactiveColor = "QLineEdit {background-color: transparent; border-radius: 0px;} ";
    activeColor = "QLineEdit {border: 1px solid #808080; background-color: white; border-radius: 4px;} ";
    this->setStyleSheet(inactiveColor);

    defaultText = QString(tr("Click to add..."));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(textModified(QString)));
    this->textModified(defaultText);

    connect(this, SIGNAL(focussed(bool)), this, SLOT(gainedFocus(bool)));
    completer = NULL;
    loadCompleter();
    hide();
}
Exemplo n.º 3
0
//****************************************************
//* Constructor
//****************************************************
TagEditorNewTag::TagEditorNewTag(QWidget *parent) :
    QLineEdit(parent)
{
    QLOG_TRACE_IN() << typeid(*this).name();
    account = 0;
    this->setCursor(Qt::PointingHandCursor);
    // Setup the note title editor
    QPalette pal;
    pal.setColor(backgroundRole(), QPalette::Base);
    setPalette(pal);

    this->setFont(global.getGuiFont(font()));

    inactiveColor = "QLineEdit {background-color: transparent; border-radius: 0px;} ";
    activeColor = "QLineEdit {border: 1px solid #808080; background-color: white; border-radius: 4px;} ";
    this->setStyleSheet(inactiveColor);

    this->setPlaceholderText(tr("Click to add tag..."));
    connect(this, SIGNAL(textChanged(QString)), this, SLOT(textModified(QString)));

//    connect(this, SIGNAL(focussed(bool)), this, SLOT(gainedFocus(bool)));
    completer = new QCompleter(this);
    connect(completer, SIGNAL(activated(QString)), this, SLOT(mouseCompleterSelection(QString)));
    loadCompleter();
    connect(this, SIGNAL(returnPressed()), this, SLOT(enterPressed()));
    hide();
    QLOG_TRACE_OUT() << typeid(*this).name();
}
Exemplo n.º 4
0
void AuthorEditor::focusOutEvent(QFocusEvent *e)
{
  QLineEdit::focusOutEvent(e);
  this->setCursor(Qt::PointingHandCursor);
  setStyleSheet(inactiveColor);
  textModified(text());
  emit(focussed(false));
}
Exemplo n.º 5
0
/** setup principal GUI elements
 */
void spqrMainWindow::make_tabs() {
    delete tabs;

    setCentralWidget(tabs = new QStackedWidget_KeybTabs);
    connect(tabs, SIGNAL(currentChanged(int)), SLOT(currentChanged(int)));

    tabs->addWidget(new CodeMirrorFile);
    tabs->addWidget(con);
    tabs->addWidget(new HelpDocView);

    connect(source(), SIGNAL(helpRequestTopic(QString)), SLOT(helpRequest(QString)));
    connect(source(), SIGNAL(textModified()), SLOT(textModified()));
    connect(source(), SIGNAL(userMessage(CodeMirror::messageKind,QString)), SLOT(userMessage(CodeMirror::messageKind,QString)));

    connect(helpDoc(), SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
    connect(helpDoc(), SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
    connect(helpDoc(), SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
    connect(helpDoc(), SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
}
Exemplo n.º 6
0
void BtLineEdit::lineChanged(Unit::unitDisplay oldUnit, Unit::unitScale oldScale)
{
   // This is where it gets hard
   double val = -1.0;
   QString amt;
   bool force = Brewtarget::hasUnits(text());
   bool ok = false;
   bool wasChanged = sender() == this;

   // editingFinished happens on focus being lost, regardless of anything
   // being changed. I am hoping this short circuits properly and we do
   // nothing if nothing changed.
   if ( sender() == this && ! isModified() )
   {
      return;
   }

   if (text().isEmpty())
   {
      return;
   }

   // The idea here is we need to first translate the field into a known
   // amount (aka to SI) and then into the unit we want.
   switch( _type )
   {
      case Unit::Mass:
      case Unit::Volume:
      case Unit::Temp:
      case Unit::Time:
      case Unit::Density:
         val = toSI(oldUnit,oldScale,force);
         amt = displayAmount(val,3);
         break;
      case Unit::Color:
         val = toSI(oldUnit,oldScale,force);
         amt = displayAmount(val,0);
         break;
      case Unit::String:
         amt = text();
         break;
      case Unit::None:
      default:
         val = Brewtarget::toDouble(text(),&ok);
         if ( ! ok )
            Brewtarget::logW( QString("%1: failed to convert %2 (%3:%4) to double").arg(Q_FUNC_INFO).arg(text()).arg(_section).arg(_editField) );
         amt = displayAmount(val);
   }
   QLineEdit::setText(amt);

   if ( wasChanged ) {
      emit textModified();
   }
}
Exemplo n.º 7
0
BrewDayScrollWidget::BrewDayScrollWidget(QWidget* parent)
   : QWidget(parent), doc(new QWebView())
{
   setupUi(this);
   setObjectName("BrewDayScrollWidget");
   recObs = 0;

   connect( listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(showInstruction(int)) );
   // connect( plainTextEdit, SIGNAL(textChanged()), this, SLOT(saveInstruction()) );
   connect(btTextEdit,SIGNAL(textModified()), this, SLOT(saveInstruction()));
   connect( pushButton_insert, SIGNAL(clicked()), this, SLOT(insertInstruction()) );
   connect( pushButton_remove, SIGNAL(clicked()), this, SLOT(removeSelectedInstruction()) );
   connect( pushButton_up, SIGNAL(clicked()), this, SLOT(pushInstructionUp()) );
   connect( pushButton_down, SIGNAL(clicked()), this, SLOT(pushInstructionDown()) );
   connect( pushButton_generateInstructions, SIGNAL(clicked()), this, SLOT(generateInstructions()) );
}
Exemplo n.º 8
0
void AuthorEditor::gainedFocus(bool focus) {
    if (focus && this->text() == defaultText)
        textModified("");
    if (!focus && this->text().trimmed() == "")
        textModified(defaultText);
}
Exemplo n.º 9
0
RecipeExtrasWidget::RecipeExtrasWidget(QWidget* parent)
   : QWidget(parent), recipe(0)
{
   setupUi(this);

   ratingChanged = false;

   connect( lineEdit_age,        SIGNAL(textModified()), this, SLOT(updateAge()));
   connect( lineEdit_ageTemp,    SIGNAL(textModified()), this, SLOT(updateAgeTemp()));
   connect( lineEdit_asstBrewer, SIGNAL(textModified()), this, SLOT(updateBrewerAsst()) );
   connect( lineEdit_brewer,     SIGNAL(textModified()), this, SLOT(updateBrewer()) );
   connect( lineEdit_carbVols,   SIGNAL(textModified()), this, SLOT(updateCarbonation()) );
   connect( lineEdit_primaryAge, SIGNAL(textModified()), this, SLOT(updatePrimaryAge()) );
   connect( lineEdit_primaryTemp,SIGNAL(textModified()), this, SLOT(updatePrimaryTemp()) );
   connect( lineEdit_secAge,     SIGNAL(textModified()), this, SLOT(updateSecondaryAge()) );
   connect( lineEdit_secTemp,    SIGNAL(textModified()), this, SLOT(updateSecondaryTemp()) );
   connect( lineEdit_tertAge,    SIGNAL(textModified()), this, SLOT(updateTertiaryAge()) );
   connect( lineEdit_tertTemp,   SIGNAL(textModified()), this, SLOT(updateTertiaryTemp()) );

   connect( spinBox_tasteRating, SIGNAL(valueChanged(int)), this, SLOT(changeRatings(int)) );
   connect( spinBox_tasteRating, SIGNAL(editingFinished()), this, SLOT(updateTasteRating()) );

   connect( dateEdit_date, SIGNAL(dateChanged(const QDate& )), this, SLOT(updateDate(const QDate&)) );

   connect(btTextEdit_notes, SIGNAL(textModified()), this, SLOT(updateNotes()));
   connect(btTextEdit_tasteNotes, SIGNAL(textModified()), this, SLOT(updateTasteNotes()));

}
Exemplo n.º 10
0
//*******************************************************
//* Event listener for when the editor gains focus
//*******************************************************
void TagEditorNewTag::gainedFocus(bool focus) {
    if (focus && text() == defaultText)
        textModified("");
    if (!focus && text().trimmed() == "")
        textModified(defaultText);
}
Exemplo n.º 11
0
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);

}
Exemplo n.º 12
0
void BtLineEdit::lineChanged(Unit::unitDisplay oldUnit, Unit::unitScale oldScale)
{
   // This is where it gets hard
   double val = -1.0;
   QString amt;
   bool force = false;
   bool ok = false;

   // editingFinished happens on focus being lost, regardless of anything
   // being changed. I am hoping this short circuits properly and we do
   // nothing if nothing changed.
   if ( sender() == this && ! isModified() )
   {
      return;
   }

   // If we are here because somebody else sent the signal (ie, a label) or we
   // generated the signal but nothing has changed then don't try to guess the
   // units.
   if ( sender() != this )
   {
      force = true;
   }

   if ( _section.isEmpty() )
      initializeSection();

   if ( _property.isEmpty() )
      initializeProperties();

   if (text().isEmpty())
   {
      return;
   }

   // The idea here is we need to first translate the field into a known
   // amount (aka to SI) and then into the unit we want.
   switch( _type )
   {
      case MASS:
      case VOLUME:
      case TEMPERATURE:
      case TIME:
         val = toSI(oldUnit,oldScale,force);
         amt = displayAmount(val,3);
         break;
      case DENSITY:
      case COLOR:
         val = toSI(oldUnit,oldScale,force);
         amt = displayAmount(val,0);
         break;
      case STRING:
         amt = text();
         break;
      case GENERIC:
      default:
         val = Brewtarget::toDouble(text(),&ok);
         if ( ! ok )
            Brewtarget::logW( QString("BtLineEdit::lineChanged: failed to convert %1 toDouble").arg(text()) );
         amt = displayAmount(val);
   }
   QLineEdit::setText(amt);

   if ( ! force )
   {
      emit textModified();
   }
}
Exemplo n.º 13
0
EquipmentEditor::EquipmentEditor(QWidget* parent, bool singleEquipEditor)
   : QDialog(parent)
{
   doLayout();

   if( singleEquipEditor )
   {
      //horizontalLayout_equipments->setVisible(false);
      for(int i = 0; i < horizontalLayout_equipments->count(); ++i)
      {
         QWidget* w = horizontalLayout_equipments->itemAt(i)->widget();
         if(w)
            w->setVisible(false);
      }

      pushButton_new->setVisible(false);
   }

   // Set grain absorption label based on units.
   Unit* weightUnit = 0;
   Unit* volumeUnit = 0;
   Brewtarget::getThicknessUnits( &volumeUnit, &weightUnit );
   label_absorption->setText(tr("Grain absorption (%1/%2)").arg(volumeUnit->getUnitName()).arg(weightUnit->getUnitName()));

   equipmentListModel = new EquipmentListModel(equipmentComboBox);
   equipmentSortProxyModel = new BeerXMLSortProxyModel(equipmentListModel);
   equipmentComboBox->setModel(equipmentSortProxyModel);

   obsEquip = 0;

   // Connect all the edit boxen
   connect(lineEdit_boilTime,SIGNAL(textModified()),this,SLOT(updateCheckboxRecord()));
   connect(lineEdit_evaporationRate,SIGNAL(textModified()),this,SLOT(updateCheckboxRecord()));
   connect(lineEdit_topUpWater,SIGNAL(textModified()),this,SLOT(updateCheckboxRecord()));
   connect(lineEdit_trubChillerLoss,SIGNAL(textModified()),this,SLOT(updateCheckboxRecord()));

   // Set up the buttons
   connect( pushButton_save, SIGNAL( clicked() ), this, SLOT( save() ) );
   connect( pushButton_new, SIGNAL( clicked() ), this, SLOT( newEquipment() ) );
   connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) );
   connect( pushButton_remove, SIGNAL( clicked() ), this, SLOT( removeEquipment() ) );
   connect( pushButton_absorption, SIGNAL( clicked() ), this, SLOT( resetAbsorption() ) );
   connect( equipmentComboBox, SIGNAL(activated(const QString&)), this, SLOT( equipmentSelected() ) );

   // Check boxen
   connect(checkBox_calcBoilVolume, SIGNAL(stateChanged(int)), this, SLOT(updateCheckboxRecord()));
   connect(checkBox_defaultEquipment, SIGNAL(stateChanged(int)), this, SLOT(updateDefaultEquipment(int)));

   // Labels
   connect(label_boilSize, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_boilSize, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_batchSize, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_batchSize, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_evaporationRate, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_evaporationRate, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_topUpWater, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_topUpWater, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_boilingPoint, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_boilingPoint, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_tunVolume, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_tunVolume, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_tunWeight, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_tunWeight, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_lauterDeadspace, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_lauterDeadspace, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_trubChillerLoss, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_trubChillerLoss, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_topUpKettle, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_topUpKettle, SLOT(lineChanged(unitDisplay,unitScale)));
   connect(label_boilTime, SIGNAL(labelChanged(unitDisplay,unitScale)), lineEdit_boilTime, SLOT(lineChanged(unitDisplay,unitScale)));

   QMetaObject::connectSlotsByName(this);

   // make sure the dialog gets populated the first time it's opened from the menu
   equipmentSelected();
}