Skip to content

Commit

Permalink
UI: Add 'TruncateString' to override UI truncation if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
zathras-crypto committed May 12, 2015
1 parent ebd4322 commit 4615360
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/qt/omnicore_qtutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ std::string StripTrailingZeros(const std::string& inputStr)
return outputStr;
}

/**
* Truncates a string at n digits and adds "..." to indicate that display is incomplete
*/
std::string TruncateString(const std::string& inputStr, unsigned int length)
{
if (inputStr.empty()) return "";
std::string outputStr = inputStr;
if (length > 0 && inputStr.length() > length) {
outputStr = inputStr.substr(0, length) + "...";
}
return outputStr;
}

/**
* Variable length find and replace. Find all iterations of findText within inputStr and replace them
* with replaceText.
Expand Down
5 changes: 5 additions & 0 deletions src/qt/omnicore_qtutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ namespace mastercore
*/
void PopulateSimpleDialog(const std::string& content, const std::string& title, const std::string& tooltip);

/**
* Truncates a string at n digits and adds "..." to indicate that display is incomplete
*/
std::string TruncateString(const std::string& inputStr, unsigned int length);

/**
* Strips trailing zeros from a string containing a divisible value
*/
Expand Down

0 comments on commit 4615360

Please sign in to comment.