menu: clean up source code 62/26462/2
authorGiWoong Kim <giwoong.kim@samsung.com>
Fri, 22 Aug 2014 05:32:46 +0000 (14:32 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Mon, 25 Aug 2014 08:17:19 +0000 (17:17 +0900)
Change-Id: I1c0305f3b94ef41f6a9d1934515adaa195a7610a
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/display/qt5_supplement.cpp
tizen/src/ui/menu/contextmenu.cpp
tizen/src/ui/menu/contextmenu.h
tizen/src/ui/menu/detailedinfodialog.cpp

index d63d631203fc2972a133707b29aea29b23350876..9b895717cc5dfec7429446405b321cb7b6f14da2 100644 (file)
@@ -63,7 +63,8 @@ static UIInformation *uiInfo;
 void qt5_skin_init(void)
 {
     qDebug() << "* Qt version :" << QT_VERSION_STR;
-    qDebug() << "* working directory :" << QDir::currentPath();
+    qDebug() << "* working path :" << QDir::currentPath();
+    qDebug() << "* binary path :" << QCoreApplication::applicationDirPath();
 
     uiInfo = new UIInformation();
 
@@ -73,7 +74,7 @@ void qt5_skin_init(void)
     uiInfo->vmName = QString(get_emul_vm_name()).trimmed();
     uiInfo->resolution.setWidth(get_emul_resolution_width());
     uiInfo->resolution.setHeight(get_emul_resolution_height());
-    uiInfo->basePort = get_emul_vm_base_port() + 1;
+    uiInfo->basePort = get_emul_vm_base_port();
 
     uiInfo->skinPath = QDir(get_emul_skin_path()).canonicalPath();
     if (uiInfo->skinPath.endsWith(QDir::separator()) == false) {
index 3541254b07434652fe9083ee70ef4b356c95b079..6aedfae5a1e3433750b0a8eeb8221eaf59444961 100644 (file)
@@ -38,6 +38,8 @@ ContextMenu::ContextMenu(QWidget *parent) :
 {
     infoDialog = NULL;
     aboutDialog = NULL;
+    vmName = ((MainWindow *)parent)->uiInfo->vmName + " : "
+        + QString::number(get_device_serial_number());
 
     createItems();
 
@@ -48,8 +50,7 @@ void ContextMenu::createItems() {
     MainWindow *win = (MainWindow *)this->parent();
 
     /* Detailed Info menu */
-    QAction *action = addAction(win->uiInfo->vmName + " : "
-        + QString::number(win->uiInfo->basePort));
+    QAction *action = addAction(vmName);
     action->setIcon(QIcon(QPixmap(":/icons/detailed_info.png")));
     connect(action, SIGNAL(triggered()), this, SLOT(slotDetailedInfo()));
 
@@ -267,39 +268,39 @@ void ContextMenu::slotShell()
 
     if (is_sdbd_initialized == 0) {
         QString msg = "SDB is not ready.\nPlease wait until the emulator is completely boot up.";
-        QMessageBox *msgBox = new QMessageBox();
+        qDebug() << msg;
+
+        QMessageBox *msgBox = new QMessageBox(QMessageBox::Information,
+            "Emulator", msg, QMessageBox::Ok);
         msgBox->setAttribute(Qt::WA_DeleteOnClose);
-        msgBox->setWindowTitle("Emulator");
-        msgBox->setText(msg);
         msgBox->setModal(false);
         msgBox->show();
-        qDebug() << msg;
+
         return;
     }
 
-    MainWindow *win = (MainWindow *)this->parent();
-    qint32 basePort = win->uiInfo->basePort;
-    QString sdbPort = QString::number(basePort + 1);
-    QString sdbSerial = "emulator-" + sdbPort;
+    QString sdbPort = QString::number(get_device_serial_number());
+    QString sdbSerialName = "emulator-" + sdbPort;
 
-    QString vmName = win->uiInfo->vmName;
-    QString sdbPath;
+    QString sdbPath = QCoreApplication::applicationDirPath();
 #ifdef CONFIG_WIN32
-    sdbPath = "..\\..\\ansicon.exe";
+    sdbPath += "\\..\\..\\ansicon.exe";
 #else
-    sdbPath = "../../sdb";
+    sdbPath += "/../../sdb";
 #endif
 
-    QFileInfo fileInfo(sdbPath);
-    if (!fileInfo.exists()) {
-        QString msg = "SDB file does not exist : " + fileInfo.absoluteFilePath();
-        QMessageBox *msgBox = new QMessageBox();
+    QFileInfo sdbFileInfo(sdbPath);
+    if (sdbFileInfo.exists() == false) {
+        QString msg = "SDB file does not exist in the following path.\n"
+            + sdbFileInfo.absoluteFilePath();
+        qWarning() << msg;
+
+        QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning,
+            "Emulator", msg, QMessageBox::Ok);
         msgBox->setAttribute(Qt::WA_DeleteOnClose);
-        msgBox->setWindowTitle("Emulator");
-        msgBox->setText(msg);
         msgBox->setModal(false);
         msgBox->show();
-        qWarning() << msg;
+
         return;
     }
 
@@ -308,29 +309,31 @@ void ContextMenu::slotShell()
 
 #ifdef CONFIG_WIN32
     command = "cmd.exe";
-    arguments << "/c start" << sdbPath << "-s" << sdbSerial << "shell";
+    arguments << "/c start" << sdbPath << "-s" << sdbSerialName << "shell";
 #elif defined CONFIG_DARWIN
-    QString binPath = get_bin_path();
-    command = binPath + "/sdbscript";
-    arguments << sdbSerial;
+    command = QCoreApplication::applicationDirPath() + "/sdbscript";
+    arguments << sdbSerialName;
 #else
-    QString title = "--title=" + vmName;
     command = "/usr/bin/gnome-terminal";
-    arguments << title << "-x" << sdbPath << "-s" << sdbSerial << "shell";
+    QString title = "--title=" + vmName;
+    arguments << title << "-x" << sdbPath << "-s" << sdbSerialName << "shell";
 #endif
 
+    qDebug() << command << arguments;
+
     try {
         QProcess *terminal = new QProcess(this);
         terminal->start(command, arguments);
     } catch (QString error) {
-        QString msg = "Fail to open Shell : " + error;
-        QMessageBox *msgBox = new QMessageBox();
+        QString msg = "Failed to open Shell : " + error;
+        qDebug() << msg;
+
+        QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning,
+            "Emulator", msg, QMessageBox::Ok);
         msgBox->setAttribute(Qt::WA_DeleteOnClose);
-        msgBox->setWindowTitle("Emulator");
-        msgBox->setText(msg);
         msgBox->setModal(false);
         msgBox->show();
-        qDebug() << msg;
+
         return;
     }
 }
@@ -339,25 +342,29 @@ void ContextMenu::slotControlPanel()
 {
     qDebug("Control Panel");
 
-    QString basePortOpt = "base.port=" + QString::number(get_emul_vm_base_port());
-    QString vmNameOpt = "vmname=" + QString(get_emul_vm_name());
-    QString ecpPath;
+    MainWindow *win = (MainWindow *)this->parent();
+    QString basePortOpt = "base.port=" + QString::number(win->uiInfo->basePort);
+    QString vmNameOpt = "vmname=" + win->uiInfo->vmName;
+
+    QString ecpPath = QCoreApplication::applicationDirPath();
 #ifdef CONFIG_WIN32
-    ecpPath = ".\\emulator-control-panel.jar";
+    ecpPath += "\\emulator-control-panel.jar";
 #else
-    ecpPath = "./emulator-control-panel.jar";
+    ecpPath += "/emulator-control-panel.jar";
 #endif
 
-    QFileInfo fileInfo(ecpPath);
-    if (!fileInfo.exists()) {
-        QString msg = "Control Panel file does not exist in the following path.\n" + fileInfo.absoluteFilePath();
-        QMessageBox *msgBox = new QMessageBox();
+    QFileInfo ecpFileInfo(ecpPath);
+    if (!ecpFileInfo.exists()) {
+        QString msg = "Control Panel file does not exist in the following path.\n"
+            + ecpFileInfo.absoluteFilePath();
+        qWarning() << msg;
+
+        QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning,
+            "Emulator", msg, QMessageBox::Ok);
         msgBox->setAttribute(Qt::WA_DeleteOnClose);
-        msgBox->setWindowTitle("Error");
-        msgBox->setText(msg);
         msgBox->setModal(false);
         msgBox->show();
-        qWarning() << msg;
+
         return;
     }
 
@@ -371,18 +378,21 @@ void ContextMenu::slotControlPanel()
     QStringList arguments;
     arguments << "-jar" << ecpPath << vmNameOpt << basePortOpt;
 
+    qDebug() << command << arguments;
+
     try {
         QProcess *terminal = new QProcess(this);
         terminal->start(command, arguments);
     } catch (QString error) {
-        QString msg = "Fail to open control panel : " + error;
-        QMessageBox *msgBox = new QMessageBox();
+        QString msg = "Failed to open Control Panel : " + error;
+        qDebug() << msg;
+
+        QMessageBox *msgBox = new QMessageBox(QMessageBox::Warning,
+            "Emulator", msg, QMessageBox::Ok);
         msgBox->setAttribute(Qt::WA_DeleteOnClose);
-        msgBox->setWindowTitle("Fail");
-        msgBox->setText(msg);
         msgBox->setModal(false);
         msgBox->show();
-        qDebug() << msg;
+
         return;
     }
 }
index d801ac5b9128af9fc3ff56151ca31485fa7127d9..1a6cea45f3e5935450312e92fa68307260c73b71 100644 (file)
@@ -77,9 +77,10 @@ protected:
     bool eventFilter(QObject *obj, QEvent *event);
 
 private:
-    QTimer *longPressTimer;
+    QString vmName;
     DetailedInfoDialog *infoDialog;
     AboutDialog *aboutDialog;
+    QTimer *longPressTimer;
 
     QSignalMapper *rotateMapper;
     QSignalMapper *scaleMapper;
index 9321a97602e30768163632d4d10fa9672c3a7910..1ab41579621cfb9ad37279fc0ef4ab76c5d010f7 100644 (file)
@@ -73,7 +73,7 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) :
     item = new QTableWidgetItem(win->uiInfo->vmName);
     infoTable->setItem(index++, 1, item);
 
-    item = new QTableWidgetItem("Skin name");
+    item = new QTableWidgetItem("Skin Name");
     infoTable->setItem(index, 0, item);
     item = new QTableWidgetItem(win->uiInfo->skinName);
     infoTable->setItem(index++, 1, item);
@@ -130,7 +130,7 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) :
     /* temp */
     item = new QTableWidgetItem("Logging Telnet Port");
     infoTable->setItem(index, 0, item);
-    item = new QTableWidgetItem(QString::number(win->uiInfo->basePort + 4));
+    item = new QTableWidgetItem(QString::number(get_emul_serial_port()));
     infoTable->setItem(index++, 1, item);
 
     int tableHeight = infoTable->horizontalHeader()->height();