Пример #1
0
  private void changeSize(boolean checked) {
    if (!checked) return;

    int extent;

    if (otherRadioButton.isChecked()) {
      extent = otherSpinBox.value();
    } else {
      QStyle.PixelMetric metric;

      if (smallRadioButton.isChecked()) {
        metric = QStyle.PixelMetric.PM_SmallIconSize;
      } else if (largeRadioButton.isChecked()) {
        metric = QStyle.PixelMetric.PM_LargeIconSize;
      } else if (toolBarRadioButton.isChecked()) {
        metric = QStyle.PixelMetric.PM_ToolBarIconSize;
      } else if (listViewRadioButton.isChecked()) {
        metric = QStyle.PixelMetric.PM_ListViewIconSize;
      } else if (iconViewRadioButton.isChecked()) {
        metric = QStyle.PixelMetric.PM_IconViewIconSize;
      } else {
        metric = QStyle.PixelMetric.PM_TabBarIconSize;
      }
      extent = QApplication.style().pixelMetric(metric);
    }
    previewArea.setSize(new QSize(extent, extent));
    otherSpinBox.setEnabled(otherRadioButton.isChecked());
  }
Пример #2
0
  private void createIconSizeGroupBox() {
    iconSizeGroupBox = new QGroupBox(tr("Icon Size"));

    smallRadioButton = new QRadioButton();
    largeRadioButton = new QRadioButton();
    toolBarRadioButton = new QRadioButton();
    listViewRadioButton = new QRadioButton();
    iconViewRadioButton = new QRadioButton();
    tabBarRadioButton = new QRadioButton();
    otherRadioButton = new QRadioButton(tr("Other:"));

    otherSpinBox = new IconSizeSpinBox();
    otherSpinBox.setRange(8, 128);
    otherSpinBox.setValue(64);

    smallRadioButton.toggled.connect(this, "changeSize(boolean)");
    largeRadioButton.toggled.connect(this, "changeSize(boolean)");
    toolBarRadioButton.toggled.connect(this, "changeSize(boolean)");
    listViewRadioButton.toggled.connect(this, "changeSize(boolean)");
    iconViewRadioButton.toggled.connect(this, "changeSize(boolean)");
    tabBarRadioButton.toggled.connect(this, "changeSize(boolean)");
    otherRadioButton.toggled.connect(this, "changeSize(boolean)");
    otherSpinBox.valueChanged.connect(this, "changeSize(int)");

    QHBoxLayout otherSizeLayout = new QHBoxLayout();
    otherSizeLayout.addWidget(otherRadioButton);
    otherSizeLayout.addWidget(otherSpinBox);
    otherSizeLayout.addStretch();

    QGridLayout layout = new QGridLayout();
    layout.addWidget(smallRadioButton, 0, 0);
    layout.addWidget(largeRadioButton, 1, 0);
    layout.addWidget(toolBarRadioButton, 2, 0);
    layout.addWidget(listViewRadioButton, 0, 1);
    layout.addWidget(iconViewRadioButton, 1, 1);
    layout.addWidget(tabBarRadioButton, 2, 1);
    layout.addLayout(otherSizeLayout, 3, 0, 1, 2);
    layout.setRowStretch(4, 1);
    iconSizeGroupBox.setLayout(layout);
  }