ui: some minor modifications
authorGiWoong Kim <giwoong.kim@samsung.com>
Tue, 11 Aug 2015 11:06:30 +0000 (20:06 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Thu, 13 Aug 2015 07:49:05 +0000 (16:49 +0900)
remove button type mismatching between dialog and slot
clean up some text and path resources
add some log and etc

Change-Id: Ie195bd859994c60b90d6fd5257e719ac1f5641ad
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
tizen/src/emul_state.c
tizen/src/ui/menu/aboutdialog.cpp
tizen/src/ui/menu/contextmenu.cpp
tizen/src/ui/menu/detailedinfodialog.cpp
tizen/src/ui/qt5.c
tizen/src/ui/qt5_supplement.cpp
tizen/src/ui/resource/ui_strings.h
vl.c

index d37cc05..78db9d5 100644 (file)
@@ -672,11 +672,13 @@ static void set_resolution_legacy(void)
                 g_ascii_strtoull(splitted[1], NULL, 0));
     }
     g_strfreev(splitted);
-        }
+}
 #endif
 
 void set_initial_display_resolution(int width, int height)
 {
+    LOG_INFO("initial display resolution: %dx%d\n", width, height);
+
     initial_resolution_width = width;
     initial_resolution_height = height;
 }
index df5f083..c6d4127 100644 (file)
 #include "resource/ui_strings.h"
 #include "build_info.h"
 
-#define SDK_NAME "Tizen SDK"
-#define SDK_VERSION_FILE_KEY "TIZEN_SDK_VERSION"
-#define URL_TIZEN_ORG "<a href=\"https://developer.tizen.org\">https://developer.tizen.org</a>";
-
 AboutDialog::AboutDialog(QWidget *parent) :
     QDialog(parent, Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowStaysOnTopHint)
 {
@@ -50,15 +46,22 @@ AboutDialog::AboutDialog(QWidget *parent) :
     upsideLayout->setSpacing(0);
 
     QLabel *imageLabel = new QLabel(this);
-    imageLabel->setPixmap(QPixmap(
-        QString(SDK_EMULATOR_IMAGES_PATH) + QString(SDK_ABOUT_IMAGE_FILE)));
+    QString sdkImagePath = QDir(QCoreApplication::applicationDirPath() +
+        QDir::separator() + SDK_EMULATOR_IMAGES_PATH + SDK_ABOUT_IMAGE_FILE).absolutePath();
+    QPixmap sdkImage(sdkImagePath);
+    if (sdkImage.isNull() == false) {
+        imageLabel->setPixmap(sdkImage);
+    } else {
+        qWarning() << "failed to load image from" << sdkImagePath;
+    }
     upsideLayout->addWidget(imageLabel);
 
-    QSettings sdkVersion(
-        QString(SDK_ROOT_PATH) + QString(SDK_VERSION_FILE), QSettings::IniFormat);
-    QString version = sdkVersion.value(SDK_VERSION_FILE_KEY).toString();
+    QString versionFilePath = QDir(QCoreApplication::applicationDirPath() +
+        QDir::separator() + SDK_ROOT_PATH + SDK_VERSION_FILE).absolutePath();
+    QSettings versionFile(versionFilePath, QSettings::IniFormat);
+    QString version = versionFile.value(SDK_VERSION_FILE_KEY).toString();
     if (version.isEmpty() == true) {
-        qWarning("failed to load SDK version");
+        qWarning() << "failed to load SDK version file from" << versionFilePath;
         version = "Undefined";
     }
 
@@ -82,11 +85,12 @@ AboutDialog::AboutDialog(QWidget *parent) :
     }
     */
 
-    QString aboutText = QString(SDK_NAME) + "<p>"
-        + ABOUT_VERSION_TEXT + " : " + version + "<br>"
-        /* + "Snapshot : " + SnapshotName + "<br>" */
-        + ABOUT_BUILD_DATE_TEXT + " : " + QString(build_date) + "<p><br>"
-        + ABOUT_VISIT_TEXT + " " + URL_TIZEN_ORG;
+    QString aboutText = QString(SDK_OFFICIAL_NAME) + "<p>" +
+        ABOUT_VERSION_TEXT + " : " + version + "<br>" +
+        /* "Snapshot : " + SnapshotName + "<br>" + */
+        ABOUT_BUILD_DATE_TEXT + " : " + QString(build_date) + "<p><br>" +
+        ABOUT_VISIT_TEXT + " <a href=\"" + SDK_OFFICIAL_URL + "\">" +
+        SDK_OFFICIAL_URL + "</a>";
 
     QLabel *textLabel = new QLabel(this);
     textLabel->setStyleSheet("background-color: white");
