示例#1
0
  private void createActions() {
    addImagesAct = new QAction(tr("&Add Images..."), this);
    addImagesAct.setShortcut(tr("Ctrl+A"));
    addImagesAct.triggered.connect(this, "addImages()");

    removeAllImagesAct = new QAction(tr("&Remove All Images"), this);
    removeAllImagesAct.setShortcut(tr("Ctrl+R"));
    removeAllImagesAct.triggered.connect(this, "removeAllImages()");

    exitAct = new QAction(tr("&Quit"), this);
    exitAct.setShortcut(tr("Ctrl+Q"));
    exitAct.triggered.connect(this, "close()");

    styleActionGroup = new QActionGroup(this);
    for (String styleName : QStyleFactory.keys()) {
      QAction action = new QAction(styleActionGroup);
      action.setText(styleName + " Style");
      action.setData(styleName);
      action.setCheckable(true);
      action.triggered.connect(this, "changeStyle(boolean)");
    }

    guessModeStateAct = new QAction(tr("&Guess Image Mode/State"), this);
    guessModeStateAct.setCheckable(true);
    guessModeStateAct.setChecked(true);

    aboutAct = new QAction(tr("&About"), this);
    aboutAct.triggered.connect(this, "about()");

    aboutQtAct = new QAction(tr("About &Qt"), this);
    aboutQtAct.triggered.connect(QApplication.instance(), "aboutQt()");
  }
示例#2
0
  private void checkCurrentStyle() {
    for (QAction action : styleActionGroup.actions()) {
      String styleName = action.data().toString();
      QStyle candidate = QStyleFactory.create(styleName);

      if (candidate.objectName().equals(QApplication.style().objectName())) {
        action.trigger();
        return;
      }
    }
  }
示例#3
0
  private void changeStyle(boolean checked) {
    if (!checked) return;

    QAction action = (QAction) QSignalEmitter.signalSender();
    QStyle style = QStyleFactory.create((String) action.data());

    if (style != null) {
      QApplication.setStyle(style);
      QApplication.setPalette(style.standardPalette());
    }

    setTextOnRadioButtons();

    changeSize(true);
  }