ui: polishing for presentation

* enabled highDpi icons in QApplication for Searchbar Icons
* realigned StartScreen contents
* showing version number 0.1
* "Search" as placeholder text in SearchBar
* same content margins for each dockwidget view
* brighter variable color in Graph
* press ESC to close StartScreen
This commit is contained in:
Eberhard Graether
2015-05-30 21:18:18 +02:00
parent 0153330317
commit 3e419bb41f
21 changed files with 192 additions and 166 deletions
@@ -70,20 +70,20 @@
<hover>#F4BC3D</hover>
</method>
<field>
<normal>#6DA1BC</normal>
<hover>#3190BA</hover>
<normal>#7BB5D4</normal>
<hover>#42A1D4</hover>
</field>
<global>
<normal>#6DA1BC</normal>
<hover>#3190BA</hover>
<normal>#7BB5D4</normal>
<hover>#42A1D4</hover>
</global>
<undefined>
<normal>#00000000</normal>
<hover>#00000000</hover>
</undefined>
<undefined_variable>
<normal>#6DA1BC</normal>
<hover>#3190BA</hover>
<normal>#7BB5D4</normal>
<hover>#42A1D4</hover>
</undefined_variable>
<undefined_function>
<normal>#F4D07D</normal>
@@ -102,8 +102,8 @@
<hover>#ededed</hover>
</typedef>
<enum_constant>
<normal>#6DA1BC</normal>
<hover>#3190BA</hover>
<normal>#7BB5D4</normal>
<hover>#42A1D4</hover>
</enum_constant>
<template_parameter_type>
<normal>#ededed</normal>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

