upsideLayout->setSpacing(0);
/* tab */
- QTabWidget *tabWidget = new QTabWidget(this);
+ tabWidget = new QTabWidget(this);
QWidget *vmInfo = new QWidget;
QWidget *shortcutInfo = new QWidget;
tabWidget->addTab(vmInfo, tr("VM Info"));
vmInfoTable->setColumnCount(2);
vmInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
vmInfoTable->setAlternatingRowColors(true);
-
vmInfoTable->verticalHeader()->hide();
- vmInfoTable->resizeRowsToContents();
- vmInfoTable->horizontalHeader()->setStretchLastSection(true);
- vmInfoTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
QStringList header;
header << "Feature" << "Value";
vmInfoTable->setHorizontalHeaderLabels(header);
+ /* shortcut info table */
+ shortcutInfoTable = new QTableWidget(shortcutInfo);
+ shortcutInfoTable->setColumnCount(2);
+ shortcutInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ shortcutInfoTable->setAlternatingRowColors(true);
+ shortcutInfoTable->verticalHeader()->hide();
+
+ header.clear();
+ header << "Function" << "Key sequence";
+ shortcutInfoTable->setHorizontalHeaderLabels(header);
+
/* table items */
int index = 0;
setDataTable(vmInfoTable, "VM Name", win->uiInfo->vmName, index++);
int tableHeight = vmInfoTable->horizontalHeader()->height();
for (int i = 0; i < vmInfoTable->rowCount(); i++) {
- tableHeight += vmInfoTable->rowHeight(i);
+ tableHeight += vmInfoTable->rowHeight(i);
}
- vmInfoTable->setMinimumWidth(200);
- vmInfoTable->setMinimumHeight(tableHeight + 2/*border*/);
+ vmInfoTable->setMinimumHeight(tableHeight + TABLE_BORDER_SIZE);
+ shortcutInfoTable->setMinimumHeight(tableHeight + TABLE_BORDER_SIZE);
- /* shortcut info table */
- shortcutInfoTable = new QTableWidget(shortcutInfo);
- shortcutInfoTable->setColumnCount(2);
- shortcutInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
- shortcutInfoTable->setAlternatingRowColors(true);
-
- shortcutInfoTable->verticalHeader()->hide();
- shortcutInfoTable->horizontalHeader()->setStretchLastSection(true);
- shortcutInfoTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
- shortcutInfoTable->setMinimumHeight(tableHeight + 2);
-
- header.clear();
- header << "Function" << "Key sequence";
- shortcutInfoTable->setHorizontalHeaderLabels(header);
-
- tabWidget->setMinimumWidth(vmInfoTable->width() + 60);
- tabWidget->setMinimumHeight(vmInfoTable->height() + 30);
+ QSize tabSize = tabWidget->tabBar()->sizeHint();
+ tabWidget->setMinimumHeight(vmInfoTable->height() + tabSize.height() + TABLE_BORDER_SIZE);
upsideLayout->addWidget(tabWidget);
table->setItem(index, 0, item);
item = new QTableWidgetItem(value);
table->setItem(index, 1, item);
+
+ resizeTableWidth();
+}
+
+void DetailedInfoDialog::resizeTableWidth()
+{
+ vmInfoTable->resizeColumnsToContents();
+ shortcutInfoTable->resizeColumnsToContents();
+
+ QSize scrollBarSize = shortcutInfoTable->verticalScrollBar()->sizeHint();
+ int vtWidth = vmInfoTable->columnWidth(0) + vmInfoTable->columnWidth(1) + TABLE_BORDER_SIZE;
+ int stWidth = shortcutInfoTable->columnWidth(0) + shortcutInfoTable->columnWidth(1)
+ + scrollBarSize.width() + TABLE_BORDER_SIZE;
+ int tableMinWidth = (vtWidth > stWidth) ? vtWidth : stWidth;
+
+ vmInfoTable->setMinimumWidth(tableMinWidth);
+ shortcutInfoTable->setMinimumWidth(tableMinWidth);
+ tabWidget->setMinimumWidth(tableMinWidth + TAB_BORDER_SIZE);
}
void DetailedInfoDialog::removeDataTable(QTableWidget* table, int startIndex, int lastIndex)
setShortcutInfoTable(keyboardShortcut->getPopupMenuShortcutMap());
setShortcutInfoTable(keyboardShortcut->getHwKeyShortcutMap());
setShortcutInfoTable(keyboardShortcut->getControllerShortcutMap());
+
+ vmInfoTable->horizontalHeader()->setStretchLastSection(true);
+ shortcutInfoTable->horizontalHeader()->setStretchLastSection(true);
}
QTableWidget *DetailedInfoDialog::getShortcutInfoTable()