diff options
47 files changed, 1268 insertions, 1047 deletions
@@ -311,7 +311,6 @@ smartcard_nss="" libusb="" libtizenusb="no" usb_redir="" -opengl="" efence="no" yagl="no" yagl_stats="no" @@ -330,19 +329,6 @@ libnfs="" coroutine="" coroutine_pool="" seccomp="" - -# for TIZEN-maru -java_ui="no" -maru="no" -shm="no" -libav="" -libpng="no" -dxva2="" -vaapi="" -qt="no" -qtabi="5.0" -extension_path="" -# glusterfs="" glusterfs_discard="no" glusterfs_zerofill="no" @@ -355,6 +341,19 @@ libssh2="" vhdx="" quorum="" numa="" +# for TIZEN-maru +winver="0x501" +java_ui="no" +maru="no" +shm="no" +libav="" +libpng="no" +dxva2="" +vaapi="" +qt="no" +qtabi="5.0" +extension_path="" +# # parse CC options first for opt do @@ -723,7 +722,7 @@ fi if test "$mingw32" = "yes" ; then EXESUF=".exe" DSOSUF=".dll" - QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN -DWINVER=0x501 $QEMU_CFLAGS" + QEMU_CFLAGS="-DWIN32_LEAN_AND_MEAN $QEMU_CFLAGS" # enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) QEMU_CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $QEMU_CFLAGS" LIBS="-lwinmm -lws2_32 -liphlpapi $LIBS" @@ -1064,14 +1063,10 @@ for opt do ;; --disable-yagl-stats) yagl_stats="no" ;; - --enable-opengl) opengl="yes" - ;; --enable-vigs) vigs="yes" ;; --disable-vigs) vigs="no" ;; - --disable-opengl) opengl="no" - ;; --disable-vhost-scsi) vhost_scsi="no" ;; --enable-vhost-scsi) vhost_scsi="yes" @@ -1138,34 +1133,6 @@ for opt do ;; --disable-seccomp) seccomp="no" ;; -# for TIZEN-maru - --enable-maru) maru="yes" - ;; - --enable-java-ui) java_ui="yes" - ;; - --enable-shm) shm="yes" - ;; - --enable-libav) libav="yes" - ;; - --disable-libav) libav="no" - ;; - --enable-libpng) libpng="yes" - ;; - --enable-dxva2) dxva2="yes" - ;; - --disable-dxva2) dxva2="no" - ;; - --enable-vaapi) vaapi="yes" - ;; - --disable-vaapi) vaapi="no" - ;; - --disable-qt) qt="no" - ;; - --enable-qt) qt="yes" - ;; - --extension-path=*) extension_path="$optarg" - ;; -# --disable-glusterfs) glusterfs="no" ;; --enable-glusterfs) glusterfs="yes" @@ -1211,6 +1178,36 @@ for opt do ;; --enable-numa) numa="yes" ;; +# for TIZEN-maru + --enable-maru) maru="yes" + ;; + --winver=*) winver="$optarg" + ;; + --enable-java-ui) java_ui="yes" + ;; + --enable-shm) shm="yes" + ;; + --enable-libav) libav="yes" + ;; + --disable-libav) libav="no" + ;; + --enable-libpng) libpng="yes" + ;; + --enable-dxva2) dxva2="yes" + ;; + --disable-dxva2) dxva2="no" + ;; + --enable-vaapi) vaapi="yes" + ;; + --disable-vaapi) vaapi="no" + ;; + --disable-qt) qt="no" + ;; + --enable-qt) qt="yes" + ;; + --extension-path=*) extension_path="$optarg" + ;; +# *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1495,6 +1492,7 @@ Advanced options (experts only): --disable-vigs disable VIGS device TIZEN-maru options: + --winver=WINVER set WINVER --enable-maru enable maru board --enable-java-ui enable java UI --enable-shm enable shared memory for framebuffer @@ -4310,6 +4308,13 @@ else fi ######################################## +# set WINVER + +if test "$mingw32" = "yes" ; then + QEMU_CFLAGS="-DWINVER=$winver $QEMU_CFLAGS" +fi + +######################################## # check extension path if [ ! -d "$source_path/tizen/src/$extension_path" ] ; then @@ -4691,19 +4696,22 @@ echo "NUMA host support $numa" echo "HAX support $hax" echo "YaGL support $yagl" echo "YaGL stats $yagl_stats" -echo "OpenGL support $opengl" echo "VIGS support $vigs" # for TIZEN-maru -echo "TIZEN-maru support $maru" -echo "TIZEN-maru Java UI support $java_ui" -echo "TIZEN-maru shared framebuffer support $shm" -echo "TIZEN-maru libav support $libav" -echo "TIZEN-maru libpng support $libpng" -echo "TIZEN-maru DXVA2 support $dxva2" -echo "TIZEN-maru vaapi support $vaapi" -echo "TIZEN-maru libtizenusb support $libtizenusb" -echo "TIZEN-maru extension path $extension_path" +echo "TIZEN-maru options:" +echo "maru enabled $maru" +if test "$mingw32" = "yes"; then +echo "WINVER $winver" +fi +echo "Java UI enabled $java_ui" +echo "shared framebuffer enabled $shm" +echo "libav support $libav" +echo "libpng support $libpng" +echo "DXVA2 support $dxva2" +echo "vaapi support $vaapi" +echo "libtizenusb support $libtizenusb" +echo "extension path $extension_path" # if test "$sdl_too_old" = "yes"; then @@ -5205,48 +5213,6 @@ else echo "HOST_USB=stub" >> $config_host_mak fi -# for TIZEN-maru -if test "$maru" = "yes" ; then - echo "CONFIG_MARU=y" >> $config_host_mak -fi -# java ui is deprecated -if test "$java_ui" = "yes" ; then - if test "$shm" = "yes" || test "$sdl" = "yes" ; then - echo "CONFIG_JAVA_UI=y" >> $config_host_mak - else - error_exit "Java UI is only available with SDL or SHM" - fi -fi -if test "$shm" = "yes" ; then - if test "$java_ui" = "yes" ; then - echo "CONFIG_USE_SHM=y" >> $config_host_mak - else - error_exit "SHM is only available whith Java UI" - fi -fi -if test "$libav" = "yes" ; then - echo "CONFIG_LIBAV=y" >> $config_host_mak - echo "LIBAV_CFLAGS=$libav_cflags" >> $config_host_mak - echo "LIBAV_LIBS=$libav_libs" >> $config_host_mak -fi -if test "$libpng" = "yes" ; then - echo "CONFIG_PNG=y" >> $config_host_mak - echo "LIBPNG_CFLAGS=$libpng_cflags" >> $config_host_mak -fi -if test "$dxva2" = "yes" ; then - echo "CONFIG_DXVA2=y" >> $config_host_mak -fi -if test "$vaapi" = "yes" ; then - echo "CONFIG_VAAPI=y" >> $config_host_mak - echo "LIBVA_CFLAGS=$libva_cflags $libva_x11_cflags" >> $config_host_mak -fi -if test "$libtizenusb" = "yes" ; then - echo "CONFIG_TIZENUSB=y" >> $config_host_mak -fi -if [ ! -z "$extension_path" ] ; then - echo "CONFIG_EXTENSION_PATH=$extension_path" >> $config_host_mak -fi - # TPM passthrough support? if test "$tpm" = "yes"; then echo 'CONFIG_TPM=$(CONFIG_SOFTMMU)' >> $config_host_mak @@ -5848,6 +5814,49 @@ if test "$numa" = "yes"; then echo "CONFIG_NUMA=y" >> $config_host_mak fi +# for TIZEN-maru +if test "$maru" = "yes" ; then + echo "CONFIG_MARU=y" >> $config_host_mak +fi +# java ui is deprecated +if test "$java_ui" = "yes" ; then + if test "$shm" = "yes" || test "$sdl" = "yes" ; then + echo "CONFIG_JAVA_UI=y" >> $config_host_mak + else + error_exit "Java UI is only available with SDL or SHM" + fi +fi +if test "$shm" = "yes" ; then + if test "$java_ui" = "yes" ; then + echo "CONFIG_USE_SHM=y" >> $config_host_mak + else + error_exit "SHM is only available whith Java UI" + fi +fi +if test "$libav" = "yes" ; then + echo "CONFIG_LIBAV=y" >> $config_host_mak + echo "LIBAV_CFLAGS=$libav_cflags" >> $config_host_mak + echo "LIBAV_LIBS=$libav_libs" >> $config_host_mak +fi +if test "$libpng" = "yes" ; then + echo "CONFIG_PNG=y" >> $config_host_mak + echo "LIBPNG_CFLAGS=$libpng_cflags" >> $config_host_mak +fi +if test "$dxva2" = "yes" ; then + echo "CONFIG_DXVA2=y" >> $config_host_mak +fi +if test "$vaapi" = "yes" ; then + echo "CONFIG_VAAPI=y" >> $config_host_mak + echo "LIBVA_CFLAGS=$libva_cflags $libva_x11_cflags" >> $config_host_mak +fi +if test "$libtizenusb" = "yes" ; then + echo "CONFIG_TIZENUSB=y" >> $config_host_mak +fi +if [ ! -z "$extension_path" ] ; then + echo "CONFIG_EXTENSION_PATH=$extension_path" >> $config_host_mak +fi + + # build tree in object directory in case the source is not in the current directory DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests" DIRS="$DIRS fsdev" diff --git a/package/changelog b/package/changelog index 9327ef9cb2..0044cdee4b 100644 --- a/package/changelog +++ b/package/changelog @@ -1,3 +1,6 @@ +* 2.2.43 +- enable DPI information on Detailed Info dialog +== GiWoong Kim <giwoong.kim@samsung.com> 2015-08-13 * 2.2.42 - fixed dest dir of emulator binary on DIBS == Sooyoung Ha <yoosah.ha@samsung.com> 2015-08-05 diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index 877b2dffe6..4fec36cb85 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version: 2.2.42 +Version: 2.2.43 Maintainer: Sangho Park <sangho.p@samsung.com> Source: emulator diff --git a/tizen/emulator_configure.sh b/tizen/emulator_configure.sh index 511cb0b484..d6cd88df7b 100755 --- a/tizen/emulator_configure.sh +++ b/tizen/emulator_configure.sh @@ -79,7 +79,7 @@ if [ -z "$EMUL_TARGET_LIST" ] ; then fi # append common flags -CONFIGURE_APPEND="--target-list=$EMUL_TARGET_LIST --enable-yagl --enable-curl --enable-vigs --enable-maru --enable-qt --enable-libav --enable-libpng --disable-sdl --disable-gtk --disable-vnc --disable-curses --disable-quorum --disable-xen $CONFIGURE_APPEND" +CONFIGURE_APPEND="--target-list=$EMUL_TARGET_LIST --enable-yagl --enable-curl --enable-vigs --enable-maru --enable-qt --enable-libav --enable-libpng --disable-sdl --disable-gtk --disable-vnc --disable-spice --disable-curses --disable-quorum --disable-xen $CONFIGURE_APPEND" if [ -z ${PKG_CONFIG_PATH} ] ; then # avoid pkg-config bug on Windows export PKG_CONFIG_PATH=${TIZEN_SDK_DEV_PATH}/distrib/lib/pkgconfig diff --git a/tizen/src/Makefile b/tizen/src/Makefile index bb9f1f3017..fa87de9965 100755 --- a/tizen/src/Makefile +++ b/tizen/src/Makefile @@ -26,83 +26,6 @@ qemu_clean: qemu_distclean: cd ../../ && $(MAKE) distclean -# Building check-net -CHECK_NET_OBJS = util/check_net.o -CHECK_NET_CFLAGS = -c $(GLIB_CFLAGS) $(CURL_CFLAGS) -CHECK_NET_LDFLAGS = -CHECK_NET_TARGET = util/check-net$(EXESUF) -ifdef CONFIG_LINUX -CHECK_NET_OBJS += util/check_net_linux.o -CHECK_NET_LDFLAGS += ${CURL_LIBS} `pkg-config --libs glib-2.0` -endif -ifdef CONFIG_WIN32 -CHECK_NET_OBJS += util/check_net_win32.o -CHECK_NET_LDFLAGS += -liphlpapi -lws2_32 ${CURL_LIBS} `pkg-config --libs glib-2.0` -endif -ifdef CONFIG_DARWIN -CHECK_NET_OBJS += util/check_net_darwin.o -CHECK_NET_LDFLAGS += -mmacosx-version-min=10.4 ${CURL_LIBS} -framework CoreFoundation -framework SystemConfiguration `pkg-config --libs glib-2.0` -endif - -util/check-net$(EXESUF): $(CHECK_NET_OBJS) - $(CC) $(CHECK_NET_OBJS) $(CHECK_NET_LDFLAGS) -o $@ -$(CHECK_NET_OBJS): %.o: %.c - $(CC) $< $(CHECK_NET_CFLAGS) -o $@ - -# Building check-gl -CHECK_GL_OBJS = util/check_gl.o util/check_gl_core.o -CHECK_GL_CFLAGS = -c -I$(SRC_PATH)/hw/yagl/yagl_inc -CHECK_GL_LDFLAGS = -CHECK_GL_TARGET = util/check-gl$(EXESUF) -ifdef CONFIG_LINUX -CHECK_GL_OBJS += util/check_gl_glx.o -CHECK_GL_LDFLAGS += -lX11 -lXext -lglib-2.0 -ldl -endif -ifdef CONFIG_WIN32 -CHECK_GL_OBJS += util/check_gl_wgl.o -CHECK_GL_LDFLAGS += -fstack-protector `pkg-config --libs glib-2.0` -lgdi32 -endif -ifdef CONFIG_DARWIN -CHECK_GL_OBJS += util/check_gl_cgl.o -CHECK_GL_LDFLAGS += -mmacosx-version-min=10.4 `pkg-config --cflags --libs glib-2.0` -framework OpenGL -endif - -util/check-gl$(EXESUF): $(CHECK_GL_OBJS) - $(CC) $(CHECK_GL_OBJS) $(CHECK_GL_LDFLAGS) -o $@ -$(CHECK_GL_OBJS): %.o: %.c - $(CC) $< $(CHECK_GL_CFLAGS) -o $@ - -# Building check-cam -CHECK_CAM_CFLAGS = -c -ifdef CONFIG_LINUX -CHECK_CAM_LDFLAGS = -lv4l2 -lv4lconvert -endif -ifdef CONFIG_WIN32 -CHECK_CAM_CFLAGS += -I. -CHECK_CAM_LDFLAGS = -lole32 -loleaut32 -luuid -lstrmiids -endif -ifdef CONFIG_DARWIN -endif - -util/check-cam$(EXESUF): util/check_cam.o - $(CC) $< -o $@ $(CHECK_CAM_LDFLAGS) -util/check_cam.o: %.o: %.c - $(CC) $< -o $@ $(CHECK_CAM_CFLAGS) - -# Building check-hax -CHECK_HAX_CFLAGS = -c -ifdef CONFIG_LINUX -endif -ifdef CONFIG_WIN32 -endif -ifdef CONFIG_DARWIN -CHECK_HAX_CFLAGS += -mmacosx-version-min=10.4 -endif -util/check-hax$(EXESUF): util/check_hax.o - $(CC) $< -o $@ -util/check_hax.o: %.o: %.c - $(CC) $< $(CHECK_HAX_CFLAGS) -o $@ - # Building java skin skin_client: ifdef CONFIG_JAVA_UI @@ -125,7 +48,7 @@ build_info: clean: qemu_clean - rm -f util/check-hax$(EXESUF) util/check-cam$(EXESUF) util/check-gl$(EXESUF) util/check-net$(EXESUF) + rm -rf ../emulator/ distclean: clean qemu_distclean install: all diff --git a/tizen/src/ecs/ecs_msg_injector.c b/tizen/src/ecs/ecs_msg_injector.c index 6892443fd1..587a3ed0e0 100644 --- a/tizen/src/ecs/ecs_msg_injector.c +++ b/tizen/src/ecs/ecs_msg_injector.c @@ -329,7 +329,6 @@ static void* hds_mount_request_thread(void* args) } #define MSG_GROUP_HDS 100 -#define DEFAULT_STATIC_HDS_ID "fsdef0" static void do_hds(char* cat, type_action action, const char* data) { FsDriverEntry *entry; diff --git a/tizen/src/emul_state.c b/tizen/src/emul_state.c index 7dfc2a8da6..c65903a7f9 100644 --- a/tizen/src/emul_state.c +++ b/tizen/src/emul_state.c @@ -41,6 +41,7 @@ extern bool kvm_allowed; #include <windows.h> extern bool hax_allowed; #elif defined(CONFIG_DARWIN) +#include <fcntl.h> extern bool hax_allowed; #endif @@ -50,7 +51,9 @@ extern bool hax_allowed; #include "sysemu/block-backend.h" #include "net/net.h" #include "qmp-commands.h" +#include "fsdev/qemu-fsdev.h" +#include "emulator.h" #include "emulator_options.h" #include "hw/virtio/maru_virtio_touchscreen.h" #include "hw/virtio/maru_virtio_evdi.h" @@ -65,40 +68,6 @@ DECLARE_DEBUG_CHANNEL(emul_state); static EmulatorConfigInfo _emul_info = {0,}; static EmulatorConfigState _emul_state; -/* misc */ -const char *get_bin_path(void) -{ - const char *bin_path = get_variable(KEYWORD_BIN_PATH); - // guarantee bin_path is not NULL - if (!bin_path) { - bin_path = ""; - } - return bin_path; -} - -const char *get_log_path(void) -{ - const char *log_path = get_variable("log_path"); - - // if "log_path" is not exist, make it first. - if (!log_path) { - char *vms_path = get_variable("vms_path"); - char *vm_name = get_variable("vm_name"); - if (!vms_path || !vm_name) { - // we can not specify log path. - // emulator may not be launched from emulator-manager. - log_path = ""; - } - else { - log_path = g_strdup_printf("%s/%s/logs", vms_path, vm_name); - } - - set_variable("log_path", log_path, false); - } - - return log_path; -} - /* sdl bits per pixel */ void set_emul_sdl_bpp(int bpp) { @@ -114,56 +83,6 @@ int get_emul_sdl_bpp(void) return _emul_info.sdl_bpp; } -/* mouse device */ -void set_emul_input_mouse_enable(bool on) -{ - _emul_info.input_mouse_enable = on; - - if (_emul_info.input_mouse_enable == true) { - LOG_INFO("set_emul_input_mouse_enable\n"); - } -} - -bool is_emul_input_mouse_enable(void) -{ - return _emul_info.input_mouse_enable; -} - -/* touchscreen device */ -void set_emul_input_touch_enable(bool on) -{ - _emul_info.input_touch_enable = on; - - if (_emul_info.input_touch_enable == true) { - LOG_INFO("set_emul_input_touch_enable\n"); - } -} - -bool is_emul_input_touch_enable(void) -{ - return _emul_info.input_touch_enable; -} - -bool is_netclient_tap_attached(void) -{ - NetClientState *ncs[MAX_QUEUE_NUM]; - int queues, i; - - queues = qemu_find_net_clients_except(NULL, ncs, - NET_CLIENT_OPTIONS_KIND_NIC, - MAX_QUEUE_NUM); - for (i = 0; i < queues; ++i) { - if (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_TAP && - (ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC || - // for legacy -net option. - ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT)) { - return true; - } - } - - return false; -} - void set_emul_guest_ip(char *ip) { strncpy(_emul_info.guest_ip, ip, strlen(ip)); @@ -423,34 +342,118 @@ bool get_emul_cpu_accel(void) return false; } -/* VM ram size */ -void set_emul_ram_size(const char *size) -{ - _emul_info.vm_ram_size = size; -} +// +// cleaned-up +// -const char* get_emul_ram_size(void) +// launch_conf_path +// only set by emulator.c when start up +const char *launch_conf_file = NULL; + +// bin path +// only set by osutil-{OS}.c when start up +const char *bin_path = NULL; + +const char *get_bin_path(void) { - return _emul_info.vm_ram_size; + if (bin_path) { + return bin_path; + } + + return ""; } -/* file sharing path */ -void set_emul_file_sharing_path(const char *path) +// emulator kernel log file +static const char *kernel_log_redirect_file = NULL; + +const char *get_kernel_log_redirect_file(void) { - _emul_info.file_sharing_path = path; + // TODO: kernel log path should be aquired from char device. + if (kernel_log_redirect_file) { + return kernel_log_redirect_file; + } + + char *vms_path = get_variable("vms_path"); + char *vm_name = get_variable("vm_name"); + if (!vms_path || !vm_name) { + // we can not specify log path. + // emulator may not be launched from emulator-manager. + kernel_log_redirect_file = g_strdup(""); + } + else { + kernel_log_redirect_file = + g_strdup_printf("%s/%s/logs/emulator.klog", vms_path, vm_name); + } + + return kernel_log_redirect_file; } -const char* get_emul_file_sharing_path(void) +// emulator log file +static const char *log_redirect_file = NULL; + +#ifdef CONFIG_WIN32 +// for checking Windows version +extern OSVERSIONINFO osvi; +#endif + +const char *get_log_redirect_file(void) { - return _emul_info.file_sharing_path; -} + int result = -1; + char log_filename[PATH_MAX]; -// -// cleaned-up -// + // should we compare stdout(fd/1) and stderr(fd/2) ?? +#if defined(CONFIG_LINUX) + result = readlink("/proc/self/fd/1", log_filename, PATH_MAX); + if (result >= 0) { + log_filename[result] = '\0'; + } +#elif defined(CONFIG_DARWIN) + result = fcntl(STDOUT_FILENO, F_GETPATH, log_filename); +#elif defined(CONFIG_WIN32) +# if WINVER >= 0x600 + // works only vista or newer... + if (osvi.dwMajorVersion >= 6) { + char win32_log_filename_normalized[PATH_MAX]; + HANDLE handle_stdout = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD ret = GetFinalPathNameByHandle(handle_stdout, + win32_log_filename_normalized, + PATH_MAX, FILE_NAME_NORMALIZED); + // strip "\\?\" + if (ret > 0) { + g_stpcpy(log_filename, win32_log_filename_normalized + 4); + result = 0; + } else { + result = -1; + } + } +# endif +#endif + if (log_redirect_file) { + g_free((void *)log_redirect_file); + } -// launch_conf_path -const char *launch_conf_file = NULL; + if (result >= 0) { + log_redirect_file = g_strdup(log_filename); + } else { + // fail safe + LOG_WARNING("Can not identify log redirection path, " + "We should assume it !!!\n"); + + char *vms_path = get_variable("vms_path"); + char *vm_name = get_variable("vm_name"); + if (!vms_path || !vm_name) { + // we can not specify log path. + // emulator may not be launched from emulator-manager. + log_redirect_file = g_strdup(""); + } + else { + log_redirect_file = + g_strdup_printf("%s/%s/logs/emulator.log", vms_path, vm_name); + } + } + + return log_redirect_file; +} // drive image file static const char *drive_image_file = NULL; @@ -478,6 +481,31 @@ const char *get_drive_image_file(void) return ""; } +// swap image file +static const char *swap_image_file = NULL; + +const char *get_swap_image_file(void) +{ + if (swap_image_file) { + return swap_image_file; + } + + // we should parse from "swap" parameter. + // so qemu_main() had to be called before. + BlockBackend *bb = blk_by_name("swap"); + if (bb) { + BlockDriverState *bs = blk_bs(bb); + swap_image_file = g_strdup(bs->filename); + + return swap_image_file; + } + + // called before device initialized + // or very weired situation + LOG_WARNING("Can not identify swap image file !!!\n"); + + return ""; +} // http proxy static const char *http_proxy_addr = NULL; @@ -505,7 +533,7 @@ const char *get_http_proxy_addr(void) g_strfreev(token); } - http_proxy_addr = ""; + http_proxy_addr = g_strdup(""); LOG_INFO("HTTP proxy address is not set.\n"); @@ -563,7 +591,16 @@ const char *get_profile_name(void) return get_variable("profile"); } -/* GPU virtualization */ +// host directory sharing path +const char* get_host_directory_sharing_path(void) +{ + FsDriverEntry *sharing_entry = get_fsdev_fsentry((char*)DEFAULT_STATIC_HDS_ID); + const char *sharing_path = (sharing_entry != NULL ? sharing_entry->path : NULL); + + return sharing_path; +} + +// GPU virtualization static bool gpu_accel_enabled; bool is_gpu_accel_enabled(void) @@ -603,6 +640,77 @@ bool is_gpu_accel_enabled(void) return gpu_accel_enabled; } +// ram size +uint64_t get_ram_size(void) +{ + return ram_size; +} + +// look-up PCI devices +bool is_pci_device_enabled(int device_id) +{ + bool is_enabled = false; + PciInfoList *info_list, *info; + Error *err = NULL; + + info_list = qmp_query_pci(&err); + if (err) { + LOG_WARNING("PCI devices not supported\n"); + error_free(err); + return false; + } + + for (info = info_list; info; info = info->next) { + PciDeviceInfoList *dev; + for (dev = info->value->devices; dev; dev = dev->next) { + if (dev->value->id.device == device_id) { + is_enabled = true; + break; + } + } + } + + qapi_free_PciInfoList(info_list); + + return is_enabled; +} + +// mouse input +bool is_mouse_enabled(void) +{ + /* TODO: If the maru mouse device is added, + * the device id should to be changed for it. + */ + return !is_pci_device_enabled(PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN); +} + +// touchscreen input +bool is_touchscreen_enabled(void) +{ + return is_pci_device_enabled(PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN); +} + +// tap attached +bool is_netclient_tap_attached(void) +{ + NetClientState *ncs[MAX_QUEUE_NUM]; + int queues, i; + + queues = qemu_find_net_clients_except(NULL, ncs, + NET_CLIENT_OPTIONS_KIND_NIC, + MAX_QUEUE_NUM); + for (i = 0; i < queues; ++i) { + if (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_TAP && + (ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC || + // for legacy -net option. + ncs[i]->peer->info->type == NET_CLIENT_OPTIONS_KIND_HUBPORT)) { + return true; + } + } + + return false; +} + // vm_data_path static const char *vm_data_path = NULL; @@ -634,6 +742,7 @@ const char* get_vm_data_path(void) } // display resolution +// only set by vl.c when start up int initial_resolution_width = -1; int initial_resolution_height = -1; @@ -656,11 +765,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; } @@ -713,3 +824,40 @@ bool is_skin_enabled(void) return skin_enabled; } #endif + +static void emul_state_notify_exit(Notifier *notifier, void *data) +{ + g_free((void *)launch_conf_file); + launch_conf_file = NULL; + + g_free((void *)bin_path); + bin_path = NULL; + + g_free((void *)kernel_log_redirect_file); + kernel_log_redirect_file = NULL; + + g_free((void *)log_redirect_file); + log_redirect_file = NULL; + + g_free((void *)drive_image_file); + drive_image_file = NULL; + + g_free((void *)swap_image_file); + swap_image_file = NULL; + + g_free((void *)http_proxy_addr); + http_proxy_addr = NULL; + + g_free((void *)vm_name); + vm_name = NULL; + + g_free((void *)vm_data_path); + vm_data_path = NULL; +} + +static Notifier emul_state_exit = { .notify = emul_state_notify_exit }; + +void init_emul_state(void) +{ + emulator_add_exit_notifier(&emul_state_exit); +} diff --git a/tizen/src/emul_state.h b/tizen/src/emul_state.h index 92baa4b895..57a321c151 100644 --- a/tizen/src/emul_state.h +++ b/tizen/src/emul_state.h @@ -35,6 +35,7 @@ #include "display/maru_finger.h" #include "config-host.h" +#include "hw/maru_device_ids.h" #define MAX_ADDR_LEN 256 #define MAX_PORT_LEN 256 @@ -42,6 +43,8 @@ #define MAX_HDS_PATH 256 #define MAX_PROFILE 256 +#define DEFAULT_STATIC_HDS_ID "fsdef0" + enum { RESET = 0, BOOT_COMPLETED = 1, @@ -88,10 +91,7 @@ enum { }; typedef struct EmulatorConfigInfo { - bool skin_enable; int sdl_bpp; - bool input_mouse_enable; - bool input_touch_enable; int vm_base_port; int device_serial_number; int ecs_port; @@ -102,7 +102,6 @@ typedef struct EmulatorConfigInfo { int spice_port; const char *skin_path; const char *file_sharing_path; - const char *vm_ram_size; int serial_port; /* add here */ } EmulatorConfigInfo; @@ -121,21 +120,13 @@ typedef struct EmulatorConfigState { bool sdb_connection; } EmulatorConfigState; -/* misc */ -char const *get_bin_path(void); -char const *get_log_path(void); - /* setter */ void set_emul_win_scale(double scale); void set_emul_sdl_bpp(int bpp); -void set_emul_input_mouse_enable(bool on); -void set_emul_input_touch_enable(bool on); void set_emul_vm_base_port(int port); void set_emul_ecs_port(int port); void set_emul_guest_ip(char *ip); void set_emul_host_ip(char *ip); -void set_emul_file_sharing_path(const char *path); -void set_emul_ram_size(const char *size); void set_emulator_condition(int state); void set_emul_rotation(short rotation_type); @@ -148,8 +139,6 @@ void set_sdb_connection(bool connected); /* getter */ double get_emul_win_scale(void); int get_emul_sdl_bpp(void); -bool is_emul_input_mouse_enable(void); -bool is_emul_input_touch_enable(void); int get_emul_vm_base_port(void); int get_device_serial_number(void); int get_emul_ecs_port(void); @@ -157,8 +146,6 @@ int get_emul_serial_port(void); int get_emul_spice_port(void); const char* get_emul_skin_path(void); bool get_emul_cpu_accel(void); -const char* get_emul_file_sharing_path(void); -const char* get_emul_ram_size(void); int get_emulator_condition(void); short get_emul_rotation(void); @@ -171,7 +158,6 @@ char* get_emul_host_ip(void); bool get_emuld_connection(void); bool get_sdb_connection(void); -bool is_netclient_tap_attached(void); int get_max_touch_point(void); /* multi-touch */ @@ -181,13 +167,29 @@ int get_multi_touch_enable(void); // cleaned-up extern const char *launch_conf_file; +extern const char *bin_path; +extern int initial_resolution_width; +extern int initial_resolution_height; +char const *get_bin_path(void); +char const *get_log_redirect_file(void); +char const *get_kernel_log_redirect_file(void); const char *get_drive_image_file(void); +const char *get_swap_image_file(void); const char *get_http_proxy_addr(void); const char *get_vm_name(void); const char *get_profile_name(void); -bool is_gpu_accel_enabled(void); const char *get_vm_data_path(void); +const char* get_host_directory_sharing_path(void); + +bool is_gpu_accel_enabled(void); +bool is_pci_device_enabled(int device_id); +bool is_mouse_enabled(void); +bool is_touchscreen_enabled(void); +bool is_netclient_tap_attached(void); + +uint64_t get_ram_size(void); + void set_initial_display_resolution(int width, int height); int get_display_resolution_width(void); int get_display_resolution_height(void); @@ -196,4 +198,5 @@ void set_skin_enabled(bool enabled); bool is_skin_enabled(void); #endif +void init_emul_state(void); #endif /* __EMUL_STATE_H__ */ diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index de7c20756e..776472ebe4 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -64,7 +64,6 @@ int thread_running = 1; /* Check if we need exit main */ DECLARE_DEBUG_CHANNEL(main); -#define INPUT_TOUCH_PARAMETER "virtio-touchscreen-pci" #define ARGS_LIMIT 128 char *maru_kernel_cmdline; @@ -212,21 +211,6 @@ void print_system_info(void) is_printed = true; } -static void set_qemu_input_mode(void) -{ - int i; - for (i = 0; i < _qemu_argc; ++i) { - if (strstr(_qemu_argv[i], INPUT_TOUCH_PARAMETER) != NULL) { - /* touchscreen */ - set_emul_input_touch_enable(true); - } - } - - if (is_emul_input_touch_enable() != true) { - set_emul_input_mouse_enable(true); - } -} - static void print_options_info(void) { int i; @@ -274,7 +258,6 @@ const char *prepare_maru(const char * const kernel_cmdline) void prepare_maru_after_device_init(void) { make_vm_lock_os(); - set_qemu_input_mode(); init_device_hotplug(); start_ecs(); init_sdb(get_emul_vm_base_port() + SDB_UDP_SENSOR_INDEX); @@ -390,6 +373,8 @@ static int emulator_main(int argc, char *argv[], char **envp) LOG_INFO("Start emulator...\n"); print_options_info(); + init_emul_state(); + LOG_INFO("qemu main start...\n"); qemu_main(_qemu_argc, _qemu_argv, envp); diff --git a/tizen/src/emulator_common.h b/tizen/src/emulator_common.h index 4aef16733f..ad88358a21 100644 --- a/tizen/src/emulator_common.h +++ b/tizen/src/emulator_common.h @@ -49,6 +49,10 @@ #include "config-host.h" +#ifdef CONFIG_DARWIN +#include "sys/syslimits.h" +#endif + #if !defined(PATH_MAX) #if defined(MAX_PATH) #define PATH_MAX MAX_PATH diff --git a/tizen/src/emulator_options.h b/tizen/src/emulator_options.h index cbe18954eb..f085f1bc48 100644 --- a/tizen/src/emulator_options.h +++ b/tizen/src/emulator_options.h @@ -37,8 +37,6 @@ #define SUPPORT_SKIN_OPTIONS #endif -#define KEYWORD_BIN_PATH "_BIN_PATH_" - void set_variable(const char * const arg1, const char * const arg2, bool override); char *get_variable(const char * const name); void reset_variables(void); diff --git a/tizen/src/eventcast/common.c b/tizen/src/eventcast/common.c index 0a8fb3587b..02172474a7 100644 --- a/tizen/src/eventcast/common.c +++ b/tizen/src/eventcast/common.c @@ -345,7 +345,7 @@ static bool msgproc_eventcast_event_msg(Eventcast__EventMsg *msg) // TODO: check sensor device whether it exists or not set_eventcast_sensor_status(EVENTCAST__STATE__ENABLED); - if (is_emul_input_touch_enable()) { + if (is_touchscreen_enabled()) { touch_status = EVENTCAST__STATE__ENABLED; } else { touch_status = EVENTCAST__STATE__DISABLED; diff --git a/tizen/src/hw/virtio/maru_virtio_evdi.c b/tizen/src/hw/virtio/maru_virtio_evdi.c index 0f7b43a7ce..2b2006b017 100644 --- a/tizen/src/hw/virtio/maru_virtio_evdi.c +++ b/tizen/src/hw/virtio/maru_virtio_evdi.c @@ -75,7 +75,7 @@ static QTAILQ_HEAD(EvdiMsgHead , EvdiBuf) evdi_in_queue = QTAILQ_HEAD_INITIALIZER(evdi_in_queue); -static pthread_mutex_t recv_buf_mutex = PTHREAD_MUTEX_INITIALIZER; +static QemuMutex recv_buf_mutex; bool send_to_evdi(const uint32_t route, char* data, const uint32_t len) { @@ -107,11 +107,11 @@ bool send_to_evdi(const uint32_t route, char* data, const uint32_t len) _msg->info.use = size; _msg->info.index = count; - pthread_mutex_lock(&recv_buf_mutex); + qemu_mutex_lock(&recv_buf_mutex); QTAILQ_INSERT_TAIL(&evdi_recv_msg_queue, _msg, next); - pthread_mutex_unlock(&recv_buf_mutex); + qemu_mutex_unlock(&recv_buf_mutex); left -= size; count ++; @@ -138,7 +138,7 @@ static void flush_evdi_recv_queue(void) } - pthread_mutex_lock(&recv_buf_mutex); + qemu_mutex_lock(&recv_buf_mutex); while (!QTAILQ_EMPTY(&evdi_recv_msg_queue)) { @@ -170,7 +170,7 @@ static void flush_evdi_recv_queue(void) free(msginfo); } - pthread_mutex_unlock(&recv_buf_mutex); + qemu_mutex_unlock(&recv_buf_mutex); } @@ -241,6 +241,8 @@ static void virtio_evdi_realize(DeviceState *dev, Error **errp) vio_evdi->bh = qemu_bh_new(maru_evdi_bh, vio_evdi); + qemu_mutex_init(&recv_buf_mutex); + epi_init(); } @@ -250,6 +252,8 @@ static void virtio_evdi_unrealize(DeviceState *dev, Error **errp) INFO("destroy evdi device\n"); + qemu_mutex_destroy(&recv_buf_mutex); + if (vio_evdi->bh) { qemu_bh_delete(vio_evdi->bh); } diff --git a/tizen/src/hw/virtio/maru_virtio_nfc.c b/tizen/src/hw/virtio/maru_virtio_nfc.c index e7a68b781d..76aa9da3f4 100644 --- a/tizen/src/hw/virtio/maru_virtio_nfc.c +++ b/tizen/src/hw/virtio/maru_virtio_nfc.c @@ -65,7 +65,7 @@ typedef struct NFCBuf { static char nfc_data [NFC_MAX_BUF_SIZE] = {'0',}; -static pthread_mutex_t recv_buf_mutex = PTHREAD_MUTEX_INITIALIZER; +static QemuMutex recv_buf_mutex; static void send_nfc_data_to_ecs(const char* data) { @@ -133,11 +133,11 @@ bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const u _msg->info.client_id = id; _msg->info.client_type = type; - pthread_mutex_lock(&recv_buf_mutex); + qemu_mutex_lock(&recv_buf_mutex); strcpy(nfc_data, data); QTAILQ_INSERT_TAIL(&nfc_recv_msg_queue, _msg, next); - pthread_mutex_unlock(&recv_buf_mutex); + qemu_mutex_unlock(&recv_buf_mutex); qemu_bh_schedule(vio_nfc->bh); @@ -159,7 +159,7 @@ static void flush_nfc_recv_queue(void) } - pthread_mutex_lock(&recv_buf_mutex); + qemu_mutex_lock(&recv_buf_mutex); while (!QTAILQ_EMPTY(&nfc_recv_msg_queue)) { @@ -191,7 +191,7 @@ static void flush_nfc_recv_queue(void) free(msginfo); } - pthread_mutex_unlock(&recv_buf_mutex); + qemu_mutex_unlock(&recv_buf_mutex); } @@ -261,6 +261,8 @@ static void virtio_nfc_realize(DeviceState* dev, Error **errp) vio_nfc->svq = virtio_add_queue(&vio_nfc->vdev, 256, virtio_nfc_send); vio_nfc->bh = qemu_bh_new(maru_nfc_bh, vio_nfc); + + qemu_mutex_init(&recv_buf_mutex); } static void virtio_nfc_unrealize(DeviceState* dev, Error **errp) @@ -269,6 +271,8 @@ static void virtio_nfc_unrealize(DeviceState* dev, Error **errp) INFO("destroy nfc device\n"); + qemu_mutex_destroy(&recv_buf_mutex); + if (vio_nfc->bh) { qemu_bh_delete(vio_nfc->bh); } diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index 235b36aee3..62c24de6ad 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -129,7 +129,7 @@ static void *run_skin_client(void *arg) /* input */ char buf_input[12] = { 0, }; - if (is_emul_input_mouse_enable() == true) { + if (is_mouse_enabled() == true) { strcpy(buf_input, OPT_INPUT_MOUSE); } else { strcpy(buf_input, OPT_INPUT_TOUCH); diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index 398c4bebe8..10033ba576 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -381,7 +381,7 @@ DetailInfo* get_detail_info(int qemu_argc, char** qemu_argv) /* collect log path information */ #define LOGPATH_TEXT "log_path=" - const char* log_path = get_log_path(); + char* log_path = g_path_get_dirname(get_log_redirect_file()); int log_path_len = strlen(LOGPATH_TEXT) + strlen(log_path) + delimiter_len; total_len += (log_path_len + 1); @@ -418,6 +418,8 @@ DetailInfo* get_detail_info(int qemu_argc, char** qemu_argv) detail_info->data = info_data; detail_info->data_length = total_len; + g_free(log_path); + return detail_info; } diff --git a/tizen/src/ui/displaybase.cpp b/tizen/src/ui/displaybase.cpp index 5468962952..f9cf74e1cc 100644 --- a/tizen/src/ui/displaybase.cpp +++ b/tizen/src/ui/displaybase.cpp @@ -58,8 +58,8 @@ DisplayBase::DisplayBase(DisplayType *displayForm, QSize resolution, qreal scale this->gImg = new QImage(); this->gPxmImg = new QPixmap(); - isMouse = is_emul_input_mouse_enable(); - if (isMouse) { + isTouch = is_touchscreen_enabled(); + if (!isTouch) { prevX = 0; prevY = 0; lastMouseTime.tv_sec = 0; @@ -248,10 +248,10 @@ void DisplayBase::handleMousePress(QMouseEvent *event) if (event->button() == Qt::LeftButton) { isDragging = true; - if (isMouse) { - do_mouse_event(1, PS2_PRESS, 0, 0, 0, 0, 0); - } else { + if (isTouch) { tsHelper->mousePressed(event, getGuestPos(event->pos())); + } else { + do_mouse_event(1, PS2_PRESS, 0, 0, 0, 0, 0); } } } @@ -263,34 +263,17 @@ void DisplayBase::handleMouseRelease(QMouseEvent *event) isDragging = false; } - if (isMouse) { - do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0); - } else { + if (isTouch) { tsHelper->mouseReleased(event, getGuestPos(event->pos())); + } else { + do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0); } } } void DisplayBase::handleMouseMove(QMouseEvent *event) { - if (isMouse) { - int event_type = MOUSE_MOVE; - int clientX = event->x(); - int clientY = event->y(); - - if (clientX < 0 || clientX > widget->width() || - clientY < 0 || clientY > widget->height()) { - if (isDragging == true) { - isDragging = false; - qDebug("auto released..."); - do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0); - return; - } else { - /* do nothing */ - } - } - sendMouseEvent(event_type, clientX, clientY); - } else { /* touch device */ + if (isTouch) { /* touch device */ if (isDragging == true) { int hostPosX = event->x(); int hostPosY = event->y(); @@ -322,6 +305,23 @@ void DisplayBase::handleMouseMove(QMouseEvent *event) tsHelper->mouseMoved(event, getGuestPos(event->pos())); } } + } else { + int event_type = MOUSE_MOVE; + int clientX = event->x(); + int clientY = event->y(); + + if (clientX < 0 || clientX > widget->width() || + clientY < 0 || clientY > widget->height()) { + if (isDragging == true) { + isDragging = false; + qDebug("auto released..."); + do_mouse_event(1, PS2_RELEASE, 0, 0, 0, 0, 0); + return; + } else { + /* do nothing */ + } + } + sendMouseEvent(event_type, clientX, clientY); } } @@ -337,7 +337,7 @@ void DisplayBase::handleMouseInit(QMouseEvent *event) void DisplayBase::handleMouseEnter(QEvent *event) { - if (isMouse) { + if (!isTouch) { if (mouseStatus == MOUSE_LEAVE) { mouseStatus = MOUSE_ENTER; } @@ -346,7 +346,7 @@ void DisplayBase::handleMouseEnter(QEvent *event) void DisplayBase::handleMouseLeave(QEvent *event) { - if (isMouse) { + if (!isTouch) { mouseStatus = MOUSE_LEAVE; } } diff --git a/tizen/src/ui/displaybase.h b/tizen/src/ui/displaybase.h index 01de411841..8469475c22 100644 --- a/tizen/src/ui/displaybase.h +++ b/tizen/src/ui/displaybase.h @@ -104,7 +104,7 @@ private: void sendMouseEvent(int eventType, int clientX, int clientY); QSize resolution; - bool isMouse; + bool isTouch; int prevX; int prevY; diff --git a/tizen/src/ui/displayglwidget.cpp b/tizen/src/ui/displayglwidget.cpp index 28b5f811b2..9bbbf57d3c 100644 --- a/tizen/src/ui/displayglwidget.cpp +++ b/tizen/src/ui/displayglwidget.cpp @@ -39,9 +39,9 @@ DisplayGLWidget::DisplayGLWidget(QWidget *parent, QGLContext *context, QGLWidget(context, parent), DisplayBase(displayForm, resolution, scaleFactor, this) { setAutoBufferSwap(false); - isMouse = is_emul_input_mouse_enable(); + isTouch = is_touchscreen_enabled(); /* mouse mode */ - if (isMouse) { + if (!isTouch) { setCursor(Qt::BlankCursor); setMouseTracking(true); } diff --git a/tizen/src/ui/displayglwidget.h b/tizen/src/ui/displayglwidget.h index f41e08331a..170c801159 100644 --- a/tizen/src/ui/displayglwidget.h +++ b/tizen/src/ui/displayglwidget.h @@ -58,7 +58,7 @@ protected: void enterEvent(QEvent *event); void leaveEvent(QEvent *event); private: - bool isMouse; + bool isTouch; }; #endif // DISPLAYGLWIDGET_H diff --git a/tizen/src/ui/displayswwidget.cpp b/tizen/src/ui/displayswwidget.cpp index 7d1d278df5..a973a8c0a0 100644 --- a/tizen/src/ui/displayswwidget.cpp +++ b/tizen/src/ui/displayswwidget.cpp @@ -48,9 +48,9 @@ DisplaySWWidget::DisplaySWWidget(QWidget *parent, initImage.fill(Qt::black); setPixmap(initImage); - isMouse = is_emul_input_mouse_enable(); + isTouch = is_touchscreen_enabled(); /* mouse mode */ - if (isMouse) { + if (!isTouch) { setCursor(Qt::BlankCursor); setMouseTracking(true); } diff --git a/tizen/src/ui/displayswwidget.h b/tizen/src/ui/displayswwidget.h index 779c7e87ef..5c3d27ec32 100644 --- a/tizen/src/ui/displayswwidget.h +++ b/tizen/src/ui/displayswwidget.h @@ -57,7 +57,7 @@ protected: void leaveEvent(QEvent *event); private: MultiTouchTracker *mtTracker; - bool isMouse; + bool isTouch; }; #endif // DISPLAYSWWIDGET_H diff --git a/tizen/src/ui/input/keyboardshortcut.cpp b/tizen/src/ui/input/keyboardshortcut.cpp index e23a3fa1ea..c3baebee0a 100644 --- a/tizen/src/ui/input/keyboardshortcut.cpp +++ b/tizen/src/ui/input/keyboardshortcut.cpp @@ -66,18 +66,6 @@ void KeyboardShortcut::removeHwKeyShortcut() qDebug() << "Removed hwKey shortcuts"; } -void KeyboardShortcut::removePopupMenuShortcut() -{ - for (int index = 0; index < popupMenuShortcutList.count(); index++) { - delete popupMenuShortcutList.at(index); - } - - popupMenuShortcutList.clear(); - popupMenuShortcutMap.clear(); - - qDebug() << "Removed popupMenu shortcuts"; -} - void KeyboardShortcut::registShortcutKey(QShortcut *shortcut, QString item) { QSignalMapper *mapper = new QSignalMapper(this); @@ -165,226 +153,6 @@ void KeyboardShortcut::setKeyboardShortcutHwKey() } } -void KeyboardShortcut::setKeyboardShortcutContextMenu( - MenuItem *item, QString property, QString keySequence) -{ - QShortcut *shortcut = new QShortcut(QKeySequence::fromString(keySequence), parent); - int itemType = item->getType(); - QString itemName = item->getName(); - - switch (itemType) { - case MenuItemType::closeItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutClose())); - break; - case MenuItemType::infoItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutDetailedInfo())); - if (itemName.isEmpty()) { - itemName = DETAILED_INFO_TITLE; - } - break; - case MenuItemType::onTopItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutTopMost())); - break; - case MenuItemType::hostKeyboardItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutHostKeyboard())); - break; - case MenuItemType::forceCloseItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutForceClose())); - break; - case MenuItemType::shellItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutShell())); - break; - case MenuItemType::controlPanelItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutControlPanel())); - break; - case MenuItemType::screenShotItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutRequestScreenshot())); - break; - case MenuItemType::controllerItem: - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutController())); - break; - case MenuItemType::scaleItem: - if (property == "prev") { - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutScalePrev())); - } else if (property == "next") { - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutScaleNext())); - } else { - qDebug() << "undefined property: " << property; - } - break; - case MenuItemType::switchItem: - if (property == "prev") { - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutSwitchPrev())); - } else if (property == "next") { - connect(shortcut, SIGNAL(activated()), this, SLOT(slotShortcutSwitchNext())); - } else { - qDebug() << "undefined property: " << property; - } - break; - default: - qDebug() << "undefined item type: " << itemType; - return; - } - - if (!property.isEmpty()) { - itemName.append(" " + property); - } - - popupMenuShortcutList.append(shortcut); - popupMenuShortcutMap.insert(itemName, keySequence); -} - -void KeyboardShortcut::slotShortcutClose() -{ - parent->getPopupMenu()->slotClose(); -} - -void KeyboardShortcut::slotShortcutDetailedInfo() -{ - parent->getPopupMenu()->slotDetailedInfo(); -} - -void KeyboardShortcut::slotShortcutShell() -{ - parent->getPopupMenu()->slotShell(); -} - -void KeyboardShortcut::slotShortcutRequestScreenshot() -{ - parent->getPopupMenu()->slotRequestScreenshot(); -} - -void KeyboardShortcut::slotShortcutForceClose() -{ - parent->getPopupMenu()->slotForceClose(); -} - -void KeyboardShortcut::slotShortcutControlPanel() -{ - parent->getPopupMenu()->slotControlPanel(); -} - -void KeyboardShortcut::slotShortcutTopMost() -{ - QAction *action = parent->getPopupMenu()->getActionTopMost(); - parent->getPopupMenu()->slotTopMost(!action->isChecked()); -} - -void KeyboardShortcut::slotShortcutSwitchPrev() -{ - QAction *action = parent->getPopupMenu()->switchGroup->checkedAction(); - QList<QAction *> switchList = parent->getPopupMenu()->switchGroup->actions(); - - if (!action) { - qWarning() << "switch prev failed."; - return; - } - - int index = switchList.indexOf(action); - if (index == switchList.count() - 1) { - index = 0; - } else { - index++; - } - - QAction *nextSwitchAction = switchList.at(index); - nextSwitchAction->setChecked(true); - nextSwitchAction->trigger(); -} - -void KeyboardShortcut::slotShortcutSwitchNext() -{ - QAction *action = parent->getPopupMenu()->switchGroup->checkedAction(); - QList<QAction *> switchList = parent->getPopupMenu()->switchGroup->actions(); - - if (!action) { - qWarning() << "switch next failed."; - return; - } - - int index = switchList.indexOf(action); - if (index == 0) { - index = switchList.count() - 1; - } else { - index--; - } - - QAction *nextSwitchAction = switchList.at(index); - nextSwitchAction->setChecked(true); - nextSwitchAction->trigger(); -} - -void KeyboardShortcut::slotShortcutScaleNext() -{ - QAction *action = parent->getPopupMenu()->scaleGroup->checkedAction(); - QList<QAction *> scaleList = parent->getPopupMenu()->scaleGroup->actions(); - - if (!action) { - qWarning() << "scale next failed."; - return; - } - - int index = scaleList.indexOf(action); - if (index == 0) { - index = scaleList.count() - 1; - } else { - index--; - } - - QAction *nextScaleAction = scaleList.at(index); - nextScaleAction->setChecked(true); - nextScaleAction->trigger(); -} - -void KeyboardShortcut::slotShortcutScalePrev() -{ - QAction *action = parent->getPopupMenu()->scaleGroup->checkedAction(); - QList<QAction *> scaleList = parent->getPopupMenu()->scaleGroup->actions(); - - if (!action) { - qWarning() << "scale prev failed."; - return; - } - - int index = scaleList.indexOf(action); - if (index == scaleList.count() - 1) { - index = 0; - } else { - index++; - } - - QAction *nextScaleAction = scaleList.at(index); - nextScaleAction->setChecked(true); - nextScaleAction->trigger(); -} - -void KeyboardShortcut::slotShortcutController() -{ - QAction *action = parent->getPopupMenu()->controllerGroup->checkedAction(); - QList<QAction *> controllerList = parent->getPopupMenu()->controllerGroup->actions(); - - if (!action) { - qWarning() << "change controller failed."; - return; - } - - int last_index = controllerList.count() - 1; - int index = controllerList.indexOf(action) + 1; - - if (index > last_index) { - index = 0; - } - - QAction *nextControllerAction = controllerList.at(index); - if (!nextControllerAction) { - qWarning() << "controllerList.at(" << index << ") is NULL"; - return; - } - - nextControllerAction->setChecked(true); - nextControllerAction->trigger(); -} - void KeyboardShortcut::slotShortcutHostKeyboard() { QAction *action = parent->getPopupMenu()->keyboardGroup->checkedAction(); @@ -459,21 +227,11 @@ QList<QShortcut *> KeyboardShortcut::getControllerShortcutList() return controllerShortcutList; } -QList<QShortcut *> KeyboardShortcut::getPopupMenuShortcutList() -{ - return popupMenuShortcutList; -} - QList<QShortcut *> KeyboardShortcut::getHwKeyShortcutList() { return hwKeyShortcutList; } -QMap<QString, QString> KeyboardShortcut::getPopupMenuShortcutMap() -{ - return popupMenuShortcutMap; -} - QMap<QString, QString> KeyboardShortcut::getHwKeyShortcutMap() { return hwKeyShortcutMap; @@ -488,7 +246,6 @@ KeyboardShortcut::~KeyboardShortcut() { removeHwKeyShortcut(); removeControllerShortcut(); - removePopupMenuShortcut(); qDebug("destroy keyboard shortcut"); } diff --git a/tizen/src/ui/input/keyboardshortcut.h b/tizen/src/ui/input/keyboardshortcut.h index c91d9c1aba..39544874e1 100644 --- a/tizen/src/ui/input/keyboardshortcut.h +++ b/tizen/src/ui/input/keyboardshortcut.h @@ -36,7 +36,6 @@ #include <QMap> #include "layout/hardwarekey.h" -#include "menu/menuitem.h" class MainWindow; @@ -50,33 +49,17 @@ public: void setKeyboardShortcutHwKey(); void setKeyboardShortcutController(); - void setKeyboardShortcutContextMenu(MenuItem *item, QString property, QString keySequence); void removeControllerShortcut(); void removeHwKeyShortcut(); - void removePopupMenuShortcut(); QList<QShortcut *> getControllerShortcutList(); - QList<QShortcut *> getPopupMenuShortcutList(); QList<QShortcut *> getHwKeyShortcutList(); - QMap<QString, QString> getPopupMenuShortcutMap(); QMap<QString, QString> getHwKeyShortcutMap(); QMap<QString, QString> getControllerShortcutMap(); public slots: void slotShortcutHwKey(const QString &name); - void slotShortcutClose(); - void slotShortcutDetailedInfo(); - void slotShortcutControlPanel(); - void slotShortcutShell(); - void slotShortcutRequestScreenshot(); - void slotShortcutForceClose(); void slotShortcutHostKeyboard(); - void slotShortcutController(); - void slotShortcutScalePrev(); - void slotShortcutScaleNext(); - void slotShortcutSwitchPrev(); - void slotShortcutSwitchNext(); - void slotShortcutTopMost(); private: void registShortcutKey(QShortcut *shortcut, QString item); @@ -86,10 +69,8 @@ private: MainWindow *parent; QList<HardwareKey *> hwKeyList; QList<HardwareKey *> controllerKeyList; - QList<QShortcut *> popupMenuShortcutList; QList<QShortcut *> controllerShortcutList; QList<QShortcut *> hwKeyShortcutList; - QMap<QString, QString> popupMenuShortcutMap; QMap<QString, QString> hwKeyShortcutMap; QMap<QString, QString> controllerShortcutMap; }; diff --git a/tizen/src/ui/mainwindow.cpp b/tizen/src/ui/mainwindow.cpp index 3cd69c9172..84fc6fd553 100644 --- a/tizen/src/ui/mainwindow.cpp +++ b/tizen/src/ui/mainwindow.cpp @@ -512,6 +512,11 @@ MainWindow::~MainWindow() { qDebug("destroy main window"); + if (popupMenu) { + delete popupMenu; + popupMenu = NULL; + } + if (rotary != NULL) { delete rotary; rotary = NULL; diff --git a/tizen/src/ui/menu/aboutdialog.cpp b/tizen/src/ui/menu/aboutdialog.cpp index df5f0833ca..88a8dd090d 100644 --- a/tizen/src/ui/menu/aboutdialog.cpp +++ b/tizen/src/ui/menu/aboutdialog.cpp @@ -31,12 +31,8 @@ #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) + QDialog(parent, Qt::Dialog | Qt::WindowStaysOnTopHint) { setWindowTitle(ABOUT_TITLE); @@ -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"); @@ -116,6 +120,8 @@ void AboutDialog::showEvent(QShowEvent *event) { Q_UNUSED(event) + setFixedSize(size()); + QWidget *win = parentWidget(); move(win->geometry().center().x() - (geometry().size().width() / 2), win->geometry().center().y() - (geometry().size().height() / 2)); diff --git a/tizen/src/ui/menu/contextmenu.cpp b/tizen/src/ui/menu/contextmenu.cpp index c617a8430e..dbbb486e37 100644 --- a/tizen/src/ui/menu/contextmenu.cpp +++ b/tizen/src/ui/menu/contextmenu.cpp @@ -83,20 +83,9 @@ ContextMenu::ContextMenu(QWidget *parent) : QMenu(parent) void ContextMenu::createItems(QMenu *menu, QList<MenuItem *> &list) { MenuItem *item = NULL; - KeyboardShortcut *keyboardShortcut = parent->getKeyboardShortcut(); - for (int i = 0; i < list.count(); i++) { item = list.at(i); - QMap<QString, QString> shortcutMap = item->getShortcutMap(); - if (!shortcutMap.isEmpty()) { - QMap<QString, QString>::iterator iter; - for (iter = shortcutMap.begin(); iter != shortcutMap.end(); iter++) { - keyboardShortcut->setKeyboardShortcutContextMenu(item, - iter.key(), iter.value()); - } - } - switch (item->getType()) { case MenuItemType::separator: createSeparator(menu); @@ -181,25 +170,6 @@ void ContextMenu::createAdvancedItem(QMenu *menu, MenuItem *item) createItems(advancedMenu, ((AdvancedMenuItem *)item)->getMenuList()); } -QString ContextMenu::getShortcutKeySeq(QString key) -{ - KeyboardShortcut *keyboardShortcut = parent->getKeyboardShortcut(); - QMap<QString, QString> shortcutMap = keyboardShortcut->getPopupMenuShortcutMap(); - QMap<QString, QString>::iterator iter; - QString keySequence; - - if (!shortcutMap.isEmpty()) { - for (iter = shortcutMap.begin(); iter != shortcutMap.end(); iter++) { - if (iter.key().startsWith(key)) { - keySequence.append(iter.value()); - break; - } - } - } - - return keySequence; -} - void ContextMenu::createInfoItem(QMenu *menu, MenuItem *item) { if (menu == NULL || item == NULL) { @@ -207,9 +177,16 @@ void ContextMenu::createInfoItem(QMenu *menu, MenuItem *item) } QString menuName = item->getName(); - actionDetailedInfo = addGeneralAction(menu, QIcon(QPixmap(":/icons/detailed_info.png")), - menuName.isEmpty() ? vmName : menuName, SLOT(slotDetailedInfo()), - getShortcutKeySeq(DETAILED_INFO_TITLE)); + actionDetailedInfo = addGeneralAction( + menu, QIcon(QPixmap(":/icons/detailed_info.png")), + menuName.isEmpty() ? vmName : menuName, + item->getShortcutMap().isEmpty()? NULL : + new QShortcut(item->getShortcutMap().begin().value(), parent), + SLOT(slotDetailedInfo())); + + actionDetailedInfo->setIconText(menuName.isEmpty() ? QString(DETAILED_INFO_TITLE) : menuName); + + item->setAction(actionDetailedInfo); } void ContextMenu::createOnTopItem(QMenu *menu, MenuItem *item) @@ -221,9 +198,19 @@ void ContextMenu::createOnTopItem(QMenu *menu, MenuItem *item) QString menuName = item->getName(); actionTopMost = menu->addAction( menuName.isEmpty() ? MENU_ONTOP_ITEM_TEXT : menuName); - actionTopMost->setShortcut(getShortcutKeySeq(menuName)); actionTopMost->setCheckable(true); connect(actionTopMost, SIGNAL(triggered(bool)), this, SLOT(slotTopMost(bool))); + + /* shortcut */ + if (item->getShortcutMap().isEmpty() == false) { + QShortcut *shortcut = new QShortcut( + item->getShortcutMap().begin().value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotTopMostShortcut())); + + actionTopMost->setShortcut(shortcut->key()); + } + + item->setAction(actionTopMost); } void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item) @@ -239,12 +226,38 @@ void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item) switchMenu = menu->addMenu(QIcon(QPixmap(":/icons/rotate.png")), menuName.isEmpty() ? MENU_SWITCH_ITEM_TEXT : menuName); - QAction *menuAction = switchMenu->menuAction(); - menuAction->setShortcut(getShortcutKeySeq(menuName)); switchGroup = new QActionGroup(this); switchMapper = new QSignalMapper(this); connect(switchMapper, SIGNAL(mapped(int)), this, SLOT(slotSwitch(int))); + /* shortcuts */ + QAction *switchAction = switchMenu->menuAction(); + QMap<QString, QKeySequence> shortcutMap = item->getShortcutMap(); + + if (shortcutMap.isEmpty() == false) { + QMap<QString, QKeySequence>::const_iterator iter; + if ((iter = shortcutMap.find("prev")) != shortcutMap.end()) { + QShortcut *shortcut = new QShortcut(iter.value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotSwitchShortcutPrev())); + + switchAction->setShortcut(shortcut->key()); + } + if ((iter = shortcutMap.find("next")) != shortcutMap.end()) { + QShortcut *shortcut = new QShortcut(iter.value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotSwitchShortcutNext())); + + switchAction->setShortcut(shortcut->key()); + } + + if (switchAction->shortcut().isEmpty() == true) { + QShortcut *shortcut = new QShortcut( + item->getShortcutMap().begin().value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotSwitchShortcutNext())); + + switchAction->setShortcut(shortcut->key()); + } + } + QAction *action = NULL; for (int i = 0; i < mainFormList.count(); i++) { action = switchMenu->addAction(mainFormList.at(i)->getName()); @@ -260,6 +273,8 @@ void ContextMenu::createSwitchItem(QMenu *menu, MenuItem *item) } else { qWarning("cannot create a switchItem"); } + + item->setAction(switchMenu->menuAction()); } void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item) @@ -275,25 +290,51 @@ void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item) scaleMenu = menu->addMenu(QIcon(QPixmap(":/icons/scale.png")), menuName.isEmpty() ? MENU_SCALE_ITEM_TEXT : menuName); - QAction *menuAction = scaleMenu->menuAction(); - menuAction->setShortcut(getShortcutKeySeq(menuName)); scaleGroup = new QActionGroup(this); scaleMapper = new QSignalMapper(this); connect(scaleMapper, SIGNAL(mapped(int)), this, SLOT(slotScale(int))); + /* shortcuts */ + QAction *scaleAction = scaleMenu->menuAction(); + QMap<QString, QKeySequence> shortcutMap = item->getShortcutMap(); + + if (shortcutMap.isEmpty() == false) { + QMap<QString, QKeySequence>::const_iterator shortcutIter; + if ((shortcutIter = shortcutMap.find("prev")) != shortcutMap.end()) { + QShortcut *shortcut = new QShortcut(shortcutIter.value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotScaleShortcutPrev())); + + scaleAction->setShortcut(shortcut->key()); + } + if ((shortcutIter = shortcutMap.find("next")) != shortcutMap.end()) { + QShortcut *shortcut = new QShortcut(shortcutIter.value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotScaleShortcutNext())); + + scaleAction->setShortcut(shortcut->key()); + } + + if (scaleAction->shortcut().isEmpty() == true) { + QShortcut *shortcut = new QShortcut( + item->getShortcutMap().begin().value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotScaleShortcutNext())); + + scaleAction->setShortcut(shortcut->key()); + } + } + QAction *action = NULL; - QMapIterator<int, QString> iter(factorMap); - iter.toBack(); - while(iter.hasPrevious() == true) { - iter.previous(); + QMapIterator<int, QString> factorIter(factorMap); + factorIter.toBack(); + while(factorIter.hasPrevious() == true) { + factorIter.previous(); - QString factorName = iter.value(); + QString factorName = factorIter.value(); action = scaleMenu->addAction( - factorName.isEmpty() ? (QString::number(iter.key()) + '%') : factorName); + factorName.isEmpty() ? (QString::number(factorIter.key()) + '%') : factorName); action->setActionGroup(scaleGroup); action->setCheckable(true); - scaleMapper->setMapping(action, iter.key()); + scaleMapper->setMapping(action, factorIter.key()); connect(action, SIGNAL(triggered()), scaleMapper, SLOT(map())); } @@ -305,6 +346,8 @@ void ContextMenu::createScaleItem(QMenu *menu, MenuItem *item) } else { qWarning("cannot create a scaleItem"); } + + item->setAction(scaleMenu->menuAction()); } void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item) @@ -320,12 +363,37 @@ void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item) controllerMenu = menu->addMenu( menuName.isEmpty() ? MENU_CONTROLLER_ITEM_TEXT : menuName); - QAction *menuAction = controllerMenu->menuAction(); - menuAction->setShortcut(getShortcutKeySeq(menuName)); controllerGroup = new QActionGroup(this); controllerMapper = new QSignalMapper(this); - connect(controllerMapper, SIGNAL(mapped(int)), this, - SLOT(slotController(int))); + connect(controllerMapper, SIGNAL(mapped(int)), this, SLOT(slotController(int))); + + /* shortcuts */ + QAction *conAction = controllerMenu->menuAction(); + QMap<QString, QKeySequence> shortcutMap = item->getShortcutMap(); + + if (shortcutMap.isEmpty() == false) { + QMap<QString, QKeySequence>::const_iterator iter; + if ((iter = shortcutMap.find("prev")) != shortcutMap.end()) { + QShortcut *shortcut = new QShortcut(iter.value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotConShortcutPrev())); + + conAction->setShortcut(shortcut->key()); + } + if ((iter = shortcutMap.find("next")) != shortcutMap.end()) { + QShortcut *shortcut = new QShortcut(iter.value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotConShortcutNext())); + + conAction->setShortcut(shortcut->key()); + } + + if (conAction->shortcut().isEmpty() == true) { + QShortcut *shortcut = new QShortcut( + item->getShortcutMap().begin().value(), parent); + connect(shortcut, SIGNAL(activated()), this, SLOT(slotConShortcutNext())); + + conAction->setShortcut(shortcut->key()); + } + } QAction *action = NULL; action = controllerMenu->addAction("None"); @@ -344,6 +412,8 @@ void ContextMenu::createControllerItem(QMenu *menu, MenuItem *item) } else { qWarning("cannot create a controllerItem"); } + + item->setAction(controllerMenu->menuAction()); } void ContextMenu::createHostKeyboardItem(QMenu *menu, MenuItem *item) @@ -355,19 +425,22 @@ void ContextMenu::createHostKeyboardItem(QMenu *menu, MenuItem *item) QString menuName = item->getName(); QMenu *keyboardMenu = menu->addMenu(QIcon(QPixmap(":/icons/host_keyboard.png")), menuName.isEmpty() ? MENU_HOSTKBD_ITEM_TEXT : menuName); - QAction *menuAction = keyboardMenu->menuAction(); - menuAction->setShortcut(getShortcutKeySeq(menuName)); keyboardGroup = new QActionGroup(this); - QAction *action = keyboardMenu->addAction(MENU_ON_ITEM_TEXT); - action->setActionGroup(keyboardGroup); - action->setCheckable(true); - connect(action, SIGNAL(toggled(bool)), this, SLOT(slotHostKeyboard(bool))); + QAction *hostKbdAction = keyboardMenu->addAction(MENU_ON_ITEM_TEXT); + hostKbdAction->setActionGroup(keyboardGroup); + hostKbdAction->setCheckable(true); + connect(hostKbdAction, SIGNAL(toggled(bool)), this, SLOT(slotHostKeyboard(bool))); + + /* shortcuts */ + // TODO: + + hostKbdAction = keyboardMenu->addAction(MENU_OFF_ITEM_TEXT); + hostKbdAction->setActionGroup(keyboardGroup); + hostKbdAction->setCheckable(true); + hostKbdAction->setChecked(true); - action = keyboardMenu->addAction(MENU_OFF_ITEM_TEXT); - action->setActionGroup(keyboardGroup); - action->setCheckable(true); - action->setChecked(true); + item->setAction(hostKbdAction); } void ContextMenu::createShellItem(QMenu *menu, MenuItem *item) @@ -377,9 +450,14 @@ void ContextMenu::createShellItem(QMenu *menu, MenuItem *item) } QString menuName = item->getName(); - actionShell = addGeneralAction(menu, QIcon(QPixmap(":/icons/shell.png")), - menuName.isEmpty() ? MENU_SHELL_ITEM_TEXT : menuName, SLOT(slotShell()), - getShortcutKeySeq(menuName)); + actionShell = addGeneralAction( + menu, QIcon(QPixmap(":/icons/shell.png")), + menuName.isEmpty() ? MENU_SHELL_ITEM_TEXT : menuName, + item->getShortcutMap().isEmpty()? NULL : + new QShortcut(item->getShortcutMap().begin().value(), parent), + SLOT(slotShell())); + + item->setAction(actionShell); } void ContextMenu::createControlPanelItem(QMenu *menu, MenuItem *item) @@ -392,8 +470,11 @@ void ContextMenu::createControlPanelItem(QMenu *menu, MenuItem *item) actionControlPanel = addGeneralAction( menu, QIcon(QPixmap(":/icons/control_panel.png")), menuName.isEmpty() ? MENU_ECP_ITEM_TEXT : menuName, - SLOT(slotControlPanel()), - getShortcutKeySeq(menuName)); + item->getShortcutMap().isEmpty()? NULL : + new QShortcut(item->getShortcutMap().begin().value(), parent), + SLOT(slotControlPanel())); + + item->setAction(actionControlPanel); } void ContextMenu::createScreenShotItem(QMenu *menu, MenuItem *item) @@ -406,8 +487,11 @@ void ContextMenu::createScreenShotItem(QMenu *menu, MenuItem *item) actionScreenShot = addGeneralAction( menu, QIcon(QPixmap(":/icons/screen_shot.png")), menuName.isEmpty() ? MENU_SCREENSHOT_ITEM_TEXT : menuName, - SLOT(slotRequestScreenshot()), - getShortcutKeySeq(menuName)); + item->getShortcutMap().isEmpty()? NULL : + new QShortcut(item->getShortcutMap().begin().value(), parent), + SLOT(slotRequestScreenshot())); + + item->setAction(actionScreenShot); } void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item) @@ -417,9 +501,14 @@ void ContextMenu::createAboutItem(QMenu *menu, MenuItem *item) } QString menuName = item->getName(); - actionAbout = addGeneralAction(menu, QIcon(QPixmap(":/icons/about.png")), - menuName.isEmpty() ? MENU_ABOUT_ITEM_TEXT : menuName, SLOT(slotAbout()), - getShortcutKeySeq(menuName)); + actionAbout = addGeneralAction( + menu, QIcon(QPixmap(":/icons/about.png")), + menuName.isEmpty() ? MENU_ABOUT_ITEM_TEXT : menuName, + item->getShortcutMap().isEmpty()? NULL : + new QShortcut(item->getShortcutMap().begin().value(), parent), + SLOT(slotAbout())); + + item->setAction(actionAbout); } void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item) @@ -432,8 +521,11 @@ void ContextMenu::createForceCloseItem(QMenu *menu, MenuItem *item) actionForceClose = addGeneralAction( menu, QIcon(QPixmap(":/icons/force_close.png")), menuName.isEmpty() ? MENU_FORCECLOSE_ITEM_TEXT : menuName, - SLOT(slotForceClose()), - getShortcutKeySeq(menuName)); + item->getShortcutMap().isEmpty()? NULL : + new QShortcut(item->getShortcutMap().begin().value(), parent), + SLOT(slotForceClose())); + + item->setAction(actionForceClose); } void ContextMenu::createCloseItem(QMenu *menu, MenuItem *item) @@ -443,19 +535,28 @@ void ContextMenu::createCloseItem(QMenu *menu, MenuItem *item) } QString menuName = item->getName(); - actionClose = addGeneralAction(menu, QIcon(QPixmap(":/icons/close.png")), - menuName.isEmpty() ? MENU_CLOSE_ITEM_TEXT : menuName, SLOT(slotClose()), - getShortcutKeySeq(menuName)); + actionClose = addGeneralAction( + menu, QIcon(QPixmap(":/icons/close.png")), + menuName.isEmpty() ? MENU_CLOSE_ITEM_TEXT : menuName, + item->getShortcutMap().isEmpty()? NULL : + new QShortcut(item->getShortcutMap().begin().value(), parent), + SLOT(slotClose())); + + item->setAction(actionClose); } QAction *ContextMenu::addGeneralAction(QMenu *menu, - const QIcon &icon, const QString &text, const char *slot, const QString &shortcut) + const QIcon &icon, const QString &text, QShortcut *shortcut, const char *slot) { QAction *action = menu->addAction(text); action->setIcon(icon); - action->setShortcut(shortcut); connect(action, SIGNAL(triggered()), this, slot); + if (shortcut != NULL) { + connect(shortcut, SIGNAL(activated()), this, slot); + action->setShortcut(shortcut->key()); + } + return action; } @@ -523,6 +624,14 @@ void ContextMenu::slotTopMost(bool on) parent->getUIState()->setOnTop(on); } +void ContextMenu::slotTopMostShortcut() +{ + /* toggle */ + slotTopMost(!actionTopMost->isChecked()); + + qDebug() << "shortcut:" << actionTopMost->text() << actionTopMost->isChecked(); +} + void ContextMenu::slotSwitch(int index) { qDebug("switch : %d", index); @@ -544,6 +653,58 @@ void ContextMenu::slotSwitch(int index) keyboardShortcut->setKeyboardShortcutHwKey(); } +void ContextMenu::slotSwitchShortcutPrev() +{ + QList<QAction *> switchActions = switchGroup->actions(); + if (switchActions.count() < 2) { + return; + } + + int index = 0; + + QAction *action = switchGroup->checkedAction(); + if (action != NULL) { + index = switchActions.indexOf(action); + if (index == 0) { + index = switchActions.count() - 1; + } else { + index--; + } + } + + QAction *prevAction = switchActions.at(index); + prevAction->setChecked(true); + prevAction->trigger(); + + qDebug() << "shortcut: prev" << switchMenu->title() << prevAction->text(); +} + +void ContextMenu::slotSwitchShortcutNext() +{ + QList<QAction *> switchActions = switchGroup->actions(); + if (switchActions.count() < 2) { + return; + } + + int index = 0; + + QAction *action = switchGroup->checkedAction(); + if (action != NULL) { + index = switchActions.indexOf(action); + if (index == switchActions.count() - 1) { + index = 0; + } else { + index++; + } + } + + QAction *nextAction = switchActions.at(index); + nextAction->setChecked(true); + nextAction->trigger(); + + qDebug() << "shortcut: next" << switchMenu->title() << nextAction->text(); +} + void ContextMenu::slotScale(int scale) { qDebug("scale : %d", scale); @@ -560,20 +721,134 @@ void ContextMenu::slotScale(int scale) } } +void ContextMenu::slotScaleShortcutPrev() +{ + QList<QAction *> scaleActions = scaleGroup->actions(); + if (scaleActions.count() < 2) { + return; + } + + int index = 0; + + QAction *action = scaleGroup->checkedAction(); + if (action != NULL) { + index = scaleActions.indexOf(action); + if (index == 0) { + index = scaleActions.count() - 1; + } else { + index--; + } + } + + QAction *prevAction = scaleActions.at(index); + prevAction->setChecked(true); + prevAction->trigger(); + + qDebug() << "shortcut: prev" << scaleMenu->title() << prevAction->text(); +} + +void ContextMenu::slotScaleShortcutNext() +{ + QList<QAction *> scaleActions = scaleGroup->actions(); + if (scaleActions.count() < 2) { + return; + } + + int index = 0; + + QAction *action = scaleGroup->checkedAction(); + if (action != NULL) { + index = scaleActions.indexOf(action); + if (index == scaleActions.count() - 1) { + index = 0; + } else { + index++; + } + } + + QAction *nextAction = scaleActions.at(index); + nextAction->setChecked(true); + nextAction->trigger(); + + qDebug() << "shortcut: next" << scaleMenu->title() << nextAction->text(); +} + void ContextMenu::slotController(int index) { - qDebug("controller : %d", index); + qDebug("controller: %d", index); parent->openController(index, parent->getUIState()->conState.recentlyDockPos); + + if (infoDialog != NULL && infoDialog->isVisible() == true) { + /* update controller shortcut info */ + infoDialog->updateShortcutTableItems(); + } } void ContextMenu::slotCloseCon() { - qDebug("controller : None"); + qDebug("controller: None"); parent->closeController(); parent->getUIState()->conState.conFormIndex = -1; + + if (infoDialog != NULL && infoDialog->isVisible() == true) { + /* update controller shortcut info */ + infoDialog->updateShortcutTableItems(); + } +} + +void ContextMenu::slotConShortcutPrev() +{ + QList<QAction *> conActions = controllerGroup->actions(); + if (conActions.count() < 2) { + return; + } + + int index = 0; + + QAction *action = controllerGroup->checkedAction(); + if (action != NULL) { + index = conActions.indexOf(action); + if (index == 0) { + index = conActions.count() - 1; + } else { + index--; + } + } + + QAction *prevAction = conActions.at(index); + prevAction->setChecked(true); + prevAction->trigger(); + + qDebug() << "shortcut: prev" << controllerMenu->title() << prevAction->text(); +} + +void ContextMenu::slotConShortcutNext() +{ + QList<QAction *> conActions = controllerGroup->actions(); + if (conActions.count() < 2) { + return; + } + + int index = 0; + + QAction *action = controllerGroup->checkedAction(); + if (action != NULL) { + index = conActions.indexOf(action); + if (index == conActions.count() - 1) { + index = 0; + } else { + index++; + } + } + + QAction *nextAction = conActions.at(index); + nextAction->setChecked(true); + nextAction->trigger(); + + qDebug() << "shortcut: next" << controllerMenu->title() << nextAction->text(); } void ContextMenu::slotShell() @@ -602,16 +877,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 +887,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 +1016,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; } } @@ -792,11 +1064,6 @@ QSignalMapper *ContextMenu::getControllerMapper() return controllerMapper; } -QAction *ContextMenu::getActionTopMost() -{ - return actionTopMost; -} - QMessageBox *ContextMenu::showMsgBox( QMessageBox::Icon iconType, const QString &text, QMessageBox::StandardButtons buttons, @@ -823,6 +1090,11 @@ ContextMenu::~ContextMenu() { qDebug("destroy menu"); + if (infoDialog) { + delete infoDialog; + infoDialog = NULL; + } + delete shellOpener; longPressTimer->stop(); diff --git a/tizen/src/ui/menu/contextmenu.h b/tizen/src/ui/menu/contextmenu.h index 57fa534b2f..1d9d3dfa74 100644 --- a/tizen/src/ui/menu/contextmenu.h +++ b/tizen/src/ui/menu/contextmenu.h @@ -62,12 +62,11 @@ public: QSignalMapper *getScaleMapper(); QSignalMapper *getControllerMapper(); + QActionGroup *switchGroup; QActionGroup *scaleGroup; QActionGroup *keyboardGroup; QActionGroup *controllerGroup; - QActionGroup *switchGroup; - QAction *getActionTopMost(); ScreenShotDialog *screenshotDialog; signals: @@ -75,16 +74,28 @@ signals: public slots: void slotDetailedInfo(); void slotTopMost(bool on); + void slotTopMostShortcut(); + void slotSwitch(int index); + void slotSwitchShortcutPrev(); + void slotSwitchShortcutNext(); + void slotScale(int scale); + void slotScaleShortcutPrev(); + void slotScaleShortcutNext(); + void slotController(int index); void slotCloseCon(); + void slotConShortcutPrev(); + void slotConShortcutNext(); + void slotShell(); void slotControlPanel(); void slotRequestScreenshot(); void slotShowScreenshot(const QPixmap &); void slotHostKeyboard(bool on); void slotAbout(); + void slotForceClose(); void slotForceCloseSelected(QAbstractButton *); void slotClose(); @@ -108,12 +119,10 @@ protected: void createForceCloseItem(QMenu *menu, MenuItem *item); void createCloseItem(QMenu *menu, MenuItem *item); bool eventFilter(QObject *obj, QEvent *event); - QString getShortcutKeySeq(QString key); private: - QAction *addGeneralAction(QMenu *menu, - const QIcon &icon, const QString &text, const char *slot, - const QString &shortcut); + QAction *addGeneralAction(QMenu *menu, const QIcon &icon, + const QString &text, QShortcut *shortcut, const char *slot); QMessageBox *showMsgBox(QMessageBox::Icon iconType, const QString &text, QMessageBox::StandardButtons buttons = QMessageBox::NoButton, QMessageBox::StandardButton defaultButton = QMessageBox::NoButton); diff --git a/tizen/src/ui/menu/detailedinfodialog.cpp b/tizen/src/ui/menu/detailedinfodialog.cpp index 38d19cf956..5ded7ab252 100644 --- a/tizen/src/ui/menu/detailedinfodialog.cpp +++ b/tizen/src/ui/menu/detailedinfodialog.cpp @@ -30,172 +30,221 @@ #include "detailedinfodialog.h" #include "resource/ui_strings.h" #include "mainwindow.h" +#include "menu/advancedmenuitem.h" -extern int _qemu_argc; -extern char **_qemu_argv; +extern "C" { +int get_display_pixel_density(void); +} + +#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 480 DetailedInfoDialog::DetailedInfoDialog(QWidget *parent) : - QDialog(parent, Qt::Tool | Qt::WindowTitleHint | - Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint) + QDialog(parent) { - QStringList imagePathList = getImagePathList(); - MainWindow *win = ((MainWindow *)parent); + win = ((MainWindow *)parent); keyboardShortcut = win->getKeyboardShortcut(); setWindowTitle(DETAILED_INFO_TITLE); + setMinimumWidth(DIALOG_MIN_WIDTH); + setMinimumHeight(DIALOG_MIN_HEIGHT); baseLayout = new QVBoxLayout(this); baseLayout->setMargin(10); baseLayout->setSpacing(10); /* upside */ - upsideLayout = new QHBoxLayout(this); + upsideLayout = new QHBoxLayout(); upsideLayout->setMargin(0); upsideLayout->setSpacing(0); /* tab */ tabWidget = new QTabWidget(this); - QWidget *vmInfo = new QWidget; - QWidget *shortcutInfo = new QWidget; + + /* VM information table */ + QTableWidget *vmInfo = createVmInfoTable(); tabWidget->addTab(vmInfo, tr(DETAILED_INFO_VMTAB_TITLE)); + + /* shortcut info table */ + QTableWidget *shortcutInfo = createShortcutInfoTable(); tabWidget->addTab(shortcutInfo, tr(DETAILED_INFO_SHORTCUTTAB_TITLE)); - connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(slotSetMaximumSize(int))); + upsideLayout->addWidget(tabWidget); + + baseLayout->addLayout(upsideLayout); + + /* downside */ + downsideLayout = new QHBoxLayout(); + downsideLayout->setAlignment(Qt::AlignRight); + downsideLayout->setMargin(0); + + QPushButton *okBtn = new QPushButton("OK", this); + connect(okBtn, SIGNAL(clicked()), this, SLOT(close())); + downsideLayout->addWidget(okBtn); + + baseLayout->addLayout(downsideLayout); + + resize(DIALOG_DEF_WIDTH, DIALOG_DEF_HEIGHT); +} + +QTableWidget *DetailedInfoDialog::createVmInfoTable() +{ + vmInfoTable = new QTableWidget(); + + /* horizontal headers */ + QStringList headers; + headers << DETAILED_INFO_VMTAB_HEADER1 << DETAILED_INFO_VMTAB_HEADER2; + + vmInfoTable->setColumnCount(headers.count()); + vmInfoTable->setHorizontalHeaderLabels(headers); + vmInfoTable->horizontalHeader()->setStretchLastSection(true); + vmInfoTable->verticalHeader()->hide(); - /* VM information table */ - vmInfoTable = new QTableWidget(vmInfo); - vmInfoTable->setColumnCount(2); vmInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); vmInfoTable->setAlternatingRowColors(true); - vmInfoTable->verticalHeader()->hide(); - QStringList header; - header << DETAILED_INFO_VMTAB_HEADER1 << DETAILED_INFO_VMTAB_HEADER2; - vmInfoTable->setHorizontalHeaderLabels(header); + /* insert table items */ + insertTableRow(vmInfoTable, QString(DETAILED_INFO_VM_NAME), + win->uiInfo->vmName); - /* shortcut info table */ - shortcutInfoTable = new QTableWidget(shortcutInfo); - shortcutInfoTable->setColumnCount(2); - shortcutInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); - shortcutInfoTable->setAlternatingRowColors(true); - shortcutInfoTable->verticalHeader()->hide(); + insertTableRow(vmInfoTable, QString(DETAILED_INFO_SKIN_NAME), + win->uiInfo->skinName); - header.clear(); - header << DETAILED_INFO_SHORTCUTTAB_HEADER1 << DETAILED_INFO_SHORTCUTTAB_HEADER2; - shortcutInfoTable->setHorizontalHeaderLabels(header); - - /* table items */ - int index = 0; - setDataTable(vmInfoTable, DETAILED_INFO_VM_NAME, - win->uiInfo->vmName, index++); - setDataTable(vmInfoTable, DETAILED_INFO_SKIN_NAME, - win->uiInfo->skinName, index++); - setDataTable(vmInfoTable, DETAILED_INFO_CPU, "x86", index++); - setDataTable(vmInfoTable, DETAILED_INFO_RAM_SIZE, - QString(get_emul_ram_size()) + " MB", index++); - setDataTable(vmInfoTable, DETAILED_INFO_DPY_RESOLUTION, + insertTableRow(vmInfoTable, QString(DETAILED_INFO_CPU), "x86"); + + insertTableRow(vmInfoTable, QString(DETAILED_INFO_RAM_SIZE), + QString::number(get_ram_size() >> 20) + " MiB"); + + insertTableRow(vmInfoTable, QString(DETAILED_INFO_DPY_RESOLUTION), QString::number(win->uiInfo->resolution.width()) + "x" + - QString::number(win->uiInfo->resolution.height()), index++); -#if 0 - setDataTable(vmInfoTable, "Display Density", "0"/* TODO: */, index++); -#endif + QString::number(win->uiInfo->resolution.height())); + + insertTableRow(vmInfoTable, QString(DETAILED_INFO_DPY_DENSITY), + QString::number(get_display_pixel_density())); - QString sharingPath(get_emul_file_sharing_path()); - setDataTable(vmInfoTable, DETAILED_INFO_HDS_PATH, - (sharingPath.isEmpty()) ? "None" : sharingPath, index++); - setDataTable(vmInfoTable, DETAILED_INFO_CPU_VT, - (get_emul_cpu_accel()) ? "Enabled" : "Disabled", index++); - setDataTable(vmInfoTable, DETAILED_INFO_GPU_VT, - (is_gpu_accel_enabled()) ? "Enabled" : "Disabled", index++); + QString sharingPath(get_host_directory_sharing_path()); + insertTableRow(vmInfoTable, QString(DETAILED_INFO_HDS_PATH), + (sharingPath.isEmpty()) ? QString(GENERIC_TEXT_NONE) : sharingPath); - for (int i = 0; i < imagePathList.size(); i++) { - setDataTable(vmInfoTable, QString(DETAILED_INFO_IMAGE_PATH) + " " + - QString::number(i + 1), imagePathList[i], index++); + insertTableRow(vmInfoTable, QString(DETAILED_INFO_CPU_VT), + (get_emul_cpu_accel()) ? + QString(GENERIC_TEXT_ENABLED) : QString(GENERIC_TEXT_DISABLED)); - item->setToolTip(imagePathList[i]); + insertTableRow(vmInfoTable, QString(DETAILED_INFO_GPU_VT), + (is_gpu_accel_enabled()) ? + QString(GENERIC_TEXT_ENABLED) : QString(GENERIC_TEXT_DISABLED)); + + QString drive_image_file(get_drive_image_file()); + if (drive_image_file.isEmpty() == false) { + insertTableRow(vmInfoTable, QString(DETAILED_INFO_DRIVE_IMAGE_FILE), + drive_image_file, drive_image_file); } - setDataTable(vmInfoTable, DETAILED_INFO_LOG_PATH, get_log_path(), index++); - item->setToolTip(get_log_path()); - /* temp */ - setDataTable(vmInfoTable, DETAILED_INFO_TELNET_PORT, - QString::number(get_emul_serial_port()), index++); + QString swap_image_file(get_swap_image_file()); + if (swap_image_file.isEmpty() == false) { + insertTableRow(vmInfoTable, QString(DETAILED_INFO_SWAP_IMAGE_FILE), + swap_image_file, swap_image_file); + } - /* add double click event listener */ - connect(vmInfoTable, SIGNAL(cellDoubleClicked(int, int)), - this, SLOT(slotDoubleClicked(int, int))); + QString log_redirect_file(get_log_redirect_file()); + if (log_redirect_file.isEmpty() == false) { + insertTableRow(vmInfoTable, QString(DETAILED_INFO_EMUL_LOG_FILE), + log_redirect_file, log_redirect_file); + } - int tableHeight = vmInfoTable->horizontalHeader()->height(); - for (int i = 0; i < vmInfoTable->rowCount(); i++) { - tableHeight += vmInfoTable->rowHeight(i); + QString kernel_log_redirect_file(get_kernel_log_redirect_file()); + if (kernel_log_redirect_file.isEmpty() == false) { + insertTableRow(vmInfoTable, QString(DETAILED_INFO_KERNEL_LOG_FILE), + kernel_log_redirect_file, kernel_log_redirect_file); } - setMinimumWidth(DIALOG_MIN_WIDTH); - setMinimumHeight(DIALOG_MIN_HEIGHT); - slotSetMaximumSize(tabWidget->currentIndex()); +#if 0 + insertTableRow(vmInfoTable, DETAILED_INFO_TELNET_PORT, + QString::number(get_emul_serial_port()), index++); +#endif - upsideLayout->addWidget(tabWidget); + /* add double click event listener */ + connect(vmInfoTable, SIGNAL(cellDoubleClicked(int, int)), + this, SLOT(slotCellOpen(int, int))); - baseLayout->addLayout(upsideLayout); + return vmInfoTable; +} - /* downside */ - downsideLayout = new QHBoxLayout(this); - downsideLayout->setAlignment(Qt::AlignRight); - downsideLayout->setMargin(0); +QTableWidget *DetailedInfoDialog::createShortcutInfoTable() +{ + shortcutInfoTable = new QTableWidget(); - okBtn = new QPushButton("OK", this); - connect(okBtn, SIGNAL(clicked()), this, SLOT(close())); - downsideLayout->addWidget(okBtn); + /* horizontal headers */ + QStringList headers; + headers << DETAILED_INFO_SHORTCUTTAB_HEADER1 << DETAILED_INFO_SHORTCUTTAB_HEADER2; - baseLayout->addLayout(downsideLayout); + shortcutInfoTable->setColumnCount(headers.count()); + shortcutInfoTable->setHorizontalHeaderLabels(headers); + shortcutInfoTable->horizontalHeader()->setStretchLastSection(true); + shortcutInfoTable->verticalHeader()->hide(); - resize(DIALOG_DEF_WIDTH, DIALOG_DEF_HEIGHT); + shortcutInfoTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + shortcutInfoTable->setAlternatingRowColors(true); + + return shortcutInfoTable; } -void DetailedInfoDialog::slotSetMaximumSize(int tab) +void DetailedInfoDialog::updateShortcutTableItems() { - 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; - } + qDebug() << "clear" << shortcutInfoTable->rowCount() << "shortcut items"; + removeTableRows(shortcutInfoTable, 0, shortcutInfoTable->rowCount()); - table->resizeColumnsToContents(); - - /* width */ - tWidth = table->columnWidth(0) + table->columnWidth(1); - tWidth = (tWidth < DIALOG_DEF_WIDTH) ? DIALOG_DEF_WIDTH : tWidth; + /* insert menu shortcut info */ + insertMenuShortcutInfo(win->uiInfo->menuList); - setMaximumWidth(tWidth + TABLE_BORDER_SIZE + - TAB_BORDER_SIZE + - DIALOG_HORIZ_SPACE); + setShortcutInfoTable(keyboardShortcut->getHwKeyShortcutMap(), + keyboardShortcut->getHwKeyShortcutList()); + setShortcutInfoTable(keyboardShortcut->getControllerShortcutMap(), + keyboardShortcut->getControllerShortcutList()); - /* height */ - tHeight = table->horizontalHeader()->height(); - for (tRow = 0; tRow < table->rowCount(); tRow++) { - tHeight += table->rowHeight(tRow); - } + qDebug() << shortcutInfoTable->rowCount() << "shortcut items have been inserted"; +} - setMaximumHeight(tHeight + TABLE_BORDER_SIZE + - tabWidget->tabBar()->sizeHint().height() + - DIALOG_VERTIC_SPACE); +void DetailedInfoDialog::insertMenuShortcutInfo(QList<MenuItem *> list) +{ + for (int i = 0; i < list.count(); i++) { + MenuItem *item = list.at(i); + if (item != NULL) { + if (item->getType() == MenuItemType::separator) { + /* do nothing */ + } else if (item->getType() == MenuItemType::advancedItem) { + /* insert advanced menu shortcut info */ + AdvancedMenuItem *advItem = (AdvancedMenuItem *)item; + insertMenuShortcutInfo(advItem->getMenuList()); + } else if (item->getAction() != NULL && + item->getShortcutMap().isEmpty() == false) { + + QMap<QString, QKeySequence>::iterator iter = item->getShortcutMap().begin(); + for ( ; iter != item->getShortcutMap().end(); iter++) { + QString function = item->getAction()->iconText().isEmpty() ? + item->getAction()->text() : item->getAction()->iconText(); + function += " " + iter.key(); + + QString keySequence = iter.value().toString(); +#ifdef CONFIG_DARWIN + keySequence.replace("Ctrl", "Cmd"); +#endif - table->horizontalHeader()->setStretchLastSection(true); + insertTableRow(shortcutInfoTable, function, keySequence); + } + } + } + } } -void DetailedInfoDialog::setShortcutInfoTable(QMap<QString, QString> map, QList<QShortcut *> list) +void DetailedInfoDialog::setShortcutInfoTable( + const QMap<QString, QString>& map, const QList<QShortcut *>& list) { - int row = shortcutInfoTable->rowCount(); QMap<QString, QString>::const_iterator mapIter = map.constBegin(); for (int index = 0; index < list.count(); index++) { @@ -204,9 +253,9 @@ void DetailedInfoDialog::setShortcutInfoTable(QMap<QString, QString> map, QList< #ifdef CONFIG_DARWIN QString value = mapIter.value(); value.replace("Ctrl", "Cmd"); - setDataTable(shortcutInfoTable, mapIter.key(), value, row++); + insertTableRow(shortcutInfoTable, mapIter.key(), value); #else - setDataTable(shortcutInfoTable, mapIter.key(), mapIter.value(), row++); + insertTableRow(shortcutInfoTable, mapIter.key(), mapIter.value()); #endif break; } @@ -216,66 +265,97 @@ void DetailedInfoDialog::setShortcutInfoTable(QMap<QString, QString> map, QList< } } -void DetailedInfoDialog::setDataTable(QTableWidget* table, QString key, QString value, int index) +/* override */ +void DetailedInfoDialog::showEvent(QShowEvent *event) { - table->insertRow(index); - item = new QTableWidgetItem(key); - table->setItem(index, 0, item); - item = new QTableWidgetItem(value); - table->setItem(index, 1, item); + updateShortcutTableItems(); + + if ((windowState() & Qt::WindowMaximized) == 0) { + tabWidget->setCurrentIndex(0); + resizeTableToContents(vmInfoTable); + } + + move(win->geometry().center().x() - (geometry().size().width() / 2), + win->geometry().center().y() - (geometry().size().height() / 2)); + + QDialog::showEvent(event); } -void DetailedInfoDialog::resizeEvent(QResizeEvent* event) +/* override */ +void DetailedInfoDialog::resizeEvent(QResizeEvent *event) { - 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; + /* do nothing */ - vmInfoTable->resize(tWidth, tHeight); - shortcutInfoTable->resize(tWidth, tHeight); + QDialog::resizeEvent(event); } -void DetailedInfoDialog::removeDataTable(QTableWidget* table, int startIndex, int lastIndex) +void DetailedInfoDialog::resizeTableToContents(QTableWidget *table) { - for (int cnt = startIndex; cnt < lastIndex; cnt++) { - table->removeRow(startIndex); + /* width */ + int tWidth = qMin(table->columnWidth(0) + table->columnWidth(1), DIALOG_DEF_WIDTH); + tWidth += TABLE_BORDER_SIZE + TAB_BORDER_SIZE + DIALOG_HORIZ_SPACE; + + /* height */ + int tHeight = table->horizontalHeader()->height(); + for (int tRow = 0; tRow < table->rowCount(); tRow++) { + tHeight += table->rowHeight(tRow); } + tHeight += TABLE_BORDER_SIZE + + tabWidget->tabBar()->sizeHint().height() + DIALOG_VERTIC_SPACE; + + resize(tWidth, tHeight); + + shortcutInfoTable->resizeColumnsToContents(); + vmInfoTable->resizeColumnsToContents(); } -QStringList DetailedInfoDialog::getImagePathList() +void DetailedInfoDialog::insertTableRow(QTableWidget *table, + const QString& key, const QString& value, const QString& tooltip) { - QStringList imagePathList; - for (int i = 0; i <_qemu_argc; i++) { - if (QString(_qemu_argv[i]).compare("-drive") == 0) { - i += 1; - QStringList splitString = QString(_qemu_argv[i]).split(","); - QStringList splitString2 = splitString[0].split("="); - QString drivePath = splitString2[splitString2.length() -1]; - imagePathList << drivePath; - } + const int row = table->rowCount(); + table->insertRow(row); + table->setItem(row, 0, new QTableWidgetItem(key)); + QTableWidgetItem *item = new QTableWidgetItem(value); + table->setItem(row, 1, item); + + if (!tooltip.isNull() && !tooltip.isEmpty()) { + item->setToolTip(tooltip); } - qDebug() << imagePathList; - return imagePathList; } -void DetailedInfoDialog::slotDoubleClicked(int nRow, int nCol) +void DetailedInfoDialog::insertTableRow(QTableWidget *table, + const QString& key, const QString& value) { - QTableWidgetItem *item; - QString string; + insertTableRow(table, QString(key), QString(value), QString()); +} - /* Feature side double click event is occured, ignore it */ - if (nCol == 0) +void DetailedInfoDialog::removeTableRows( + QTableWidget *table, int startIndex, int lastIndex) +{ + for (int index = startIndex; index < lastIndex; index++) { + table->removeRow(startIndex); + } +} + +void DetailedInfoDialog::slotCellOpen(int nRow, int nCol) +{ + if (nCol <= 0 || nRow >= vmInfoTable->rowCount()) { return; + } - item = vmInfoTable->item(nRow, 0); - if (item->text().compare(DETAILED_INFO_HDS_PATH, Qt::CaseInsensitive) == 0 || - item->text().startsWith(DETAILED_INFO_IMAGE_PATH) == true || - item->text().compare(DETAILED_INFO_LOG_PATH, Qt::CaseInsensitive) == 0) { - /* get path name */ + QTableWidgetItem *item = vmInfoTable->item(nRow, 0); + qDebug() << item->text() << "item was double clicked"; + + if (item->text().compare(DETAILED_INFO_HDS_PATH) == 0 || + item->text().compare(DETAILED_INFO_EMUL_LOG_FILE) == 0 || + item->text().compare(DETAILED_INFO_KERNEL_LOG_FILE) == 0 || + item->text().compare(DETAILED_INFO_DRIVE_IMAGE_FILE) == 0 || + item->text().compare(DETAILED_INFO_SWAP_IMAGE_FILE) == 0) { + /* get path item */ item = vmInfoTable->item(nRow, nCol); - if (item->text().compare("None", Qt::CaseInsensitive) == 0 || - item->text().compare("", Qt::CaseInsensitive) == 0) { + + if (item->text().compare(GENERIC_TEXT_NONE) == 0 || + item->text().isEmpty() == true) { /* ignore this event */ return; } @@ -284,59 +364,38 @@ void DetailedInfoDialog::slotDoubleClicked(int nRow, int nCol) return; } - if (QFileInfo(item->text()).isDir() == true) { - /* path name is a directory name */ - QDesktopServices::openUrl(QUrl("file:///" + item->text(), QUrl::TolerantMode)); - } else if (QFileInfo(item->text()).isFile() == true) { - /* path name is a file name */ - QDesktopServices::openUrl(QUrl( - "file:///" + QFileInfo(item->text()).absolutePath(), QUrl::TolerantMode)); + QFileInfo pathInfo(item->text()); + if (pathInfo.isDir() == true) { + /* directory path */ + QDesktopServices::openUrl( + QUrl("file:///" + item->text(), QUrl::TolerantMode)); + } else if (pathInfo.isFile() == true) { + /* file path */ + QDesktopServices::openUrl( + QUrl("file:///" + pathInfo.absolutePath(), QUrl::TolerantMode)); } else { - qWarning("wrong path name"); + qWarning() << "invalid path info:" << item->text(); } - - return; -} - -void DetailedInfoDialog::showEvent(QShowEvent *event) -{ - Q_UNUSED(event) - - QWidget *win = parentWidget(); - move(win->geometry().center().x() - (geometry().size().width() / 2), - win->geometry().center().y() - (geometry().size().height() / 2)); - - /* insert shortcut info */ - removeDataTable(shortcutInfoTable, 0, shortcutInfoTable->rowCount()); - setShortcutInfoTable(keyboardShortcut->getPopupMenuShortcutMap(), - keyboardShortcut->getPopupMenuShortcutList()); - setShortcutInfoTable(keyboardShortcut->getHwKeyShortcutMap(), - keyboardShortcut->getHwKeyShortcutList()); - setShortcutInfoTable(keyboardShortcut->getControllerShortcutMap(), - keyboardShortcut->getControllerShortcutList()); - - vmInfoTable->horizontalHeader()->setStretchLastSection(true); - shortcutInfoTable->horizontalHeader()->setStretchLastSection(true); -} - -QTableWidget *DetailedInfoDialog::getShortcutInfoTable() -{ - return shortcutInfoTable; } DetailedInfoDialog::~DetailedInfoDialog() { qDebug("destroy detailed info dialog"); - for (int i = 0; i < vmInfoTable->rowCount(); i++) { - for (int j = 0; j < vmInfoTable->columnCount(); j++) { - delete vmInfoTable->item(i, j); - } + if (vmInfoTable) { + delete vmInfoTable; + vmInfoTable = NULL; } - - for (int i = 0; i < shortcutInfoTable->rowCount(); i++) { - for (int j = 0; j < shortcutInfoTable->columnCount(); j++) { - delete shortcutInfoTable->item(i, j); - } + if (upsideLayout) { + delete upsideLayout; + upsideLayout = NULL; + } + if (downsideLayout) { + delete downsideLayout; + downsideLayout = NULL; + } + if (baseLayout) { + delete baseLayout; + baseLayout = NULL; } } diff --git a/tizen/src/ui/menu/detailedinfodialog.h b/tizen/src/ui/menu/detailedinfodialog.h index 4efe368305..fb0946ec22 100644 --- a/tizen/src/ui/menu/detailedinfodialog.h +++ b/tizen/src/ui/menu/detailedinfodialog.h @@ -27,23 +27,15 @@ * */ -#ifndef DETAILEDINFODIALOG_H -#define DETAILEDINFODIALOG_H +#ifndef DETAILEDINFO_DIALOG_H +#define DETAILEDINFO_DIALOG_H #include <QtWidgets> #include <QDialog> +#include "menu/menuitem.h" #include "input/keyboardshortcut.h" -#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 { Q_OBJECT @@ -52,30 +44,38 @@ public: explicit DetailedInfoDialog(QWidget *parent = 0); ~DetailedInfoDialog(); - QTableWidget *getShortcutInfoTable(); - void setShortcutInfoTable(QMap<QString, QString> map, QList<QShortcut *> list); - void setDataTable(QTableWidget* table, QString key, QString value, int index); - void removeDataTable(QTableWidget* table, int startIndex, int lastIndex); + void updateShortcutTableItems(); + void insertMenuShortcutInfo(QList<MenuItem *> list); + + void setShortcutInfoTable(const QMap<QString, QString>& map, + const QList<QShortcut *>& list); + void insertTableRow(QTableWidget *table, const QString& key, + const QString& value, const QString& tooltip); + void insertTableRow(QTableWidget *table, const QString& key, + const QString& value); + void removeTableRows(QTableWidget *table, int startIndex, int lastIndex); + +public slots: + void slotCellOpen(int nRow, int nCol); protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); -public slots: - void slotDoubleClicked(int nRow, int nCol); - void slotSetMaximumSize(int tab); - private: - QStringList getImagePathList(); + QTableWidget *createVmInfoTable(); + QTableWidget *createShortcutInfoTable(); + void resizeTableToContents(QTableWidget *table); + + MainWindow *win; QVBoxLayout *baseLayout; QHBoxLayout *upsideLayout; - QTableWidget *vmInfoTable; - QTableWidget *shortcutInfoTable; - QTableWidgetItem *item; QHBoxLayout *downsideLayout; - QPushButton *okBtn; - KeyboardShortcut* keyboardShortcut; + QTabWidget *tabWidget; + QTableWidget *vmInfoTable; + QTableWidget *shortcutInfoTable; + KeyboardShortcut *keyboardShortcut; }; -#endif // DETAILEDINFODIALOG_H +#endif // DETAILEDINFO_DIALOG_H diff --git a/tizen/src/ui/menu/menuitem.cpp b/tizen/src/ui/menu/menuitem.cpp index b8090fa463..097d9de327 100644 --- a/tizen/src/ui/menu/menuitem.cpp +++ b/tizen/src/ui/menu/menuitem.cpp @@ -33,6 +33,7 @@ MenuItem::MenuItem(int type, QString name) { this->type = type; this->name = name; + this->action = NULL; } int MenuItem::getType() @@ -45,11 +46,21 @@ QString MenuItem::getName() return name; } -QMap<QString, QString> &MenuItem::getShortcutMap() +QMap<QString, QKeySequence> &MenuItem::getShortcutMap() { return shortcutMap; } +void MenuItem::setAction(QAction *action) +{ + this->action = action; +} + +QAction *MenuItem::getAction() +{ + return action; +} + MenuItem::~MenuItem() { /* do nothing */ diff --git a/tizen/src/ui/menu/menuitem.h b/tizen/src/ui/menu/menuitem.h index f4629b70f7..f5dcea1c4e 100644 --- a/tizen/src/ui/menu/menuitem.h +++ b/tizen/src/ui/menu/menuitem.h @@ -31,6 +31,7 @@ #define MENUITEM_H #include <QString> +#include <QShortcut> #include <QMap> namespace MenuItemType @@ -61,12 +62,15 @@ public: int getType(); QString getName(); - QMap<QString, QString> &getShortcutMap(); + QMap<QString, QKeySequence> &getShortcutMap(); + void setAction(QAction *action); + QAction *getAction(); private: int type; QString name; - QMap<QString, QString> shortcutMap; + QMap<QString, QKeySequence> shortcutMap; + QAction *action; }; #endif // MENUITEM_H diff --git a/tizen/src/ui/qt5.c b/tizen/src/ui/qt5.c index 7e8a714522..928c85e871 100644 --- a/tizen/src/ui/qt5.c +++ b/tizen/src/ui/qt5.c @@ -33,11 +33,12 @@ #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 { @@ -166,9 +166,16 @@ static void maru_qt5_display_fini(void) void set_display_pixel_density(int dpi) { + LOG_INFO("display density: %d\n", dpi); + pixel_density_dpi = dpi; } +int get_display_pixel_density(void) +{ + return pixel_density_dpi; +} + void maru_qt5_display_init(DisplayState *ds, int full_screen) { int i; diff --git a/tizen/src/ui/qt5.h b/tizen/src/ui/qt5.h index b1aac1c354..83ee83ac77 100644 --- a/tizen/src/ui/qt5.h +++ b/tizen/src/ui/qt5.h @@ -37,5 +37,6 @@ void maru_early_qt5_display_init(bool isOnscreen); void maru_qt5_display_init(DisplayState *ds, int full_screen); void set_display_pixel_density(int dpi); +int get_display_pixel_density(void); #endif // __QT5_H__ diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp index 3cd245084e..2d18fce990 100644 --- a/tizen/src/ui/qt5_supplement.cpp +++ b/tizen/src/ui/qt5_supplement.cpp @@ -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); @@ -301,8 +297,11 @@ void qt5_destroy() qt5App->processEvents(QEventLoop::ExcludeUserInputEvents); qt5App->quit(); - //TODO: fix me - //delete mainwindow; + if (mainwindow) { +// FIXME: It causes SIGSEGV now... +// delete mainwindow; + mainwindow = NULL; + } if (uiInfo) { delete uiInfo; diff --git a/tizen/src/ui/resource/ui_strings.h b/tizen/src/ui/resource/ui_strings.h index c1e1f85d2c..a2d2ddb8e6 100644 --- a/tizen/src/ui/resource/ui_strings.h +++ b/tizen/src/ui/resource/ui_strings.h @@ -32,17 +32,35 @@ #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" @@ -73,11 +91,14 @@ #define DETAILED_INFO_CPU "CPU" #define DETAILED_INFO_RAM_SIZE "Ram Size" #define DETAILED_INFO_DPY_RESOLUTION "Display Resolution" +#define DETAILED_INFO_DPY_DENSITY "Display Density" #define DETAILED_INFO_HDS_PATH "File Sharing Path" #define DETAILED_INFO_CPU_VT "CPU Virtualization" #define DETAILED_INFO_GPU_VT "GPU Virtualization" -#define DETAILED_INFO_IMAGE_PATH "Image Path" -#define DETAILED_INFO_LOG_PATH "Log Path" +#define DETAILED_INFO_DRIVE_IMAGE_FILE "Target Image File" +#define DETAILED_INFO_SWAP_IMAGE_FILE "Swap Image File" +#define DETAILED_INFO_EMUL_LOG_FILE "Emulator Log File" +#define DETAILED_INFO_KERNEL_LOG_FILE "Kernel Log File" #define DETAILED_INFO_TELNET_PORT "Logging Telnet Port" /* screen shot dialog */ diff --git a/tizen/src/ui/xmllayoutparser.cpp b/tizen/src/ui/xmllayoutparser.cpp index 82ed1dfb9b..c884cbcb66 100644 --- a/tizen/src/ui/xmllayoutparser.cpp +++ b/tizen/src/ui/xmllayoutparser.cpp @@ -357,10 +357,10 @@ int XmlLayoutParser::parseFactorList( } int XmlLayoutParser::parseShortcut( - QXmlStreamReader &xml, QMap<QString, QString> &map) + QXmlStreamReader &xml, QMap<QString, QKeySequence> &map) { QString key = xml.attributes().value(PROP_ATTR_KEYWORD).toString(); - map.insert(key, xml.readElementText()); + map.insert(key, QKeySequence::fromString(xml.readElementText())); return map.count(); } diff --git a/tizen/src/ui/xmllayoutparser.h b/tizen/src/ui/xmllayoutparser.h index 6e01a0231f..bf7cd1cbef 100644 --- a/tizen/src/ui/xmllayoutparser.h +++ b/tizen/src/ui/xmllayoutparser.h @@ -61,7 +61,7 @@ private: int parseMainFormList(QXmlStreamReader &xml, QList<MainForm *> &list); int parseFactorList(QXmlStreamReader &xml, QMap<int, QString> &map, int *defaultFactor); - int parseShortcut(QXmlStreamReader &xml, QMap<QString, QString> &map); + int parseShortcut(QXmlStreamReader &xml, QMap<QString, QKeySequence> &map); AdvancedMenuItem *parseAdvancedMenuItem(QXmlStreamReader &xml); ScaleMenuItem *parseScaleMenuItem(QXmlStreamReader &xml); MenuItem *parseGeneralMenuItem(QXmlStreamReader &xml, int menuType); diff --git a/tizen/src/util/error_handler.c b/tizen/src/util/error_handler.c index 3883972241..eeed7c13b6 100644 --- a/tizen/src/util/error_handler.c +++ b/tizen/src/util/error_handler.c @@ -61,6 +61,8 @@ static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter; static pthread_spinlock_t siglock; #endif +bool print_backtrace_at_normal_exit_enabled = false; + /* Print 'backtrace' */ #ifdef _WIN32 struct frame_layout { @@ -176,10 +178,15 @@ static void dump_backtrace(void *ptr, int depth) static void handle_error_at_exit(void) { - // dump backtrace log no matter what - INFO("Stack backtrace for tracing...\n"); - INFO("This is not an error.\n"); - dump_backtrace(NULL, 0); + if (print_backtrace_at_normal_exit_enabled) { + INFO("Stack backtrace for tracing...\n"); + INFO("This is not an error.\n"); + dump_backtrace(NULL, 0); + } +} + +void enable_print_backtrace_at_normal_exit(void) { + print_backtrace_at_normal_exit_enabled = true; } #ifdef CONFIG_WIN32 diff --git a/tizen/src/util/error_handler.h b/tizen/src/util/error_handler.h index f45b05f320..783dd00dc3 100644 --- a/tizen/src/util/error_handler.h +++ b/tizen/src/util/error_handler.h @@ -32,5 +32,6 @@ #define __ERROR_HANDLER_H__ void init_error_handler(void); +void enable_print_backtrace_at_normal_exit(void); #endif /* __ERROR_HANDLER_H__ */ diff --git a/tizen/src/util/osutil-darwin.c b/tizen/src/util/osutil-darwin.c index 4fc31e28e0..b6fcef1011 100644 --- a/tizen/src/util/osutil-darwin.c +++ b/tizen/src/util/osutil-darwin.c @@ -99,7 +99,7 @@ void remove_vm_lock_os(void) void set_bin_path_os(char const *const exec_argv) { char *file_name = NULL; - char bin_path[PATH_MAX] = { 0, }; + char bin_path_os[PATH_MAX] = { 0, }; if (!exec_argv) { return; @@ -117,12 +117,12 @@ void set_bin_path_os(char const *const exec_argv) return; } - g_strlcpy(bin_path, data, strlen(data) - strlen(file_name) + 1); - g_strlcat(bin_path, "/", PATH_MAX); - - set_variable(KEYWORD_BIN_PATH, bin_path, true); + g_strlcpy(bin_path_os, data, strlen(data) - strlen(file_name) + 1); + g_strlcat(bin_path_os, "/", PATH_MAX); free(data); + + bin_path = g_strdup(bin_path_os); } int get_number_of_processors(void) diff --git a/tizen/src/util/osutil-linux.c b/tizen/src/util/osutil-linux.c index 9f0ac30787..e02968a124 100644 --- a/tizen/src/util/osutil-linux.c +++ b/tizen/src/util/osutil-linux.c @@ -144,7 +144,7 @@ void remove_vm_lock_os(void) void set_bin_path_os(char const *const exec_argv) { char link_path[PATH_MAX] = { 0, }; - char bin_path[PATH_MAX] = { 0, }; + char bin_path_os[PATH_MAX] = { 0, }; char *file_name = NULL; ssize_t len = readlink("/proc/self/exe", link_path, sizeof(link_path) - 1); @@ -157,11 +157,11 @@ void set_bin_path_os(char const *const exec_argv) link_path[len] = '\0'; file_name = g_strrstr(link_path, "/"); - g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1); + g_strlcpy(bin_path_os, link_path, strlen(link_path) - strlen(file_name) + 1); - g_strlcat(bin_path, "/", PATH_MAX); + g_strlcat(bin_path_os, "/", PATH_MAX); - set_variable(KEYWORD_BIN_PATH, bin_path, true); + bin_path = g_strdup(bin_path_os); } int get_number_of_processors(void) diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index d01e658e86..f826ae08c2 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -144,7 +144,7 @@ void remove_vm_lock_os(void) void set_bin_path_os(char const *const exec_argv) { char link_path[PATH_MAX] = { 0, }; - char bin_path[PATH_MAX] = { 0, }; + char bin_path_os[PATH_MAX] = { 0, }; char *file_name = NULL; if (!GetModuleFileName(NULL, link_path, PATH_MAX)) { @@ -152,10 +152,10 @@ void set_bin_path_os(char const *const exec_argv) } file_name = g_strrstr(link_path, "\\"); - g_strlcpy(bin_path, link_path, strlen(link_path) - strlen(file_name) + 1); - g_strlcat(bin_path, "\\", PATH_MAX); + g_strlcpy(bin_path_os, link_path, strlen(link_path) - strlen(file_name) + 1); + g_strlcat(bin_path_os, "\\", PATH_MAX); - set_variable(KEYWORD_BIN_PATH, bin_path, true); + bin_path = g_strdup(bin_path_os); } int get_number_of_processors(void) @@ -175,6 +175,9 @@ int get_number_of_processors(void) return num_processors; } +// FIXME +OSVERSIONINFO osvi; + void print_system_info_os(void) { INFO("* Windows\n"); @@ -182,7 +185,6 @@ void print_system_info_os(void) INFO("* LibPNG Version : %s\n", PNG_LIBPNG_VER_STRING); /* Retrieves information about the current os */ - OSVERSIONINFO osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); diff --git a/tizen/src/util/ui_operations.c b/tizen/src/util/ui_operations.c index c255481bb3..8964d6482a 100644 --- a/tizen/src/util/ui_operations.c +++ b/tizen/src/util/ui_operations.c @@ -139,7 +139,7 @@ void do_mouse_event(int button_type, int event_type, break; case MOUSE_WHEELUP: case MOUSE_WHEELDOWN: - if (is_emul_input_touch_enable() == true) { + if (is_touchscreen_enabled() == true) { x -= guest_x; y -= guest_y; guest_x += x; diff --git a/ui/input.c b/ui/input.c index 5aa9bb0ce0..fbf5bd3b7f 100644 --- a/ui/input.c +++ b/ui/input.c @@ -7,6 +7,7 @@ #include "ui/console.h" #if defined CONFIG_MARU && defined CONFIG_SPICE && defined CONFIG_LINUX +# ifdef CONFIG_JAVA_UI #include <pthread.h> extern void maru_hwkey_event(int event_type, int keycode); @@ -15,6 +16,7 @@ extern void do_host_kbd_enable(bool on); extern void qemu_system_graceful_shutdown_request(unsigned int sec); extern void request_close(void); void* tizen_close_thread(void* data); +# endif #endif //#include "tizen/src/debug_ch.h" @@ -514,6 +516,7 @@ void qemu_remove_mouse_mode_change_notifier(Notifier *notify) } #if defined CONFIG_MARU && defined CONFIG_SPICE && defined CONFIG_LINUX +# ifdef CONFIG_JAVA_UI void hwkey_put_keycode(int type, int keycode) { if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { @@ -566,6 +569,7 @@ void tizen_close_put_type(int type) printf("created tizen_close thread\n"); } } +# endif #endif MouseInfoList *qmp_query_mice(Error **errp) diff --git a/ui/spice-input.c b/ui/spice-input.c index cd0cde2400..42b5690e22 100644 --- a/ui/spice-input.c +++ b/ui/spice-input.c @@ -98,6 +98,7 @@ static void kbd_leds(void *opaque, int ledstate) } #ifdef CONFIG_MARU +# ifdef CONFIG_JAVA_UI /* hwkey bits */ typedef struct QemuSpiceHwkey { @@ -199,6 +200,7 @@ static void qemu_get_sdb_port(SpiceSdbPortInstance *sin, int* sdb_port) printf("%d\n", get_emul_vm_base_port()); *sdb_port = get_emul_vm_base_port(); } +# endif #endif /* mouse bits */ @@ -136,6 +136,7 @@ int qemu_main(int argc, char **argv, char **envp); #include "tizen/src/ui/qt5.h" #include "tizen/src/util/ui_operations.h" #include "tizen/src/ecs/ecs.h" +#include "tizen/src/util/error_handler.h" # ifdef CONFIG_JAVA_UI #include "tizen/src/display/maru_display.h" # endif @@ -2202,7 +2203,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 +2212,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); @@ -3304,10 +3305,6 @@ int main(int argc, char **argv, char **envp) "'%s' option", slots_str ? "maxmem" : "slots"); exit(EXIT_FAILURE); } - -#ifdef CONFIG_MARU - set_emul_ram_size(optarg); -#endif break; } #ifdef CONFIG_TPM @@ -3489,22 +3486,13 @@ int main(int argc, char **argv, char **envp) qemu_opt_set_bool(fsdev, "readonly", qemu_opt_get_bool(opts, "readonly", 0)); -#ifdef CONFIG_MARU - device = qemu_opts_create(qemu_find_opts("device"), "fileshare", 0, - &error_abort); -#else device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); -#endif qemu_opt_set(device, "driver", "virtio-9p-pci"); qemu_opt_set(device, "fsdev", qemu_opt_get(opts, "mount_tag")); qemu_opt_set(device, "mount_tag", qemu_opt_get(opts, "mount_tag")); - -#ifdef CONFIG_MARU - set_emul_file_sharing_path(qemu_opt_get(opts, "path")); -#endif break; } case QEMU_OPTION_virtfs_synth: { @@ -4636,6 +4624,9 @@ int main(int argc, char **argv, char **envp) } } +#ifdef CONFIG_MARU + enable_print_backtrace_at_normal_exit(); +#endif main_loop(); bdrv_close_all(); pause_all_vcpus(); |