OSDN Git Service

[UI][Qt][BUG] Add paste text from clip board.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 17 Nov 2015 09:36:47 +0000 (18:36 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 17 Nov 2015 09:36:47 +0000 (18:36 +0900)
source/build-cmake/cmake/config_commonsource.cmake
source/src/emu.h
source/src/qt/common/emu_input.cpp
source/src/qt/common/emuevents_control.cpp
source/src/qt/gui/menu_control.cpp
source/src/qt/gui/menu_main.cpp

index 68bc58c..7b45cca 100644 (file)
@@ -50,22 +50,6 @@ add_definitions(-DQT_MAJOR_VERSION=${Qt5Widgets_VERSION_MAJOR})
 add_definitions(-DQT_MINOR_VERSION=${Qt5Widgets_VERSION_MINOR})
 # Build Flags
 
-#find_package(Gettext)
-#include_directories(${GETTEXT_INCLUDE_PATH})
-#include(compile_gettext_catalogue)
-#if(GETTEXT_FOUND)
-#   add_definitions(-DUSE_GETTEXT)
-#endif()
-
-
-#find_package(Freetype)
-#include_directories(${FREETYPE_INCLUDE_PATH})
-
-#find_package(Iconv)
-#if(ICONV_FOUND)
-#  add_definitions(-DUSE_ICONV)
-#endif()
-
 if(USE_OPENMP)
   find_package(OpenMP)
   include_directories(${OPENMP_INCLUDE_PATH})
@@ -139,9 +123,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/vm)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/common)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src/qt/gui)
 
-#add_subdirectory(../../src/agar/common/scaler/generic agar/common/scaler/generic)
 add_subdirectory(../../src/qt/gui qt/gui)
-
 add_subdirectory(../../src common)
 add_subdirectory(../../src/vm vm/)
 
@@ -162,14 +144,6 @@ set(BUNDLE_LIBS
 )
 if(USE_QT_5)
   set(BUNDLE_LIBS ${BUNDLE_LIBS} ${QT_LIBRARIES})
-#  FIND_PACKAGE(qtermwidget5)
-#  if(QTERMWIDGET_FOUND)
-#    #include(${QTERMWIDGET_USE_FILE})
-#    include_directories(${QTERMWIDGET_INCLUDE_DIRS})
-#    add_definitions(-DUSE_QTERMWIDGET)
-#    set(BUNDLE_LIBS ${BUNDLE_LIBS} ${QTERMWIDGET_LIBRARIES} ncurses)
-#    set(LOCAL_LIBS ${LOCAL_LIBS} libqtermwidget5.a)
-#  endif()
 endif()
 
 set(BUNDLE_LIBS ${BUNDLE_LIBS} ${THREADS_LIBRARY})
index 09fc6f3..5ba237e 100644 (file)
@@ -273,7 +273,7 @@ private:
        void initialize_input();
        void release_input();
        void update_input();
-       void key_down_sub(int code, bool repeat);
+       void key_down_sub(int code, bool flag = false);
        void key_up_sub(int code);
        
 #if !defined(_USE_QT)
@@ -311,7 +311,6 @@ private:
 #ifdef USE_AUTO_KEY
        FIFO* autokey_buffer;
        int autokey_phase, autokey_shift;
-       int autokey_table[256];
        char auto_key_str[65536];
 #endif
        
index b822f7e..6c3404f 100644 (file)
@@ -262,31 +262,25 @@ void EMU::update_input()
                if(autokey_buffer && !autokey_buffer->empty()) {
                        // update shift key status
                        int shift = autokey_buffer->read_not_remove(0) & 0x100;
-# ifdef NOTIFY_KEY_DOWN
                        if(shift && !autokey_shift) {
                                key_down(VK_SHIFT, false);
                        } else if(!shift && autokey_shift) {
                                key_up(VK_SHIFT);
                        }
-# endif                   
                        autokey_shift = shift;
                        autokey_phase++;
                        break;
                }
        case 3:
