Beispiel #1
0
void MainWindow::showSettingsDialog()
{
    // An instance of your dialog could be already created and could be
    // cached, in which case you want to display the cached dialog
    // instead of creating another one.
    if (KConfigDialog::showDialog("settings"))
        return;

    // KConfigDialog didn't find an instance of this dialog, so lets
    // create it:
    KConfigDialog* dialog = new KConfigDialog(this, "settings",
                                            Settings::self());

    QWidget *widget = new QWidget;
    Ui::General ui;
    ui.setupUi(widget);
    dialog->addPage(widget, i18n("General"), "general");

    // User edited the configuration - update your local copies of the
    // configuration data.
    connect(dialog, SIGNAL(settingsChanged(QString)),
            this, SLOT(loadSettingsXt()));

    dialog->show();
}
Beispiel #2
0
void MainWindow::showSettings()
{
    // Check if there is already a dialog and if so bring it to the foreground.
    if (QConfigDialog::showDialog("settings"))
        return;

    int dialogButtons = 0;
    if (helpButton) dialogButtons |= (int)QConfigDialog::Help;
    if (defaultButton) dialogButtons |= (int)QConfigDialog::Default;
    if (okButton) dialogButtons |= (int)QConfigDialog::Ok;
    if (applyButton) dialogButtons |= (int)QConfigDialog::Apply;
    if (cancelButton) dialogButtons |= (int)QConfigDialog::Cancel;

    QConfigDialog::Button buttons = (QConfigDialog::Button)dialogButtons;

    // Create a new dialog with the same name as the above checking code.
    QConfigDialog *dialog = new QConfigDialog(this);
    dialog->setObjectName("settings");
    dialog->setButtons(buttons);

    //                (QConfigDialog::DialogType)type, settings, buttons, modal);

    //dialog->setNamePrefix("kcfg_");

    // Add the general page.  Store the settings in the General group and
    // use the icon package_settings.
    QWidget *general = new QWidget(0);
    general->setObjectName("General");
    Ui::General ui;
    ui.setupUi(general);
    dialog->addPage(general, "General", QIcon("general.png"));

    //if (type == QConfigDialog::Tabbed || type == QConfigDialog::IconList) {
    {
        QWidget *other = new QWidget(0);
        other->setObjectName("Other");
        Ui::Other ui;
        ui.setupUi(other);
        dialog->addPage(other, "Other", QIcon("other.png"));
    }

    // When the user clicks OK or Apply we want to update our settings.
  connect(dialog, SIGNAL(settingsChanged()), this, SLOT(readSettings()));

  // Display the dialog.
  dialog->show();
}