Dialog layout

This commit is contained in:
Stojce Slavkovski 2013-12-22 15:06:40 +01:00
parent fdb1bf5622
commit 3d44ab9939
9 changed files with 213 additions and 19 deletions

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="17.186px" height="14px" viewBox="0 0 17.186 14" enable-background="new 0 0 17.186 14" xml:space="preserve">
<g>
<path fill="#666666" d="M12,9.446v1.989C12,11.747,11.987,12,11.675,12H2.806C2.494,12,2,11.747,2,11.435V2.565
C2,2.253,2.494,2,2.806,2H11V0H2.806C1.392,0,0,1.151,0,2.565v8.869C0,12.849,1.392,14,2.806,14h8.869
C13.09,14,14,12.849,14,11.435V8.435L12,9.446z"/>
<path fill="#333333" d="M9.568,10.138c-0.3,0.299-0.769,0.299-1.069,0L4.466,6.105c-0.3-0.301-0.3-0.768,0-1.069l1.032-1.032
c0.3-0.299,0.769-0.299,1.069,0L9.033,6.47l6.068-6.068c0.3-0.299,0.769-0.299,1.069,0l1.032,1.032c0.3,0.301,0.3,0.768,0,1.069
L9.568,10.138z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -1,7 +1,53 @@
QPlainTextEdit {
font-family: Inconsolata, Lucida Console, Andale Mono, Monaco;
font-size: 16px;
padding-left: 28px;
padding-top: 7px;
color: #333333;
background-color: #FFFFFF;
border: none;
}
QLineEdit {
padding-left: 7px;
background-color: #CCCCCC;
border-width: 0;
border-top-right-radius: 9px;
border-bottom-right-radius: 9px;
color: #333333;
font-size: 12px;
}
QPushButton#searchButton {
background: url(resources/styles/search.svg);
background-repeat: none;
background-position: left center;
background-origin: content;
padding-left: 7px;
background-color: #CCCCCC;
border-width: 0;
border-top-left-radius: 9px;
border-bottom-left-radius: 9px;
}
QPushButton#revealLogButton {
background: url(resources/styles/txt-file.svg);
background-repeat: none;
background-position: left center;
background-origin: content;
padding-left: 10px;
background-color: #333333;
color: #BBBBBB;
border-width: 0;
border-radius: 9px;
font-size: 11px;
}
QCheckBox::indicator:unchecked {
image: url(resources/styles/unchecked.svg);
}
QCheckBox::indicator:checked {
image: url(resources/styles/checked.svg);
}

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="12px" height="12px" viewBox="0 0 12 12" enable-background="new 0 0 12 12" xml:space="preserve">
<g>
<path d="M10.716,11.573c-0.228,0-0.449-0.094-0.603-0.254L7.815,9.028C7.032,9.57,6.094,9.858,5.143,9.858
c-2.606,0-4.716-2.11-4.716-4.716s2.11-4.716,4.716-4.716s4.716,2.11,4.716,4.716c0,0.951-0.288,1.889-0.831,2.673l2.297,2.297
c0.154,0.154,0.248,0.375,0.248,0.603C11.573,11.185,11.185,11.573,10.716,11.573z M5.143,2.142c-1.655,0-3.001,1.346-3.001,3.001
s1.346,3.001,3.001,3.001s3.001-1.346,3.001-3.001S6.797,2.142,5.143,2.142z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 929 B

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="12.927px" height="15.106px" viewBox="0 0 12.927 15.106" enable-background="new 0 0 12.927 15.106" xml:space="preserve">
<g>
<path fill="#CCCCCC" d="M12.148,13.667c0,0.503-0.408,0.911-0.911,0.911H0.911C0.408,14.578,0,14.17,0,13.667V0.911
C0,0.408,0.408,0,0.911,0h6.074c0.503,0,1.206,0.294,1.557,0.646l2.961,2.961c0.351,0.351,0.646,1.054,0.646,1.557V13.667z
M10.934,13.363V6.074H6.985c-0.503,0-0.911-0.408-0.911-0.911V1.215H1.215v12.148H10.934z M9.719,8.2
c0,0.171-0.133,0.304-0.304,0.304H2.733C2.562,8.504,2.43,8.371,2.43,8.2V7.593c0-0.171,0.133-0.304,0.304-0.304h6.682
c0.171,0,0.304,0.133,0.304,0.304V8.2z M9.719,10.63c0,0.171-0.133,0.304-0.304,0.304H2.733c-0.171,0-0.304-0.133-0.304-0.304
v-0.607c0-0.171,0.133-0.304,0.304-0.304h6.682c0.171,0,0.304,0.133,0.304,0.304V10.63z M10.857,4.859
c-0.057-0.161-0.142-0.323-0.208-0.389L7.678,1.5C7.612,1.433,7.45,1.348,7.289,1.291v3.568H10.857z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="17.186px" height="14px" viewBox="0 0 17.186 14" enable-background="new 0 0 17.186 14" xml:space="preserve">
<g>
<path fill="#666666" d="M14,11.435C14,12.851,12.851,14,11.435,14H2.565C1.149,14,0,12.851,0,11.435V2.565C0,1.149,1.149,0,2.565,0
h8.869C12.851,0,14,1.149,14,2.565V11.435z M12,2.565C12,2.253,11.747,2,11.435,2H2.565C2.253,2,2,2.253,2,2.565v8.869
C2,11.747,2.253,12,2.565,12h8.869C11.747,12,12,11.747,12,11.435V2.565z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 825 B