@@ -5,7 +5,6 @@
QPushButton {
background: #E0E0E0;
border: none;
background-position: 15px 5px;
height: 30px;
width: 30px;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

+11 -43
View File
@@ -1,19 +1,16 @@
#include <memory>
#include <QApplication>
#include <QBitmap>
#include <QThread>
#include <QSplashScreen>
#include <QtWidgets/qmainwindow.h>
#include "utility/logging/ConsoleLogger.h"
#include "utility/logging/FileLogger.h"
#include "utility/logging/LogManager.h"
#include "Application.h"
#include "includes.h" // defines 'void setup(int argc, char *argv[])'
#include "qt/element/QtSplashScreen.h"
#include "qt/utility/utilityQt.h"
#include "qt/view/QtViewFactory.h"
#include "utility/logging/ConsoleLogger.h"
#include "utility/logging/FileLogger.h"
#include "utility/logging/LogManager.h"
void init()
{
@@ -28,56 +25,27 @@ void init()
utility::loadFontsFromDirectory("data/fonts", ".otf");
}
class InitThread : public QThread
{
public:
void run(void)
{
//min Time the Splash screen is displayed
QThread::msleep(500);
}
};
int main(int argc, char *argv[])
{
setup(argc, argv);
QApplication qtApp(argc, argv);
QPixmap whitePixmap(500,500);
qtApp.setAttribute(Qt::AA_UseHighDpiPixmaps);
QPixmap whitePixmap(500, 500);
whitePixmap.fill(Qt::white);
QPixmap p;
p.load("data/gui/splash_white.png");
QPixmap foreground = p.scaled(whitePixmap.size()*0.8);
p.load("data/gui/splash_blue.png");
QPixmap background = p.scaled(whitePixmap.size()*0.9);
QtSplashScreen* splash = new QtSplashScreen(whitePixmap, Qt::WindowStaysOnTopHint);
qtApp.processEvents();
splash->setForeground(foreground);
splash->setBackground(background);
splash->show();
splash->repaint();
qtApp.processEvents();
if (splash) splash->message( "Starting GUI" );
qtApp.processEvents();
splash->setMessage("Loading UI");
splash->setVersion("0.1");
splash->exec(qtApp);
init();
// Eventloop for Splashscreen
QEventLoop loop;
InitThread* initThread = new InitThread();
QObject::connect(initThread, SIGNAL(finished()), &loop, SLOT(quit()));
QObject::connect(initThread, SIGNAL(terminated()), &loop, SLOT(quit()));
initThread->start();
loop.exec();
QtViewFactory viewFactory;
std::shared_ptr<Application> app = Application::create(&viewFactory);
if(splash)
if (splash)
{
delete splash;
}
+7 -4
View File
@@ -42,10 +42,10 @@ QtMainWindow::QtMainWindow()
// Seconde call is in Application.cpp
loadLayout();
//startScreen
startScreen = std::make_shared<QtStartScreen>(this);
startScreen->setWindowModality(Qt::WindowModal);
startScreen->show();
// StartScreen
m_startScreen = std::make_shared<QtStartScreen>(this);
m_startScreen->setWindowModality(Qt::WindowModal);
m_startScreen->show();
}
QtMainWindow::~QtMainWindow()
@@ -57,6 +57,8 @@ void QtMainWindow::addView(View* view)
QDockWidget* dock = new QDockWidget(tr(view->getName().c_str()), this);
dock->setWidget(QtViewWidgetWrapper::getWidgetOfView(view));
dock->setObjectName(QString::fromStdString("Dock" + view->getName()));
// dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
// dock->setTitleBarWidget(new QWidget());
addDockWidget(Qt::TopDockWidgetArea, dock);
m_dockWidgets.push_back(std::make_pair(view, dock));
}
@@ -216,6 +218,7 @@ void QtMainWindow::redo()
void QtMainWindow::handleEscapeShortcut()
{
m_startScreen->hide();
MessageInterruptTasks().dispatch();
}
+2 -1
View File
@@ -56,7 +56,8 @@ private:
void setupShortcuts();
QDockWidget* getDockWidgetForView(View* view) const;
std::shared_ptr<QtStartScreen> startScreen;
std::shared_ptr<QtStartScreen> m_startScreen;
std::vector<std::pair<View*, QDockWidget*>> m_dockWidgets;
+1 -1
View File
@@ -781,7 +781,7 @@ void QtSmartSearchBox::updatePlaceholder()
{
if (!text().size() && !m_elements.size())
{
setPlaceholderText("Please enter your search string.");
setPlaceholderText("Search");
}
else
{
+82 -42
View File
@@ -1,63 +1,103 @@
#include "QtSplashScreen.h"
#include <QApplication>
#include <QThread>
#include <QTimer>
QtSplashScreen::QtSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f) : QSplashScreen (pixmap, f)
#include "qt/utility/QtDeviceScaledPixmap.h"
namespace
{
state = 0;
QTimer *timer = new QTimer( this );
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
timer->start(150);
show();
repaint();
class InitThread : public QThread
{
public:
void run(void)
{
// Mininmum time the SplashScreen gets displayed.
QThread::msleep(5000);
}
};
}
QtSplashScreen::QtSplashScreen(const QPixmap &pixmap, Qt::WindowFlags f)
: QSplashScreen(pixmap, f)
, m_state(0)
{
QtDeviceScaledPixmap foreground("data/gui/splash_white.png");
foreground.scaleToHeight(pixmap.size().height() * 0.8);
m_foreground = foreground.pixmap();
QtDeviceScaledPixmap background("data/gui/splash_blue.png");
background.scaleToHeight(pixmap.size().height() * 0.9);
m_background = background.pixmap();
}
QtSplashScreen::~QtSplashScreen()
{
}
void QtSplashScreen::exec(QApplication& app)
{
m_state = 0;
QTimer* timer = new QTimer(this);
QObject::connect(timer, SIGNAL(timeout()), this, SLOT(animate()));
timer->start(150);
app.processEvents();
show();
repaint();
app.processEvents();
// Eventloop for the SplashScreen
// QEventLoop loop;
// InitThread* initThread = new InitThread();
// QObject::connect(initThread, SIGNAL(finished()), &loop, SLOT(quit()));
// initThread->start();
// loop.exec();
}
void QtSplashScreen::setMessage(const QString &str)
{
m_string = str;
repaint();
}
void QtSplashScreen::setVersion(const QString &str)
{
m_version = str;
repaint();
}
void QtSplashScreen::animate()
{
state = (state+2)%120;
repaint();
}
void QtSplashScreen::setBackground(QPixmap& pixmap)
{
m_Background = pixmap;
}
void QtSplashScreen::setForeground(QPixmap &pixmap)
{
m_Foreground = pixmap;
}
void QtSplashScreen::message(const QString &str, int flag, const QColor &color)
{
QSplashScreen::showMessage(str,flag,color);
animate();
m_string = str;
m_state = (m_state + 2) % 120;
repaint();
}
void QtSplashScreen::drawContents(QPainter *painter)
{
painter->save();
painter->translate(rect().width()/2,rect().height()/2);
painter->rotate(state*3);
painter->drawPixmap(-rect().width()*0.9/2,-rect().height()*0.9/2,m_Background);
painter->restore();
painter->drawPixmap(rect().width()*0.1,rect().height()*0.1,m_Foreground);
painter->save();
painter->translate(rect().width() / 2, rect().height() / 2);
painter->rotate(m_state * 3);
painter->drawPixmap(-rect().width() * 0.9 / 2, -rect().height() * 0.9 / 2, m_background);
painter->restore();
painter->drawPixmap(rect().width() * 0.1, rect().height() * 0.1, m_foreground);
painter->setPen(QColor(74,112,18));
QRect r = rect();
r.setRect(r.x() + 5, r.y() + 5, r.width() - 10, r.height() - 10);
QRect r = rect();
r.setRect(r.x() + 5, r.height() - 20, r.width() - 10, 20);
// TODO: automated Version number
painter->drawText(r, Qt::AlignRight, "Version 0.0.0");
// TODO: automated Version number
painter->drawText(r, Qt::AlignRight, QString("Coati v").append(m_version));
// Draw message at given position, limited to 43 chars
// If message is too long, string is truncated
if (m_string.length() > 40) {m_string.truncate(39); m_string += "...";}
painter->drawText(90, 16,m_string);
// Draw message at given position, limited to 43 chars
// If message is too long, string is truncated
if (m_string.length() > 40)
{
m_string.truncate(39);
m_string += "...";
}
painter->drawText(r, Qt::AlignLeft, m_string);
}
+20 -15
View File
@@ -5,30 +5,35 @@
#include <QPainter>
#include <QWidget>
class QApplication;
class QPixmap;
class QtSplashScreen : public QSplashScreen
class QtSplashScreen
: public QSplashScreen
{
Q_OBJECT
Q_OBJECT
public:
QtSplashScreen(const QPixmap& pixmap, Qt::WindowFlags f = 0);
QtSplashScreen(Qt::WindowFlags f = 0);
virtual ~QtSplashScreen();
void setBackground(QPixmap& pixmap);
void setForeground(QPixmap& pixmap);
protected:
void drawContents(QPainter* painter);
QtSplashScreen(const QPixmap& pixmap, Qt::WindowFlags f = 0);
virtual ~QtSplashScreen();
void exec(QApplication& app);
void setMessage(const QString& str);
void setVersion(const QString& str);
public slots:
void animate();
void message(const QString& str, int flag = Qt::AlignLeft, const QColor& color = Qt::black);
void animate();
private:
QString m_string;
int state;
QPixmap m_Background;
QPixmap m_Foreground;
void drawContents(QPainter* painter);
int m_state;
QString m_string;
QString m_version;
QPixmap m_background;
QPixmap m_foreground;
};
#endif //QTSPLASHSCREEN_H
+54 -46
View File
@@ -1,17 +1,17 @@
#include <QtWidgets/qlabel.h>
#include "QtStartScreen.h"
#include <QPainter>
#include <QKeyEvent>
#include <QLabel>
#include "utility/file/FileSystem.h"
#include "utility/messaging/type/MessageLoadProject.h"
#include "qt/utility/QtDeviceScaledPixmap.h"
QtRecentProjectButton::QtRecentProjectButton(const QString &text, QWidget *parent)
: QPushButton(text, parent)
{
m_projectFile = text.toStdString();
this->setText(FileSystem::fileName(FileSystem::filePathWithoutExtension(text.toStdString())).c_str());
this->setText(FileSystem::fileName(text.toStdString()).c_str());
}
void QtRecentProjectButton::handleButtonClick()
@@ -23,37 +23,41 @@ void QtRecentProjectButton::handleButtonClick()
QtStartScreen::QtStartScreen(QWidget *parent)
: QWidget(parent, Qt::Dialog | Qt::Popup | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint )
{
setGeometry(parent->pos().x()+parent->width()/2-350,parent->pos().y()+parent->height()/2-250,600,500);
setGeometry(parent->pos().x()+parent->width()/2-250,parent->pos().y()+parent->height()/2-250,500,500);
QPalette palette;
QLinearGradient linearGradient(QPointF(0, 0), QPointF(0, 500));
linearGradient.setColorAt(0, QColor(46,61,135));
linearGradient.setColorAt(1, QColor(0,120,195));
palette.setBrush(QPalette::Window,*(new QBrush(linearGradient)));
QLinearGradient linearGradient(QPointF(0, 275), QPointF(0, 500));
linearGradient.setColorAt(0, QColor(46, 61, 135));
linearGradient.setColorAt(1, QColor(0, 120, 195));
palette.setBrush(QPalette::Window, *(new QBrush(linearGradient)));
this->setPalette(palette);
//QPixmap coati_logo("data/gui/logo_coati.png");
QPixmap coati_logo("data/gui/startscreen/logo_white.png");
QPixmap cpp_icon("data/gui/startscreen/cpluspluss_icon.png");
QtDeviceScaledPixmap coati_logo("data/gui/startscreen/logo_white.png");
coati_logo.scaleToWidth(100);
QLabel* coatiLogoLabel = new QLabel(this);
coatiLogoLabel->setPixmap(coati_logo);
coatiLogoLabel->setGeometry(30,30,100,138);
coatiLogoLabel->setPixmap(coati_logo.pixmap());
coatiLogoLabel->setGeometry(30, 30, coati_logo.width(), coati_logo.height());
std::string buttonStyle =
"QPushButton{font-family: "
"Source Code Pro; "
"font-size: 17pt; "
"border-radius: 15px; "
"background: white} "
"QPushButton:hover {background:lightgrey;}";
"QPushButton {"
"font-size: 17pt; "
"border-radius: 10px; "
"background: white; "
"} "
"QPushButton:hover {"
"background: rgba(255, 255, 255, 0.8); "
"}";
m_newProjectButton = new QPushButton("New Project", this);
m_newProjectButton->setGeometry(20,350, 200, 50);
m_newProjectButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_newProjectButton->setGeometry(30, 375, 140, 30);
m_newProjectButton->setStyleSheet(buttonStyle.c_str());
connect(m_newProjectButton, SIGNAL(clicked()), this, SLOT(handleNewProjectButton()));
m_openProjectButton = new QPushButton("Open Project", this);
m_openProjectButton->setGeometry(20,420, 200, 50);
m_openProjectButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_openProjectButton->setGeometry(30, 420, 140, 30);
m_openProjectButton->setStyleSheet(buttonStyle.c_str());
connect(m_openProjectButton, SIGNAL(clicked()), this, SLOT(handleOpenProjectButton()));
@@ -61,47 +65,51 @@ QtStartScreen::QtStartScreen(QWidget *parent)
connect(this, SIGNAL(openNewProjectDialog()), parent, SLOT(newProject()));
QLabel* recentProjectsLabel = new QLabel("RECENT PROJECTS: ", this);
QFont font("Helvetica", 20);
recentProjectsLabel->setFont(font);
recentProjectsLabel->setStyleSheet("QLabel{font-family: Source Code Pro; font-size: 20pt; color: white;}");
recentProjectsLabel->setGeometry(250, 100, 300, 50);
recentProjectsLabel->setGeometry(300, 129, 300, 50);
recentProjectsLabel->setStyleSheet(
"QLabel {"
"font-size: 16pt; "
"color: white; "
"}"
);
std::vector<std::string> extensions;
extensions.push_back(".xml");
std::vector<std::string> recentProjects = FileSystem::getFileNamesFromDirectory("data/projects", extensions);
int position = 150;
for(std::string project : recentProjects)
int position = 200;
QIcon cpp_icon("data/gui/startscreen/cpluspluss_icon.png");
for (std::string project : recentProjects)
{
QtRecentProjectButton* button = new QtRecentProjectButton(project.c_str(), this);
button->setGeometry(250, position, 400, 40);
button->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
button->setIcon(cpp_icon);
button->setIconSize(QSize(40,40));
button->setIconSize(QSize(25, 25));
button->setStyleSheet(
"QPushButton{"
"font-family: Source Code Pro; "
"font-size: 12pt; "
"Text-align:left; "
"color: white; "
"background:none; "
"border:none;} "
"QPushButton:hover{color:lightgrey;}");
"QPushButton{"
"font-size: 12pt; "
// "text-align: left; " // when using this the QPixmap is drawn without regard of the screens DPI
"color: white; "
"background: none; "
"border: none; "
"} "
"QPushButton:hover{"
"background: rgba(255, 255, 255, 0.15); "
"border-radius: 10px; "
"}"
);
button->minimumSizeHint(); // force font loading
button->setGeometry(292, position, button->fontMetrics().width(button->text()) + 45, 40);
connect(button, SIGNAL(clicked()), button, SLOT(handleButtonClick()));
position +=50;
position += 40;
}
this->raise();
}
QSize QtStartScreen::sizeHint() const
{
return QSize(500,500);
}
void QtStartScreen::paintEvent(QPaintEvent *event)
{
QPainter* painter = new QPainter(this);
return QSize(500, 500);
}
void QtStartScreen::handleNewProjectButton()
-4
View File
@@ -5,7 +5,6 @@
#include <QWidget>
#include <QtWidgets/qpushbutton.h>
class QtRecentProjectButton : public QPushButton
{
Q_OBJECT
@@ -25,8 +24,6 @@ public:
QtStartScreen(QWidget* parent = 0);
QSize sizeHint() const Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent* event);
signals:
void openOpenProjectDialog();
void openNewProjectDialog();
@@ -40,5 +37,4 @@ private:
std::vector<QPushButton*> m_recentProjects;
};
#endif //STARTSCREEN_H
@@ -36,6 +36,12 @@ public:
return m_pixmap.height() / devicePixelRatio();
}
void scaleToWidth(int width)
{
m_pixmap = m_pixmap.scaledToWidth(width * devicePixelRatio(), Qt::SmoothTransformation);
m_pixmap.setDevicePixelRatio(devicePixelRatio());
}
void scaleToHeight(int height)
{
m_pixmap = m_pixmap.scaledToHeight(height * devicePixelRatio(), Qt::SmoothTransformation);
+1 -1
View File
@@ -19,7 +19,7 @@ QtCompositeView::QtCompositeView(ViewLayout* viewLayout, CompositeDirection dire
}
layout->setSpacing(5);
layout->setContentsMargins(5, 5, 5, 5);
layout->setContentsMargins(8, 8, 8, 8);
layout->setAlignment(Qt::AlignTop);
m_widget = new QWidget();