summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheMarlboroMan <marlborometal@gmail.com>2020-02-23 18:26:37 +0100
committerTheMarlboroMan <marlborometal@gmail.com>2020-02-23 18:26:37 +0100
commit8a4d872d938473cfda0a45441958df1b6d0ab00f (patch)
tree21ffbf761f1d35a617c74a6c19d410841a5cb50b
parentc57244cbcdeab6e1b10bd0ca3c821f1e745dae39 (diff)
Small changes, removed a lambda which does not seem to provide any benefit, changed insert calls to append
-rw-r--r--plugingui/abouttab.cc34
1 files changed, 16 insertions, 18 deletions
diff --git a/plugingui/abouttab.cc b/plugingui/abouttab.cc
index 960a321..0c56c62 100644
--- a/plugingui/abouttab.cc
+++ b/plugingui/abouttab.cc
@@ -37,8 +37,10 @@ namespace GUI
class AboutTextBuilder {
public:
//!Class constructor. Sets the separator character.
- AboutTextBuilder(char _separator='=')
- :separator_character(_separator)
+ AboutTextBuilder(char _separator='=', size_t _separator_count=20, size_t _space_count=13)
+ :separator_character(_separator),
+ separator_count(_separator_count),
+ space_count(_space_count)
{
}
@@ -46,18 +48,14 @@ public:
//!Returns a reference to the builder so more calls can be chained.
AboutTextBuilder& add(const std::string& _title, const std::string& _contents)
{
- auto repeat=[](std::string& _str, char _fill, size_t _count)
- {
- _str.insert(_str.size(), _count, _fill);
- };
-
- repeat(about_text, separator_character, separator_count);
- about_text+="\n";
- repeat(about_text, ' ', space_count);
- about_text+=_title+"\n";
- repeat(about_text, separator_character, separator_count);
- repeat(about_text, '\n', 3);
- about_text+=_contents+"\n";
+ about_text.append(separator_count, separator_character)
+ .append(1, '\n')
+ .append(space_count, ' ')
+ .append(1, '\n')
+ .append(separator_count, separator_character)
+ .append(3, '\n')
+ .append(_contents)
+ .append(1, '\n');
return *this;
}
@@ -69,8 +67,8 @@ public:
}
private:
- const size_t separator_count=13; //!< Number of times that the separator character will be added.
- const size_t space_count=13; //!< Number of times that the space character will be added before the title.
+ const size_t separator_count; //!< Number of times that the separator character will be added. Defaults to 20.
+ const size_t space_count; //!< Number of times that the space character will be added before the title. Defaults to 13.
char separator_character; //!< Separator character. Defaults to '='.
std::string about_text; //!< Text that will be filled up with calls to "add".
};
@@ -94,11 +92,11 @@ void AboutTab::resize(std::size_t width, std::size_t height)
std::string AboutTab::getAboutText()
{
- AboutTextBuilder builder('*');
+ AboutTextBuilder builder;
//This will casually add an extra newline at the end of License.
return builder.add("About", about.data())
- .add("Version", std::string(VERSION))
+ .add("Version", std::string(VERSION)+"\n")
.add("Bugs", bugs.data())
.add("Authors", UTF8().toLatin1(authors.data()))
.add("License", gpl.data())