public void setupUi(QDialog AboutTextRecognition) {
    AboutTextRecognition.setObjectName("AboutTextRecognition");
    AboutTextRecognition.resize(
        new QSize(622, 412).expandedTo(AboutTextRecognition.minimumSizeHint()));
    AboutTextRecognition.setAutoFillBackground(false);
    gridLayout = new QGridLayout(AboutTextRecognition);
    gridLayout.setObjectName("gridLayout");
    gridLayout1 = new QGridLayout();
    gridLayout1.setObjectName("gridLayout1");
    textEdit = new QTextEdit(AboutTextRecognition);
    textEdit.setObjectName("textEdit");
    QPalette palette = new QPalette();
    palette.setColor(
        QPalette.ColorGroup.Active, QPalette.ColorRole.Base, new QColor(224, 223, 227));
    palette.setColor(
        QPalette.ColorGroup.Inactive, QPalette.ColorRole.Base, new QColor(224, 223, 227));
    palette.setColor(
        QPalette.ColorGroup.Disabled, QPalette.ColorRole.Base, new QColor(224, 223, 227));
    textEdit.setPalette(palette);
    textEdit.setAcceptDrops(true);
    textEdit.setFrameShape(com.trolltech.qt.gui.QFrame.Shape.Box);
    textEdit.setUndoRedoEnabled(false);
    textEdit.setReadOnly(true);

    gridLayout1.addWidget(textEdit, 0, 1, 2, 1);

    spacerItem =
        new QSpacerItem(
            20,
            221,
            com.trolltech.qt.gui.QSizePolicy.Policy.Minimum,
            com.trolltech.qt.gui.QSizePolicy.Policy.Expanding);

    gridLayout1.addItem(spacerItem, 1, 0, 1, 1);

    gridLayout.addLayout(gridLayout1, 0, 0, 1, 3);

    spacerItem1 =
        new QSpacerItem(
            40,
            20,
            com.trolltech.qt.gui.QSizePolicy.Policy.Expanding,
            com.trolltech.qt.gui.QSizePolicy.Policy.Minimum);

    gridLayout.addItem(spacerItem1, 1, 0, 1, 1);

    okButton = new QPushButton(AboutTextRecognition);
    okButton.setObjectName("okButton");

    gridLayout.addWidget(okButton, 1, 1, 1, 1);

    spacerItem2 =
        new QSpacerItem(
            40,
            20,
            com.trolltech.qt.gui.QSizePolicy.Policy.Expanding,
            com.trolltech.qt.gui.QSizePolicy.Policy.Minimum);

    gridLayout.addItem(spacerItem2, 1, 2, 1, 1);

    retranslateUi(AboutTextRecognition);
    okButton.clicked.connect(AboutTextRecognition, "accept()");

    AboutTextRecognition.connectSlotsByName();
  } // setupUi