View file

@ -156,13 +156,16 @@ void LogDisplay::addMessage(const char* ptr) {
pthread_mutex_unlock(& _mutex);
}
QStringList LogDisplay::getLogData() {
QStringList LogDisplay::getLogData(QString searchText) {
// wait for adding new log data whilr iterating over _lines
pthread_mutex_lock(& _mutex);
QStringList list;
int i = 0;
while (_lines[i] != *_lastLinePos) {
list.append(_lines[i++]);
if (searchText.isEmpty() || QString(_lines[i]).contains(searchText, Qt::CaseInsensitive)) {
list.append(_lines[i]);
}
i++;
}
pthread_mutex_unlock(& _mutex);
return list;

View file

@ -44,7 +44,7 @@ public:
static unsigned const LINE_BUFFER_SIZE = 256; // number of lines that are buffered
static unsigned const MAX_MESSAGE_LENGTH = 512; // maximum number of characters for a message
QStringList getLogData();
QStringList getLogData(QString);
signals:
void logReceived(QString message);

View file

@ -14,7 +14,17 @@
#include "ui/LogDialog.h"
#include "LogDisplay.h"
const int INITIAL_WIDTH = 720;
const int TOP_BAR_HEIGHT = 46;
const int INITIAL_WIDTH = 720;
const int MINIMAL_WIDTH = 570;
const int ELEMENT_MARGIN = 7;
const int ELEMENT_HEIGHT = 32;
const int SEARCH_BUTTON_LEFT = 25;
const int SEARCH_BUTTON_WIDTH = 20;
const int SEARCH_TEXT_WIDTH = 240;
const int CHECKBOX_MARGIN = 12;
const int CHECKBOX_WIDTH = 140;
const int REVEAL_BUTTON_WIDTH = 122;
const float INITIAL_HEIGHT_RATIO = 0.6f;
int cursorMeta = qRegisterMetaType<QTextCursor>("QTextCursor");
@ -23,46 +33,85 @@ int blockMeta = qRegisterMetaType<QTextBlock>("QTextBlock");
LogDialog::LogDialog(QWidget* parent) : QDialog(parent, Qt::Dialog) {
setWindowTitle("Log");
_logTextBox = new QPlainTextEdit(this);
_logTextBox->setReadOnly(true);
_logTextBox->show();
setAttribute(Qt::WA_DeleteOnClose);
switchToResourcesParentIfRequired();
QFile styleSheet("resources/styles/log_dialog.qss");
if (styleSheet.open(QIODevice::ReadOnly)) {
setStyleSheet(styleSheet.readAll());
}
initControls();
QDesktopWidget desktop;
QRect screen = desktop.screenGeometry();
resize(INITIAL_WIDTH, static_cast<int>(screen.height() * INITIAL_HEIGHT_RATIO));
move(screen.center() - rect().center());
setAttribute(Qt::WA_DeleteOnClose);
setMinimumWidth(MINIMAL_WIDTH);
}
LogDialog::~LogDialog() {
deleteLater();
}
void LogDialog::showEvent(QShowEvent *e) {
_logTextBox->clear();
void LogDialog::initControls() {
pthread_mutex_lock(& _mutex);
QStringList _logData = LogDisplay::instance.getLogData();
int left;
_searchButton = new QPushButton(this);
// set object name for css styling
_searchButton->setObjectName("searchButton");
left = SEARCH_BUTTON_LEFT;
_searchButton->setGeometry(left, ELEMENT_MARGIN, SEARCH_BUTTON_WIDTH, ELEMENT_HEIGHT);
left += SEARCH_BUTTON_WIDTH;
_searchButton->show();
connect(_searchButton, SIGNAL(clicked()), SLOT(handleSearchButton()));
_searchTextBox = new QLineEdit(this);
// disable blue outline in Mac
_searchTextBox->setAttribute(Qt::WA_MacShowFocusRect, false);
_searchTextBox->setGeometry(left, ELEMENT_MARGIN, SEARCH_TEXT_WIDTH, ELEMENT_HEIGHT);
left += SEARCH_TEXT_WIDTH + CHECKBOX_MARGIN;
_searchTextBox->show();
connect(_searchTextBox, SIGNAL(textChanged(QString)), SLOT(handleSeachTextChanged(QString)));
_extraDebuggingBox = new QCheckBox("Extra debugging", this);
_extraDebuggingBox->setGeometry(left, ELEMENT_MARGIN, CHECKBOX_WIDTH, ELEMENT_HEIGHT);
_extraDebuggingBox->show();
connect(_extraDebuggingBox, SIGNAL(stateChanged(int)), SLOT(handleExtraDebuggingCheckbox(int)));
_revealLogButton = new QPushButton("Reveal log file", this);
// set object name for css styling
_revealLogButton->setObjectName("revealLogButton");
_revealLogButton->show();
connect(_revealLogButton, SIGNAL(clicked()), SLOT(handleRevealButton()));
_logTextBox = new QPlainTextEdit(this);
_logTextBox->setReadOnly(true);
_logTextBox->show();
}
void LogDialog::showEvent(QShowEvent *e) {
_searchTextBox->clear();
_searchTextBox->setText("");
/* pthread_mutex_lock(& _mutex);
QStringList _logData = LogDisplay::instance.getLogData("");
connect(&LogDisplay::instance, &LogDisplay::logReceived, this, &LogDialog::appendLogLine);
for(int i = 0; i < _logData.size(); ++i) {
appendLogLine(_logData[i]);
}
pthread_mutex_unlock(& _mutex);
pthread_mutex_unlock(& _mutex);*/
}
void LogDialog::resizeEvent(QResizeEvent *e) {
_logTextBox->resize(width(), height());
_logTextBox->setGeometry(0, TOP_BAR_HEIGHT, width(), height() - TOP_BAR_HEIGHT);
_revealLogButton->setGeometry(width() - ELEMENT_MARGIN - REVEAL_BUTTON_WIDTH,
ELEMENT_MARGIN,
REVEAL_BUTTON_WIDTH,
ELEMENT_HEIGHT);
}
void LogDialog::appendLogLine(QString logLine) {
@ -73,3 +122,33 @@ void LogDialog::appendLogLine(QString logLine) {
_logTextBox->ensureCursorVisible();
}
}
void LogDialog::handleSearchButton() {
_searchTextBox->setFocus();
}
void LogDialog::handleRevealButton() {
}
void LogDialog::handleExtraDebuggingCheckbox(int state) {
}
void LogDialog::handleSeachTextChanged(QString searchText) {
if (searchText.isEmpty()) {
connect(&LogDisplay::instance, &LogDisplay::logReceived, this, &LogDialog::appendLogLine);
} else {
disconnect(&LogDisplay::instance, &LogDisplay::logReceived, this, &LogDialog::appendLogLine);
}
_logTextBox->clear();
pthread_mutex_lock(& _mutex);
QStringList _logData = LogDisplay::instance.getLogData(searchText);
for(int i = 0; i < _logData.size(); ++i) {
appendLogLine(_logData[i]);
}
pthread_mutex_unlock(& _mutex);
}

View file

@ -11,6 +11,9 @@
#include <QDialog>
#include <QPlainTextEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QCheckBox>
class LogDialog : public QDialog {
Q_OBJECT
@ -22,14 +25,25 @@ public:
public slots:
void appendLogLine(QString logLine);
private slots:
void handleSearchButton();
void handleRevealButton();
void handleExtraDebuggingCheckbox(const int);
void handleSeachTextChanged(QString);
protected:
void resizeEvent(QResizeEvent* e);
void showEvent(QShowEvent* e);
void resizeEvent(QResizeEvent*);
void showEvent(QShowEvent*);
private:
QPushButton* _searchButton;
QLineEdit* _searchTextBox;
QCheckBox* _extraDebuggingBox;
QPushButton* _revealLogButton;
QPlainTextEdit* _logTextBox;
pthread_mutex_t _mutex;
void initControls();
};
#endif