-# ifdef NOTIFY_KEY_DOWN
                if(autokey_buffer && !autokey_buffer->empty()) {
                        key_down(autokey_buffer->read_not_remove(0) & 0xff, false);
                }
-# endif           
                autokey_phase++;
                break;
        case USE_AUTO_KEY:
-# ifdef NOTIFY_KEY_DOWN
                if(autokey_buffer && !autokey_buffer->empty()) {
                        key_up(autokey_buffer->read_not_remove(0) & 0xff);
                }
-# endif           
                autokey_phase++;
                break;
        case USE_AUTO_KEY_RELEASE:
@@ -313,7 +307,6 @@ void EMU::update_input()
 }
 
 
-
 #ifdef USE_SHIFT_NUMPAD_KEY
 static const int numpad_table[256] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00,
@@ -581,7 +574,6 @@ void EMU::set_auto_key_string(const char *cstr)
        stop_auto_key();
        memset(auto_key_str, 0x00, sizeof(auto_key_str));
        strncpy(auto_key_str, cstr, sizeof(auto_key_str) - 2);
-       //AGAR_DebugLog(AGAR_LOG_DEBUG, "AutoKey: SET :%s\n", auto_key_str);
 }
        
 void EMU::start_auto_key()
@@ -592,7 +584,6 @@ void EMU::start_auto_key()
                        char* buf = (char*)auto_key_str;
                        int size = strlen(buf), prev_kana = 0;
                        AGAR_DebugLog(AGAR_LOG_DEBUG, "AutoKey: SET :%s\n", buf);
