From: GiWoong Kim Date: Fri, 22 Aug 2014 05:32:46 +0000 (+0900) Subject: menu: clean up source code X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F26462%2F2;p=sdk%2Femulator%2Fqemu.git menu: clean up source code Change-Id: I1c0305f3b94ef41f6a9d1934515adaa195a7610a Signed-off-by: GiWoong Kim --- diff --git a/tizen/src/display/qt5_supplement.cpp b/tizen/src/display/qt5_supplement.cpp index d63d631203..9b895717cc 100644 --- a/tizen/src/display/qt5_supplement.cpp +++ b/tizen/src/display/qt5_supplement.cpp @@ -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) { diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index 3541254b07..6aedfae5a1 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -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; } } diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index d801ac5b91..1a6cea45f3 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -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; diff --git a/tizen/src/ui/menu/detailedinfodialog.cpp b/tizen/src/ui/menu/detailedinfodialog.cpp index 9321a97602..1ab4157962 100644 --- a/tizen/src/ui/menu/detailedinfodialog.cpp +++ b/tizen/src/ui/menu/detailedinfodialog.cpp @@ -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();