cabana: improve layout (#27039)

improve layout
This commit is contained in:
Dean Lee 2023-01-25 08:14:08 +08:00 committed by GitHub
parent d1c87faedc
commit 81956649c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 3 deletions

View File

@ -11,6 +11,7 @@
// BinaryView
const int CELL_HEIGHT = 36;
const int VERTICAL_HEADER_WIDTH = 30;
inline int get_bit_index(const QModelIndex &index, bool little_endian) {
return index.row() * 8 + (little_endian ? 7 - index.column() : index.column());
@ -33,6 +34,10 @@ BinaryView::BinaryView(QWidget *parent) : QTableView(parent) {
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
}
QSize BinaryView::minimumSizeHint() const {
return {horizontalHeader()->minimumSectionSize() * 9 + VERTICAL_HEADER_WIDTH + 2, 0};
}
void BinaryView::highlight(const Signal *sig) {
if (sig != hovered_sig) {
hovered_sig = sig;
@ -215,7 +220,7 @@ QVariant BinaryViewModel::headerData(int section, Qt::Orientation orientation, i
if (orientation == Qt::Vertical) {
switch (role) {
case Qt::DisplayRole: return section;
case Qt::SizeHintRole: return QSize(30, 0);
case Qt::SizeHintRole: return QSize(VERTICAL_HEADER_WIDTH, 0);
case Qt::TextAlignmentRole: return Qt::AlignCenter;
}
}

View File

@ -60,6 +60,7 @@ public:
void highlight(const Signal *sig);
QSet<const Signal*> getOverlappingSignals() const;
inline void updateState() { model->updateState(); }
QSize minimumSizeHint() const override;
signals:
void signalClicked(const Signal *sig);

View File

@ -16,7 +16,6 @@
DetailWidget::DetailWidget(ChartsWidget *charts, QWidget *parent) : charts(charts), QWidget(parent) {
undo_stack = new QUndoStack(this);
setMinimumWidth(500);
QWidget *main_widget = new QWidget(this);
QVBoxLayout *main_layout = new QVBoxLayout(main_widget);
main_layout->setContentsMargins(0, 0, 0, 0);

View File

@ -31,6 +31,7 @@ public:
DetailWidget(ChartsWidget *charts, QWidget *parent);
void setMessage(const QString &message_id);
void dbcMsgChanged(int show_form_idx = -1);
QSize minimumSizeHint() const override { return binary_view->minimumSizeHint(); }
QUndoStack *undo_stack = nullptr;
private:

View File

@ -24,7 +24,6 @@ void qLogMessageHandler(QtMsgType type, const QMessageLogContext &context, const
MainWindow::MainWindow() : QMainWindow() {
createDockWindows();
detail_widget = new DetailWidget(charts_widget, this);
detail_widget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
setCentralWidget(detail_widget);
createActions();
createStatusBar();