detailed info: modified dialog maximum size to contents
authorsungmin ha <sungmin82.ha@samsung.com>
Mon, 11 May 2015 06:13:49 +0000 (15:13 +0900)
committersung min Ha <sungmin82.ha@samsung.com>
Mon, 11 May 2015 06:52:55 +0000 (15:52 +0900)
disable MIN/MAX buttons and functions

Change-Id: Ib3e9629a299de3df503918aaf037f6f67f139fc8
Signed-off-by: sungmin ha <sungmin82.ha@samsung.com>
tizen/src/ui/menu/detailedinfodialog.cpp
tizen/src/ui/menu/detailedinfodialog.h

index 9cbe2db..243ab93 100644 (file)
@@ -36,7 +36,8 @@ extern char **_qemu_argv;
 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);
@@ -59,6 +60,7 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *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);
@@ -119,11 +121,10 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) :
     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);
 
@@ -139,6 +140,50 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) :
     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)
@@ -158,24 +203,17 @@ void DetailedInfoDialog::setDataTable(QTableWidget* table, QString key, QString
     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)
index 50617fb..023cd49 100644 (file)
 #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
 {
@@ -54,12 +60,13 @@ public:
 
 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;