Skip to content

Commit

Permalink
Add tab size to the preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
evpo committed Jan 23, 2018
1 parent 0237761 commit b5870d1
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 43 deletions.
2 changes: 2 additions & 0 deletions qt_ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,8 @@ void MainWindow::onUpdatedPreferences()
enc.SetLibcurlPath(preferences.libCurlPath.toStdString());
enc.SetLibcurlParams(preferences.libCurlParameters.toStdString());
textEdit->setFont(preferences.font);
QFontMetrics metrics(textEdit->font());
textEdit->setTabStopWidth(preferences.tabSize * metrics.width(' '));
recent_files_service_.SetMaxFiles(preferences.recentFiles);
resetZoom();

Expand Down
3 changes: 3 additions & 0 deletions qt_ui/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace
const bool kDefaultenableBakFiles = true;
const bool kDefaultWordWrap = true;
const int kDefaultS2KResultsPoolSize = 8;
const int kDefaultTabSize = 4;
const LibEncryptMsg::Compression kDefaultKeyFileCompression
= LibEncryptMsg::Compression::Uncompressed;
#if defined(__MINGW__) || defined(__MINGW32__)
Expand Down Expand Up @@ -129,6 +130,7 @@ namespace
mapper.Map("key_file_iterations", preferences.keyFileProperties.iterations);
mapper.Map("windows_eol", preferences.windowsEol);
mapper.Map("key_file_key_length", preferences.kfKeyLength);
mapper.Map("tab_size", preferences.tabSize);
}
}

Expand All @@ -153,6 +155,7 @@ void SetDefaultPreferences(PersistentPreferences &preferences)
preferences.keyFileProperties.iterations = EncryptPad::kDefaultIterations;

preferences.font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
preferences.tabSize = kDefaultTabSize;
}


Expand Down
1 change: 1 addition & 0 deletions qt_ui/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct PersistentPreferences
int recentFiles;
int s2kResultsPoolSize;
QFont font;
int tabSize;
QString libCurlPath;
QString libCurlParameters;
int kfKeyLength;
Expand Down
1 change: 1 addition & 0 deletions qt_ui/preferences_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ namespace
binder.Bind(ui.uiWindowsEol, value.windowsEol);
binder.Bind(ui.uiS2KResultsPoolSize, value.s2kResultsPoolSize);
binder.Bind(ui.uiKeyFileLength, value.kfKeyLength);
binder.Bind(ui.uiTabSize, value.tabSize);
}

void ParseComboBoxData(QComboBox *combo)
Expand Down
128 changes: 85 additions & 43 deletions qt_ui/preferences_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>503</height>
<width>500</width>
<height>516</height>
</rect>
</property>
<property name="minimumSize">
Expand All @@ -18,8 +18,8 @@
</property>
<property name="maximumSize">
<size>
<width>474</width>
<height>503</height>
<width>500</width>
<height>600</height>
</size>
</property>
<property name="windowTitle">
Expand All @@ -43,20 +43,7 @@
<property name="spacing">
<number>10</number>
</property>
<item row="9" column="0">
<widget class="QLabel" name="label_7">
<property name="toolTip">
<string>Libcurl command line parameters</string>
</property>
<property name="text">
<string>Parameters:</string>
</property>
<property name="buddy">
<cstring>uiLibcurlParameters</cstring>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<item row="13" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_6">
Expand All @@ -70,6 +57,19 @@
</item>
</layout>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="toolTip">
<string>Libcurl command line parameters</string>
</property>
<property name="text">
<string>Parameters:</string>
</property>
<property name="buddy">
<cstring>uiLibcurlParameters</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
Expand All @@ -83,28 +83,28 @@
</property>
</widget>
</item>
<item row="8" column="2">
<item row="9" column="2">
<widget class="QPushButton" name="uiLibcurlBrowse">
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<item row="8" column="0" colspan="3">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2">
<item row="7" column="1" colspan="2">
<widget class="QCheckBox" name="uiEnableBakFiles">
<property name="text">
<string>Enable BAK files</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLineEdit" name="uiLibcurl"/>
</item>
<item row="0" column="1">
Expand All @@ -129,7 +129,7 @@
</property>
</widget>
</item>
<item row="5" column="1" colspan="2">
<item row="6" column="1" colspan="2">
<widget class="QCheckBox" name="uiLastUsedDirectory">
<property name="toolTip">
<string>Retain last used directory between EncryptPad sessions</string>
Expand All @@ -139,7 +139,7 @@
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="layout_2">
<property name="spacing">
<number>0</number>
Expand Down Expand Up @@ -182,21 +182,21 @@
</property>
</widget>
</item>
<item row="11" column="2">
<item row="12" column="2">
<widget class="QPushButton" name="uiDefaultFileProperties">
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<item row="4" column="0" colspan="3">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_3">
<property name="toolTip">
<string>Path to libCURL executable</string>
Expand Down Expand Up @@ -234,7 +234,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="11" column="0" colspan="3">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
Expand All @@ -250,21 +257,14 @@
</property>
</widget>
</item>
<item row="12" column="2">
<item row="13" column="2">
<widget class="QPushButton" name="uiEditKeyFileProperties">
<property name="text">
<string>Edit...</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="15" column="0" colspan="3">
<item row="16" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="minimumSize">
<size>
Expand All @@ -283,7 +283,7 @@
</property>
</widget>
</item>
<item row="13" column="2">
<item row="14" column="2">
<widget class="QComboBox" name="uiS2KResultsPoolSize">
<property name="currentIndex">
<number>0</number>
Expand Down Expand Up @@ -315,7 +315,7 @@
</item>
</widget>
</item>
<item row="11" column="0" colspan="2">
<item row="12" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_4">
Expand All @@ -329,7 +329,7 @@
</item>
</layout>
</item>
<item row="13" column="0" colspan="2">
<item row="14" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_5">
Expand All @@ -346,14 +346,14 @@
</item>
</layout>
</item>
<item row="9" column="1" colspan="2">
<item row="10" column="1" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="uiLibcurlParameters"/>
</item>
</layout>
</item>
<item row="14" column="0" colspan="2">
<item row="15" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Key file random sequence length (bytes):</string>
Expand All @@ -363,7 +363,7 @@
</property>
</widget>
</item>
<item row="14" column="2">
<item row="15" column="2">
<widget class="QComboBox" name="uiKeyFileLength">
<item>
<property name="text">
Expand Down Expand Up @@ -397,6 +397,46 @@
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QSpinBox" name="uiTabSize">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>40</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Tab size:</string>
</property>
<property name="buddy">
<cstring>uiTabSize</cstring>
</property>
</widget>
</item>
</layout>
</item>
</layout>
Expand All @@ -406,6 +446,7 @@
<tabstop>uiSelectFont</tabstop>
<tabstop>uiWordWrap</tabstop>
<tabstop>uiWindowsEol</tabstop>
<tabstop>uiTabSize</tabstop>
<tabstop>uiRecentFiles</tabstop>
<tabstop>uiLastUsedDirectory</tabstop>
<tabstop>uiEnableBakFiles</tabstop>
Expand All @@ -415,6 +456,7 @@
<tabstop>uiDefaultFileProperties</tabstop>
<tabstop>uiEditKeyFileProperties</tabstop>
<tabstop>uiS2KResultsPoolSize</tabstop>
<tabstop>uiKeyFileLength</tabstop>
</tabstops>
<resources/>
<connections>
Expand Down

0 comments on commit b5870d1

Please sign in to comment.