extern char tizen_target_img_path[]; //TODO: not legacy
DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) :
- QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
+ QDialog(parent, Qt::Tool | Qt::WindowTitleHint |
+ Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint)
{
QStringList imagePathList = getImagePathList();
MainWindow *win = ((MainWindow *)parent);
QWidget *shortcutInfo = new QWidget;
tabWidget->addTab(vmInfo, tr("VM Info"));
tabWidget->addTab(shortcutInfo, tr("Shortcut Info"));
+ connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotSetMaximumSize(int)));
/* VM information table */
vmInfoTable = new QTableWidget(vmInfo);
for (int i = 0; i < vmInfoTable->rowCount(); i++) {
tableHeight += vmInfoTable->rowHeight(i);
}
- vmInfoTable->setMinimumHeight(tableHeight + TABLE_BORDER_SIZE);
- shortcutInfoTable->setMinimumHeight(tableHeight + TABLE_BORDER_SIZE);
- QSize tabSize = tabWidget->tabBar()->sizeHint();
- tabWidget->setMinimumHeight(vmInfoTable->height() + tabSize.height() + TABLE_BORDER_SIZE);
+ setMinimumWidth(DIALOG_MIN_WIDTH);
+ setMinimumHeight(DIALOG_MIN_HEIGHT);
+ slotSetMaximumSize(tabWidget->currentIndex());
upsideLayout->addWidget(tabWidget);
downsideLayout->addWidget(okBtn);
baseLayout->addLayout(downsideLayout);
+
+ resize(DIALOG_DEF_WIDTH, DIALOG_DEF_HEIGHT);
+}
+
+void DetailedInfoDialog::slotSetMaximumSize(int tab)
+{
+ QTableWidget *table = NULL;
+ int tRow = 0;
+ int tHeight = 0;
+ int tWidth = 0;
+
+ switch (tab) {
+ case 0: /* vmInfoTab */
+ table = vmInfoTable;
+ break;
+ case 1: /* shortcutInfoTab */
+ table = shortcutInfoTable;
+ break;
+ default:
+ qWarning() << "unimplemented tab: " << tab;
+ return;
+ }
+
+ table->resizeColumnsToContents();
+
+ /* width */
+ tWidth = table->columnWidth(0) + table->columnWidth(1);
+ tWidth = (tWidth < DIALOG_DEF_WIDTH) ? DIALOG_DEF_WIDTH : tWidth;
+
+ setMaximumWidth(tWidth + TABLE_BORDER_SIZE +
+ TAB_BORDER_SIZE +
+ DIALOG_HORIZ_SPACE);
+
+ /* height */
+ tHeight = table->horizontalHeader()->height();
+ for (tRow = 0; tRow < table->rowCount(); tRow++) {
+ tHeight += table->rowHeight(tRow);
+ }
+
+ setMaximumHeight(tHeight + TABLE_BORDER_SIZE +
+ tabWidget->tabBar()->sizeHint().height() +
+ DIALOG_VERTIC_SPACE);
+
+ table->horizontalHeader()->setStretchLastSection(true);
}
void DetailedInfoDialog::setShortcutInfoTable(QMap<QString, QString> map)
table->setItem(index, 0, item);
item = new QTableWidgetItem(value);
table->setItem(index, 1, item);
-
- resizeTableWidth();
}
-void DetailedInfoDialog::resizeTableWidth()
+void DetailedInfoDialog::resizeEvent(QResizeEvent* event)
{
- 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);
+ int tWidth = 0, tHeight = 0;
+ tWidth = event->size().width() - TAB_BORDER_SIZE - DIALOG_HORIZ_SPACE;
+ tHeight = event->size().height() - tabWidget->tabBar()->sizeHint().height() -
+ DIALOG_VERTIC_SPACE;
+
+ vmInfoTable->resize(tWidth, tHeight);
+ shortcutInfoTable->resize(tWidth, tHeight);
}
void DetailedInfoDialog::removeDataTable(QTableWidget* table, int startIndex, int lastIndex)
#define DETAILED_INFO_TITLE "Detailed Info"
#define TABLE_BORDER_SIZE 2
#define TAB_BORDER_SIZE 4
+#define DIALOG_HORIZ_SPACE 20
+#define DIALOG_VERTIC_SPACE 60
+#define DIALOG_MIN_WIDTH 200
+#define DIALOG_MIN_HEIGHT 200
+#define DIALOG_DEF_WIDTH 320
+#define DIALOG_DEF_HEIGHT 473
class DetailedInfoDialog : public QDialog
{
protected:
void showEvent(QShowEvent *event);
+ void resizeEvent(QResizeEvent *event);
public slots:
void slotDoubleClicked(int nRow, int nCol);
+ void slotSetMaximumSize(int tab);
private:
- void resizeTableWidth();
QStringList getImagePathList();
QVBoxLayout *baseLayout;
QHBoxLayout *upsideLayout;