Пример #2
0
 private void setErrorMessage(final String errorMessage) {
   lblStatus.setText(errorMessage);
   QPalette palette = lblStatus.palette();
   palette.setBrush(ColorRole.WindowText, new QBrush(QColor.red));
   lblStatus.setPalette(palette);
 }
  @Override
  public void paint(QPainter painter, QStyleOptionViewItem option, QModelIndex index) {
    // if (log.isTraceEnabled())
    // log.trace("paint(): index=" + index + ", option.palette().highlight()=" +
    // option.palette().highlight());
    Object data = index.data();
    QModelIndex sourceIndex = modelManager.getProxyModel().mapToSource(index);
    SongRecord songRecord =
        (SongRecord) ((RecordTableModelManager) modelManager).getRecordForRow(sourceIndex.row());
    if (ProfileWidgetUI.instance.getCurrentProfile() instanceof SongProfile) {
      SongProfile relativeProfile = (SongProfile) ProfileWidgetUI.instance.getCurrentProfile();
      QStyle.State state = option.state();
      if (RE3Properties.getBoolean("highlight_broken_file_links")) {
        if (modelManager instanceof RecordTableModelManager) {
          SearchRecord searchRecord =
              (SearchRecord)
                  ((RecordTableModelManager) modelManager).getRecordForRow(sourceIndex.row());
          if (searchRecord instanceof SongRecord) {
            SongRecord song = (SongRecord) searchRecord;
            if (!song.isExternalItem() && !song.hasValidSongFilename()) {
              if (!state.isSet(QStyle.StateFlag.State_Selected)) {
                state.set(QStyle.StateFlag.State_Selected);
                option.setState(state);
                QPalette p = option.palette();
                p.setColor(QPalette.ColorRole.Highlight, BROKEN_FILELINKS_COLOR.getQColor());
                option.setPalette(p);
              }
            }
          }
        }
      }
      if (relativeProfile != null) {
        boolean isMixout = false;
        float mixoutRating = 0.0f;
        for (MixoutRecord mixout : relativeProfile.getMixouts()) {
          if (mixout.getToSongUniqueId() == songRecord.getUniqueId()) {
            isMixout = true;
            mixoutRating = mixout.getRatingValue().getRatingNormalized();
            break;
          }
        }
        if (isMixout && !(parent instanceof MixoutTableWidget)) {
          if (!option.state().isSet(QStyle.StateFlag.State_Selected)) {
            mixoutRating = 0.75f * mixoutRating + 0.25f;
            Color baseColor = new Color(option.palette().color(QPalette.ColorRole.Base));
            painter.fillRect(
                option.rect(), mixoutColor.getLinearGradient(baseColor, mixoutRating).getQColor());
          }
        } else {
          // target bpm/key/time sig
          Bpm targetBpm = ProfileWidgetUI.instance.getStageWidget().getCurrentBpm();
          if (!targetBpm.isValid()) targetBpm = relativeProfile.getBpmEnd();
          if (!targetBpm.isValid()) targetBpm = relativeProfile.getBpmStart();
          Key targetKey = ProfileWidgetUI.instance.getStageWidget().getCurrentKey();
          if (!targetKey.isValid()) targetKey = relativeProfile.getEndKey();
          if (!targetKey.isValid()) targetKey = relativeProfile.getStartKey();

          if (parent instanceof CompatibleSongTableWidget) {
            CompatibleSongTableWidget compatibleWidget = (CompatibleSongTableWidget) parent;
            if ((compatibleWidget.getShowType()
                    == CompatibleSongTableWidget.COMPATIBLE_TYPE_ALL_HARMONIC)
                || (compatibleWidget.getShowType()
                    == CompatibleSongTableWidget.COMPATIBLE_TYPE_BPM_ONLY)) {
              SongKeyRelation keyRelation =
                  SongKeyRelation.getSongKeyRelation(songRecord, targetBpm, targetKey);
              if (keyRelation.isCompatible()) {
                float percentInKey =
                    (0.5f - Math.abs(keyRelation.getBestKeyRelation().getDifference())) * 2.0f;
                if (log.isTraceEnabled()) log.trace("paint(): percentInKey=" + percentInKey);
                if (!option.state().isSet(QStyle.StateFlag.State_Selected)) {
                  Color baseColor = new Color(option.palette().color(QPalette.ColorRole.Base));
                  painter.fillRect(
                      option.rect(),
                      harmonicMatchColor.getLinearGradient(baseColor, percentInKey).getQColor());
                }
              }
            } else if (compatibleWidget.getShowType()
                == CompatibleSongTableWidget.COMPATIBLE_TYPE_KEYLOCK_ONLY) {
              KeyRelation keyRelation =
                  Key.getClosestKeyRelation(
                      targetBpm.getBpmValue(),
                      songRecord.getStartKey(),
                      targetBpm.getBpmValue(),
                      targetKey);
              if (keyRelation.isCompatible()) {
                float percentInKey = (0.5f - Math.abs(keyRelation.getDifference())) * 2.0f;
                if (log.isTraceEnabled()) log.trace("paint(): percentInKey=" + percentInKey);
                if (!option.state().isSet(QStyle.StateFlag.State_Selected)) {
                  Color baseColor = new Color(option.palette().color(QPalette.ColorRole.Base));
                  painter.fillRect(
                      option.rect(),
                      harmonicMatchColor.getLinearGradient(baseColor, percentInKey).getQColor());
                }
              }
            } else if (compatibleWidget.getShowType()
                == CompatibleSongTableWidget.COMPATIBLE_TYPE_NO_KEYLOCK) {
              KeyRelation keyRelation =
                  Key.getClosestKeyRelation(
                      songRecord.getStartBpm(),
                      songRecord.getStartKey(),
                      targetBpm.getBpmValue(),
                      targetKey);
              if (keyRelation.isCompatible()) {
                float percentInKey = (0.5f - Math.abs(keyRelation.getDifference())) * 2.0f;
                if (log.isTraceEnabled()) log.trace("paint(): percentInKey=" + percentInKey);
                if (!option.state().isSet(QStyle.StateFlag.State_Selected)) {
                  Color baseColor = new Color(option.palette().color(QPalette.ColorRole.Base));
                  painter.fillRect(
                      option.rect(),
                      harmonicMatchColor.getLinearGradient(baseColor, percentInKey).getQColor());
                }
              }
            }
          } else {
            if (RE3Properties.getBoolean("enable_harmonic_coloring_in_search_table")
                && CentralWidgetUI.instance.isDetailsTabOpen()) {
              SongKeyRelation keyRelation =
                  SongKeyRelation.getSongKeyRelation(songRecord, targetBpm, targetKey);
              if (keyRelation.isCompatible()) {
                float percentInKey =
                    (0.5f - Math.abs(keyRelation.getBestKeyRelation().getDifference())) * 2.0f;
                if (log.isTraceEnabled()) log.trace("paint(): percentInKey=" + percentInKey);
                if (!option.state().isSet(QStyle.StateFlag.State_Selected)) {
                  Color baseColor = new Color(option.palette().color(QPalette.ColorRole.Base));
                  painter.fillRect(
                      option.rect(),
                      harmonicMatchColor.getLinearGradient(baseColor, percentInKey).getQColor());
                }
              }
            }
          }
        }
      }
    }
    super.paint(painter, option, index);
  }