index c617a84..b679718 100644 (file)
@@ -602,16 +602,8 @@ void ContextMenu::slotControlPanel()
 {
     qDebug("Control Panel");
 
-    QString basePortOpt = "base.port=" + QString::number(parent->uiInfo->basePort);
-    QString vmNameOpt = "vmname=" + parent->uiInfo->vmName;
-    QString vmProfileOpt = "profile=" + QString::fromLocal8Bit(get_profile_name());
-
-    QString ecpPath = QCoreApplication::applicationDirPath();
-#ifdef CONFIG_WIN32
-    ecpPath += "\\..\\..\\..\\common\\emulator\\bin\\emulator-control-panel.jar";
-#else
-    ecpPath += "/../../../common/emulator/bin/emulator-control-panel.jar";
-#endif
+    QString ecpPath = QDir(QCoreApplication::applicationDirPath() +
+        QDir::separator() + SDK_EMULATOR_BIN_PATH + SDK_ECP_FILE).absolutePath();
 
     QFileInfo ecpFileInfo(ecpPath);
     if (!ecpFileInfo.exists()) {
@@ -620,10 +612,14 @@ void ContextMenu::slotControlPanel()
         return;
     }
 
+    QString basePortOpt = "base.port=" + QString::number(parent->uiInfo->basePort);
+    QString vmNameOpt = "vmname=" + parent->uiInfo->vmName;
+    QString vmProfileOpt = "profile=" + QString::fromLocal8Bit(get_profile_name());
+
     QString command;
     QStringList arguments;
 #ifdef CONFIG_WIN32
-    char* path = (char*)malloc(JAVA_MAX_COMMAND_LENGTH);
+    char *path = (char *)malloc(JAVA_MAX_COMMAND_LENGTH);
     memset(path, 0, sizeof(char) * JAVA_MAX_COMMAND_LENGTH);
 
     if (is_wow64()) {
@@ -745,17 +741,18 @@ void ContextMenu::slotForceCloseSelected(QAbstractButton *button)
     }
 
     switch(msgBox->standardButton(button)) {
-        case QMessageBox::Ok:
+        case QMessageBox::Yes:
             qDebug() << "exit!";
             qemu_system_graceful_shutdown_request(3);
 
             break;
-        case QMessageBox::Cancel:
+        case QMessageBox::No:
             qDebug() << "cancel";
 
             break;
         default:
             /* do nothing */
+            qWarning() << "invalid return value";
             break;
     }
 }
