diff options
author | Camila San <hello@camila.codes> | 2018-02-02 00:35:38 +0300 |
---|---|---|
committer | Camila San <hello@camila.codes> | 2018-02-02 00:35:38 +0300 |
commit | 6dd349a8a6bf432add47152f057d1a34c401f807 (patch) | |
tree | 4ff0ed726b1bb3b1caf31cdae9fb01ce8c3272e3 | |
parent | f7697b0584f19a84ae82da89b17aefff7d82e76f (diff) |
Adds button to restore default patterns in the ignore list.
Signed-off-by: Camila San <hello@camila.codes>
-rw-r--r-- | src/gui/ignorelisteditor.cpp | 27 | ||||
-rw-r--r-- | src/gui/ignorelisteditor.h | 3 | ||||
-rw-r--r-- | src/gui/ignorelisteditor.ui | 108 |
3 files changed, 70 insertions, 68 deletions
diff --git a/src/gui/ignorelisteditor.cpp b/src/gui/ignorelisteditor.cpp index b6e262eac..0d49933f1 100644 --- a/src/gui/ignorelisteditor.cpp +++ b/src/gui/ignorelisteditor.cpp @@ -37,27 +37,23 @@ IgnoreListEditor::IgnoreListEditor(QWidget *parent) setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); ui->setupUi(this); + ConfigFile cfgFile; ui->descriptionLabel->setText(tr("Files or folders matching a pattern will not be synchronized.\n\n" "Items where deletion is allowed will be deleted if they prevent a " "directory from being removed. " "This is useful for meta data.")); - - ConfigFile cfgFile; readOnlyTooltip = tr("This entry is provided by the system at '%1' " "and cannot be modified in this view.") .arg(QDir::toNativeSeparators(cfgFile.excludeFile(ConfigFile::SystemScope))); - addPattern(".csync_journal.db*", /*deletable=*/false, /*readonly=*/true); - addPattern("._sync_*.db*", /*deletable=*/false, /*readonly=*/true); - addPattern(".sync_*.db*", /*deletable=*/false, /*readonly=*/true); - readIgnoreFile(cfgFile.excludeFile(ConfigFile::SystemScope), false); - readIgnoreFile(cfgFile.excludeFile(ConfigFile::UserScope), false); + populateIgnoreFileTable(); connect(this, &QDialog::accepted, this, &IgnoreListEditor::slotUpdateLocalIgnoreList); ui->removePushButton->setEnabled(false); connect(ui->tableWidget, &QTableWidget::itemSelectionChanged, this, &IgnoreListEditor::slotItemSelectionChanged); connect(ui->removePushButton, &QAbstractButton::clicked, this, &IgnoreListEditor::slotRemoveCurrentItem); connect(ui->addPushButton, &QAbstractButton::clicked, this, &IgnoreListEditor::slotAddPattern); + connect(ui->buttonBox, &QDialogButtonBox::clicked, this, &IgnoreListEditor::slotRestoreDefaults); ui->tableWidget->resizeColumnsToContents(); ui->tableWidget->horizontalHeader()->setSectionResizeMode(patternCol, QHeaderView::Stretch); @@ -150,6 +146,11 @@ void IgnoreListEditor::slotAddPattern() ui->tableWidget->scrollToBottom(); } +void IgnoreListEditor::slotRestoreDefaults(QAbstractButton *button){ + if(ui->buttonBox->buttonRole(button) == QDialogButtonBox::ResetRole) + populateIgnoreFileTable(); +} + void IgnoreListEditor::readIgnoreFile(const QString &file, bool readOnly) { QFile ignores(file); @@ -169,6 +170,18 @@ void IgnoreListEditor::readIgnoreFile(const QString &file, bool readOnly) } } +void IgnoreListEditor::populateIgnoreFileTable(){ + ui->tableWidget->setRowCount(0); + + addPattern(".csync_journal.db*", /*deletable=*/false, /*readonly=*/true); + addPattern("._sync_*.db*", /*deletable=*/false, /*readonly=*/true); + addPattern(".sync_*.db*", /*deletable=*/false, /*readonly=*/true); + + ConfigFile cfgFile; + readIgnoreFile(cfgFile.excludeFile(ConfigFile::SystemScope), false); + readIgnoreFile(cfgFile.excludeFile(ConfigFile::UserScope), false); +} + int IgnoreListEditor::addPattern(const QString &pattern, bool deletable, bool readOnly) { int newRow = ui->tableWidget->rowCount(); diff --git a/src/gui/ignorelisteditor.h b/src/gui/ignorelisteditor.h index 0018e2361..47ad63fc4 100644 --- a/src/gui/ignorelisteditor.h +++ b/src/gui/ignorelisteditor.h @@ -18,6 +18,7 @@ #include <QDialog> class QListWidgetItem; +class QAbstractButton; namespace OCC { @@ -44,9 +45,11 @@ private slots: void slotRemoveCurrentItem(); void slotUpdateLocalIgnoreList(); void slotAddPattern(); + void slotRestoreDefaults(QAbstractButton *button); private: void readIgnoreFile(const QString &file, bool readOnly); + void populateIgnoreFileTable(); int addPattern(const QString &pattern, bool deletable, bool readOnly); QString readOnlyTooltip; Ui::IgnoreListEditor *ui; diff --git a/src/gui/ignorelisteditor.ui b/src/gui/ignorelisteditor.ui index 450e12bd6..7aacee87e 100644 --- a/src/gui/ignorelisteditor.ui +++ b/src/gui/ignorelisteditor.ui @@ -13,36 +13,35 @@ <property name="windowTitle"> <string>Ignored Files Editor</string> </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Global Ignore Settings</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QCheckBox" name="syncHiddenFilesCheckBox"> - <property name="text"> - <string>Sync hidden files</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> <item row="1" column="0"> <widget class="QGroupBox" name="groupBox_2"> <property name="title"> <string>Files Ignored by Patterns</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="1"> - <widget class="QPushButton" name="removePushButton"> + <item row="3" column="0" colspan="2"> + <widget class="QLabel" name="descriptionLabel"> <property name="enabled"> <bool>true</bool> </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> - <string>Remove</string> + <string/> + </property> + <property name="textFormat"> + <enum>Qt::PlainText</enum> + </property> + <property name="wordWrap"> + <bool>true</bool> </property> </widget> </item> @@ -56,32 +55,6 @@ </property> </widget> </item> - <item row="0" column="0" rowspan="3"> - <widget class="QTableWidget" name="tableWidget"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::SingleSelection</enum> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - <property name="columnCount"> - <number>2</number> - </property> - <column> - <property name="text"> - <string>Pattern</string> - </property> - </column> - <column> - <property name="text"> - <string>Allow Deletion</string> - </property> - </column> - </widget> - </item> <item row="2" column="1"> <spacer name="verticalSpacer"> <property name="enabled"> @@ -98,35 +71,48 @@ </property> </spacer> </item> - <item row="3" column="0" colspan="2"> - <widget class="QLabel" name="descriptionLabel"> + <item row="1" column="1"> + <widget class="QPushButton" name="removePushButton"> <property name="enabled"> <bool>true</bool> </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> <property name="text"> - <string/> - </property> - <property name="textFormat"> - <enum>Qt::PlainText</enum> + <string>Remove</string> </property> - <property name="wordWrap"> - <bool>true</bool> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="0"> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Global Ignore Settings</string> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QCheckBox" name="syncHiddenFilesCheckBox"> + <property name="text"> + <string>Sync hidden files</string> </property> </widget> </item> </layout> </widget> </item> - <item row="4" column="0"> + <item row="5" column="0"> <widget class="QDialogButtonBox" name="buttonBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="layoutDirection"> + <enum>Qt::LeftToRight</enum> + </property> <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set> </property> </widget> </item> |