-
                        for(int i = 0; i < size; i++) {
                                int code = buf[i] & 0xff;
                                if((0x81 <= code && code <= 0x9f) || 0xe0 <= code) {
@@ -601,6 +592,7 @@ void EMU::start_auto_key()
                                } else if(code == 0xa) {
                                        continue;       // cr-lf
                                }
+
                                if((code = autokey_table[code]) != 0) {
                                        int kana = code & 0x200;
                                        if(prev_kana != kana) {
index 3180d04..ff31622 100644 (file)
@@ -46,13 +46,15 @@ void Ui_MainWindow::OnCpuPower(int mode)
 }
 
 #ifdef USE_AUTO_KEY
+#include <QClipboard>
 void Ui_MainWindow::OnStartAutoKey(void)
 {
        QString ctext;
-       ctext = ClipBoard->text();
+       QClipboard *clipBoard = QApplication::clipboard();
+       ctext = clipBoard->text();
        emit sig_start_auto_key(ctext);
-       ClipBoard->clear();
 }
+
 void Ui_MainWindow::OnStopAutoKey(void)
 {
        emit sig_stop_auto_key();
index c155935..6be70f1 100644 (file)
@@ -170,17 +170,16 @@ void Ui_MainWindow::ConfigControlMenu(void)
        actionExit_Emulator->setObjectName(QString::fromUtf8("actionExit_Emulator"));
        //connect(actionExit_Emulator, SIGNAL(triggered()),
        //      this, SLOT(on_actionExit_triggered())); // OnGuiExit()?  
-
+#if defined(USE_AUTO_KEY)
        actionPaste_from_Clipboard = new Action_Control(this);
        actionPaste_from_Clipboard->setObjectName(QString::fromUtf8("actionPaste_from_Clipboard"));
        connect(actionPaste_from_Clipboard, SIGNAL(triggered()),
                        this, SLOT(OnStartAutoKey())); // OK?  
-
        actionStop_Pasting = new Action_Control(this);
        actionStop_Pasting->setObjectName(QString::fromUtf8("actionStop_Pasting"));
        connect(actionStop_Pasting, SIGNAL(triggered()),
                        this, SLOT(OnStopAutoKey())); // OK?  
-  
+#endif  
 #ifdef USE_STATE
        actionSave_State = new Action_Control(this);
        actionSave_State->setObjectName(QString::fromUtf8("actionSave_State"));
@@ -243,8 +242,10 @@ void Ui_MainWindow::connectActions_ControlMenu(void)
        //        menuControl->addSeparator();
 #endif   
        menuControl->addAction(menuCpu_Speed->menuAction());
+#ifdef USE_AUTO_KEY
        menuControl->addSeparator();
        menuControl->addAction(menuCopy_Paste->menuAction());
+#endif 
        menuControl->addSeparator();
        menuControl->addAction(menuState->menuAction());
 #ifdef USE_DEBUGGER
@@ -257,8 +258,10 @@ void Ui_MainWindow::connectActions_ControlMenu(void)
        menuState->addSeparator();
        menuState->addAction(actionLoad_State);
 #endif
+#ifdef USE_AUTO_KEY
        menuCopy_Paste->addAction(actionPaste_from_Clipboard);
        menuCopy_Paste->addAction(actionStop_Pasting);
+#endif 
        menuCpu_Speed->addAction(actionSpeed_x1);
        menuCpu_Speed->addAction(actionSpeed_x2);
        menuCpu_Speed->addAction(actionSpeed_x4);
@@ -280,7 +283,9 @@ void Ui_MainWindow::createContextMenu(void)
        addAction(actionSpecial_Reset);
 #endif
        addAction(menuCpu_Speed->menuAction());
+#ifdef USE_AUTO_KEY
        addAction(menuCopy_Paste->menuAction());
+#endif 
        addAction(menuState->menuAction());
 #ifdef USE_DEBUGGER
        addAction(menuDebugger->menuAction());
@@ -303,9 +308,10 @@ void Ui_MainWindow::retranslateControlMenu(const char *SpecialResetTitle,  bool
        actionSpeed_x8->setText(QApplication::translate("MainWindow", "Seppd x8", 0));
        actionSpeed_x16->setText(QApplication::translate("MainWindow", "Speed x16", 0));
        
+#ifdef USE_AUTO_KEY
        actionPaste_from_Clipboard->setText(QApplication::translate("MainWindow", "Paste from Clipboard", 0));
        actionStop_Pasting->setText(QApplication::translate("MainWindow", "Stop Pasting", 0));
-
+#endif
 #ifdef USE_STATE
        actionSave_State->setText(QApplication::translate("MainWindow", "Save State", 0));
        actionLoad_State->setText(QApplication::translate("MainWindow", "Load State", 0));
@@ -320,8 +326,9 @@ void Ui_MainWindow::retranslateControlMenu(const char *SpecialResetTitle,  bool
 #endif   
        menuControl->setTitle(QApplication::translate("MainWindow", "control", 0));
        menuState->setTitle(QApplication::translate("MainWindow", "State", 0));
-
+#ifdef USE_AUTO_KEY
        menuCopy_Paste->setTitle(QApplication::translate("MainWindow", "Copy/Paste", 0));
+#endif 
        menuCpu_Speed->setTitle(QApplication::translate("MainWindow", "Cpu Speed", 0));
        actionMouseEnable->setText(QApplication::translate("MainWindow", "Grab MOUSE", 0));
 
index 7de14ac..9e742bb 100644 (file)
@@ -133,8 +133,10 @@ void Ui_MainWindow::setupUi(void)
        menuControl->setObjectName(QString::fromUtf8("menuControl"));
        menuState = new QMenu(menuControl);
        menuState->setObjectName(QString::fromUtf8("menuState"));
+#ifdef USE_AUTO_KEY
        menuCopy_Paste = new QMenu(menuControl);
        menuCopy_Paste->setObjectName(QString::fromUtf8("menuCopy_Paste"));
+#endif 
        menuCpu_Speed = new QMenu(menuControl);
        menuCpu_Speed->setObjectName(QString::fromUtf8("menuCpu_Speed"));
        menuDebugger = new QMenu(menuControl);
@@ -415,9 +417,6 @@ void Ui_MainWindow::setupUi(void)
                        h = 800;
                }
        }
-#ifdef USE_AUTO_KEY
-       ClipBoard = QApplication::clipboard();
-#endif 
        graphicsView->setFixedSize(w, h);
        
        this->set_screen_size(w, h);