ui: Minor improvements in the settings dialog

This commit is contained in:
Oleg Shparber 2017-03-05 21:44:43 -05:00
parent 40e54b1b53
commit 8fd3ac7499
3 changed files with 36 additions and 12 deletions

View File

@ -74,13 +74,14 @@ void SettingsDialog::chooseCustomCssFile()
ui->customCssFileEdit->setText(QDir::toNativeSeparators(file));
}
void SettingsDialog::on_storageButton_clicked()
void SettingsDialog::chooseDocsetStoragePath()
{
const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),
ui->storageEdit->text());
if (!dir.isEmpty())
ui->storageEdit->setText(QDir::toNativeSeparators(dir));
ui->docsetStorageEdit->text());
if (dir.isEmpty())
return;
ui->docsetStorageEdit->setText(QDir::toNativeSeparators(dir));
}
void SettingsDialog::loadSettings()
@ -96,7 +97,7 @@ void SettingsDialog::loadSettings()
ui->toolButton->setKeySequence(settings->showShortcut);
ui->storageEdit->setText(QDir::toNativeSeparators(settings->docsetPath));
ui->docsetStorageEdit->setText(QDir::toNativeSeparators(settings->docsetPath));
// Tabs Tab
ui->openNewTabAfterActive->setChecked(settings->openNewTabAfterActive);
@ -148,8 +149,8 @@ void SettingsDialog::saveSettings()
settings->highlightOnNavigateEnabled = ui->highlightOnNavigateCheckBox->isChecked();
settings->customCssFile = QDir::fromNativeSeparators(ui->customCssFileEdit->text());
if (QDir::fromNativeSeparators(ui->storageEdit->text()) != settings->docsetPath) {
settings->docsetPath = QDir::fromNativeSeparators(ui->storageEdit->text());
if (QDir::fromNativeSeparators(ui->docsetStorageEdit->text()) != settings->docsetPath) {
settings->docsetPath = QDir::fromNativeSeparators(ui->docsetStorageEdit->text());
m_application->docsetRegistry()->init(settings->docsetPath);
}

View File

@ -45,7 +45,7 @@ public:
private slots:
void chooseCustomCssFile();
void on_storageButton_clicked();
void chooseDocsetStoragePath();
private:
Ui::SettingsDialog *ui = nullptr;

View File

@ -120,19 +120,26 @@
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Directory:</string>
<string>&amp;Directory:</string>
</property>
<property name="buddy">
<cstring>docsetStorageEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="storageEdit"/>
<widget class="QLineEdit" name="docsetStorageEdit">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="storageButton">
<widget class="QPushButton" name="docsetStorageBrowseButton">
<property name="text">
<string>Browse...</string>
<string>&amp;Browse...</string>
</property>
</widget>
</item>
@ -669,5 +676,21 @@
</hint>
</hints>
</connection>
<connection>
<sender>docsetStorageBrowseButton</sender>
<signal>clicked()</signal>
<receiver>SettingsDialog</receiver>
<slot>chooseDocsetStoragePath()</slot>
<hints>
<hint type="sourcelabel">
<x>526</x>
<y>371</y>
</hint>
<hint type="destinationlabel">
<x>299</x>
<y>249</y>
</hint>
</hints>
</connection>
</connections>
</ui>