index 3f6df1a..455d22a 100644 (file)
@@ -108,13 +108,13 @@ DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) :
 
     QString sharingPath(get_emul_file_sharing_path());
     setDataTable(vmInfoTable, DETAILED_INFO_HDS_PATH,
-        (sharingPath.isEmpty()) ? "None" : sharingPath, index++);
+        (sharingPath.isEmpty()) ? GENERIC_TEXT_NONE : sharingPath, index++);
 
     setDataTable(vmInfoTable, DETAILED_INFO_CPU_VT,
-        (get_emul_cpu_accel()) ? "Enabled" : "Disabled", index++);
+        (get_emul_cpu_accel()) ? GENERIC_TEXT_ENABLED : GENERIC_TEXT_DISABLED, index++);
 
     setDataTable(vmInfoTable, DETAILED_INFO_GPU_VT,
-        (is_gpu_accel_enabled()) ? "Enabled" : "Disabled", index++);
+        (is_gpu_accel_enabled()) ? GENERIC_TEXT_ENABLED : GENERIC_TEXT_DISABLED, index++);
 
     for (int i = 0; i < imagePathList.size(); i++) {
         setDataTable(vmInfoTable, QString(DETAILED_INFO_IMAGE_PATH) + " " +
index 91ee0a6..928c85e 100644 (file)
 #include "emul_state.h"
 #include "qt5_supplement.h"
 #include "hw/pci/maru_brightness.h"
+#include "resource/ui_strings.h"
+
 #ifdef CONFIG_DARWIN
 #include "ns_event.h"
 #endif
 
-
 #include "util/new_debug_ch.h"
 
 DECLARE_DEBUG_CHANNEL(qt5_console);
@@ -133,21 +134,20 @@ void maru_early_qt5_display_init(bool isOnscreen)
     ns_run_in_event_loop_with_bool(&qt5_early_prepare, isOnscreen);
 
     /* set emulator icon */
-#define ICON_RESOURCE_PATH "../icons/"
-#define ICON_FILE_NAME "emulator_icon.ico"
     const int path_len = strlen(get_bin_path()) +
-        strlen(ICON_RESOURCE_PATH) + strlen(ICON_FILE_NAME) + 1;
+        strlen(SDK_EMULATOR_ICONS_PATH) + strlen(EMULATOR_ICON_FILE) + 1;
 
     char *icon_path = g_malloc0(sizeof(char) * path_len);
     snprintf(icon_path, path_len, "%s%s%s",
-        get_bin_path(), ICON_RESOURCE_PATH, ICON_FILE_NAME);
-    fprintf(stdout, "application icon path : %s\n", icon_path);
+        get_bin_path(), SDK_EMULATOR_ICONS_PATH, EMULATOR_ICON_FILE);
+    fprintf(stdout, "application icon path: %s\n", icon_path);
 
     set_application_icon(icon_path);
     g_free(icon_path);
 #else
     qt5_early_prepare(isOnscreen);
 #endif
+
     if (isOnscreen) {
         LOG_INFO("Display Type: QT5 Onscreen\n");
     } else {
index 3cd2450..84f3887 100644 (file)
@@ -65,11 +65,6 @@ static void (*captureRequestHandler)(void *);
 static MainWindow *mainwindow;
 static UIInformation *uiInfo;
 
-#define GUI_PROPERTIES_FILE_NAME "gui.property"
-#define SKIN_INFO_FILE_NAME "info.ini"
-#define FORM_FILE_NAME "layout.xml"
-#define CON_FORM_SUBPATH "controller"
-
 class ConFile {
 public:
     QFile *formFile;
@@ -100,11 +95,12 @@ bool EventFilter::nativeEventFilter(const QByteArray &eventType, void *message,
 
 void qt5_gui_init(void)
 {
-    QCoreApplication::setApplicationName("Tizen Emulator");
+    QCoreApplication::setApplicationName(EMULATOR_TITLE);
 
-    qDebug() << "* Qt version :" << QT_VERSION_STR;
-    qDebug() << "* working path :" << QDir::currentPath();
-    qDebug() << "* binary path :" << QCoreApplication::applicationDirPath();
+    qDebug() << "* Qt version (compile time):" << QT_VERSION_STR;
+    qDebug() << "* Qt version (runtime):" << qVersion();
+    qDebug() << "* working path:" << QDir::currentPath();
+    qDebug() << "* binary path:" << QCoreApplication::applicationDirPath();
 
     uiInfo = new UIInformation();
 
@@ -112,7 +108,7 @@ void qt5_gui_init(void)
     // TODO:
 
     uiInfo->vmName = QString(get_vm_name()).trimmed();
-    qDebug() << "VM name :" <<  uiInfo->vmName;
+    qDebug() << "VM name:" <<  uiInfo->vmName;
 
     uiInfo->resolution.setWidth(get_display_resolution_width());
     uiInfo->resolution.setHeight(get_display_resolution_height());
@@ -122,16 +118,16 @@ void qt5_gui_init(void)
     if (uiInfo->vmDataPath.endsWith(QDir::separator()) == false) {
         uiInfo->vmDataPath += QDir::separator();
     }
-    qDebug() << "VM path :" <<  uiInfo->vmDataPath;
+    qDebug() << "VM path:" <<  uiInfo->vmDataPath;
 
     uiInfo->skinPath = QDir(get_emul_skin_path()).canonicalPath();
     if (uiInfo->skinPath.endsWith(QDir::separator()) == false) {
         uiInfo->skinPath += QDir::separator();
     }
-    qDebug() << "skin path :" <<  uiInfo->skinPath;
+    qDebug() << "skin path:" <<  uiInfo->skinPath;
 
     /* read skin information */
-    QSettings skinInfo(uiInfo->skinPath + SKIN_INFO_FILE_NAME,
+    QSettings skinInfo(uiInfo->skinPath + LAYOUT_SKIN_INFO_FILE,
         QSettings::IniFormat);
     QString skinName = skinInfo.value(SKIN_PROPERTY_NAME).toString();
     if (skinName.isEmpty() == true) {
@@ -140,16 +136,16 @@ void qt5_gui_init(void)
     uiInfo->skinName = skinName;
 
     /* open most recently used data information file */
-    QFile::remove(uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME + ".lock");
+    QFile::remove(uiInfo->vmDataPath + GUI_PROPERTIES_FILE + ".lock");
     const QSettings mruInfo(
-        uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME, QSettings::IniFormat);
+        uiInfo->vmDataPath + GUI_PROPERTIES_FILE, QSettings::IniFormat);
 
     /* XML layout */
-    QFile mainXMLFile(uiInfo->skinPath + FORM_FILE_NAME);
+    QFile mainXMLFile(uiInfo->skinPath + LAYOUT_FORM_FILE_NAME);
     /* load main form */
     loadMainFormFromXML(&mainXMLFile, uiInfo);
 
-    QDir skinDir(uiInfo->skinPath + CON_FORM_SUBPATH);
+    QDir skinDir(uiInfo->skinPath + LAYOUT_CON_FORM_SUBPATH);
     /* load controller forms */
     QFileInfoList entries = skinDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
 
@@ -161,8 +157,8 @@ void qt5_gui_init(void)
             ConFile *conFile = new ConFile();
 
             QString conPath = entries.at(i).filePath() + QDir::separator();
-            conFile->formFile = new QFile(conPath + FORM_FILE_NAME);
-            QSettings conInfo(conPath + SKIN_INFO_FILE_NAME, QSettings::IniFormat);
+            conFile->formFile = new QFile(conPath + LAYOUT_FORM_FILE_NAME);
+            QSettings conInfo(conPath + LAYOUT_SKIN_INFO_FILE, QSettings::IniFormat);
             conFile->priority = conInfo.value("priority").toInt();
 
             int j = 0;
@@ -270,7 +266,7 @@ void qt5_destroy()
     qDebug("qt5 destroy");
 
     /* write most recently used data information */
-    QString path(uiInfo->vmDataPath + GUI_PROPERTIES_FILE_NAME);
+    QString path(uiInfo->vmDataPath + GUI_PROPERTIES_FILE);
     qDebug() <<  "save MRU data:" << path;
 
     QSettings mruInfo(path, QSettings::IniFormat);
index 4d3821a..496730d 100644 (file)
 #ifndef UI_STRINGS_H
 #define UI_STRINGS_H
 
-#define EMULATOR_TITLE "Emulator"
+#define EMULATOR_TITLE "Tizen Emulator"
+
+#define SDK_OFFICIAL_NAME "Tizen SDK"
+#define SDK_OFFICIAL_URL "https://developer.tizen.org"
 
 /* SDK path */
 #define SDK_ROOT_PATH "../../../../../"
+#define SDK_EMULATOR_BIN_PATH "../../../common/emulator/bin/"
 #define SDK_EMULATOR_IMAGES_PATH "../images/"
+#define SDK_EMULATOR_ICONS_PATH "../icons/"
+
+#define SDK_ECP_FILE "emulator-control-panel.jar"
 
 /* resource file name */
 #define SDK_ABOUT_IMAGE_FILE "tizen_sdk.png"
 #define SDK_VERSION_FILE "sdk.version"
+#define SDK_VERSION_FILE_KEY "TIZEN_SDK_VERSION"
+#define EMULATOR_ICON_FILE "emulator_icon.ico"
+#define GUI_PROPERTIES_FILE "gui.property"
+#define LAYOUT_SKIN_INFO_FILE "info.ini"
+#define LAYOUT_FORM_FILE_NAME "layout.xml"
+#define LAYOUT_CON_FORM_SUBPATH "controller/"
 #define DISPLAY_OFF_GUIDE_IMAGE_FILE "display_off_guide.png"
 
+/* generic text */
+#define GENERIC_TEXT_NONE "None"
+#define GENERIC_TEXT_ENABLED "Enabled"
+#define GENERIC_TEXT_DISABLED "Disabled"
+
 /* context menu */
 #define MENU_ONTOP_ITEM_TEXT "Always on Top"
 #define MENU_SWITCH_ITEM_TEXT "Switch"
diff --git a/vl.c b/vl.c
index 50726f9..d1425ea 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2202,7 +2202,7 @@ static DisplayType select_display(const char *p)
                 // Resolution should be formed "640x480" or "640*480".
                 int width = (int)g_ascii_strtoll(opts, &endptr, 10);
                 int height = (int)g_ascii_strtoll(++endptr, &endptr, 10);
-                if (width == 0 || height == 0) {
+                if (width <= 0 || height <= 0) {
                     goto invalid_maru_qt_args;
                 }
                 set_initial_display_resolution(width, height);
@@ -2211,7 +2211,7 @@ static DisplayType select_display(const char *p)
                 opts = nextopt;
                 char *endptr = NULL;
                 int dpi = (int)g_ascii_strtoll(opts, &endptr, 10);
-                if (dpi == 0) {
+                if (dpi <= 0) {
                     goto invalid_maru_qt_args;
                 }
                 set_display_pixel_density(dpi);