ui: use wstring in gui relates places

* loading icons
* loading fonts
* context menu action for copy path to clipboard
* context menu action for open containing folder
This commit is contained in:
mlangkabel
2018-02-19 12:45:47 +01:00
parent ed386fdbdf
commit fc92cb1ad9
23 changed files with 75 additions and 63 deletions
+2 -2
View File
@@ -10,14 +10,14 @@ void IndexerCommandList::addCommand(std::shared_ptr<IndexerCommand> command)
{
std::lock_guard<std::mutex> lock(m_commandsMutex);
std::string commandHash = command->getSourceFilePath().str() + std::to_string(command->getByteSize(1));
std::wstring commandHash = command->getSourceFilePath().wstr() + std::to_wstring(command->getByteSize(1));
if (m_commandIndex.insert(commandHash).second == true) // Don't add duplicate indexer commands
{
m_commands.push_back(command);
}
else
{
LOG_WARNING_STREAM(<< "Duplicate indexer command was ignored: " << commandHash);
LOG_WARNING(L"Duplicate indexer command was ignored: " + commandHash);
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ private:
std::deque<std::shared_ptr<IndexerCommand>> m_commands;
std::mutex m_commandsMutex;
std::set<std::string> m_commandIndex;
std::set<std::wstring> m_commandIndex;
};
#endif // INDEXER_COMMAND_LIST_H
+1 -1
View File
@@ -146,7 +146,7 @@ void TaskBuildIndex::doExit(std::shared_ptr<Blackboard> blackboard)
"conforms to the specified language standard and all necessary options are defined within your project "
"setup.", path.wstr(), 1, 1, true, true
));
LOG_INFO_STREAM(<< "crashed translation unit: " << path.str());
LOG_INFO(L"crashed translation unit: " + path.wstr());
}
m_storageProvider->insert(is);
}
+7 -7
View File
@@ -180,26 +180,26 @@ bool SourceLocation::isFullTextSearchMatch() const
return m_type == LOCATION_FULLTEXT_SEARCH;
}
std::ostream& operator<<(std::ostream& ostream, const SourceLocation& location)
std::wostream& operator<<(std::wostream& ostream, const SourceLocation& location)
{
if (location.isStartLocation())
{
ostream << '<';
ostream << L'<';
}
ostream << location.getColumnNumber() << ":[ ";
ostream << location.getColumnNumber() << L":[ ";
for (Id tokenId : location.getTokenIds())
{
ostream << '\b' << tokenId << ' ';
ostream << L'\b' << tokenId << L' ';
}
ostream << "\b]";
ostream << L"\b]";
if (location.isEndLocation())
{
ostream << '>';
ostream << L'>';
}
ostream << ' ';
ostream << L' ';
return ostream;
}
+1 -1
View File
@@ -61,6 +61,6 @@ private:
const bool m_isStart;
};
std::ostream& operator<<(std::ostream& ostream, const SourceLocation& location);
std::wostream& operator<<(std::wostream& ostream, const SourceLocation& location);
#endif // SOURCE_LOCATION_H
@@ -118,9 +118,9 @@ SourceLocationFile* SourceLocationCollection::createSourceLocationFile(const Fil
return filePtr.get();
}
std::ostream& operator<<(std::ostream& ostream, const SourceLocationCollection& base)
std::wostream& operator<<(std::wostream& ostream, const SourceLocationCollection& base)
{
ostream << "Locations:\n";
ostream << L"Locations:\n";
base.forEachSourceLocationFile([&ostream](std::shared_ptr<SourceLocationFile> f)
{
ostream << *(f.get());
@@ -45,6 +45,6 @@ private:
std::map<FilePath, std::shared_ptr<SourceLocationFile>> m_files;
};
std::ostream& operator<<(std::ostream& ostream, const SourceLocationCollection& base);
std::wostream& operator<<(std::wostream& ostream, const SourceLocationCollection& base);
#endif // SOURCE_LOCATION_COLLECTION_H
+5 -5
View File
@@ -187,9 +187,9 @@ std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByType(Locati
return ret;
}
std::ostream& operator<<(std::ostream& ostream, const SourceLocationFile& file)
std::wostream& operator<<(std::wostream& ostream, const SourceLocationFile& file)
{
ostream << "file \"" << file.getFilePath().str() << "\"";
ostream << L"file \"" << file.getFilePath().wstr() << L"\"";
size_t line = 0;
file.forEachSourceLocation(
@@ -208,16 +208,16 @@ std::ostream& operator<<(std::ostream& ostream, const SourceLocationFile& file)
line++;
}
ostream << '\n' << line;
ostream << L'\n' << line;
}
ostream << ": ";
ostream << L": ";
}
ostream << *location;
}
);
ostream << '\n';
ostream << L'\n';
return ostream;
}
+1 -1
View File
@@ -63,6 +63,6 @@ private:
std::map<Id, SourceLocation*> m_locationIndex;
};
std::ostream& operator<<(std::ostream& ostream, const SourceLocationFile& base);
std::wostream& operator<<(std::wostream& ostream, const SourceLocationFile& base);
#endif // SOURCE_LOCATION_FILE_H
+5
View File
@@ -381,6 +381,11 @@ std::string FilePath::getBackslashedString() const
return utility::replace(str(), "/", "\\");
}
std::wstring FilePath::getBackslashedWString() const
{
return utility::replace(wstr(), L"/", L"\\");
}
std::wstring FilePath::fileName() const
{
return m_path->filename().generic_wstring();
+1
View File
@@ -51,6 +51,7 @@ public:
std::string str() const;
std::wstring wstr() const;
std::string getBackslashedString() const;
std::wstring getBackslashedWString() const;
std::wstring fileName() const;
std::wstring extension() const;
@@ -20,7 +20,7 @@ CxxVerboseAstVisitor::CxxVerboseAstVisitor(
std::shared_ptr<CanonicalFilePathCache> canonicalFilePathCache
)
: base(context, preprocessor, client, fileRegister, canonicalFilePathCache)
, m_currentFilePath("")
, m_currentFilePath(L"")
, m_indentation(0)
{
}
@@ -43,10 +43,10 @@ bool CxxVerboseAstVisitor::TraverseDecl(clang::Decl *d)
ParseLocation loc = getParseLocation(d->getSourceRange());
stream << " <" << loc.startLineNumber << ":" << loc.startColumnNumber << ", " << loc.endLineNumber << ":" << loc.endColumnNumber << ">";
if (m_currentFilePath != loc.filePath.str())
if (m_currentFilePath != loc.filePath.wstr())
{
m_currentFilePath = loc.filePath.str();
LOG_INFO_STREAM_BARE(<< "Indexer - Traversing \"" + m_currentFilePath + "\"" );
m_currentFilePath = loc.filePath.wstr();
LOG_INFO_BARE(L"Indexer - Traversing \"" + m_currentFilePath + L"\"" );
}
LOG_INFO_STREAM_BARE(<< "Indexer - " << stream.str());
@@ -48,7 +48,7 @@ private:
return "";
}
std::string m_currentFilePath;
std::wstring m_currentFilePath;
unsigned int m_indentation;
};
@@ -35,7 +35,8 @@ void setupApp(int argc, char *argv[])
{
appPath = appPath.substr(0, pos + 1);
}
AppPath::setAppPath(FilePath(appPath));
AppPath::setAppPath(FilePath(L"C:/sourcetrail/täst/Sourcetrail_2018_1_19_32bit"));
//AppPath::setAppPath(FilePath(appPath)); C:\sourcetrail\täst\Sourcetrail_2018_1_19_32bit
}
{
+2 -2
View File
@@ -55,7 +55,7 @@ QtBookmark::QtBookmark(ControllerProxy<BookmarkController>* controllerProxy)
m_editButton->setToolTip("Edit bookmark");
m_editButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
m_editButton->setIconSize(QSize(20, 20));
m_editButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_edit_icon.png").c_str()));
m_editButton->setIcon(QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_edit_icon.png").wstr())));
utility::setWidgetRetainsSpaceWhenHidden(m_editButton);
m_editButton->hide();
buttonsLayout->addWidget(m_editButton);
@@ -65,7 +65,7 @@ QtBookmark::QtBookmark(ControllerProxy<BookmarkController>* controllerProxy)
m_deleteButton->setToolTip("Delete bookmark");
m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
m_deleteButton->setIconSize(QSize(20, 20));
m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_delete_icon.png").c_str()));
m_deleteButton->setIcon(QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_delete_icon.png").wstr())));
utility::setWidgetRetainsSpaceWhenHidden(m_deleteButton);
m_deleteButton->hide();
buttonsLayout->addWidget(m_deleteButton);
@@ -25,7 +25,7 @@ QtBookmarkCategory::QtBookmarkCategory(ControllerProxy<BookmarkController>* cont
m_expandButton->setObjectName("category_expand_button");
m_expandButton->setToolTip("Show/Hide bookmarks in this category");
m_expandButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
m_expandButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/arrow_down.png").c_str()));
m_expandButton->setIcon(QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/arrow_down.png").wstr())));
m_expandButton->setIconSize(QSize(8, 8));
layout->addWidget(m_expandButton);
@@ -42,7 +42,7 @@ QtBookmarkCategory::QtBookmarkCategory(ControllerProxy<BookmarkController>* cont
m_deleteButton->setToolTip("Delete this Bookmark Category and the containing Bookmarks");
m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
m_deleteButton->setIconSize(QSize(20, 20));
m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/bookmark_delete_icon.png").c_str()));
m_deleteButton->setIcon(QPixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_delete_icon.png").wstr())));
utility::setWidgetRetainsSpaceWhenHidden(m_deleteButton);
m_deleteButton->hide();
layout->addWidget(m_deleteButton);
@@ -85,12 +85,12 @@ void QtBookmarkCategory::updateArrow()
{
if (m_treeItem->isExpanded())
{
QPixmap pixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/arrow_down.png").c_str());
QPixmap pixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/arrow_down.png").wstr()));
m_expandButton->setIcon(QIcon(utility::colorizePixmap(pixmap, "black")));
}
else
{
QPixmap pixmap((ResourcePaths::getGuiPath().str() + "bookmark_view/images/arrow_right.png").c_str());
QPixmap pixmap(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/arrow_right.png").wstr()));
m_expandButton->setIcon(QIcon(utility::colorizePixmap(pixmap, "black")));
}
}
@@ -72,9 +72,9 @@ void QtCodeFileTitleButton::setIsComplete(bool isComplete)
utility::decodeFromUtf8(ColorScheme::getInstance()->getColor("code/file/title/hatching")) + L".png"
);
setStyleSheet((
"#title_button { background-image: url(" + hatchingFilePath.str() + "); }"
).c_str());
setStyleSheet(QString::fromStdWString(
L"#title_button { background-image: url(" + hatchingFilePath.wstr() + L"); }"
));
}
else
{
+12 -8
View File
@@ -30,8 +30,9 @@ QtListItemWidget::QtListItemWidget(QtDirectoryListBox* list, QListWidgetItem* it
m_data->setAcceptDrops(false);
m_button = new QtIconButton(
(ResourcePaths::getGuiPath().str() + "window/dots.png").c_str(),
(ResourcePaths::getGuiPath().str() + "window/dots_hover.png").c_str());
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots_hover.png").wstr())
);
m_button->setIconSize(QSize(16, 16));
m_button->setObjectName("dotsButton");
@@ -152,16 +153,18 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
innerLayout->setSpacing(0);
m_addButton = new QtIconButton(
(ResourcePaths::getGuiPath().str() + "window/plus.png").c_str(),
(ResourcePaths::getGuiPath().str() + "window/plus_hover.png").c_str());
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/plus.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/plus_hover.png").wstr())
);
m_addButton->setIconSize(QSize(16, 16));
m_addButton->setObjectName("plusButton");
m_addButton->setToolTip("add line");
innerLayout->addWidget(m_addButton);
m_removeButton = new QtIconButton(
(ResourcePaths::getGuiPath().str() + "window/minus.png").c_str(),
(ResourcePaths::getGuiPath().str() + "window/minus_hover.png").c_str());
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/minus.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/minus_hover.png").wstr())
);
m_removeButton->setIconSize(QSize(16, 16));
m_removeButton->setObjectName("minusButton");
m_removeButton->setToolTip("remove line");
@@ -176,8 +179,9 @@ QtDirectoryListBox::QtDirectoryListBox(QWidget *parent, const QString& listName,
innerLayout->addWidget(dropInfoText);
QPushButton* editButton = new QtIconButton(
(ResourcePaths::getGuiPath().str() + "code_view/images/edit.png").c_str(),
QString());
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"code_view/images/edit.png").wstr()),
QString()
);
editButton->setIconSize(QSize(16, 16));
editButton->setObjectName("editButton");
editButton->setToolTip("edit plain text");
+4 -3
View File
@@ -28,8 +28,9 @@ QtLocationPicker::QtLocationPicker(QWidget *parent)
layout->addWidget(m_data);
m_button = new QtIconButton(
(ResourcePaths::getGuiPath().str() + "window/dots.png").c_str(),
(ResourcePaths::getGuiPath().str() + "window/dots_hover.png").c_str());
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots.png").wstr()),
QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"window/dots_hover.png").wstr())
);
m_button->setIconSize(QSize(16, 16));
m_button->setObjectName("dotsButton");
m_button->setToolTip("pick file");
@@ -123,7 +124,7 @@ void QtLocationPicker::handleButtonPress()
const FilePath relPath = path.getRelativeTo(m_relativeRootDirectory);
if (relPath.str().size() < path.str().size())
{
fileName = QString::fromStdString(relPath.str());
fileName = QString::fromStdWString(relPath.wstr());
}
}
+4 -4
View File
@@ -113,8 +113,8 @@ void QtContextMenu::redoActionTriggered()
void QtContextMenu::copyFullPathActionTriggered()
{
const std::string pathString = (QSysInfo::windowsVersion() != QSysInfo::WV_None) ? s_filePath.getBackslashedString() : s_filePath.str();
QApplication::clipboard()->setText(pathString.c_str());
const std::wstring pathString = (QSysInfo::windowsVersion() != QSysInfo::WV_None) ? s_filePath.getBackslashedWString() : s_filePath.wstr();
QApplication::clipboard()->setText(QString::fromStdWString(pathString));
}
void QtContextMenu::openContainingFolderActionTriggered()
@@ -122,11 +122,11 @@ void QtContextMenu::openContainingFolderActionTriggered()
FilePath dir = s_filePath.getParentDirectory();
if (dir.exists())
{
QDesktopServices::openUrl(QUrl(("file:///" + dir.str()).c_str(), QUrl::TolerantMode));
QDesktopServices::openUrl(QUrl(QString::fromStdWString(L"file:///" + dir.wstr()), QUrl::TolerantMode));
}
else
{
LOG_ERROR("Unable to open directory: " + dir.str());
LOG_ERROR(L"Unable to open directory: " + dir.wstr());
}
}
+5 -5
View File
@@ -10,7 +10,7 @@
QStringList QtFileDialog::getFileNamesAndDirectories(QWidget* parent, const FilePath& path)
{
const QString dir = getDir(QString::fromStdString((path.isDirectory() ? path : path.getParentDirectory()).str()));
const QString dir = getDir(QString::fromStdWString((path.isDirectory() ? path : path.getParentDirectory()).wstr()));
QFileDialog* dialog = (utility::getOsType() == OS_MAC ? new QFileDialog(parent) : new QtFilesAndDirectoriesDialog(parent));
@@ -43,12 +43,12 @@ QStringList QtFileDialog::getFileNamesAndDirectories(QWidget* parent, const File
QString QtFileDialog::getExistingDirectory(QWidget* parent, const QString& caption, const FilePath& dir)
{
return QFileDialog::getExistingDirectory(parent, caption, getDir(QString::fromStdString(dir.str())));
return QFileDialog::getExistingDirectory(parent, caption, getDir(QString::fromStdWString(dir.wstr())));
}
QString QtFileDialog::getOpenFileName(QWidget* parent, const QString& caption, const FilePath& dir, const QString& filter)
{
return QFileDialog::getOpenFileName(parent, caption, getDir(QString::fromStdString(dir.str())), filter);
return QFileDialog::getOpenFileName(parent, caption, getDir(QString::fromStdWString(dir.wstr())), filter);
}
QString QtFileDialog::showSaveFileDialog(
@@ -56,10 +56,10 @@ QString QtFileDialog::showSaveFileDialog(
{
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
return QFileDialog::getSaveFileName(parent, title, getDir(QString::fromStdString(directory.str())), filter);
return QFileDialog::getSaveFileName(parent, title, getDir(QString::fromStdWString(directory.wstr())), filter);
#else
QFileDialog dialog(parent, title, getDir(QString::fromStdString(directory.str())), filter);
QFileDialog dialog(parent, title, getDir(QString::fromStdWString(directory.wstr())), filter);
if (parent)
{
+6 -6
View File
@@ -47,7 +47,7 @@ namespace utility
for (const FilePath& fontFilePath: fontFilePaths)
{
QFile file(fontFilePath.str().c_str());
QFile file(QString::fromStdWString(fontFilePath.wstr()));
if (file.open(QIODevice::ReadOnly))
{
int id = QFontDatabase::addApplicationFontFromData(file.readAll());
@@ -62,7 +62,7 @@ namespace utility
{
for (QString& family: QFontDatabase::applicationFontFamilies(loadedFontId))
{
LOG_INFO("Loaded FontFamily: " + family.toStdString());
LOG_INFO(L"Loaded FontFamily: " + family.toStdWString());
}
}
}
@@ -86,7 +86,7 @@ namespace utility
std::deque<std::string> seq = utility::split(css.substr(posA + 1, posB - posA - 1), ':');
if (seq.size() != 2)
{
LOG_ERROR("Syntax error in file: " + path.str());
LOG_ERROR(L"Syntax error in file: " + path.wstr());
return "";
}
@@ -161,7 +161,7 @@ namespace utility
}
else
{
LOG_ERROR("Syntax error in file: " + path.str());
LOG_ERROR(L"Syntax error in file: " + path.wstr());
return "";
}
}
@@ -174,7 +174,7 @@ namespace utility
std::vector<std::string> values = utility::splitToVector(val, '|');
if (values.size() != 3)
{
LOG_ERROR("Syntax error in file: " + path.str());
LOG_ERROR(L"Syntax error in file: " + path.wstr());
return "";
}
@@ -188,7 +188,7 @@ namespace utility
}
else
{
LOG_ERROR("Syntax error in file: " + path.str());
LOG_ERROR(L"Syntax error in file: " + path.wstr());
return "";
}
+1 -1
View File
@@ -36,7 +36,7 @@ void QtRecentProjectButton::setProjectPath(const FilePath& projectFilePath)
this->setText(QString::fromStdWString(m_projectFilePath.withoutExtension().fileName()));
if (m_projectExists)
{
this->setToolTip(m_projectFilePath.str().c_str());
this->setToolTip(QString::fromStdWString(m_projectFilePath.wstr()));
}
else
{