ui: usability improvements

* darkened red of error message in status bar
* added status error when not defined startupproject
* added tooltips for remaining search view buttons
* added filepath as tooptip for title in code view
* opening file when clicking title in code view
This commit is contained in:
Eberhard Graether
2015-05-03 00:52:04 +02:00
parent aa0c40b213
commit 7231ae36f6
9 changed files with 62 additions and 20 deletions
+14
View File
@@ -6,6 +6,14 @@
padding: 4px 12px;
}
#code_file #title_label:hover {
background: #D2D2D2;
}
#code_file #title_label:disabled {
color: black;
}
#code_snippet {
font-family: "Source Code Pro";
font-size: 14px;
@@ -29,3 +37,9 @@
#code_snippet #maximize_button:enabled {
border-image: url(data/gui/code_view/images/button_maximize.png);
}
QToolTip {
background-color: rgb(204, 204, 204);
border: 1px solid rgb(0, 0, 0);
color: rgb(0, 0, 0);
}
+25 -11
View File
@@ -1,13 +1,14 @@
#include "qt/element/QtCodeFile.h"
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>
#include "utility/messaging/type/MessageShowFile.h"
#include "qt/element/QtCodeFileList.h"
#include "qt/element/QtCodeSnippet.h"
#include "utility/file/FileSystem.h"
QtCodeFile::QtCodeFile(const std::string& filePath, QtCodeFileList* parent)
QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent)
: QWidget(parent)
, m_parent(parent)
, m_filePath(filePath)
@@ -20,26 +21,32 @@ QtCodeFile::QtCodeFile(const std::string& filePath, QtCodeFileList* parent)
layout->setAlignment(Qt::AlignTop);
setLayout(layout);
QLabel* label = new QLabel(FileSystem::fileName(filePath).c_str(), this);
label->setObjectName("title_label");
label->minimumSizeHint(); // force font loading
label->setFixedWidth(label->fontMetrics().width(FileSystem::fileName(filePath).c_str()) + 32);
label->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
layout->addWidget(label);
m_title = new QPushButton(filePath.fileName().c_str(), this);
m_title->setObjectName("title_label");
m_title->minimumSizeHint(); // force font loading
m_title->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_title->setToolTip(QString::fromStdString(filePath.str()));
m_title->setFixedWidth(m_title->fontMetrics().width(filePath.fileName().c_str()) + 32);
m_title->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
layout->addWidget(m_title);
connect(m_title, SIGNAL(clicked()), this, SLOT(clickedTitle()));
update();
}
QtCodeFile::~QtCodeFile()
{
}
const std::string& QtCodeFile::getFilePath() const
const FilePath& QtCodeFile::getFilePath() const
{
return m_filePath;
}
std::string QtCodeFile::getFileName() const
{
return FileSystem::fileName(m_filePath);
return m_filePath.fileName();
}
const std::vector<Id>& QtCodeFile::getActiveTokenIds() const
@@ -86,4 +93,11 @@ void QtCodeFile::update()
{
snippet->update();
}
m_title->setEnabled(m_parent->getShowMaximizeButton());
}
void QtCodeFile::clickedTitle()
{
MessageShowFile(m_filePath.absoluteStr(), 0, 0).dispatch();
}
+14 -4
View File
@@ -7,19 +7,24 @@
#include <QWidget>
#include "utility/file/FilePath.h"
#include "utility/types.h"
class QPushButton;
class QtCodeFileList;
class QtCodeSnippet;
class TokenLocationFile;
class QtCodeFile : public QWidget
class QtCodeFile
: public QWidget
{
Q_OBJECT
public:
QtCodeFile(const std::string& filePath, QtCodeFileList* parent);
QtCodeFile(const FilePath& filePath, QtCodeFileList* parent);
virtual ~QtCodeFile();
const std::string& getFilePath() const;
const FilePath& getFilePath() const;
std::string getFileName() const;
const std::vector<Id>& getActiveTokenIds() const;
const std::vector<std::string>& getErrorMessages() const;
@@ -32,11 +37,16 @@ public:
void update();
private slots:
void clickedTitle();
private:
QtCodeFileList* m_parent;
QPushButton* m_title;
std::vector<std::shared_ptr<QtCodeSnippet>> m_snippets;
const std::string m_filePath;
const FilePath m_filePath;
};
#endif // QT_CODE_FILE_H
+3 -3
View File
@@ -39,12 +39,12 @@ void QtCodeFileList::addCodeSnippet(
const std::string& code,
const TokenLocationFile& locationFile
){
std::string fileName = locationFile.getFilePath().fileName();
FilePath filePath = locationFile.getFilePath();
QtCodeFile* file = nullptr;
for (std::shared_ptr<QtCodeFile> filePtr : m_files)
{
if (filePtr->getFileName() == fileName)
if (filePtr->getFilePath() == filePath)
{
file = filePtr.get();
break;
@@ -53,7 +53,7 @@ void QtCodeFileList::addCodeSnippet(
if (!file)
{
std::shared_ptr<QtCodeFile> filePtr = std::make_shared<QtCodeFile>(locationFile.getFilePath().absoluteStr(), this);
std::shared_ptr<QtCodeFile> filePtr = std::make_shared<QtCodeFile>(locationFile.getFilePath(), this);
m_files.push_back(filePtr);
file = filePtr.get();
+1 -1
View File
@@ -272,7 +272,7 @@ void QtCodeSnippet::updateLineNumberArea(const QRect &rect, int dy)
void QtCodeSnippet::clickedMaximizeButton()
{
MessageShowFile(m_parent->getFilePath(), m_startLineNumber, m_startLineNumber + blockCount() - 1).dispatch();
MessageShowFile(m_parent->getFilePath().absoluteStr(), m_startLineNumber, m_startLineNumber + blockCount() - 1).dispatch();
}
void QtCodeSnippet::clearSelection()
+1
View File
@@ -36,6 +36,7 @@ QtSearchBar::QtSearchBar()
m_searchButton = new QPushButton(this);
m_searchButton->setObjectName("search_button");
m_searchButton->setToolTip("search");
m_searchButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_searchButton->setIcon(QIcon("data/gui/search_view/images/search.png"));
layout->addWidget(m_searchButton);
+1 -1
View File
@@ -29,7 +29,7 @@ void QtStatusBar::setText(const std::string& text, bool isError, bool showLoader
{
if (isError)
{
m_text.setStyleSheet("QLabel { color: red }");
m_text.setStyleSheet("QLabel { color: #E00000 }");
}
else
{
+2
View File
@@ -13,12 +13,14 @@ QtUndoRedo::QtUndoRedo()
m_undoButton = new QPushButton(this);
m_undoButton->setObjectName("undo_button");
m_undoButton->setToolTip("undo");
m_undoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_undoButton->setIcon(QIcon("data/gui/undoredo_view/images/arrow_left.png"));
m_undoButton->setEnabled(false);
m_redoButton = new QPushButton(this);
m_redoButton->setObjectName("redo_button");
m_redoButton->setToolTip("redo");
m_redoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_redoButton->setIcon(QIcon("data/gui/undoredo_view/images/arrow_right.png"));
m_redoButton->setEnabled(false);
+1
View File
@@ -33,6 +33,7 @@ std::shared_ptr<Application> Application::create(ViewFactory* viewFactory)
}
else
{
MessageStatus("StartupProject was not defined in the ApplicationSettings", true).dispatch();
LOG_WARNING("No StartupProject defined in ApplicationSettings");
}