-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandItemWidget.cpp
More file actions
48 lines (36 loc) · 1.35 KB
/
Copy pathCommandItemWidget.cpp
File metadata and controls
48 lines (36 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "CommandItemWidget.hpp"
#include <QVBoxLayout>
CommandItemWidget::CommandItemWidget(const QString &command,
const QString &remark, QWidget *parent)
: QWidget(parent), commandLabelPtr(new QLabel(this)),
remarkLabelPtr(new QLabel(this)) {
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(4, 4, 4, 4);
layout->setSpacing(8);
commandLabelPtr->setStyleSheet("font-size: 10pt;");
remarkLabelPtr->setStyleSheet("font-size: 9pt; color: #909090;");
commandLabelPtr->setWordWrap(false);
remarkLabelPtr->setWordWrap(false);
layout->addWidget(commandLabelPtr);
layout->addWidget(remarkLabelPtr);
setContent(command, remark);
}
void CommandItemWidget::setCommand(const QString &command) {
_command = command;
commandLabelPtr->setText(command);
}
void CommandItemWidget::setRemark(const QString &remark) {
_remark = remark;
remarkLabelPtr->setText(remark);
}
void CommandItemWidget::setContent(const QString &command,
const QString &remark) {
setCommand(command);
setRemark(remark);
}
QString CommandItemWidget::command() const { return _command; }
QString CommandItemWidget::remark() const { return _remark; }
QSize CommandItemWidget::sizeHint() const {
const QSize layoutSize = layout()->sizeHint();
return layoutSize + QSize(4, 4);
}