void PrivacyDlg::newList() { bool done = false; bool ok = false; QString name; while (!done) { name = QInputDialog::getText(this, tr("New List"), tr("Enter the name of the new list:"), QLineEdit::Normal, "", &ok); if (!ok) { done = true; } else if (ui_.cb_lists->findText(name) != -1) { QMessageBox::critical(this, tr("Error"), tr("A list with this name already exists.")); } else if (!name.isEmpty()) { done = true; } } if (ok) { if (ui_.cb_lists->currentIndex() != -1 && model_.list().isEmpty()) { ui_.cb_lists->removeItem(ui_.cb_lists->currentIndex()); } ui_.cb_lists->addItem(name); ui_.cb_lists->setCurrentIndex(ui_.cb_lists->findText(name)); model_.setList(PrivacyList(name)); newList_ = true; rememberSettings(); } }
void PrivacyDlg::refreshList(const PrivacyList& list) { if (list.name() == ui_.cb_lists->currentText()) { rememberSettings(); model_.setList(list); setWidgetsEnabled(true); } }
void PrivacyDlg::listChanged() { if (model_.list().isEmpty()) { ui_.cb_lists->removeItem(previousList_); rememberSettings(); } setWidgetsEnabled(false); manager_->requestList(ui_.cb_lists->currentText()); }
void SettingsDialog::resetSettings() { QMessageBox::StandardButton b = QMessageBox::question( this, tr("Reset settings"), tr("Clear all settings?") ); if(b==QMessageBox::Yes) { QSettings().clear(); restoreSettings(); rememberSettings(); } }
void MacMenu::joinSession() { auto dlg = new dialogs::JoinDialog; connect(dlg, &dialogs::JoinDialog::finished, [this, dlg](int i) { if(i==QDialog::Accepted) { QUrl url = dlg->getUrl(); if(!url.isValid()) { // TODO add validator to prevent this from happening QMessageBox::warning(0, "Error", "Invalid address"); return; } dlg->rememberSettings(); MainWindow *mw = new MainWindow; mw->joinSession(url, dlg->recordSession()); } dlg->deleteLater(); }); dlg->show();}
/** * Construct a settings dialog. The actions in the list should have * a "defaultshortcut" property for reset to default to work. * * @param actions list of customizeable actions (for shortcut editing) * @param parent parent widget */ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent) { _ui = new Ui_SettingsDialog; _ui->setupUi(this); connect(_ui->pickFfmpeg, &QToolButton::clicked, [this]() { QString path = QFileDialog::getOpenFileName(this, tr("Set ffmepg path"), _ui->ffmpegpath->text(), #ifdef Q_OS_WIN tr("Executables (%1)").arg("*.exe") + ";;" + #endif QApplication::tr("All files (*)") ); if(!path.isEmpty()) _ui->ffmpegpath->setText(path); }); connect(_ui->pickRecordingFolder, &QToolButton::clicked, [this]() { QString path = QFileDialog::getExistingDirectory(this, tr("Recording folder"), _ui->recordingFolder->text()); if(!path.isEmpty()) _ui->recordingFolder->setText(path); }); connect(_ui->notificationVolume, &QSlider::valueChanged, [this](int val) { if(val>0) _ui->volumeLabel->setText(QString::number(val) + "%"); else _ui->volumeLabel->setText(tr("off", "notifications sounds")); }); // Get available languages _ui->languageBox->addItem(tr("Default"), QString()); _ui->languageBox->addItem(QStringLiteral("English"), QStringLiteral("en")); const QLocale localeC = QLocale::c(); QStringList locales; for(const QString &datapath : DrawpileApp::dataPaths()) { QStringList files = QDir(datapath + "/i18n").entryList(QStringList("drawpile_*.qm"), QDir::Files, QDir::Name); for(const QString &file : files) { QString localename = file.mid(9, file.length() - 3 - 9); QLocale locale(localename); if(locale != localeC && !locales.contains(localename)) { locales << localename; _ui->languageBox->addItem(locale.nativeLanguageName(), localename); } } } // Editable shortcuts _customShortcuts = new CustomShortcutModel(this); auto filteredShortcuts = new QSortFilterProxyModel(this); filteredShortcuts->setSourceModel(_customShortcuts); connect(_ui->shortcutFilter, &QLineEdit::textChanged, filteredShortcuts, &QSortFilterProxyModel::setFilterFixedString); filteredShortcuts->setFilterCaseSensitivity(Qt::CaseInsensitive); _ui->shortcuts->setModel(filteredShortcuts); _ui->shortcuts->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); _ui->shortcuts->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch); // QKeySequence editor delegate QStyledItemDelegate *keyseqdel = new QStyledItemDelegate(this); QItemEditorFactory *itemeditorfactory = new QItemEditorFactory; itemeditorfactory->registerEditor(QVariant::nameToType("QKeySequence"), new KeySequenceEditFactory); keyseqdel->setItemEditorFactory(itemeditorfactory); _ui->shortcuts->setItemDelegateForColumn(1, keyseqdel); // Deselect item before saving. This causes the editor widget to close // and commit the change. connect(_ui->buttonBox, &QDialogButtonBox::accepted, [this]() { _ui->shortcuts->setCurrentIndex(QModelIndex()); }); // Known hosts list connect(_ui->knownHostList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(viewCertificate(QListWidgetItem*))); connect(_ui->knownHostList, SIGNAL(itemSelectionChanged()), this, SLOT(certificateSelectionChanged())); connect(_ui->trustKnownHosts, SIGNAL(clicked()), this, SLOT(markTrustedCertificates())); connect(_ui->removeKnownHosts, SIGNAL(clicked()), this, SLOT(removeCertificates())); connect(_ui->importTrustedButton, SIGNAL(clicked()), this, SLOT(importTrustedCertificate())); QStringList pemfilter; pemfilter << "*.pem"; QDir knownHostsDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/known-hosts/"); for(const QString &filename : knownHostsDir.entryList(pemfilter, QDir::Files)) { auto *i = new QListWidgetItem(filename.left(filename.length()-4), _ui->knownHostList); i->setData(Qt::UserRole, false); i->setData(Qt::UserRole+1, knownHostsDir.absoluteFilePath(filename)); } QDir trustedHostsDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/trusted-hosts/"); QIcon trustedIcon("builtin:trusted.svg"); for(const QString &filename : trustedHostsDir.entryList(pemfilter, QDir::Files)) { auto *i = new QListWidgetItem(trustedIcon, filename.left(filename.length()-4), _ui->knownHostList); i->setData(Qt::UserRole, true); i->setData(Qt::UserRole+1, trustedHostsDir.absoluteFilePath(filename)); } // Session listing server list _listservers = new sessionlisting::ListServerModel(false, this); _ui->listserverview->setModel(_listservers); _ui->listserverview->setItemDelegate(new sessionlisting::ListServerDelegate(this)); connect(_ui->addListServer, &QPushButton::clicked, this, &SettingsDialog::addListingServer); connect(_ui->removeListServer, &QPushButton::clicked, this, &SettingsDialog::removeListingServer); // Load configuration restoreSettings(); // Settings saving connect(_ui->buttonBox, SIGNAL(accepted()), this, SLOT(rememberSettings())); connect(_ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveCertTrustChanges())); connect(_ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(resetSettings())); }
void PrivacyDlg::change_succeeded() { rememberSettings(); setWidgetsEnabled(true); }
void PrefGeneral::getData(Preferences * pref) { requires_restart = false; filesettings_method_changed = false; if (pref->mplayer_bin != mplayerPath()) { requires_restart = true; pref->mplayer_bin = mplayerPath(); qDebug("PrefGeneral::getData: mplayer binary has changed, getting version number"); // Forces to get info from mplayer to update version number InfoReader i( pref->mplayer_bin ); i.getInfo(); // Update the drivers list at the same time //setDrivers( i.voList(), i.aoList() ); } TEST_AND_SET(pref->use_screenshot, useScreenshots()); TEST_AND_SET(pref->screenshot_directory, screenshotDir()); TEST_AND_SET(pref->vo, VO()); TEST_AND_SET(pref->ao, AO()); bool dont_remember_ms = !rememberSettings(); TEST_AND_SET(pref->dont_remember_media_settings, dont_remember_ms); bool dont_remember_time = !rememberTimePos(); TEST_AND_SET(pref->dont_remember_time_pos, dont_remember_time); if (pref->file_settings_method != fileSettingsMethod()) { pref->file_settings_method = fileSettingsMethod(); filesettings_method_changed = true; } pref->audio_lang = audioLang(); pref->subtitle_lang = subtitleLang(); pref->initial_audio_track = audioTrack(); pref->initial_subtitle_track = subtitleTrack(); pref->close_on_finish = closeOnFinish(); pref->pause_when_hidden = pauseWhenHidden(); TEST_AND_SET(pref->use_soft_video_eq, eq2()); TEST_AND_SET(pref->use_soft_vol, softVol()); pref->global_volume = globalVolume(); TEST_AND_SET(pref->use_audio_equalizer, useAudioEqualizer()); TEST_AND_SET(pref->use_hwac3, Ac3DTSPassthrough()); pref->initial_volnorm = initialVolNorm(); TEST_AND_SET(pref->softvol_max, amplification()); pref->initial_postprocessing = initialPostprocessing(); pref->initial_deinterlace = initialDeinterlace(); pref->initial_zoom_factor = initialZoom(); TEST_AND_SET(pref->use_direct_rendering, directRendering()); TEST_AND_SET(pref->use_double_buffer, doubleBuffer()); TEST_AND_SET(pref->use_slices, useSlices()); pref->start_in_fullscreen = startInFullscreen(); if (pref->add_blackborders_on_fullscreen != blackbordersOnFullscreen()) { pref->add_blackborders_on_fullscreen = blackbordersOnFullscreen(); if (pref->fullscreen) requires_restart = true; } TEST_AND_SET(pref->autoq, autoq()); #ifdef Q_OS_WIN pref->avoid_screensaver = avoidScreensaver(); TEST_AND_SET(pref->turn_screensaver_off, turnScreensaverOff()); #else TEST_AND_SET(pref->disable_screensaver, disableScreensaver()); #endif #ifndef Q_OS_WIN pref->vdpau = vdpau; #endif pref->initial_audio_channels = audioChannels(); TEST_AND_SET(pref->use_scaletempo, scaleTempoFilter()); TEST_AND_SET(pref->autosync, autoSyncActivated()); TEST_AND_SET(pref->autosync_factor, autoSyncFactor()); TEST_AND_SET(pref->use_mc, mcActivated()); TEST_AND_SET(pref->mc_value, mc()); }