diff --git a/.gitignore b/.gitignore deleted file mode 100644 index c8e84db..0000000 --- a/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -# ignore files - -/**/*.user -*.filters - -/**/x64 -.vs/ - -/**/Debug/ -/**/out/ - -/**/__pycache__ \ No newline at end of file diff --git a/QtRpa/CMakeLists.txt b/QtRpa/CMakeLists.txt deleted file mode 100644 index fcc907b..0000000 --- a/QtRpa/CMakeLists.txt +++ /dev/null @@ -1,27 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) - -project(Velkhana) - -add_definitions(-DPROJECT_NAME="${PROJECT_NAME}") - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -#set(Boost_USE_STATIC_LIBS ON) - -add_subdirectory(modules/common) -add_subdirectory(modules/model) -add_subdirectory(modules/interpreter) -add_subdirectory(modules/frameless) -#add_subdirectory(modules/scintilla) -add_subdirectory(modules/creator) -add_subdirectory(modules/wizard) -add_subdirectory(modules/property) -#add_subdirectory(modules/property_browser) -#add_subdirectory(modules/graphics) -add_subdirectory(modules/events) - - diff --git a/QtRpa/CMakeSettings.json b/QtRpa/CMakeSettings.json deleted file mode 100644 index c1db2ec..0000000 --- a/QtRpa/CMakeSettings.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - // "cmakeExecutable": "%CMAKE_ROOT%\\cmake.exe", - "cmakeExecutable": "${env.CMAKE_ROOT}\\cmake.exe", - //"cmakeExecutable": "C:\\Program Files\\CMake\\bin\\cmake.exe", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "-v", - "ctestCommandArgs": "", - "cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake", - "variables": [ - { - "name": "VCPKG_TARGET_TRIPLET", - "value": "x64-windows-mixed", - "type": "STRING" - } - ] - }, - { - "name": "x64-Release", - "generator": "Ninja", - "configurationType": "RelWithDebInfo", - "cmakeExecutable": "C:\\Program Files\\CMake\\bin\\cmake.exe", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "inheritEnvironments": [ "msvc_x64_x64" ], - "variables": [] - } - ] -} \ No newline at end of file diff --git a/QtRpa/assets/Assets/additional.xml b/QtRpa/assets/Assets/additional.xml deleted file mode 100644 index f4971e7..0000000 --- a/QtRpa/assets/Assets/additional.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/QtRpa/assets/Assets/keyboard.xml b/QtRpa/assets/Assets/keyboard.xml deleted file mode 100644 index 969b09e..0000000 --- a/QtRpa/assets/Assets/keyboard.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/QtRpa/assets/Assets/system.xml b/QtRpa/assets/Assets/system.xml deleted file mode 100644 index d787767..0000000 --- a/QtRpa/assets/Assets/system.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/QtRpa/assets/Assets/workflow.xml b/QtRpa/assets/Assets/workflow.xml deleted file mode 100644 index 7b95559..0000000 --- a/QtRpa/assets/Assets/workflow.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/QtRpa/assets/activities/additional.xml b/QtRpa/assets/activities/additional.xml deleted file mode 100644 index f4971e7..0000000 --- a/QtRpa/assets/activities/additional.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/QtRpa/assets/activities/keyboard.xml b/QtRpa/assets/activities/keyboard.xml deleted file mode 100644 index 969b09e..0000000 --- a/QtRpa/assets/activities/keyboard.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/QtRpa/assets/activities/system.xml b/QtRpa/assets/activities/system.xml deleted file mode 100644 index d787767..0000000 --- a/QtRpa/assets/activities/system.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/QtRpa/assets/activities/workflow.xml b/QtRpa/assets/activities/workflow.xml deleted file mode 100644 index 7b95559..0000000 --- a/QtRpa/assets/activities/workflow.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/QtRpa/assets/cursor/cursor-arrow.png b/QtRpa/assets/cursor/cursor-arrow.png deleted file mode 100644 index a69ef4e..0000000 Binary files a/QtRpa/assets/cursor/cursor-arrow.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-busy.png b/QtRpa/assets/cursor/cursor-busy.png deleted file mode 100644 index 53717e4..0000000 Binary files a/QtRpa/assets/cursor/cursor-busy.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-closedhand.png b/QtRpa/assets/cursor/cursor-closedhand.png deleted file mode 100644 index b78dd1d..0000000 Binary files a/QtRpa/assets/cursor/cursor-closedhand.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-cross.png b/QtRpa/assets/cursor/cursor-cross.png deleted file mode 100644 index fe38e74..0000000 Binary files a/QtRpa/assets/cursor/cursor-cross.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-forbidden.png b/QtRpa/assets/cursor/cursor-forbidden.png deleted file mode 100644 index 2b08c4e..0000000 Binary files a/QtRpa/assets/cursor/cursor-forbidden.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-hand.png b/QtRpa/assets/cursor/cursor-hand.png deleted file mode 100644 index d2004ae..0000000 Binary files a/QtRpa/assets/cursor/cursor-hand.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-hsplit.png b/QtRpa/assets/cursor/cursor-hsplit.png deleted file mode 100644 index a5667e3..0000000 Binary files a/QtRpa/assets/cursor/cursor-hsplit.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-ibeam.png b/QtRpa/assets/cursor/cursor-ibeam.png deleted file mode 100644 index 097fc5f..0000000 Binary files a/QtRpa/assets/cursor/cursor-ibeam.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-openhand.png b/QtRpa/assets/cursor/cursor-openhand.png deleted file mode 100644 index 9181c85..0000000 Binary files a/QtRpa/assets/cursor/cursor-openhand.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-sizeall.png b/QtRpa/assets/cursor/cursor-sizeall.png deleted file mode 100644 index 69f13eb..0000000 Binary files a/QtRpa/assets/cursor/cursor-sizeall.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-sizeb.png b/QtRpa/assets/cursor/cursor-sizeb.png deleted file mode 100644 index f37d7b9..0000000 Binary files a/QtRpa/assets/cursor/cursor-sizeb.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-sizef.png b/QtRpa/assets/cursor/cursor-sizef.png deleted file mode 100644 index 3b127a0..0000000 Binary files a/QtRpa/assets/cursor/cursor-sizef.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-sizeh.png b/QtRpa/assets/cursor/cursor-sizeh.png deleted file mode 100644 index a9f40cb..0000000 Binary files a/QtRpa/assets/cursor/cursor-sizeh.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-sizev.png b/QtRpa/assets/cursor/cursor-sizev.png deleted file mode 100644 index 1edbab2..0000000 Binary files a/QtRpa/assets/cursor/cursor-sizev.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-uparrow.png b/QtRpa/assets/cursor/cursor-uparrow.png deleted file mode 100644 index d3e70ef..0000000 Binary files a/QtRpa/assets/cursor/cursor-uparrow.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-vsplit.png b/QtRpa/assets/cursor/cursor-vsplit.png deleted file mode 100644 index 1beda25..0000000 Binary files a/QtRpa/assets/cursor/cursor-vsplit.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-wait.png b/QtRpa/assets/cursor/cursor-wait.png deleted file mode 100644 index 69056c4..0000000 Binary files a/QtRpa/assets/cursor/cursor-wait.png and /dev/null differ diff --git a/QtRpa/assets/cursor/cursor-whatsthis.png b/QtRpa/assets/cursor/cursor-whatsthis.png deleted file mode 100644 index b47601c..0000000 Binary files a/QtRpa/assets/cursor/cursor-whatsthis.png and /dev/null differ diff --git a/QtRpa/assets/favicon.png b/QtRpa/assets/favicon.png deleted file mode 100644 index 6eec87d..0000000 Binary files a/QtRpa/assets/favicon.png and /dev/null differ diff --git a/QtRpa/assets/icons/about.svg b/QtRpa/assets/icons/about.svg deleted file mode 100644 index c8590fd..0000000 --- a/QtRpa/assets/icons/about.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/icons/arrow.svg b/QtRpa/assets/icons/arrow.svg deleted file mode 100644 index 383ea9f..0000000 --- a/QtRpa/assets/icons/arrow.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/icons/close.svg b/QtRpa/assets/icons/close.svg deleted file mode 100644 index 0fcb5a0..0000000 --- a/QtRpa/assets/icons/close.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/icons/exec.svg b/QtRpa/assets/icons/exec.svg deleted file mode 100644 index d8926ab..0000000 --- a/QtRpa/assets/icons/exec.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/icons/favicon.png b/QtRpa/assets/icons/favicon.png deleted file mode 100644 index 6eec87d..0000000 Binary files a/QtRpa/assets/icons/favicon.png and /dev/null differ diff --git a/QtRpa/assets/icons/git.svg b/QtRpa/assets/icons/git.svg deleted file mode 100644 index f8af876..0000000 --- a/QtRpa/assets/icons/git.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/icons/new.svg b/QtRpa/assets/icons/new.svg deleted file mode 100644 index 358aa9a..0000000 --- a/QtRpa/assets/icons/new.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/icons/open.svg b/QtRpa/assets/icons/open.svg deleted file mode 100644 index a6d7d9d..0000000 --- a/QtRpa/assets/icons/open.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/icons/save.svg b/QtRpa/assets/icons/save.svg deleted file mode 100644 index d46d895..0000000 --- a/QtRpa/assets/icons/save.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/QtRpa/assets/images/photo.jpg b/QtRpa/assets/images/photo.jpg deleted file mode 100644 index 2111d9d..0000000 Binary files a/QtRpa/assets/images/photo.jpg and /dev/null differ diff --git a/QtRpa/assets/languages/en-US.json b/QtRpa/assets/languages/en-US.json deleted file mode 100644 index e723dfb..0000000 --- a/QtRpa/assets/languages/en-US.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "plugin": { - "l1": "Missing parameters or type is mismatch", - "l2": "The `%1%`does not exist", - "common": { - "l3": "The ini file parse failed" - } - }, - "model": { - "image": { - "l1": "Can't find image `%1%`" - } - }, - "image": { - "l1": "Template image is empty" - }, - "core": { - "l2": "String conversion failed", - "thread": { - "l1": "Thread interrupted" - } - } -} \ No newline at end of file diff --git a/QtRpa/assets/library/__init__.py b/QtRpa/assets/library/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/QtRpa/assets/library/additional/code.py b/QtRpa/assets/library/additional/code.py deleted file mode 100644 index 7171126..0000000 --- a/QtRpa/assets/library/additional/code.py +++ /dev/null @@ -1,60 +0,0 @@ -from interpreter import LayoutItem -from interpreter import Widget -from interpreter import Item -from interpreter import Property -from interpreter import Element -from interpreter import Layout -from interpreter import LinearLayout -from interpreter import Scintilla -from interpreter import LexerPython - - -class CodePoperty(Property): - def __init__(self, node): - Property.__init__(self, node) - #self.node = node - # print(node.attribute("display").value()) - self.code = node.attribute("code").value() - - - def get_doc(self): - doc = super().get_doc() - doc.document_element().append_attribute("filename").set_value(self.filename) - return doc - - def filename_changed(self, new): - self.code = new - - # def get_input(self, browser): - # group = super().get_input(browser) - # line_edit = LineEditFactory.create() - # str_manager = StringPropertyManager.create() - # filename = str_manager.add_property("Filename") - # group.add_sub_property(filename) - # str_manager.set_value(filename, self.filename) - # str_manager.value_changed.connect(self.filename_changed) - # browser.set_factory_for_manager(str_manager, line_edit) - # return group - - def exec(self): - if self.filename is not None: - exec(self.code) - - -class CodeElement(Element): - def __init__(self, node, parent): - Element.__init__(self, parent) - self.prop = CodePoperty(node) - self.layout = LinearLayout.create(LinearLayout.Vertical, self) - self.layout.set_contents_margins(11, 11, 11, 11) - - self.cintilla = Scintilla(self) - self.cintilla.set_utf8(True) - self.cintilla.set_text(self.prop.code) - self.lexer = LexerPython.create() - self.cintilla.set_lexer(self.lexer) - self.layout.add_item(self.cintilla.widget()) - - - def get_prop(self): - return self.prop diff --git a/QtRpa/assets/library/code.py b/QtRpa/assets/library/code.py deleted file mode 100644 index 4f094ec..0000000 --- a/QtRpa/assets/library/code.py +++ /dev/null @@ -1,6 +0,0 @@ -import dataset -from system import file_remove - -hash = 0x01 - -file_remove.invoke(filename= dataset.attribute[hash].filename) \ No newline at end of file diff --git a/QtRpa/assets/library/filedelete.py b/QtRpa/assets/library/filedelete.py deleted file mode 100644 index 4f094ec..0000000 --- a/QtRpa/assets/library/filedelete.py +++ /dev/null @@ -1,6 +0,0 @@ -import dataset -from system import file_remove - -hash = 0x01 - -file_remove.invoke(filename= dataset.attribute[hash].filename) \ No newline at end of file diff --git a/QtRpa/assets/library/parse.py b/QtRpa/assets/library/parse.py deleted file mode 100644 index 45985e1..0000000 --- a/QtRpa/assets/library/parse.py +++ /dev/null @@ -1,40 +0,0 @@ -import ast -import astunparse - - -class CodeAnalyzer(ast.NodeVisitor): - def visit_Import(self, node): - print("### local:", locals()) - global astunparse - self.dicts.append(astunparse.unparse(node)) - - def visit_ImportFrom(self, node): - self.dicts.append(astunparse.unparse(node)) - dicts = list() - - -try: - code -except NameError: - code = None - - -result = "" - -print(locals()) -#print("""{code}""".format(**locals())) - -print("xxxxxx-") - -print(code) - -if 'code' in locals(): - print("----------", code) - print(locals()) - - node = ast.parse(code) - analyzer = CodeAnalyzer() - analyzer.visit(node) - result = "".join(analyzer.dicts) - -print(result) diff --git a/QtRpa/assets/library/system/fileremove.py b/QtRpa/assets/library/system/fileremove.py deleted file mode 100644 index 1bca2ca..0000000 --- a/QtRpa/assets/library/system/fileremove.py +++ /dev/null @@ -1,47 +0,0 @@ -from interpreter import Property -from interpreter import Container -from interpreter import LineEditFactory -from interpreter import StringPropertyManager -import os - - -class ProcessStartPoperty(Property): - def __init__(self, node): - Property.__init__(self, node) - #self.node = node - # print(node.attribute("display").value()) - self.filename = node.attribute("filename").value() - - def get_doc(self): - doc = super().get_doc() - doc.document_element().append_attribute("filename").set_value(self.filename) - return doc - - def filename_changed(self, new): - self.filename = new - - def get_input(self, browser): - group = super().get_input(browser) - line_edit = LineEditFactory.create() - str_manager = StringPropertyManager.create() - filename = str_manager.add_property("Filename") - group.add_sub_property(filename) - str_manager.set_value(filename, self.filename) - str_manager.value_changed.connect(self.filename_changed) - browser.set_factory_for_manager(str_manager, line_edit) - return group - - def exec(self): - self.filename = "notepad.exe" - if self.filename is not None: - os.remove(self.filename) - - -class ProcessStartView(Container): - def __init__(self, node, parent): - Container.__init__(self, parent) - self.property = ProcessStartPoperty(node) - # print(node.attribute("display").value()) - - def get_prop(self): - return self.property diff --git a/QtRpa/assets/library/system/process_start.py b/QtRpa/assets/library/system/process_start.py deleted file mode 100644 index 11312ef..0000000 --- a/QtRpa/assets/library/system/process_start.py +++ /dev/null @@ -1,48 +0,0 @@ -from interpreter import Property -from interpreter import Element -from interpreter import LineEditFactory -from interpreter import StringPropertyManager -import subprocess - -class ProcessStartPoperty(Property): - def __init__(self, node): - Property.__init__(self, node) - #self.node = node - # print(node.attribute("display").value()) - self.filename = node.attribute("filename").value() - - def get_doc(self): - doc = super().get_doc() - doc.document_element().append_attribute("filename").set_value(self.filename) - return doc - - def filename_changed(self, new): - self.filename = new - - def get_input(self, browser): - group = super().get_input(browser) - line_edit = LineEditFactory.create() - str_manager = StringPropertyManager.create() - filename = str_manager.add_property("Filename") - group.add_sub_property(filename) - str_manager.set_value(filename, self.filename) - str_manager.value_changed.connect(self.filename_changed) - browser.set_factory_for_manager(str_manager, line_edit) - return group - - def exec(self): - if self.filename is None: - subprocess.Popen(self.filename) - else: - #subprocess.Popen([self.filename, self.args]) - subprocess.Popen(self.filename) - - -class ProcessStartView(Element): - def __init__(self, node, parent): - Element.__init__(self, parent) - self.property = ProcessStartPoperty(node) - # print(node.attribute("display").value()) - - def get_prop(self): - return self.property diff --git a/QtRpa/assets/library/workflow/__init__.py b/QtRpa/assets/library/workflow/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/QtRpa/assets/library/workflow/sequence.py b/QtRpa/assets/library/workflow/sequence.py deleted file mode 100644 index ac1a7c5..0000000 --- a/QtRpa/assets/library/workflow/sequence.py +++ /dev/null @@ -1,16 +0,0 @@ -from interpreter import Property -from interpreter import Container - - -class SequencePoperty(Property): - def __init__(self, node): - Property.__init__(self, node) - - -class SequenceView(Container): - def __init__(self, node, parent): - Container.__init__(self, parent) - self.property = SequencePoperty(node) - - def get_prop(self): - return self.property diff --git a/QtRpa/assets/setting/columns.xml b/QtRpa/assets/setting/columns.xml deleted file mode 100644 index 5437dd5..0000000 --- a/QtRpa/assets/setting/columns.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/QtRpa/assets/setting/modules.xml b/QtRpa/assets/setting/modules.xml deleted file mode 100644 index 2762d5e..0000000 --- a/QtRpa/assets/setting/modules.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/QtRpa/assets/template/index.xml b/QtRpa/assets/template/index.xml deleted file mode 100644 index c9fdb5c..0000000 --- a/QtRpa/assets/template/index.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/QtRpa/include/common.hpp b/QtRpa/include/common.hpp deleted file mode 100644 index ab978a9..0000000 --- a/QtRpa/include/common.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "common/framework.h" -#include "common/path.h" -#include "common/zip_entry.h" -#include "common/object.h" -#include "common/worker_thread.h" -#include "common/format.h" -#include "common/code.h" -#include "common/stream.h" -#include "common/const_string.h" -#include "common/logs.h" -#include "common/runnable.h" -#include "common/environment.h" -#include "common/convert.h" -#include "common/mimedata.h" -#include "common/elementparser.h" -#include "common/alias.h" -#include "common/serialization.h" -#include "common/string.h" -#include "common/file.h" -#include "common/algorithm.h" -#include "common/point.h" -#include "common/rect.h" -#include "common/image.h" -#include "common/xmldocument.h" -#include "common/xmlattribute.h" -#include "common/xmlnode.h" -#include "common/directoryentry.h" -#include "common/directoryiterator.h" -#include "common/wobjectdefs.h" - -using namespace shelllet::common; - - -#define DELVELOP_CODE_NAME "Velkhana" \ No newline at end of file diff --git a/QtRpa/include/common/algorithm.h b/QtRpa/include/common/algorithm.h deleted file mode 100644 index 9e20a7d..0000000 --- a/QtRpa/include/common/algorithm.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -namespace shelllet { - namespace common { - - template< typename SequenceSequenceT, typename Range1T> - inline typename boost::range_value::type - join( - const SequenceSequenceT& Input, - const Range1T& Separator) - { - return boost::join(Input, Separator); - } - - } -} - - - diff --git a/QtRpa/include/common/alias.h b/QtRpa/include/common/alias.h deleted file mode 100644 index 350cb3e..0000000 --- a/QtRpa/include/common/alias.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "framework.h" - - -namespace std { - //template -// using iterator = iterator_traits; -} -namespace shelllet { - namespace common { - //using String = std::string; - using WString = std::wstring; - //using Path = std::filesystem::path; - //template - // struct Alloc { }; - - template> - using Vector = std::vector; - - using Int32 = std::int32_t; - - using UInt32 = std::uint32_t; - - using Bool = bool; - - template > - using UniquePointer = std::unique_ptr; - - template - using SharedPointer = std::shared_ptr; - - template, class Allocator = std::allocator > - using Set = std::set; - - template - using Variant = std::variant; - } -} \ No newline at end of file diff --git a/QtRpa/include/common/code.h b/QtRpa/include/common/code.h deleted file mode 100644 index b8c0795..0000000 --- a/QtRpa/include/common/code.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -namespace shelllet { - namespace common { - class code - { - public: - virtual ~code() { } - - //virtual void startProcess() = 0; - - //virtual void endProcess() = 0; - virtual void javascript_code(std::stringstream& stream) = 0; - virtual void process_start(std::stringstream& stream); - virtual void process_end(std::stringstream& stream); - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/common/common_widget.h b/QtRpa/include/common/common_widget.h deleted file mode 100644 index ce15624..0000000 --- a/QtRpa/include/common/common_widget.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include -namespace shelllet { - namespace common { - namespace widget { - enum ExitCode { - ExitWithNormal, - ExitWithCreate, - ExitWithOpen, - ExitWithGit - }; - - class CommonWidget { - public: - virtual ExitCode show() = 0; - virtual void centerToScreen(const QRect& rect) = 0; - }; - } - } -} \ No newline at end of file diff --git a/QtRpa/include/common/const_string.h b/QtRpa/include/common/const_string.h deleted file mode 100644 index 6101d3e..0000000 --- a/QtRpa/include/common/const_string.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace shelllet { -#define STR(str) #str -#define QUOTED(str) #str - - static inline const char K_CONST_MARK_UNKNOWN[] = "unknown"; - static inline const char K_CONST_ERROR_CALLED[] = "# invalid object."; - static inline const char K_CONST_ERROR_NULL_PTR[] = "# this null."; - static inline const char K_CONST_ERROR_INVLAID_PARAM[] = "# invalid param."; -} \ No newline at end of file diff --git a/QtRpa/include/common/convert.h b/QtRpa/include/common/convert.h deleted file mode 100644 index 6ccaf26..0000000 --- a/QtRpa/include/common/convert.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include - - -namespace shelllet { - namespace common { - - static inline void add_declaration(pugi::xml_document& doc) - { - pugi::xml_node decl = doc.append_child(pugi::node_declaration); - decl.append_attribute("version") = "1.0"; - decl.append_attribute("encoding") = "utf-8"; - decl.append_attribute("standalone") = "yes"; - } - - /* static inline void AddDocumentElement(pugi::xml_document& doc) - { - doc.append_child("items"); - }*/ - - - template - static inline QString GetNamespace(const char * name) { - return QString(typeid(T).name()).remove("class ").chopped(strlen(name)); - } - - - } -} diff --git a/QtRpa/include/common/custom_output_backend.h b/QtRpa/include/common/custom_output_backend.h deleted file mode 100644 index 5287901..0000000 --- a/QtRpa/include/common/custom_output_backend.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -namespace shelllet { - namespace common { - class custom_output_backend : public CustomSink - { - public: - - void ReceiveLogMessage(g3::LogMessageMover logEntry) override; - - }; - - - class StdOutBackend : public CustomSink - { - public: - - void ReceiveLogMessage(g3::LogMessageMover logEntry) override; - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/common/directoryentry.h b/QtRpa/include/common/directoryentry.h deleted file mode 100644 index 29daf2f..0000000 --- a/QtRpa/include/common/directoryentry.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "object.h" -namespace shelllet { - namespace common{ - class DirectoryEntryPrivate; - class DirectoryEntry : public Object { - Q_DECLARE_PRIVATE(DirectoryEntry) - public: - DirectoryEntry(Object*parent = nullptr); - DirectoryEntry(const std::filesystem::directory_entry& entry, Object* parent = nullptr); - const Path& path() const noexcept; - - operator const Path& () const noexcept; - protected: - DirectoryEntry(DirectoryEntryPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/common/directoryiterator.h b/QtRpa/include/common/directoryiterator.h deleted file mode 100644 index c39db83..0000000 --- a/QtRpa/include/common/directoryiterator.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "object.h" -namespace shelllet { - namespace common { - class DirectoryIteratorPrivate; - class DirectoryIterator : public Object { - Q_DECLARE_PRIVATE(DirectoryIterator) - public: - DirectoryIterator(Object* parent = nullptr); - DirectoryIterator(const Path& p, Object* parent = nullptr); - DirectoryIterator(const std::filesystem::directory_iterator& iterator, Object* parent = nullptr); - - - using value_type = DirectoryIterator; - using difference_type = std::ptrdiff_t; - using pointer = const DirectoryIterator*; - using reference = const DirectoryIterator&; - using iterator_category = std::input_iterator_tag; - - DirectoryIterator& operator++(); - - bool operator==(const DirectoryIterator& rhs) const noexcept; - - bool operator!=(const DirectoryIterator& rhs) const noexcept; - - DirectoryIterator begin() const; - DirectoryIterator end() const; - - const DirectoryEntry& operator*() const noexcept; - - const DirectoryEntry* operator->() const noexcept; - - protected: - DirectoryIterator(DirectoryIteratorPrivate& d, Object* parent = nullptr); - }; - } -} diff --git a/QtRpa/include/common/elementparser.h b/QtRpa/include/common/elementparser.h deleted file mode 100644 index 4838b75..0000000 --- a/QtRpa/include/common/elementparser.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -namespace shelllet { - namespace common { - class ElementParserPrivate; - class ElementParser : public Object , public boost::serialization::singleton{ - Q_DECLARE_PRIVATE(ElementParser) - public: - ElementParser(); - void parseElement(); - - std::list> data() const; - - - String keyDisplay() const; - - String keyDecoration() const; - - String keySystem() const; - }; - } -} diff --git a/QtRpa/include/common/environment.h b/QtRpa/include/common/environment.h deleted file mode 100644 index d6776f1..0000000 --- a/QtRpa/include/common/environment.h +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once -#include "framework.h" -#include "object.h" -#include "qstring.h" -#include "qstandardpaths.h" -#include "boost/serialization/singleton.hpp" -#include "qicon.h" -#include "path.h" -namespace shelllet { - namespace common { - struct Options { - std::filesystem::path modules_path; - QString extension; - QString pkg_extension; - std::filesystem::path home; - - QString config_filename; - - QString pkg_res; - QString readme_filename; - - QString mime_data_type; - // QString version; - //QString organization_name; - QString pipe_name; - QString dump_remote; - - QString applicationName; - - std::filesystem::path modPath; - std::filesystem::path module_search_path; - int depth = 1; // tree depth - }; - class EnvironmentPrivate; - class Environment : public Object { - Q_DECLARE_PRIVATE(Environment) - public: - Environment(); - public: - void setModulePath(const QString& path); - Path indexXmlPath() const; - - std::filesystem::path storagePath() const; - std::filesystem::path logsPath() const; - std::filesystem::path dumpPath() const; - - std::filesystem::path modPath() const; - QIcon getIconByName(const String &name) const; - QIcon iconMods(const std::string& filename) const; - QPixmap pixmap(const std::string& name) const; - String getIconFileName(const String &name) const; - static Environment* getInstanceRef(); - static const Environment* getInstance(); - - Options const* getOptions() const; - - Path getViewPath() const; - Path getModePath() const; - String getPkgSrcName() const; - String getScriptExtension() const; - Path getAssetsPath() const; - Path getActivitiesPath() const; - - Path getCurrentProjectPath() const; - void setCurrentFilePath(const Path& path); - - Path getTemplatePath() const; - String getIndexFileName() const; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/common/file.h b/QtRpa/include/common/file.h deleted file mode 100644 index 82811bb..0000000 --- a/QtRpa/include/common/file.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace common { - class FilePrivate; - class File : public Object { - Q_DECLARE_PRIVATE(File) - public: - File(); - File(const String& name); - File(const Path& path); - static String readAllAsText(const Path& path); - - File& operator<<(const String& str); - - void write(const String &data); - - static void copy(const Path& src, const Path& target); - protected: - File(FilePrivate& d); - }; - } -} diff --git a/QtRpa/include/common/format.h b/QtRpa/include/common/format.h deleted file mode 100644 index 443ac51..0000000 --- a/QtRpa/include/common/format.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include -#include - -namespace shelllet { - namespace common { - class Format - { - public: - Format(); - virtual ~Format() { } - - std::string format(const std::string& c); - void initialize(int argc, char* argv[]); - private: - std::unique_ptr llvm_; - }; - Q_GLOBAL_STATIC(Format, glFormat) - } -} \ No newline at end of file diff --git a/QtRpa/include/common/framework.h b/QtRpa/include/common/framework.h deleted file mode 100644 index 83ab765..0000000 --- a/QtRpa/include/common/framework.h +++ /dev/null @@ -1,90 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "boost/algorithm/string.hpp" - -using namespace std::chrono_literals; - -#include "wobjectdefs.h" - -template inline T* getPtrHelper(T* ptr) { return ptr; } -template inline auto getPtrHelper(Ptr& ptr) -> decltype(ptr.operator->()) { return ptr.operator->(); } - - -#define DECLARE_PRIVATE(Class) \ -inline Class##Private * d_func() \ - { Q_CAST_IGNORE_ALIGN(return reinterpret_cast(getPtrHelper(d_ptr));) } \ - inline const Class##Private* d_func() const \ - { Q_CAST_IGNORE_ALIGN(return reinterpret_cast(getPtrHelper(d_ptr));) } \ -friend class Class##Private; \ - -#define DECLARE_PRIVATE_D(Dptr, Class) \ -inline Class##Private* d_func() \ - { return dynamic_cast(getPtrHelper(Dptr)); } \ -inline const Class##Private* d_func() const \ - { return dynamic_cast(getPtrHelper(Dptr)); } \ -friend class Class##Private; - - -#define T_DECLARE_PRIVATE(Class) \ -inline Class##Private * d_func() \ - { Q_CAST_IGNORE_ALIGN(return reinterpret_cast *>(getPtrHelper(d_ptr));) } \ - inline const Class##Private* d_func() const \ - { Q_CAST_IGNORE_ALIGN(return reinterpret_cast *>(getPtrHelper(d_ptr));) } \ -friend class Class##Private; \ - -#define T_DECLARE_PRIVATE_D(Dptr, Class) \ -inline Class##Private* d_func() \ - { return dynamic_cast*>(getPtrHelper(Dptr)); } \ -inline const Class##Private* d_func() const \ - { return dynamic_cast*>(getPtrHelper(Dptr)); } \ -friend class Class##Private; - -#define DECLARE_IMPLEMENT_Q(Class) \ -inline Class##* q_func() \ - { return static_cast*>(getPtrHelper(q_ptr));} \ -inline const Class##* q_func() const \ - { return static_cast*>(getPtrHelper(q_ptr)); } \ -friend class Class##; - - - - -#define T_Q_D(Class) Class##Private * const d = d_func() -#define T_Q_Q(Class) Class * const q = q_func() \ No newline at end of file diff --git a/QtRpa/include/common/image.h b/QtRpa/include/common/image.h deleted file mode 100644 index a5d7bbd..0000000 --- a/QtRpa/include/common/image.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "framework.h" -#include "alias.h" -#include "object.h" -#include "qimage.h" -namespace shelllet { - namespace common { - class ImagePrivate; - class Image : public Object { - Q_DECLARE_PRIVATE(Image) - public: - Image(); - Image(const QImage* image); - Image(const QPixmap* pixmap); - Image(const uint8_t* data, int32_t width, int32_t height, UInt32 bytesPerLine, QImage::Format format); - protected: - Image(ImagePrivate& d); - }; - } -} diff --git a/QtRpa/include/common/iterator_traits.h b/QtRpa/include/common/iterator_traits.h deleted file mode 100644 index a97b4ea..0000000 --- a/QtRpa/include/common/iterator_traits.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include - -namespace shelllet { - namespace common { - template - struct iterator_value - { - typedef typename std::iterator_traits::value_type type; - }; - - template - struct iterator_reference - { - typedef typename std::iterator_traits::reference type; - }; - - - template - struct iterator_pointer - { - typedef typename std::iterator_traits::pointer type; - }; - - template - struct iterator_difference - { - typedef typename std::iterator_traits::difference_type type; - }; - - template - struct iterator_category - { - typedef typename std::iterator_traits::iterator_category type; - }; - - } - -} - diff --git a/QtRpa/include/common/kernel.h b/QtRpa/include/common/kernel.h deleted file mode 100644 index 3209b38..0000000 --- a/QtRpa/include/common/kernel.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -namespace shelllet { - static inline const char K_APPLICATION_NAME[] = "creator"; - static inline const char kProjectExtensionName[] = ".let"; - - static inline const char kPropertyCurrentProjectDir[] = "current_project_dir"; - static inline const char kSettingHistoryName[] = "history"; - //static inline const char kSettingTempName[] = "temp"; -} \ No newline at end of file diff --git a/QtRpa/include/common/logs.h b/QtRpa/include/common/logs.h deleted file mode 100644 index 0ca3540..0000000 --- a/QtRpa/include/common/logs.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once -#include "filesystem" -#include "object.h" - -namespace std { - template - using result_of = invoke_result; -} -#include - -enum severity_level -{ - debug, - info, - warning, - error -}; - -namespace shelllet { - namespace common { - - const LEVELS ERROR_ALIAS{ WARNING.value + 1, {"ERROR"} }; - - //#define LOG_TRACE(c) BOOST_LOG_CHANNEL_SEV(__logger::get(), c, boost::log::trivial::trace/*) -#define LOG_DEBUG(c) LOG(G3LOG_DEBUG) << "#" << c << ": " -#define LOG_INFO(c) LOG(INFO) << "#" << c << ": " -#define LOG_WARNING(c) LOG(WARNING) << "#" << c << ": " -#define LOG_ERROR(c) LOG(ERROR_ALIAS) << "#" << c << ": " -#define LOG_FATAL(c) LOG(FATAL) << "#" << c << ": " - struct CustomSink { - virtual void ReceiveLogMessage(g3::LogMessageMover logEntry) { } - int level; - }; - - class LoggerPrivate; - class Logger final : public Object { - Q_DECLARE_PRIVATE(Logger) - public: - Logger(); - - static Logger* getInstance(); - - void addFileSink(severity_level level, const std::filesystem::path& folder); - - void addCustomSink(severity_level level, std::unique_ptr< CustomSink> sink); - - static severity_level levelFromString(const std::string& level); - - void initialize(); - }; - } -} - diff --git a/QtRpa/include/common/mimedata.h b/QtRpa/include/common/mimedata.h deleted file mode 100644 index 2a16c53..0000000 --- a/QtRpa/include/common/mimedata.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "qmimedata.h" -#include "object.h" -namespace shelllet { - namespace common { - class MimeDataPrivate; - class MimeData : public QMimeData, public Object - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, MimeData) - - protected: - MimeData(MimeDataPrivate&); - private: - - }; - - - } -} \ No newline at end of file diff --git a/QtRpa/include/common/object.h b/QtRpa/include/common/object.h deleted file mode 100644 index ed158f4..0000000 --- a/QtRpa/include/common/object.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -#include "qobject.h" -#include "boost/noncopyable.hpp" - -namespace shelllet { - namespace common { - - enum class XmlNodeType - { - Null, // Empty (null) node handle - Document, // A document tree's absolute root - Element, // Element tag, i.e. '' - PCData, // Plain character data, i.e. 'text' - CData, // Character data, i.e. '' - Comment, // Comment tag, i.e. '' - PI, // Processing instruction, i.e. '' - Declaration, // Document declaration, i.e. '' - DocType // Document type declaration, i.e. '' - }; - - - class Object; - class ObjectData : private boost::noncopyable - { - public: - virtual ~ObjectData() = 0; - public: - Object* q_ptr; - Object* parent; - std::list children; - }; - class ObjectPrivate : public ObjectData { - public: - virtual ~ObjectPrivate(); - }; - - class Object { - Q_DECLARE_PRIVATE(Object) - public: - Object() = default; - void invokeMethod(Object* obj); - protected: - Object(ObjectPrivate& dd, Object* parent = nullptr); - protected: - std::unique_ptr d_ptr; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/common/path.h b/QtRpa/include/common/path.h deleted file mode 100644 index 50f60e0..0000000 --- a/QtRpa/include/common/path.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once -#include "qdir.h" -#include "object.h" -#include "string.h" - -namespace shelllet { - namespace common { - class PathPrivate; - class Path : public Object{ - Q_DECLARE_PRIVATE(Path) - friend std::ostream& operator<< (std::ostream&, const Path&); - public: - Path(); - Path(const String& path); - Path(const Path& path); - Path(const std::filesystem::path& path); - Path(const std::string& path); - Path(const char* path); - Path& operator =(const Path& path); - protected: - Path(PathPrivate& d); - public: - - Path& operator/=(const Path& path); - Path operator/(const Path& path) const; - Path operator/(const char* path) const; - operator std::filesystem::path() const; - void replaceExtension(const Path& path); - void replaceFileName(const Path& path); - String fileName() const; - String toString() const; - bool isExist() const; - bool isEmpty() const; - bool isDir() const; - String extension() const; - - static Path applicationDirPath(); - std::filesystem::path toStdPath() const; - private: - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/common/point.h b/QtRpa/include/common/point.h deleted file mode 100644 index 18bc78f..0000000 --- a/QtRpa/include/common/point.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#include "framework.h" -#include "object.h" -#include "qpoint.h" - -namespace shelllet { - namespace common { - using N = QPoint; - using F = QPointF; - - class PointPrivate : public ObjectPrivate { - public: - std::variant point; - - auto x(); - }; - template - class Point : public Object { - Q_DECLARE_PRIVATE(Point) - public: - Point() : Point(*new PointPrivate) { - - } - T x() const { - Q_D(const Point); - if (isReal()) { - return std::get(d->point).x(); - } - else { - return std::get(d->point).x(); - } - } - T y() const { - Q_D(const Point); - if (isReal()) { - return std::get(d->point).y(); - } - else { - return std::get(d->point).y(); - } - } - protected: - Point(PointPrivate& d) : Object(d, nullptr) { - - } - - private: - bool isReal() const { - return (std::is_same::value || std::is_same::value); - } - - }; - } -} diff --git a/QtRpa/include/common/private/directoryentry_p.h b/QtRpa/include/common/private/directoryentry_p.h deleted file mode 100644 index d20a35a..0000000 --- a/QtRpa/include/common/private/directoryentry_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace common{ - class DirectoryEntryPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(DirectoryEntry) - public: - - UniquePointer entry = std::make_unique(); - }; - } -} diff --git a/QtRpa/include/common/private/directoryiterator_p.h b/QtRpa/include/common/private/directoryiterator_p.h deleted file mode 100644 index c910c5d..0000000 --- a/QtRpa/include/common/private/directoryiterator_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace common { - class DirectoryIteratorPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(DirectoryIterator) - public: - SharedPointer iterator = std::make_shared(); - }; - } -} diff --git a/QtRpa/include/common/private/elementparser_p.h b/QtRpa/include/common/private/elementparser_p.h deleted file mode 100644 index 87b526a..0000000 --- a/QtRpa/include/common/private/elementparser_p.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -namespace shelllet { - namespace common { - class ElementParserPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(ElementParser) - public: - - std::list> data; - - - const char* key_filename = "config.yaml"; - const char* key_description = "description"; - const char* key_name = "name"; - const char* key_properties = "properties"; - const char* key_type = "type"; - const char* key_elements = "elements"; - const char* key_display = "display"; - const char* key_icon = "icon"; - const char* key_system = "system"; - }; - } -} diff --git a/QtRpa/include/common/private/file_p.h b/QtRpa/include/common/private/file_p.h deleted file mode 100644 index 71c8b14..0000000 --- a/QtRpa/include/common/private/file_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "object_p.h" -class QFile; -namespace shelllet { - namespace common { - class FilePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(File) - public: - - std::unique_ptr file; - }; - } -} diff --git a/QtRpa/include/common/private/image_p.h b/QtRpa/include/common/private/image_p.h deleted file mode 100644 index 66d18eb..0000000 --- a/QtRpa/include/common/private/image_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "object_p.h" -class QImage; -namespace shelllet { - namespace common { - class ImagePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(Image) - public: - UniquePointer image; - }; - } -} diff --git a/QtRpa/include/common/private/mimedata_p.h b/QtRpa/include/common/private/mimedata_p.h deleted file mode 100644 index 67fc0be..0000000 --- a/QtRpa/include/common/private/mimedata_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "object_p.h" - -namespace shelllet { - namespace common { - class MimeDataPrivate : public ObjectPrivate { - public: - - }; - - } -} \ No newline at end of file diff --git a/QtRpa/include/common/private/object_p.h b/QtRpa/include/common/private/object_p.h deleted file mode 100644 index 291302f..0000000 --- a/QtRpa/include/common/private/object_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "common/object.h" - -namespace shelllet { - namespace common { - - - } -} \ No newline at end of file diff --git a/QtRpa/include/common/private/path_p.h b/QtRpa/include/common/private/path_p.h deleted file mode 100644 index 38a9673..0000000 --- a/QtRpa/include/common/private/path_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace common { - - class PathPrivate : public ObjectPrivate { - - public: - std::filesystem::path path; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/common/private/point_p.h b/QtRpa/include/common/private/point_p.h deleted file mode 100644 index 4cbcb45..0000000 --- a/QtRpa/include/common/private/point_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace common{ - class PointPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(Point) - public: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/common/private/rect_p.h b/QtRpa/include/common/private/rect_p.h deleted file mode 100644 index bd884c4..0000000 --- a/QtRpa/include/common/private/rect_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace common { - template - class RectPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(Rect) - public: - std::variant rect; - - - }; - } -} diff --git a/QtRpa/include/common/private/string_p.h b/QtRpa/include/common/private/string_p.h deleted file mode 100644 index 97d3e6c..0000000 --- a/QtRpa/include/common/private/string_p.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "common/alias.h" -#include "object_p.h" -#ifdef U_NAMESPACE_BEGIN -U_NAMESPACE_BEGIN -#endif // U_NAMESPACE_BEGIN -class UnicodeString; -#ifdef U_NAMESPACE_END -U_NAMESPACE_END -#endif // U_NAMESPACE_END -namespace shelllet { - namespace common { - class StringPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(String) - public: - UniquePointer str; - }; - } -} diff --git a/QtRpa/include/common/private/xmlattribute_p.h b/QtRpa/include/common/private/xmlattribute_p.h deleted file mode 100644 index 21d7078..0000000 --- a/QtRpa/include/common/private/xmlattribute_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "object_p.h" -#include "private/qobject_p.h" - -namespace shelllet { - namespace common { - using namespace pugi; - class XmlNode; - class XmlAttributePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(XmlAttribute) - public: - UniquePointer< xml_attribute> attr{ new xml_attribute }; - }; - } -} diff --git a/QtRpa/include/common/private/xmldocument_p.h b/QtRpa/include/common/private/xmldocument_p.h deleted file mode 100644 index 4744b39..0000000 --- a/QtRpa/include/common/private/xmldocument_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "xmlnode_p.h" -namespace shelllet { - namespace common { - using namespace pugi; - class XmlDocumentPrivate : public XmlNodePrivate { - Q_DECLARE_PUBLIC(XmlDocument) - public: - }; - - } -} \ No newline at end of file diff --git a/QtRpa/include/common/private/xmlnode_p.h b/QtRpa/include/common/private/xmlnode_p.h deleted file mode 100644 index 15b1ad7..0000000 --- a/QtRpa/include/common/private/xmlnode_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace common { - class XmlNodePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(XmlNode) - public: - Variant, SharedPointer> node; - - - }; - - } -} diff --git a/QtRpa/include/common/private/xmlnodeiterator_p.h b/QtRpa/include/common/private/xmlnodeiterator_p.h deleted file mode 100644 index 9b89658..0000000 --- a/QtRpa/include/common/private/xmlnodeiterator_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace common { - using namespace pugi; - class XmlNodeIteratorPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(XmlNodeIterator) - public: - UniquePointer iter{ new xml_node_iterator }; - mutable XmlNode node; - - }; - } -} diff --git a/QtRpa/include/common/rect.h b/QtRpa/include/common/rect.h deleted file mode 100644 index cdf4177..0000000 --- a/QtRpa/include/common/rect.h +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once -#include "framework.h" -#include "object.h" -#include - -namespace shelllet { - namespace common { - class RectPrivate : public ObjectPrivate { - public: - std::variant rect; - }; - template - class Rect : public Object { - Q_DECLARE_PRIVATE(Rect) - public: - Rect() : Rect(*new RectPrivate) { - - } - Rect(const Rect& rect) : Rect(*new RectPrivate) { - Q_D(Rect); - d->rect = rect.d_func()->rect; - } - - Rect(const QRect* rc) : Rect(*new RectPrivate) { - Q_D(Rect); - d->rect = { *rc }; - } - - Rect& operator = (const QRect* rc) { - Q_D(Rect); - d->rect = { *rc }; - return *this; - } - - Rect& operator = (const Rect& rc) { - Q_D(Rect); - //d->rect = { *rc }; - } - bool isReal() const{ - return (std::is_same::value || std::is_same::value); - } - bool isEmpty() const { - Q_D(const Rect); - if (isReal()) { - return std::get(d->rect).isEmpty(); - } - else { - return std::get(d->rect).isEmpty(); - } - } - bool isValid() const { - Q_D(const Rect); - if (isReal()) { - return std::get(d->rect).isValid(); - } - else { - return std::get(d->rect).isValid(); - } - } - - T width() const { - Q_D(const Rect); - if (isReal()) { - return std::get(d->rect).width(); - } - else { - return std::get(d->rect).width(); - } - } - - T height() const { - Q_D(const Rect); - if (isReal()) { - return std::get(d->rect).height(); - } - else { - return std::get(d->rect).height(); - } - } - - T x() const { - Q_D(const Rect); - if (isReal()) { - return std::get(d->rect).x(); - } - else { - return std::get(d->rect).x(); - } - } - - T y() const { - Q_D(const Rect); - if (isReal()) { - return std::get(d->rect).y(); - } - else { - return std::get(d->rect).y(); - } - } - - protected: - Rect(RectPrivate& d) : Object(d, nullptr) { - - } - }; - - - } -} diff --git a/QtRpa/include/common/runnable.h b/QtRpa/include/common/runnable.h deleted file mode 100644 index d8b6a5b..0000000 --- a/QtRpa/include/common/runnable.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "qevent.h" -#include "boost/core/noncopyable.hpp" - -namespace shelllet { - class Runnable - { - public: - virtual void run(QEvent* event) = 0; - }; - - -} \ No newline at end of file diff --git a/QtRpa/include/common/serialization.h b/QtRpa/include/common/serialization.h deleted file mode 100644 index c58126f..0000000 --- a/QtRpa/include/common/serialization.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "common.hpp" - -namespace shelllet { - namespace common { - class Serialization - { - public: - virtual ~Serialization() {} - virtual void create() = 0; - virtual void load(const Path& filename) = 0; - virtual void save(const Path& filename) = 0; - }; - - class Property { - public: - virtual std::filesystem::path relative() = 0; - }; - - static inline const char* endline() { - return "\n"; - } - } -} diff --git a/QtRpa/include/common/stream.h b/QtRpa/include/common/stream.h deleted file mode 100644 index 3b9f099..0000000 --- a/QtRpa/include/common/stream.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once -#include "qstring.h" -#include "qbytearray.h" -#include "qbuffer.h" -#include "qdatastream.h" -#include "pugixml.hpp" -namespace std { - - std::ostream& operator<< (std::ostream& out, const QString& data); - std::wostream& operator<< (std::wostream& out, const std::wstring& data); - - - - std::ostream& operator<< (std::ostream& out, const QStringList& data); - std::ostream& operator<< (std::ostream& out, const QPoint& data); - std::ostream& operator<< (std::ostream& out, const QPointF& data); - std::ostream& operator<< (std::ostream& out, const QSize& data); - std::ostream& operator<< (std::ostream& out, const QSizeF& data); - std::ostream& operator<< (std::ostream& out, const QByteArray& data); - - std::ostream& operator<< (std::ostream& out, const QRect& data); - std::ostream& operator<< (std::ostream& out, const QRectF& data); - - - - std::istream& operator >> (std::istream& in, QString& data); - std::istream& operator>> (std::istream& in, QStringList& data); - - -} - - -namespace shelllet { - struct XmlByteArrayWriter : pugi::xml_writer - { - QByteArray result; - - virtual void write(const void* data, size_t size) - { - result.append(static_cast(data), size); - } - }; -} - -//Q_DECLARE_METATYPE(std::string) - - - - - - - diff --git a/QtRpa/include/common/string.h b/QtRpa/include/common/string.h deleted file mode 100644 index 880a0fb..0000000 --- a/QtRpa/include/common/string.h +++ /dev/null @@ -1,88 +0,0 @@ -#pragma once -#include -//#include -#include "object.h" -#include "alias.h" - -#include "yaml-cpp/yaml.h" - -class QString; -namespace shelllet { - namespace common { - class U8StringPrivate; - class U8String : public Object { - Q_DECLARE_PRIVATE(U8String) - public: - U8String(); - U8String(const U8String& str); - U8String& append(const char* data, UInt32 n); - UInt32 length() const; - UInt32 capacity() const; - void reserve(UInt32 cap); - - operator const char* () const; - protected: - U8String(U8StringPrivate& d); - }; - class StringPrivate; - class String : public Object { - Q_DECLARE_PRIVATE(String) - friend std::ostream& operator<< (std::ostream&, const String&); - - public: - String(); - String(const char* str); - String(const std::string& str); - String(const String& str); - String(const std::vector& v); - - String(std::istream& stream); - //String(std::ifstream& stream); - public: - //operator std::string() const; - String& append(const String& str); - String& operator =(const String& str); - String operator +(const String& str) const; - bool operator ==(const String& str) const; - bool operator <(const String& str) const; - std::string toStdString() const; - std::wstring toStdWString() const; - QString* toQString() const; - const char16_t* data() const; - String clone() const; - //friend String operator+(const String& lhs, String const& rhs) { - // return lhs + rhs; - //} - U8String toUtf8()const; - - String subString(std::int32_t start, std::int32_t len = INT32_MAX) const; - - bool isEmpty() const; - void toLower(); - int toInt() const; - static String fromQString(const QString* str); - static String& toLower(String&& str); - static String toLower(const String& str); - static String removeNamespace(const String& str); - - static Int32 typeId(); - - static bool isEquals(const char* ch1, const char* ch2); - protected: - String(StringPrivate& d); - - }; - - - } -} -W_REGISTER_ARGTYPE(shelllet::common::String) - -Q_DECLARE_METATYPE(shelllet::common::String) -//std::ostream& operator<< (std::ostream& out, const shelllet::common::String& data); - -static inline YAML::Emitter& operator << (YAML::Emitter& out, const shelllet::common::String& v) { - out << YAML::DoubleQuoted; - out << v.toUtf8(); - return out; -} \ No newline at end of file diff --git a/QtRpa/include/common/variable.h b/QtRpa/include/common/variable.h deleted file mode 100644 index 6c7b91d..0000000 --- a/QtRpa/include/common/variable.h +++ /dev/null @@ -1,87 +0,0 @@ -#pragma once -#include -#include -#include -#include "logs.h" -namespace shelllet { - enum Columns { - Name, - Type, - Value, - Ref, // ref count - Desc, - Count - }; - struct Var { - std::string name; - std::string type; - std::string value; // js data types[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures] - std::int32_t ref; - std::string desc; - - static inline std::map keys = { {Name, "name"}, {Type, "type"}, {Value, "value"}, {Ref, "ref"}, {Desc, "desc"} }; - }; -} -namespace YAML { - using namespace shelllet; - template<> - struct convert { - static Node encode(const Var& rhs) { - Node node; - node[Var::keys[Name]] = rhs.name; - node[Var::keys[Type]] = rhs.type; - node[Var::keys[Columns::Value]] = rhs.value; - node[Var::keys[Ref]] = rhs.ref; - node[Var::keys[Desc]] = rhs.desc; - - return node; - } - - static bool decode(const Node& node, Var& rhs) { - try - { - rhs.name = node[Var::keys[Name]].as(); - } - catch (const std::exception& err) - { - LOG_FATAL("rpa") << "# parse variables error: " << err.what(); - } - - try - { - rhs.type = node[Var::keys[Type]].as(); - } - catch (const std::exception& err) - { - LOG_FATAL("rpa") << "# parse variables error: " << err.what(); - } - try - { - rhs.value = node[Var::keys[Columns::Value]].as(); - } - catch (const std::exception& err) - { - LOG_FATAL("rpa") << "# parse variables error: " << err.what(); - } - try - { - rhs.ref = node[Var::keys[Ref]].as(); - } - catch (const std::exception& err) - { - rhs.ref = 0; - LOG_FATAL("rpa") << "# parse variables error: " << err.what(); - } - try - { - rhs.desc = node[Var::keys[Desc]].as(); - } - catch (const std::exception& err) - { - LOG_FATAL("rpa") << "# parse variables error: " << err.what(); - } - - return true; - } - }; -} diff --git a/QtRpa/include/common/wobjectcpp.h b/QtRpa/include/common/wobjectcpp.h deleted file mode 100644 index ff02fe6..0000000 --- a/QtRpa/include/common/wobjectcpp.h +++ /dev/null @@ -1,270 +0,0 @@ -#pragma once -#include "wobjectdefs.h" - -namespace w_internal { -#if __cplusplus <= 201700L -template -constexpr bool all() { - bool b = true; - ordered2({(b = b && Bs)...}); - return b; -} -#endif - -template, class ParamNames = w_internal::StringViewArray<>> -struct MetaMethodInfoBuilder { - StringView name; - F func; - ParamTypes paramTypes{}; - ParamNames paramNames{}; - static constexpr int flags = Flags; - using IntegralConstant = IC; - -#if __cplusplus > 201700L - template, StringView> && ...)>> -#else - template, StringView>::value...>()>> -#endif - constexpr auto setParamTypes(Args... paramTypes) const - -> MetaMethodInfoBuilder, ParamNames> { - return {name, func, {paramTypes...}, paramNames}; - } -#if __cplusplus > 201700L - template, StringView> && ...)>> -#else - template, StringView>::value...>()>> -#endif - constexpr auto setParamNames(Args... paramNames) const - -> MetaMethodInfoBuilder> { - return {name, func, paramTypes, {paramNames...}}; - } - template - constexpr auto addFlags(w_internal::W_MethodFlags...) const -#if __cplusplus > 201700L - -> MetaMethodInfoBuilder { -#else - -> MetaMethodInfoBuilder, IC, ParamTypes, ParamNames> { -#endif - return {name, func, paramTypes, paramNames}; - } - template - constexpr auto setIntegralConstant() const -> MetaMethodInfoBuilder { - return {name, func, paramTypes, paramNames}; - } - - constexpr auto build() const -> w_internal::MetaMethodInfo { - return {func, name, paramTypes, paramNames}; - } -}; - -} // namespace w_internal - -namespace w_cpp { - -/// Very simple constexpr version of std::string_view -/// -/// example usage: -/// constexpr char text[6] = "Hello"; // if you have a string literal use `viewLiteral` below. -/// constexpr auto view = w_cpp::StringView{&text[0], &text[5]}; -/// -/// \note the end pointer has to point behind the \0 -using w_internal::StringView; - -/// Array of StringView -/// -/// example usage: -/// auto array = w_cpp::StringViewArray<2>{{w_cpp::viewLiteral("Hello"), w_cpp::viewLiteral("World")}}; -/// array.data[1] = w_cpp::viewLiteral("World !!!"); -using w_internal::StringViewArray; - -/// Generate a constexpr StringView from a C++ string literal. -/// -/// example usage: -/// constexpr auto view = w_cpp::viewLiteral{"Hello"}; -using w_internal::viewLiteral; - -/// Store a compile time sequence of enum values -/// -/// example usage: -/// enum class Level { Easy, Normal, Hard }; -/// constexpr auto sequence = w_cpp::enum_sequence{}; -using w_internal::enum_sequence; - -/// create a compile time property description for registraton usage -/// -/// \arg T the type of the property -/// \arg name the compile time StringView for the property name -/// \arg type the compile time StringView for the type of the property -/// -/// Following methods may be called in chain: -/// * .setGetter(F) - set the member function that returns the value of the property `() -> T` -/// * .setSetter(F) - set the member function that changes the value of the property `(T) -> void` -/// * .setMember(M) - set the class attribute to read and write the value of the property -/// * .setNotify(F) - set the member function that represents the changed signal for the property -/// * .setReset(F) - set the member function that resets the property value to it's default -/// * .addFlag() - add one or multiple flags for the property -template -constexpr auto makeProperty(StringView name, StringView type) { - return w_internal::MetaPropertyInfo{ name, type, {}, {}, {}, {}, {} }; -} - -/// create a builder for a signal description -/// -/// \arg name the compile time StringView for the function name -/// \arg func the member function that implements the signal -/// -/// Following methods may be call in chain: -/// * .setParamNames(StringView...) - set the names for all the function parameters (optional) -/// * .setParamTypes(StringView...) - set the names of for all parameter types -/// * .addFlag(Flags...) - add some methods flags -/// * .setIntegralConstant() - set a compile time integral value type as a unique identifier -/// * .build() - build the final MethodInfo for this signal -template -constexpr auto makeSignalBuilder(StringView name, F func) { - return w_internal::MetaMethodInfoBuilder{name, func}; -} - -/// create a compile time enum description for registraton usage -/// -/// \arg Enum type -/// \arg name the compile time StringView for the enum name -/// \arg memberValueSequence the compile time enum_sequence of all enum member values -/// \arg memberNames the compile time StringViewArray of all enum member names -/// -/// \note to correct map between values and names, member values in memberValueSequence must be in the same order as member names in memberNames -template -constexpr auto makeEnumInfo(StringView name, w_internal::enum_sequence memberValueSequence, w_internal::StringViewArray memberNames) { - return w_internal::makeMetaEnumInfo(name, 0, memberValueSequence, memberNames); -} - -/// create a compile time flags description for registraton usage -/// -/// \arg Enum type -/// \arg name the compile time StringView for the flag name -/// \arg enumAliasName the compile time StringView for the enum name that is used as alias by flags -/// \arg memberValueSequence the compile time enum_sequence of all enum member values -/// \arg memberNames the compile time StringViewArray of all enum member names -/// -/// \note to correct map between values and names, member values in memberValueSequence must be in the same order as member names in memberNames -template -constexpr auto makeFlagInfo(StringView name, StringView enumAliasName, w_internal::enum_sequence memberValueSequence, w_internal::StringViewArray memberNames) { - return w_internal::makeMetaEnumInfo(name, enumAliasName, memberValueSequence, memberNames); -} - -} // namespace w_cpp - -/// \macro W_CPP_PROPERTY(callback) -/// allows to create multiple properties from a templated structure using regular C++. -/// -/// example usage: -/// template -/// struct MyProperties; -/// template<> -/// struct MyProperties<0> { -/// constexpr static auto property = w_cpp::makeProperty(w_cpp::viewLiteral("name"), w_cpp::viewLiteral("QString")) -/// .setGetter(&Example::getName); -/// }; -/// W_CPP_PROPERTY(MyProperties) -/// -/// \note you have to ensure that the struct is only valid for some `I`s. -#define W_CPP_PROPERTY(a) \ - static constexpr size_t W_MACRO_CONCAT(a,_O) = w_internal::stateCount<__COUNTER__, w_internal::PropertyStateTag, W_ThisType**>; \ - template \ - friend constexpr auto w_state(w_internal::Index, w_internal::PropertyStateTag, W_ThisType**) W_RETURN((a::property)) - -/// \macro W_CPP_SIGNAL(callback) -/// allows to register multiple signals from a templated structure using regular C++. -/// -/// example usage: -/// template -/// struct MySignals; -/// template<> -/// struct MySignals<0> { -/// constexpr static auto signal = w_cpp::makeSignalBuilder(w_cpp::viewLiteral("nameChanged"), &Example::nameChanged).build(); -/// }; -/// W_CPP_SIGNAL(MySignals) -/// -/// \note you have to ensure that the struct is only valid for some `I`s. -#define W_CPP_SIGNAL(a) \ - static constexpr size_t W_MACRO_CONCAT(a,_O) = w_internal::stateCount<__COUNTER__, w_internal::SignalStateTag, W_ThisType**>; \ - template \ - friend constexpr auto w_state(w_internal::Index, w_internal::SignalStateTag, W_ThisType**) W_RETURN((a::signal)) - -/// \macro W_CPP_SIGNAL_IMPL(type, callback, index) -/// allows to implement a signal -/// -/// example usage: -/// template -/// void notifyPropertyChanged() W_CPP_SIGNAL_IMPL(decltype (&tst_CppApi::notifyPropertyChanged), MySignals, I, 0) -/// -#define W_CPP_SIGNAL_IMPL(type, a, i, ...) \ - constexpr int index = W_ThisType::W_MACRO_CONCAT(a,_O) + i; \ - return w_internal::SignalImplementation{this}(__VA_ARGS__) - -/// \macro W_CPP_ENUM(type, callback) -/// allows to register a enum type for a QObject type from a templated structure using regular C++. -/// additionally enum can be declared outside QObject where it is registered. -/// -/// example usage: -/// enum class Level { Easy, Normal, Hard }; -/// -/// template -/// struct MyEnums; -/// template<> -/// struct MyEnums { -/// constexpr static auto enumInfo = w_cpp::makeEnumInfo( -/// w_cpp::viewLiteral("Level"), -/// w_cpp::enum_sequence{}, -/// w_cpp::StringViewArray<3>{ -/// {w_cpp::viewLiteral("Easy"), w_cpp::viewLiteral("Normal"), w_cpp::viewLiteral("Hard")}}); -/// }; -/// W_CPP_ENUM(Level, MyEnums) -/// -#define W_CPP_ENUM(type, a) \ - W_STATE_APPEND(EnumState, a::enumInfo) \ - Q_ENUM(type) - -/// \macro W_CPP_ENUM_NS(type, callback) -/// allows to register a enum type for a namespace that was declarated with W_NAMESPACE from a templated structure using regular C++. -/// additionally enum can be declared outside namespace where it is registered. -/// -/// example usage: -/// Similar to usage of W_CPP_ENUM but you must use W_CPP_ENUM_NS instead of W_CPP_ENUM -#define W_CPP_ENUM_NS(type, a) \ - W_STATE_APPEND_NS(EnumState, a::enumInfo) \ - Q_ENUM_NS(type) - -/// \macro W_CPP_FLAG(type, callback) -/// allows to register a enum type as QFlags for a QObject type from a templated structure using regular C++. -/// additionally enum can be declared outside QObject where it is registered. -/// -/// example usage: -/// enum class Filter { None = 0x00, Name = 0x01, Comment = 0x02, Any = Name | Comment }; -/// -/// Q_DECLARE_FLAGS(Filters, Filter) -/// template<> -/// struct MyEnums { -/// constexpr static auto flagInfo = w_cpp::makeFlagInfo( -/// w_cpp::viewLiteral("Filters"), -/// w_cpp::viewLiteral("Filter"), -/// w_cpp::enum_sequence{}, -/// w_cpp::StringViewArray<4>{{w_cpp::viewLiteral("None"), -/// w_cpp::viewLiteral("Name"), -/// w_cpp::viewLiteral("Comment"), -/// w_cpp::viewLiteral("Any")}}); -/// }; -/// W_CPP_FLAG(Filters, MyEnums) -/// -#define W_CPP_FLAG(type, a) \ - W_STATE_APPEND(EnumState, a::flagInfo) \ - Q_FLAG(type) - -/// \macro W_CPP_FLAG_NS(type, callback) -/// allows to register a enum type as QFlags for a namespace that was declarated with W_NAMESPACE from a templated structure using regular C++. -/// additionally enum can be declared outside namespace where it is registered. -/// -/// example usage: -/// Similar to usage of W_CPP_FLAG but you must use W_CPP_FLAG_NS instead of W_CPP_FLAG -#define W_CPP_FLAG_NS(type, a) \ - W_STATE_APPEND_NS(EnumState, a::flagInfo) \ - Q_FLAG_NS(type) diff --git a/QtRpa/include/common/wobjectdefs.h b/QtRpa/include/common/wobjectdefs.h deleted file mode 100644 index 9caa6ac..0000000 --- a/QtRpa/include/common/wobjectdefs.h +++ /dev/null @@ -1,1006 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2016-2018 Woboq GmbH - * Olivier Goffart - * https://woboq.com/ - * - * This file is part of Verdigris: a way to use Qt without moc. - * https://github.com/woboq/verdigris - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. - * If not, see . - */ -#pragma once - -#ifndef Q_MOC_RUN // don't define anything when moc is run - -#include -#include -#include - -#define W_VERSION 0x010200 - -namespace w_internal { -using std::index_sequence; // From C++14, make sure to enable the C++14 option in your compiler - -#ifdef W_USE_CUSTOM_MAKE_INDEX_SEQUENCE -// The default std::make_index_sequence from libstdc++ is recursing O(N) times which is reaching -// recursion limits level for big strings. This implementation has only O(log N) recursion -template -index_sequence -make_index_sequence_helper_merge(index_sequence, index_sequence); - -template struct make_index_sequence_helper { - using part1 = typename make_index_sequence_helper<(N+1)/2>::result; - using part2 = typename make_index_sequence_helper::result; - using result = decltype(make_index_sequence_helper_merge(part1(), part2())); -}; -template<> struct make_index_sequence_helper<1> { using result = index_sequence<0>; }; -template<> struct make_index_sequence_helper<0> { using result = index_sequence<>; }; -template using make_index_sequence = typename make_index_sequence_helper::result; -#else -using std::make_index_sequence; -#endif - -/// integral_constant with an inheritance based fallback -struct IndexBase {}; -template struct Index : IndexBase {}; -template constexpr auto index = Index{}; - -template constexpr void ordered(Args...) {} -template constexpr void ordered2(std::initializer_list) {} - -/// Compute the sum of many integers -template -constexpr int sums(Args... args) { -#if __cplusplus > 201700L - return static_cast((args + ... + 0)); -#else - auto r = int{}; - ordered2({(r += args)...}); - return r; -#endif -} -// This indirection is required to work around a MSVC bug. (See https://github.com/woboq/verdigris/issues/6 ) -template -constexpr int summed = sums(args...); - -/// constexpr friendly string_view -struct StringView { - const char* b{}; - const char* e{}; - - constexpr auto size() const -> qptrdiff { return e - b; } - constexpr auto begin() const { return b; } - constexpr auto end() const { return e; } -}; -// adding this constructor requires more constructors which generates overhead -template -constexpr auto viewLiteral(const char (&d)[N]) -> StringView { - return {&d[0], &d[N-1]}; -} - -/// raw arrays cannot be returned from functions so we wrap it -template -struct StringViewArray { - StringView data[(N > 0 ? N : 1)]{}; - - constexpr auto operator[] (size_t i) const { return data[i]; } -}; - - -template -constexpr auto countParsedLiterals(const char (&s)[SN]) { - auto r = size_t{}; - auto i = 0u; - while (true) { - while (true) { - if (i >= SN-1) return r; - if (s[i] != ' ' && s[i] != ',') break; // start found - i++; - } - r++; - i++; - while (true) { - if (i >= SN-1) return r; - if (s[i] == ',') break; - i++; - } - i++; - } -} - -template -constexpr auto viewParsedLiterals(const char (&s)[SN]) -> StringViewArray { - // assumtions: - // 1. s is generated from a macro - // 2. each value is seperated by comma - // 3. exactly N values are generated - // 4. no second space can follow a space (no tabs or line breaks) - auto r = StringViewArray{}; - auto ri = size_t{}; - auto i = 0u; - while (true) { - while (true) { - if (i >= SN-1) return r; - if (s[i] != ' ' && s[i] != ',') break; // start found - i++; - } - r.data[ri].b = &s[i]; - i++; - while (true) { - if (i >= SN-1) { - r.data[ri].e = &s[i]; - return r; // text - end - } - if (s[i] == ' ') { - if (i+1 >= SN-1) { - r.data[ri].e = &s[i]; - return r; // text - whitespace - end - } - if (s[i+1] == ',') { - r.data[ri].e = &s[i]; - i += 2; - break; // text - whitespace - comma - } - i += 2; - continue; // text - whitespace - text - } - if (s[i] == ',') { - r.data[ri].e = &s[i]; - i++; - break; // text - comma - } - i++; - } - ri++; - } -} - -template -constexpr auto viewScopedLiterals(const char (&s)[SN]) -> StringViewArray { - auto r = StringViewArray{}; - auto ri = size_t{}; - auto i = 0u; - while (true) { - while (true) { - if (i >= SN-1) return r; - if (s[i] != ' ' && s[i] != ',' && s[i] != ':') break; // start found - i++; - } - r.data[ri].b = &s[i]; - i++; - while (true) { - if (i >= SN-1) { - r.data[ri].e = &s[i]; - return r; // text - end - } - if (s[i] == ':') { - i++; - if (s[i] == ' ') i++; - r.data[ri].b = &s[i]; - continue; - } - if (s[i] == ' ') { - if (i+1 >= SN-1) { - r.data[ri].e = &s[i]; - return r; // text - whitespace - end - } - if (s[i+1] == ',') { - r.data[ri].e = &s[i]; - i += 2; - break; // text - whitespace - comma - } - i += 2; - continue; // text - whitespace - text - } - if (s[i] == ',') { - r.data[ri].e = &s[i]; - i++; - break; // text - comma - } - i++; - } - ri++; - } -} - -//----------- - -// From qmetaobject_p.h -enum class PropertyFlags { - Invalid = 0x00000000, - Readable = 0x00000001, - Writable = 0x00000002, - Resettable = 0x00000004, - EnumOrFlag = 0x00000008, - StdCppSet = 0x00000100, - // Override = 0x00000200, - Constant = 0x00000400, - Final = 0x00000800, - Designable = 0x00001000, - ResolveDesignable = 0x00002000, - Scriptable = 0x00004000, - ResolveScriptable = 0x00008000, - Stored = 0x00010000, - ResolveStored = 0x00020000, - Editable = 0x00040000, - ResolveEditable = 0x00080000, - User = 0x00100000, - ResolveUser = 0x00200000, - Notify = 0x00400000, - Revisioned = 0x00800000 -}; -constexpr uint operator|(uint a, PropertyFlags b) { return a | uint(b); } - -template struct W_MethodFlags { static constexpr int value = N; }; -constexpr W_MethodFlags<0> W_EmptyFlag{}; - -} // namespace w_internal - -/// Objects that are used as flags in the W_SLOT macro - -// Mirror of QMetaMethod::Access -namespace W_Access { - // From qmetaobject_p.h MethodFlags - // AccessPrivate = 0x00, - // AccessProtected = 0x01, - // AccessPublic = 0x02, - // AccessMask = 0x03, //mask - constexpr w_internal::W_MethodFlags<0x1000> Private{}; // Note: Private has a higher number to differentiate it from the default - constexpr w_internal::W_MethodFlags<0x01> Protected{}; - constexpr w_internal::W_MethodFlags<0x02> Public{}; -} - -// Mirror of QMetaMethod::MethodType -namespace W_MethodType { - // From qmetaobject_p.h MethodFlags - // MethodMethod = 0x00, - // MethodSignal = 0x04, - // MethodSlot = 0x08, - // MethodConstructor = 0x0c, - // MethodTypeMask = 0x0c, - constexpr w_internal::W_MethodFlags<0x00> Method{}; - constexpr w_internal::W_MethodFlags<0x04> Signal{}; - constexpr w_internal::W_MethodFlags<0x08> Slot{}; - constexpr w_internal::W_MethodFlags<0x0c> Constructor{}; -} - -// From qmetaobject_p.h MethodFlags -// MethodCompatibility = 0x10, -// MethodCloned = 0x20, -// MethodScriptable = 0x40, -// MethodRevisioned = 0x80 -constexpr w_internal::W_MethodFlags<0x10> W_Compat{}; -constexpr w_internal::W_MethodFlags<0x40> W_Scriptable{}; -constexpr struct {} W_Notify{}; -constexpr struct {} W_Reset{}; -constexpr std::integral_constant W_Constant{}; -constexpr std::integral_constant W_Final{}; - -namespace w_internal { - -/// Holds information about a method -template> -struct MetaMethodInfo { - F func; - StringView name; - ParamTypes paramTypes; - ParamNames paramNames; - static constexpr int argCount = QtPrivate::FunctionPointer::ArgumentCount; - static constexpr auto argSequence = make_index_sequence{}; - static constexpr int flags = Flags; - using IntegralConstant = IC; -}; - -// Called from the W_SLOT macro -template -constexpr MetaMethodInfo | W_MethodType::Slot.value, IntegralConstant, ParamTypes> -makeMetaSlotInfo(F f, StringView name, IntegralConstant, const ParamTypes ¶mTypes, W_MethodFlags...) -{ return { f, name, paramTypes, {} }; } - -// Called from the W_METHOD macro -template -constexpr MetaMethodInfo | W_MethodType::Method.value, IntegralConstant, ParamTypes> -makeMetaMethodInfo(F f, StringView name, IntegralConstant, const ParamTypes ¶mTypes, W_MethodFlags...) -{ return { f, name, paramTypes, {} }; } - -// Called from the W_SIGNAL macro -template -constexpr MetaMethodInfo | W_MethodType::Signal.value, IntegralConstant, - ParamTypes, ParamNames> -makeMetaSignalInfo(F f, StringView name, IntegralConstant, const ParamTypes ¶mTypes, - const ParamNames ¶mNames, W_MethodFlags...) -{ return { f, name, paramTypes, paramNames }; } - -/// Holds information about a constructor -template -struct MetaConstructorInfo { - static constexpr std::size_t argCount = sizeof...(Args); - static constexpr auto argSequence = make_index_sequence{}; - static constexpr int flags = W_MethodType::Constructor.value | W_Access::Public.value; - using IntegralConstant = void*; // Used to detect the access specifier, but it is always public, so no need for this - StringView name; -}; -// called from the W_CONSTRUCTOR macro -template -constexpr MetaConstructorInfo makeMetaConstructorInfo(StringView name) -{ return { name }; } - -struct Empty{ - constexpr operator bool() const { return false; } -}; - -/// Holds information about a property -template -struct MetaPropertyInfo { - using PropertyType = Type; - StringView name; - StringView typeStr; - Getter getter; - Setter setter; - Member member; - Notify notify; - Reset reset; - static constexpr uint flags = Flags; - - template constexpr auto setGetter(const S&s) const { - return MetaPropertyInfo - {name, typeStr, s, setter, member, notify, reset}; - } - template constexpr auto setSetter(const S&s) const { - return MetaPropertyInfo - {name, typeStr, getter, s, member, notify, reset}; - } - template constexpr auto setMember(const S&s) const { - return MetaPropertyInfo - {name, typeStr, getter, setter, s, notify, reset}; - } - template constexpr auto setNotify(const S&s) const { - return MetaPropertyInfo - { name, typeStr, getter, setter, member, s, reset}; - } - template constexpr auto setReset(const S&s) const { - return MetaPropertyInfo - { name, typeStr, getter, setter, member, notify, s}; - } - template constexpr auto addFlag() const { - return MetaPropertyInfo - { name, typeStr, getter, setter, member, notify, reset}; - } -}; - -/// Parse a property and fill a MetaPropertyInfo (called from W_PROPERTY macro) -// base case -template constexpr auto parseProperty(const PropInfo &p) { return p; } -// setter -template -constexpr auto parseProperty(const PropInfo &p, Ret (Obj::*s)(Arg), Tail... t) -{ return parseProperty(p.setSetter(s) , t...); } -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -constexpr auto parseProperty(const PropInfo &p, Ret (Obj::*s)(Arg) noexcept, Tail... t) -{ return parseProperty(p.setSetter(s) , t...); } -#endif -// getter -template -constexpr auto parseProperty(const PropInfo &p, Ret (Obj::*s)(), Tail... t) -{ return parseProperty(p.setGetter(s), t...); } -template -constexpr auto parseProperty(const PropInfo &p, Ret (Obj::*s)() const, Tail... t) -{ return parseProperty(p.setGetter(s), t...); } -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -constexpr auto parseProperty(const PropInfo &p, Ret (Obj::*s)() noexcept, Tail... t) -{ return parseProperty(p.setGetter(s), t...); } -template -constexpr auto parseProperty(const PropInfo &p, Ret (Obj::*s)() const noexcept, Tail... t) -{ return parseProperty(p.setGetter(s), t...); } -#endif -// member -template -constexpr auto parseProperty(const PropInfo &p, Ret Obj::*s, Tail... t) -{ return parseProperty(p.setMember(s) ,t...); } -// notify -template -constexpr auto parseProperty(const PropInfo &p, decltype(W_Notify), F f, Tail... t) -{ return parseProperty(p.setNotify(f) ,t...); } -// reset -template -constexpr auto parseProperty(const PropInfo &p, decltype(W_Reset), Ret (Obj::*s)(), Tail... t) -{ return parseProperty(p.setReset(s) ,t...); } -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 -template -constexpr auto parseProperty(const PropInfo &p, decltype(W_Reset), Ret (Obj::*s)() noexcept, Tail... t) -{ return parseProperty(p.setReset(s) ,t...); } -#endif -// other flags flags -template -constexpr auto parseProperty(const PropInfo &p, std::integral_constant, Tail... t) -{ return parseProperty(p.template addFlag() ,t...); } - -template -constexpr auto makeMetaPropertyInfo(StringView name, StringView type, Args... args) { - auto meta = MetaPropertyInfo{ name, type, {}, {}, {}, {}, {} }; - return parseProperty(meta, args...); -} - -template struct EnumIsScoped { - enum { Value = std::is_convertible::value ? 0 : 2 }; -}; -template struct EnumIsScoped, void> : EnumIsScoped::enum_type> {}; - -template struct QEnumOrQFlags { using Type = T; }; -template struct QEnumOrQFlags> { using Type = T; }; - -/// Holds information about an enum -template -struct MetaEnumInfo { - StringView name; - StringView alias; - Names names; - using Values = Values_; - static constexpr uint flags = Flags; - static constexpr auto count = Values::size(); - static constexpr auto sequence = make_index_sequence{}; - static constexpr auto hasAlias = HasAlias; -}; -template struct enum_sequence {}; -// called from W_ENUM and W_FLAG -template -constexpr auto makeMetaEnumInfo(StringView name, int, enum_sequence, Names names) - -> MetaEnumInfo, Names, Flag | EnumIsScoped::Value> { - return { name, viewLiteral(""), names }; -} -template -constexpr auto makeMetaEnumInfo(StringView name, StringView alias, enum_sequence, Names names) - -> MetaEnumInfo, Names, Flag | EnumIsScoped::Value> { - return { name, alias, names }; -} - -// Helper function to remove the scope in a scoped enum name. (so "Foo::Bar" -> Bar) -template constexpr int removedScopeSize(const char (&name)[N]) { - // Find the position of the last colon (or 0 if it is not there) - int p = N - 1; - while (p > 0 && name[p] != ':') - p--; - if (name[p] == ':') - p++; - return N - p; -} - -/// Helper for the implementation of a signal. -/// Called from the signal implementation within the W_SIGNAL macro. -/// -/// 'Func' is the type of the signal. 'Idx' is the signal index (relative). -/// It is implemented as a functor so the operator() has exactly the same amount of argument of the -/// signal so the __VA_ARGS__ works also if there is no arguments (no leading commas) -/// -/// There is specialization for const and non-const, and for void and non-void signals. -/// -/// the last argument of the operator() is an int, to workaround the ",0" required in the W_SIGNAL -/// macro to make sure there is at least one argument for the ... -template struct SignalImplementation {}; -template -struct SignalImplementation{ - Obj *this_; - Ret operator()(Args... args, int) const { - Ret r{}; - const void * a[]= { std::addressof(r), std::addressof(args)... }; - QMetaObject::activate(this_, &Obj::staticMetaObject, Idx, const_cast(a)); - return r; - } -}; -template -struct SignalImplementation{ - Obj *this_; - void operator()(Args... args, int) { - const void * a[]= { nullptr, std::addressof(args)... }; - QMetaObject::activate(this_, &Obj::staticMetaObject, Idx, const_cast(a)); - } -}; -template -struct SignalImplementation{ - const Obj *this_; - Ret operator()(Args... args, int) const { - Ret r{}; - const void * a[]= { std::addressof(r), std::addressof(args)... }; - QMetaObject::activate(const_cast(this_), &Obj::staticMetaObject, Idx, const_cast(a)); - return r; - } -}; -template -struct SignalImplementation{ - const Obj *this_; - void operator()(Args... args, int) { - const void * a[]= { nullptr, std::addressof(args)... }; - QMetaObject::activate(const_cast(this_), &Obj::staticMetaObject, Idx, const_cast(a)); - } -}; - -/// Used in the W_OBJECT macro to compute the base type. -/// Used like this: -/// using W_BaseType = std::remove_reference_t; -/// Since qt_metacast for W_ThisType will be declared later, the pointer to member function will be -/// pointing to the qt_metacast of the base class, so T will be deduced to the base class type. -/// -/// Returns a reference so this work if T is an abstract class. -template T &getParentObjectHelper(void* (T::*)(const char*)); - -// helper class that can access the private member of any class with W_OBJECT -struct FriendHelper; - -inline namespace w_ShouldBeInQt { -// qOverload is already in Qt 5.7, but we need it with older version. -// Note that as of Qt 5.11, it is still not enabled with MSVC as Qt relies on feature macro. -template -struct QNonConstOverload -{ - template - constexpr auto operator()(R (T::*ptr)(Args...)) const - { return ptr; } -}; -template -struct QConstOverload -{ - template - constexpr auto operator()(R (T::*ptr)(Args...) const) const - { return ptr; } -}; -template -struct QOverload : QConstOverload, QNonConstOverload -{ - using QConstOverload::operator(); - using QNonConstOverload::operator(); - - template - constexpr auto operator()(R (*ptr)(Args...)) const - { return ptr; } -}; -template constexpr QOverload qOverload = {}; - -#ifndef QT_ANNOTATE_CLASS // Was added in Qt 5.6.1 -#define QT_ANNOTATE_CLASS(...) -#endif -} // namespace w_ShouldBeInQt - -} // namespace w_internal - -#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) -// Workaround for MSVC: expension rules are different so we need some extra macro. -#define W_MACRO_MSVC_EXPAND(...) __VA_ARGS__ -#define W_MACRO_MSVC_DELAY(X,...) W_MACRO_MSVC_EXPAND(X(__VA_ARGS__)) -#define W_MACRO_MSVC_EMPTY /##* *##/ -#else -#define W_MACRO_MSVC_EXPAND(...) __VA_ARGS__ -#define W_MACRO_MSVC_DELAY(X,...) X(__VA_ARGS__) -#define W_MACRO_MSVC_EMPTY -#endif - -// Private macro helpers for macro programming -#define W_MACRO_EMPTY -#define W_MACRO_EVAL(...) __VA_ARGS__ -#define W_MACRO_DELAY(X,...) W_MACRO_MSVC_EXPAND(X(__VA_ARGS__)) -#define W_MACRO_DELAY2(X,...) W_MACRO_MSVC_EXPAND(X(__VA_ARGS__)) -#define W_MACRO_TAIL(A, ...) __VA_ARGS__ -#define W_MACRO_FIRST(...) W_MACRO_MSVC_EXPAND(W_MACRO_FIRST2(__VA_ARGS__,)) -#define W_MACRO_FIRST2(A, ...) A -#define W_MACRO_STRIGNIFY(...) W_MACRO_STRIGNIFY2(__VA_ARGS__) -#define W_MACRO_STRIGNIFY2(...) #__VA_ARGS__ -#define W_MACRO_CONCAT(A, B) W_MACRO_CONCAT2(A,B) -#define W_MACRO_CONCAT2(A, B) A##_##B - -// strignify and make a StaticStringList out of an array of arguments -#define W_PARAM_TOSTRING(...) W_MACRO_MSVC_EMPTY W_MACRO_MSVC_DELAY(W_PARAM_TOSTRING2,__VA_ARGS__) -#define W_PARAM_TOSTRING2(...) w_internal::viewParsedLiterals("" #__VA_ARGS__) - -#define W_PARAM_TOSTRING_REMOVE_SCOPE(...) W_MACRO_MSVC_EMPTY W_MACRO_MSVC_DELAY(W_PARAM_TOSTRING2_REMOVE_SCOPE,__VA_ARGS__) -#define W_PARAM_TOSTRING2_REMOVE_SCOPE(...) w_internal::viewScopedLiterals("" #__VA_ARGS__) - -// remove the surrounding parentheses -#define W_MACRO_REMOVEPAREN(A) W_MACRO_DELAY(W_MACRO_REMOVEPAREN2, W_MACRO_REMOVEPAREN_HELPER A) -#define W_MACRO_REMOVEPAREN2(...) W_MACRO_DELAY2(W_MACRO_TAIL, W_MACRO_REMOVEPAREN_HELPER_##__VA_ARGS__) -#define W_MACRO_REMOVEPAREN_HELPER(...) _ , __VA_ARGS__ -#define W_MACRO_REMOVEPAREN_HELPER_W_MACRO_REMOVEPAREN_HELPER , - -// if __VA_ARGS__ is "(types), foobar" then return just the types, otherwise return nothing -#define W_OVERLOAD_TYPES(...) W_MACRO_DELAY(W_OVERLOAD_TYPES2,W_OVERLOAD_TYPES_HELPER __VA_ARGS__,) -#define W_OVERLOAD_TYPES2(A,...) W_MACRO_DELAY2(W_OVERLOAD_TYPES3, W_OVERLOAD_TYPES_HELPER_##A ...) -#define W_OVERLOAD_TYPES3(A,...) W_MACRO_EVAL A -#define W_OVERLOAD_TYPES_HELPER(...) YES(__VA_ARGS__) -#define W_OVERLOAD_TYPES_HELPER_W_OVERLOAD_TYPES_HELPER (), -#define W_OVERLOAD_TYPES_HELPER_YES(...) (__VA_ARGS__), - -#define W_OVERLOAD_RESOLVE(...) W_MACRO_DELAY(W_OVERLOAD_RESOLVE2,W_OVERLOAD_RESOLVE_HELPER __VA_ARGS__,) -#define W_OVERLOAD_RESOLVE2(A, ...) W_MACRO_DELAY2(W_MACRO_FIRST,W_OVERLOAD_RESOLVE_HELPER_##A) -#define W_OVERLOAD_RESOLVE_HELPER(...) YES(w_internal::qOverload<__VA_ARGS__>) -#define W_OVERLOAD_RESOLVE_HELPER_YES(...) (__VA_ARGS__) -#define W_OVERLOAD_RESOLVE_HELPER_W_OVERLOAD_RESOLVE_HELPER , - - -// remove the first argument if it is in parentheses" -#define W_OVERLOAD_REMOVE(...) W_MACRO_DELAY(W_OVERLOAD_REMOVE2, W_OVERLOAD_REMOVE_HELPER __VA_ARGS__) -#define W_OVERLOAD_REMOVE2(...) W_MACRO_DELAY2(W_MACRO_TAIL, W_OVERLOAD_REMOVE_HELPER_##__VA_ARGS__) - -#define W_OVERLOAD_REMOVE_HELPER(...) _ -#define W_OVERLOAD_REMOVE_HELPER_W_OVERLOAD_REMOVE_HELPER , - -#define W_RETURN(R) -> decltype(R) { return R; } - -#ifndef Q_CC_MSVC -//Define a unique integral_constant type for a given function pointer -#define W_INTEGRAL_CONSTANT_HELPER(NAME, ...) std::integral_constant -#else -// On MSVC 2017 we trying to get a function pointer in the type cause compiler internal error, so use a simple hash function -namespace w_internal { -constexpr auto simple_hash(char const *p) { - unsigned long long h = *p; - while (*p++) h = ((h >> 8)*37ull) ^ *p ^ ((h & 0xff) << 56) ; - return h; -} -} // namespace w_internal -#define W_INTEGRAL_CONSTANT_HELPER(NAME, ...) std::integral_constant -#endif - -namespace w_internal { - -/// We store state in overloads for this method. -/// This overload is found if no better overload was found. -/// All overloads are found using ADL in the QObject T -template -void w_state(IndexBase, State, TPP); - -#if __cplusplus > 201700L -template -constexpr size_t countBetween() { - using R = decltype(w_state(index, State{}, TPP{})); - if constexpr (N==X) { - return std::is_same_v ? N : M; - } - else if constexpr (std::is_same_v) { - return countBetween(); - } - else { - return countBetween(); - } -} -template -constexpr size_t count() { - using R = decltype(w_state(index, State{}, TPP{})); - if constexpr (std::is_same_v) { - return countBetween(); - } - else { - return count(); - } -} - -template -constexpr auto stateCount = count(); -#else -template, State{}, TPP{}))>::value - , bool up = N==X> -struct CountBetween; - -template -struct CountBetween { - static constexpr auto value = N; -}; -template -struct CountBetween { - static constexpr auto value = M; -}; -template -struct CountBetween { - static constexpr auto value = CountBetween::value; -}; -template -struct CountBetween { - static constexpr auto value = CountBetween::value; -}; - -template, State{}, TPP{}))>::value> -struct Count; - -template -struct Count { - static constexpr auto value = CountBetween::value; -}; -template -struct Count { - static constexpr auto value = Count::value; -}; - -template -constexpr auto stateCount = Count::value; -#endif - -struct SlotStateTag {}; -struct SignalStateTag {}; -struct MethodStateTag {}; -struct ConstructorStateTag {}; -struct PropertyStateTag {}; -struct EnumStateTag {}; -struct ClassInfoStateTag {}; -struct InterfaceStateTag {}; - -} // namespace w_internal - -#define W_OBJECT_COMMON(TYPE) \ - using W_ThisType = TYPE; \ - static constexpr auto W_UnscopedName = w_internal::viewLiteral(#TYPE); /* so we don't repeat it in W_CONSTRUCTOR */ \ - friend struct w_internal::FriendHelper; \ - template static inline constexpr int w_flagAlias(W_Flag) { return 0; } \ - public: \ - struct W_MetaObjectCreatorHelper; - -#define W_STATE_APPEND(STATE, ...) \ - friend constexpr auto w_state(w_internal::Index>, \ - w_internal::STATE##Tag, W_ThisType**) W_RETURN((__VA_ARGS__)) -#define W_STATE_APPEND_NS(STATE, ...) \ - static constexpr auto w_state(w_internal::Index>, \ - w_internal::STATE##Tag, W_ThisType**) W_RETURN((__VA_ARGS__)) - -// public macros - -/// \macro W_OBJECT(TYPE) -/// Like the Q_OBJECT macro, this declare that the object might have signals, slots or properties. -/// Must contains the class name as a parameter and need to be put before any other W_ macro in the class. -#define W_OBJECT(TYPE) \ - W_OBJECT_COMMON(TYPE) \ - public: \ - using W_BaseType = std::remove_reference_t; \ - Q_OBJECT \ - QT_ANNOTATE_CLASS(qt_fake, "") - -/// \macro W_GADGET(TYPE) -/// Like the Q_GADGET macro, this declare that the object might have properties. -/// Must contains the class name as a parameter and need to be put before any other W_ macro in the class. -#define W_GADGET(TYPE) \ - W_OBJECT_COMMON(TYPE) \ - Q_GADGET \ - QT_ANNOTATE_CLASS(qt_fake, "") - -/// \macro W_NAMESPACE(NAMESPACE) -/// Like the Q_GADGET macro, this declare that the object might have properties. -/// Must contains the class name as a parameter and need to be put before any other W_ macro in the class. -#define W_NAMESPACE(NAMESPACE) \ - Q_NAMESPACE \ - struct W_MetaObjectCreatorHelper; \ - struct W_ThisType { \ - using W_MetaObjectCreatorHelper = NAMESPACE::W_MetaObjectCreatorHelper; \ - static constexpr auto qt_static_metacall = nullptr; \ - }; \ - static constexpr auto W_UnscopedName = w_internal::viewLiteral(#NAMESPACE); \ - template Q_DECL_UNUSED static inline constexpr int w_flagAlias(W_Flag) { Q_UNUSED(W_UnscopedName) return 0; } \ - QT_ANNOTATE_CLASS(qt_fake, "") - -/// \macro W_SLOT( [, () ] [, ]* ) -/// -/// The W_SLOT macro needs to be put after the slot declaration. -/// -/// The W_SLOT macro can optionally have a list of parameter types as second argument to disambiguate -/// overloads or use types that are not registered with W_REGISTER_ARGTYPE. The list of parameter -/// need to be within parentheses (even if there is 0 or 1 argument). -/// -/// The W_SLOT macro can have flags: -/// - Specifying the the access: W_Access::Protected, W_Access::Private -/// or W_Access::Public. (By default, it is auto-detected from the location of this macro.) -/// - W_Compat: for deprecated methods (equivalent of Q_MOC_COMPAT) -#define W_SLOT(...) W_MACRO_MSVC_EXPAND(W_SLOT2(__VA_ARGS__, w_internal::W_EmptyFlag)) -#define W_SLOT2(NAME, ...) \ - W_STATE_APPEND(SlotState, w_internal::makeMetaSlotInfo( \ - W_OVERLOAD_RESOLVE(__VA_ARGS__)(&W_ThisType::NAME), w_internal::viewLiteral(#NAME), \ - W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)(), \ - W_PARAM_TOSTRING(W_OVERLOAD_TYPES(__VA_ARGS__)), \ - W_OVERLOAD_REMOVE(__VA_ARGS__))) \ - static inline void w_GetAccessSpecifierHelper(W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)) {} - -/// \macro W_INVOKABLE( [, () ] [, ]* ) -/// Exactly like W_SLOT but for Q_INVOKABLE methods. -#define W_INVOKABLE(...) W_MACRO_MSVC_EXPAND(W_INVOKABLE2(__VA_ARGS__, w_internal::W_EmptyFlag)) -#define W_INVOKABLE2(NAME, ...) \ - W_STATE_APPEND(MethodState, w_internal::makeMetaMethodInfo( \ - W_OVERLOAD_RESOLVE(__VA_ARGS__)(&W_ThisType::NAME), w_internal::viewLiteral(#NAME), \ - W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)(), \ - W_PARAM_TOSTRING(W_OVERLOAD_TYPES(__VA_ARGS__)), \ - W_OVERLOAD_REMOVE(__VA_ARGS__))) \ - static inline void w_GetAccessSpecifierHelper(W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)) {} - -/// -/// \macro W_SIGNAL( [, () ] , ) -/// -/// Unlike W_SLOT, W_SIGNAL must be placed directly after the signal signature declaration. -/// There should not be a semi colon between the signal signature and the macro -/// -/// Like W_SLOT, there can be the types of the parametter as a second argument, within parentheses. -/// You must then follow with the parameter names -/// -/// Note about exported classes: since the signal is inline, GCC won't export it when compiling -/// with -fvisibility-inlines-hidden (which is the default), so connecting using pointer to member -/// functions won't work accross library boundaries. You need to explicitly export the signal with -/// your MYLIB_EXPORT macro in front of the signal declaration. -#define W_SIGNAL(...) W_MACRO_MSVC_EXPAND(W_SIGNAL2(__VA_ARGS__ , 0)) -#define W_SIGNAL2(NAME, ...) \ - { /* W_SIGNAL need to be placed directly after the signal declaration, without semicolon. */\ - using w_SignalType = decltype(W_OVERLOAD_RESOLVE(__VA_ARGS__)(&W_ThisType::NAME)); \ - return w_internal::SignalImplementation{this}(W_OVERLOAD_REMOVE(__VA_ARGS__)); \ - } \ - static constexpr int W_MACRO_CONCAT(w_signalIndex_##NAME,__LINE__) = \ - w_internal::stateCount<__COUNTER__, w_internal::SignalStateTag, W_ThisType**>; \ - friend constexpr auto w_state(w_internal::Index, w_internal::SignalStateTag, W_ThisType**) \ - W_RETURN(w_internal::makeMetaSignalInfo( \ - W_OVERLOAD_RESOLVE(__VA_ARGS__)(&W_ThisType::NAME), w_internal::viewLiteral(#NAME), \ - W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)(), \ - W_PARAM_TOSTRING(W_OVERLOAD_TYPES(__VA_ARGS__)), W_PARAM_TOSTRING(W_OVERLOAD_REMOVE(__VA_ARGS__)))) \ - static inline void w_GetAccessSpecifierHelper(W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)) {} - -/// \macro W_SIGNAL_COMPAT -/// Same as W_SIGNAL, but set the W_Compat flag -#define W_SIGNAL_COMPAT(...) W_MACRO_MSVC_EXPAND(W_SIGNAL_COMPAT2(__VA_ARGS__, 0)) -#define W_SIGNAL_COMPAT2(NAME, ...) \ - { \ - using w_SignalType = decltype(W_OVERLOAD_RESOLVE(__VA_ARGS__)(&W_ThisType::NAME)); \ - return w_internal::SignalImplementation{this}(W_OVERLOAD_REMOVE(__VA_ARGS__)); \ - } \ - static constexpr int W_MACRO_CONCAT(w_signalIndex_##NAME,__LINE__) = \ - w_internal::stateCount<__COUNTER__, w_internal::SignalStateTag, W_ThisType**>; \ - friend constexpr auto w_state(w_internal::Index, w_internal::SignalStateTag, W_ThisType**) \ - W_RETURN(w_internal::makeMetaSignalInfo( \ - W_OVERLOAD_RESOLVE(__VA_ARGS__)(&W_ThisType::NAME), w_internal::viewLiteral(#NAME), \ - W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)(), \ - W_PARAM_TOSTRING(W_OVERLOAD_TYPES(__VA_ARGS__)), W_PARAM_TOSTRING(W_OVERLOAD_REMOVE(__VA_ARGS__)), W_Compat)) \ - static inline void w_GetAccessSpecifierHelper(W_INTEGRAL_CONSTANT_HELPER(NAME, __VA_ARGS__)) {} - -/// \macro W_CONSTRUCTOR() -/// Declares that this class can be constructed with this list of argument. -/// Equivalent to Q_INVOKABLE constructor. -/// One can have W_CONSTRUCTOR() for the default constructor even if it is implicit. -#define W_CONSTRUCTOR(...) \ - W_STATE_APPEND(ConstructorState, \ - w_internal::makeMetaConstructorInfo<__VA_ARGS__>(W_UnscopedName)) - - -/// \macro W_PROPERTY(, [, ]*) -/// -/// Declare a property with the type . -/// The flags can be function pointers that are detected to be setter, getters, notify signal or -/// other flags. Use the macro READ, WRITE, MEMBER, ... for the flag so you can write W_PROPERTY -/// just like in a Q_PROPERTY. The only difference with Q_PROPERTY would be the semicolon before the -/// name. -/// W_PROPERTY need to be put after all the setters, getters, signals and members have been declared. -/// -/// can optionally be put in parentheses, if you have a type containing a comma -/// -/// The macro to be used inside W_PROPERTY can also be prefixed by W_ (W_READ, W_WRITE, ...) -/// If you define the macro W_NO_PROPERTY_MACRO in your build settings, the macro without prefix -/// won't be defined. -#define W_PROPERTY(...) W_MACRO_MSVC_EXPAND(W_PROPERTY2(__VA_ARGS__)) // expands the READ, WRITE, and other sub marcos -#define W_PROPERTY2(TYPE, NAME, ...) \ - W_STATE_APPEND(PropertyState, \ - w_internal::makeMetaPropertyInfo(\ - w_internal::viewLiteral(#NAME), w_internal::viewLiteral(W_MACRO_STRIGNIFY(W_MACRO_REMOVEPAREN(TYPE))), __VA_ARGS__)) - -#define W_WRITE , &W_ThisType:: -#define W_READ , &W_ThisType:: -#define W_NOTIFY , W_Notify, &W_ThisType:: -#define W_RESET , W_Reset, &W_ThisType:: -#define W_MEMBER , &W_ThisType:: -#define W_CONSTANT , W_Constant -#define W_FINAL , W_Final - -#ifndef W_NO_PROPERTY_MACRO -#define WRITE W_WRITE -#define READ W_READ -#define NOTIFY W_NOTIFY -//#define RESET W_RESET -#define MEMBER W_MEMBER -#define CONSTANT W_CONSTANT -#define FINAL W_FINAL -#endif - -#undef Q_PRIVATE_PROPERTY // the official macro is not a variadic macro, and the coma in READ would break it -#define Q_PRIVATE_PROPERTY(...) - -/// \macro W_ENUM(, ) -/// Similar to Q_ENUM, but one must also manually write all the values. -#define W_ENUM(NAME, ...) \ - W_STATE_APPEND(EnumState, w_internal::makeMetaEnumInfo( \ - w_internal::viewLiteral(#NAME), w_flagAlias(NAME{}), \ - w_internal::enum_sequence{}, W_PARAM_TOSTRING_REMOVE_SCOPE(__VA_ARGS__))) \ - Q_ENUM(NAME) - - -/// \macro W_ENUM_NS(, ) -/// Similar to Q_ENUM_NS, like W_ENUM -#define W_ENUM_NS(NAME, ...) \ - W_STATE_APPEND_NS(EnumState, w_internal::makeMetaEnumInfo( \ - w_internal::viewLiteral(#NAME), w_flagAlias(NAME{}), \ - w_internal::enum_sequence{}, W_PARAM_TOSTRING_REMOVE_SCOPE(__VA_ARGS__))) \ - Q_ENUM_NS(NAME) - -/// \macro W_FLAG(, ) -/// Similar to Q_FLAG, but one must also manually write all the values. -#define W_FLAG(NAME, ...) \ - W_STATE_APPEND(EnumState, w_internal::makeMetaEnumInfo::Type,true>( \ - w_internal::viewLiteral(#NAME), w_flagAlias(NAME{}), \ - w_internal::enum_sequence::Type,__VA_ARGS__>{}, \ - W_PARAM_TOSTRING_REMOVE_SCOPE(__VA_ARGS__))) \ - Q_FLAG(NAME) - -/// \macro W_FLAG_NS(, ) -/// Similar to Q_FLAG_NS, like W_FLAG. -#define W_FLAG_NS(NAME, ...) \ - W_STATE_APPEND_NS(EnumState, w_internal::makeMetaEnumInfo::Type,true>( \ - w_internal::viewLiteral(#NAME), w_flagAlias(NAME{}), \ - w_internal::enum_sequence::Type,__VA_ARGS__>{}, \ - W_PARAM_TOSTRING_REMOVE_SCOPE(__VA_ARGS__))) \ - Q_FLAG_NS(NAME) - -/// Same as Q_CLASSINFO. Note, Q_CLASSINFO_NS is required for namespace -#define W_CLASSINFO(A, B) \ - W_STATE_APPEND(ClassInfoState, \ - std::pair{ w_internal::viewLiteral(A), w_internal::viewLiteral(B) }) - -/// Same as Q_CLASSINFO, but within a namespace -#define W_CLASSINFO_NS(A, B) \ - W_STATE_APPEND_NS(ClassInfoState, \ - std::pair{ w_internal::viewLiteral(A), w_internal::viewLiteral(B) }) - -/// Same as Q_INTERFACE -#define W_INTERFACE(A) \ - W_STATE_APPEND(InterfaceState, static_cast(nullptr)) - -/// Same as Q_DECLARE_FLAGS -#define W_DECLARE_FLAGS(Flags, Enum) \ - Q_DECLARE_FLAGS(Flags, Enum) \ - static inline constexpr w_internal::StringView w_flagAlias(Flags) { return w_internal::viewLiteral(#Enum); } - -/// \macro W_REGISTER_ARGTYPE(TYPE) -/// Registers TYPE so it can be used as a parameter of a signal/slot or return value. -/// The normalized signature must be used. -/// Note: This does not imply Q_DECLARE_METATYPE, and Q_DECLARE_METATYPE does not imply this -namespace w_internal { template struct W_TypeRegistery { enum { registered = false }; }; } -#define W_REGISTER_ARGTYPE(...) namespace w_internal { \ - template<> struct W_TypeRegistery<__VA_ARGS__> { \ - enum { registered = true }; \ - static constexpr auto name = viewLiteral(#__VA_ARGS__); \ - };} -W_REGISTER_ARGTYPE(char*) -W_REGISTER_ARGTYPE(const char*) - -#else // Q_MOC_RUN -// just to avoid parse errors when moc is run over things that it should ignore -#define W_SIGNAL(...) ; -#define W_SIGNAL_COMPAT(...) ; -#define W_PROPERTY(...) -#define W_SLOT(...) -#define W_CLASSINFO(...) -#define W_INTERFACE(...) -#define W_CONSTRUCTOR(...) -#define W_FLAG(...) -#define W_ENUM(...) -#define W_DECLARE_FLAGS(...) -#endif diff --git a/QtRpa/include/common/wobjectimpl.h b/QtRpa/include/common/wobjectimpl.h deleted file mode 100644 index 7485c4e..0000000 --- a/QtRpa/include/common/wobjectimpl.h +++ /dev/null @@ -1,1157 +0,0 @@ -/**************************************************************************** - * Copyright (C) 2016-2018 Woboq GmbH - * Olivier Goffart - * https://woboq.com/ - * - * This file is part of Verdigris: a way to use Qt without moc. - * https://github.com/woboq/verdigris - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program. If not, see . - */ -#pragma once - -#include "wobjectdefs.h" -#include - -namespace w_internal { - -// Match MetaDataFlags constants form the MetaDataFlags in qmetaobject_p.h -enum : uint { IsUnresolvedType = 0x80000000, IsUnresolvedNotifySignal = 0x70000000 }; - -/// all details about a class T -template -struct ObjectInfo { - using Type = T; - static constexpr auto counter = L; - static constexpr auto name = StringView{Name::value}; - - static constexpr int signalCount = stateCount; - static constexpr int slotCount = stateCount; - static constexpr int methodCount = signalCount + slotCount + stateCount; - static constexpr int constructorCount = stateCount; - static constexpr int propertyCount = stateCount; - static constexpr int enumCount = stateCount; - static constexpr int classInfoCount = stateCount; - static constexpr int interfaceCount = stateCount; - - static constexpr auto methodSequence = make_index_sequence{}; - static constexpr auto constructorSequence = make_index_sequence{}; - static constexpr auto propertySequence = make_index_sequence{}; - static constexpr auto interfaceSequence = make_index_sequence{}; - -#if __cplusplus > 201700L - template - static constexpr auto method(Index) { - using TPP = T**; - if constexpr (Idx < signalCount) return w_state(index, SignalStateTag{}, TPP{}); - else if constexpr (Idx - signalCount < slotCount) return w_state(index, SlotStateTag{}, TPP{}); - else return w_state(index, MethodStateTag{}, TPP{}); - } -#else - template - static constexpr auto method(Index, std::enable_if_t<(Idx < signalCount)>* = {}) { - using TPP = T**; - return w_state(index, SignalStateTag{}, TPP{}); - } - template - static constexpr auto method(Index, std::enable_if_t<(Idx >= signalCount && Idx - signalCount < slotCount)>* = {}) { - using TPP = T**; - return w_state(index, SlotStateTag{}, TPP{}); - } - template - static constexpr auto method(Index, std::enable_if_t<(Idx >= signalCount + slotCount)>* = {}) { - using TPP = T**; - return w_state(index, MethodStateTag{}, TPP{}); - } -#endif -}; - -template -constexpr void fold(index_sequence, F&& f) { - (void)f; -#if __cplusplus > 201700L - (f(index), ...); -#else - ordered((f(index),0)...); -#endif -} - -#if __cplusplus > 201700L -template -constexpr void foldState(F&& f) { - fold(make_index_sequence>{}, [&](auto i) { f(w_state(i, State{}, TPP{}), i); }); -} -#else -template -struct FoldState { - F&& f; - template - constexpr void operator() (I i) { f(w_state(i, State{}, TPP{}), i); } -}; -template -constexpr void foldState(F&& f) { - auto fs = FoldState{std::forward(f)}; - fold(make_index_sequence>{}, fs); -} -#endif - -template -constexpr void foldMethods(F&& f) { - foldState(f); - foldState(f); - foldState(f); -} - -template -constexpr auto fetchExplicitName(const StringView& defaultName, ...) { - return defaultName; -} - -template -constexpr auto fetchExplicitName(const StringView&, int) -> decltype (w_explicitObjectName(static_cast(nullptr))) { - return w_explicitObjectName(static_cast(nullptr)); -} - -/// Helper to get information about the notify signal of the property within object T -template -struct ResolveNotifySignal { -private: - using TP = T**; - using OP = O**; - static constexpr auto prop = w_state(index, PropertyStateTag{}, TP{}); - - template, SignalStateTag{}, OP{}).func == prop.notify> - static constexpr auto match(int) { return Eq; } - template - static constexpr auto match(float) { return false; } - - template - static constexpr int indexFold(index_sequence) { - int r = -1; -#if __cplusplus > 201700L - ((match(0) ? r = (int)Is : 0), ...); -#else - ordered2({(match(0) ? r = (int)Is : 0)...}); -#endif - return r; - } -public: - static constexpr int signalIndex() { - return indexFold(make_index_sequence>{}); - } -}; - -/// returns true if the object T has at least one property with a notify signal -#if __cplusplus > 201700L -template -constexpr bool hasNotifySignal() { - auto r = bool{}; - foldState([&](auto p, auto) { - r = r || !std::is_same::value; - }); - return r; -} -#else -struct HasNotifySignal { - bool r{}; - template - constexpr void operator() (P p, I) { - r = r || !std::is_same::value; - } -}; -template -constexpr bool hasNotifySignal() { - auto hns = HasNotifySignal{}; - foldState(hns); - return hns.r; -} -#endif - - -template -struct ClassInfoGenerator { - State& s; - constexpr ClassInfoGenerator(State& s) : s(s) {} - - template - constexpr void operator() (const ClassInfo& ci, Index) { - s.addString(ci.first); - s.addString(ci.second); - } -}; - -/// auto-detect the access specifiers -template -auto test_public(int) -> std::enable_if_t::value, std::true_type>; -template -auto test_public(float) -> std::false_type; -template -using isPublic = decltype(test_public(0)); - -template struct isProtected : std::false_type {}; -template ::value>> -struct Derived : T { template static decltype(X::w_GetAccessSpecifierHelper(std::declval())) test(M); }; -template struct isProtected::test(std::declval()))> : std::true_type {}; - -template -struct MethodGenerator { - State& s; - int parameterIndex; - MethodGenerator(const MethodGenerator&) = delete; - constexpr MethodGenerator(State& s, int pi) : s(s), parameterIndex(pi) {} - - template - constexpr void operator() (const Method& method, Index) { - s.addString(method.name); // name - s.addInts((uint)Method::argCount, - parameterIndex, //parameters - 1, //tag, always \0 - adjustFlags(Method::flags, typename Method::IntegralConstant())); - parameterIndex += 1 + Method::argCount * 2; - } - -private: - template - static constexpr uint adjustFlags(uint f, M) { - if (!(f & (W_Access::Protected.value | W_Access::Private.value | W_Access::Public.value))) { - // Auto-detect the access specifier - f |= isPublic::value ? W_Access::Public.value : isProtected::value ? W_Access::Protected.value : W_Access::Private.value; - } - return f & static_cast(~W_Access::Private.value); // Because QMetaMethod::Private is 0, but not W_Access::Private; - } -}; - -/// compute if type T is a builtin QMetaType -template struct MetaTypeIdIsBuiltIn : std::false_type {}; -template struct MetaTypeIdIsBuiltIn::IsBuiltIn>::type> : std::true_type{}; - -/// Helper to generate the type information of type 'T': -/// If T is a builtin QMetaType, its meta type id need to be added in the state. -/// If it's not builtin, then it would be an reference to T's name. -#if __cplusplus > 201700L -template -constexpr void handleType(State& s, TypeStr v = {}) { - (void)v; - if constexpr (MetaTypeIdIsBuiltIn::value) { - s.addInts(QMetaTypeId2::MetaType); - } - else if constexpr (std::is_same_v, StringView>) { - s.addTypeString(v); - } - else { - s.addTypeString(W_TypeRegistery::name); - static_assert(W_TypeRegistery::registered, "Please Register T with W_REGISTER_ARGTYPE"); - } -} -#else -template -constexpr void handleType(State& s, TypeStr = {}, std::enable_if_t::value>* = {}) { - s.addInts(QMetaTypeId2::MetaType); -} -template -constexpr void handleType(State& s, TypeStr = {}, std::enable_if_t::value>* = {}) { - s.addTypeString(W_TypeRegistery::name); - static_assert(W_TypeRegistery::registered, "Please Register T with W_REGISTER_ARGTYPE"); -} -template -constexpr void handleType(State& s, StringView v, std::enable_if_t::value>* = {}) { - s.addTypeString(v); -} -#endif - -template -struct PropertyGenerator { - State& s; - constexpr PropertyGenerator(State& s) : s(s) {} - - template - constexpr void operator() (const Prop& prop, Index) { - s.addString(prop.name); - handleType(s, prop.typeStr); - constexpr uint moreFlags = (QtPrivate::IsQEnumHelper::Value - ? uint(PropertyFlags::EnumOrFlag) : 0); - constexpr uint finalFlag = std::is_final::value ? 0 | PropertyFlags::Final : 0; - constexpr uint defaultFlags = 0 | PropertyFlags::Stored | PropertyFlags::Scriptable - | PropertyFlags::Designable; - s.addInts(Prop::flags | moreFlags | finalFlag | defaultFlags); - } -}; - -#if __cplusplus > 201700L -template -struct NotifySignalGenerator { -#else -template -struct NotifySignalGenerator; -template -struct NotifySignalGenerator { - constexpr NotifySignalGenerator(State&) {} - template - constexpr void operator() (const Prop&, Index) {} -}; -template -struct NotifySignalGenerator { -#endif - using TP = T**; - State& s; - constexpr NotifySignalGenerator(State& s) : s(s) {} - -#if __cplusplus > 201700L - template - constexpr void operator() (const Prop& prop, Index) { - if constexpr (hasNotify) { - process(prop.notify, index); - } - } -#else - template - constexpr void operator() (const Prop& prop, Index) { - process(prop.notify, index); - } -#endif - -private: - template - constexpr void process(Empty, Index) { - s.addInts(0); - } - - // Signal in the same class - template - constexpr void process(Func, Index, std::enable_if_t::Object>::value, int> = 0) { - constexpr int signalIndex = ResolveNotifySignal::signalIndex(); - static_assert(signalIndex >= 0, "NOTIFY signal in parent class not registered as a W_SIGNAL"); - s.addInts(signalIndex); - } - - // Signal in a parent class - template - constexpr void process(Func, Index, std::enable_if_t::Object>::value, int> = 0) { - using O = typename QtPrivate::FunctionPointer::Object; - using OP = O**; - constexpr int signalIndex = ResolveNotifySignal::signalIndex(); - static_assert(signalIndex >= 0, "NOTIFY signal in parent class not registered as a W_SIGNAL"); - static_assert(signalIndex < 0 || QT_VERSION >= QT_VERSION_CHECK(5, 10, 0), - "NOTIFY signal in parent class requires Qt 5.10"); - constexpr auto sig = w_state(index, SignalStateTag{}, OP{}); - s.template addTypeString(sig.name); - } -}; - -template -struct EnumGenerator { - State& s; - int dataIndex{}; - EnumGenerator(const EnumGenerator&) = delete; - constexpr EnumGenerator(State& s, int di) : s(s), dataIndex(di) {} - - template - constexpr void operator() (const Enum& e, Index) { - auto nameIndex = s.stringCount; // required for MSVC-2019 - (void)nameIndex; - s.addString(e.name); // name -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) -#if __cplusplus > 201700L - if constexpr (Enum::hasAlias) s.addString(e.alias); // alias -#else - if (Enum::hasAlias) s.addString(e.alias); // alias -#endif - else s.addInts(nameIndex); -#endif - s.addInts(Enum::flags, (uint)Enum::count, dataIndex); - dataIndex += Enum::count * 2; - } -}; - -template -struct EnumValuesGenerator { - State& s; - constexpr EnumValuesGenerator(State& s) : s(s) {} - - template - constexpr void operator() (const Enum& e, Index) { - generateAll(typename Enum::Values{}, e.names, Enum::sequence); - } - -private: - template - constexpr void generateAll(index_sequence, const Names& names, index_sequence) { -#if __cplusplus > 201700L - ((s.addString(names[Is]), s.addInts((uint)Values)), ...); -#else - ordered((s.addString(names[Is]), s.addInts((uint)Values), 0)...); -#endif - } -}; - -#if __cplusplus > 201700L -template -constexpr auto stringFetch(const StringViewArray& s) { - if constexpr (I < N) { - return s[I]; - } - else { - (void)s; - struct _{}; - return _{}; - } -} -#else -template -constexpr auto stringFetch(const StringViewArray& s, std::enable_if_t<(I < N)>* = {}) { - return s[I]; -} -template -constexpr auto stringFetch(const StringViewArray& s, std::enable_if_t* = {}) { - (void)s; - struct _{}; - return _{}; -} -#endif -template -constexpr void handleArgType(State& ss, const TypeName& typeName) { - using Type = typename QtPrivate::RemoveConstRef::Type; - // This way, the overload of result will not pick the StringView one if it is a tuple (because registered types have the priority) - auto typeName2 = std::conditional_t::value, TypeName, std::tuple>{typeName}; - handleType(ss, typeName2); -} -template -constexpr void handleArgTypes(State& ss, const TypeNames& typeNames, index_sequence) { -#if __cplusplus > 201700L - (handleArgType(ss, stringFetch(typeNames)), ...); -#else - ordered((handleArgType(ss, stringFetch(typeNames)), 0)...); -#endif -} - -template -constexpr void handleArgNames(State& ss, const StringViewArray& paramNames) { - auto i = size_t{}; - for (; i < ArgCount && i < NameCount; ++i) ss.addString(paramNames[i]); - for (; i < ArgCount; ++i) ss.addInts(1); -} - -template -struct MethodParametersGenerator { - State& s; - constexpr MethodParametersGenerator(State& s) : s(s) {} - template - constexpr void operator() (const Method& method, Index) { - generateSingleMethodParameter(method.func, method); - } - -private: - // non-const function - template - constexpr void generateSingleMethodParameter(Ret (Obj::*)(Args...), const Method &method) { - handleType(s); - handleArgTypes(s, method.paramTypes, Method::argSequence); - handleArgNames(s, method.paramNames); - } -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 - template - constexpr void generateSingleMethodParameter(Ret (Obj::*)(Args...) noexcept, const Method &method) { - handleType(s); - handleArgTypes(s, method.paramTypes, Method::argSequence); - handleArgNames(s, method.paramNames); - } -#endif - template - // const function - constexpr void generateSingleMethodParameter(Ret (Obj::*)(Args...) const, const Method &method) { - handleType(s); - handleArgTypes(s, method.paramTypes, Method::argSequence); - handleArgNames(s, method.paramNames); - } -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 - template - constexpr void generateSingleMethodParameter(Ret (Obj::*)(Args...) const noexcept, const Method &method) { - handleType(s); - handleArgTypes(s, method.paramTypes, Method::argSequence); - handleArgNames(s, method.paramNames); - } -#endif - // static member functions - template - constexpr void generateSingleMethodParameter(Ret (*)(Args...), const Method &method) { - handleType(s); - handleArgTypes(s, method.paramTypes, Method::argSequence); - handleArgNames(s, method.paramNames); - } -#if defined(__cpp_noexcept_function_type) && __cpp_noexcept_function_type >= 201510 - template - constexpr void generateSingleMethodParameter(Ret (*)(Args...) noexcept, const Method &method) { - handleType(s); - handleArgTypes(s, method.paramTypes, Method::argSequence); - handleArgNames(s, method.paramNames); - } -#endif -}; - -template -struct ConstructorParametersGenerator { - State& s; - constexpr ConstructorParametersGenerator(State& s) : s(s) {} - - template - constexpr void operator() (const MetaConstructorInfo& info, Index) { - s.addInts(IsUnresolvedType | 1); - handleArgTypes(s, StringViewArray<>{}, info.argSequence); - s.addInts(((void)sizeof(Args),1)...); // all the names are 1 (for "\0") - } -}; - -/// Given method, a binary::tree containing information about methods or constructor, -/// return the amount of item it will add in the int array. -#if __cplusplus > 201700L -template -constexpr int methodsParamOffset() { - auto sum = int{}; - foldMethods([&](auto m, auto) { sum += int(1 + m.argCount * 2); }); - return sum; -} -#else -struct MethodParamOffset { - int sum{}; - template - constexpr void operator() (M m, I) { sum += int(1 + m.argCount * 2); } -}; -template -constexpr int methodsParamOffset() { - auto mpo = MethodParamOffset{}; - foldMethods(mpo); - return mpo.sum; -} -#endif -#if __cplusplus > 201700L -template -constexpr int constructorParamOffset() { - auto sum = int{}; - foldState([&](auto m, auto) { sum += int(1 + m.argCount * 2); }); - return sum; -} -#else -struct ConstructorParamOffset { - int sum{}; - template - constexpr void operator() (M m, I) { sum += int(1 + m.argCount * 2); } -}; -template -constexpr int constructorParamOffset() { - auto cpo = ConstructorParamOffset{}; - foldState(cpo); - return cpo.sum; -} - -#endif - -template using RawArray = T[N]; -template struct OwnArray { - RawArray data{}; - constexpr OwnArray(const T (&s)[N]) { - auto p = data; - for (auto c : s) *p++ = c; - } -}; - -struct LayoutBuilder { - size_t stringSize{}; - uint stringCount{}; - uint intCount{}; - - constexpr void addString(const StringView& s) { - stringSize += s.size() + 1; - stringCount += 1; - intCount += 1; - } - constexpr void addStringUntracked(const StringView& s) { - stringSize += s.size() + 1; - stringCount += 1; - } - template - constexpr void addTypeString(const StringView& s) { - stringSize += s.size() + 1; - stringCount += 1; - intCount += 1; - } - template - constexpr void addInts(Ts...) { - intCount += sizeof... (Ts); - } -}; -struct DataBuilder { - char* stringCharP{}; - qptrdiff* stringOffestP{}; - int* stringLengthP{}; - uint* intP{}; - uint stringCount{}; - uint intCount{}; - qptrdiff stringOffset{}; - - constexpr DataBuilder() = default; - DataBuilder(const DataBuilder&) = delete; - template - constexpr DataBuilder(Holder& r) - : stringCharP(r.stringChars) - , stringOffestP(r.stringOffsets) - , stringLengthP(r.stringLengths) - , intP(r.ints) - , stringOffset(r.stringOffset) {} - - constexpr void addString(const StringView& s) { - for (auto c : s) *stringCharP++ = c; - *stringCharP++ = '\0'; - *stringOffestP++ = stringOffset; - *stringLengthP++ = s.size(); - *intP++ = stringCount; - stringOffset += 1 + s.size() - qptrdiff(sizeof(QByteArrayData)); - stringCount += 1; - intCount += 1; - } - constexpr void addStringUntracked(const StringView& s) { - for (auto c : s) *stringCharP++ = c; - *stringCharP++ = '\0'; - *stringOffestP++ = stringOffset; - *stringLengthP++ = s.size(); - stringOffset += 1 + s.size() - qptrdiff(sizeof(QByteArrayData)); - stringCount += 1; - } - - template - constexpr void addTypeString(const StringView& s) { - for (auto c : s) *stringCharP++ = c; - *stringCharP++ = '\0'; - *stringOffestP++ = stringOffset; - *stringLengthP++ = s.size(); - *intP++ = Flag | stringCount; - stringOffset += 1 + s.size() - qptrdiff(sizeof(QByteArrayData)); - stringCount += 1; - intCount += 1; - } - template - constexpr void addInts(Ts... vs) { -#if __cplusplus > 201700L - ((*intP++ = vs),...); -#else - ordered2({(*intP++ = vs)...}); -#endif - intCount += sizeof... (Ts); - } -}; - - -/// fold ObjectInfo into State -template -constexpr void generateDataPass(State& state) { - using ObjI = typename T::W_MetaObjectCreatorHelper::ObjectInfo; - constexpr size_t L = ObjI::counter; - constexpr bool hasNotify = hasNotifySignal(); - constexpr int classInfoOffset = 14; - constexpr int methodOffset = classInfoOffset + ObjI::classInfoCount * 2; - constexpr int propertyOffset = methodOffset + ObjI::methodCount * 5; - constexpr int enumOffset = propertyOffset + ObjI::propertyCount * (hasNotify ? 4: 3); - constexpr int constructorOffset = enumOffset + ObjI::enumCount * (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) ? 5 : 4); - constexpr int paramIndex = constructorOffset + ObjI::constructorCount * 5 ; - constexpr int constructorParamIndex = paramIndex + methodsParamOffset(); - constexpr int enumValueOffset = constructorParamIndex + constructorParamOffset(); - - state.addInts(QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) ? 8 : 7); // revision - state.addString(ObjI::name); - state.addStringUntracked(viewLiteral("")); - state.addInts( - ObjI::classInfoCount, classInfoOffset, // classinfo - ObjI::methodCount, methodOffset, // methods - ObjI::propertyCount, propertyOffset, // properties - ObjI::enumCount, enumOffset, // enums/sets - ObjI::constructorCount, constructorOffset, // constructors - 0x4 /* PropertyAccessInStaticMetaCall */, // flags - ObjI::signalCount); - - //if (state.intCount != classInfoOffset) throw "offset mismatch!"; - foldState(ClassInfoGenerator{state}); - - //if (state.intCount != methodOffset) throw "offset mismatch!"; - foldMethods(MethodGenerator{state, paramIndex}); - - //if (state.intCount != propertyOffset) throw "offset mismatch!"; - foldState(PropertyGenerator{state}); - foldState(NotifySignalGenerator{state}); - - //if (state.intCount != enumOffset) throw "offset mismatch!"; - foldState(EnumGenerator{state, enumValueOffset}); - - //if (state.intCount != constructorOffset) throw "offset mismatch!"; - foldState(MethodGenerator{state, constructorParamIndex}); - - //if (state.intCount != paramIndex) throw "offset mismatch!"; - foldMethods(MethodParametersGenerator{state}); - - //if (state.intCount != constructorParamIndex) throw "offset mismatch!"; - foldState(ConstructorParametersGenerator{state}); - - //if (state.intCount != enumValueOffset) throw "offset mismatch!"; - foldState(EnumValuesGenerator{state}); -} - -#if __cplusplus > 201700L -template -constexpr LayoutBuilder dataLayout = [](){ - auto r = LayoutBuilder{}; - generateDataPass(r); - return r; -}(); -#else -template -constexpr auto createLayout() { - auto r = LayoutBuilder{}; - generateDataPass(r); - return r; -} -template -constexpr LayoutBuilder dataLayout = createLayout(); -#endif - -/// Final data holder -template -struct MetaDataHolder { - RawArray byteArrays; - OwnArray stringChars; -#if __cplusplus > 201700L - const uint* ints; -#else - OwnArray ints; -#endif -}; -template -struct MetaDataProvider { - static constexpr auto stringSize = dataLayout.stringSize; - static constexpr auto stringCount = dataLayout.stringCount; - static constexpr auto intCount = dataLayout.intCount; - using MetaDataType = const MetaDataHolder; - - struct Arrays { -#ifndef Q_CC_MSVC - constexpr static qptrdiff stringOffset = offsetof(MetaDataType, stringChars); -#else // offsetof does not work with MSVC - constexpr static qptrdiff stringOffset = sizeof(MetaDataType::byteArrays); -#endif - RawArray stringOffsets{}; - RawArray stringLengths{}; - RawArray stringChars{}; - RawArray ints{}; - }; -#if __cplusplus > 201700L - constexpr static Arrays arrays = []() { - auto r = Arrays{}; - DataBuilder b{r}; - generateDataPass(b); - return r; - }(); -#else - constexpr static auto buildArrays() { - auto r = Arrays{}; - DataBuilder b{r}; - generateDataPass(b); - return r; - } - constexpr static Arrays arrays = buildArrays(); -#endif -}; - -template -struct MetaDataBuilder; -template -struct MetaDataBuilder> { - using P = MetaDataProvider; - using MetaDataType = typename P::MetaDataType; -#if __cplusplus >= 201700L - constexpr static MetaDataType meta_data = { - {Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(P::arrays.stringLengths[Is], P::arrays.stringOffsets[Is])...}, - P::arrays.stringChars, P::arrays.ints - }; -#else - static MetaDataType meta_data; -#endif -}; -#if __cplusplus < 201700L -template -typename MetaDataBuilder>::MetaDataType MetaDataBuilder>::meta_data = { - {Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(P::arrays.stringLengths[Is], P::arrays.stringOffsets[Is])...}, - {P::arrays.stringChars}, {P::arrays.ints} -}; -#endif - -/// Returns the QMetaObject* of the base type. Use SFINAE to only return it if it exists -template -static constexpr auto parentMetaObject(int) W_RETURN(&T::W_BaseType::staticMetaObject) -template -static constexpr const QMetaObject *parentMetaObject(...) { return nullptr; } - -// Bunch of helpers for propertyOperation -// this uses SFINAE of the return value to work either with F a pointer to member, or to member function -// or nullptr. -template -inline auto propSet(F f, O *o, const T &t) W_RETURN(((o->*f)(t),0)) -template -inline auto propSet(F f, O *o, const T &t) W_RETURN(o->*f = t) -template -inline void propSet(Empty, O *, const T &) {} - -template -inline auto propGet(F f, O *o, T &t) W_RETURN(t = (o->*f)()) -template -inline auto propGet(F f, O *o, T &t) W_RETURN(t = o->*f) -template -inline void propGet(Empty, O *, T &) {} - -template -inline auto propNotify(F f, M m, O *o) W_RETURN(((o->*f)(o->*m),0)) -template -inline auto propNotify(F f, M, O *o) W_RETURN(((o->*f)(),0)) -template -inline void propNotify(T...) {} - -template -inline auto propReset(F f, O *o) W_RETURN(((o->*f)(),0)) -template -inline void propReset(T...) {} - -struct FriendHelper { - - template - static constexpr QMetaObject createMetaObject() { - using MetaData = MetaDataBuilder.stringCount>>; -#if __cplusplus > 201700L - return { { parentMetaObject(0), MetaData::meta_data.byteArrays, MetaData::meta_data.ints, T::qt_static_metacall, {}, {} } }; -#else - return { { parentMetaObject(0), MetaData::meta_data.byteArrays, MetaData::meta_data.ints.data, T::qt_static_metacall, {}, {} } }; -#endif - } - - template static int qt_metacall_impl(T *_o, QMetaObject::Call _c, int _id, void** _a) { - using ObjI = typename T::W_MetaObjectCreatorHelper::ObjectInfo; - _id = _o->T::W_BaseType::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod || _c == QMetaObject::RegisterMethodArgumentMetaType) { - constexpr int methodCount = ObjI::methodCount; - if (_id < methodCount) - T::qt_static_metacall(_o, _c, _id, _a); - _id -= methodCount; - } else if ((_c >= QMetaObject::ReadProperty && _c <= QMetaObject::QueryPropertyUser) - || _c == QMetaObject::RegisterPropertyMetaType) { - constexpr int propertyCount = ObjI::propertyCount; - if (_id < propertyCount) - T::qt_static_metacall(_o, _c, _id, _a); - _id -= propertyCount; - } - return _id; - } - -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Waddress") - /// Helper for implementation of qt_static_metacall for QMetaObject::IndexOfMethod - /// T is the class, and I is the index of a method. - /// Returns I if the argument is equal to the pointer to member function of the signal of index 'I' - template - static int indexOfMethod(void **func) { - using ObjI = typename T::W_MetaObjectCreatorHelper::ObjectInfo; - constexpr auto m = ObjI::method(index); - if ((m.flags & 0xc) == W_MethodType::Signal.value - && m.func == *reinterpret_cast(func)) - return I; - return -1; - } -QT_WARNING_POP - - /// Helper for implementation of qt_static_metacall for QMetaObject::InvokeMetaMethod - /// T is the class, and I is the index of a method. - /// Invoke the method with index I if id == I. - template - static void invokeMethod(T *_o, int _id, void **_a) { - if (_id == I) { - using ObjI = typename T::W_MetaObjectCreatorHelper::ObjectInfo; - constexpr auto f = ObjI::method(index).func; - using P = QtPrivate::FunctionPointer>; - P::template call(f, _o, _a); - } - } - - /// Helper for implementation of qt_static_metacall for QMetaObject::RegisterMethodArgumentMetaType - /// T is the class, and I is the index of a method. - template - static void registerMethodArgumentType(int _id, void **_a) { - if (_id == I) { - using ObjI = typename T::W_MetaObjectCreatorHelper::ObjectInfo; - constexpr auto f = ObjI::method(index).func; - using P = QtPrivate::FunctionPointer>; - auto _t = QtPrivate::ConnectionTypes::types(); - uint arg = *reinterpret_cast(_a[1]); - *reinterpret_cast(_a[0]) = _t && arg < P::ArgumentCount ? - _t[arg] : -1; - } - } - - /// Helper for implementation of qt_static_metacall for any of the operations in a property - /// T is the class, and I is the index of a property. - template - static void propertyOperation(T *_o, QMetaObject::Call _c, int _id, void **_a) { - if (_id != I) - return; - using TPP = T**; - constexpr auto p = w_state(index, PropertyStateTag{}, TPP{}); - using Type = typename decltype(p)::PropertyType; - switch(+_c) { - case QMetaObject::ReadProperty: - if (p.getter) { - propGet(p.getter, _o, *reinterpret_cast(_a[0])); - } else if (p.member) { - propGet(p.member, _o, *reinterpret_cast(_a[0])); - } - break; - case QMetaObject::WriteProperty: - if (p.setter) { - propSet(p.setter, _o, *reinterpret_cast(_a[0])); - } else if (p.member) { - propSet(p.member, _o, *reinterpret_cast(_a[0])); - propNotify(p.notify, p.member, _o); - } - break; - case QMetaObject::ResetProperty: - if (p.reset) { - propReset(p.reset, _o); - } - break; - case QMetaObject::RegisterPropertyMetaType: - *reinterpret_cast(_a[0]) = QtPrivate::QMetaTypeIdHelper::qt_metatype_id(); - } - } - - /// Helper for implementation of qt_static_metacall for QMetaObject::CreateInstance - /// T is the class, and I is the index of a constructor. - template - static void createInstanceImpl(void **_a, const MetaConstructorInfo&, index_sequence) { - *reinterpret_cast(_a[0]) = - new T(*reinterpret_cast *>(_a[I+1])...); - } - template - static void createInstance(int _id, void** _a) { - if (_id == I) { - using TPP = T**; - constexpr auto m = w_state(index, ConstructorStateTag{}, TPP{}); - createInstanceImpl(_a, m, m.argSequence); - } - } - - /// Implementation of qt_static_metacall for W_OBJECT_IMPL which should be called with - /// std::index_sequence for the amount of method, constructor, and properties. - template - static void qt_static_metacall_impl2(QObject *_o, QMetaObject::Call _c, int _id, void** _a, - std::index_sequence, std::index_sequence, std::index_sequence) { - Q_UNUSED(_id) Q_UNUSED(_o) Q_UNUSED(_a) - if (_c == QMetaObject::InvokeMetaMethod) { - Q_ASSERT(T::staticMetaObject.cast(_o)); -#if __cplusplus > 201700L - (invokeMethod(reinterpret_cast(_o), _id, _a),...); -#else - ordered((invokeMethod(reinterpret_cast(_o), _id, _a),0)...); -#endif - } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { -#if __cplusplus > 201700L - (registerMethodArgumentType(_id, _a),...); -#else - ordered((registerMethodArgumentType(_id, _a),0)...); -#endif - } else if (_c == QMetaObject::IndexOfMethod) { -#if __cplusplus > 201700L - *reinterpret_cast(_a[0]) = ((1+indexOfMethod(reinterpret_cast(_a[1]))) + ... + 0)-1; -#else - auto r = int{-1}; - ordered2({(r += (1+indexOfMethod(reinterpret_cast(_a[1]))))...}); - *reinterpret_cast(_a[0]) = r; -#endif - } else if (_c == QMetaObject::CreateInstance) { -#if __cplusplus > 201700L - (createInstance(_id, _a),...); -#else - ordered((createInstance(_id, _a),0)...); -#endif - } else if ((_c >= QMetaObject::ReadProperty && _c <= QMetaObject::QueryPropertyUser) - || _c == QMetaObject::RegisterPropertyMetaType) { -#if __cplusplus > 201700L - (propertyOperation(static_cast(_o), _c, _id, _a),...); -#else - ordered((propertyOperation(static_cast(_o), _c, _id, _a),0)...); -#endif - } - } - - // Same for W_GADGET - template - static void qt_static_metacall_impl2(T *_o, QMetaObject::Call _c, int _id, void** _a, - std::index_sequence, std::index_sequence, std::index_sequence) { - Q_UNUSED(_id) Q_UNUSED(_o) Q_UNUSED(_a) - if (_c == QMetaObject::InvokeMetaMethod) { -#if __cplusplus > 201700L - (invokeMethod(_o, _id, _a),...); -#else - ordered((invokeMethod(_o, _id, _a), 0)...); -#endif - } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { -#if __cplusplus > 201700L - (registerMethodArgumentType(_id, _a),...); -#else - ordered((registerMethodArgumentType(_id, _a), 0)...); -#endif - } else if (_c == QMetaObject::IndexOfMethod) { - Q_ASSERT_X(false, "qt_static_metacall", "IndexOfMethod called on a Q_GADGET"); - } else if (_c == QMetaObject::CreateInstance) { -#if __cplusplus > 201700L - (createInstance(_id, _a),...); -#else - ordered((createInstance(_id, _a), 0)...); -#endif - } else if ((_c >= QMetaObject::ReadProperty && _c <= QMetaObject::QueryPropertyUser) - || _c == QMetaObject::RegisterPropertyMetaType) { -#if __cplusplus > 201700L - (propertyOperation(_o, _c, _id, _a),...); -#else - ordered((propertyOperation(_o, _c, _id, _a), 0)...); -#endif - } - } - - template - static void qt_static_metacall_impl(Ts &&... args) { - using ObjI = typename T::W_MetaObjectCreatorHelper::ObjectInfo; - return qt_static_metacall_impl2(std::forward(args)..., - ObjI::methodSequence, ObjI::constructorSequence, ObjI::propertySequence); - } - - /// implementation of qt_metacast - template - static void* qt_metacast_impl(T *o, const char *_clname) { - if (!_clname) - return nullptr; - const QByteArrayDataPtr sd = { const_cast(T::staticMetaObject.d.stringdata) }; - if (_clname == QByteArray(sd)) - return o; - using ObjI = typename T::W_MetaObjectCreatorHelper::ObjectInfo; - void *result = {}; - auto l = [&](auto i) { - using TPP = T**; - using Interface = decltype(w_state(i, InterfaceStateTag{}, TPP{})); - const char *iid = qobject_interface_iid(); - if (iid && !strcmp(_clname, iid)) - result = static_cast(o); - }; - fold(ObjI::interfaceSequence, l); - if (!result) return o->T::W_BaseType::qt_metacast(_clname); - return result; - } - -}; // FriendHelper - -} // namespace w_internal - -#ifndef QT_INIT_METAOBJECT // Defined in qglobal.h since Qt 5.10 -#define QT_INIT_METAOBJECT -#endif - -// W_OBJECT_IMPL was designed to take advantage of the GNU extension that ... can have zero arguments. -// So we need to work around that to extract the template stuff which may not exist or be composed -// of several macro arguments: If the first argument has parentheses, there must be at least two -// arguments, so just do a tail. Otherwise, there should be only one or two argument, so take the second. -#define W_MACRO_TEMPLATE_STUFF(...) W_MACRO_CONCAT(W_MACRO_TEMPLATE_STUFF_HELPER, W_MACRO_DELAY(W_MACRO_TEMPLATE_STUFF_QUERY,W_MACRO_TEMPLATE_STUFF_HELPER __VA_ARGS__))(__VA_ARGS__) -#define W_MACRO_TEMPLATE_STUFF_QUERY(...) W_MACRO_DELAY2(W_MACRO_FIRST, W_MACRO_TEMPLATE_STUFF_HELPER_ ## __VA_ARGS__) -#define W_MACRO_TEMPLATE_STUFF_HELPER(...) YES -#define W_MACRO_TEMPLATE_STUFF_HELPER_YES TAIL, -#define W_MACRO_TEMPLATE_STUFF_HELPER_W_MACRO_TEMPLATE_STUFF_HELPER SECOND, -#define W_MACRO_TEMPLATE_STUFF_HELPER_TAIL(...) W_MACRO_MSVC_EXPAND(W_MACRO_TAIL(__VA_ARGS__)) -#define W_MACRO_TEMPLATE_STUFF_HELPER_SECOND(...) W_MACRO_MSVC_EXPAND(W_MACRO_TEMPLATE_STUFF_HELPER_SECOND2(__VA_ARGS__,,)) -#define W_MACRO_TEMPLATE_STUFF_HELPER_SECOND2(A,B,...) B -#define W_MACRO_FIRST_REMOVEPAREN(...) W_MACRO_REMOVEPAREN(W_MACRO_FIRST(__VA_ARGS__)) - -#define W_OBJECT_IMPL_COMMON(INLINE, ...) \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) struct W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::W_MetaObjectCreatorHelper { \ - struct Name { \ - static constexpr auto defaultName = w_internal::viewLiteral(W_MACRO_STRIGNIFY(W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__))); \ - static constexpr auto value = w_internal::fetchExplicitName(defaultName, 0); \ - }; \ - using ObjectInfo = w_internal::ObjectInfo; \ - }; \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) INLINE const QT_INIT_METAOBJECT QMetaObject W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::staticMetaObject = \ - w_internal::FriendHelper::createMetaObject(); - -/// \macro W_OBJECT_IMPL(TYPE [, TEMPLATE_STUFF]) -/// This macro expand to the code that instantiate the QMetaObject. It must be placed outside of -/// the class, in the .cpp file. The TYPE argument must be the qualified name of the class, -/// including the namespace, if any. -/// Example: `W_OBJECT_IMPL(Namespace::MyClass)` -/// -/// If the class is a templated class, the second argument contains the template introducer. -/// Example: `W_OBJECT_IMPL(MyTemplate, template )` -/// Parentheses are required if there is several template arguments: -/// `W_OBJECT_IMPL((MyTemplate2), template)` -#define W_OBJECT_IMPL(...) \ - W_OBJECT_IMPL_COMMON(W_MACRO_EMPTY, __VA_ARGS__) \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) void W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void** _a) \ - { w_internal::FriendHelper::qt_static_metacall_impl(_o, _c, _id, _a); } \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) const QMetaObject *W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::metaObject() const { return &staticMetaObject; } \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) void *W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_metacast(const char *_clname) \ - { return w_internal::FriendHelper::qt_metacast_impl(this, _clname); } \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) int W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_metacall(QMetaObject::Call _c, int _id, void** _a) \ - { return w_internal::FriendHelper::qt_metacall_impl(this, _c, _id, _a); } - - -/// \macro W_GADGET_IMPL(TYPE [, TEMPLATE_STUFF]) -/// Same as W_OBJECT_IMPL, but for a W_GADGET -#define W_GADGET_IMPL(...) \ - W_OBJECT_IMPL_COMMON(W_MACRO_EMPTY, __VA_ARGS__) \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) void W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void** _a) \ - { w_internal::FriendHelper::qt_static_metacall_impl(reinterpret_cast(_o), _c, _id, _a); } - -/// \macro W_NAMESPACE_IMPL(...) -/// Same as W_OBJECT_IMPL, but for a W_NAMESPACE -#define W_NAMESPACE_IMPL(...) \ - W_OBJECT_IMPL_COMMON(W_MACRO_EMPTY, __VA_ARGS__) - - -/// \macro W_OBJECT_IMPL_INLINE(TYPE [, TEMPLATE_STUFF]) -/// Same as W_OBJECT_IMPL, but to be used in a header -/// (Requires support for c++17 inline variables) -#define W_OBJECT_IMPL_INLINE(...) \ - W_OBJECT_IMPL_COMMON(inline, __VA_ARGS__) \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) inline void W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void** _a) \ - { w_internal::FriendHelper::qt_static_metacall_impl(_o, _c, _id, _a); } \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) inline const QMetaObject *W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::metaObject() const { return &staticMetaObject; } \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) inline void *W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_metacast(const char *_clname) \ - { return w_internal::FriendHelper::qt_metacast_impl(this, _clname); } \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) inline int W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_metacall(QMetaObject::Call _c, int _id, void** _a) \ - { return w_internal::FriendHelper::qt_metacall_impl(this, _c, _id, _a); } - - -/// \macro W_GADGET_IMPL_INLINE(TYPE [, TEMPLATE_STUFF]) -/// Same as W_GADGET_IMPL, but to be used in a header -/// (Requires support for c++17 inline variables) -#define W_GADGET_IMPL_INLINE(...) \ - W_OBJECT_IMPL_COMMON(inline, __VA_ARGS__) \ - W_MACRO_TEMPLATE_STUFF(__VA_ARGS__) inline void W_MACRO_FIRST_REMOVEPAREN(__VA_ARGS__)::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void** _a) \ - { w_internal::FriendHelper::qt_static_metacall_impl(reinterpret_cast(_o), _c, _id, _a); } - -/// \macro W_NAMESPACE_IMPL_INLINE(...) -/// Same as W_NAMESPACE_IMPL, but to be used in a header -/// (Requires support for c++17 inline variables) -#define W_NAMESPACE_IMPL_INLINE(...) \ - W_OBJECT_IMPL_COMMON(inline, __VA_ARGS__) diff --git a/QtRpa/include/common/worker_thread.h b/QtRpa/include/common/worker_thread.h deleted file mode 100644 index 3ec6fb5..0000000 --- a/QtRpa/include/common/worker_thread.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - - -#include - -typedef QList> ListEnvironment; - -class WorkerThread : public QThread { - Q_OBJECT -public: - WorkerThread(const QString& src, QObject* object = nullptr); - -protected: - void run(); -signals: - void reported(const QString& info); -private: - QString program_; - QString source_dir_; -}; diff --git a/QtRpa/include/common/xmlattribute.h b/QtRpa/include/common/xmlattribute.h deleted file mode 100644 index efeb6aa..0000000 --- a/QtRpa/include/common/xmlattribute.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "string.h" -namespace pugi { class xml_attribute; } -namespace shelllet { - namespace common { - class XmlAttributePrivate; - class XmlAttribute : public Object { - Q_DECLARE_PRIVATE(XmlAttribute) - public: - XmlAttribute(Object* parent = nullptr); - XmlAttribute& operator=(const String& rhs); - XmlAttribute& operator=(int32_t rhs); - /* xml_attribute& operator=(unsigned int rhs); - xml_attribute& operator=(long rhs); - xml_attribute& operator=(unsigned long rhs); - xml_attribute& operator=(double rhs); - xml_attribute& operator=(float rhs); - xml_attribute& operator=(bool rhs);*/ - - String value() const; - void setValue(const String& rhs); - protected: - XmlAttribute(XmlAttributePrivate& d, Object* parent = nullptr); - - public: - static XmlAttribute from(const pugi::xml_attribute* attr); - }; - } -} diff --git a/QtRpa/include/common/xmldocument.h b/QtRpa/include/common/xmldocument.h deleted file mode 100644 index 016974e..0000000 --- a/QtRpa/include/common/xmldocument.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "xmlnode.h" -namespace shelllet { - namespace common { - class XmlDocumentPrivate; - class XmlDocument : public XmlNode { - Q_DECLARE_PRIVATE(XmlDocument) - friend std::ostream& operator<< (std::ostream& out, const XmlDocument& doc); - public: - XmlDocument(Object* parent = nullptr); - XmlDocument(const Path& p, Object* parent = nullptr); - - XmlNode documentElement() const; - - void addDeclaration(); - - void loadFile(const Path& path); - - void print(std::ostream& stream); - protected: - XmlDocument(XmlDocumentPrivate& d, Object* parent = nullptr); - }; - } -} diff --git a/QtRpa/include/common/xmlnode.h b/QtRpa/include/common/xmlnode.h deleted file mode 100644 index 1b50dbb..0000000 --- a/QtRpa/include/common/xmlnode.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once -#include "xmlattribute.h" -#include "xmlnodeiterator.h" -namespace shelllet { - namespace common { - - template class XmlNodeRange - { - public: - typedef It const_iterator; - typedef It iterator; - - XmlNodeRange(It b, It e) : _begin(b), _end(e) - { - } - - It begin() const { return _begin; } - It end() const { return _end; } - - private: - It _begin, _end; - }; - - class XmlNodePrivate; - class XmlNode : public Object { - Q_DECLARE_PRIVATE(XmlNode) - friend std::ostream& operator<< (std::ostream& out, const XmlNode& node); - friend class XmlNodeIterator; - public: - XmlNode(Object* parent = nullptr); - XmlNode(const XmlNode& node, Object* parent = nullptr); - XmlNode appendChild(XmlNodeType type = XmlNodeType::Element); - XmlNode appendChild(const String& name); - void setValue(const String& value); - bool setName(const String& name); - XmlNode appendCopy(const XmlNode& proto); - XmlAttribute appendAttribute(const String& name); - - XmlAttribute attribute(const String& name) const; - - XmlNode parent() const; - XmlNodeRange children() const; - - String name() const; - - XmlNodeType type() const; - - - - XmlNodeIterator begin() const; - XmlNodeIterator end() const; - - XmlNode& operator= (const XmlNode& node); - - - /*bool operator==(const XmlNode& r) const; - bool operator!=(const XmlNode& r) const; - bool operator<(const XmlNode& r) const; - bool operator>(const XmlNode& r) const; - bool operator<=(const XmlNode& r) const; - bool operator>=(const XmlNode& r) const;*/ - - protected: - XmlNode(XmlNodePrivate& d, Object* parent = nullptr); - - public: - static XmlNode from(const pugi::xml_node* n); - }; - } -} diff --git a/QtRpa/include/common/xmlnodeiterator.h b/QtRpa/include/common/xmlnodeiterator.h deleted file mode 100644 index f48606f..0000000 --- a/QtRpa/include/common/xmlnodeiterator.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "object.h" -#include "xmlnode.h" -namespace pugi { class xml_node_iterator; class xml_node; } - -namespace shelllet { - namespace common { - class XmlNode; - class XmlNodeIteratorPrivate; - - class XmlNodeIterator : public Object { - Q_DECLARE_PRIVATE(XmlNodeIterator) - public: - using difference_type = std::ptrdiff_t; - using value_type = XmlNodeIterator; - using pointer = XmlNodeIterator*; - using reference = XmlNodeIterator&; - using iterator_category = std::bidirectional_iterator_tag; - - XmlNodeIterator(Object* parent=nullptr); - XmlNodeIterator(const XmlNodeIterator& iter, Object* parent = nullptr); - XmlNodeIterator(const XmlNode& node, Object* parent = nullptr); - - XmlNode& operator *() const; - XmlNode* operator ->() const; - - bool operator==(const XmlNodeIterator& rhs) const; - bool operator!=(const XmlNodeIterator& rhs) const; - - const XmlNodeIterator& operator++(); - XmlNodeIterator operator++(int); - - const XmlNodeIterator& operator--(); - XmlNodeIterator operator--(int); - - - static XmlNodeIterator from(pugi::xml_node_iterator* iter); - protected: - XmlNodeIterator(XmlNodeIteratorPrivate& d, Object* parent = nullptr); - }; - - } -} diff --git a/QtRpa/include/common/zip_entry.h b/QtRpa/include/common/zip_entry.h deleted file mode 100644 index 5900388..0000000 --- a/QtRpa/include/common/zip_entry.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -//class zip_entry : public juce::ZipFile::ZipEntry { -//public: -// zip_entry(); -// // virtual Button* createDocumentWindowButton(int buttonType) override; -// -// // virtual Typeface::Ptr getTypefaceForFont(const Font&) override; -// -// //virtual void drawDocumentWindowTitleBar(DocumentWindow&, Graphics&, int, int, int, int, const Image*, bool) override; -// -//public: -// zip_entry* next(); -//private: -//}; diff --git a/QtRpa/include/creator.hpp b/QtRpa/include/creator.hpp deleted file mode 100644 index 706d661..0000000 --- a/QtRpa/include/creator.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "common/framework.h" - -#include "events/common_event.h" -#include "creator/command_event_about.h" -#include "creator/command_event_exec.h" -#include "creator/command_event_new.h" -#include "creator/command_event_open.h" -#include "creator/command_event_save.h" - -#include "creator/about_window.h" -#include "creator/items_callback.h" diff --git a/QtRpa/include/creator/about_window.h b/QtRpa/include/creator/about_window.h deleted file mode 100644 index 7aeff80..0000000 --- a/QtRpa/include/creator/about_window.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "frameless.hpp" -namespace shelllet::creator { - class AboutWindow : public MainWindow - { - public: - AboutWindow(QWidget* parent = nullptr); - ~AboutWindow(); - - private: - - private: - }; -} diff --git a/QtRpa/include/creator/application.h b/QtRpa/include/creator/application.h deleted file mode 100644 index 839186c..0000000 --- a/QtRpa/include/creator/application.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace creator{ - class ApplicationPrivate; - class Application : public Object { - Q_DECLARE_PRIVATE(Application) - public: - // Application(Object*parent = nullptr); - Application(int& argc, char** argv, Object* parent = nullptr); - void customEvent(QEvent* event); - - void setWindowIcon(const QIcon & icon); - void setQuitOnLastWindowClosed(bool quit); - - QApplication* toQApplication() const; - protected: - Application(ApplicationPrivate& d, int& argc, char** argv, Object*parent = nullptr); - }; - } -} - diff --git a/QtRpa/include/creator/command_event_about.h b/QtRpa/include/creator/command_event_about.h deleted file mode 100644 index cc07cdb..0000000 --- a/QtRpa/include/creator/command_event_about.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "items_callback.h" -namespace shelllet { - namespace creator { - class About : public CallbackMessage - { - protected: - virtual void messageCallback(Callback* call); - private: - }; - } -} diff --git a/QtRpa/include/creator/command_event_exec.h b/QtRpa/include/creator/command_event_exec.h deleted file mode 100644 index 74e6530..0000000 --- a/QtRpa/include/creator/command_event_exec.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "items_callback.h" -namespace shelllet { - namespace creator { - class Exec : public CallbackMessage - { - protected: - virtual void messageCallback(Callback* call); - }; - } -} diff --git a/QtRpa/include/creator/command_event_new.h b/QtRpa/include/creator/command_event_new.h deleted file mode 100644 index e4a6ec7..0000000 --- a/QtRpa/include/creator/command_event_new.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "items_callback.h" -#include "pugixml.hpp" - -namespace shelllet { - namespace creator { - class New : public CallbackMessage - { - public: - virtual void messageCallback(Callback* call); - }; - } -} diff --git a/QtRpa/include/creator/command_event_open.h b/QtRpa/include/creator/command_event_open.h deleted file mode 100644 index 1f7c159..0000000 --- a/QtRpa/include/creator/command_event_open.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "items_callback.h" - -namespace shelllet { - namespace creator { - class Open : public CallbackMessage - { - protected: - virtual void messageCallback(Callback* call); - }; - } -} diff --git a/QtRpa/include/creator/command_event_save.h b/QtRpa/include/creator/command_event_save.h deleted file mode 100644 index 0c18b20..0000000 --- a/QtRpa/include/creator/command_event_save.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "items_callback.h" -namespace shelllet { - namespace creator { - class Save : public CallbackMessage - { - protected: - virtual void messageCallback(Callback* call); - }; - } -} diff --git a/QtRpa/include/creator/component.h b/QtRpa/include/creator/component.h deleted file mode 100644 index 275f25f..0000000 --- a/QtRpa/include/creator/component.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include - -namespace shelllet{ - namespace property { class PropertyBrowser; } - namespace creator { - class properties_component : public QWidget - { - public: - properties_component(QWidget* parent = nullptr); - ~properties_component(); - - - - public: - //void updateProperty(const std::shared_ptr& property); - void variable_changed(int action, const std::string& old_name, const std::string& new_name); - - protected: - - QSize sizeHint() const override; - virtual void customEvent(QEvent* event) override; - private: - //std::unique_ptr display_; - - property::PropertyBrowser* browser_; - }; -} -} diff --git a/QtRpa/include/creator/dump_dialog.h b/QtRpa/include/creator/dump_dialog.h deleted file mode 100644 index 1f69064..0000000 --- a/QtRpa/include/creator/dump_dialog.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "qdialog.h" -#include "boost/core/noncopyable.hpp" -namespace shelllet { - class DumpDialogPrivate; - namespace creator { - class DumpDialog : public QDialog, private boost::noncopyable - { - Q_DECLARE_PRIVATE(DumpDialog) - public: - DumpDialog(QWidget* parent = nullptr); - ~DumpDialog(); - - private: - }; - } -} diff --git a/QtRpa/include/creator/gui_application.h b/QtRpa/include/creator/gui_application.h deleted file mode 100644 index d450e56..0000000 --- a/QtRpa/include/creator/gui_application.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "common.hpp" - -namespace shelllet { - namespace creator { - class GuiApplicationPrivate; - class GuiApplication : public Runnable, public Object - { - Q_DECLARE_PRIVATE(GuiApplication) - public: - GuiApplication(); - - void run(QEvent* event) override; - - - static GuiApplication* getInstance(); - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/creator/items_callback.h b/QtRpa/include/creator/items_callback.h deleted file mode 100644 index c8111aa..0000000 --- a/QtRpa/include/creator/items_callback.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -namespace shelllet { - namespace creator { - class Callback; - - class CallbackMessage { - public: - virtual ~CallbackMessage() {} - }; - - class Callback { - public: - virtual void callbk(CallbackMessage*, int num, ...) = 0; - }; - } -} diff --git a/QtRpa/include/creator/mini_dump.h b/QtRpa/include/creator/mini_dump.h deleted file mode 100644 index 5bc658b..0000000 --- a/QtRpa/include/creator/mini_dump.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "boost/core/noncopyable.hpp" -#include "qobject.h" -namespace shelllet { - class MiniDumpPrivate; - namespace debug { - class MiniDump: public QObject, public boost::noncopyable { - Q_DECLARE_PRIVATE(MiniDump) - public: - MiniDump(QObject *parent = nullptr); - ~MiniDump(); - bool startCrashServer(const std::wstring& dump_path); - void stopCrashServer(); - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/creator/private/application_p.h b/QtRpa/include/creator/private/application_p.h deleted file mode 100644 index e6eaddf..0000000 --- a/QtRpa/include/creator/private/application_p.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "common.hpp" -class QApplication; -namespace shelllet { - namespace creator{ - class ApplicationPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(Application) - public: - - class __Application : public QApplication { - public: - - __Application(Application* self, int& argc, char** argv); - - void customEvent(QEvent* event); - private: - Application* self; - }; - UniquePointer<__Application> app; - }; - - - } -} diff --git a/QtRpa/include/creator/scene.h b/QtRpa/include/creator/scene.h deleted file mode 100644 index ed511e3..0000000 --- a/QtRpa/include/creator/scene.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once -#include -#include "common.hpp" -QT_BEGIN_NAMESPACE -class QGraphicsSceneMouseEvent; -class QMenu; -class QPointF; -class QGraphicsLineItem; -class QFont; -class QGraphicsTextItem; -class QColor; -QT_END_NAMESPACE - -namespace shelllet { - namespace creator { - - class DiagramScenePrivate; - class DiagramScene : public QGraphicsScene, public Object - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, DiagramScene) - public: - enum Mode { InsertItem, InsertLine, InsertText, MoveItem }; - - explicit DiagramScene(QMenu* itemMenu, QObject* parent = 0); - - QGraphicsItem* rootItem() const; - - QGraphicsItem* startItem() const; - std::unique_ptr toXml(); - - void loadFromXml(const XmlDocument& doc); - - QGraphicsWidget* rootWidget() const; - public slots: - void setMode(Mode mode); - void addItem(QGraphicsLayoutItem* item); - - static void RegisterAllViews(); - - signals: - - - protected: - void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override; - - void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override; - - void dropEvent(QGraphicsSceneDragDropEvent* event) override; - - - void customEvent(QEvent* event) override; - - private: - bool isItemChange(int type); - void walkChildNode(XmlNode node, Element* item); - - static void walkChildItem(XmlNode node, const QList& items); - }; - } -} diff --git a/QtRpa/include/events.hpp b/QtRpa/include/events.hpp deleted file mode 100644 index 4a882d3..0000000 --- a/QtRpa/include/events.hpp +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "common/framework.h" -#include "events/common_event.h" -#include "events/createevent.h" -#include "events/openevent.h" -#include "events/gitcloneevent.h" -#include "events/closeevent.h" -#include "events/showevent.h" -#include "events/adjustsizeevent.h" - - -using namespace shelllet::events; \ No newline at end of file diff --git a/QtRpa/include/events/activity_create_event.h b/QtRpa/include/events/activity_create_event.h deleted file mode 100644 index b2b3b80..0000000 --- a/QtRpa/include/events/activity_create_event.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include -#include -#include -#include -namespace shelllet { - namespace events { - class ActivityCreateEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - ActivityCreateEvent(const String& meta); - - String meta() const; - private: - String meta_; - }; - } -} diff --git a/QtRpa/include/events/activity_select_event.h b/QtRpa/include/events/activity_select_event.h deleted file mode 100644 index 3f672ed..0000000 --- a/QtRpa/include/events/activity_select_event.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -#include -#include -#include -namespace shelllet { - namespace interpreter { - class CompositeProperty; - } - namespace events { - class ActivitySelectEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - ActivitySelectEvent(interpreter::CompositeProperty* prop); - interpreter::CompositeProperty* getProp() const; - private: - interpreter::CompositeProperty* prop_; - }; - } -} diff --git a/QtRpa/include/events/adjustsizeevent.h b/QtRpa/include/events/adjustsizeevent.h deleted file mode 100644 index b37483a..0000000 --- a/QtRpa/include/events/adjustsizeevent.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include -#include -namespace shelllet { - namespace events { - class AdjustSizeEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - AdjustSizeEvent(); - }; - } -} diff --git a/QtRpa/include/events/closeevent.h b/QtRpa/include/events/closeevent.h deleted file mode 100644 index 0bd19a5..0000000 --- a/QtRpa/include/events/closeevent.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include -#include -#include -namespace shelllet { - namespace events { - class CloseEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - CloseEvent(int result = 0); - - int result; - private: - }; - } -} diff --git a/QtRpa/include/events/common_event.h b/QtRpa/include/events/common_event.h deleted file mode 100644 index 8079993..0000000 --- a/QtRpa/include/events/common_event.h +++ /dev/null @@ -1,80 +0,0 @@ -#pragma once -#include "filesystem" -#include -#include -#include -#include -#include "common.hpp" - -namespace shelllet { - namespace events { - class Event : public QEvent { - static inline QEvent::Type Type = static_cast(registerEventType()); - public: - Event(Runnable* p) :QEvent(Type), p_(p) {} - Runnable* ptr() { return p_; } - private: - Runnable* p_ = nullptr; - }; - class ConsoleEvent : public Event { - public: - - ConsoleEvent(const Path& file, bool inspect_brk) - : Event(0) - , file_(file) - , inspect_brk_(inspect_brk) {} - - Path filename() const { return file_; } - bool inspectBrk() const { return inspect_brk_; } - private: - Path file_; - bool inspect_brk_; - }; - - class GuiEvent : public Event { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - GuiEvent() - : Event(0) - {} - }; - - class EmptyPtr { - public: - virtual ~EmptyPtr() {} - - private: - EmptyPtr* d_ptr; - }; - class DumpRequestEvent : public Event { - public: - DumpRequestEvent(Runnable* p) - : Event(p) - {} - }; - class ActivitiesShowEvent : public QEvent { - public: - - static inline QEvent::Type eType = static_cast(registerEventType()); - ActivitiesShowEvent(/*QTreeWidgetItem* item*/); - //QTreeWidgetItem* getItem() const; - private: - //QTreeWidgetItem* item; - }; - - class EventDispatcher : public QObject, public boost::serialization::singleton { - public: - EventDispatcher(); - void push(QObject* receiver); - - static EventDispatcher* Dispatcher() { return &EventDispatcher::get_mutable_instance(); } - static const EventDispatcher* ConstDispatcher() { return &EventDispatcher::get_const_instance(); } - protected: - void customEvent(QEvent* event) override; - - private: - QObjectList concerns; - }; - //Q_GLOBAL_STATIC(EventDispatcher, eDispatcher) - } -} diff --git a/QtRpa/include/events/createevent.h b/QtRpa/include/events/createevent.h deleted file mode 100644 index 9895131..0000000 --- a/QtRpa/include/events/createevent.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include -#include -#include -namespace shelllet { - namespace events { - class CreateSelectEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - CreateSelectEvent(); - - - private: - - }; - } -} diff --git a/QtRpa/include/events/file_browser_event.h b/QtRpa/include/events/file_browser_event.h deleted file mode 100644 index 328dcff..0000000 --- a/QtRpa/include/events/file_browser_event.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -namespace shelllet { - namespace events { - class FileBrowserEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - FileBrowserEvent(const std::filesystem::path& root, const std::filesystem::path& filename); - std::filesystem::path getFileName() const; - std::filesystem::path filePath() const; - private: - std::filesystem::path fileName_; - std::filesystem::path root_; - }; - } -} diff --git a/QtRpa/include/events/gitcloneevent.h b/QtRpa/include/events/gitcloneevent.h deleted file mode 100644 index 598429b..0000000 --- a/QtRpa/include/events/gitcloneevent.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include -#include -#include -namespace shelllet { - namespace events { - class GitCloneEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - GitCloneEvent(); - - private: - }; - } -} diff --git a/QtRpa/include/events/listener_manager.h b/QtRpa/include/events/listener_manager.h deleted file mode 100644 index 6f70f09..0000000 --- a/QtRpa/include/events/listener_manager.h +++ /dev/null @@ -1 +0,0 @@ -#pragma once diff --git a/QtRpa/include/events/message_output_event.h b/QtRpa/include/events/message_output_event.h deleted file mode 100644 index e1c4cdb..0000000 --- a/QtRpa/include/events/message_output_event.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include - -namespace shelllet { - namespace events { - class MessageOutputEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - MessageOutputEvent(const std::string& msg); - - std::string message() const; - private: - std::string message_; - }; - } -} diff --git a/QtRpa/include/events/openevent.h b/QtRpa/include/events/openevent.h deleted file mode 100644 index 0b5c92f..0000000 --- a/QtRpa/include/events/openevent.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include -#include -#include -namespace shelllet { - namespace events { - class OpenSelectEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - OpenSelectEvent(); - - private: - }; - } -} diff --git a/QtRpa/include/events/script_status_listener.h b/QtRpa/include/events/script_status_listener.h deleted file mode 100644 index dfd99c7..0000000 --- a/QtRpa/include/events/script_status_listener.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -namespace shelllet { - namespace listener { - class script_status_listener - { - public: - script_status_listener() {}; - ~script_status_listener() {}; - public: - }; - } -} diff --git a/QtRpa/include/events/showevent.h b/QtRpa/include/events/showevent.h deleted file mode 100644 index af88ee6..0000000 --- a/QtRpa/include/events/showevent.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include -#include -#include -namespace shelllet { - namespace events { - class ShowEvent : public QEvent { - public: - - static inline QEvent::Type Type = static_cast(registerEventType()); - ShowEvent(); - - private: - }; - } -} diff --git a/QtRpa/include/frameless.hpp b/QtRpa/include/frameless.hpp deleted file mode 100644 index 752f92d..0000000 --- a/QtRpa/include/frameless.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include "frameless/mainwindow.h" - - -using namespace shelllet::frameless; \ No newline at end of file diff --git a/QtRpa/include/frameless/delegatewindow.h b/QtRpa/include/frameless/delegatewindow.h deleted file mode 100644 index cbf969e..0000000 --- a/QtRpa/include/frameless/delegatewindow.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "common.hpp" -#include "qt_windows.h" -#include "flags.h" -namespace shelllet { - namespace frameless { - class TitleBarWidget; - class DelegateWindowPrivate; - class DelegateWindow : public Object - { - Q_DECLARE_PRIVATE(DelegateWindow) - public: - DelegateWindow(TitleBarWidget* widget); - - long hitNcTest(HWND hWnd, const QPoint& pos, const QRect& geometry, const SizePolicyFlags& flags); - bool calcNcSize(HWND hWnd, WPARAM wParam, LPARAM lParam); - - void updateWindow(HWND hWnd, bool frameChange, bool redraw); - - int getSystemTitleBarHeight(HWND hWnd); - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/frameless/flags.h b/QtRpa/include/frameless/flags.h deleted file mode 100644 index 48b6f70..0000000 --- a/QtRpa/include/frameless/flags.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -namespace shelllet { - namespace frameless { - - - enum class WindowType - { - None = 1 << 0, - MinimizeButtonHint = 1 << 1, - MaximizeButtonHint = 1 << 2, - MinMaxButtonsHint = MinimizeButtonHint | MaximizeButtonHint, - CloseButtonHint = 1 << 3, - AllButton = CloseButtonHint | MinMaxButtonsHint, - MinCloseButton = MinimizeButtonHint | CloseButtonHint, - CustomButtonHint = 1 << 4 - }; - - //Q_ENUM(WindowType); - Q_DECLARE_FLAGS(WindowTypeFlags, WindowType) - Q_DECLARE_OPERATORS_FOR_FLAGS(WindowTypeFlags) - - - enum class SizePolicy - { - None = 1 << 0, - FixedWidth = 1 << 1, - FixedHeigth = 1 << 2, - FixedAll = FixedWidth | FixedHeigth - }; - - Q_DECLARE_FLAGS(SizePolicyFlags, SizePolicy) - Q_DECLARE_OPERATORS_FOR_FLAGS(SizePolicyFlags) - } -} diff --git a/QtRpa/include/frameless/framelesswindow.h b/QtRpa/include/frameless/framelesswindow.h deleted file mode 100644 index a7e3935..0000000 --- a/QtRpa/include/frameless/framelesswindow.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "qmainwindow.h" -#include "common.hpp" -#include "flags.h" -namespace shelllet { - namespace frameless { - class FramelessWindowPrivate; - class FramelessWindow : public QMainWindow, public Object { - Q_OBJECT - Q_DECLARE_PRIVATE_D(Object::d_ptr, FramelessWindow) - public: - explicit FramelessWindow(QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - virtual ~FramelessWindow(); - - void setCustomButton(QWidget* c); - void setContextMenu(QMenu* menu); - void setTitleTextBlurRadius(qreal blurRadius); - void disableNativeTitleBar(); - void enableNativeTitleBar(); - - virtual SizePolicyFlags fixedSizeTypes() const = 0; - protected: - virtual void minimizeButtonClicked(); - virtual void restoreButtonClicked(); - virtual void maximizeButtonClicked(); - virtual void closeButtonClicked(); - virtual void iconDoubleClicked(); - - FramelessWindow(FramelessWindowPrivate& d, QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - protected: - void paintEvent(QPaintEvent* event) override; - void changeEvent(QEvent* event) override; - bool nativeEvent(const QByteArray& eventType, void* message, long* result) override; - }; - } -} diff --git a/QtRpa/include/frameless/mainwindow.h b/QtRpa/include/frameless/mainwindow.h deleted file mode 100644 index 69827e1..0000000 --- a/QtRpa/include/frameless/mainwindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "framelesswindow.h" - -namespace shelllet { - namespace frameless { - class MainWindowPrivate; - class MainWindow : public FramelessWindow { - Q_DECLARE_PRIVATE_D(Object::d_ptr, MainWindow) - public: - MainWindow(QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - - - void moveToCentral(); - - void setFixedHeight(int h); - void setFixedWidth(int w); - void setFixedSize(int w, int h); - void setFixedSize(const QSize& s); - - SizePolicyFlags fixedSizeTypes() const override; - - protected: - MainWindow(MainWindowPrivate&d, QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - }; - } -} diff --git a/QtRpa/include/frameless/private/framelesswindow_p.h b/QtRpa/include/frameless/private/framelesswindow_p.h deleted file mode 100644 index 1ca80e3..0000000 --- a/QtRpa/include/frameless/private/framelesswindow_p.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include "common/private/object_p.h" -namespace QT_NAMESPACE { - class QMenu; -} -namespace shelllet { - namespace frameless { - class DelegateWindow; - class TitleBarWidget; - class FramelessWindowPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(FramelessWindow) - public: - DelegateWindow* delegateWindow = nullptr; - QMenu* menu = nullptr; - TitleBarWidget* titleBar = nullptr; - WindowTypeFlags flags; - LONG currentStyle; - LONG currentExStyle; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/frameless/private/mainwindow_p.h b/QtRpa/include/frameless/private/mainwindow_p.h deleted file mode 100644 index 157bfae..0000000 --- a/QtRpa/include/frameless/private/mainwindow_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "framelesswindow_p.h" -namespace shelllet { - namespace frameless{ - class MainWindowPrivate : public FramelessWindowPrivate { - Q_DECLARE_PUBLIC(MainWindow) - public: - SizePolicyFlags fixedSize; - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/frameless/standardbutton.h b/QtRpa/include/frameless/standardbutton.h deleted file mode 100644 index 2e6c1ba..0000000 --- a/QtRpa/include/frameless/standardbutton.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "common.hpp" -#include "qsvgwidget.h" -namespace shelllet { - namespace frameless { - enum class ButtonType { - Close, - Minimize, - Maximize, - Restore - }; - class StandardButtonPrivate; - class StandardButton : public QSvgWidget, public Object { - Q_DECLARE_PRIVATE_D(Object::d_ptr, StandardButton) - Q_OBJECT - public: - StandardButton(ButtonType t, QWidget* parent = nullptr); - - - signals: - void clicked(); - protected slots: - void applicationStateChanged(Qt::ApplicationState state); - protected: - void paintEvent(QPaintEvent* event); - - void mousePressEvent(QMouseEvent* event) override; - - void enterEvent(QEvent* event) override; - - void leaveEvent(QEvent* event) override; - - void mouseReleaseEvent(QMouseEvent* event) override; - - QSize sizeHint() const override; - }; - - } -} \ No newline at end of file diff --git a/QtRpa/include/frameless/titlebarwidget.h b/QtRpa/include/frameless/titlebarwidget.h deleted file mode 100644 index 8ee621d..0000000 --- a/QtRpa/include/frameless/titlebarwidget.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "qwidget.h" -#include "qevent.h" -#include "flags.h" -namespace shelllet { - namespace frameless { - class TitleBarWidgetPrivate; - class TitleBarWidget : public QWidget { - Q_OBJECT - Q_DECLARE_PRIVATE(TitleBarWidget) - public: - explicit TitleBarWidget(QWidget* parent = nullptr, WindowTypeFlags f = WindowTypeFlags()); - virtual ~TitleBarWidget() {} - - void setWindowTypes(WindowTypeFlags f); - - void setCustomButton(QWidget* c); - - bool underMouse(); - - void switchToMaxButton(); - void switchToRestoreButton(); - void setTitleTextBlurRadius(qreal blurRadius); - signals: - void minimizeButtonClicked(); - void restoreButtonClicked(); - void maximizeButtonClicked(); - void closeButtonClicked(); - void iconDoubleClicked(); - protected: - void paintEvent(QPaintEvent* event); - - void resizeEvent(QResizeEvent* event) override; - - }; - - } -} diff --git a/QtRpa/include/graphics/code.xxxx b/QtRpa/include/graphics/code.xxxx deleted file mode 100644 index c4c672d..0000000 --- a/QtRpa/include/graphics/code.xxxx +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "elementitem.h" -namespace shelllet { - namespace graphics { - class CodePrivate; - class Code : public ElementItem { - Q_OBJECT - Q_DECLARE_PRIVATE_D(Object::d_ptr, Code) - - - - public: - Q_INVOKABLE Code(const std::shared_ptr& property, QGraphicsItem* parent = 0); - ~Code(); - - bool eventFilter(QObject* watched, QEvent* event) override; - - }; - } -} - - -Q_DECLARE_METATYPE(shelllet::graphics::Code*) \ No newline at end of file diff --git a/QtRpa/include/graphics/filedeleteitem.xxx b/QtRpa/include/graphics/filedeleteitem.xxx deleted file mode 100644 index 4f2d7d2..0000000 --- a/QtRpa/include/graphics/filedeleteitem.xxx +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "graphics/elementitem.h" -#include "common.hpp" -#include "properties.hpp" -#include "qgraphicswidget.h" -namespace shelllet { - namespace graphics { - class FileDeletePrivate; - class FileDelete : public ElementItem { - Q_OBJECT - Q_DECLARE_PRIVATE_D(Object::d_ptr, FileDelete) - public: - Q_INVOKABLE FileDelete(const std::shared_ptr& property, QGraphicsItem* parent = 0); - - void paintWindowFrame(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; - - - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; - - protected: - - - - QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const override; - - private: - - }; - } -} -Q_DECLARE_METATYPE(shelllet::graphics::FileDelete*) \ No newline at end of file diff --git a/QtRpa/include/graphics/private/code_p.h b/QtRpa/include/graphics/private/code_p.h deleted file mode 100644 index ee71b82..0000000 --- a/QtRpa/include/graphics/private/code_p.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "elementitem_p.h" -#include "qpushbutton.h" -#include "Qsci/qsciscintilla.h" -#include "qgraphicsproxywidget.h" -#include "Qsci/qscilexerpython.h" -#include "frameless.hpp" -namespace shelllet { - namespace interpreter { - class CodeDialog; - class CodePrivate : public ElementPrivate { - Q_DECLARE_PUBLIC(Code) - - inline interpreter::Code* pFunc() - { - return dynamic_cast(qGetPtrHelper(prop.get())); - } - - inline const interpreter::Code* pFunc() const - { - return dynamic_cast(qGetPtrHelper(prop.get())); - } - - public: - - void setupUi(Code* parent); - - QPushButton* button = nullptr; - CodeDialog* dialog = nullptr; - QGraphicsProxyWidget* proxy = nullptr; - QsciLexerPython* lexer; - }; - } -} diff --git a/QtRpa/include/graphics/processstartitem.xxxx b/QtRpa/include/graphics/processstartitem.xxxx deleted file mode 100644 index 30e1186..0000000 --- a/QtRpa/include/graphics/processstartitem.xxxx +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "graphics/elementitem.h" -#include "common.hpp" -#include "properties.hpp" -#include "qgraphicswidget.h" -namespace shelllet { - namespace graphics { - class ProcessStartPrivate; - class ProcessStart : public ElementItem { - Q_OBJECT - Q_DECLARE_PRIVATE_D(Object::d_ptr, ProcessStart) - public: - Q_INVOKABLE ProcessStart(const std::shared_ptr& property, QGraphicsItem* parent = 0); - protected: - - - - private: - - }; - } -} -Q_DECLARE_METATYPE(shelllet::graphics::ProcessStart*) \ No newline at end of file diff --git a/QtRpa/include/graphics/sequenceitem.h b/QtRpa/include/graphics/sequenceitem.h deleted file mode 100644 index 04408a5..0000000 --- a/QtRpa/include/graphics/sequenceitem.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "graphics/containeritem.h" -#include "common.hpp" -#include "properties.hpp" -#include "qgraphicswidget.h" -namespace shelllet { - namespace interpreter { - class SequencePrivate; - class Sequence : public Container { - Q_OBJECT - Q_DECLARE_PRIVATE_D(Object::d_ptr, Sequence) - public: - //Q_INVOKABLE Sequence(const std::shared_ptr& property, QGraphicsItem* parent = nullptr); - protected: - - - //void resizeEvent(QGraphicsSceneResizeEvent* event) override; - - - - - - }; - } -} -Q_DECLARE_METATYPE(shelllet::interpreter::Sequence*) \ No newline at end of file diff --git a/QtRpa/include/interpreter.hpp b/QtRpa/include/interpreter.hpp deleted file mode 100644 index d336110..0000000 --- a/QtRpa/include/interpreter.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include "common/framework.h" - -#include "interpreter/composite_property.h" -#include "interpreter/consoleapplication.h" -#include "interpreter/element.h" -#include "interpreter/propparser.h" -//#include "interpreter/error.h" - -using namespace shelllet::interpreter; diff --git a/QtRpa/include/interpreter/arrowitem.h b/QtRpa/include/interpreter/arrowitem.h deleted file mode 100644 index 2ab52c0..0000000 --- a/QtRpa/include/interpreter/arrowitem.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "svgitem.h" - -namespace shelllet { - namespace interpreter { - class ArrowItemPrivate; - class ArrowItem : public SvgItem - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, ArrowItem) - public: - ArrowItem(QGraphicsItem* parent = nullptr); - protected: - //void setGeometry(const QRectF& rect) override; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/component.h b/QtRpa/include/interpreter/component.h deleted file mode 100644 index ea53595..0000000 --- a/QtRpa/include/interpreter/component.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "qgraphicswidget.h" -#include "common.hpp" -#include "qgraphicslinearlayout.h" -namespace shelllet { - namespace interpreter { - class ComponentPrivate; - - class Component : public QGraphicsWidget, public Object { - Q_DECLARE_PRIVATE_D(Object::d_ptr, Component) - - protected: - Component(ComponentPrivate&, QGraphicsItem* parent = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags()); - - public: - virtual Component* nextItem() const; - Component* previousItem() const; - - void setNextItem(const Component* item); - void setPreviousItem(const Component* item); - - virtual void removeItem(QGraphicsLayoutItem* item); - - - void setGeometry(const QRectF& rect) override; - - //QGraphicsLinearLayout* linearLayout() const; - private: - - }; - } -} - diff --git a/QtRpa/include/interpreter/composite_property.h b/QtRpa/include/interpreter/composite_property.h deleted file mode 100644 index 33fbc91..0000000 --- a/QtRpa/include/interpreter/composite_property.h +++ /dev/null @@ -1,76 +0,0 @@ -#pragma once -#include "property.h" -namespace shelllet { - namespace interpreter { - enum DiagramType { Step, Conditional, StartEnd, Io }; - - class CompositePropertyPrivate; - class CompositeProperty : public Property - { - Q_OBJECT - Q_DECLARE_PRIVATE(CompositeProperty) - public: - - CompositeProperty(const XmlNode& node, QObject* parent = nullptr); - virtual QString identifier() const { return ""; } - - void restore_from_xml(const std::string& xml); - - - - virtual int getPropertyMetaTypeID() const { return 0; } - - virtual String category() const; - virtual void jsCode(std::ostringstream& ss) const { } - int32_t getId() const; - void setId(int32_t id); - //virtual void toXml(pugi::xml_node& node); - //virtual void fromXml(const pugi::xml_node& node); - int32_t getParentId() const; - void setParentId(int32_t id); - - virtual void getCode(std::ostringstream& stream) {} - virtual String getImport() const; - virtual void exec(); - virtual void getDefines(std::ostringstream& oss); - - virtual std::shared_ptr getNode() override; - - - std::string json() const override; - - protected: - CompositeProperty(CompositePropertyPrivate& d, const XmlNode& node, QObject* parent = nullptr); - public: - virtual property::PropertySheet* getInput(property::PropertyBrowser*); - - virtual property::PropertySheet* getOutput(property::PropertyBrowser*); - - DiagramType type(); - float x() const; - float y() const; - - void setX(float x); - void setY(float y); - - float width() const; - float height() const; - - String meta() const; - QPointF pos() const; - - //std::string meta_; - - static UniquePointer CreateNode(const XmlNode& node); - //static std::unique_ptr CreateNode(const QString& name); - }; - - extern std::map> ACTIVITY_PROPERTIES; - - class AbstractActivityProperty { - public: - virtual interpreter::CompositeProperty* getProperty() = 0; - }; - } -} -Q_DECLARE_METATYPE(shelllet::interpreter::CompositeProperty*) \ No newline at end of file diff --git a/QtRpa/include/interpreter/consoleapplication.h b/QtRpa/include/interpreter/consoleapplication.h deleted file mode 100644 index 73bb779..0000000 --- a/QtRpa/include/interpreter/consoleapplication.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -namespace shelllet { - namespace events { class ConsoleEvent; } - namespace interpreter { - class ConsoleApplicationPrivate; - class ConsoleApplication : public Runnable, public Object{ - Q_DECLARE_PRIVATE(ConsoleApplication) - public: - ConsoleApplication(); - ~ConsoleApplication(); - void initialize(); - void run(QEvent* event) override; - - static String translate(const String& xml); - - static ConsoleApplication* getInstance(); - protected: - ConsoleApplication(ConsoleApplicationPrivate& d); - }; - } -} diff --git a/QtRpa/include/interpreter/containeritem.h b/QtRpa/include/interpreter/containeritem.h deleted file mode 100644 index b3ffb6d..0000000 --- a/QtRpa/include/interpreter/containeritem.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once -#include "interpreter/element.h" -#include "common.hpp" - -#include "qgraphicswidget.h" -namespace shelllet { - namespace interpreter { - class ContainerPrivate; - class Container : public Element { - Q_DECLARE_PRIVATE_D(Object::d_ptr, Container) - - public: - Container( Element* parent = nullptr, Object* p = nullptr); - int insertItem(int index, QGraphicsLayoutItem* item); - - void removeItem(int index); - - - void setGeometry(const QRectF& rect) override; - int indexWidget(const QGraphicsLayoutItem* item) const; - - - bool isEmpty() const; - - - void removeItem(QGraphicsLayoutItem* item) override; - void dropItem(const QMimeData* mimeData, Component* current); - - - - Component* itemAt(int index) const; - - - protected: - void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override; - - - void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override; - - - void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override; - - QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) override; - Container(ContainerPrivate&, Element* parent = nullptr, Object * p=nullptr); - - - - - void hideExtraItem(); - void showExtraItem(); - void updateExtraItem(); - - void customEvent(QEvent* event) override; - - - - - void addItem(Element* item) override; - - private: - - - void addItem(QGraphicsLayoutItem* item); - - }; - } -} -Q_DECLARE_METATYPE(shelllet::interpreter::Container*) \ No newline at end of file diff --git a/QtRpa/include/interpreter/dropareaitem.h b/QtRpa/include/interpreter/dropareaitem.h deleted file mode 100644 index 8fb8a52..0000000 --- a/QtRpa/include/interpreter/dropareaitem.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -#include "component.h" -namespace shelllet { - namespace interpreter { - class DropAreaPrivate; - class DropArea : public Component - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, DropArea) - public: - - DropArea(QGraphicsItem* parent = nullptr); - - - - - - - void setGeometry(const QRectF& rect) override; - - protected: - - //QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const override; - - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; - - void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override; - - - void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override; - - - void dropEvent(QGraphicsSceneDragDropEvent* event) override; - - - QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const override; - - - void removeItem(QGraphicsLayoutItem* item) override; - private: - void addItem(QGraphicsLayoutItem* item); - - - void hideExtraItem(); - void showExtraItem(); - - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/element.h b/QtRpa/include/interpreter/element.h deleted file mode 100644 index 27781c6..0000000 --- a/QtRpa/include/interpreter/element.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once -#include "component.h" -#include "common.hpp" -namespace shelllet { - namespace interpreter { - class ElementPrivate; - class Element; - class WrapperElement { - public: - WrapperElement(Element* item) : item(item) { - - } - public: - Element* item; - }; - - class Element : public Component { - Q_DECLARE_PRIVATE_D(Object::d_ptr, Element) - public: - - Element( QGraphicsItem* parent = nullptr, Object* p = nullptr); - void paintWindowFrame(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; - // std::shared_ptr prop(); - - - Component* nextItem() const override; - - public: - //static ElementItem* CreateElement(const py::object& property, QGraphicsItem* parent = nullptr); - virtual void addItem(Element* item); - - virtual CompositeProperty* prop(); - protected: - Element(ElementPrivate&, QGraphicsItem* parent = nullptr, Object* p=nullptr); - void contextMenuEvent(QGraphicsSceneContextMenuEvent* event) override; - - - - Qt::WindowFrameSection windowFrameSectionAt(const QPointF& pos) const override; - - - bool windowFrameEvent(QEvent* e) override; - - QMimeData* mimeData(); - - private: - - }; - } -} - diff --git a/QtRpa/include/interpreter/elementmimedata.h b/QtRpa/include/interpreter/elementmimedata.h deleted file mode 100644 index c495f8e..0000000 --- a/QtRpa/include/interpreter/elementmimedata.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter { - class Element; - class ElementMimeDataPrivate; - class ElementMimeData : public MimeData - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, ElementMimeData) - public: - ElementMimeData(); - - void setElementItem(Element* item); - - Element* elementItem()const; - private: - - }; - - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/framework.h b/QtRpa/include/interpreter/framework.h deleted file mode 100644 index 2bbf452..0000000 --- a/QtRpa/include/interpreter/framework.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include -#include -#include -#include "common.hpp" - -//#include - -namespace py = pybind11; - diff --git a/QtRpa/include/interpreter/keyboard.h b/QtRpa/include/interpreter/keyboard.h deleted file mode 100644 index 7400ebe..0000000 --- a/QtRpa/include/interpreter/keyboard.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -namespace shelllet { - namespace interpreter { - class KeyboardPrivate; - class Keyboard : public Object { - Q_DECLARE_PRIVATE(Keyboard) - public: - static LPINPUT SendInput(WORD wVk, BOOL u); - - static UINT Release(LPINPUT input); - - static void SendText(const std::wstring& text); - - static SHORT KeyCode(char ch); - - static void Simulate(const std::vector& wVks); - static std::string KeyName(WORD wVk); - static bool GetAsyncKeyState(std::uint8_t wVk) - { - return Invoke<&::GetAsyncKeyState>(wVk) & (1 << 15); - } - static void InstallHook( const v8::Local& fn); - static BOOL RemoveHook(); - - protected: - Keyboard(KeyboardPrivate&d); - }; - - } -} diff --git a/QtRpa/include/interpreter/mouse.h b/QtRpa/include/interpreter/mouse.h deleted file mode 100644 index b10abaa..0000000 --- a/QtRpa/include/interpreter/mouse.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter { - class MousePrivate; - class Mouse : public Object { - Q_DECLARE_PRIVATE(Mouse) - public: - Mouse(); - static void Move(int x, int y); - - static void Click(); - - static void RightClick(); - - static void MoveAndClick(int x, int y); - - static void InstallHook(); - static BOOL RemoveHook(); - protected: - - Mouse(MousePrivate& d); - - }; - - } -} diff --git a/QtRpa/include/interpreter/mybase.h b/QtRpa/include/interpreter/mybase.h deleted file mode 100644 index 8750f9a..0000000 --- a/QtRpa/include/interpreter/mybase.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -namespace shelllet { - namespace interpreter{ - class MybasePrivate; - class Mybase { - // Q_DECLARE_PRIVATE(Mybase) - - public: - Mybase(); - std::string name(); - }; - - - } -} - - diff --git a/QtRpa/include/interpreter/placeholderitem.h b/QtRpa/include/interpreter/placeholderitem.h deleted file mode 100644 index 14842b5..0000000 --- a/QtRpa/include/interpreter/placeholderitem.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "common.hpp" -#include "qgraphicsitem.h" -#include "qgraphicslayout.h" - - -namespace shelllet { - namespace interpreter { - class PlaceholderItemPrivate; - class PlaceholderItem : public QGraphicsRectItem, public QGraphicsLayoutItem, public Object - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, PlaceholderItem) - public: - - PlaceholderItem(QGraphicsItem* parent = 0); - - protected: - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; - - QRectF boundingRect() const override; - - void setGeometry(const QRectF& rect); - - QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const override; - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/component_p.h b/QtRpa/include/interpreter/private/component_p.h deleted file mode 100644 index ccdabcb..0000000 --- a/QtRpa/include/interpreter/private/component_p.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "common/private/object_p.h" -#include "qgraphicslinearlayout.h" -namespace shelllet { - namespace interpreter { - class Component; - - class ComponentPrivate : public ObjectPrivate { - public: - QGraphicsLinearLayout* layout = nullptr; - - Component* next; - Component* previous; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/composite_property_p.h b/QtRpa/include/interpreter/private/composite_property_p.h deleted file mode 100644 index 9bbd59a..0000000 --- a/QtRpa/include/interpreter/private/composite_property_p.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "property_p.h" -//#include "properties/helper.h" -namespace shelllet { - namespace interpreter { - class CompositePropertyPrivate : public PropertyPrivate{ - friend class boost::serialization::access; - - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - ar& dtype_; - ar& x_; - ar& y_; - ar& width_; - ar& height_; - } - public: - PropertySheet* m_input; - PropertySheet* m_output; - int32_t id_; - int32_t pid_; - - float x_; - float y_; - - float width_; - float height_; - DiagramType dtype_; - String meta; - String category; - - }; -} -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/consoleapplication_p.h b/QtRpa/include/interpreter/private/consoleapplication_p.h deleted file mode 100644 index 43cfd7b..0000000 --- a/QtRpa/include/interpreter/private/consoleapplication_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace shelllet { - namespace interpreter { - class ConsoleApplicationPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(ConsoleApplication) - public: - - std::unique_ptr guard; - }; - } -} diff --git a/QtRpa/include/interpreter/private/containeritem_p.h b/QtRpa/include/interpreter/private/containeritem_p.h deleted file mode 100644 index 6276c80..0000000 --- a/QtRpa/include/interpreter/private/containeritem_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "element_p.h" - -namespace shelllet { - namespace interpreter { - class DropArea; - class SimpleTextItem; - class Container; - class ContainerPrivate : public ElementPrivate { - Q_DECLARE_PUBLIC(Container) - public: - SimpleTextItem* description = nullptr; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/element_p.h b/QtRpa/include/interpreter/private/element_p.h deleted file mode 100644 index 4dffedf..0000000 --- a/QtRpa/include/interpreter/private/element_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "component_p.h" - -namespace shelllet { - namespace interpreter { - class ElementPrivate : public ComponentPrivate { - public: - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/elementmimedata_p.h b/QtRpa/include/interpreter/private/elementmimedata_p.h deleted file mode 100644 index cc746ad..0000000 --- a/QtRpa/include/interpreter/private/elementmimedata_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "common/private/mimedata_p.h" - -namespace shelllet { - namespace interpreter { - - class ElementMimeDataPrivate : public MimeDataPrivate { - public: - Element* item = nullptr; - }; - - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/mybase_p.h b/QtRpa/include/interpreter/private/mybase_p.h deleted file mode 100644 index 5498f0f..0000000 --- a/QtRpa/include/interpreter/private/mybase_p.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class MybasePrivate : public ObjectPrivate { - //Q_DECLARE_PUBLIC(Mybase) - public: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/process_p.h b/QtRpa/include/interpreter/private/process_p.h deleted file mode 100644 index d677184..0000000 --- a/QtRpa/include/interpreter/private/process_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace interpreter{ - class ProcessPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(Process) - public: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/property_p.h b/QtRpa/include/interpreter/private/property_p.h deleted file mode 100644 index f175299..0000000 --- a/QtRpa/include/interpreter/private/property_p.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "pugixml.hpp" -#include "boost/serialization/list.hpp" -#include "boost/serialization/string.hpp" -#include "boost/serialization/version.hpp" -#include "private/qobject_p.h" -#include "qicon.h" -class QtProperty; -namespace shelllet { - namespace interpreter { - class PropertyPrivate : public QObjectPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& m_displayName; - ar& icon; - } - - public: - String m_displayName; - PropertySheet* m_misc; - String tagName; - QIcon icon; - }; - } -} -BOOST_CLASS_VERSION(shelllet::interpreter::PropertyPrivate, 1) diff --git a/QtRpa/include/interpreter/private/propparser_p.h b/QtRpa/include/interpreter/private/propparser_p.h deleted file mode 100644 index c872971..0000000 --- a/QtRpa/include/interpreter/private/propparser_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PropParserPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PropParser) - public: - - py::object ooo; - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/pyabstracteditorfactory_p.h b/QtRpa/include/interpreter/private/pyabstracteditorfactory_p.h deleted file mode 100644 index ac47af7..0000000 --- a/QtRpa/include/interpreter/private/pyabstracteditorfactory_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyAbstractEditorFactoryPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyAbstractEditorFactory) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pyactivityproperty_p.h b/QtRpa/include/interpreter/private/pyactivityproperty_p.h deleted file mode 100644 index f56b9fe..0000000 --- a/QtRpa/include/interpreter/private/pyactivityproperty_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "composite_property_p.h" -namespace shelllet { - namespace interpreter{ - class PyActivityPropertyPrivate : public CompositePropertyPrivate { - Q_DECLARE_PUBLIC(PyActivityProperty) - public: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/pycontainer_p.h b/QtRpa/include/interpreter/private/pycontainer_p.h deleted file mode 100644 index a465da9..0000000 --- a/QtRpa/include/interpreter/private/pycontainer_p.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "containeritem_p.h" -namespace shelllet { - namespace interpreter{ - class PyContainerPrivate : public ContainerPrivate { - // Q_DECLARE_PUBLIC(PyContainer) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pyelement_p.h b/QtRpa/include/interpreter/private/pyelement_p.h deleted file mode 100644 index a3ff8ec..0000000 --- a/QtRpa/include/interpreter/private/pyelement_p.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "element_p.h" -namespace shelllet { - namespace interpreter{ - class PyElementItemPrivate : public ElementPrivate { - // Q_DECLARE_PUBLIC(PyElementItem) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pyitem_p.h b/QtRpa/include/interpreter/private/pyitem_p.h deleted file mode 100644 index 298cb96..0000000 --- a/QtRpa/include/interpreter/private/pyitem_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyItemPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyItem) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pylayout_p.h b/QtRpa/include/interpreter/private/pylayout_p.h deleted file mode 100644 index bc725f0..0000000 --- a/QtRpa/include/interpreter/private/pylayout_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyLayoutPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyLayout) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pylayoutitem_p.h b/QtRpa/include/interpreter/private/pylayoutitem_p.h deleted file mode 100644 index 88602dc..0000000 --- a/QtRpa/include/interpreter/private/pylayoutitem_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyLayoutItemPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyLayoutItem) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pylexerpython_p.h b/QtRpa/include/interpreter/private/pylexerpython_p.h deleted file mode 100644 index 23f8bf6..0000000 --- a/QtRpa/include/interpreter/private/pylexerpython_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyLexerPythonPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyLexerPython) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pylinearlayout_p.h b/QtRpa/include/interpreter/private/pylinearlayout_p.h deleted file mode 100644 index 0dec9af..0000000 --- a/QtRpa/include/interpreter/private/pylinearlayout_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyLinearLayoutPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyLinearLayout) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pylineeditfactory_p.h b/QtRpa/include/interpreter/private/pylineeditfactory_p.h deleted file mode 100644 index 26981f5..0000000 --- a/QtRpa/include/interpreter/private/pylineeditfactory_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyLineEditFactoryPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyLineEditFactory) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pymodule_p.h b/QtRpa/include/interpreter/private/pymodule_p.h deleted file mode 100644 index c99868e..0000000 --- a/QtRpa/include/interpreter/private/pymodule_p.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace interpreter{ - - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/pypropertybrowser_p.h b/QtRpa/include/interpreter/private/pypropertybrowser_p.h deleted file mode 100644 index d3153db..0000000 --- a/QtRpa/include/interpreter/private/pypropertybrowser_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyPropertyBrowserPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyPropertyBrowser) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pypropertysheet_p.h b/QtRpa/include/interpreter/private/pypropertysheet_p.h deleted file mode 100644 index bdf9d18..0000000 --- a/QtRpa/include/interpreter/private/pypropertysheet_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyPropertySheetPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyPropertySheet) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pypushbutton_p.h b/QtRpa/include/interpreter/private/pypushbutton_p.h deleted file mode 100644 index d74f93e..0000000 --- a/QtRpa/include/interpreter/private/pypushbutton_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyPushButtonPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyPushButton) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pyscintilla_p.h b/QtRpa/include/interpreter/private/pyscintilla_p.h deleted file mode 100644 index fb1f7bf..0000000 --- a/QtRpa/include/interpreter/private/pyscintilla_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter { - class PyScintillaPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyScintilla) - public: - UniquePointerscintilla; - UniquePointer proxyWidget; - }; - } -} diff --git a/QtRpa/include/interpreter/private/pystderroutstreamredirect_p.h b/QtRpa/include/interpreter/private/pystderroutstreamredirect_p.h deleted file mode 100644 index 725e69f..0000000 --- a/QtRpa/include/interpreter/private/pystderroutstreamredirect_p.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "common.hpp" -#include "common/private/object_p.h" -namespace pybind11 { - class object; -} -namespace shelllet { - namespace interpreter { - - class PyStdErrOutStreamRedirectPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyStdErrOutStreamRedirect) - public: - UniquePointer stdout_raw; - UniquePointer stderr_raw; - UniquePointer stdout_buffer; - UniquePointer stderr_buffer; - }; - } -} diff --git a/QtRpa/include/interpreter/private/pystring_p.h b/QtRpa/include/interpreter/private/pystring_p.h deleted file mode 100644 index 72bdca7..0000000 --- a/QtRpa/include/interpreter/private/pystring_p.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyStringPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyString) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pystringpropertymanager_p.h b/QtRpa/include/interpreter/private/pystringpropertymanager_p.h deleted file mode 100644 index 14be819..0000000 --- a/QtRpa/include/interpreter/private/pystringpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyStringPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyStringPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pywidget_p.h b/QtRpa/include/interpreter/private/pywidget_p.h deleted file mode 100644 index 7999378..0000000 --- a/QtRpa/include/interpreter/private/pywidget_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter{ - class PyWidgetPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyWidget) - public: - }; - } -} diff --git a/QtRpa/include/interpreter/private/pyxmlattribute_p.h b/QtRpa/include/interpreter/private/pyxmlattribute_p.h deleted file mode 100644 index 42368fb..0000000 --- a/QtRpa/include/interpreter/private/pyxmlattribute_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace interpreter{ - class PyXmlAttributePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyXmlAttribute) - public: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/pyxmldocument_p.h b/QtRpa/include/interpreter/private/pyxmldocument_p.h deleted file mode 100644 index 1e1be6b..0000000 --- a/QtRpa/include/interpreter/private/pyxmldocument_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace interpreter{ - class PyXmlDocumentPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyXmlDocument) - public: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/pyxmlnode_p.h b/QtRpa/include/interpreter/private/pyxmlnode_p.h deleted file mode 100644 index 8ca310a..0000000 --- a/QtRpa/include/interpreter/private/pyxmlnode_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace interpreter{ - class PyXmlNodePrivate : public XmlNodePrivate { - Q_DECLARE_PUBLIC(PyXmlNode) - public: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/private/scriptparser_p.h b/QtRpa/include/interpreter/private/scriptparser_p.h deleted file mode 100644 index 20506a4..0000000 --- a/QtRpa/include/interpreter/private/scriptparser_p.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "common/private/object_p.h" -namespace pybind11 { - class scoped_interpreter; -} -namespace shelllet { - namespace interpreter { - class ScriptParserPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(ScriptParser) - public: - String code; - - //std::unique_ptr guard; - }; - } -} diff --git a/QtRpa/include/interpreter/private/svgitem_p.h b/QtRpa/include/interpreter/private/svgitem_p.h deleted file mode 100644 index 02cce85..0000000 --- a/QtRpa/include/interpreter/private/svgitem_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "common/private/object_p.h" - -namespace shelllet { - namespace interpreter { - class SvgItemPrivate : public ObjectPrivate { - public: - QSize size; - }; - - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/process.xx b/QtRpa/include/interpreter/process.xx deleted file mode 100644 index 0768ab5..0000000 --- a/QtRpa/include/interpreter/process.xx +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once - - -namespace shelllet { - namespace interpreter{ - class ProcessPrivate; - class Process : public Object { - Q_DECLARE_PRIVATE(Process) - public: - - static bool Start(const String& filename, const std::vector& args); - - static BOOL EnumModule(DWORD th32ProcessID, const std::function& cb); - - static BOOL EnumProcess(const std::function& cb); - - static BOOL EnumThread(const std::function& cb); - - static BOOL RunAs(const std::wstring& username, const std::wstring& password, const std::wstring& application, const std::wstring& commandLine, const std::wstring& currentDirectory); - static BOOL CreateProcessWithToken(HANDLE hToken, const std::wstring& application, const std::wstring& commandLine, const std::wstring& currentDirectory); - static HANDLE OpenProcessToken(DWORD dwProcessId, DWORD desiredAccess = TOKEN_QUERY | TOKEN_DUPLICATE); - - static HANDLE OpenProcessToken(); - static BOOL AdjustTokenPrivileges(HANDLE hToken, const std::wstring& name, bool e); - - static BOOL RunAsDesktop(const std::wstring& application, const std::wstring& commandLine, const std::wstring& currentDirectory); - template - static TOKENINFORMATION TokenInformation(DWORD dwProcessId) { - auto hToken = OpenProcessToken(dwProcessId); - - BOOST_SCOPE_EXIT(hToken) { - CloseHandle(hToken); - }BOOST_SCOPE_EXIT_END; - - DWORD length = 0; - TOKENINFORMATION information = nullptr; - - if (!Invoke<&::GetTokenInformation>( - hToken, // handle to the access token - tokenInformationClass, // get information about the token's groups - nullptr, // pointer to PTOKEN_USER buffer - 0, // size of buffer - &length // receives required buffer size - ) && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { - return information; - } - - information = (TOKENINFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, length); - - if (!Invoke<&::GetTokenInformation>( - hToken, // handle to the access token - tokenInformationClass, // get information about the token's groups - (LPVOID)information, // pointer to PTOKEN_USER buffer - length, // size of buffer - &length // receives required buffer size - )) { - ::HeapFree(::GetProcessHeap(), 0, (LPVOID)information); - information = nullptr; - } - return information; - } - static std::pair GetUserFromProcess(DWORD dwProcessId); - public: - static void Embedded(py::module_& m); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/property.h b/QtRpa/include/interpreter/property.h deleted file mode 100644 index 8bfbe05..0000000 --- a/QtRpa/include/interpreter/property.h +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once -#include "pugixml.hpp" -#include "qobject.h" -#include "qstring.h" -#include -#include "boost/serialization/split_free.hpp" -#include "boost/serialization/split_free.hpp" -#include "boost/serialization/list.hpp" -#include "boost/serialization/string.hpp" -#include "boost/serialization/version.hpp" -#include "common.hpp" - -namespace shelllet { - namespace property { - class PropertySheet; - class PropertyBrowser; - } - namespace interpreter { - class PropertyPrivate; - - class Property : public QObject { - Q_OBJECT - Q_DECLARE_PRIVATE(Property) - public: - Property(QObject* parent = nullptr); - Property(const XmlNode& node, QObject* parent = nullptr); - virtual void initialize(); - String displayName() const; - - void deleteLater(); - - /*pugi::xml_node getNode() const;*/ - - virtual property::PropertySheet* getMisc(property::PropertyBrowser*); - - virtual std::vector getProp(property::PropertyBrowser* browser); - - virtual property::PropertySheet* getInput(property::PropertyBrowser*); - - virtual property::PropertySheet* getOutput(property::PropertyBrowser*); - - virtual std::shared_ptr getNode(); - - //virtual QByteArray toData() const = 0; - virtual std::string json() const = 0; - // virtual void fromData(const QByteArray& data) =0; - virtual QString metaName() const; - String tagName() const; - - QIcon icon() const; - - //virtual void toXml(pugi::xml_node& node); - //virtual void fromXml(const pugi::xml_node& node); - - signals: - void displayNameChanged(); - public: - static QString Prefix(); - - - protected: - Property(PropertyPrivate& d, const XmlNode& node, QObject* parent = nullptr); - private: - - //pugi::xml_node node_; - }; - - } -} -Q_DECLARE_METATYPE(pugi::xml_node) -Q_DECLARE_METATYPE(shelllet::interpreter::Property*) \ No newline at end of file diff --git a/QtRpa/include/interpreter/propparser.h b/QtRpa/include/interpreter/propparser.h deleted file mode 100644 index 74aa8e6..0000000 --- a/QtRpa/include/interpreter/propparser.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter { - class Element; - } - namespace interpreter { - - class PropParserPrivate; - class PropParser : public Object { - Q_DECLARE_PRIVATE(PropParser) - public: - - PropParser(const XmlNode& node, interpreter::Element* parentItem = nullptr, Object* parent = nullptr); - //py::object loadPy(const XmlNode& node); - interpreter::Element* element(); - - CompositeProperty* prop(); - // static PropParser* getInstance(); - protected: - PropParser(PropParserPrivate& d); - }; - } -} diff --git a/QtRpa/include/interpreter/pyabstracteditorfactory.h b/QtRpa/include/interpreter/pyabstracteditorfactory.h deleted file mode 100644 index 2dd21c7..0000000 --- a/QtRpa/include/interpreter/pyabstracteditorfactory.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyAbstractEditorFactoryPrivate; - - //template - class PyAbstractEditorFactory : public Object { - Q_DECLARE_PRIVATE(PyAbstractEditorFactory) - public: - PyAbstractEditorFactory(Object*parent = nullptr); - - - static void embedded(py::module_& m); - - protected: - PyAbstractEditorFactory(PyAbstractEditorFactoryPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pyactivityproperty.h b/QtRpa/include/interpreter/pyactivityproperty.h deleted file mode 100644 index 76edfaf..0000000 --- a/QtRpa/include/interpreter/pyactivityproperty.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "object.h" -namespace shelllet { - namespace interpreter{ - class PyActivityPropertyPrivate; - class PyActivityProperty : public CompositeProperty { - Q_DECLARE_PRIVATE(PyActivityProperty) - public: - PyActivityProperty(const XmlNode& node); - - std::shared_ptr getNode() override; - - - void exec() override; - static void embedded(py::module_& m); - - static void importModule(); - protected: - PyActivityProperty(PyActivityPropertyPrivate& d, const XmlNode&node); - - virtual property::PropertySheet* getInput(property::PropertyBrowser*) override; - - virtual property::PropertySheet* getOutput(property::PropertyBrowser*) override; - - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pycontainer.h b/QtRpa/include/interpreter/pycontainer.h deleted file mode 100644 index 33ef159..0000000 --- a/QtRpa/include/interpreter/pycontainer.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once -#include "common.hpp" -#include "pyelement.h" -#include "private/containeritem_p.h" -#include "containeritem.h" -namespace shelllet { - namespace interpreter { - //class PyContainerPrivate; - // template - class PyContainer : public PyElement { - //Q_DECLARE_PRIVATE_D(Object::d_ptr, PyContainer) - public: - /* PyContainer(ElementItem* parentItem, Object* parent = nullptr) - :PyElementItem<>(*new ContainerPrivate, parentItem, parent) - { - - }*/ - using PyElement::PyElement; - - //static void embedded(py::module_& m); - - - protected: - /*PyContainer(PyContainerPrivate& d, ElementItem* parentItem = nullptr, Object* parent = nullptr) - : ContainerBase(d, parentItem, parent){ - - }*/ - - //shelllet::interpreter::PyContainer::PyContainer(ElementItem* parentItem, Object* parent /*= nullptr*/) - // :PyContainer(*new PyContainerPrivate, parentItem, parent) - //{ - // - //} - public: - static void embedded(py::module_& m) - { - py::class_>(m, "Container") - .def(py::init()) - - // .def(QUOTED(getInput), &CompositeProperty::getInput) - //.def(QUOTED(getOutput), &CompositeProperty::getOutput) - //.def(QUOTED(getNode), &CompositeProperty::getNode) - ; - } - - }; - } -} diff --git a/QtRpa/include/interpreter/pyelement.h b/QtRpa/include/interpreter/pyelement.h deleted file mode 100644 index aaebed8..0000000 --- a/QtRpa/include/interpreter/pyelement.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include "common.hpp" -#include "element.h" -#include "private/element_p.h" -namespace shelllet { - namespace interpreter { - //class PyElementItemPrivate; - - template - class PyElement : public TBase { - //Q_DECLARE_PRIVATE_D(Object::d_ptr, PyElementItem) - public: - // PyElementItem(Object*parent = nullptr); - PyElement(Element* element, Object* parent = nullptr) - : TBase(element, parent) {} - // static void embedded(py::module_& m); - using TBase::TBase; - protected: - /*PyElementItem(PyElementItemPrivate& d, ElementItem* item, Object* parent = nullptr) - : TBase(d, item) - { - - }*/ - - //shelllet::interpreter::PyElementItem::PyElementItem( ElementItem* element, Object* parent /*= nullptr*/) - // :PyElementItem(*new PyElementItemPrivate, element, parent) - //{ - // - //} - - CompositeProperty* prop()override - { - PYBIND11_OVERRIDE_NAME(CompositeProperty*, TBase, "get_prop", prop); - } - public: - static void importModule() { - py::module::import("interpreter").attr(QUOTED(Element)); - - } - static void embedded(py::module_& m) - { - py::class_>(m, "Element") - .def(py::init()) - //.def("get_prop", &TBase::prop) - ; - - - /*py::class_(m, "WrapperElement") - - ;*/ - } - - }; - } -} diff --git a/QtRpa/include/interpreter/pyitem.h b/QtRpa/include/interpreter/pyitem.h deleted file mode 100644 index 41f115f..0000000 --- a/QtRpa/include/interpreter/pyitem.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyItemPrivate; - class PyItem : public Object { - Q_DECLARE_PRIVATE(PyItem) - public: - PyItem(Object*parent = nullptr); - static void embeddedModule(py::module_& m); - protected: - PyItem(PyItemPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pylayout.h b/QtRpa/include/interpreter/pylayout.h deleted file mode 100644 index bd3272b..0000000 --- a/QtRpa/include/interpreter/pylayout.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyLayoutPrivate; - class PyLayout : public Object { - Q_DECLARE_PRIVATE(PyLayout) - public: - PyLayout(Object*parent = nullptr); - static void embeddedModule(py::module_& m); - protected: - PyLayout(PyLayoutPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pylayoutitem.h b/QtRpa/include/interpreter/pylayoutitem.h deleted file mode 100644 index f118ac6..0000000 --- a/QtRpa/include/interpreter/pylayoutitem.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyLayoutItemPrivate; - - - class PyLayoutItem : public Object { - Q_DECLARE_PRIVATE(PyLayoutItem) - public: - PyLayoutItem(Object*parent = nullptr); - static void embeddedModule(py::module_& m); - protected: - PyLayoutItem(PyLayoutItemPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pylexerpython.h b/QtRpa/include/interpreter/pylexerpython.h deleted file mode 100644 index 2c7d4a3..0000000 --- a/QtRpa/include/interpreter/pylexerpython.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyLexerPythonPrivate; - class PyLexerPython : public Object { - Q_DECLARE_PRIVATE(PyLexerPython) - public: - PyLexerPython(Object*parent = nullptr); - static void importAttr(); - static void embeddedModule(py::module_& m); - protected: - PyLexerPython(PyLexerPythonPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pylinearlayout.h b/QtRpa/include/interpreter/pylinearlayout.h deleted file mode 100644 index 0cb11dd..0000000 --- a/QtRpa/include/interpreter/pylinearlayout.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyLinearLayoutPrivate; - class PyLinearLayout : public Object { - Q_DECLARE_PRIVATE(PyLinearLayout) - public: - PyLinearLayout(Object*parent = nullptr); - static void importAttr(); - static void embeddedModule(py::module_& m); - protected: - PyLinearLayout(PyLinearLayoutPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pylineeditfactory.h b/QtRpa/include/interpreter/pylineeditfactory.h deleted file mode 100644 index 23a7e98..0000000 --- a/QtRpa/include/interpreter/pylineeditfactory.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyLineEditFactoryPrivate; - class PyLineEditFactory : public Object { - Q_DECLARE_PRIVATE(PyLineEditFactory) - public: - PyLineEditFactory(Object*parent = nullptr); - - static void embedded(py::module_& m); - protected: - PyLineEditFactory(PyLineEditFactoryPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pymodule.h b/QtRpa/include/interpreter/pymodule.h deleted file mode 100644 index bcb7c03..0000000 --- a/QtRpa/include/interpreter/pymodule.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -namespace shelllet { - namespace interpreter { - class PyModulePrivate; - class PyModule : public Object { - Q_DECLARE_PRIVATE(PyModule) - public: - PyModule(); - void importModules(); - void initLibPath(); - static PyModule* getInstance(); - }; - } -} diff --git a/QtRpa/include/interpreter/pypropertybrowser.h b/QtRpa/include/interpreter/pypropertybrowser.h deleted file mode 100644 index 10f1aa3..0000000 --- a/QtRpa/include/interpreter/pypropertybrowser.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyPropertyBrowserPrivate; - class PyPropertyBrowser : public Object { - Q_DECLARE_PRIVATE(PyPropertyBrowser) - public: - PyPropertyBrowser(Object*parent = nullptr); - static void embedded(py::module_& m); - protected: - PyPropertyBrowser(PyPropertyBrowserPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pypropertysheet.h b/QtRpa/include/interpreter/pypropertysheet.h deleted file mode 100644 index a412efe..0000000 --- a/QtRpa/include/interpreter/pypropertysheet.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyPropertySheetPrivate; - class PyPropertySheet : public Object { - Q_DECLARE_PRIVATE(PyPropertySheet) - public: - PyPropertySheet(Object*parent = nullptr); - static void embedded(py::module_& m); - protected: - PyPropertySheet(PyPropertySheetPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pypushbutton.h b/QtRpa/include/interpreter/pypushbutton.h deleted file mode 100644 index e25bc15..0000000 --- a/QtRpa/include/interpreter/pypushbutton.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyPushButtonPrivate; - class PyPushButton : public Object { - Q_DECLARE_PRIVATE(PyPushButton) - public: - PyPushButton(Object*parent = nullptr); - - static void importAttr(); - static void embeddedModule(py::module_& m); - protected: - PyPushButton(PyPushButtonPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pyscintilla.h b/QtRpa/include/interpreter/pyscintilla.h deleted file mode 100644 index db6d77d..0000000 --- a/QtRpa/include/interpreter/pyscintilla.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyScintillaPrivate; - class PyScintilla : public Object { - Q_DECLARE_PRIVATE(PyScintilla) - public: - PyScintilla(QGraphicsItem*parent = nullptr, Object*parent2 = nullptr); - static void importAttr(); - static void embeddedModule(py::module_& m); - protected: - PyScintilla(PyScintillaPrivate& d, QGraphicsItem* parent = nullptr, Object*parent2 = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pystderroutstreamredirect.h b/QtRpa/include/interpreter/pystderroutstreamredirect.h deleted file mode 100644 index d9f5428..0000000 --- a/QtRpa/include/interpreter/pystderroutstreamredirect.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter { - class PyStdErrOutStreamRedirectPrivate; - class PyStdErrOutStreamRedirect : public Object { - Q_DECLARE_PRIVATE(PyStdErrOutStreamRedirect) - public: - PyStdErrOutStreamRedirect(); - virtual ~PyStdErrOutStreamRedirect(); - - String stdoutString() const; - String stderrString()const; - - void initialize(); - void release(); - - static PyStdErrOutStreamRedirect* getInstance(); - - protected: - PyStdErrOutStreamRedirect(PyStdErrOutStreamRedirectPrivate& d); - }; - } -} diff --git a/QtRpa/include/interpreter/pystring.h b/QtRpa/include/interpreter/pystring.h deleted file mode 100644 index 710fe8d..0000000 --- a/QtRpa/include/interpreter/pystring.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyStringPrivate; - class PyString : public Object { - Q_DECLARE_PRIVATE(PyString) - public: - PyString(Object*parent = nullptr); - - static void embedded(py::module_& m); - protected: - PyString(PyStringPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pystringpropertymanager.h b/QtRpa/include/interpreter/pystringpropertymanager.h deleted file mode 100644 index 24a6ae8..0000000 --- a/QtRpa/include/interpreter/pystringpropertymanager.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyStringPropertyManagerPrivate; - class PyStringPropertyManager : public Object { - Q_DECLARE_PRIVATE(PyStringPropertyManager) - public: - PyStringPropertyManager(Object*parent = nullptr); - - static void embedded(py::module_& m); - static void importModule(); - protected: - PyStringPropertyManager(PyStringPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pywidget.h b/QtRpa/include/interpreter/pywidget.h deleted file mode 100644 index ba62ed3..0000000 --- a/QtRpa/include/interpreter/pywidget.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter{ - class PyWidgetPrivate; - class PyWidget : public Object { - Q_DECLARE_PRIVATE(PyWidget) - public: - PyWidget(Object*parent = nullptr); - static void embeddedModule(py::module_& m); - protected: - PyWidget(PyWidgetPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pyxmlattribute.h b/QtRpa/include/interpreter/pyxmlattribute.h deleted file mode 100644 index 87e2af1..0000000 --- a/QtRpa/include/interpreter/pyxmlattribute.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "object.h" -namespace shelllet { - namespace interpreter{ - class PyXmlAttribute { - public: - static void embedded(py::module_& m); - protected: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pyxmldocument.h b/QtRpa/include/interpreter/pyxmldocument.h deleted file mode 100644 index 066a67e..0000000 --- a/QtRpa/include/interpreter/pyxmldocument.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "object.h" -namespace shelllet { - namespace interpreter{ - - class PyXmlDocument { - public: - static void embedded(py::module_& m); - protected: - - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/pyxmlnode.h b/QtRpa/include/interpreter/pyxmlnode.h deleted file mode 100644 index add7941..0000000 --- a/QtRpa/include/interpreter/pyxmlnode.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "object.h" -namespace shelllet { - namespace interpreter{ - class PyXmlNode { - public: - static void embedded(py::module_& m); - protected: - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/interpreter/scriptparser.h b/QtRpa/include/interpreter/scriptparser.h deleted file mode 100644 index 6b0e7d8..0000000 --- a/QtRpa/include/interpreter/scriptparser.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace interpreter { - class ScriptParserPrivate; - class ScriptParser : public Object { - Q_DECLARE_PRIVATE(ScriptParser) - public: - ScriptParser(); - void loadFile(const Path& path); - String parseImports() const; - - String parseCode(std::int32_t hash); - - void exec(const Path& path, QObject* obj, const QMetaObject* meta); - - static ScriptParser* getInstance(); - }; - } -} diff --git a/QtRpa/include/interpreter/simpletextitem.h b/QtRpa/include/interpreter/simpletextitem.h deleted file mode 100644 index 515d067..0000000 --- a/QtRpa/include/interpreter/simpletextitem.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "common.hpp" -#include "qgraphicsitem.h" -#include "qgraphicslayoutitem.h" - -namespace shelllet { - namespace interpreter { - class SimpleTextItemPrivate; - class SimpleTextItem : public QGraphicsSimpleTextItem, public QGraphicsLayoutItem, public Object - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, SimpleTextItem) - public: - SimpleTextItem(QGraphicsItem* parent = nullptr); - SimpleTextItem(const QString& text, QGraphicsItem* parent = nullptr); - ~SimpleTextItem(); - void setColor(const QColor& color); - - protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const override; - void setGeometry(const QRectF& rect) override; - - }; - - } -} -Q_DECLARE_METATYPE(shelllet::interpreter::SimpleTextItem*) \ No newline at end of file diff --git a/QtRpa/include/interpreter/stringio.h b/QtRpa/include/interpreter/stringio.h deleted file mode 100644 index 9649979..0000000 --- a/QtRpa/include/interpreter/stringio.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -namespace shelllet { - namespace interpreter { - class StringIO { - public: - StringIO() = default; - static void write(const std::string& message); - - - static void embedded(py::module_& m); - - }; - } -} diff --git a/QtRpa/include/interpreter/svgitem.h b/QtRpa/include/interpreter/svgitem.h deleted file mode 100644 index 5bb03ce..0000000 --- a/QtRpa/include/interpreter/svgitem.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "common.hpp" -#include "qgraphicssvgitem.h" -#include "qgraphicslayout.h" - - -namespace shelllet { - namespace interpreter { - class SvgItemPrivate; - class SvgItem : public QGraphicsSvgItem, public QGraphicsLayoutItem, public Object - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, SvgItem) - public: - - SvgItem(const String& fileName, QGraphicsItem* parent = 0); - void setSize(const QSize& size); - protected: - - SvgItem(SvgItemPrivate&d, const String& fileName, QGraphicsItem* parent = 0); - - //void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override; - - //QRectF boundingRect() const override; - - void setGeometry(const QRectF& rect) override; - - QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const override; - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/textitem.h b/QtRpa/include/interpreter/textitem.h deleted file mode 100644 index b614ac5..0000000 --- a/QtRpa/include/interpreter/textitem.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "common.hpp" -#include "qgraphicsitem.h" -#include "qgraphicslayoutitem.h" - -namespace shelllet { - namespace interpreter { - class TextItemPrivate; - class TextItem : public QGraphicsTextItem, public QGraphicsLayoutItem, public Object - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, TextItem) - public: - TextItem(QGraphicsItem* parent = nullptr); - - void setColor(const QColor& color); - - protected: - QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint = QSizeF()) const override; - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/win.h b/QtRpa/include/interpreter/win.h deleted file mode 100644 index a212822..0000000 --- a/QtRpa/include/interpreter/win.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -namespace shelllet { - namespace interpreter { - template - static inline decltype(auto) Invoke(TArgs... args) - { - using T = typename std::invoke_result::type; - - if constexpr (std::is_same::value) { - auto hr = __Api(std::forward(args)...); - throw std::runtime_error(std::system_category().message(hr)); - } - - BOOST_SCOPE_EXIT(void) { - auto err = ::GetLastError(); - throw std::runtime_error(std::system_category().message(err)); - }BOOST_SCOPE_EXIT_END - return __Api(std::forward(args)...); - } - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter/winapi.xx b/QtRpa/include/interpreter/winapi.xx deleted file mode 100644 index 74ef475..0000000 --- a/QtRpa/include/interpreter/winapi.xx +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -namespace shelllet { - namespace interpreter { - class WinApiPrivate; - class WinApi : public Object { - Q_DECLARE_PRIVATE(WinApi) - public: - static HWND FindWindow(const String& windowName, const String& className); - - static bool MouseClick(HWND hWnd, const Point& point); - - static bool CloseWindow(HWND hWnd); - - static HWND GetDesktopWindow(); - - static Bool EnumWindows(const std::function& cb); - - static BOOL EnumChildWindows(HWND hWnd, const std::function& cb); - - static std::wstring GetWindowTitle(HWND hWnd); - - static BOOL SetForegroundWindow(HWND hWnd); - - static Image GrabDesktop(const Rect& rc); - - static Image GrabWindow(HWND hWnd, const Rect& rect); - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/consoleapplication.h b/QtRpa/include/interpreter2/consoleapplication.h deleted file mode 100644 index c5800e6..0000000 --- a/QtRpa/include/interpreter2/consoleapplication.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include -#include "inspector.h" -#include "common.hpp" - -QT_FORWARD_DECLARE_CLASS(QEvent) -namespace shelllet { - namespace interpreter { - class ConsoleApplicationPrivate; - class ConsoleApplication : public inspect::Receiver, public Runnable - { - Q_DECLARE_PRIVATE_D(p_, ConsoleApplication) - public: - ConsoleApplication(); - ~ConsoleApplication(); - void run(QEvent* event) override; - protected: - virtual void customEvent(QEvent* event) override; - protected: - inspect::InspectorVersion requestInspectorVersion() override; - inspect::InspectorList requestInspectorList() override; - void finished(); - private: - ConsoleApplicationPrivate* p_ = nullptr; - }; - } // namespace engine -} diff --git a/QtRpa/include/interpreter2/error.h b/QtRpa/include/interpreter2/error.h deleted file mode 100644 index e5f6037..0000000 --- a/QtRpa/include/interpreter2/error.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include -namespace shelllet { - namespace error { - std::string GetLastErrorMessage(); - void SetLastErrorMessage(const std::variant& err); - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/global/console.h b/QtRpa/include/interpreter2/global/console.h deleted file mode 100644 index aa40481..0000000 --- a/QtRpa/include/interpreter2/global/console.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace global { - class MyConsole { - public: - MyConsole() = default; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/global/console_implement.h b/QtRpa/include/interpreter2/global/console_implement.h deleted file mode 100644 index 8c7d5e3..0000000 --- a/QtRpa/include/interpreter2/global/console_implement.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include -#include "console.h" -#include "console_p.h" -#include "console_wrapper.h" - -namespace shelllet { - namespace global { - class Console : public MyConsoleWrapper - { - public: - using ReturnType = MyConsolePrivate; - using ReturnType2 = MyConsolePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - Console(const v8::FunctionCallbackInfo& args) : MyConsoleWrapper(*Private(args), args) - { - } - Console(MyConsole* p, const v8::FunctionCallbackInfo& args) : MyConsoleWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Console(v8::Isolate* isolate, const v8::Local& tpl) : MyConsoleWrapper(isolate, tpl) - {} - - Console(v8::Isolate* isolate, const v8::Local& proto) : MyConsoleWrapper(isolate, proto) - {} - - static const char* Name() { return "console"; } - public: - }; - } -} diff --git a/QtRpa/include/interpreter2/global/console_p.h b/QtRpa/include/interpreter2/global/console_p.h deleted file mode 100644 index 5fc2aef..0000000 --- a/QtRpa/include/interpreter2/global/console_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace global { - template - class MyConsolePrivate : public V8ObjectPrivate - { - public: - template - MyConsolePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : V8ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/QtRpa/include/interpreter2/global/console_wrapper.h b/QtRpa/include/interpreter2/global/console_wrapper.h deleted file mode 100644 index 19bb4d1..0000000 --- a/QtRpa/include/interpreter2/global/console_wrapper.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -namespace shelllet { - namespace global { - template - class MyConsoleWrapper : public ObjectWrapper - { - public: - template - MyConsoleWrapper(MyConsolePrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - MyConsoleWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - tpl->Set(isolate, "log", v8::FunctionTemplate::New(isolate, Print)); - } - MyConsoleWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - static void Print(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - std::vector list; - for (int i = 0; i < args.Length(); i++) { - list.push_back(ToWString({ isolate, args[i] })); - } - std::wcout.imbue(std::locale(std::locale(), "", LC_CTYPE)); - std::wcout << boost::join(list, " ") << std::endl; - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/QtRpa/include/interpreter2/global/global.h b/QtRpa/include/interpreter2/global/global.h deleted file mode 100644 index d951e66..0000000 --- a/QtRpa/include/interpreter2/global/global.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -namespace shelllet { - namespace global { - class MyGlobal { - public: - static QString Version(); - - static std::string dirname(); - - static std::string Chdir(const std::string& tar); - - static bool IEquals(const std::string& s1, const std::string& s2); - - static bool Start(const std::string& file, const std::vector& args); - - static void Sleep(int64_t ms); - - static std::filesystem::path GetExePath(); - static std::filesystem::path GetHomePath(); - - static std::string Now(); - static void WriteFile(const std::string& filename, const std::string& txt, std::ios_base::openmode mode = std::ios_base::trunc); - - static std::string ToUpperCase(const std::string& string, int index = -1); - - static double ToNumber(const std::vector& v, int type = 0) { - const int L = sizeof(double) / sizeof(std::uint16_t); - union Convert - { - std::uint16_t u[L]; - double real; - }; - Convert convert; - for (int i = 0; i < v.size(); ++i) { - convert.u[i] = v[i]; - } - return convert.real; - } - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/global/global_implement.h b/QtRpa/include/interpreter2/global/global_implement.h deleted file mode 100644 index 63feca7..0000000 --- a/QtRpa/include/interpreter2/global/global_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "interpreter/timer_resource.h" -#include "interpreter/global/global.h" -#include "interpreter/global/global_p.h" -#include "interpreter/global/global_wrapper.h" -#include - -#include -#include - -namespace shelllet { - using namespace resource; - namespace global { - class Global :public MyGlobalWrapper { - public: - using ReturnType = MyGlobalPrivate; - using ReturnType2 = MyGlobalPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - Global(const v8::FunctionCallbackInfo& args) : MyGlobalWrapper(*Private(args), args) { - } - Global(v8::Isolate* isolate, const v8::Local& tpl) : MyGlobalWrapper(isolate, tpl) - {} - Global(v8::Isolate* isolate, const v8::Local& proto) : MyGlobalWrapper(isolate, proto) - {} - - public: - static const char* Name() { return "global"; } - }; - } -} diff --git a/QtRpa/include/interpreter2/global/global_p.h b/QtRpa/include/interpreter2/global/global_p.h deleted file mode 100644 index c92de63..0000000 --- a/QtRpa/include/interpreter2/global/global_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -namespace shelllet::global { - template - class MyGlobalPrivate : public V8ObjectPrivate - { - public: - template - MyGlobalPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : V8ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/QtRpa/include/interpreter2/global/global_wrapper.h b/QtRpa/include/interpreter2/global/global_wrapper.h deleted file mode 100644 index b8ebfed..0000000 --- a/QtRpa/include/interpreter2/global/global_wrapper.h +++ /dev/null @@ -1,257 +0,0 @@ -#pragma once -namespace shelllet { - namespace global { - template - class MyGlobalWrapper : public ObjectWrapper - { - public: - template - MyGlobalWrapper(MyGlobalPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - MyGlobalWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - } - MyGlobalWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "__dirname"), Dirname); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "__version"), Version); - - proto->Set(isolate, "chdir", v8::FunctionTemplate::New(isolate, Chdir)); - proto->Set(isolate, "sleep", v8::FunctionTemplate::New(isolate, Sleep)); - proto->Set(isolate, "iequals", v8::FunctionTemplate::New(isolate, IEquals)); - proto->Set(isolate, "start", v8::FunctionTemplate::New(isolate, Start)); - proto->Set(isolate, "setTimeout", v8::FunctionTemplate::New(isolate, SetTimeout)); - proto->Set(isolate, "clearTimeout", v8::FunctionTemplate::New(isolate, ClearTimeout)); - proto->Set(isolate, "setInterval", v8::FunctionTemplate::New(isolate, SetInterval)); - proto->Set(isolate, "clearInterval", v8::FunctionTemplate::New(isolate, ClearInterval)); - proto->Set(isolate, "getLastError", v8::FunctionTemplate::New(isolate, GetLastError)); - proto->Set(isolate, "setLastError", v8::FunctionTemplate::New(isolate, SetLastError)); - proto->Set(isolate, "writeFile", v8::FunctionTemplate::New(isolate, WriteFile)); - proto->Set(isolate, "toUpperCase", v8::FunctionTemplate::New(isolate, ToUpperCase)); - proto->Set(isolate, "toNumber", v8::FunctionTemplate::New(isolate, ToNumber)); - proto->Set(isolate, "waitForDebugger", v8::FunctionTemplate::New(isolate, WaitForDebugger)); - } - - protected: - static void Version(v8::Local property, const v8::PropertyCallbackInfo& info) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - info.GetReturnValue().Set(V8_NEW_WSTRING_VAR(isolate, MyGlobal::Version().toStdWString().c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Dirname(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - info.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, MyGlobal::dirname().c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Chdir(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) { - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, MyGlobal::Chdir(ToString({ isolate, args[0] })).c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IEquals(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - v8::String::Utf8Value s1(isolate, args[0]); - v8::String::Utf8Value s2(isolate, args[1]); - - args.GetReturnValue().Set(v8::Boolean::New(isolate, MyGlobal::IEquals(*s1, *s2))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Start(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) { - std::string filename = ToString({ isolate, args[0] }); - std::vector arguments = {}; - for (int i = 1; i < args.Length(); i++) { - arguments.push_back(ToString({ isolate, args[i] })); - } - - MyGlobal::Start(filename, arguments); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Sleep(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - int64_t ms = args[0]->Uint32Value(context).FromJust(); - v8::Unlocker unlocker(isolate); - MyGlobal::Sleep(ms); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetTimeout(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - int32_t timeout = 0; - timeout = args[1]->Uint32Value(context).FromMaybe(timeout); - if (args[0].IsEmpty() || !args[0]->IsFunction()) { - throw std::invalid_argument("# function required."); - } - - resource::TimerPrivate* p = new resource::TimerPrivate(isolate, args[0].As()); - p->setTimeout([isolate](resource::TimerPrivate* p) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::Local fn = p->fn.Get(isolate); - if (!fn.IsEmpty() && fn->IsFunction()) - fn->CallAsFunction(context, context->Global(), 0, {}); - } - V8_CREATE_LOCAL_CONTEXT_END - }, timeout); - - V8_GL_VALUE(isolate)->push_back(std::unique_ptr(p)); - args.GetReturnValue().Set(v8::External::New(isolate, p)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ClearTimeout(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (!args[0]->IsExternal()) - { - return; - } - if (auto* timer = static_cast(args[0].As()->Value()); timer) - { - timer->clearTimeout(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void SetInterval(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - int32_t repeat = 0; - repeat = args[1]->Uint32Value(context).FromMaybe(repeat); - - if (args[0].IsEmpty() || !args[0]->IsFunction()) { - throw std::invalid_argument("# function required."); - } - resource::TimerPrivate* p = new resource::TimerPrivate(isolate, args[0].As()); - p->setInterval([isolate](resource::TimerPrivate* p) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::Local fn = p->fn.Get(isolate); - if (!fn.IsEmpty() && fn->IsFunction()) - fn->CallAsFunction(context, context->Global(), 0, {}); - } - V8_CREATE_LOCAL_CONTEXT_END - }, repeat); - V8_GL_VALUE(isolate)->push_back(std::unique_ptr(p)); - args.GetReturnValue().Set(v8::External::New(isolate, p)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ClearInterval(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (!args[0]->IsExternal()) - { - return; - } - if (auto* timer = static_cast(args[0].As()->Value()); timer) - { - timer->clearTimeout(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetLastError(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, error::GetLastErrorMessage().c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void SetLastError(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args[0]->IsNumber()) { - error::SetLastErrorMessage(args[0]->Int32Value(context).FromJust()); - } - else if (args[0]->IsString()) { - error::SetLastErrorMessage(ToString({ isolate, args[0] })); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WriteFile(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - std::string filename = ToString({ isolate, args[0] }); - std::string content = ToString({ isolate, args[1] }); - std::ios_base::openmode mode = std::ios_base::trunc; - - if (args.Length() > 2) { - mode = static_cast(args[2]->Int32Value(context).FromJust()); - } - MyGlobal::WriteFile(filename, content, mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ToUpperCase(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - std::string string = ToString({ isolate, args[0] }); - - int index = -1; - if (args.Length() > 1) { - index = args[1]->Int32Value(context).FromJust(); - } - std::string result = MyGlobal::ToUpperCase(string, index); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, result.c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ToNumber(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto v = ToArray(isolate, args[0]); - int type = 0; - if (args.Length() > 1) { - type = args[1]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(v8::Number::New(isolate, MyGlobal::ToNumber(v, type))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void WaitForDebugger(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto v = ToArray(isolate, args[0]); - int type = 0; - if (args.Length() > 1) { - type = args[1]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(v8::Number::New(isolate, MyGlobal::ToNumber(v, type))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/QtRpa/include/interpreter2/http_session.h b/QtRpa/include/interpreter2/http_session.h deleted file mode 100644 index e350eb9..0000000 --- a/QtRpa/include/interpreter2/http_session.h +++ /dev/null @@ -1,99 +0,0 @@ -#pragma once -#include -#include -#include -#include "interpreter/inspector.h" -namespace shelllet { - namespace inspect { - class HttpSession : public std::enable_shared_from_this - { - class Queue - { - enum - { - limit = 8 - }; - - struct Work - { - virtual ~Work() = default; - virtual void operator()() = 0; - }; - - HttpSession& self; - std::vector> items; - - public: - explicit Queue(HttpSession& self) - : self(self) - { - static_assert(limit > 0, "queue limit must be positive"); - items.reserve(limit); - } - - bool isFull() const - { - return items.size() >= limit; - } - - bool onWrite() - { - BOOST_ASSERT(!items.empty()); - auto const was_full = isFull(); - items.erase(items.begin()); - if (!items.empty()) - (*items.front())(); - return was_full; - } - - template - void operator()(boost::beast::http::message&& msg) - { - struct WorkImpl : Work - { - HttpSession& self_; - boost::beast::http::message msg_; - - WorkImpl(HttpSession& self, boost::beast::http::message&& msg) - : self_(self) - , msg_(std::move(msg)) - { - } - - void operator()() - { - boost::beast::http::async_write(self_.stream_, msg_, boost::beast::bind_front_handler(&HttpSession::onWrite, self_.shared_from_this(), msg_.need_eof())); - } - }; - - items.push_back(boost::make_unique(self, std::move(msg))); - - if (items.size() == 1) - (*items.front())(); - } - }; - - public: - explicit HttpSession(Receiver* receiver, boost::asio::ip::tcp::socket&& socket); - - public: - void run(); - protected: - void doRead(); - - void onRead(boost::beast::error_code ec, std::size_t bytes_transferred); - - void onWrite(bool close, boost::beast::error_code ec, std::size_t bytes_transferred); - - void doClose(); - - private: - boost::beast::tcp_stream stream_; - - boost::beast::flat_buffer buffer_; - boost::optional> parser_; - Receiver* receiver_; - Queue queue_; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/inspector.h b/QtRpa/include/interpreter2/inspector.h deleted file mode 100644 index 3fa313f..0000000 --- a/QtRpa/include/interpreter2/inspector.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include - -namespace shelllet { - namespace inspect { - struct InspectorVersion { - std::string version; - std::string browser; - }; - struct InspectorList { - std::string description; - std::string type; - std::string title; - std::string url; - std::string address; - uint16_t port; - }; - - class Receiver : public QObject { - public: - void dispatchInspectorMessage(const std::string& message) { if (callback) { callback(message); } } - virtual InspectorVersion requestInspectorVersion() = 0; - virtual InspectorList requestInspectorList() = 0; - std::function callback; - }; - - class MessageInEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - MessageInEvent(const std::string& message) : QEvent(Type), message(message) {} - std::string message; - }; - class MessageOutEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - MessageOutEvent(const std::string& message) : QEvent(Type), message(message) {} - std::string message; - }; - class PumpMessageLoopEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - PumpMessageLoopEvent() : QEvent(Type) {} - }; - class ContinueRunEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - ContinueRunEvent() : QEvent(Type) {} - }; - - class DisconnectEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - DisconnectEvent() : QEvent(Type) {} - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/inspector_agent.h b/QtRpa/include/interpreter2/inspector_agent.h deleted file mode 100644 index 239a2cb..0000000 --- a/QtRpa/include/interpreter2/inspector_agent.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include "resource.h" -#include "inspector_client.h" -QT_FORWARD_DECLARE_CLASS(QEvent) - -namespace shelllet { - namespace interpreter { - class InspectorAgent :public QObject, public QRunnable - { - public: - InspectorAgent(QObject* receiver, v8::Platform* platform, const std::filesystem::path& filename, bool inspect_brk); - ~InspectorAgent(); - public: - void postInspectorMessage(const QString& message); - void disconnectInspector(); - void pumpMessageLoop(); - - void run() override; - void cleanup(); - void evaluate(); - private: - - static std::string translate(const std::string& xml); - private: - v8::Platform* platform_; - v8::Isolate* isolate_ = nullptr; - std::unique_ptr inspector_client_; - v8::Isolate::CreateParams create_params_; - std::filesystem::path filename_; - QObject* receiver_; - bool inspect_brk_; - std::string index_code_; - //static std::list> resources; - }; - } -} diff --git a/QtRpa/include/interpreter2/inspector_channel.h b/QtRpa/include/interpreter2/inspector_channel.h deleted file mode 100644 index 26568d8..0000000 --- a/QtRpa/include/interpreter2/inspector_channel.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -namespace shelllet { - namespace inspect { - class InspectorClient; - class InspectorChannel final : public v8_inspector::V8Inspector::Channel { - public: - explicit InspectorChannel(v8_inspector::V8Inspector* inspector, InspectorClient* c); - ~InspectorChannel() = default; - public: - void pauseOnNextJavascriptStatement(const std::string& reason); - void dispatchProtocolMessage(const std::string& message); - private: - void sendResponse(int call_id, std::unique_ptr message) override; - void sendNotification(std::unique_ptr message) override; - void flushProtocolNotifications() override {} - private: - InspectorClient* client_; - std::unique_ptr session_; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/inspector_client.h b/QtRpa/include/interpreter2/inspector_client.h deleted file mode 100644 index d008ee2..0000000 --- a/QtRpa/include/interpreter2/inspector_client.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include "interpreter/inspector_channel.h" -#include "interpreter/inspector.h" - -namespace shelllet { - namespace inspect { - class InspectorClient : public v8_inspector::V8InspectorClient { - public: - InspectorClient(QObject* receiver, const v8::Local& context, v8::Platform* platform); - - protected: - void runMessageLoopOnPause(int contextGroupId) override; - - void quitMessageLoopOnPause() override; - - void pauseOnNextJavascriptStatement(const std::string& reason); - - double currentTimeMS() override; - - void runIfWaitingForDebugger(int contextGroupId) override; - - // std::unique_ptr resourceNameToUrl(const v8_inspector::StringView& resourceName) override; - - void consoleAPIMessage(int contextGroupId, v8::Isolate::MessageErrorLevel level, const v8_inspector::StringView& message, const v8_inspector::StringView& url, unsigned lineNumber, unsigned columnNumber, v8_inspector::V8StackTrace*) override; - - private: - - v8::Local ensureDefaultContextInGroup(int groupId) override; - public: - void postInspectorMessage(const std::string& message); - void sendMessageToFrontend(const v8_inspector::StringView& string); - void dispatchProtocolMessage(const std::string& message); - bool waitForFrontendMessageWhilePaused(); - void disconnectFrontend(); - void pumpMessageLoop(); - - private: - std::unique_ptr inspector_; - std::unique_ptr channel_; - bool is_paused_ = false; - bool is_ready_ = false; - v8::Isolate* isolate_; - v8::Platform* platform_; - QObject* receiver_; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/native_library.h b/QtRpa/include/interpreter2/native_library.h deleted file mode 100644 index 246b76d..0000000 --- a/QtRpa/include/interpreter2/native_library.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include -namespace shelllet { - namespace library { - class NativeLibrary { - public: - NativeLibrary() = default; - ~NativeLibrary(); - bool initialize(v8::Isolate* isolate, const v8::Local& global); - - static NativeLibrary* getInstance(); - - private: - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/tcp_server.h b/QtRpa/include/interpreter2/tcp_server.h deleted file mode 100644 index 97d6873..0000000 --- a/QtRpa/include/interpreter2/tcp_server.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include -#include -#include -#include "interpreter/inspector.h" -QT_FORWARD_DECLARE_CLASS(QTimerEvent) -namespace shelllet { - namespace inspect { - class TcpServer : public QThread - { - public: - TcpServer(Receiver* receiver, const QHostAddress& address, uint16_t port); - - protected: - void run() override; - private: - Receiver* receiver_; - QHostAddress address_; - uint16_t port_; - boost::asio::io_context io_{ 1 }; - }; - } -} diff --git a/QtRpa/include/interpreter2/timer_resource.h b/QtRpa/include/interpreter2/timer_resource.h deleted file mode 100644 index 971de4c..0000000 --- a/QtRpa/include/interpreter2/timer_resource.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "v8.hpp" -#include "resource.h" -#include - -namespace shelllet { - namespace resource { - class TimerPrivate : public Resource { - public: - TimerPrivate(v8::Isolate* isolate, const v8::Local& f); - public: - v8::Global fn; - std::unique_ptr timer; - QMetaObject::Connection connection; - void setTimeout(const std::function& cb, uint64_t timeout); - void clearTimeout(); - void setInterval(const std::function& cb, uint64_t repeat); - void clearInterval(); - protected: - void cleanup() override; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/v8_util.h b/QtRpa/include/interpreter2/v8_util.h deleted file mode 100644 index 35c5083..0000000 --- a/QtRpa/include/interpreter2/v8_util.h +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include -namespace shelllet { - static inline bool V8_IsBoolean(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsBoolean(); - } - static inline bool V8_IsString(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsString(); - } - static inline bool V8_IsUint8Array(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsUint8Array(); - } - static inline bool V8_IsNumber(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsNumber(); - } - static inline bool V8_IsUint32(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsUint32(); - } - static inline bool V8_IsInt32(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsInt32(); - } - static inline bool V8_IsBigInt(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsBigInt(); - } - static inline bool V8_IsObject(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsObject(); - } - static inline bool V8_IsSymbol(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsSymbol(); - } - static inline bool V8_IsExternal(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsExternal(); - } - static inline bool V8_IsFunction(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsFunction(); - } - - template - static inline T V8_To_Ptr(const v8::Local& value) { - v8::Local external = v8::Local::Cast(value); - return static_cast(external->Value()); - } - - namespace convert { - class String : public v8::String { - public: - static v8::Local New(v8::Isolate* isolate, const QString& data) { - return v8::String::NewFromUtf8(isolate, data.toUtf8().constData()).ToLocalChecked(); - } - static v8::Local New(v8::Isolate* isolate, const char* data) { - return v8::String::NewFromUtf8(isolate, data).ToLocalChecked(); - } - static v8::Local New(v8::Isolate* isolate, const std::string& data) { - return v8::String::NewFromUtf8(isolate, data.c_str()).ToLocalChecked(); - } - static inline QString To(v8::Isolate* isolate, const v8::Local& value) { - v8::String::Utf8Value s = { isolate, value }; - if (*s) { - return *s; - } - return QString(); - } - }; - - class Object : public v8::Object { - public: - template - static inline T* UnWrap(const v8::Local& obj, int index = 0) { - if (obj->InternalFieldCount() > index) - return dynamic_cast(static_cast(obj->GetAlignedPointerFromInternalField(index))); - return nullptr; - } - static inline v8::Local Wrap(v8::Isolate* isolate, v8::Local context, const char* name, int argc, v8::Local argv[]) - { - v8::EscapableHandleScope scope(isolate); - v8::Local f = context->Global()->Get(context, convert::String::New(isolate, name)).ToLocalChecked(); - if (f->IsFunction()) { - v8::Local ctor = f.As(); - auto r = ctor->CallAsConstructor(context, argc, argv); - if (!r.IsEmpty()) - return scope.Escape(r.ToLocalChecked()); - } - throw std::runtime_error((boost::format("!`%1%` not registered.") % name).str()); - } - }; - class External : public v8::External { - public: - template - static inline T Value(const v8::Local& value) { - v8::Local external = v8::Local::Cast(value); - return static_cast(external->Value()); - } - }; - class Array : public v8::Array { - public: - static inline v8::Local New(v8::Isolate* isolate, const v8::Local& context, const QStringList& c) { - v8::EscapableHandleScope scope(isolate); - v8::Local array = v8::Array::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - array->Set(context, i, convert::String::New(isolate, c[i])); - } - return scope.Escape(array); - } - static inline void To(v8::Isolate* isolate, const v8::Local& context, const v8::Local& value, QStringList& list) { - v8::Local array = v8::Local::Cast(value); - if (!array.IsEmpty()) { - for (std::uint32_t i = 0; i < array->Length(); ++i) { - list.push_back(convert::String::To(isolate, array->Get(context, i).ToLocalChecked())); - } - } - } - }; - class Uint8Array : public v8::Uint8Array { - public: - static inline v8::Local New(v8::Isolate* isolate, const v8::Local& context, const QByteArray& bytes) { - v8::Local buffer = v8::ArrayBuffer::New(isolate, bytes.size()); - std::memcpy(buffer->GetContents().Data(), bytes.constData(), bytes.size()); - return v8::Uint8Array::New(buffer, 0, buffer->ByteLength()); - } - - static inline void To(const v8::Local& value, QByteArray& buffer) { - v8::Local array = v8::Local::Cast(value); - if (!array.IsEmpty()) { - buffer.resize(array->Length()); - array->CopyContents(buffer.data(), array->Length()); - } - } - }; - class Int32Array : public v8::Int32Array { - public: - template - static inline v8::Local New(v8::Isolate* isolate, const v8::Local& context, const T& c) { - v8::Local ar = v8::ArrayBuffer::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - ar->Set(context, i, v8::Int32::New(isolate, c[i])); - } - - return v8::Int32Array::New(ar, 0, ar->ByteLength()); - } - - static inline void ToVector(const v8::Local& value, QVector& buffer) { - v8::Local ar = v8::Local::Cast(value); - if (!ar.IsEmpty()) { - buffer.resize(ar->Length()); - ar->CopyContents(buffer.data(), ar->ByteLength()); - } - } - static inline QVector ToVector(const v8::Local& value) { - v8::Local ar = v8::Local::Cast(value); - QVector buffer; - if (!ar.IsEmpty()) { - buffer.resize(ar->Length()); - ar->CopyContents(buffer.data(), ar->ByteLength()); - } - return buffer; - } - }; - } - template - static inline v8::Local V8_From_Int32Array(v8::Isolate* isolate, const v8::Local& context, const T& c) { - v8::Local ar = v8::ArrayBuffer::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - ar->Set(context, i, v8::Int32::New(isolate, c[i])); - } - - return v8::Int32Array::New(ar, 0, ar->ByteLength()); - } - template - static inline v8::Local V8_From_ObjectArray(v8::Isolate* isolate, const v8::Local& context, const char* name, const T& c) { - v8::Local ar = v8::Array::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - v8::Local argv[] = { v8::External::New(isolate, (void*)&c[i]) }; - ar->Set(context, i, convert::Object::Wrap(isolate, context, name, std::size(argv), argv)); - } - return ar; - } - - static inline v8::Local Call(v8::Isolate* isolate, const v8::Local& context, const char* name, const char* object, int argc, v8::Local argv[]) { - if (object == nullptr) { - auto v = context->Global()->Get(context, convert::String::New(isolate, name)).ToLocalChecked(); - auto f = v8::Local::Cast(v); - return f->CallAsFunction(context, context->Global(), argc, argv).ToLocalChecked(); - } - auto m = context->Global()->Get(context, convert::String::New(isolate, object)).ToLocalChecked(); - auto o = m->ToObject(context).ToLocalChecked(); - auto v = o->Get(context, convert::String::New(isolate, name)).ToLocalChecked(); - auto f = v8::Local::Cast(v); - return f->CallAsFunction(context, o, argc, argv).ToLocalChecked(); - } -} diff --git a/QtRpa/include/interpreter2/websocket_listener.h b/QtRpa/include/interpreter2/websocket_listener.h deleted file mode 100644 index 819a98b..0000000 --- a/QtRpa/include/interpreter2/websocket_listener.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include "interpreter/inspector.h" - -namespace shelllet { - namespace inspect { - class WebSocketListener : public std::enable_shared_from_this - { - public: - WebSocketListener(Receiver* receiver, boost::asio::io_context& ioc, boost::asio::ip::tcp::endpoint endpoint); - - public: - void run(); - private: - void doAccept(); - - void onAccept(boost::beast::error_code ec, boost::asio::ip::tcp::socket socket); - - private: - boost::asio::io_context& ioc_; - boost::asio::ip::tcp::acceptor acceptor_; - - Receiver* receiver_; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/interpreter2/websocket_session.h b/QtRpa/include/interpreter2/websocket_session.h deleted file mode 100644 index 561ecd8..0000000 --- a/QtRpa/include/interpreter2/websocket_session.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include "interpreter/inspector.h" - -namespace shelllet { - namespace inspect { - class WebsocketSession : public std::enable_shared_from_this - { - public: - explicit WebsocketSession(shelllet::inspect::Receiver* receiver, boost::asio::ip::tcp::socket&& socket); - - ~WebsocketSession(); - public: - template - void doAccept(boost::beast::http::request> req) - { - ws_.async_accept(req, boost::beast::bind_front_handler(&WebsocketSession::onAccept, shared_from_this())); - } - - void onAccept(boost::beast::error_code ec); - - void doRead(); - - void onRead(boost::beast::error_code ec, std::size_t bytes_transferred); - - void doWrite(const std::string& message); - private: - friend class Runnable; - boost::beast::websocket::stream ws_; - boost::beast::flat_buffer buffer_; - Receiver* receiver_; - bool is_read_ok_ = true; - std::list messages_; - QThread* thread_ = nullptr; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/model.hpp b/QtRpa/include/model.hpp deleted file mode 100644 index 59c2ce8..0000000 --- a/QtRpa/include/model.hpp +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include "common/framework.h" -#include "model/activities_dom_item.h" -#include "model/activities_search_model.h" -#include "model/variable_model.h" -#include "model/xmlmimedata.h" -#include "model/activitiesmanager.h" -using namespace shelllet::model; - \ No newline at end of file diff --git a/QtRpa/include/model/activities_dom_item.h b/QtRpa/include/model/activities_dom_item.h deleted file mode 100644 index 396f25f..0000000 --- a/QtRpa/include/model/activities_dom_item.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include -#include -#include "common.hpp" - -namespace shelllet { - namespace model { - class ActivitiesDomItemPrivate; - class ActivitiesDomItem : public Object - { - Q_DECLARE_PRIVATE(ActivitiesDomItem) - public: - ActivitiesDomItem(const XmlNode& node, int row, int depth, ActivitiesDomItem* parent = nullptr); - ~ActivitiesDomItem(); - ActivitiesDomItem* child(int i); - ActivitiesDomItem* parent(); - XmlNode node() const; - int row() const; - - private: - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/model/activities_search_model.h b/QtRpa/include/model/activities_search_model.h deleted file mode 100644 index 1084639..0000000 --- a/QtRpa/include/model/activities_search_model.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include -#include -#include "common/serialization.h" - -class QMimeData; -namespace shelllet { - namespace model { - class ActivitiesDomItem; - class ActivitiesDomModel : public QAbstractItemModel - { - Q_OBJECT - - public: - explicit ActivitiesDomModel(const SharedPointer& doc, QObject* parent = nullptr); - ~ActivitiesDomModel(); - - QVariant data(const QModelIndex& index, int role) const override; - Qt::ItemFlags flags(const QModelIndex& index) const override; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const override; - QModelIndex index(int row, int column, - const QModelIndex& parent = QModelIndex()) const override; - QModelIndex parent(const QModelIndex& child) const override; - int rowCount(const QModelIndex& parent = QModelIndex()) const override; - int columnCount(const QModelIndex& parent = QModelIndex()) const override; - - QMimeData* mimeData(const QModelIndexList& indexes) const override; - - private: - ActivitiesDomItem* rootItem; - }; - } -} diff --git a/QtRpa/include/model/activitiesmanager.h b/QtRpa/include/model/activitiesmanager.h deleted file mode 100644 index a1381e7..0000000 --- a/QtRpa/include/model/activitiesmanager.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace model { - class ActivitiesManagerPrivate; - class ActivitiesManager : public QObject { - Q_DECLARE_PRIVATE(ActivitiesManager) - public: - ActivitiesManager(QObject* parent = nullptr); - void loadAll(); - SharedPointer document() const; - - static ActivitiesManager* getInstance(); - protected: - ActivitiesManager(ActivitiesManagerPrivate& d, QObject* parent = nullptr); - }; - } -} diff --git a/QtRpa/include/model/private/activitiesmanager_p.h b/QtRpa/include/model/private/activitiesmanager_p.h deleted file mode 100644 index a7f6e8c..0000000 --- a/QtRpa/include/model/private/activitiesmanager_p.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -#include "object_p.h" -namespace shelllet { - namespace model{ - - } -} - \ No newline at end of file diff --git a/QtRpa/include/model/private/elementdomitem_p.h b/QtRpa/include/model/private/elementdomitem_p.h deleted file mode 100644 index 83ca856..0000000 --- a/QtRpa/include/model/private/elementdomitem_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace model { - class ActivitiesDomItemPrivate : public ObjectPrivate { - public: - XmlNode domNode; - QHash childItems; - ActivitiesDomItem* parentItem; - int rowNumber; - int depth; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/model/private/xmlmimedata_p.h b/QtRpa/include/model/private/xmlmimedata_p.h deleted file mode 100644 index 7cae540..0000000 --- a/QtRpa/include/model/private/xmlmimedata_p.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "common/private/mimedata_p.h" -#include "pugixml.hpp" - -class QGraphicsItem; -namespace shelllet { - namespace model { - class XmlMimeDataPrivate : public MimeDataPrivate { - Q_DECLARE_PUBLIC(XmlMimeData) - public: - - XmlDocument doc; - - QGraphicsItem* source = nullptr; - }; - } -} diff --git a/QtRpa/include/model/variable_model.h b/QtRpa/include/model/variable_model.h deleted file mode 100644 index 16271f3..0000000 --- a/QtRpa/include/model/variable_model.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include -#include - -namespace shelllet { - namespace model { - class VariableModel : public QAbstractTableModel - { - Q_OBJECT - - public: - - explicit VariableModel(const YAML::Node& node, QObject* parent = nullptr); - ~VariableModel(); - - QVariant data(const QModelIndex& index, int role) const override; - Qt::ItemFlags flags(const QModelIndex& index) const override; - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const override; - - int rowCount(const QModelIndex& parent = QModelIndex()) const override; - int columnCount(const QModelIndex& parent = QModelIndex()) const override; - - YAML::Node node() const; - - bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; - - bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; - - bool removeRows(int row, int count, const QModelIndex& parent = QModelIndex()) override; - - private: - - private: - YAML::Node node_; - }; - } -} diff --git a/QtRpa/include/model/xmlmimedata.h b/QtRpa/include/model/xmlmimedata.h deleted file mode 100644 index 09c5862..0000000 --- a/QtRpa/include/model/xmlmimedata.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "common.hpp" -class QGraphicsItem; -namespace shelllet { - namespace model { - class XmlMimeDataPrivate; - class XmlMimeData : public MimeData { - Q_DECLARE_PRIVATE_D(Object::d_ptr,XmlMimeData) - public: - XmlMimeData(const XmlNode& node); - - XmlNode documentElement() const; - - void setSourceItem(QGraphicsItem* source); - QGraphicsItem* sourceItem() const; - }; - } -} diff --git a/QtRpa/include/opencv/core_implement.h b/QtRpa/include/opencv/core_implement.h deleted file mode 100644 index 2c1d78d..0000000 --- a/QtRpa/include/opencv/core_implement.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "core_p.h" -#include "core_wrapper.h" -namespace shelllet { - namespace opencv { - class __Core {}; - class Core : public CoreWrapper<__Core, Core, false> - { - public: - using ReturnType = CorePrivate<__Core, true>; - using ReturnType2 = CorePrivate<__Core, false>; - - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - Core(const v8::FunctionCallbackInfo& args) : CorePrivate(*Param(args), args) - { - } - Core(cv::Mat* p, const v8::FunctionCallbackInfo& args) : CorePrivate(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Core(v8::Isolate* isolate, const v8::Local& proto) : CorePrivate(isolate, tpl, proto) - { - } - Core(v8::Isolate* isolate, const v8::Local& tpl) : CorePrivate(isolate, tpl, proto) - { - } - static const char* Name() { return "cv"; } - protected: - }; - } -} diff --git a/QtRpa/include/opencv/core_p.h b/QtRpa/include/opencv/core_p.h deleted file mode 100644 index 9249482..0000000 --- a/QtRpa/include/opencv/core_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -namespace shelllet::opencv { - template - class CorePrivate : public ObjectPrivate - { - public: - template - CorePrivate(v8::Isolate* isoalte, const v8::Local& obj, Args&&... args) : ObjectPrivate(isoalte, obj, std::forward(args)...) { - } - }; -} diff --git a/QtRpa/include/opencv/core_wrapper.h b/QtRpa/include/opencv/core_wrapper.h deleted file mode 100644 index db257ea..0000000 --- a/QtRpa/include/opencv/core_wrapper.h +++ /dev/null @@ -1,48 +0,0 @@ -#pragma once -namespace shelllet { - namespace opencv { - template - class CoreWrapper : public ObjectWrapper - { - public: - template - CoreWrapper(CorePrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - - CoreWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - CoreWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "minMaxLoc", v8::FunctionTemplate::New(isolate, minMaxLoc)); - } - - protected: - static void minMaxLoc(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* src = Mat::From(args[0]); - if (!src) - throw std::domain_error(K_CONST_ERROR_CALLED); - - int flags = cv::IMREAD_COLOR; - cv::InputArray mask = cv::noArray(); - - if (args.Length() > 1) { - mask = **Mat::From(args[1]); - } - double minVal, maxVal, minLoc, maxLoc; - cv::minMaxLoc(**src, &minVal, &maxVal, &minLoc, &maxLoc, mask); - - v8::Local result = v8::Array::New(isolate, 4); - result->Set(context, 0, v8::Number::New(isolate, minVal)); - result->Set(context, 1, v8::Number::New(isolate, maxVal)); - result->Set(context, 2, v8::Number::New(isolate, minLoc)); - result->Set(context, 3, v8::Number::New(isolate, maxLoc)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/QtRpa/include/opencv/imgcodecs_implement.h b/QtRpa/include/opencv/imgcodecs_implement.h deleted file mode 100644 index d093ba1..0000000 --- a/QtRpa/include/opencv/imgcodecs_implement.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "imgcodecs_p.h" -#include "imgcodecs_wrapper.h" -namespace shelllet { - namespace opencv { - class __ImgCodecs {}; - class ImgCodecs : public ImgCodecsWrapper<__ImgCodecs, ImgCodecs, false> - { - public: - using ReturnType = ImgCodecsPrivate<__ImgCodecs, true>; - using ReturnType2 = ImgCodecsPrivate<__ImgCodecs, false>; - - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - ImgCodecs(const v8::FunctionCallbackInfo& args) : ImgCodecsWrapper(*Param(args), args) - { - } - ImgCodecs(__ImgCodecs* p, const v8::FunctionCallbackInfo& args) : ImgCodecsWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - - ImgCodecs(v8::Isolate* isolate, const v8::Local& tpl) : ImgCodecsWrapper(isolate, tpl) - { - } - ImgCodecs(v8::Isolate* isolate, const v8::Local& proto) : ImgCodecsWrapper(isolate, proto) - { - } - static const char* Name() { return "cv"; } - protected: - }; - } -} diff --git a/QtRpa/include/opencv/imgcodecs_p.h b/QtRpa/include/opencv/imgcodecs_p.h deleted file mode 100644 index 8308bb5..0000000 --- a/QtRpa/include/opencv/imgcodecs_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -namespace shelllet::opencv { - template - class ImgCodecsPrivate : public ObjectPrivate - { - - public: - template - ImgCodecsPrivate(v8::Isolate* isoalte, const v8::Local& obj, Args&&... args) : ObjectPrivate(isoalte, obj, std::forward(args)...) { - } - }; -} - diff --git a/QtRpa/include/opencv/imgcodecs_wrapper.h b/QtRpa/include/opencv/imgcodecs_wrapper.h deleted file mode 100644 index ef3a363..0000000 --- a/QtRpa/include/opencv/imgcodecs_wrapper.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -namespace shelllet { - namespace opencv { - template - class ImgCodecsWrapper : public ObjectWrapper - { - public: - template - ImgCodecsWrapper(ImgCodecsPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - - ImgCodecsWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - ImgCodecsWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "imread", v8::FunctionTemplate::New(isolate, ImRead)); - } - - protected: - static void ImRead(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - std::filesystem::path fixed = FixRelativePath(ToString({ isolate, args[0] }), args.GetIsolate()); - if (!std::filesystem::exists(fixed)) { - LOG_FATAL("v8") << "# `" << fixed << "` not exist." << std::endl; - } - int flags = args[1]->Int32Value(context).FromMaybe(cv::IMREAD_COLOR); - cv::Mat img = cv::imread(fixed.string(), flags); - args.GetReturnValue().Set(Mat::New2(isolate, new cv::Mat(img))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/QtRpa/include/opencv/imgproc_implement.h b/QtRpa/include/opencv/imgproc_implement.h deleted file mode 100644 index 3f5f463..0000000 --- a/QtRpa/include/opencv/imgproc_implement.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "mat_implement.h" -#include "scalar_implement.h" -#include "imgproc_p.h" -#include "imgproc_wrapper.h" -namespace shelllet { - namespace opencv { - class __ImgProc {}; - class ImgProc : public ImgProcWrapper<__ImgProc, ImgProc, false> - { - using ReturnType = ImgProcPrivate<__ImgProc, true>; - using ReturnType2 = ImgProcPrivate<__ImgProc, false>; - - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - ImgProc(const v8::FunctionCallbackInfo& args) : ImgProcWrapper(*Param(args), args) - { - } - ImgProc(__ImgProc* p, const v8::FunctionCallbackInfo& args) : ImgProcWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ImgProc(v8::Isolate* isolate, const v8::Local& tpl) : ImgProcWrapper(isolate, tpl) - { - } - ImgProc(v8::Isolate* isolate, const v8::Local& proto) : ImgProcWrapper(isolate, proto) - { - } - static const char* Name() { return "cv"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/QtRpa/include/opencv/imgproc_p.h b/QtRpa/include/opencv/imgproc_p.h deleted file mode 100644 index cc1135e..0000000 --- a/QtRpa/include/opencv/imgproc_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -namespace shelllet::opencv { - template - class ImgProcPrivate : public ObjectPrivate - { - public: - template - ImgProcPrivate(v8::Isolate* isoalte, const v8::Local& obj, Args&&... args) : ObjectPrivate(isoalte, obj, std::forward(args)...) { - } - }; -} diff --git a/QtRpa/include/opencv/imgproc_wrapper.h b/QtRpa/include/opencv/imgproc_wrapper.h deleted file mode 100644 index b404eac..0000000 --- a/QtRpa/include/opencv/imgproc_wrapper.h +++ /dev/null @@ -1,127 +0,0 @@ -#pragma once -namespace shelllet { - namespace opencv { - template - class ImgProcWrapper : public ObjectWrapper - { - public: - template - ImgProcWrapper(ImgProcPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - - ImgProcWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - ImgProcWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "threshold", v8::FunctionTemplate::New(isolate, Threshold)); - proto->Set(isolate, "cvtColor", v8::FunctionTemplate::New(isolate, CvtColor)); - proto->Set(isolate, "matchTemplate", v8::FunctionTemplate::New(isolate, MatchTemplate)); - proto->Set(isolate, "floodFill", v8::FunctionTemplate::New(isolate, FloodFill)); - } - - protected: - static void Threshold(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - Mat* src = Mat::From(args[0]); - if (!src) - throw std::domain_error(K_CONST_ERROR_CALLED); - - cv::Mat dst; - double thresh = args[1]->NumberValue(context).FromJust(); - double maxval = args[2]->NumberValue(context).FromJust(); - int type = args[3]->Int32Value(context).FromJust(); - double retval = cv::threshold(**src, dst, thresh, maxval, type); - v8::Local result = v8::Array::New(isolate, 2); - result->Set(context, 0, v8::Number::New(isolate, retval)); - result->Set(context, 1, Mat::New2(isolate, new cv::Mat(dst))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void CvtColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* src = Mat::From(args[0]); - if (!src) - throw std::domain_error(K_CONST_ERROR_CALLED); - - cv::Mat dst; - int code, dstCn = 0; - code = args[1]->Int32Value(context).FromJust(); - dstCn = args[2]->Int32Value(context).FromMaybe(dstCn); - - cv::cvtColor(**src, dst, code, dstCn); - - args.GetReturnValue().Set(Mat::New2(isolate, new cv::Mat(dst))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void MatchTemplate(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* image = Mat::From(args[0]); - if (!image) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto* templ = Mat::From(args[1]); - if (!templ) - throw std::domain_error(K_CONST_ERROR_CALLED); - - cv::Mat result; - int method; - method = args[2]->Int32Value(context).FromJust(); - - cv::matchTemplate(**image, **templ, result, method); - - args.GetReturnValue().Set(Mat::New(isolate, v8::External::New(isolate, &result))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void FloodFill(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* image = Mat::From(args[0]); - if (!image) - throw std::domain_error(K_CONST_ERROR_CALLED); - - int index = 1; - auto* mask = Mat::From(args[index]); - if (mask) { - index++; - } - - auto* seed = Point::From(args[index++]); - auto newVal = Scalar::From(args[index++]); - auto loDiff = Scalar::From(args[index++]); - auto upDiff = Scalar::From(args[index++]); - int flags = args[index++]->Int32Value(context).FromMaybe(4); - cv::Rect rect; - - if (mask) { - int n = cv::floodFill(**image, **mask, { (*seed)->x(), (*seed)->y() }, **newVal, &rect, **loDiff, **upDiff, flags); - v8::Local result = v8::Array::New(isolate, 4); - result->Set(context, 0, v8::Int32::New(isolate, n)); - result->Set(context, 1, Mat::New(isolate, v8::External::New(isolate, *image))); - result->Set(context, 2, Mat::New(isolate, v8::External::New(isolate, *mask))); - result->Set(context, 3, Rect::New(isolate, v8::Int32::New(isolate, rect.x), v8::Int32::New(isolate, rect.y), v8::Int32::New(isolate, rect.width), v8::Int32::New(isolate, rect.height))); - args.GetReturnValue().Set(result); - } - else { - int n = cv::floodFill(**image, { (*seed)->x(), (*seed)->y() }, **newVal, &rect, **loDiff, **upDiff, flags); - v8::Local result = v8::Array::New(isolate, 4); - result->Set(context, 0, v8::Int32::New(isolate, n)); - result->Set(context, 1, Mat::New(isolate, v8::External::New(isolate, *image))); - result->Set(context, 2, Rect::New(isolate, v8::Int32::New(isolate, rect.x), v8::Int32::New(isolate, rect.y), v8::Int32::New(isolate, rect.width), v8::Int32::New(isolate, rect.height))); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/QtRpa/include/opencv/initialize.h b/QtRpa/include/opencv/initialize.h deleted file mode 100644 index 6ae2a51..0000000 --- a/QtRpa/include/opencv/initialize.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "framework.h" -#include "qtcore/qpoint_implement.h" -#include "qtcore/qrect_implement.h" -#include "imgcodecs_implement.h" -#include "mat_implement.h" -#include "imgproc_implement.h" -#include "qrcodedetector_implement.h" - -namespace shelllet { - using namespace core; - namespace opencv { - void initialize(v8::Isolate* isolate, const v8::Local& proto) { - using namespace shelllet::opencv; - proto->Set(isolate, Mat::Name(), Mat::WrapClass(isolate)); - proto->Set(isolate, QRCodeDetector::Name(), QRCodeDetector::WrapClass(isolate)); - { - static_cast(std::make_unique(isolate, proto)); - static_cast(std::make_unique(isolate, proto)); - } - - proto->Set(isolate, "THRESH_BINARY", v8::Int32::New(isolate, cv::THRESH_BINARY)); - proto->Set(isolate, "THRESH_BINARY_INV", v8::Int32::New(isolate, cv::THRESH_BINARY_INV)); - proto->Set(isolate, "THRESH_TRUNC", v8::Int32::New(isolate, cv::THRESH_TRUNC)); - proto->Set(isolate, "THRESH_TOZERO", v8::Int32::New(isolate, cv::THRESH_TOZERO)); - proto->Set(isolate, "THRESH_TOZERO_INV", v8::Int32::New(isolate, cv::THRESH_TOZERO_INV)); - proto->Set(isolate, "THRESH_MASK", v8::Int32::New(isolate, cv::THRESH_MASK)); - proto->Set(isolate, "THRESH_OTSU", v8::Int32::New(isolate, cv::THRESH_OTSU)); - proto->Set(isolate, "THRESH_TRIANGLE", v8::Int32::New(isolate, cv::THRESH_TRIANGLE)); - - proto->Set(isolate, "COLOR_RGB2GRAY", v8::Int32::New(isolate, cv::COLOR_RGB2GRAY)); - } - } -} \ No newline at end of file diff --git a/QtRpa/include/opencv/mat_implement.h b/QtRpa/include/opencv/mat_implement.h deleted file mode 100644 index f5fed46..0000000 --- a/QtRpa/include/opencv/mat_implement.h +++ /dev/null @@ -1,44 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "mat_p.h" -#include "mat_wrapper.h" -namespace shelllet { - namespace opencv { - class Mat : public MatWrapper - { - using ReturnType = MatPrivate; - using ReturnType2 = MatPrivate; - - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - if (args[0]->IsExternal()) { - cv::Mat* m = static_cast(args[0].As()->Value()); - if (m) { - return new ReturnType(args.GetIsolate(), args.This(), *m); - } - } - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - Mat(const v8::FunctionCallbackInfo& args) : MatWrapper(*Param(args), args) - { - } - Mat(cv::Mat* p, const v8::FunctionCallbackInfo& args) : MatWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Mat(v8::Isolate* isolate, const v8::Local& tpl) : MatWrapper(isolate, tpl) - { - } - Mat(v8::Isolate* isolate, const v8::Local& proto) : MatWrapper(isolate, proto) - { - } - - static const char* Name() - { - return "Mat"; - } - - protected: - }; - } -} diff --git a/QtRpa/include/opencv/mat_p.h b/QtRpa/include/opencv/mat_p.h deleted file mode 100644 index 4001dc8..0000000 --- a/QtRpa/include/opencv/mat_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -namespace shelllet::opencv { - template - class MatPrivate : public ObjectPrivate - { - public: - template - MatPrivate(v8::Isolate* isoalte, const v8::Local& obj, Args&&... args) : ObjectPrivate(isoalte, obj, std::forward(args)...) { - } - }; -} diff --git a/QtRpa/include/opencv/mat_wrapper.h b/QtRpa/include/opencv/mat_wrapper.h deleted file mode 100644 index 0ae4677..0000000 --- a/QtRpa/include/opencv/mat_wrapper.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -namespace shelllet { - namespace opencv { - template - class MatWrapper : public ObjectWrapper - { - public: - template - MatWrapper(MatPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - - MatWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - MatWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - }; - } -} diff --git a/QtRpa/include/opencv/qrcodedetector_implement.h b/QtRpa/include/opencv/qrcodedetector_implement.h deleted file mode 100644 index 949abbf..0000000 --- a/QtRpa/include/opencv/qrcodedetector_implement.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qrcodedetector_p.h" -#include "qrcodedetector_wrapper.h" - -namespace shelllet { - namespace opencv { - class QRCodeDetector : public QRCodeDetectorWrapper - { - using ReturnType = QRCodeDetectorPrivate; - using ReturnType2 = QRCodeDetectorPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - QRCodeDetector(const v8::FunctionCallbackInfo& args) :QRCodeDetectorWrapper(*Private(args), args) - { - } - QRCodeDetector(cv::QRCodeDetector* p, const v8::FunctionCallbackInfo& args) :QRCodeDetectorWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - QRCodeDetector(v8::Isolate* isolate, const v8::Local& tpl) : QRCodeDetectorWrapper(isolate, tpl) - {} - QRCodeDetector(v8::Isolate* isolate, const v8::Local& proto) : QRCodeDetectorWrapper(isolate, proto) - { - } - - protected: - void toString(std::stringstream& ss) const {} - public: - static const char* Name() { return "QRCodeDetector"; } - protected: - }; - } -} diff --git a/QtRpa/include/opencv/qrcodedetector_p.h b/QtRpa/include/opencv/qrcodedetector_p.h deleted file mode 100644 index a89a2af..0000000 --- a/QtRpa/include/opencv/qrcodedetector_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -namespace shelllet { - namespace opencv { - template - class QRCodeDetectorPrivate : public ObjectPrivate - { - public: - template - QRCodeDetectorPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - }; - } -} diff --git a/QtRpa/include/opencv/qrcodedetector_wrapper.h b/QtRpa/include/opencv/qrcodedetector_wrapper.h deleted file mode 100644 index 36fc4f8..0000000 --- a/QtRpa/include/opencv/qrcodedetector_wrapper.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -namespace shelllet { - namespace opencv { - template - class QRCodeDetectorWrapper : public ObjectWrapper - { - public: - template - QRCodeDetectorWrapper(QRCodeDetectorPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QRCodeDetectorWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - } - QRCodeDetectorWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "decode", v8::FunctionTemplate::New(isolate, Decode)); - proto->Set(isolate, "detectAndDecode", v8::FunctionTemplate::New(isolate, DetectAndDecode)); - } - - protected: - static void Decode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - auto* image = Mat::From(args[0]); - if (!image) - throw std::domain_error(K_CONST_ERROR_CALLED); - auto* points = Mat::From(args[0]); - if (!points) - throw std::domain_error(K_CONST_ERROR_CALLED); - - cv::OutputArray straight_qrcode = cv::noArray(); - auto retval = (*self)->decode(**image, **points, straight_qrcode); - - v8::Local result = v8::Array::New(isolate, 2); - result->Set(context, 0, V8_NEW_STRING_VAR(isolate, retval.c_str())); - result->Set(context, 1, Mat::New(isolate, v8::External::New(isolate, &straight_qrcode.getMatRef()))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void DetectAndDecode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto* image = Mat::From(args[0]); - if (!image) - throw std::domain_error(K_CONST_ERROR_CALLED); - - cv::Mat points; - cv::Mat straight_qrcode; - - auto retval = (*self)->detectAndDecode(**image, points, straight_qrcode); - - v8::Local result = v8::Array::New(isolate, 3); - result->Set(context, 0,V8_NEW_STRING_VAR(isolate, retval.c_str())); - result->Set(context, 1, Mat::New2(isolate, new cv::Mat(points))); - result->Set(context, 2, Mat::New2(isolate, new cv::Mat(straight_qrcode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/opencv/scalar_implement.h b/QtRpa/include/opencv/scalar_implement.h deleted file mode 100644 index f5c1c70..0000000 --- a/QtRpa/include/opencv/scalar_implement.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "scalar_p.h" -#include "scalar_wrapper.h" -namespace shelllet { - namespace opencv { - class Scalar : public ScalarWrapper - { - using ReturnType = ScalarPrivate; - using ReturnType2 = ScalarPrivate; - - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - Scalar(const v8::FunctionCallbackInfo& args) : ScalarWrapper(*Param(args), args) - { - } - Scalar(cv::Scalar* p, const v8::FunctionCallbackInfo& args) : ScalarWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Scalar(v8::Isolate* isolate, const v8::Local& tpl) : ScalarWrapper(isolate, tpl) - { - } - Scalar(v8::Isolate* isolate, const v8::Local& proto) : ScalarWrapper(isolate, proto) - { - } - - static const char* Name() - { - return "Mat"; - } - - protected: - }; - } -} diff --git a/QtRpa/include/opencv/scalar_p.h b/QtRpa/include/opencv/scalar_p.h deleted file mode 100644 index 03e0365..0000000 --- a/QtRpa/include/opencv/scalar_p.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -namespace shelllet::opencv { - template - class ScalarPrivate : public ObjectPrivate - { - public: - template - ScalarPrivate(v8::Isolate* isoalte, const v8::Local& obj, Args&&... args) : ObjectPrivate(isoalte, obj, std::forward(args)...) { - } - }; -} diff --git a/QtRpa/include/opencv/scalar_wrapper.h b/QtRpa/include/opencv/scalar_wrapper.h deleted file mode 100644 index 8b8dcb8..0000000 --- a/QtRpa/include/opencv/scalar_wrapper.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -namespace shelllet { - namespace opencv { - template - class ScalarWrapper : public ObjectWrapper - { - public: - template - ScalarWrapper(ScalarPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - - ScalarWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - ScalarWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - }; - } -} diff --git a/QtRpa/include/properties2/code.xxx b/QtRpa/include/properties2/code.xxx deleted file mode 100644 index cfcdc59..0000000 --- a/QtRpa/include/properties2/code.xxx +++ /dev/null @@ -1,83 +0,0 @@ -#pragma once - -#include "composite_property.h" -namespace shelllet { - namespace properties { - class CodePrivate; - class Code : public CompositeProperty - { - //friend class boost::serialization::access; - - //template - //void save(Archive& ar, const unsigned int version) const - //{ - //// ar& boost::serialization::base_object(*this); - // //QByteArray bytes = toData(); - // ar << toData(); - //} - - //template - //void load(Archive& ar, const unsigned int version) - //{ - //// ar >> boost::serialization::base_object(*this); - // QByteArray bytes; - // ar >> bytes; - // fromData(bytes); - //} - - /*template - void serialize(Archive& ar, const unsigned int version) - { - boost::serialization::split_member(ar, *this, version); - }*/ - //BOOST_SERIALIZATION_SPLIT_FREE(Print) - Q_OBJECT - Q_DECLARE_PRIVATE(Code) - Q_PROPERTY(String code READ code WRITE setCode) - public: - // Print(QObject* parent = nullptr); - Q_INVOKABLE Code(const pugi::xml_node& prop = pugi::xml_node(), QObject* parent = nullptr); - - /*Q_INVOKABLE print(QObject* parent = nullptr);*/ - - - //std::unique_ptr getNode() ; - - - String code() const; - - void setCode(const String& filename); - - - void getCode(std::ostringstream& oss) override; - - - - - //QByteArray toData() const override; - - - - - - void getDefines(std::ostringstream& oss) override; - - - - - - - - //void fromData(const QByteArray& data) override; - - protected: - //virtual void toXml(pugi::xml_node& node); - //virtual void fromXml(const pugi::xml_node& node); - virtual QtProperty* getInput(QtTreePropertyBrowser* browser); - - - }; - } -} - -Q_DECLARE_METATYPE(shelllet::properties::Code*) diff --git a/QtRpa/include/properties2/filedelete.xxx b/QtRpa/include/properties2/filedelete.xxx deleted file mode 100644 index da030c5..0000000 --- a/QtRpa/include/properties2/filedelete.xxx +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "composite_property.h" - -namespace shelllet { - namespace properties { - class FileDeletePrivate; - class FileDelete : public CompositeProperty - { - Q_OBJECT - Q_DECLARE_PRIVATE(FileDelete) - public: - Q_INVOKABLE FileDelete(const pugi::xml_node& node, QObject* parent = nullptr); - void setFileName(const QString& fileName); - QString fileName() const; - - int getPropertyMetaTypeID() const override; - - - - - void getCode(std::ostringstream& oss) override; - - - //std::string getImport() const override; - - protected: - virtual QtProperty* getInput(QtTreePropertyBrowser* browser); - - - private: - - }; - } -} -Q_DECLARE_METATYPE(shelllet::properties::FileDelete*) \ No newline at end of file diff --git a/QtRpa/include/properties2/helper.xxx b/QtRpa/include/properties2/helper.xxx deleted file mode 100644 index cb8bc8e..0000000 --- a/QtRpa/include/properties2/helper.xxx +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "pugixml.hpp" -#include "composite_property.h" -class QtProperty; -class QtTreePropertyBrowser; -namespace shelllet::properties { - class Helper { - public: - static void register_meta_type(); - - - static std::unique_ptr createRoot(); - // static std::unique_ptr create_node(pugi::xml_node node); - - //static std::string toData(const std::shared_ptr& data); - - // static std::shared_ptr fromData(const std::string& data); - - static std::string toString(const pugi::xml_node& node); - - - }; -} \ No newline at end of file diff --git a/QtRpa/include/properties2/network_send.xxx b/QtRpa/include/properties2/network_send.xxx deleted file mode 100644 index e969773..0000000 --- a/QtRpa/include/properties2/network_send.xxx +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "composite_property.h" - -namespace shelllet { - namespace properties { - class NetworkSendPrivate; - class NetworkSend : public CompositeProperty - { - Q_DECLARE_PRIVATE(NetworkSend) - public: - NetworkSend(const pugi::xml_node& prop, QObject* parent = nullptr); - void setData(const QString& data); - QString getData() const; - - void setOwner(const QString& owner); - QString getOwner() const; - - int getPropertyMetaTypeID() const override; - - - private: - - }; - } -} -Q_DECLARE_METATYPE(shelllet::properties::NetworkSend*) \ No newline at end of file diff --git a/QtRpa/include/properties2/network_udp_client.xxx b/QtRpa/include/properties2/network_udp_client.xxx deleted file mode 100644 index 8fd10b8..0000000 --- a/QtRpa/include/properties2/network_udp_client.xxx +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "composite_property.h" - -namespace shelllet { - namespace properties { - class NetworkUDPClientPrivate; - class NetworkUDPClient : public CompositeProperty - { - Q_DECLARE_PRIVATE(NetworkUDPClient) - public: - NetworkUDPClient(const pugi::xml_node& node, QObject* parent = nullptr); - void setCode(const QString& fileName); - QString getCode() const; - - void setIP(const QString& ip); - QString getIP() const; - - int16_t getPort() const; - void setPort(int16_t port); - - QString getOutputVariable() const; - void setOutputVariable(const QString& variable); - - int getPropertyMetaTypeID() const override; - - protected: - - }; - } -} -Q_DECLARE_METATYPE(shelllet::properties::NetworkUDPClient*) \ No newline at end of file diff --git a/QtRpa/include/properties2/network_udp_server.xxx b/QtRpa/include/properties2/network_udp_server.xxx deleted file mode 100644 index 190b150..0000000 --- a/QtRpa/include/properties2/network_udp_server.xxx +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "composite_property.h" - -namespace shelllet { - namespace properties { - class NetworkUDPServerPrivate; - class NetworkUDPServer : public CompositeProperty - { - Q_DECLARE_PRIVATE(NetworkUDPServer) - public: - NetworkUDPServer(const pugi::xml_node& node, QObject* parent = nullptr); - void setCode(const QString& fileName); - QString getCode() const; - - void setIP(const QString& ip); - QString getIP() const; - - int16_t getPort() const; - void setPort(int16_t port); - - QString getOutputVariable() const; - void setOutputVariable(const QString& variable); - - int getPropertyMetaTypeID() const override; - - - protected: - - }; - } -} -Q_DECLARE_METATYPE(shelllet::properties::NetworkUDPServer*) \ No newline at end of file diff --git a/QtRpa/include/properties2/print.xxxx b/QtRpa/include/properties2/print.xxxx deleted file mode 100644 index 3c54651..0000000 --- a/QtRpa/include/properties2/print.xxxx +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once -#include "composite_property.h" -namespace shelllet { - namespace properties { - class PrintPrivate; - class Print : public CompositeProperty - { - //friend class boost::serialization::access; - - //template - //void save(Archive& ar, const unsigned int version) const - //{ - //// ar& boost::serialization::base_object(*this); - // //QByteArray bytes = toData(); - // ar << toData(); - //} - - //template - //void load(Archive& ar, const unsigned int version) - //{ - //// ar >> boost::serialization::base_object(*this); - // QByteArray bytes; - // ar >> bytes; - // fromData(bytes); - //} - - /*template - void serialize(Archive& ar, const unsigned int version) - { - boost::serialization::split_member(ar, *this, version); - }*/ - //BOOST_SERIALIZATION_SPLIT_FREE(Print) - Q_OBJECT - Q_DECLARE_PRIVATE(Print) - public: - // Print(QObject* parent = nullptr); - Q_INVOKABLE Print(const pugi::xml_node& prop, QObject* parent = nullptr); - - /*Q_INVOKABLE print(QObject* parent = nullptr);*/ - - - //std::unique_ptr getNode() override; - - void getCode(std::ostringstream& oss) override; - - - - - //QByteArray toData() const override; - - - - // std::string getImport()const override; - - - void getDefines(std::ostringstream& oss) override; - - - - //void fromData(const QByteArray& data) override; - - protected: - //virtual void toXml(pugi::xml_node& node); - //virtual void fromXml(const pugi::xml_node& node); - virtual QtProperty* getInput(QtTreePropertyBrowser* browser); - - - }; - } -} - -Q_DECLARE_METATYPE(shelllet::properties::Print*) diff --git a/QtRpa/include/properties2/private/code_p.h b/QtRpa/include/properties2/private/code_p.h deleted file mode 100644 index ed70b80..0000000 --- a/QtRpa/include/properties2/private/code_p.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "common.hpp" -#include "composite_property_p.h" -namespace shelllet { - namespace interpreter { - class CodePrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - - ar& import; - ar& code; - } - public: - String import; - String code; - }; - } -} -BOOST_CLASS_VERSION(shelllet::interpreter::CodePrivate, 1) \ No newline at end of file diff --git a/QtRpa/include/properties2/private/filedelete_p.h b/QtRpa/include/properties2/private/filedelete_p.h deleted file mode 100644 index 8581d54..0000000 --- a/QtRpa/include/properties2/private/filedelete_p.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class FileDeletePrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - } - public: - - QString fileName; - }; -} -} \ No newline at end of file diff --git a/QtRpa/include/properties2/private/network_send_p.h b/QtRpa/include/properties2/private/network_send_p.h deleted file mode 100644 index 93484cb..0000000 --- a/QtRpa/include/properties2/private/network_send_p.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class NetworkSendPrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - } - public: - - QString m_data; - QString m_owner; - }; -} -} \ No newline at end of file diff --git a/QtRpa/include/properties2/private/network_udp_client_p.h b/QtRpa/include/properties2/private/network_udp_client_p.h deleted file mode 100644 index 8a57b58..0000000 --- a/QtRpa/include/properties2/private/network_udp_client_p.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class NetworkUDPClientPrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - } - - public: - - int64_t m_port; - QString m_ip; - QString m_code; - QString m_outputVariable; - }; -} -} \ No newline at end of file diff --git a/QtRpa/include/properties2/private/network_udp_server_p.h b/QtRpa/include/properties2/private/network_udp_server_p.h deleted file mode 100644 index 8ce0669..0000000 --- a/QtRpa/include/properties2/private/network_udp_server_p.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class NetworkUDPServerPrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - } - - public: - - int64_t m_port; - QString m_ip; - QString m_code; - QString m_outputVariable; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/properties2/private/print_p.h b/QtRpa/include/properties2/private/print_p.h deleted file mode 100644 index eca0a72..0000000 --- a/QtRpa/include/properties2/private/print_p.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class PrintPrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - - ar& message_; - } - public: - QString message_; - - QString id; - - }; - } -} -BOOST_CLASS_VERSION(shelllet::interpreter::PrintPrivate, 1) \ No newline at end of file diff --git a/QtRpa/include/properties2/private/processstart_p.h b/QtRpa/include/properties2/private/processstart_p.h deleted file mode 100644 index 93b108b..0000000 --- a/QtRpa/include/properties2/private/processstart_p.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class ProcessStartPrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - - ar& m_fileName; - } - public: - String m_fileName; - QStringList m_parameters; - QString m_workingDirectory; - }; -} -} \ No newline at end of file diff --git a/QtRpa/include/properties2/private/sequence_p.h b/QtRpa/include/properties2/private/sequence_p.h deleted file mode 100644 index 09d78d4..0000000 --- a/QtRpa/include/properties2/private/sequence_p.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class SequencePrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - } - - }; -} -} \ No newline at end of file diff --git a/QtRpa/include/properties2/private/workflow_assign_p.h b/QtRpa/include/properties2/private/workflow_assign_p.h deleted file mode 100644 index f87309f..0000000 --- a/QtRpa/include/properties2/private/workflow_assign_p.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - - class WorkflowAssignPrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - - ar& m_name; - ar& m_value; - } - - public: - QString m_name; - QVariant m_value; - - }; - } -} -BOOST_CLASS_VERSION(shelllet::interpreter::WorkflowAssignPrivate, 1) \ No newline at end of file diff --git a/QtRpa/include/properties2/private/workflow_while_p.h b/QtRpa/include/properties2/private/workflow_while_p.h deleted file mode 100644 index bb77399..0000000 --- a/QtRpa/include/properties2/private/workflow_while_p.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "composite_property_p.h" - -namespace shelllet { - namespace interpreter { - class WorkflowWhilePrivate : public CompositePropertyPrivate { - friend class boost::serialization::access; - template - void serialize(Archive& ar, const unsigned int version) - { - ar& boost::serialization::base_object(*this); - - //ar& m_name; - //ar& m_value; - } - - - }; - } -} -BOOST_CLASS_VERSION(shelllet::interpreter::WorkflowWhilePrivate, 1) \ No newline at end of file diff --git a/QtRpa/include/properties2/processstart.xxxx b/QtRpa/include/properties2/processstart.xxxx deleted file mode 100644 index 00cb992..0000000 --- a/QtRpa/include/properties2/processstart.xxxx +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "composite_property.h" -namespace shelllet { - namespace properties { - class ProcessStartPrivate; - class ProcessStart : public CompositeProperty - { - Q_OBJECT - Q_DECLARE_PRIVATE(ProcessStart) - Q_PROPERTY(String fileName READ fileName WRITE setFileName) - public: - Q_INVOKABLE ProcessStart(const pugi::xml_node& node, QObject* parent = nullptr); - void setFileName(const String& fileName); - void setParameters(const QStringList& parameters); - void setWorkingDirectory(const QString& workingDirectory); - - String fileName() const; - QStringList parameters() const; - QString workingDirectory() const; - - int getPropertyMetaTypeID() const override; - //std::unique_ptr getNode() override; - - void getCode(std::ostringstream& oss) override; - - - //std::string getImport() const override; - - }; - } -} -Q_DECLARE_METATYPE(shelllet::properties::ProcessStart*) \ No newline at end of file diff --git a/QtRpa/include/properties2/sequence.h b/QtRpa/include/properties2/sequence.h deleted file mode 100644 index f861b56..0000000 --- a/QtRpa/include/properties2/sequence.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "composite_property.h" - -namespace shelllet { - namespace interpreter { - class SequencePrivate; - class Sequence : public CompositeProperty - { - Q_OBJECT - Q_DECLARE_PRIVATE(Sequence) - public: - Q_INVOKABLE Sequence(const XmlNode& node = {}, QObject* parent = nullptr); - - - //std::unique_ptr getNode() override; - - void getCode(std::ostringstream& oss) override; - - - - //std::string getImport() const override; - - }; - } -} - -Q_DECLARE_METATYPE(shelllet::interpreter::Sequence*) diff --git a/QtRpa/include/properties2/workflow_assign.xxx b/QtRpa/include/properties2/workflow_assign.xxx deleted file mode 100644 index f26630c..0000000 --- a/QtRpa/include/properties2/workflow_assign.xxx +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "composite_property.h" -namespace shelllet { - namespace properties { - class WorkflowAssignPrivate; - class WorkflowAssign : public CompositeProperty - { - Q_DECLARE_PRIVATE(WorkflowAssign) - public: - WorkflowAssign(const pugi::xml_node& node, QObject* parent = nullptr); - - QString varName() const; - void setVarName(const QString& val); - QVariant varValue() const; - void setVarValue(const QVariant& val); - - int getPropertyMetaTypeID() const override; - - private: - - }; - } -} -Q_DECLARE_METATYPE(shelllet::properties::WorkflowAssign*) \ No newline at end of file diff --git a/QtRpa/include/properties2/workflow_while.xxx b/QtRpa/include/properties2/workflow_while.xxx deleted file mode 100644 index 93f44cc..0000000 --- a/QtRpa/include/properties2/workflow_while.xxx +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "composite_property.h" -namespace shelllet { - namespace properties { - class WorkflowWhilePrivate; - class WorkflowWhile : public CompositeProperty - { - Q_DECLARE_PRIVATE(WorkflowWhile) - public: - WorkflowWhile(const pugi::xml_node& node, QObject* parent = nullptr); - }; - } -} -Q_DECLARE_METATYPE(shelllet::properties::WorkflowWhile*) \ No newline at end of file diff --git a/QtRpa/include/property.hpp b/QtRpa/include/property.hpp deleted file mode 100644 index 512f2da..0000000 --- a/QtRpa/include/property.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "common.hpp" -#include "qwidget.h" -#include "property/propertysheet.h" -#include "property/abstractpropertymanager.h" -#include "property/grouppropertymanager.h" -#include "property/abstractpropertybrowser.h" -#include "property/propertybrowser.h" -#include "property/abstracteditorfactorybase.h" -#include "property/abstracteditorfactory.h" -#include "property/abstractpropertymanager.h" -#include "property/stringpropertymanager.h" -#include "property/lineeditfactory.h" -//#include "interpreter/error.h" - -using namespace shelllet::property; diff --git a/QtRpa/include/property/abstracteditorfactory.h b/QtRpa/include/property/abstracteditorfactory.h deleted file mode 100644 index 9ee5fcf..0000000 --- a/QtRpa/include/property/abstracteditorfactory.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once -#include "propertysheet.h" -namespace shelllet { - namespace property { - class AbstractEditorFactoryPrivate; - class PropertySheet; - template - class AbstractEditorFactory : public AbstractEditorFactoryBase - { - public: - explicit AbstractEditorFactory(QObject* parent) : AbstractEditorFactoryBase(parent) {} - QWidget* createEditor(PropertySheet* property, QWidget* parent) - { - for (PropertyManager* manager : qAsConst(m_managers)) { - if (manager == property->propertyManager()) { - return createEditor(manager, property, parent); - } - } - return 0; - } - void addPropertyManager(PropertyManager* manager) - { - if (m_managers.contains(manager)) - return; - m_managers.insert(manager); - connectPropertyManager(manager); - connect(manager, &AbstractEditorFactory::destroyed, this, &AbstractEditorFactory::managerDestroyed); - } - void removePropertyManager(PropertyManager* manager) - { - if (!m_managers.contains(manager)) - return; - - disconnect(manager, &AbstractEditorFactory::destroyed, this, &AbstractEditorFactory::managerDestroyed); - disconnectPropertyManager(manager); - m_managers.remove(manager); - } - QSet propertyManagers() const - { - return m_managers; - } - PropertyManager* propertyManager(PropertySheet* property) const - { - AbstractPropertyManager* manager = property->propertyManager(); - for (PropertyManager* m : qAsConst(m_managers)) { - if (m == manager) { - return m; - } - } - return 0; - } - protected: - AbstractEditorFactory(AbstractEditorFactoryPrivate& d, QObject* parent) :AbstractEditorFactoryBase(d, parent) { - - } - virtual void connectPropertyManager(PropertyManager* manager) = 0; - virtual QWidget* createEditor(PropertyManager* manager, PropertySheet* property, - QWidget* parent) = 0; - virtual void disconnectPropertyManager(PropertyManager* manager) = 0; - void managerDestroyed(QObject* manager) - { - for (PropertyManager* m : qAsConst(m_managers)) { - if (m == manager) { - m_managers.remove(m); - return; - } - } - } - private: - void breakConnection(AbstractPropertyManager* manager) - { - for (PropertyManager* m : qAsConst(m_managers)) { - if (m == manager) { - removePropertyManager(m); - return; - } - } - } - private: - QSet m_managers; - friend class QtAbstractPropertyEditor; - }; - - } -} diff --git a/QtRpa/include/property/abstracteditorfactorybase.h b/QtRpa/include/property/abstracteditorfactorybase.h deleted file mode 100644 index b915c42..0000000 --- a/QtRpa/include/property/abstracteditorfactorybase.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "qobject.h" - -namespace shelllet { - namespace property { - class PropertySheet; - class AbstractPropertyManager; - class AbstractEditorFactoryBasePrivate; - class AbstractEditorFactoryBase : public QObject - { - Q_OBJECT - public: - virtual QWidget* createEditor(PropertySheet* property, QWidget* parent) = 0; - protected: - explicit AbstractEditorFactoryBase(QObject* parent = 0) - : QObject(parent) {} - - virtual void breakConnection(AbstractPropertyManager* manager) = 0; - - AbstractEditorFactoryBase(AbstractEditorFactoryBasePrivate& d, QObject* parent); - protected slots: - virtual void managerDestroyed(QObject* manager) = 0; - - friend class AbstractPropertyBrowser; - }; - - } -} diff --git a/QtRpa/include/property/abstractpropertybrowser.h b/QtRpa/include/property/abstractpropertybrowser.h deleted file mode 100644 index 3c9c790..0000000 --- a/QtRpa/include/property/abstractpropertybrowser.h +++ /dev/null @@ -1,74 +0,0 @@ -#pragma once -#include "qwidget.h" -namespace shelllet { - namespace property { - class BrowserItem; - class PropertySheet; - template class AbstractEditorFactory; - class AbstractEditorFactoryBase; - class AbstractPropertyManager; - class AbstractPropertyBrowserPrivate; - class AbstractPropertyBrowser : public QWidget/*, private boost::noncopyable*/ { - Q_OBJECT - Q_DECLARE_PRIVATE(AbstractPropertyBrowser) - public: - - explicit AbstractPropertyBrowser(QWidget* parent = 0); - ~AbstractPropertyBrowser(); - - QList properties() const; - QList items(PropertySheet* property) const; - BrowserItem* topLevelItem(PropertySheet* property) const; - QList topLevelItems() const; - void clear(); - - template - void setFactoryForManager(PropertyManager* manager, - AbstractEditorFactory* factory) { - AbstractPropertyManager* abstractManager = manager; - AbstractEditorFactoryBase* abstractFactory = factory; - - if (addFactory(abstractManager, abstractFactory)) - factory->addPropertyManager(manager); - } - - void unsetFactoryForManager(AbstractPropertyManager* manager); - - BrowserItem* currentItem() const; - void setCurrentItem(BrowserItem*); - - signals: - void currentItemChanged(BrowserItem* item); - public slots: - - BrowserItem* addProperty(PropertySheet* property); - BrowserItem* insertProperty(PropertySheet* property, PropertySheet* afterProperty); - void removeProperty(PropertySheet* property); - - protected: - - virtual void itemInserted(BrowserItem* item, BrowserItem* afterItem) = 0; - virtual void itemRemoved(BrowserItem* item) = 0; - // can be tooltip, statustip, whatsthis, name, icon, text. - virtual void itemChanged(BrowserItem* item) = 0; - - virtual QWidget* createEditor(PropertySheet* property, QWidget* parent); - private: - - bool addFactory(AbstractPropertyManager* abstractManager, - AbstractEditorFactoryBase* abstractFactory); - - // QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtAbstractPropertyBrowser) - // Q_DISABLE_COPY_MOVE(QtAbstractPropertyBrowser) - /*Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(PropertySheet*, - PropertySheet*, PropertySheet*)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(PropertySheet*, - PropertySheet*)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDataChanged(PropertySheet*))*/ - protected: - AbstractPropertyBrowser(AbstractPropertyBrowserPrivate& d, QWidget* parent = nullptr); - }; - } -} diff --git a/QtRpa/include/property/abstractpropertymanager.h b/QtRpa/include/property/abstractpropertymanager.h deleted file mode 100644 index dbbbf34..0000000 --- a/QtRpa/include/property/abstractpropertymanager.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class PropertySheet; - class AbstractPropertyManagerPrivate; - class AbstractPropertyManager : public QObject, private boost::noncopyable { - Q_OBJECT - Q_DECLARE_PRIVATE(AbstractPropertyManager) - public: - //AbstractPropertyManager(Object*parent = nullptr); - - public: - - explicit AbstractPropertyManager(QObject* parent = 0); - ~AbstractPropertyManager(); - - QSet properties() const; - void clear() const; - - PropertySheet* addProperty(const String& name); - signals: - - void propertyInserted(PropertySheet* property, PropertySheet* parent, PropertySheet* after); - - void propertyChanged(PropertySheet* property); - void propertyRemoved(PropertySheet* property, PropertySheet* parent); - void propertyDestroyed(PropertySheet* property); - protected: - virtual bool hasValue(const PropertySheet* property) const; - virtual QIcon valueIcon(const PropertySheet* property) const; - virtual String valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property) = 0; - virtual void uninitializeProperty(PropertySheet* property); - virtual PropertySheet* createProperty(); - private: - friend class PropertySheet; - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtAbstractPropertyManager) - //Q_DISABLE_COPY_MOVE(QtAbstractPropertyManager) - protected: - AbstractPropertyManager(AbstractPropertyManagerPrivate& d, QObject*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/booledit.h b/QtRpa/include/property/booledit.h deleted file mode 100644 index 308e8c4..0000000 --- a/QtRpa/include/property/booledit.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "qwidget.h" -class QCheckBox; -namespace shelllet { - namespace property{ - class BoolEditPrivate; - class BoolEdit : public QWidget { - Q_DECLARE_PRIVATE(BoolEdit) - public: - BoolEdit(Object*parent = nullptr); - Q_OBJECT - public: - BoolEdit(QWidget* parent = 0); - - bool textVisible() const { return m_textVisible; } - void setTextVisible(bool textVisible); - - Qt::CheckState checkState() const; - void setCheckState(Qt::CheckState state); - - bool isChecked() const; - void setChecked(bool c); - - bool blockCheckBoxSignals(bool block); - - Q_SIGNALS: - void toggled(bool); - - protected: - void mousePressEvent(QMouseEvent* event); - - private: - QCheckBox* m_checkBox; - bool m_textVisible; - protected: - BoolEdit(BoolEditPrivate& d, QWidget*parent = nullptr); - - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/boolpropertymanager.h1 b/QtRpa/include/property/boolpropertymanager.h1 deleted file mode 100644 index fd3cc2e..0000000 --- a/QtRpa/include/property/boolpropertymanager.h1 +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class BoolPropertyManagerPrivate; - class BoolPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(BoolPropertyManager) - public: - BoolPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - BoolPropertyManager(QObject* parent = 0); - ~BoolPropertyManager(); - - bool value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, bool val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, bool val); - protected: - QString valueText(const PropertySheet* property) const; - QIcon valueIcon(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtBoolPropertyManager) - // Q_DISABLE_COPY_MOVE(QtBoolPropertyManager) - protected: - BoolPropertyManager(BoolPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/browseritem.h b/QtRpa/include/property/browseritem.h deleted file mode 100644 index 1327e65..0000000 --- a/QtRpa/include/property/browseritem.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -namespace shelllet { - namespace property { - class PropertySheet; - class AbstractPropertyBrowser; - class BrowserItemPrivate; - class BrowserItem : public Object { - Q_DECLARE_PRIVATE(BrowserItem) - public: - - public: - PropertySheet* property() const; - BrowserItem* parent() const; - QList children() const; - AbstractPropertyBrowser* browser() const; - private: - explicit BrowserItem(AbstractPropertyBrowser* browser, PropertySheet* property, BrowserItem* parent); - ~BrowserItem(); - // QScopedPointer d_ptr; - friend class AbstractPropertyBrowserPrivate; - protected: - BrowserItem(BrowserItemPrivate& d, Object* parent = nullptr); - }; - } -} -W_REGISTER_ARGTYPE(shelllet::property::BrowserItem*) - diff --git a/QtRpa/include/property/buttonpropertybrowser.h b/QtRpa/include/property/buttonpropertybrowser.h deleted file mode 100644 index 0db72d2..0000000 --- a/QtRpa/include/property/buttonpropertybrowser.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once -#include "abstractpropertybrowser.h" -namespace shelllet { - namespace property { - class ButtonPropertyBrowserPrivate; - class ButtonPropertyBrowser : public AbstractPropertyBrowser { - Q_OBJECT - Q_DECLARE_PRIVATE(ButtonPropertyBrowser) - public: - ButtonPropertyBrowser(Object* parent = nullptr); - //Q_DECLARE_PRIVATE(QtButtonPropertyBrowser) - public: - - ButtonPropertyBrowser(QWidget* parent = 0); - ~ButtonPropertyBrowser(); - - void setExpanded(BrowserItem* item, bool expanded); - bool isExpanded(BrowserItem* item) const; - - Q_SIGNALS: - - void collapsed(BrowserItem* item); - void expanded(BrowserItem* item); - - protected: - virtual void itemInserted(BrowserItem* item, BrowserItem* afterItem); - virtual void itemRemoved(BrowserItem* item); - virtual void itemChanged(BrowserItem* item); - - private slots: - - // QScopedPointer d_ptr; - - // Q_DISABLE_COPY_MOVE(QtButtonPropertyBrowser) - /*Q_PRIVATE_SLOT(d_func(), void slotUpdate()) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) - Q_PRIVATE_SLOT(d_func(), void slotToggled(bool))*/ - protected: - ButtonPropertyBrowser(ButtonPropertyBrowserPrivate& d, QWidget* parent1 = nullptr, Object* parent = nullptr); - }; - } -} diff --git a/QtRpa/include/property/charpropertymanager.h1 b/QtRpa/include/property/charpropertymanager.h1 deleted file mode 100644 index 3e155c6..0000000 --- a/QtRpa/include/property/charpropertymanager.h1 +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class CharPropertyManagerPrivate; - class CharPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(CharPropertyManager) - public: - CharPropertyManager(Object*parent = nullptr); - - Q_OBJECT - public: - CharPropertyManager(QObject* parent = 0); - ~CharPropertyManager(); - - QChar value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QChar& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QChar& val); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - // Q_DECLARE_PRIVATE(QtCharPropertyManager) - // Q_DISABLE_COPY_MOVE(QtCharPropertyManager) - protected: - CharPropertyManager(CharPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/colorpropertymanager.h1 b/QtRpa/include/property/colorpropertymanager.h1 deleted file mode 100644 index f3c5efd..0000000 --- a/QtRpa/include/property/colorpropertymanager.h1 +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class ColorPropertyManagerPrivate; - class ColorPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(ColorPropertyManager) - public: - ColorPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - ColorPropertyManager(QObject* parent = 0); - ~ColorPropertyManager(); - - QtIntPropertyManager* subIntPropertyManager() const; - - QColor value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QColor& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QColor& val); - protected: - QString valueText(const PropertySheet* property) const; - QIcon valueIcon(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtColorPropertyManager) - // Q_DISABLE_COPY_MOVE(QtColorPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - protected: - ColorPropertyManager(ColorPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/cursordatabase.h b/QtRpa/include/property/cursordatabase.h deleted file mode 100644 index 56e5f9d..0000000 --- a/QtRpa/include/property/cursordatabase.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class CursorDatabasePrivate; - class CursorDatabase : public Object { - Q_DECLARE_PRIVATE(CursorDatabase) - public: - CursorDatabase(Object*parent = nullptr); - - void clear(); - - QStringList cursorShapeNames() const; - QMap cursorShapeIcons() const; - QString cursorToShapeName(const QCursor& cursor) const; - QIcon cursorToShapeIcon(const QCursor& cursor) const; - int cursorToValue(const QCursor& cursor) const; -#ifndef QT_NO_CURSOR - QCursor valueToCursor(int value) const; -#endif - static CursorDatabase* getInstance(); - private: - void appendCursor(Qt::CursorShape shape, const QString& name, const QIcon& icon); - QStringList m_cursorNames; - QMap m_cursorIcons; - QMap m_valueToCursorShape; - QMap m_cursorShapeToValue; - protected: - CursorDatabase(CursorDatabasePrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/cursorpropertymanager.h1 b/QtRpa/include/property/cursorpropertymanager.h1 deleted file mode 100644 index 71f516c..0000000 --- a/QtRpa/include/property/cursorpropertymanager.h1 +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class CursorPropertyManagerPrivate; - class CursorPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(CursorPropertyManager) - public: - CursorPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - CursorPropertyManager(QObject* parent = 0); - ~CursorPropertyManager(); - -#ifndef QT_NO_CURSOR - QCursor value(const PropertySheet* property) const; -#endif - - public Q_SLOTS: - void setValue(PropertySheet* property, const QCursor& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QCursor& val); - protected: - QString valueText(const PropertySheet* property) const; - QIcon valueIcon(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtCursorPropertyManager) - // Q_DISABLE_COPY_MOVE(QtCursorPropertyManager) - protected: - CursorPropertyManager(CursorPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/datepropertymanager.h1 b/QtRpa/include/property/datepropertymanager.h1 deleted file mode 100644 index be22385..0000000 --- a/QtRpa/include/property/datepropertymanager.h1 +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class DatePropertyManagerPrivate; - class DatePropertyManager : public AbstractPropertyManager, private boost::noncopyable{ - Q_DECLARE_PRIVATE(DatePropertyManager) - public: - DatePropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - DatePropertyManager(QObject* parent = 0); - ~DatePropertyManager(); - - QDate value(const PropertySheet* property) const; - QDate minimum(const PropertySheet* property) const; - QDate maximum(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QDate& val); - void setMinimum(PropertySheet* property, const QDate& minVal); - void setMaximum(PropertySheet* property, const QDate& maxVal); - void setRange(PropertySheet* property, const QDate& minVal, const QDate& maxVal); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QDate& val); - void rangeChanged(PropertySheet* property, const QDate& minVal, const QDate& maxVal); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtDatePropertyManager) - // Q_DISABLE_COPY_MOVE(QtDatePropertyManager) - protected: - DatePropertyManager(DatePropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/datetimepropertymanager.h1 b/QtRpa/include/property/datetimepropertymanager.h1 deleted file mode 100644 index cc35d41..0000000 --- a/QtRpa/include/property/datetimepropertymanager.h1 +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class DateTimePropertyManagerPrivate; - class DateTimePropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(DateTimePropertyManager) - public: - DateTimePropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - DateTimePropertyManager(QObject* parent = 0); - ~DateTimePropertyManager(); - - QDateTime value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QDateTime& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QDateTime& val); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - // Q_DECLARE_PRIVATE(QtDateTimePropertyManager) - // Q_DISABLE_COPY_MOVE(QtDateTimePropertyManager) - protected: - DateTimePropertyManager(DateTimePropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/doublepropertymanager.h1 b/QtRpa/include/property/doublepropertymanager.h1 deleted file mode 100644 index 6833f73..0000000 --- a/QtRpa/include/property/doublepropertymanager.h1 +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class DoublePropertyManagerPrivate; - class DoublePropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(DoublePropertyManager) - public: - DoublePropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - DoublePropertyManager(QObject* parent = 0); - ~DoublePropertyManager(); - - double value(const PropertySheet* property) const; - double minimum(const PropertySheet* property) const; - double maximum(const PropertySheet* property) const; - double singleStep(const PropertySheet* property) const; - int decimals(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, double val); - void setMinimum(PropertySheet* property, double minVal); - void setMaximum(PropertySheet* property, double maxVal); - void setRange(PropertySheet* property, double minVal, double maxVal); - void setSingleStep(PropertySheet* property, double step); - void setDecimals(PropertySheet* property, int prec); - Q_SIGNALS: - void valueChanged(PropertySheet* property, double val); - void rangeChanged(PropertySheet* property, double minVal, double maxVal); - void singleStepChanged(PropertySheet* property, double step); - void decimalsChanged(PropertySheet* property, int prec); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtDoublePropertyManager) - // Q_DISABLE_COPY_MOVE(QtDoublePropertyManager) - protected: - DoublePropertyManager(DoublePropertyManagerPrivate& d, QObject* parent, Object*/*parent = nullptr*/); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/enumpropertymanager.h1 b/QtRpa/include/property/enumpropertymanager.h1 deleted file mode 100644 index 24bfbac..0000000 --- a/QtRpa/include/property/enumpropertymanager.h1 +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class EnumPropertyManagerPrivate; - class EnumPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(EnumPropertyManager) - public: - EnumPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - EnumPropertyManager(QObject* parent = 0); - ~EnumPropertyManager(); - - int value(const PropertySheet* property) const; - QStringList enumNames(const PropertySheet* property) const; - QMap enumIcons(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, int val); - void setEnumNames(PropertySheet* property, const QStringList& names); - void setEnumIcons(PropertySheet* property, const QMap& icons); - Q_SIGNALS: - void valueChanged(PropertySheet* property, int val); - void enumNamesChanged(PropertySheet* property, const QStringList& names); - void enumIconsChanged(PropertySheet* property, const QMap& icons); - protected: - QString valueText(const PropertySheet* property) const; - QIcon valueIcon(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - // QScopedPointer d_ptr; - // Q_DECLARE_PRIVATE(QtEnumPropertyManager) - // Q_DISABLE_COPY_MOVE(QtEnumPropertyManager) - protected: - EnumPropertyManager(EnumPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/flagpropertymanager.h1 b/QtRpa/include/property/flagpropertymanager.h1 deleted file mode 100644 index 88428fc..0000000 --- a/QtRpa/include/property/flagpropertymanager.h1 +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class FlagPropertyManagerPrivate; - class FlagPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(FlagPropertyManager) - public: - FlagPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - FlagPropertyManager(QObject* parent = 0); - ~FlagPropertyManager(); - - QtBoolPropertyManager* subBoolPropertyManager() const; - - int value(const PropertySheet* property) const; - QStringList flagNames(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, int val); - void setFlagNames(PropertySheet* property, const QStringList& names); - Q_SIGNALS: - void valueChanged(PropertySheet* property, int val); - void flagNamesChanged(PropertySheet* property, const QStringList& names); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - // QScopedPointer d_ptr; - // Q_DECLARE_PRIVATE(QtFlagPropertyManager) - // Q_DISABLE_COPY_MOVE(QtFlagPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(PropertySheet*, bool)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - protected: - FlagPropertyManager(FlagPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/fontpropertymanager.h1 b/QtRpa/include/property/fontpropertymanager.h1 deleted file mode 100644 index b70bf3d..0000000 --- a/QtRpa/include/property/fontpropertymanager.h1 +++ /dev/null @@ -1,45 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class FontPropertyManagerPrivate; - class FontPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(FontPropertyManager) - public: - FontPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - QtFontPropertyManager(QObject* parent = 0); - ~QtFontPropertyManager(); - - QtIntPropertyManager* subIntPropertyManager() const; - QtEnumPropertyManager* subEnumPropertyManager() const; - QtBoolPropertyManager* subBoolPropertyManager() const; - - QFont value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QFont& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QFont& val); - protected: - QString valueText(const PropertySheet* property) const; - QIcon valueIcon(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - // QScopedPointer d_ptr; - // Q_DECLARE_PRIVATE(QtFontPropertyManager) - // Q_DISABLE_COPY_MOVE(QtFontPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotBoolChanged(PropertySheet*, bool)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseChanged()) - Q_PRIVATE_SLOT(d_func(), void slotFontDatabaseDelayedChange()) - protected: - FontPropertyManager(FontPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/framework.h b/QtRpa/include/property/framework.h deleted file mode 100644 index 2085256..0000000 --- a/QtRpa/include/property/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -#include "common.hpp" -#include "qobject.h" -#include "qwidget.h" -#include "propertysheet.h" diff --git a/QtRpa/include/property/groupboxpropertybrowser.h b/QtRpa/include/property/groupboxpropertybrowser.h deleted file mode 100644 index bfe1c5f..0000000 --- a/QtRpa/include/property/groupboxpropertybrowser.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class GroupBoxPropertyBrowserPrivate; - class GroupBoxPropertyBrowser : public AbstractPropertyBrowser { - Q_DECLARE_PRIVATE(GroupBoxPropertyBrowser) - public: - GroupBoxPropertyBrowser(Object*parent = nullptr); - - Q_OBJECT - public: - - GroupBoxPropertyBrowser(QWidget* parent = 0); - ~GroupBoxPropertyBrowser(); - - protected: - virtual void itemInserted(BrowserItem* item, BrowserItem* afterItem); - virtual void itemRemoved(BrowserItem* item); - virtual void itemChanged(BrowserItem* item); - - private: - - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser) - // Q_DISABLE_COPY_MOVE(QtGroupBoxPropertyBrowser) - //Q_PRIVATE_SLOT(d_func(), void slotUpdate()) - //Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed()) - protected: - GroupBoxPropertyBrowser(GroupBoxPropertyBrowserPrivate& d, QWidget* widget = nullptr, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/grouppropertymanager.h b/QtRpa/include/property/grouppropertymanager.h deleted file mode 100644 index 9645e87..0000000 --- a/QtRpa/include/property/grouppropertymanager.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class GroupPropertyManagerPrivate; - class GroupPropertyManager : public AbstractPropertyManager { - Q_DECLARE_PRIVATE(GroupPropertyManager) - W_OBJECT(GroupPropertyManager) - public: - // GroupPropertyManager(Object*parent = nullptr); - - //Q_OBJECT - public: - GroupPropertyManager(QObject* parent = 0); - ~GroupPropertyManager() = default; - - protected: - virtual bool hasValue(const PropertySheet* property) const; - - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - protected: - GroupPropertyManager(GroupPropertyManagerPrivate& d, QObject* parent1, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/intpropertymanager.h1 b/QtRpa/include/property/intpropertymanager.h1 deleted file mode 100644 index 561b4c7..0000000 --- a/QtRpa/include/property/intpropertymanager.h1 +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class IntPropertyManagerPrivate; - class IntPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(IntPropertyManager) - public: - IntPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - IntPropertyManager(QObject* parent = 0); - ~IntPropertyManager(); - - int value(const PropertySheet* property) const; - int minimum(const PropertySheet* property) const; - int maximum(const PropertySheet* property) const; - int singleStep(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, int val); - void setMinimum(PropertySheet* property, int minVal); - void setMaximum(PropertySheet* property, int maxVal); - void setRange(PropertySheet* property, int minVal, int maxVal); - void setSingleStep(PropertySheet* property, int step); - Q_SIGNALS: - void valueChanged(PropertySheet* property, int val); - void rangeChanged(PropertySheet* property, int minVal, int maxVal); - void singleStepChanged(PropertySheet* property, int step); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtIntPropertyManager) - // Q_DISABLE_COPY_MOVE(QtIntPropertyManager) - protected: - IntPropertyManager(IntPropertyManagerPrivate& d,QObject*parent1, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/keysequencepropertymanager.h1 b/QtRpa/include/property/keysequencepropertymanager.h1 deleted file mode 100644 index dbd88e8..0000000 --- a/QtRpa/include/property/keysequencepropertymanager.h1 +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class KeySequencePropertyManagerPrivate; - class KeySequencePropertyManager : public AbstractPropertyManager, boost::noncopyable { - Q_DECLARE_PRIVATE(KeySequencePropertyManager) - public: - KeySequencePropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - KeySequencePropertyManager(QObject* parent = 0); - ~KeySequencePropertyManager(); - - QKeySequence value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QKeySequence& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QKeySequence& val); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtKeySequencePropertyManager) - // Q_DISABLE_COPY_MOVE(QtKeySequencePropertyManager) - protected: - KeySequencePropertyManager(KeySequencePropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/lineeditfactory.h b/QtRpa/include/property/lineeditfactory.h deleted file mode 100644 index 6d9da3d..0000000 --- a/QtRpa/include/property/lineeditfactory.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "stringpropertymanager.h" -#include "abstracteditorfactory.h" -namespace shelllet { - namespace property{ - class LineEditFactoryPrivate; - class LineEditFactory : public AbstractEditorFactory { - Q_OBJECT - Q_DECLARE_PRIVATE(LineEditFactory) - public: - // LineEditFactory(Object*parent = nullptr); - - public: - LineEditFactory(QObject* parent = 0); - ~LineEditFactory(); - protected: - void connectPropertyManager(StringPropertyManager* manager); - QWidget* createEditor(StringPropertyManager* manager, PropertySheet* property, - QWidget* parent); - void disconnectPropertyManager(StringPropertyManager* manager); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtLineEditFactory) - // Q_DISABLE_COPY_MOVE(QtLineEditFactory) - /*Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet*, const QString&)) - Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(PropertySheet*, const QRegExp&)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QString&)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject*))*/ - - - protected: - LineEditFactory(LineEditFactoryPrivate& d, QObject* parent, Object*parent1 = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/localepropertymanager.h1 b/QtRpa/include/property/localepropertymanager.h1 deleted file mode 100644 index b41ac64..0000000 --- a/QtRpa/include/property/localepropertymanager.h1 +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class LocalePropertyManagerPrivate; - class LocalePropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(LocalePropertyManager) - public: - LocalePropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - LocalePropertyManager(QObject* parent = 0); - ~LocalePropertyManager(); - - QtEnumPropertyManager* subEnumPropertyManager() const; - - QLocale value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QLocale& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QLocale& val); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtLocalePropertyManager) - // Q_DISABLE_COPY_MOVE(QtLocalePropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - protected: - LocalePropertyManager(LocalePropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/pointpropertymanager.h1 b/QtRpa/include/property/pointpropertymanager.h1 deleted file mode 100644 index d4c9fce..0000000 --- a/QtRpa/include/property/pointpropertymanager.h1 +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class PointPropertyManagerPrivate; - class PointPropertyManager : public AbstractPropertyManager, boost::noncopyable { - Q_DECLARE_PRIVATE(PointPropertyManager) - public: - PointPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - PointPropertyManager(QObject* parent = 0); - ~PointPropertyManager(); - - QtDoublePropertyManager* subDoublePropertyManager() const; - - QPointF value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QPoint& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QPoint& val); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtPointPropertyManager) - // Q_DISABLE_COPY_MOVE(QtPointPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - protected: - PointPropertyManager(PointPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - - diff --git a/QtRpa/include/property/private/abstracteditorfactorybaseprivate_p.h b/QtRpa/include/property/private/abstracteditorfactorybaseprivate_p.h deleted file mode 100644 index 85b1cac..0000000 --- a/QtRpa/include/property/private/abstracteditorfactorybaseprivate_p.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - - -namespace shelllet { - namespace property { - class AbstractEditorFactoryBasePrivate : public QObjectPrivate { - public: - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/property/private/abstracteditorfactoryprivate_p.h b/QtRpa/include/property/private/abstracteditorfactoryprivate_p.h deleted file mode 100644 index 210f31f..0000000 --- a/QtRpa/include/property/private/abstracteditorfactoryprivate_p.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once -namespace shelllet { - namespace property { - class AbstractEditorFactoryPrivate : public AbstractEditorFactoryBasePrivate { - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/property/private/abstractpropertybrowser_p.h b/QtRpa/include/property/private/abstractpropertybrowser_p.h deleted file mode 100644 index 15a9678..0000000 --- a/QtRpa/include/property/private/abstractpropertybrowser_p.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#ifdef PropertySheet -#undef PropertySheet -#endif // PropertySheet -namespace shelllet { - namespace property { - class AbstractPropertyBrowserPrivate : public QWidgetPrivate { - Q_DECLARE_PUBLIC(AbstractPropertyBrowser) - public: - AbstractPropertyBrowserPrivate(); - void insertSubTree(PropertySheet* property, - PropertySheet* parentProperty); - void removeSubTree(PropertySheet* property, - PropertySheet* parentProperty); - void createBrowserIndexes(PropertySheet* property, PropertySheet* parentProperty, PropertySheet* afterProperty); - void removeBrowserIndexes(PropertySheet* property, PropertySheet* parentProperty); - BrowserItem* createBrowserIndex(PropertySheet* property, BrowserItem* parentIndex, BrowserItem* afterIndex); - void removeBrowserIndex(BrowserItem* index); - void clearIndex(BrowserItem* index); - - void slotPropertyInserted(PropertySheet* property, - PropertySheet* parentProperty, PropertySheet* afterProperty); - void slotPropertyRemoved(PropertySheet* property, PropertySheet* parentProperty); - void slotPropertyDestroyed(PropertySheet* property); - void slotPropertyDataChanged(PropertySheet* property); - - QList m_subItems; - QMap > m_managerToProperties; - QMap > m_propertyToParents; - - QMap m_topLevelPropertyToIndex; - QList m_topLevelIndexes; - QMap > m_propertyToIndexes; - - BrowserItem* m_currentItem; - }; - } -} diff --git a/QtRpa/include/property/private/abstractpropertymanager_p.h b/QtRpa/include/property/private/abstractpropertymanager_p.h deleted file mode 100644 index 4b6146d..0000000 --- a/QtRpa/include/property/private/abstractpropertymanager_p.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class AbstractPropertyManagerPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(AbstractPropertyManager) - public: - //QtAbstractPropertyManager* q_ptr; - //Q_DECLARE_PUBLIC(QtAbstractPropertyManager) - public: - void propertyDestroyed(PropertySheet* property); - void propertyChanged(PropertySheet* property) ; - void propertyRemoved(PropertySheet* property, - PropertySheet* parentProperty) ; - void propertyInserted(PropertySheet* property, PropertySheet* parentProperty, - PropertySheet* afterProperty); - - QSet m_properties; - }; - } -} diff --git a/QtRpa/include/property/private/booledit_p.h b/QtRpa/include/property/private/booledit_p.h deleted file mode 100644 index 05a367e..0000000 --- a/QtRpa/include/property/private/booledit_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class BoolEditPrivate : public QWidgetPrivate { - Q_DECLARE_PUBLIC(BoolEdit) - public: - }; - } -} diff --git a/QtRpa/include/property/private/boolpropertymanager_p.h b/QtRpa/include/property/private/boolpropertymanager_p.h deleted file mode 100644 index 9fdf811..0000000 --- a/QtRpa/include/property/private/boolpropertymanager_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class BoolPropertyManagerPrivate : public AbstractPropertyManagerPrivate { - Q_DECLARE_PUBLIC(BoolPropertyManager) - - public: - QtBoolPropertyManagerPrivate(); - - QMap m_values; - const QIcon m_checkedIcon; - const QIcon m_uncheckedIcon; - }; - } -} diff --git a/QtRpa/include/property/private/browseritem_p.h b/QtRpa/include/property/private/browseritem_p.h deleted file mode 100644 index 8f1a19d..0000000 --- a/QtRpa/include/property/private/browseritem_p.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#ifdef PropertySheet -#undef PropertySheet -#endif // PropertySheet -namespace shelllet { - namespace property{ - class BrowserItemPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(BrowserItem) - public: - public: - BrowserItemPrivate(AbstractPropertyBrowser* browser, PropertySheet* property, BrowserItem* parent) - : m_browser(browser), m_property(property), m_parent(parent), q_ptr(0) {} - - void addChild(BrowserItem* index, BrowserItem* after); - void removeChild(BrowserItem* index); - - AbstractPropertyBrowser* const m_browser; - PropertySheet* m_property; - BrowserItem* m_parent; - - BrowserItem* q_ptr; - - QList m_children; - }; - } -} diff --git a/QtRpa/include/property/private/buttonpropertybrowser_p.h b/QtRpa/include/property/private/buttonpropertybrowser_p.h deleted file mode 100644 index f60358e..0000000 --- a/QtRpa/include/property/private/buttonpropertybrowser_p.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class ButtonPropertyBrowserPrivate : public AbstractPropertyBrowserPrivate { - Q_DECLARE_PUBLIC(ButtonPropertyBrowser) - public: - - //QtButtonPropertyBrowser* q_ptr; - //Q_DECLARE_PUBLIC(QtButtonPropertyBrowser) - public: - - void init(QWidget* parent); - - void propertyInserted(BrowserItem* index, BrowserItem* afterIndex); - void propertyRemoved(BrowserItem* index); - void propertyChanged(BrowserItem* index); - QWidget* createEditor(PropertySheet* property, QWidget* parent) - { - Q_Q(ButtonPropertyBrowser); - return q->createEditor(property, parent); - } - - void slotEditorDestroyed(); - void slotUpdate(); - void slotToggled(bool checked); - - struct WidgetItem - { - QWidget* widget{ nullptr }; // can be null - QLabel* label{ nullptr }; // main label with property name - QLabel* widgetLabel{ nullptr }; // label substitute showing the current value if there is no widget - QToolButton* button{ nullptr }; // expandable button for items with children - QWidget* container{ nullptr }; // container which is expanded when the button is clicked - QGridLayout* layout{ nullptr }; // layout in container - WidgetItem* parent{ nullptr }; - QList children; - bool expanded{ false }; - }; - private: - void updateLater(); - void updateItem(WidgetItem* item); - void insertRow(QGridLayout* layout, int row) const; - void removeRow(QGridLayout* layout, int row) const; - int gridRow(WidgetItem* item) const; - int gridSpan(WidgetItem* item) const; - void setExpanded(WidgetItem* item, bool expanded); - QToolButton* createButton(QWidget* panret = 0) const; - - QMap m_indexToItem; - QMap m_itemToIndex; - QMap m_widgetToItem; - QMap m_buttonToItem; - QGridLayout* m_mainLayout; - QList m_children; - QList m_recreateQueue; - }; - } -} diff --git a/QtRpa/include/property/private/charpropertymanager_p.h b/QtRpa/include/property/private/charpropertymanager_p.h deleted file mode 100644 index b25dff7..0000000 --- a/QtRpa/include/property/private/charpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class CharPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(CharPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/colorpropertymanager_p.h b/QtRpa/include/property/private/colorpropertymanager_p.h deleted file mode 100644 index 6c213de..0000000 --- a/QtRpa/include/property/private/colorpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class ColorPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(ColorPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/cursordatabase_p.h b/QtRpa/include/property/private/cursordatabase_p.h deleted file mode 100644 index 55b0d40..0000000 --- a/QtRpa/include/property/private/cursordatabase_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class CursorDatabasePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(CursorDatabase) - public: - }; - } -} diff --git a/QtRpa/include/property/private/cursorpropertymanager_p.h b/QtRpa/include/property/private/cursorpropertymanager_p.h deleted file mode 100644 index c13e612..0000000 --- a/QtRpa/include/property/private/cursorpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class CursorPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(CursorPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/datepropertymanager_p.h b/QtRpa/include/property/private/datepropertymanager_p.h deleted file mode 100644 index a500545..0000000 --- a/QtRpa/include/property/private/datepropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class DatePropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(DatePropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/datetimepropertymanager_p.h b/QtRpa/include/property/private/datetimepropertymanager_p.h deleted file mode 100644 index 6f071da..0000000 --- a/QtRpa/include/property/private/datetimepropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class DateTimePropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(DateTimePropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/doublepropertymanager_p.h b/QtRpa/include/property/private/doublepropertymanager_p.h deleted file mode 100644 index ebd6b0e..0000000 --- a/QtRpa/include/property/private/doublepropertymanager_p.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class DoublePropertyManagerPrivate : public AbstractPropertyManagerPrivate { - Q_DECLARE_PUBLIC(DoublePropertyManager) - public: - public: - - struct Data - { - double val{ 0 }; - double minVal{ -DBL_MAX }; - double maxVal{ DBL_MAX }; - double singleStep{ 1 }; - int decimals{ 2 }; - double minimumValue() const { return minVal; } - double maximumValue() const { return maxVal; } - void setMinimumValue(double newMinVal) { setSimpleMinimumData(this, newMinVal); } - void setMaximumValue(double newMaxVal) { setSimpleMaximumData(this, newMaxVal); } - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - }; - } -} diff --git a/QtRpa/include/property/private/editorfactoryprivate_p.h b/QtRpa/include/property/private/editorfactoryprivate_p.h deleted file mode 100644 index b64bb83..0000000 --- a/QtRpa/include/property/private/editorfactoryprivate_p.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once - -namespace shelllet { - namespace property { - - - template - class EditorFactoryPrivate : public AbstractEditorFactoryPrivate - { - public: - - typedef QList EditorList; - typedef QMap PropertyToEditorListMap; - typedef QMap EditorToPropertyMap; - - Editor* createEditor(PropertySheet* property, QWidget* parent); - void initializeEditor(PropertySheet* property, Editor* e); - void slotEditorDestroyed(QObject* object); - - PropertyToEditorListMap m_createdEditors; - EditorToPropertyMap m_editorToProperty; - }; - - template - Editor* EditorFactoryPrivate::createEditor(PropertySheet* property, QWidget* parent) - { - Editor* editor = new Editor(parent); - initializeEditor(property, editor); - return editor; - } - - template - void EditorFactoryPrivate::initializeEditor(PropertySheet* property, Editor* editor) - { - typename PropertyToEditorListMap::iterator it = m_createdEditors.find(property); - if (it == m_createdEditors.end()) - it = m_createdEditors.insert(property, EditorList()); - it.value().append(editor); - m_editorToProperty.insert(editor, property); - } - - template - void EditorFactoryPrivate::slotEditorDestroyed(QObject* object) - { - const typename EditorToPropertyMap::iterator ecend = m_editorToProperty.end(); - for (typename EditorToPropertyMap::iterator itEditor = m_editorToProperty.begin(); itEditor != ecend; ++itEditor) { - if (itEditor.key() == object) { - Editor* editor = itEditor.key(); - PropertySheet* property = itEditor.value(); - const typename PropertyToEditorListMap::iterator pit = m_createdEditors.find(property); - if (pit != m_createdEditors.end()) { - pit.value().removeAll(editor); - if (pit.value().empty()) - m_createdEditors.erase(pit); - } - m_editorToProperty.erase(itEditor); - return; - } - } - } - - - } -} \ No newline at end of file diff --git a/QtRpa/include/property/private/enumpropertymanager_p.h b/QtRpa/include/property/private/enumpropertymanager_p.h deleted file mode 100644 index 3231a43..0000000 --- a/QtRpa/include/property/private/enumpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class EnumPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(EnumPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/flagpropertymanager_p.h b/QtRpa/include/property/private/flagpropertymanager_p.h deleted file mode 100644 index a5ed419..0000000 --- a/QtRpa/include/property/private/flagpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class FlagPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(FlagPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/fontpropertymanager_p.h b/QtRpa/include/property/private/fontpropertymanager_p.h deleted file mode 100644 index 8bd9e71..0000000 --- a/QtRpa/include/property/private/fontpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class FontPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(FontPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/groupboxpropertybrowser_p.h b/QtRpa/include/property/private/groupboxpropertybrowser_p.h deleted file mode 100644 index c2ff9aa..0000000 --- a/QtRpa/include/property/private/groupboxpropertybrowser_p.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class BrowserItem; - class GroupBoxPropertyBrowserPrivate : public AbstractPropertyBrowserPrivate { - Q_DECLARE_PUBLIC(GroupBoxPropertyBrowser) - public: - // QtGroupBoxPropertyBrowser* q_ptr; - //Q_DECLARE_PUBLIC(QtGroupBoxPropertyBrowser) - public: - - void init(QWidget* parent); - - void propertyInserted(BrowserItem* index, BrowserItem* afterIndex); - void propertyRemoved(BrowserItem* index); - void propertyChanged(BrowserItem* index); - QWidget* createEditor(PropertySheet* property, QWidget* parent) - { - Q_Q(GroupBoxPropertyBrowser); - return q->createEditor(property, parent); - } - - void slotEditorDestroyed(); - void slotUpdate(); - - struct WidgetItem - { - QWidget* widget{ nullptr }; // can be null - QLabel* label{ nullptr }; - QLabel* widgetLabel{ nullptr }; - QGroupBox* groupBox{ nullptr }; - QGridLayout* layout{ nullptr }; - QFrame* line{ nullptr }; - WidgetItem* parent{ nullptr }; - QList children; - }; - private: - void updateLater(); - void updateItem(WidgetItem* item); - void insertRow(QGridLayout* layout, int row) const; - void removeRow(QGridLayout* layout, int row) const; - - bool hasHeader(WidgetItem* item) const; - - QMap m_indexToItem; - QMap m_itemToIndex; - QMap m_widgetToItem; - QGridLayout* m_mainLayout; - QList m_children; - QList m_recreateQueue; - }; - } -} diff --git a/QtRpa/include/property/private/grouppropertymanager_p.h b/QtRpa/include/property/private/grouppropertymanager_p.h deleted file mode 100644 index 03d8a92..0000000 --- a/QtRpa/include/property/private/grouppropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class GroupPropertyManagerPrivate : public AbstractPropertyManagerPrivate { - Q_DECLARE_PUBLIC(GroupPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/intpropertymanager_p.h b/QtRpa/include/property/private/intpropertymanager_p.h deleted file mode 100644 index d7bbbf5..0000000 --- a/QtRpa/include/property/private/intpropertymanager_p.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class IntPropertyManagerPrivate : public AbstractPropertyManagerPrivate { - Q_DECLARE_PUBLIC(IntPropertyManager) - public: - - struct Data - { - int val{ 0 }; - int minVal{ -INT_MAX }; - int maxVal{ INT_MAX }; - int singleStep{ 1 }; - int minimumValue() const { return minVal; } - int maximumValue() const { return maxVal; } - void setMinimumValue(int newMinVal) { setSimpleMinimumData(this, newMinVal); } - void setMaximumValue(int newMaxVal) { setSimpleMaximumData(this, newMaxVal); } - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - }; - } -} diff --git a/QtRpa/include/property/private/keysequencepropertymanager_p.h b/QtRpa/include/property/private/keysequencepropertymanager_p.h deleted file mode 100644 index bccabb6..0000000 --- a/QtRpa/include/property/private/keysequencepropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class KeySequencePropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(KeySequencePropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/lineeditfactory_p.h b/QtRpa/include/property/private/lineeditfactory_p.h deleted file mode 100644 index 561be46..0000000 --- a/QtRpa/include/property/private/lineeditfactory_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class LineEditFactoryPrivate : public EditorFactoryPrivate { - Q_DECLARE_PUBLIC(LineEditFactory) - public: - - void slotPropertyChanged(PropertySheet* property, const String& value); - void slotRegExpChanged(PropertySheet* property, const QRegExp& regExp); - void slotSetValue(const QString& value); - }; - } -} diff --git a/QtRpa/include/property/private/localepropertymanager_p.h b/QtRpa/include/property/private/localepropertymanager_p.h deleted file mode 100644 index 06b6229..0000000 --- a/QtRpa/include/property/private/localepropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class LocalePropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(LocalePropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/pointpropertymanager_p.h b/QtRpa/include/property/private/pointpropertymanager_p.h deleted file mode 100644 index 76b4686..0000000 --- a/QtRpa/include/property/private/pointpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class PointPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PointPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/propertybrowser_p.h b/QtRpa/include/property/private/propertybrowser_p.h deleted file mode 100644 index 41308e1..0000000 --- a/QtRpa/include/property/private/propertybrowser_p.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - - class PropertyBrowserPrivate : public AbstractPropertyBrowserPrivate { - Q_DECLARE_PUBLIC(PropertyBrowser) - // PropertyBrowser* q_ptr; - - public: - PropertyBrowserPrivate(); - void init(QWidget* parent); - - void propertyInserted(BrowserItem* index, BrowserItem* afterIndex); - void propertyRemoved(BrowserItem* index); - void propertyChanged(BrowserItem* index); - QWidget* createEditor(PropertySheet* property, QWidget* parent) - { - Q_Q(PropertyBrowser); - return q->createEditor(property, parent); - } - PropertySheet* indexToProperty(const QModelIndex& index) const; - QTreeWidgetItem* indexToItem(const QModelIndex& index) const; - BrowserItem* indexToBrowserItem(const QModelIndex& index) const; - bool lastColumn(int column) const; - void disableItem(QTreeWidgetItem* item) const; - void enableItem(QTreeWidgetItem* item) const; - bool hasValue(QTreeWidgetItem* item) const; - - void slotCollapsed(const QModelIndex& index); - void slotExpanded(const QModelIndex& index); - - QColor calculatedBackgroundColor(BrowserItem* item) const; - - PropertyEditorView* treeWidget() const { return m_treeWidget; } - bool markPropertiesWithoutValue() const { return m_markPropertiesWithoutValue; } - - BrowserItem* currentItem() const; - void setCurrentItem(BrowserItem* browserItem, bool block); - void editItem(BrowserItem* browserItem); - - void slotCurrentBrowserItemChanged(BrowserItem* item); - void slotCurrentTreeItemChanged(QTreeWidgetItem* newItem, QTreeWidgetItem*); - - QTreeWidgetItem* editedItem() const; - - private: - void updateItem(QTreeWidgetItem* item); - - QMap m_indexToItem; - QMap m_itemToIndex; - - QMap m_indexToBackgroundColor; - - PropertyEditorView* m_treeWidget; - - bool m_headerVisible; - PropertyBrowser::ResizeMode m_resizeMode; - class PropertyEditorDelegate* m_delegate; - bool m_markPropertiesWithoutValue; - bool m_browserChangedBlocked; - QIcon m_expandIcon; - - - }; - } -} - diff --git a/QtRpa/include/property/private/propertyeditordelegate_p.h b/QtRpa/include/property/private/propertyeditordelegate_p.h deleted file mode 100644 index 7ca0b5b..0000000 --- a/QtRpa/include/property/private/propertyeditordelegate_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class PropertyEditorDelegatePrivate : public ObjectPrivate { - // Q_DECLARE_PUBLIC(PropertyEditorDelegate) - public: - }; - } -} diff --git a/QtRpa/include/property/private/propertyeditorview_p.h b/QtRpa/include/property/private/propertyeditorview_p.h deleted file mode 100644 index 63d1285..0000000 --- a/QtRpa/include/property/private/propertyeditorview_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class PropertyEditorViewPrivate : public ObjectPrivate { - // Q_DECLARE_PUBLIC(PropertyEditorView) - public: - }; - } -} diff --git a/QtRpa/include/property/private/propertysheet_p.h b/QtRpa/include/property/private/propertysheet_p.h deleted file mode 100644 index a3a8daa..0000000 --- a/QtRpa/include/property/private/propertysheet_p.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class AbstractPropertyManager; - class PropertySheetPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PropertySheet) - public: - PropertySheetPrivate(AbstractPropertyManager* manager) : m_enabled(true), m_modified(false), m_manager(manager) {} - PropertySheet* q_ptr; - - QSet m_parentItems; - QList m_subItems; - - QString m_valueToolTip; - QString m_descriptionToolTip; - QString m_statusTip; - QString m_whatsThis; - QString m_name; - bool m_enabled; - bool m_modified; - - AbstractPropertyManager* const m_manager; - }; - } -} diff --git a/QtRpa/include/property/private/rectpropertymanager_p.h b/QtRpa/include/property/private/rectpropertymanager_p.h deleted file mode 100644 index 8f4cf66..0000000 --- a/QtRpa/include/property/private/rectpropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class RectPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(RectPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/sizepolicypropertymanager_p.h b/QtRpa/include/property/private/sizepolicypropertymanager_p.h deleted file mode 100644 index 64dfcd2..0000000 --- a/QtRpa/include/property/private/sizepolicypropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class SizePolicyPropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(SizePolicyPropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/sizepropertymanager_p.h b/QtRpa/include/property/private/sizepropertymanager_p.h deleted file mode 100644 index e2d4b49..0000000 --- a/QtRpa/include/property/private/sizepropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class SizePropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(SizePropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/stringpropertymanager_p.h b/QtRpa/include/property/private/stringpropertymanager_p.h deleted file mode 100644 index 0441024..0000000 --- a/QtRpa/include/property/private/stringpropertymanager_p.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class StringPropertyManagerPrivate : public AbstractPropertyManagerPrivate { - Q_DECLARE_PUBLIC(StringPropertyManager) - public: - - struct Data - { - Data() : regExp(QString(QLatin1Char('*')), Qt::CaseSensitive, QRegExp::Wildcard) - { - } - String val; - QRegExp regExp; - }; - - typedef QMap PropertyValueMap; - QMap m_values; - }; - } -} diff --git a/QtRpa/include/property/private/timepropertymanager_p.h b/QtRpa/include/property/private/timepropertymanager_p.h deleted file mode 100644 index 4e2f658..0000000 --- a/QtRpa/include/property/private/timepropertymanager_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class TimePropertyManagerPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(TimePropertyManager) - public: - }; - } -} diff --git a/QtRpa/include/property/private/utils_p.h b/QtRpa/include/property/private/utils_p.h deleted file mode 100644 index 02ba89d..0000000 --- a/QtRpa/include/property/private/utils_p.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class UtilsPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(Utils) - public: - }; - } -} diff --git a/QtRpa/include/property/propertybrowser.h b/QtRpa/include/property/propertybrowser.h deleted file mode 100644 index c74be2e..0000000 --- a/QtRpa/include/property/propertybrowser.h +++ /dev/null @@ -1,89 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class BrowserItem; - class PropertyBrowserPrivate; - class PropertyBrowser : public AbstractPropertyBrowser{ - Q_DECLARE_PRIVATE(PropertyBrowser) - Q_OBJECT - Q_PROPERTY(int indentation READ indentation WRITE setIndentation) - Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated) - Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors) - Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible) - Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) - Q_PROPERTY(int splitterPosition READ splitterPosition WRITE setSplitterPosition) - Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked WRITE setPropertiesWithoutValueMarked) - public: - - PropertyBrowser(QWidget* parentWidget = 0,Object*parent = nullptr); - enum ResizeMode - { - Interactive, - Stretch, - Fixed, - ResizeToContents - }; - Q_ENUM(ResizeMode) - ~PropertyBrowser(); - - int indentation() const; - void setIndentation(int i); - - bool rootIsDecorated() const; - void setRootIsDecorated(bool show); - - bool alternatingRowColors() const; - void setAlternatingRowColors(bool enable); - - bool isHeaderVisible() const; - void setHeaderVisible(bool visible); - - ResizeMode resizeMode() const; - void setResizeMode(ResizeMode mode); - - int splitterPosition() const; - void setSplitterPosition(int position); - - void setExpanded(BrowserItem* item, bool expanded); - bool isExpanded(BrowserItem* item) const; - - bool isItemVisible(BrowserItem* item) const; - void setItemVisible(BrowserItem* item, bool visible); - - void setBackgroundColor(BrowserItem* item, const QColor& color); - QColor backgroundColor(BrowserItem* item) const; - QColor calculatedBackgroundColor(BrowserItem* item) const; - - void setPropertiesWithoutValueMarked(bool mark); - bool propertiesWithoutValueMarked() const; - - void editItem(BrowserItem* item); - - - signals: - - void collapsed(BrowserItem* item); - void expanded(BrowserItem* item); - - protected: - virtual void itemInserted(BrowserItem* item, BrowserItem* afterItem); - virtual void itemRemoved(BrowserItem* item); - virtual void itemChanged(BrowserItem* item); - - private: - - // QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(PropertyBrowser) - // Q_DISABLE_COPY_MOVE(PropertyBrowser) - - //Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex&)) - //Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex&)) - //Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(BrowserItem*)) - //Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)) - protected: - PropertyBrowser(PropertyBrowserPrivate& d, QWidget* parentWidget = 0, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/propertyeditordelegate.h b/QtRpa/include/property/propertyeditordelegate.h deleted file mode 100644 index 80f64d2..0000000 --- a/QtRpa/include/property/propertyeditordelegate.h +++ /dev/null @@ -1,62 +0,0 @@ -#pragma once - -namespace shelllet { - namespace property{ - class PropertyEditorDelegatePrivate; - class PropertyEditorDelegate : public QItemDelegate { - Q_DECLARE_PRIVATE(PropertyEditorDelegate) - W_OBJECT(PropertyEditorDelegate) - public: - PropertyEditorDelegate(Object*parent = nullptr); - - //Q_OBJECT - - public: - PropertyEditorDelegate(QObject* parent = 0); - - void setEditorPrivate(PropertyBrowserPrivate* editorPrivate) - { - m_editorPrivate = editorPrivate; - } - - QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - - void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - - void paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const; - - QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; - - void setModelData(QWidget*, QAbstractItemModel*, - const QModelIndex&) const {} - - void setEditorData(QWidget*, const QModelIndex&) const {} - - bool eventFilter(QObject* object, QEvent* event); - void closeEditor(PropertySheet* property); - - QTreeWidgetItem* editedItem() const { return m_editedItem; } - - private slots: - void slotEditorDestroyed(QObject* object); - - private: - int indentation(const QModelIndex& index) const; - - typedef QMap EditorToPropertyMap; - mutable EditorToPropertyMap m_editorToProperty; - - typedef QMap PropertyToEditorMap; - mutable PropertyToEditorMap m_propertyToEditor; - PropertyBrowserPrivate* m_editorPrivate; - mutable QTreeWidgetItem* m_editedItem; - mutable QWidget* m_editedWidget; - protected: - PropertyEditorDelegate(PropertyEditorDelegatePrivate& d, QObject* parent1 = 0, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/propertyeditorview.h b/QtRpa/include/property/propertyeditorview.h deleted file mode 100644 index fcc3eee..0000000 --- a/QtRpa/include/property/propertyeditorview.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class PropertyBrowserPrivate; - class PropertyEditorViewPrivate; - class PropertyEditorView : public QTreeWidget { - Q_DECLARE_PRIVATE(PropertyEditorView) - W_OBJECT(PropertyEditorView) - public: - PropertyEditorView(Object*parent = nullptr); - - //Q_OBJECT - public: - PropertyEditorView(QWidget* parent = 0); - - void setEditorPrivate(PropertyBrowserPrivate* editorPrivate) - { - m_editorPrivate = editorPrivate; - } - - QTreeWidgetItem* indexToItem(const QModelIndex& index) const - { - return itemFromIndex(index); - } - - protected: - void keyPressEvent(QKeyEvent* event); - void mousePressEvent(QMouseEvent* event); - void drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; - - private: - PropertyBrowserPrivate* m_editorPrivate; - protected: - PropertyEditorView(PropertyEditorViewPrivate& d, QWidget* parent1 = 0, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/propertysheet.h b/QtRpa/include/property/propertysheet.h deleted file mode 100644 index f6a8084..0000000 --- a/QtRpa/include/property/propertysheet.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -namespace shelllet { - namespace property { - class AbstractPropertyManager; - class PropertySheetPrivate; - class PropertySheet : public Object { - Q_DECLARE_PRIVATE(PropertySheet) - public: - // PropertySheet(Object*parent = nullptr); - - virtual ~PropertySheet(); - - QList subProperties() const; - - AbstractPropertyManager* propertyManager() const; - - QString toolTip() const { return valueToolTip(); } // Compatibility - QString valueToolTip() const; - QString descriptionToolTip() const; - QString statusTip() const; - QString whatsThis() const; - QString propertyName() const; - bool isEnabled() const; - bool isModified() const; - - bool hasValue() const; - QIcon valueIcon() const; - String valueText() const; - - void setToolTip(const QString& text) { setValueToolTip(text); } // Compatibility - void setValueToolTip(const QString& text); - void setDescriptionToolTip(const QString& text); - void setStatusTip(const QString& text); - void setWhatsThis(const QString& text); - void setPropertyName(const QString& text); - void setEnabled(bool enable); - void setModified(bool modified); - - void addSubProperty(PropertySheet* property); - void insertSubProperty(PropertySheet* property, PropertySheet* afterProperty); - void removeSubProperty(PropertySheet* property); - protected: - explicit PropertySheet(AbstractPropertyManager* manager); - void propertyChanged(); - private: - friend class AbstractPropertyManager; - // QScopedPointer d_ptr; - protected: - PropertySheet(PropertySheetPrivate& d, Object* parent = nullptr); - }; - } -} - -W_REGISTER_ARGTYPE(shelllet::property::PropertySheet*) - - diff --git a/QtRpa/include/property/qteditorfactory.h1 b/QtRpa/include/property/qteditorfactory.h1 deleted file mode 100644 index 927aca3..0000000 --- a/QtRpa/include/property/qteditorfactory.h1 +++ /dev/null @@ -1,378 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTEDITORFACTORY_H -#define QTEDITORFACTORY_H - -#include "qtpropertymanager.h" - -QT_BEGIN_NAMESPACE - -class QtSpinBoxFactoryPrivate; - -class QtSpinBoxFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtSpinBoxFactory(QObject *parent = 0); - ~QtSpinBoxFactory(); -protected: - void connectPropertyManager(QtIntPropertyManager *manager); - QWidget *createEditor(QtIntPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtIntPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtSpinBoxFactory) - Q_DISABLE_COPY_MOVE(QtSpinBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(PropertySheet *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtSliderFactoryPrivate; - -class QtSliderFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtSliderFactory(QObject *parent = 0); - ~QtSliderFactory(); -protected: - void connectPropertyManager(QtIntPropertyManager *manager); - QWidget *createEditor(QtIntPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtIntPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtSliderFactory) - Q_DISABLE_COPY_MOVE(QtSliderFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(PropertySheet *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtScrollBarFactoryPrivate; - -class QtScrollBarFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtScrollBarFactory(QObject *parent = 0); - ~QtScrollBarFactory(); -protected: - void connectPropertyManager(QtIntPropertyManager *manager); - QWidget *createEditor(QtIntPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtIntPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtScrollBarFactory) - Q_DISABLE_COPY_MOVE(QtScrollBarFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(PropertySheet *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtCheckBoxFactoryPrivate; - -class QtCheckBoxFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtCheckBoxFactory(QObject *parent = 0); - ~QtCheckBoxFactory(); -protected: - void connectPropertyManager(QtBoolPropertyManager *manager); - QWidget *createEditor(QtBoolPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtBoolPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtCheckBoxFactory) - Q_DISABLE_COPY_MOVE(QtCheckBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(bool)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtDoubleSpinBoxFactoryPrivate; - -class QtDoubleSpinBoxFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtDoubleSpinBoxFactory(QObject *parent = 0); - ~QtDoubleSpinBoxFactory(); -protected: - void connectPropertyManager(QtDoublePropertyManager *manager); - QWidget *createEditor(QtDoublePropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtDoublePropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtDoubleSpinBoxFactory) - Q_DISABLE_COPY_MOVE(QtDoubleSpinBoxFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, double)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(PropertySheet *, double, double)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(PropertySheet *, double)) - Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(double)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtLineEditFactoryPrivate; - -class QtLineEditFactory : public AbstractEditorFactory -{ -}; - -class QtDateEditFactoryPrivate; - -class QtDateEditFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtDateEditFactory(QObject *parent = 0); - ~QtDateEditFactory(); -protected: - void connectPropertyManager(QtDatePropertyManager *manager); - QWidget *createEditor(QtDatePropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtDatePropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtDateEditFactory) - Q_DISABLE_COPY_MOVE(QtDateEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(PropertySheet *, - const QDate &, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtTimeEditFactoryPrivate; - -class QtTimeEditFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtTimeEditFactory(QObject *parent = 0); - ~QtTimeEditFactory(); -protected: - void connectPropertyManager(QtTimePropertyManager *manager); - QWidget *createEditor(QtTimePropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtTimePropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtTimeEditFactory) - Q_DISABLE_COPY_MOVE(QtTimeEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QTime &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QTime &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtDateTimeEditFactoryPrivate; - -class QtDateTimeEditFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtDateTimeEditFactory(QObject *parent = 0); - ~QtDateTimeEditFactory(); -protected: - void connectPropertyManager(QtDateTimePropertyManager *manager); - QWidget *createEditor(QtDateTimePropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtDateTimePropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtDateTimeEditFactory) - Q_DISABLE_COPY_MOVE(QtDateTimeEditFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtKeySequenceEditorFactoryPrivate; - -class QtKeySequenceEditorFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtKeySequenceEditorFactory(QObject *parent = 0); - ~QtKeySequenceEditorFactory(); -protected: - void connectPropertyManager(QtKeySequencePropertyManager *manager); - QWidget *createEditor(QtKeySequencePropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtKeySequencePropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtKeySequenceEditorFactory) - Q_DISABLE_COPY_MOVE(QtKeySequenceEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtCharEditorFactoryPrivate; - -class QtCharEditorFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtCharEditorFactory(QObject *parent = 0); - ~QtCharEditorFactory(); -protected: - void connectPropertyManager(QtCharPropertyManager *manager); - QWidget *createEditor(QtCharPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtCharPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtCharEditorFactory) - Q_DISABLE_COPY_MOVE(QtCharEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtEnumEditorFactoryPrivate; - -class QtEnumEditorFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtEnumEditorFactory(QObject *parent = 0); - ~QtEnumEditorFactory(); -protected: - void connectPropertyManager(QtEnumPropertyManager *manager); - QWidget *createEditor(QtEnumPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtEnumPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtEnumEditorFactory) - Q_DISABLE_COPY_MOVE(QtEnumEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(PropertySheet *, - const QStringList &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(PropertySheet *, - const QMap &)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtCursorEditorFactoryPrivate; - -class QtCursorEditorFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtCursorEditorFactory(QObject *parent = 0); - ~QtCursorEditorFactory(); -protected: - void connectPropertyManager(QtCursorPropertyManager *manager); - QWidget *createEditor(QtCursorPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtCursorPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtCursorEditorFactory) - Q_DISABLE_COPY_MOVE(QtCursorEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QCursor &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(PropertySheet *, int)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) -}; - -class QtColorEditorFactoryPrivate; - -class QtColorEditorFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtColorEditorFactory(QObject *parent = 0); - ~QtColorEditorFactory(); -protected: - void connectPropertyManager(QtColorPropertyManager *manager); - QWidget *createEditor(QtColorPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtColorPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtColorEditorFactory) - Q_DISABLE_COPY_MOVE(QtColorEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QColor &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QColor &)) -}; - -class QtFontEditorFactoryPrivate; - -class QtFontEditorFactory : public AbstractEditorFactory -{ - Q_OBJECT -public: - QtFontEditorFactory(QObject *parent = 0); - ~QtFontEditorFactory(); -protected: - void connectPropertyManager(QtFontPropertyManager *manager); - QWidget *createEditor(QtFontPropertyManager *manager, PropertySheet *property, - QWidget *parent); - void disconnectPropertyManager(QtFontPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtFontEditorFactory) - Q_DISABLE_COPY_MOVE(QtFontEditorFactory) - Q_PRIVATE_SLOT(d_func(), void slotPropertyChanged(PropertySheet *, const QFont &)) - Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed(QObject *)) - Q_PRIVATE_SLOT(d_func(), void slotSetValue(const QFont &)) -}; - -QT_END_NAMESPACE - -#endif diff --git a/QtRpa/include/property/qtpropertybrowser.h b/QtRpa/include/property/qtpropertybrowser.h deleted file mode 100644 index bbd4b10..0000000 --- a/QtRpa/include/property/qtpropertybrowser.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTPROPERTYBROWSER_H -#define QTPROPERTYBROWSER_H - -#include -#include - -QT_BEGIN_NAMESPACE - -class QtAbstractPropertyManager; -namespace shelllet { - namespace property { - class PropertySheet; - } -} -using namespace shelllet::property; - -class QtAbstractPropertyManagerPrivate -{ - -}; - -class QtAbstractPropertyManagerPrivate; - - - - -QT_END_NAMESPACE - -#endif // QTPROPERTYBROWSER_H diff --git a/QtRpa/include/property/qtvariantproperty.h1 b/QtRpa/include/property/qtvariantproperty.h1 deleted file mode 100644 index ff5af83..0000000 --- a/QtRpa/include/property/qtvariantproperty.h1 +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QTVARIANTPROPERTY_H -#define QTVARIANTPROPERTY_H - -#include "qtpropertybrowser.h" -#include -#include - -QT_BEGIN_NAMESPACE - -typedef QMap QtIconMap; - -class QtVariantPropertyManager; - -class QtVariantProperty : public QtProperty -{ -public: - ~QtVariantProperty(); - QVariant value() const; - QVariant attributeValue(const QString &attribute) const; - int valueType() const; - int propertyType() const; - - void setValue(const QVariant &value); - void setAttribute(const QString &attribute, const QVariant &value); -protected: - QtVariantProperty(QtVariantPropertyManager *manager); -private: - friend class QtVariantPropertyManager; - QScopedPointer d_ptr; -}; - -class QtVariantPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT -public: - QtVariantPropertyManager(QObject *parent = 0); - ~QtVariantPropertyManager(); - - virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString()); - - int propertyType(const QtProperty *property) const; - int valueType(const QtProperty *property) const; - QtVariantProperty *variantProperty(const QtProperty *property) const; - - virtual bool isPropertyTypeSupported(int propertyType) const; - virtual int valueType(int propertyType) const; - virtual QStringList attributes(int propertyType) const; - virtual int attributeType(int propertyType, const QString &attribute) const; - - virtual QVariant value(const QtProperty *property) const; - virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const; - - static int enumTypeId(); - static int flagTypeId(); - static int groupTypeId(); - static int iconMapTypeId(); -public Q_SLOTS: - virtual void setValue(QtProperty *property, const QVariant &val); - virtual void setAttribute(QtProperty *property, - const QString &attribute, const QVariant &value); -Q_SIGNALS: - void valueChanged(QtProperty *property, const QVariant &val); - void attributeChanged(QtProperty *property, - const QString &attribute, const QVariant &val); -protected: - virtual bool hasValue(const QtProperty *property) const; - QString valueText(const QtProperty *property) const; - QIcon valueIcon(const QtProperty *property) const; - virtual void initializeProperty(QtProperty *property); - virtual void uninitializeProperty(QtProperty *property); - virtual QtProperty *createProperty(); -private: - QScopedPointer d_ptr; - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, int, int)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, double, double)) - Q_PRIVATE_SLOT(d_func(), void slotSingleStepChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotDecimalsChanged(QtProperty *, int)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, bool)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QString &)) - Q_PRIVATE_SLOT(d_func(), void slotRegExpChanged(QtProperty *, const QRegExp &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QDate &, const QDate &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QTime &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QDateTime &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QKeySequence &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QChar &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QLocale &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPoint &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QPointF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSize &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSize &, const QSize &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizeF &)) - Q_PRIVATE_SLOT(d_func(), void slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRect &)) - Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRect &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void slotConstraintChanged(QtProperty *, const QRectF &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QColor &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumNamesChanged(QtProperty *, const QStringList &)) - Q_PRIVATE_SLOT(d_func(), void slotEnumIconsChanged(QtProperty *, const QMap &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QSizePolicy &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QFont &)) - Q_PRIVATE_SLOT(d_func(), void slotValueChanged(QtProperty *, const QCursor &)) - Q_PRIVATE_SLOT(d_func(), void slotFlagNamesChanged(QtProperty *, const QStringList &)) - - Q_PRIVATE_SLOT(d_func(), void slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyRemoved(QtProperty *, QtProperty *)) - Q_DECLARE_PRIVATE(QtVariantPropertyManager) - Q_DISABLE_COPY_MOVE(QtVariantPropertyManager) -}; - -class QtVariantEditorFactory : public QtAbstractEditorFactory -{ - Q_OBJECT -public: - QtVariantEditorFactory(QObject *parent = 0); - ~QtVariantEditorFactory(); -protected: - void connectPropertyManager(QtVariantPropertyManager *manager); - QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property, - QWidget *parent); - void disconnectPropertyManager(QtVariantPropertyManager *manager); -private: - QScopedPointer d_ptr; - Q_DECLARE_PRIVATE(QtVariantEditorFactory) - Q_DISABLE_COPY_MOVE(QtVariantEditorFactory) -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QIcon) -Q_DECLARE_METATYPE(QtIconMap) -#endif diff --git a/QtRpa/include/property/rectpropertymanager.h1 b/QtRpa/include/property/rectpropertymanager.h1 deleted file mode 100644 index 0b80268..0000000 --- a/QtRpa/include/property/rectpropertymanager.h1 +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class RectPropertyManagerPrivate; - class RectPropertyManager : public AbstractPropertyManager , private boost::noncopyable{ - Q_DECLARE_PRIVATE(RectPropertyManager) - public: - RectPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - RectPropertyManager(QObject* parent = 0); - ~RectPropertyManager(); - - QtDoublePropertyManager* subIntPropertyManager() const; - - QRectF value(const PropertySheet* property) const; - QRectF constraint(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QRectF& val); - void setConstraint(PropertySheet* property, const QRectF& constraint); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QRectF& val); - void constraintChanged(PropertySheet* property, const QRectF& constraint); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - // QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtRectPropertyManager) - // Q_DISABLE_COPY_MOVE(QtRectPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - protected: - RectPropertyManager(RectPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/sizepolicypropertymanager.h1 b/QtRpa/include/property/sizepolicypropertymanager.h1 deleted file mode 100644 index ef78d82..0000000 --- a/QtRpa/include/property/sizepolicypropertymanager.h1 +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class SizePolicyPropertyManagerPrivate; - class SizePolicyPropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(SizePolicyPropertyManager) - public: - SizePolicyPropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - QtSizePolicyPropertyManager(QObject* parent = 0); - ~QtSizePolicyPropertyManager(); - - QtIntPropertyManager* subIntPropertyManager() const; - QtEnumPropertyManager* subEnumPropertyManager() const; - - QSizePolicy value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QSizePolicy& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QSizePolicy& val); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtSizePolicyPropertyManager) - // Q_DISABLE_COPY_MOVE(QtSizePolicyPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotIntChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotEnumChanged(PropertySheet*, int)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - protected: - SizePolicyPropertyManager(SizePolicyPropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/sizepropertymanager.h1 b/QtRpa/include/property/sizepropertymanager.h1 deleted file mode 100644 index a148055..0000000 --- a/QtRpa/include/property/sizepropertymanager.h1 +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class SizePropertyManagerPrivate; - class SizePropertyManager : public AbstractPropertyManager, boost::noncopyable { - Q_DECLARE_PRIVATE(SizePropertyManager) - public: - SizePropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - SizePropertyManager(QObject* parent = 0); - ~SizePropertyManager(); - - QtDoublePropertyManager* subDoublePropertyManager() const; - - QSizeF value(const PropertySheet* property) const; - QSizeF minimum(const PropertySheet* property) const; - QSizeF maximum(const PropertySheet* property) const; - int decimals(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QSizeF& val); - void setMinimum(PropertySheet* property, const QSizeF& minVal); - void setMaximum(PropertySheet* property, const QSizeF& maxVal); - void setRange(PropertySheet* property, const QSizeF& minVal, const QSizeF& maxVal); - void setDecimals(PropertySheet* property, int prec); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QSizeF& val); - void rangeChanged(PropertySheet* property, const QSizeF& minVal, const QSizeF& maxVal); - void decimalsChanged(PropertySheet* property, int prec); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtSizeFPropertyManager) - // Q_DISABLE_COPY_MOVE(QtSizeFPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(PropertySheet*, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(PropertySheet*)) - protected: - SizePropertyManager(SizePropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/stringpropertymanager.h b/QtRpa/include/property/stringpropertymanager.h deleted file mode 100644 index 32151b0..0000000 --- a/QtRpa/include/property/stringpropertymanager.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -namespace shelllet { - namespace property{ - class StringPropertyManagerPrivate; - class StringPropertyManager : public AbstractPropertyManager { - Q_OBJECT - Q_DECLARE_PRIVATE(StringPropertyManager) - public: - //StringPropertyManager(Object*parent = nullptr); - //Q_OBJECT - public: - StringPropertyManager(QObject* parent = 0); - ~StringPropertyManager(); - - String value(const PropertySheet* property) const; - QRegExp regExp(const PropertySheet* property) const; - - public slots: - void setValue(PropertySheet* property, const String& val); - - void setRegExp(PropertySheet* property, const QRegExp& regExp); - signals: - void valueChanged(PropertySheet* property, const String& val); - void regExpChanged(PropertySheet* property, const QRegExp& regExp); - protected: - String valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - // QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtStringPropertyManager) - // Q_DISABLE_COPY_MOVE(QtStringPropertyManager) - protected: - StringPropertyManager(StringPropertyManagerPrivate& d, QObject* parent, Object*); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/timepropertymanager.h1 b/QtRpa/include/property/timepropertymanager.h1 deleted file mode 100644 index 31b4148..0000000 --- a/QtRpa/include/property/timepropertymanager.h1 +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class TimePropertyManagerPrivate; - class TimePropertyManager : public AbstractPropertyManager, private boost::noncopyable { - Q_DECLARE_PRIVATE(TimePropertyManager) - public: - TimePropertyManager(Object*parent = nullptr); - Q_OBJECT - public: - TimePropertyManager(QObject* parent = 0); - ~TimePropertyManager(); - - QTime value(const PropertySheet* property) const; - - public Q_SLOTS: - void setValue(PropertySheet* property, const QTime& val); - Q_SIGNALS: - void valueChanged(PropertySheet* property, const QTime& val); - protected: - QString valueText(const PropertySheet* property) const; - virtual void initializeProperty(PropertySheet* property); - virtual void uninitializeProperty(PropertySheet* property); - private: - //QScopedPointer d_ptr; - //Q_DECLARE_PRIVATE(QtTimePropertyManager) - // Q_DISABLE_COPY_MOVE(QtTimePropertyManager) - protected: - TimePropertyManager(TimePropertyManagerPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/property/utils.h b/QtRpa/include/property/utils.h deleted file mode 100644 index fba7d24..0000000 --- a/QtRpa/include/property/utils.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace property{ - class UtilsPrivate; - class Utils : public Object { - Q_DECLARE_PRIVATE(Utils) - public: - Utils(Object*parent = nullptr); - - static QPixmap brushValuePixmap(const QBrush& b); - static QIcon brushValueIcon(const QBrush& b); - static QString colorValueText(const QColor& c); - static QPixmap fontValuePixmap(const QFont& f); - static QIcon fontValueIcon(const QFont& f); - static QString fontValueText(const QFont& f); - static QString dateFormat(); - static QString timeFormat(); - static QString dateTimeFormat(); - protected: - Utils(UtilsPrivate& d, Object*parent = nullptr); - }; - } -} - \ No newline at end of file diff --git a/QtRpa/include/resource.h b/QtRpa/include/resource.h deleted file mode 100644 index ef1c494..0000000 --- a/QtRpa/include/resource.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - class Resource { - public: - virtual ~Resource() {}; - virtual void cleanup() = 0; - class Deleter { - public: - void operator()(Resource* res) { - res->cleanup(); - delete res; - LOG_DEBUG("resource") << "# free." << std::endl; - } - }; - }; -} \ No newline at end of file diff --git a/QtRpa/include/scintilla2/page.h b/QtRpa/include/scintilla2/page.h deleted file mode 100644 index a2f2dbc..0000000 --- a/QtRpa/include/scintilla2/page.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "common.hpp" - -#include "scintilla/scintilla_component.h" - -namespace shelllet { - namespace scintilla { - - - class ScintillaPage : public scintilla_component - { - public: - ScintillaPage( QWidget* parent = nullptr); - ScintillaPage(const String& text, QWidget* parent = nullptr); - ~ScintillaPage(); - - - - private: - protected: - }; -} -} diff --git a/QtRpa/include/scintilla2/scintilla_api_wrapper.h b/QtRpa/include/scintilla2/scintilla_api_wrapper.h deleted file mode 100644 index 690cbaa..0000000 --- a/QtRpa/include/scintilla2/scintilla_api_wrapper.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "common.hpp" -namespace shelllet { - namespace scintilla { - class ScintillaApiWrapper - { - public: - void setText(const String& text); - String text() const; - void setSavePoint(); - void setStyleJavaScript(); - void setUtf8Encode(); - void disablePopup(); - virtual intptr_t sendMessage(unsigned int message, uintptr_t wParam = 0, intptr_t lParam = 0) const = 0; - int get_current_pos() const; - int get_word_start_pos(int pos) const; - int get_word_end_pos(int pos) const; - bool isModified() const; - void showAuto(const char* items, int lengthEntered); - String getAutoCurrentText(); - String get_text_range(int cpMin, int cpMax) const; - void formatText(); - }; - } -} diff --git a/QtRpa/include/scintilla2/scintilla_component.h b/QtRpa/include/scintilla2/scintilla_component.h deleted file mode 100644 index e4c1f54..0000000 --- a/QtRpa/include/scintilla2/scintilla_component.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include -#include -#include "scintilla_api_wrapper.h" -#include "scintilla_module_manager.h" - -namespace shelllet { - namespace scintilla { - class scintilla_component : public QWidget, public ScintillaModuleManager - - { - public: - scintilla_component(QWidget* parent); - ~scintilla_component(); - public: - private: - - public: - - private: - //QWidget* widget_; - protected: - bool nativeEvent(const QByteArray& eventType, void* message, long* result) override; - }; - } -} diff --git a/QtRpa/include/scintilla2/scintilla_module_manager.h b/QtRpa/include/scintilla2/scintilla_module_manager.h deleted file mode 100644 index 9d2dfd7..0000000 --- a/QtRpa/include/scintilla2/scintilla_module_manager.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include - -#include -#include "scintilla_api_wrapper.h" -namespace shelllet { - namespace scintilla { -#define FORMAT_CODE_ACTION_TEXT "#FORMATCODE" -#define CHAR_ADDED_ACTION_TEXT "#CHARADDED" - - class ScintillaModuleManager : public ScintillaApiWrapper - { - public: - ScintillaModuleManager(); - virtual ~ScintillaModuleManager(); - public: - void hookWndProc(HWND hwnd); - intptr_t sendMessage(unsigned int message, uintptr_t wParam = 0, intptr_t lParam = 0) const; - - QWindow* createEditor(QWidget* parent); - - - void destroyWndResource(); - // std::vector>::iterator find(uint32_t sci); - public: - private: - QLibrary libray; - intptr_t sci_ = 0; - }; - } -} diff --git a/QtRpa/include/scintilla3.hpp b/QtRpa/include/scintilla3.hpp deleted file mode 100644 index 54d2b31..0000000 --- a/QtRpa/include/scintilla3.hpp +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#include "scintilla/page.h" - -using namespace shelllet::scintilla; \ No newline at end of file diff --git a/QtRpa/include/v8.hpp b/QtRpa/include/v8.hpp deleted file mode 100644 index 1f5adc9..0000000 --- a/QtRpa/include/v8.hpp +++ /dev/null @@ -1,455 +0,0 @@ -#pragma once -#include "include/v8.h" -namespace shelllet { - enum class IsolateData : uint32_t { - GlobalContext, - GlobalValue, - SetErrorAddress, - }; - enum class ContextEmbedderData : uint32_t { - WorkingDirectory, - IsZip, - ZipSource - }; -#define V8_GL_CONTEXT(isolate) static_cast*>(isolate->GetData(static_cast(IsolateData::GlobalContext))) -#define V8_GL_VALUE(isolate) static_cast>*>(isolate->GetData(static_cast(IsolateData::GlobalValue))) -#define F_SET_LAST_ERROR(isolate, err) static_cast&)>(isolate->GetData(static_cast(IsolateData::SetErrorAddress)))(err) - -#define V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(Args) v8::Isolate* isolate = Args.GetIsolate(); \ - v8::HandleScope handleScope(isolate); \ - v8::Local context = v8::Local::New(isolate, V8_GL_CONTEXT(isolate)->Get(isolate)); \ - v8::Context::Scope contextScope(context); \ - try - -#define V8_CREATE_LOCAL_CONTEXT_END \ - catch (const std::exception& err) { \ - isolate->ThrowException(v8::String::NewFromUtf8(isolate, err.what()).ToLocalChecked()); \ - } - -#define V8_CREATE_LOCAL_CONTEXT_END_WITH_RETURN(ret) \ - catch (const std::exception& err) { \ - isolate->ThrowException(v8::String::NewFromUtf8(isolate, err.what()).ToLocalChecked()); \ - } \ - return ret; - -#define V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) \ - v8::Locker locker(isolate); \ - v8::Isolate::Scope isolateScope(isolate); \ - v8::HandleScope handleScope(isolate); \ - v8::Local context = v8::Local::New(isolate, V8_GL_CONTEXT(isolate)->Get(isolate)); \ - v8::Context::Scope contextScope(context); \ - try - -#define V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) \ - v8::HandleScope handleScope(isolate); \ - v8::Local context = v8::Local::New(isolate, V8_GL_CONTEXT(isolate)->Get(isolate)); \ - v8::Context::Scope contextScope(context); \ - try - -#define V8_NEW_STRING_VAR(isolate, v) v8::String::NewFromUtf8(isolate, v).ToLocalChecked() -#define V8_NEW_WSTRING_VAR(isolate, v) v8::String::NewFromTwoByte(isolate, reinterpret_cast(v)).ToLocalChecked() -} -namespace shelllet { - template - using CopyablePersistent = v8::Persistent>; - - static inline std::string ToString(const v8::String::Utf8Value& value) { - return *value ? *value : ""; - } - static inline std::wstring ToWString(const v8::String::Value& value) { - return *value ? reinterpret_cast(*value) : L""; - } - static inline std::string GetConstructorName(v8::Isolate* isolate, const v8::Local& value) { - if (value->IsObject()) - return ToString({ isolate ,value->ToObject(isolate->GetCurrentContext()).ToLocalChecked()->GetConstructorName() }); - return std::string(); - } - static inline std::string GetException(v8::Isolate* isolate, const v8::TryCatch& tryCatch) - { - v8::HandleScope handleScope(isolate); - v8::String::Utf8Value exception(isolate, tryCatch.Exception()); - auto exceptionString = ToString(exception); - v8::Local message = tryCatch.Message(); - std::ostringstream stream; - if (message.IsEmpty()) { - // V8 didn't provide any extra information about this error; just print the exception. - stream << exceptionString; - } - else { - // Print (filename):(line number): (message). - v8::Local context(isolate->GetCurrentContext()); - auto filenameString = ToString({ isolate, message->GetScriptResourceName() }); - int linenum = message->GetLineNumber(context).FromJust(); - - stream << filenameString << ":" << linenum << ": " << exceptionString; - // Print line of source code. - v8::String::Utf8Value sourceline(isolate, message->GetSourceLine(context).ToLocalChecked()); - auto sourcelineString = ToString(sourceline); - stream << sourcelineString; - // Print wavy underline (GetUnderline is deprecated). - int start = message->GetStartColumn(context).FromJust(); - for (int i = 0; i < start; i++) { - stream << " "; - } - int end = message->GetEndColumn(context).FromJust(); - for (int i = start; i < end; i++) { - stream << "^"; - } - stream << "\n"; - v8::Local stackTrace; - if (tryCatch.StackTrace(context).ToLocal(&stackTrace) && !stackTrace.IsEmpty() && stackTrace->IsString() && v8::Local::Cast(stackTrace)->Length() > 0) { - v8::String::Utf8Value stackTrace(isolate, stackTrace); - stream << ToString(stackTrace); - } - } - - return stream.str(); - } - - template - static void ToArray(v8::Isolate* isolate, const v8::Local& value, std::vector& buffer) { - if constexpr (std::is_same, std::uint32_t>::value) - { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - else if constexpr (std::is_same, std::uint16_t>::value) - { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - else if (std::is_same, std::uint8_t>::value) - { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - else if (std::is_same, std::int8_t>::value) { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - - template - static void ToArray(v8::Isolate* isolate, const v8::Local& value, std::vector& buffer) { - buffer.resize(value->Length()); - if constexpr (std::is_same::value - || std::is_same, std::uint8_t>::value - || std::is_same, std::uint16_t>::value) - { - for (std::uint32_t i = 0; i < value->Length(); ++i) { - buffer[i] = value->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->Uint32Value(isolate->GetCurrentContext()).FromJust(); - } - } - if constexpr (std::is_same, std::byte>::value) { - for (std::uint32_t i = 0; i < value->Length(); ++i) { - buffer[i] = static_cast(value->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->Uint32Value(isolate->GetCurrentContext()).FromJust()); - } - } - // else { - //for (std::uint32_t i = 0; i < value->Length(); ++i) { - //buffer[i] = value->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->Int32Value(isolate->GetCurrentContext()).FromJust(); - //} - //} - } - template - static auto ToArray(v8::Isolate* isolate, const v8::Local& value) { - std::vector buffer; - if (value->IsArray()) { - ToArray(isolate, v8::Local::Cast(value), buffer); - } - else if (value->IsTypedArray()) { - ToArray(isolate, v8::Local::Cast(value), buffer); - } - - return buffer; - } - - static inline v8::Local NewArray(v8::Isolate* isolate, const std::vector& value) - { - v8::Local array = v8::ArrayBuffer::New(isolate, value.size()); - std::memcpy(array->GetContents().Data(), &value[0], array->ByteLength()); - - return v8::Uint8Array::New(array, 0, array->ByteLength()); - } - template - static inline v8::Local NewArray(v8::Isolate* isolate, const std::vector& v) - { - v8::Local array = v8::Array::New(isolate, v.size()); - for (int i = 0; i < v.size(); ++i) { - if constexpr (std::is_same::value) { - array->Set(isolate->GetCurrentContext(), i, V8_NEW_WSTRING_VAR(isolate, v.at(i).c_str())); - } - else if constexpr (std::is_same::value) { - array->Set(isolate->GetCurrentContext(), i, V8_NEW_STRING_VAR(isolate, v.at(i).c_str())); - } - } - return array; - } - static inline std::filesystem::path FixRelativePath(const std::filesystem::path& path, v8::Isolate* isolate) { - if (path.is_relative()) { - std::filesystem::path root = ToString({ isolate, isolate->GetCurrentContext()->GetEmbedderData(static_cast(ContextEmbedderData::WorkingDirectory)) }); - LOG_DEBUG("v8") << "# rel: " << std::filesystem::relative(path, root); - if (std::filesystem::relative(path, root).empty()) - return (root / path).lexically_normal(); - } - return path.lexically_normal(); - } -} -#define V8_CREATE_ENUM_SYMBOL(T, I, C, N, V) \ -T->Set(I, #V, v8::Symbol::New(I, V8_NEW_STRING_VAR(I, std::to_string(C::N::V).c_str()))) - -namespace shelllet { - class Private - { - public: - Private() = default; - virtual ~Private() { - if (!weak.IsEmpty()) { - weak.ClearWeak(); - weak.Reset(); - } - } - v8::Persistent weak; - }; - - template - class V8ObjectPrivate :public T, public Private { - public: - template - V8ObjectPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : T(std::forward(args)...), object(isolate, obj) { - } - - T* operator-> () { - return dynamic_cast(this); - } - const T* operator-> () const { - return dynamic_cast(this); - } - operator T* () { - return dynamic_cast(this); - } - operator const T* () const { - return dynamic_cast(this); - } - - template - v8::Local call(const char* name, Args&&... args) const { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Local local = holder(isolate); - v8::Local proto = local->GetPrototype()->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); - v8::Local value = proto->Get(isolate->GetCurrentContext(), V8_NEW_STRING_VAR(isolate, name)).ToLocalChecked(); - v8::Local func = v8::Local::Cast(value); - if constexpr (sizeof...(Args) == 0) { - return func->CallAsFunction(isolate->GetCurrentContext(), local, 0, {}).ToLocalChecked(); - } - else { - v8::Local argv[] = { std::forward(args)... }; - return func->CallAsFunction(isolate->GetCurrentContext(), local, std::size(argv), argv).ToLocalChecked(); - } - } - - virtual bool hasOwnProperty(const std::string& name) const - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Local proto = holder(isolate)->GetPrototype()->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); - return proto->HasOwnProperty(isolate->GetCurrentContext(), V8_NEW_STRING_VAR(isolate, name.c_str())).FromJust(); - } - - v8::Local holder(v8::Isolate* isolate) const { return object.Get(isolate); } - private: - v8::Global object; - V8ObjectPrivate() = delete; - }; - - template - class V8ObjectPrivate::value>::type> : public Private { - public: - V8ObjectPrivate(v8::Isolate*, const v8::Local&, T* p) : p(p) { - } - - operator T* () { - return dynamic_cast(p.get()); - } - operator const T* () const { - return dynamic_cast(p.get()); - } - - T* operator-> () { - return dynamic_cast(p.get()); - } - const T* operator-> () const { - return dynamic_cast(p.get()); - } - private: - std::shared_ptr p; - //ObjectPrivate() = delete; - }; -} - -namespace shelllet { - class Empty { - public: - virtual ~Empty() {} - }; - - template // can remove c. - class ObjectWrapper : public Empty - { - public: - template - ObjectWrapper(V8ObjectPrivate& d, const v8::FunctionCallbackInfo& args) - : d_ptr(std::unique_ptr>(&d)) - { - } - - ObjectWrapper(v8::Isolate* isolate, const v8::Local& tpl) {} - ObjectWrapper(v8::Isolate* isolate, const v8::Local& proto) {} - - virtual ~ObjectWrapper() {} - virtual void toString(std::stringstream& ss) const { ss << "[object" << " " << U::Name() << "]"; } - - template - static v8::Local New(v8::Isolate* isolate, Args&&... args) - { - //std::unique_ptr p = std::make_unique(std::forward(args)...); - v8::Local argv[] = { std::forward(args)... }; - v8::Local name = V8_NEW_STRING_VAR(isolate, U::Name()); - v8::Local value = isolate->GetCurrentContext()->Global()->Get(isolate->GetCurrentContext(), name).ToLocalChecked(); - if (!value->IsFunction()) { - throw std::runtime_error((boost::format("#! `%1%` not registered.") % U::Name()).str()); - } - v8::Local func = value.As(); - auto result = func->CallAsConstructor(isolate->GetCurrentContext(), std::size(argv), argv); - if (!result.IsEmpty()) - return result.ToLocalChecked(); - return v8::Local(); - } - - static v8::Local New2(v8::Isolate* isolate, T* p) - { - auto fn = WrapClass(isolate, p); - auto v = fn->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()->CallAsConstructor(isolate->GetCurrentContext(), 0, {}); - return v.ToLocalChecked(); - } - static U* From(const v8::Local& value, int index = 0) { - if (value->IsObject()) { - v8::Local o = value.As(); - if (o->InternalFieldCount() > index) - return dynamic_cast(static_cast(o->GetAlignedPointerFromInternalField(index))); - } - return nullptr; - } - template - static inline M* UnWrap(const v8::Local& value, int index = 0) { - if (value->InternalFieldCount() > index) - return dynamic_cast(static_cast(value->GetAlignedPointerFromInternalField(index))); - - return nullptr; - } - public: - operator const T* () const { - if (std::holds_alternative>>(d_ptr)) - return *std::get>>(d_ptr); - else { - return *std::get>>(d_ptr); - } - //return *d_ptr; - } - operator T* () { - //return *d_ptr; - if (std::holds_alternative>>(d_ptr)) - return *std::get>>(d_ptr); - else { - return *std::get < std::unique_ptr>>(d_ptr); - } - } - - const T* operator -> () const { - return static_cast(*this); - } - T* operator -> () { - return static_cast(*this); - } - - static v8::Local WrapClass(v8::Isolate* isolate, T* p = nullptr) - { - v8::Local tpl = v8::FunctionTemplate::New(isolate, U::NewCallback, v8::External::New(isolate, p)); - //if constexpr (C) { - static_cast(std::make_unique(isolate, tpl)); - static_cast(std::make_unique(isolate, tpl->PrototypeTemplate())); - //} - tpl->PrototypeTemplate()->Set(isolate, "toString", v8::FunctionTemplate::New(isolate, [](const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (auto* self = UnWrap>(args.This()); self) { - std::stringstream ss; - self->toString(ss); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, ss.str().c_str())); - } - } - V8_CREATE_LOCAL_CONTEXT_END - })); - tpl->InstanceTemplate()->SetInternalFieldCount(1); - return tpl; - } - - protected: - static void NewCallback(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if constexpr (!C) { - throw std::logic_error((boost::format("`%1%` is not a constructor") % U::Name()).str()); - } - - if (!args.IsConstructCall()) { - throw std::logic_error("should use `new` to create instance"); - } - ObjectWrapper* value = nullptr; - if (auto* self = args.Data().As()->Value(); self) { - value = new U(static_cast(self), args); - } - else { - value = new U(args); - } - - args.This()->SetAlignedPointerInInternalField(0, static_cast(value)); - if (std::holds_alternative>>(value->d_ptr)) { - std::get>>(value->d_ptr)->weak.Reset(isolate, args.This()); - std::get>>(value->d_ptr)->weak.SetWeak(dynamic_cast(value), [](const v8::WeakCallbackInfo& data) { - delete data.GetParameter(); - LOG_INFO("v8") << "# free class `" << U::Name() << "`" << std::endl; - }, v8::WeakCallbackType::kParameter); - } - else { - std::get>>(value->d_ptr)->weak.Reset(isolate, args.This()); - std::get>>(value->d_ptr)->weak.SetWeak(dynamic_cast(value), [](const v8::WeakCallbackInfo& data) { - delete data.GetParameter(); - LOG_INFO("v8") << "# free class `" << U::Name() << "`" << std::endl; - }, v8::WeakCallbackType::kParameter); - } - - args.GetReturnValue().Set(args.This()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - protected: - std::variant>, std::unique_ptr>> d_ptr; - }; -} - -#include "interpreter/v8_util.h" diff --git a/QtRpa/include/wizard.hpp b/QtRpa/include/wizard.hpp deleted file mode 100644 index c3fd4ce..0000000 --- a/QtRpa/include/wizard.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include "common/framework.h" -#include "wizard/framework.h" -#include "wizard/wizardwidget.h" - -using namespace shelllet::wizard; \ No newline at end of file diff --git a/QtRpa/include/wizard/createpage.h b/QtRpa/include/wizard/createpage.h deleted file mode 100644 index a2407ed..0000000 --- a/QtRpa/include/wizard/createpage.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include "framework.h" - -namespace shelllet { - namespace wizard { - - - class CreatePage : public QWizardPage - { - public: - CreatePage(QWidget* parent = nullptr); - ~CreatePage(); - - public: - - protected: - - - private: - QStackedWidget* widget_; - QLineEdit* lineEdit_; - QComboBox* comboBox_; - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/wizard/framework.h b/QtRpa/include/wizard/framework.h deleted file mode 100644 index 4bf9767..0000000 --- a/QtRpa/include/wizard/framework.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -namespace shelllet { - namespace wizard { - class ResponseHandler { - public: - enum class Exit { - Create, - Open, - FromGit, - }; - - virtual void finshed(Exit exit) = 0; - }; - - } -} diff --git a/QtRpa/include/wizard/gitpage.h b/QtRpa/include/wizard/gitpage.h deleted file mode 100644 index 08c2192..0000000 --- a/QtRpa/include/wizard/gitpage.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include "framework.h" - -namespace shelllet { - namespace wizard { - class GitPage : public QWizardPage - { - public: - GitPage(QWidget* parent = nullptr); - ~GitPage(); - - public: - - protected: - - - private: - QStackedWidget* widget_; - QLineEdit* lineEdit_; - QComboBox* comboBox_; - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/wizard/recent_component.h b/QtRpa/include/wizard/recent_component.h deleted file mode 100644 index 5c7619d..0000000 --- a/QtRpa/include/wizard/recent_component.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include "framework.h" - -namespace shelllet { - namespace wizard { - class RencentComponentPrivate; - class RencentComponent : public QWidget - { - Q_DECLARE_PRIVATE(RencentComponent) - public: - RencentComponent( QWidget* parent = nullptr); - ~RencentComponent(); - - private: - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/wizard/splash_content.h b/QtRpa/include/wizard/splash_content.h deleted file mode 100644 index 4794db6..0000000 --- a/QtRpa/include/wizard/splash_content.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -#include "recent_component.h" -#include "started_component.h" - -namespace shelllet { - namespace wizard { - - class SplashContentComponent : public QWidget - { - public: - SplashContentComponent(ResponseHandler* response, QWidget* parent = nullptr); - ~SplashContentComponent(); - - private: - - RencentComponent* recent; - StartedComponent* start; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/wizard/splash_guide.h b/QtRpa/include/wizard/splash_guide.h deleted file mode 100644 index b250b46..0000000 --- a/QtRpa/include/wizard/splash_guide.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include -#include -#include "framework.h" - -namespace shelllet { - namespace wizard { - - class SplashGuide : public QWidget - { - public: - SplashGuide(ResponseHandler* response, QWidget* parent = nullptr); - ~SplashGuide(); - - - private: - QWidget* content; - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/wizard/started_component.h b/QtRpa/include/wizard/started_component.h deleted file mode 100644 index e0d19d0..0000000 --- a/QtRpa/include/wizard/started_component.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include -#include -#include "wizard/framework.h" - -namespace shelllet { - namespace wizard { - class StartedComponentPrivate; - class StartedComponent : public QWidget - { - Q_DECLARE_PRIVATE(StartedComponent) - public: - StartedComponent(ResponseHandler* response, QWidget* parent = nullptr); - ~StartedComponent(); - - protected: - void buttonClicked(); - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/wizard/wizardpage.h b/QtRpa/include/wizard/wizardpage.h deleted file mode 100644 index 49e744f..0000000 --- a/QtRpa/include/wizard/wizardpage.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include -#include -#include -#include "framework.h" -#include "common.hpp" -#define DECLARE_PRIVATE_OBJECT(name) extern name##Private* dx_; -#define DECLARE_PRIVATE_CLASS(name) class name##Private; -#define IMPLEMENT_PRIVATE_CLASS(name) name##Private* dx_ = new name##Private; -#define FREE_PRIVATE_OBJECT delete dx_; - -namespace shelllet { - namespace wizard { - - DECLARE_PRIVATE_CLASS(WizardPage) - DECLARE_PRIVATE_OBJECT(WizardPage) - class WizardPage :public QWizardPage - { - Q_DECLARE_PRIVATE_D(dx_, WizardPage) - public: - WizardPage(QWidget* parent = nullptr); - ~WizardPage(); - - public: - - - }; - } -} \ No newline at end of file diff --git a/QtRpa/include/wizard/wizardwidget.h b/QtRpa/include/wizard/wizardwidget.h deleted file mode 100644 index 3cbf11d..0000000 --- a/QtRpa/include/wizard/wizardwidget.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "common.hpp" -#include "frameless.hpp" -namespace shelllet { - namespace wizard { - class WizardWidgetPrivate; - class WizardWidget : public MainWindow - { - //Q_DECLARE_PRIVATE(WizardWidget) - - public: - WizardWidget(ResponseHandler * handler, QWidget* parent = nullptr); - }; - } -} diff --git a/QtRpa/library/additional/code.py b/QtRpa/library/additional/code.py deleted file mode 100644 index 7356dbe..0000000 --- a/QtRpa/library/additional/code.py +++ /dev/null @@ -1,14 +0,0 @@ -import os - - -try: - filename -except NameError: - filename = None - - -print("filename:", filename) - -os.remove(filename) - - diff --git a/QtRpa/library/system/fileremove.py b/QtRpa/library/system/fileremove.py deleted file mode 100644 index dcf301b..0000000 --- a/QtRpa/library/system/fileremove.py +++ /dev/null @@ -1,15 +0,0 @@ -import os - - -try: - filename -except NameError: - filename = None - - -print("filename:", filename) - -os.remove(filename) - - - diff --git a/QtRpa/library/system/processstart.py b/QtRpa/library/system/processstart.py deleted file mode 100644 index 449746d..0000000 --- a/QtRpa/library/system/processstart.py +++ /dev/null @@ -1,17 +0,0 @@ -import subprocess - - -try: - filename - args -except NameError: - filename = None - args = None - -filename = "notepad.exe" -#args = "file.txt" - -if args is None: - subprocess.Popen(filename) -else: - subprocess.Popen([filename, args]) diff --git a/QtRpa/modules/common/CMakeLists.txt b/QtRpa/modules/common/CMakeLists.txt deleted file mode 100644 index 4ecc78a..0000000 --- a/QtRpa/modules/common/CMakeLists.txt +++ /dev/null @@ -1,42 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(common) - -set(CMAKE_AUTOMOC ON) - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Clang CONFIG REQUIRED) -find_package(LLVM CONFIG REQUIRED) -find_package(g3logger CONFIG REQUIRED) -find_package(ICU REQUIRED COMPONENTS uc dt in io) - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} -) - -#message(STATUS ${ICU_LIBRARY}) - -#add_definitions(-DBOOST_ALL_DYN_LINK) -add_definitions(-DBOOST_LOG_USE_WCHAR_T -DBOOST_LOG_WITHOUT_CHAR) - -add_definitions(-DCMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DCMAKE_OUT_DIR="${CMAKE_OUT_DIR}") - -target_link_libraries(${PROJECT_NAME} PRIVATE - clangTooling - clangFormat - g3logger - ${ICU_LIBRARY} -) \ No newline at end of file diff --git a/QtRpa/modules/common/src/code.cpp b/QtRpa/modules/common/src/code.cpp deleted file mode 100644 index d0729c0..0000000 --- a/QtRpa/modules/common/src/code.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "common.hpp" -#include "common/code.h" - - -void shelllet::common::code::process_start(std::stringstream& stream) -{ - stream << "{"; -} - -void shelllet::common::code::process_end(std::stringstream& stream) -{ - stream << "}"; -} - -//std::string shelllet::activities::code::format(const std::string& js) -//{ -// v8::Isolate* isolate = (dynamic_cast(juce::JUCEApplication::getInstance()))->get_isolate(); -// { -// v8::TryCatch try_catch(isolate); -// v8::Isolate::Scope isolate_scope(isolate); -// -// // Create a stack-allocated handle scope. -// v8::HandleScope handle_scope(isolate); -// -// // Create a new context. -// v8::Local context = v8::Context::New(isolate); -// -// // Enter the context for compiling and running the hello world script. -// v8::Context::Scope context_scope(context); -// v8::ScriptOrigin origin = make_script_origin("no", isolate); -// { -// // Create a string containing the JavaScript source code. -// -// std::string src = R"( -// -//import * from 'C:/Users/Admin/Downloads/js-beautify-master/js/bin/js-beautify.js'; -// -//var myCodeMirror = CodeMirror("let ddd = 10") -// -////highlight('javascript', 'console.log(" sss ")'))"; -// -// v8::Local module; -// v8::ScriptCompiler::Source source_text(convert::String::New(isolate, src.c_str()), origin); -// -// if (!v8::ScriptCompiler::CompileModule(isolate, &source_text).ToLocal(&module)) { -// LOG_WARN(kMainModuleName) << *(v8::String::Utf8Value(isolate, try_catch.Exception())) << std::endl; -// return js; -// } -// -// auto result = module->InstantiateModule(context, [](v8::Local context, v8::Local specifier, -// v8::Local referrer)->v8::MaybeLocal { -// v8::String::Utf8Value param(context->GetIsolate(), specifier); -// std::string filename = std::string(*param); -// -// v8::Isolate* isolate = context->GetIsolate(); -// -// std::ifstream stream(filename); -// -// std::string str((std::istreambuf_iterator(stream)), std::istreambuf_iterator()); -// -// v8::ScriptOrigin origin = make_script_origin(filename.c_str(), context->GetIsolate()); -// -// v8::ScriptCompiler::Source source(convert::String::New(isolate, str.c_str()), origin); -// -// return v8::ScriptCompiler::CompileModule(context->GetIsolate(), &source); -// }); -// -// if (result.IsNothing()) { -// LOG_WARN(kMainModuleName) << *(v8::String::Utf8Value(isolate, try_catch.Exception())) << std::endl; -// return js; -// } -// -// v8::Local value; -// -// module->Evaluate(context).ToLocal(&value); -// -// if (try_catch.HasCaught()) { -// LOG_WARN(kMainModuleName) << *(v8::String::Utf8Value(isolate, try_catch.Exception())) << std::endl; -// return js; -// } -// // Convert the result to an UTF8 string and print it. -// -// return *(v8::String::Utf8Value(isolate, value)); -// } -// } -//} diff --git a/QtRpa/modules/common/src/custom_output_backend.cpp b/QtRpa/modules/common/src/custom_output_backend.cpp deleted file mode 100644 index 5f30bd0..0000000 --- a/QtRpa/modules/common/src/custom_output_backend.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "common/framework.h" -#include "common/logs.h" -#include "common/custom_output_backend.h" -#include "qdebug.h" -void shelllet::common::custom_output_backend::ReceiveLogMessage(g3::LogMessageMover logEntry) -{ - qDebug().noquote() << QString::fromStdString(logEntry.get().toString()); -} - -void shelllet::common::StdOutBackend::ReceiveLogMessage(g3::LogMessageMover logEntry) -{ - std::cout << logEntry.get().toString() << std::endl; -} diff --git a/QtRpa/modules/common/src/directoryentry.cpp b/QtRpa/modules/common/src/directoryentry.cpp deleted file mode 100644 index fa37855..0000000 --- a/QtRpa/modules/common/src/directoryentry.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "common/path.h" -#include "common/directoryentry.h" -#include "common/private/directoryentry_p.h" - -shelllet::common::DirectoryEntry::DirectoryEntry(Object* parent /*= nullptr*/) - :DirectoryEntry(*new DirectoryEntryPrivate, parent) -{ - -} - -const shelllet::common::Path& shelllet::common::DirectoryEntry::path() const noexcept -{ - Q_D(const DirectoryEntry); - static Path path; - path= d->entry->path(); - return path; -} - -shelllet::common::DirectoryEntry::DirectoryEntry(const std::filesystem::directory_entry& entry, Object* parent /*= nullptr*/) - : DirectoryEntry(*new DirectoryEntryPrivate, parent) -{ - Q_D(DirectoryEntry); - d->entry.reset(new std::filesystem::directory_entry(entry)); -} - -shelllet::common::DirectoryEntry::operator const shelllet::common::Path& () const noexcept -{ - Q_D(const DirectoryEntry); - static Path path; - path = d->entry->operator const std::filesystem::path &() ; - return path; -} - -shelllet::common::DirectoryEntry::DirectoryEntry(DirectoryEntryPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} diff --git a/QtRpa/modules/common/src/directoryiterator.cpp b/QtRpa/modules/common/src/directoryiterator.cpp deleted file mode 100644 index dda8f0d..0000000 --- a/QtRpa/modules/common/src/directoryiterator.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "common/path.h" -#include "common/directoryentry.h" -#include "common/directoryiterator.h" -#include "common/private/directoryiterator_p.h" -shelllet::common::DirectoryIterator::DirectoryIterator(Object* parent /*= nullptr*/) - :DirectoryIterator(*new DirectoryIteratorPrivate, parent) -{ - -} - -shelllet::common::DirectoryIterator& shelllet::common::DirectoryIterator::operator++() -{ - Q_D(DirectoryIterator); - d->iterator->operator++(); - return *this; -} - -bool shelllet::common::DirectoryIterator::operator==(const DirectoryIterator& rhs) const noexcept -{ - Q_D(const DirectoryIterator); - return *d->iterator == *rhs.d_func()->iterator; -} - -bool shelllet::common::DirectoryIterator::operator!=(const DirectoryIterator& rhs) const noexcept -{ - Q_D(const DirectoryIterator); - return *d->iterator != *rhs.d_func()->iterator; -} - -shelllet::common::DirectoryIterator shelllet::common::DirectoryIterator::begin() const -{ - Q_D(const DirectoryIterator); - return std::filesystem::begin(*d->iterator); -} - -shelllet::common::DirectoryIterator shelllet::common::DirectoryIterator::end() const -{ - Q_D(const DirectoryIterator); - return std::filesystem::end(*d->iterator); -} - -const shelllet::common::DirectoryEntry& shelllet::common::DirectoryIterator::operator*() const noexcept -{ - Q_D(const DirectoryIterator); - static DirectoryEntry entry; - entry = d->iterator->operator*(); - return entry; -} - -const shelllet::common::DirectoryEntry* shelllet::common::DirectoryIterator::operator->() const noexcept -{ - Q_D(const DirectoryIterator); - static DirectoryEntry entry; - entry = *d->iterator->operator->(); - return &entry; -} - -shelllet::common::DirectoryIterator::DirectoryIterator(const std::filesystem::directory_iterator& iterator, Object* parent /*= nullptr*/) - : DirectoryIterator(*new DirectoryIteratorPrivate, parent) -{ - Q_D(DirectoryIterator); - d->iterator.reset(new std::filesystem::directory_iterator(iterator)); -} - -shelllet::common::DirectoryIterator::DirectoryIterator(const Path& p, Object* parent /*= nullptr*/) - : DirectoryIterator(*new DirectoryIteratorPrivate, parent) -{ - Q_D(DirectoryIterator); - d->iterator.reset(new std::filesystem::directory_iterator(p)); -} - -shelllet::common::DirectoryIterator::DirectoryIterator(DirectoryIteratorPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} diff --git a/QtRpa/modules/common/src/elementparser.cpp b/QtRpa/modules/common/src/elementparser.cpp deleted file mode 100644 index a91dac9..0000000 --- a/QtRpa/modules/common/src/elementparser.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "common.hpp" -#include "pugixml.hpp" -#include "common/elementparser.h" -#include "common/environment.h" -#include "yaml-cpp/yaml.h" -#include "common/private/object_p.h" -#include "common/private/elementparser_p.h" -namespace shelllet { - namespace fs = std::filesystem; - using namespace YAML; - using namespace pugi; -} - -shelllet::common::ElementParser::ElementParser() - : Object(*new ElementParserPrivate, nullptr) -{ - -} - -void shelllet::common::ElementParser::parseElement() -{ - Q_D(ElementParser); - - - for (auto& p : fs::directory_iterator(Environment::getInstance()->modPath())) { - fs::path config = p.path() / d->key_filename; - if (!fs::exists(config)) { - continue; - } - - Node root = LoadFile(config.string()); - Node elements = root[d->key_elements]; - if (elements && elements.IsSequence()) { - std::shared_ptr doc = std::make_shared(); - auto e = doc->append_child(p.path().filename().string().c_str()); - e.append_attribute(d->key_display) = root[d->key_name].as().c_str(); - - for (std::size_t i = 0; i < elements.size(); ++i) { - if (auto tmp = elements[i][d->key_name]) { - xml_node node = e.append_child(tmp.as().c_str()); - if (auto tmp = elements[i][d->key_description]) { - node.append_attribute(d->key_description) = tmp.as().c_str(); - } - if (auto tmp = elements[i][d->key_display]) { - node.append_attribute(d->key_display) = tmp.as().c_str(); - } - - xml_node p = node.append_child(d->key_properties); - auto properties = elements[i][d->key_properties]; - if (properties && properties.IsSequence()) - { - for (std::size_t i = 0; i < properties.size(); ++i) { - const_iterator it = properties[i].begin(); - auto ch = p.append_child(it->first.as().c_str()); - ch.text().set(it->second.as().c_str()); - - for (it = properties[i].begin(), it++; it != properties[i].end(); ++it) { - std::string key = it->first.as(); - std::string value = it->second.as(); - - ch.append_attribute(key.c_str()) = value.c_str(); - } - - } - } - } - - - } - LOG_DEBUG("rpa") << *doc << std::endl; - - d->data.push_back(doc); - } - } - -} - -std::list> shelllet::common::ElementParser::data() const -{ - Q_D(const ElementParser); - return d->data; -} - -String shelllet::common::ElementParser::keyDisplay() const -{ - Q_D(const ElementParser); - return d->key_display; -} - -String shelllet::common::ElementParser::keyDecoration() const -{ - Q_D(const ElementParser); - return d->key_icon; -} - -String shelllet::common::ElementParser::keySystem() const -{ - Q_D(const ElementParser); - return d->key_system; -} diff --git a/QtRpa/modules/common/src/environment.cpp b/QtRpa/modules/common/src/environment.cpp deleted file mode 100644 index c303a78..0000000 --- a/QtRpa/modules/common/src/environment.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "common/environment.h" -#include "common/logs.h" -#include "common/private/object_p.h" -#include "qcoreapplication.h" -namespace shelllet { - namespace common { - class EnvironmentPrivate : public ObjectPrivate { - public: - std::unique_ptr data = std::make_unique(); - - //Path scripts; - String script_extension; - Path current_filepath; - Path assets; - String index_xml_filename; - String pkg_src; - Path tplPath; - }; - - Q_GLOBAL_STATIC(Environment, __env__) - } -} -shelllet::common::Environment::Environment() : Object(*new EnvironmentPrivate, nullptr) -{ - Q_D(Environment); - d->data->modules_path = std::filesystem::current_path() / "modules"; - d->data->extension = ".dll"; - - d->data->pkg_extension = ".zip"; - -#ifdef _DEBUG - d->data->home = CMAKE_OUT_DIR; -#else - d->data->home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString(); -#endif // _DEBUG - d->data->config_filename = "config.yaml"; - d->index_xml_filename = "index.xml"; - d->data->readme_filename = "README.md"; - d->data->mime_data_type = "application/activity"; - d->pkg_src = "src"; - d->data->pkg_res = "res"; - d->script_extension = ".py"; - d->data->pipe_name = "\\\\.\\pipe\\breakpad_crash_service\\shelllet"; - d->data->dump_remote = "https://shelllet.com?apikey="; - - -#ifdef _DEBUG - d->assets = CMAKE_SOURCE_DIR "/assets"; - d->data->modPath = CMAKE_SOURCE_DIR "/.mod"; - d->data->module_search_path = CMAKE_SOURCE_DIR "/library"; -#else - d->data->modPath = std::filesystem::path(QCoreApplication::applicationDirPath().toStdString()) / ".mod"; - d->assets = std::filesystem::path(QCoreApplication::applicationDirPath().toStdString()) / "assets"; - d->data->module_search_path = std::filesystem::path(QCoreApplication::applicationDirPath().toStdString()) / "library"; -#endif // _DEBUG - - d->data->applicationName = QObject::tr("Hello"); -} - -void shelllet::common::Environment::setModulePath(const QString& path) -{ - Q_D(Environment); - d->data->modules_path = path.toStdWString(); -} - -shelllet::common::Path shelllet::common::Environment::indexXmlPath() const -{ - Q_D(const Environment); - return (d->pkg_src + "/" + d->index_xml_filename).toStdString(); -} - - - - -std::filesystem::path shelllet::common::Environment::storagePath() const -{ - Q_D(const Environment); - - std::filesystem::path tmp = d->data->home; - - return tmp /= QCoreApplication::organizationName().toStdWString(); -} - -std::filesystem::path shelllet::common::Environment::logsPath() const -{ - Q_D(const Environment); - return storagePath() /= "logs"; -} - -std::filesystem::path shelllet::common::Environment::dumpPath() const -{ - Q_D(const Environment); - return storagePath() /= "dump"; -} - -std::filesystem::path shelllet::common::Environment::modPath() const -{ - Q_D(const Environment); - return d->data->modPath; -} - -QIcon shelllet::common::Environment::getIconByName(const String& name) const -{ - return QIcon(*getIconFileName(name).toQString()); -} - -QIcon shelllet::common::Environment::iconMods(const std::string& filename) const -{ - Q_D(const Environment); - auto full_filename = d->data->modPath / filename; - return QIcon(QString::fromStdString(full_filename.string())); -} - -QPixmap shelllet::common::Environment::pixmap(const std::string& name) const -{ - Q_D(const Environment); - Path filename = d->assets / "images/"; - filename.replaceFileName(name); - return QPixmap(*filename.toString().toQString()); -} - -shelllet::common::String shelllet::common::Environment::getIconFileName(const String& name) const -{ - Q_D(const Environment); - Path filename = d->assets / "icons/"; - - filename.replaceFileName(name + ".svg"); - return filename.toString(); -} - -shelllet::common::Environment* shelllet::common::Environment::getInstanceRef() -{ - return __env__; -} - -const shelllet::common::Environment* shelllet::common::Environment::getInstance() -{ - return __env__; -} - -shelllet::common::Options const* shelllet::common::Environment::getOptions() const -{ - Q_D(const Environment); - return d->data.get(); -} - -shelllet::common::Path shelllet::common::Environment::getViewPath() const -{ - Q_D(const Environment); - return d->assets / "library"; -} - -shelllet::common::Path shelllet::common::Environment::getModePath() const -{ - Q_D(const Environment); - return d->data->module_search_path; -} - -shelllet::common::String shelllet::common::Environment::getPkgSrcName() const -{ - Q_D(const Environment); - return d->pkg_src; -} - -shelllet::common::String shelllet::common::Environment::getScriptExtension() const -{ - Q_D(const Environment); - return d->script_extension; -} - -shelllet::common::Path shelllet::common::Environment::getAssetsPath() const -{ - Q_D(const Environment); - return d->assets; -} - -shelllet::common::Path shelllet::common::Environment::getActivitiesPath() const -{ - Q_D(const Environment); - return d->assets / "activities"; -} - -shelllet::common::Path shelllet::common::Environment::getCurrentProjectPath() const -{ - Q_D(const Environment); - return d->current_filepath; -} -void shelllet::common::Environment::setCurrentFilePath(const Path& path) -{ - Q_D(Environment); - d->current_filepath = path; -} - -shelllet::common::Path shelllet::common::Environment::getTemplatePath() const -{ - Q_D(const Environment); - return d->assets / "template"; -} - -shelllet::common::String shelllet::common::Environment::getIndexFileName() const -{ - Q_D(const Environment); - return d->index_xml_filename; -} diff --git a/QtRpa/modules/common/src/file.cpp b/QtRpa/modules/common/src/file.cpp deleted file mode 100644 index e5d2f50..0000000 --- a/QtRpa/modules/common/src/file.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "common/file.h" -//#include "common/private/file_p.h" - -namespace shelllet { - namespace common { - class FilePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(File) - public: - std::unique_ptr file; - }; - } -} - - -shelllet::common::String shelllet::common::File::readAllAsText(const Path& path) -{ - std::ifstream stream(path.toStdPath()); - BOOST_ASSERT_MSG(path.isExist(), "file not exist"); - return stream; -} - -shelllet::common::File& shelllet::common::File::operator<<(const String& str) -{ - return *this; -} - -void shelllet::common::File::write(const String& data) -{ - Q_D(File); - if (!d->file->isOpen()) { - BOOST_VERIFY_MSG(d->file->open(QIODevice::WriteOnly), "Open file failed."); - - } - d->file->write(data.toUtf8()); -} - -void shelllet::common::File::copy(const Path& src, const Path& target) -{ - std::filesystem::copy_file(src, target); -} - -shelllet::common::File::File(const Path& path) - : File(*new FilePrivate) -{ - Q_D(File); - d->file->setFileName(*path.toString().toQString()); -} - -shelllet::common::File::File(const String& name) - : File(*new FilePrivate) -{ - Q_D(File); - d->file->setFileName(*name.toQString()); -} - -shelllet::common::File::File() - : File(*new FilePrivate) -{ - -} - -shelllet::common::File::File(FilePrivate& d) - : Object(d, nullptr) -{ - d.file = std::make_unique(); -} diff --git a/QtRpa/modules/common/src/format.cpp b/QtRpa/modules/common/src/format.cpp deleted file mode 100644 index cddde20..0000000 --- a/QtRpa/modules/common/src/format.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//#include -//#include -//#include -#include "common.hpp" - -#include -#include -#include -#include - - -/* -ref clang/tools/clang-format/ClangFormat.cpp -*/ -namespace shelllet { - using namespace llvm; - using namespace clang; - using namespace clang::format; - using clang::tooling::Replacements; -} - -shelllet::common::Format::Format() -{ -} - -std::string shelllet::common::Format::format(const std::string& c) -{ - std::unique_ptr Code = MemoryBuffer::getMemBuffer(c); - if (Code->getBufferSize() == 0) - return c; // Empty files are formatted correctly. - llvm::StringRef BufStr = Code->getBuffer(); - - //const char* InvalidBOM = SrcMgr::ContentCache::getInvalidBOM(BufStr); - - //if (InvalidBOM) { - //LOG_ERROR(__FUNCTION__) << "error: encoding with unsupported byte order mark \"" - // << InvalidBOM << "\" detected."; - // return c; - //} - - std::vector Ranges = { tooling::Range(0, Code->getBufferSize()) }; - - llvm::Expected FormatStyle = - getStyle("Google", clang::format::getLanguageName(FormatStyle::LK_JavaScript), clang::format::DefaultFallbackStyle); - if (!FormatStyle) { - // LOG_ERROR(kMainModuleName) << llvm::toString(FormatStyle.takeError()) << std::endl; - return c; - } - Replacements Replaces; - FormattingAttemptStatus Status; - - Replacements cleanupChanges = clang::format::cleanup(*FormatStyle, BufStr, Ranges, clang::format::getLanguageName(FormatStyle::LK_JavaScript)); - Replaces = Replaces.merge(cleanupChanges); - - Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges); - Replacements FormatChanges = - clang::format::reformat(*FormatStyle, BufStr, Ranges, clang::format::getLanguageName(FormatStyle::LK_JavaScript), &Status); - Replaces = Replaces.merge(FormatChanges); - - auto ChangedCode = tooling::applyAllReplacements(BufStr, Replaces); - if (!ChangedCode) { - // LOG_ERROR(__FUNCTION__) << llvm::toString(ChangedCode.takeError()) << std::endl; - return c; - } - - return *ChangedCode; -} - -void shelllet::common::Format::initialize(int argc, char* argv[]) -{ - llvm_ = std::make_unique(argc, argv); -} \ No newline at end of file diff --git a/QtRpa/modules/common/src/image.cpp b/QtRpa/modules/common/src/image.cpp deleted file mode 100644 index 0139f1f..0000000 --- a/QtRpa/modules/common/src/image.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "common/image.h" -#include "common/private/image_p.h" -#include "qimage.h" -#include "qpixmap.h" -shelllet::common::Image::Image() - : Image(*new ImagePrivate) -{ - -} - -shelllet::common::Image::Image(const QPixmap* pixmap) - : Image(*new ImagePrivate) -{ - Q_D(Image); - *d->image = { pixmap->toImage() }; -} - -shelllet::common::Image::Image(const uint8_t* data, int32_t width, int32_t height, UInt32 bytesPerLine, QImage::Format format) - : Image(*new ImagePrivate) -{ - Q_D(Image); - d->image.reset(new QImage(data, width, height, bytesPerLine, format)); -} - -shelllet::common::Image::Image(const QImage* image) - : Image(*new ImagePrivate) -{ - Q_D(Image); - - *d->image = { *image }; -} - -shelllet::common::Image::Image(ImagePrivate& d) - : Object(d, nullptr) -{ - d.image = std::make_unique(); -} diff --git a/QtRpa/modules/common/src/logs.cpp b/QtRpa/modules/common/src/logs.cpp deleted file mode 100644 index f6dbe5b..0000000 --- a/QtRpa/modules/common/src/logs.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include "common/logs.h" -#include "common/private/object_p.h" -#include -#include "common/custom_output_backend.h" - -//#include "boost/log/support/date_time.hpp" -//#include "boost/log/utility/setup/common_attributes.hpp" -//#include "boost/log/expressions/predicates/is_debugger_present.hpp" -//#include "boost/log/utility/setup/console.hpp" -//#include "boost/log/utility/setup/file.hpp" -// -//namespace shelllet { -// typedef boost::log::sinks::synchronous_sink sink_debug_t; -// -// namespace logging { -// static inline auto LOG_FORMAT_STREAM = (boost::log::expressions::format(L"[%1%]<%2%> : <%3%> %4%") -// % boost::log::expressions::format_date_time(L"TimeStamp", "%Y-%m-%d %H:%M:%S") -// % boost::log::expressions::attr< std::wstring >(L"Channel") -// % severity -// % boost::log::expressions::message); -// -// -// BOOST_LOG_ATTRIBUTE_KEYWORD(keyword_channel, L"Channel", std::string); -// } -//} -//void shelllet::logging::add_custom_sink(const boost::shared_ptr& sink) -//{ -// //boost::shared_ptr sink(new sink_broadcast_t()); -// -// sink->set_formatter(boost::log::expressions::stream << boost::log::expressions::if_(boost::log::expressions::has_attr(simple_log_message) && boost::log::expressions::attr("Simple")) -// [ -// boost::log::expressions::stream << boost::log::expressions::message -// ] -// .else_ -// [ -// LOG_FORMAT_STREAM -// ]); -// -// boost::log::core::get()->add_sink(sink); -// // LOG_INFO("") << boost::log::add_value(simple_log_message, true) << "simple message." << std::endl; -//} -// -// -//void shelllet::logging::add_file_sink(const std::filesystem::path& filename) -//{ -// boost::log::add_file_log(boost::log::keywords::file_name = filename.c_str(), -// boost::log::keywords::rotation_size = 1 * 1024 * 1024, -// boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0), -// boost::log::keywords::format = LOG_FORMAT_STREAM -// //boost::log::keywords::channel = keyword_channel == channel -// ); -//} -// -//void shelllet::logging::initialize(boost::log::trivial::severity_level level) -//{ -// boost::log::add_common_attributes(); -// -// { -// boost::shared_ptr sink = boost::make_shared(); -// sink->set_formatter(LOG_FORMAT_STREAM); -// boost::log::core::get()->add_sink(sink); -// } -// -// -// boost::log::add_console_log(std::clog, boost::log::keywords::format = LOG_FORMAT_STREAM); -// boost::log::core::get()->set_filter(boost::log::trivial::severity >= level); -//} -// -//boost::log::trivial::severity_level shelllet::logging::level_from_string(const std::string& level) -//{ -// static std::map map = { -// {"trace", boost::log::trivial::trace} , -// {"debug", boost::log::trivial::debug} , -// {"info", boost::log::trivial::info} , -// {"warning", boost::log::trivial::warning} , -// {"error", boost::log::trivial::error} , -// {"fatal", boost::log::trivial::fatal} -// }; -// -// if (auto itor = map.find(level); itor != map.cend()) { -// return itor->second; -// } -// return boost::log::trivial::fatal; -//} -#include "qglobalstatic.h" -#include "qcoreapplication.h" -namespace shelllet { - - namespace common { - - class LoggerPrivate : public ObjectPrivate { - public: - std::unique_ptr worker = g3::LogWorker::createLogWorker(); - }; - - Q_GLOBAL_STATIC(Logger, __logger__) - } -} -shelllet::common::Logger::Logger() - : Object(*new LoggerPrivate, nullptr) -{ - - - //std::future log_file_name = handle->call(&g3::FileSink::fileName); - - //auto changeFormatting = handle->call(&g3::FileSink::overrideLogDetails, g3::LogMessage::FullLogDetailsToString); - //const std::string newHeader = "\t\tLOG format: [YYYY/MM/DD hh:mm:ss uuu* LEVEL THREAD_ID FILE->FUNCTION:LINE] message\n\t\t(uuu*: microseconds fractions of the seconds value)\n\n"; - //// example of ovrriding the default formatting of header - //auto changeHeader = handle->call(&g3::FileSink::overrideLogHeader, newHeader); - - //changeFormatting.wait(); - //changeHeader.wait(); -} - -shelllet::common::Logger* shelllet::common::Logger::getInstance() -{ - return __logger__; -} - -void shelllet::common::Logger::addFileSink(severity_level level, const std::filesystem::path& folder) -{ - Q_D(Logger); - auto handle = d->worker->addDefaultLogger(QCoreApplication::applicationName().toStdString(), folder.string()); - -} - -severity_level shelllet::common::Logger::levelFromString(const std::string& level) -{ - static std::map map = { - -{"debug", debug} , -{"info", info} , -{"warning", warning} , -{"error", error} - }; - - if (auto itor = map.find(level); itor != map.cend()) { - return itor->second; - } - return debug; -} - -void shelllet::common::Logger::initialize() -{ - Q_D(Logger); - addCustomSink(debug, std::make_unique()); - addCustomSink(debug, std::make_unique()); - g3::initializeLogging(d->worker.get()); -} - -void shelllet::common::Logger::addCustomSink(severity_level level, std::unique_ptr sink) -{ - Q_D(Logger); - d->worker->addSink(std::move(sink), &CustomSink::ReceiveLogMessage); -} diff --git a/QtRpa/modules/common/src/mimedata.cpp b/QtRpa/modules/common/src/mimedata.cpp deleted file mode 100644 index 60f44b1..0000000 --- a/QtRpa/modules/common/src/mimedata.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "common/mimedata.h" -#include "common/private/mimedata_p.h" - -shelllet::common::MimeData::MimeData(MimeDataPrivate& d) - : Object(d) -{ - -} diff --git a/QtRpa/modules/common/src/object.cpp b/QtRpa/modules/common/src/object.cpp deleted file mode 100644 index 31e351c..0000000 --- a/QtRpa/modules/common/src/object.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "common/object.h" -#include "common/private/object_p.h" - -shelllet::common::ObjectData::~ObjectData() -{ - -} - -shelllet::common::ObjectPrivate::~ObjectPrivate() -{ - -} - -shelllet::common::Object::Object(ObjectPrivate& dd, Object* parent /*= nullptr*/) - : d_ptr(&dd) -{ - Q_D(Object); - d_ptr->q_ptr = this; -} \ No newline at end of file diff --git a/QtRpa/modules/common/src/operator.cpp b/QtRpa/modules/common/src/operator.cpp deleted file mode 100644 index ca8a918..0000000 --- a/QtRpa/modules/common/src/operator.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "common.hpp" -#include -namespace std { - std::ostream& operator<< (std::ostream& os, const QString& arr) - { - os << arr.toStdString(); - return os; - } -} \ No newline at end of file diff --git a/QtRpa/modules/common/src/path.cpp b/QtRpa/modules/common/src/path.cpp deleted file mode 100644 index a0bdef7..0000000 --- a/QtRpa/modules/common/src/path.cpp +++ /dev/null @@ -1,158 +0,0 @@ -#include "common/framework.h" -#include "common/alias.h" -#include "common/path.h" -#include "common/logs.h" -#include "common/private/path_p.h" -#include "qcoreapplication.h" - -namespace shelllet { - namespace common { - std::ostream& operator<<(std::ostream& o, const Path& p) - { - o << p.d_func()->path; - return o; - } - } -} -using namespace shelllet::common; - -shelllet::common::Path::Path(PathPrivate& d) - : Object(d, nullptr) -{ - -} - -shelllet::common::Path::Path(const char* path) - : Path(*new PathPrivate) -{ - Q_D(Path); - d->path = path; -} - -shelllet::common::Path::Path(const std::string& path) - : Path(*new PathPrivate) -{ - Q_D(Path); - d->path = path; -} - -shelllet::common::Path::Path(const std::filesystem::path& path) - : Path(*new PathPrivate) -{ - Q_D(Path); - d->path = path; -} - -shelllet::common::Path::Path() - : Path(*new PathPrivate) -{ - -} - -shelllet::common::Path& shelllet::common::Path::operator=(const Path& p) -{ - Q_D(Path); - d->path = p.d_func()->path; - - return *this; -} - -shelllet::common::Path::Path(const Path& p) - : Path(*new PathPrivate) -{ - Q_D(Path); - d->path = p.d_func()->path; -} - -shelllet::common::Path& shelllet::common::Path::operator/=(const Path& path) -{ - Q_D(Path); - d->path /= path.d_func()->path; - return *this; -} - -void shelllet::common::Path::replaceExtension(const Path& path) -{ - Q_D(Path); - d->path.replace_extension(path.d_func()->path); -} - -void shelllet::common::Path::replaceFileName(const Path& path) -{ - Q_D(Path); - - d->path.replace_filename(path.d_func()->path); -} - -shelllet::common::String shelllet::common::Path::fileName() const -{ - Q_D(const Path); - return d->path.stem().string(); -} - -shelllet::common::Path shelllet::common::Path::operator/(const char* path) const -{ - Q_D(const Path); - return d->path / path; -} - -shelllet::common::Path shelllet::common::Path::operator/(const Path& path) const -{ - Q_D(const Path); - return d->path / path.d_func()->path; -} - -shelllet::common::String shelllet::common::Path::toString() const -{ - Q_D(const Path); - return d->path.string(); -} - -bool shelllet::common::Path::isExist() const -{ - Q_D(const Path); - return std::filesystem::exists(d->path); -} - -bool shelllet::common::Path::isEmpty() const -{ - Q_D(const Path); - return d->path.empty(); -} - -bool shelllet::common::Path::isDir() const -{ - Q_D(const Path); - return std::filesystem::is_directory(d->path); -} - -shelllet::common::String shelllet::common::Path::extension() const -{ - Q_D(const Path); - return d->path.extension().string(); -} - -shelllet::common::Path shelllet::common::Path::applicationDirPath() -{ - return String::fromQString(&static_cast(QCoreApplication::applicationDirPath())) ; -} - -std::filesystem::path shelllet::common::Path::toStdPath() const -{ - Q_D(const Path); - return d->path; -} - -shelllet::common::Path::Path(const String& path) - : Path(*new PathPrivate) -{ - Q_D(Path); - - d->path = path.toStdString(); -} - -shelllet::common::Path::operator std::filesystem::path() const -{ - Q_D(const Path); - return d->path; -} diff --git a/QtRpa/modules/common/src/point.cpp b/QtRpa/modules/common/src/point.cpp deleted file mode 100644 index 8a86d9b..0000000 --- a/QtRpa/modules/common/src/point.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "common/point.h" - -auto shelllet::common::PointPrivate::x() -{ - -} diff --git a/QtRpa/modules/common/src/rect.cpp b/QtRpa/modules/common/src/rect.cpp deleted file mode 100644 index 07a0965..0000000 --- a/QtRpa/modules/common/src/rect.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "common/rect.h" \ No newline at end of file diff --git a/QtRpa/modules/common/src/stream.cpp b/QtRpa/modules/common/src/stream.cpp deleted file mode 100644 index de3a4ec..0000000 --- a/QtRpa/modules/common/src/stream.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "common.hpp" - -namespace std { - template - T&& operator-(T&& t) { return std::forward(t); } - - template - std::ostream& operator<(std::ostream& out, const T& data) - { - QString message; - QDebug debug(&message); - debug << data; - out << message; - return out; - } - - std::ostream& operator<<(std::ostream& out, const QString& data) - { - std::string s = data.toUtf8().constData(); - out << data.toUtf8().constData(); - return out; - } - std::wostream& operator<<(wostream& out, const wstring& data) - { - out << data; - return out; - } - - std::ostream& operator<<(std::ostream& out, const QStringList& data) - { - QByteArray bytes; - { - QBuffer buffer(&bytes); - buffer.open(QIODevice::WriteOnly); - QDataStream stream(&buffer); - stream << data; - out << bytes.constData(); - } - return out; - } - - /*std::ostream& operator<<(ostream& out, const pugi::xml_node& node) - { - node.print(out); - return out; - }*/ - - std::ostream& operator<<(ostream& out, const QPoint& data) - { - out << "(" << data.x() << ", " << data.y() << ")"; - return out; - } - - std::ostream& operator<<(ostream& out, const QSizeF& data) - { - out << "(" << data.width() << ", " << data.height() << ")"; - return out; - } - - std::ostream& operator<<(ostream& out, const QSize& data) - { - out << "(" << data.width() << ", " << data.height() << ")"; - return out; - } - - std::ostream& operator<<(ostream& out, const QPointF& data) - { - out << "(" << data.x() << ", " << data.y() << ")"; - return out; - } - - std::ostream& operator<<(ostream& out, const QRectF& data) - { - QByteArray bytes; - { - QBuffer buffer(&bytes); - buffer.open(QIODevice::WriteOnly); - QDataStream stream(&buffer); - stream << data; - } - out << bytes.constData(); - out < -data; - return out; - } - - std::ostream& operator<<(std::ostream& out, const QRect& data) - { - /* QByteArray bytes; - { - QBuffer buffer(&bytes); - buffer.open(QIODevice::WriteOnly); - QDataStream stream(&buffer); - stream << data; - }*/ - out < -data; - return out; - } - - /*std::ostream& operator<<(ostream& out, const pugi::xml_document& doc) - { - doc.print(out); - return out; - }*/ - - std::ostream& operator<<(ostream& out, const QByteArray& data) - { - out < -data; - return out; - } - - - - std::istream& operator>>(std::istream& in, QString& data) - { - std::string temp; - in >> temp; - data = QString::fromStdString(temp); - return in; - } - - std::istream& operator>>(std::istream& in, QStringList& data) - { - std::string temp; - in >> temp; - QBuffer buffer; - buffer.setData(temp.c_str(), static_cast(temp.size())); - buffer.open(QIODevice::ReadOnly); - QDataStream stream(&buffer); - stream >> data; - return in; - } - -} \ No newline at end of file diff --git a/QtRpa/modules/common/src/string.cpp b/QtRpa/modules/common/src/string.cpp deleted file mode 100644 index 1f34ebc..0000000 --- a/QtRpa/modules/common/src/string.cpp +++ /dev/null @@ -1,298 +0,0 @@ -#include "unicode/unistr.h" -#include "unicode/ustring.h" -#include "unicode/ustream.h" -#include "common/wobjectdefs.h" -#include "common/string.h" -#include "common/private/string_p.h" -#include "common/const_string.h" -#include "boost/lexical_cast.hpp" -#include "common/logs.h" -namespace shelllet { - using namespace icu; - namespace common { - std::ostream& operator<<(std::ostream& o, const String& data) - { - o << data.d_func()->str.operator*(); - return o; - } - - - class U8StringPrivate : public ObjectPrivate { - public: - std::string str; - }; - } -} - -shelllet::common::U8String& shelllet::common::U8String::append(const char* data, UInt32 n) -{ - Q_D(U8String); - d->str.append(data, n); - return *this; -} - -shelllet::common::UInt32 shelllet::common::U8String::length() const -{ - Q_D(const U8String); - return d->str.length(); -} - -shelllet::common::UInt32 shelllet::common::U8String::capacity() const -{ - Q_D(const U8String); - return d->str.capacity(); -} - -void shelllet::common::U8String::reserve(UInt32 cap) -{ - Q_D(U8String); - d->str.reserve(cap); -} - -shelllet::common::U8String::operator const char* () const -{ - Q_D(const U8String); - return d->str.c_str(); -} - -shelllet::common::U8String::U8String() - : U8String(*new U8StringPrivate) -{ - -} - -shelllet::common::U8String::U8String(const U8String& str) - : U8String(*new U8StringPrivate) -{ - Q_D(U8String); - d->str = str.d_func()->str; -} - -shelllet::common::U8String::U8String(U8StringPrivate& d) - : Object(d) -{ - -} - -shelllet::common::String::String(const char* str) - : String(*new StringPrivate) -{ - Q_D(String); - d->str->setTo(str); -} - - - -shelllet::common::String& shelllet::common::String::append(const String& str) -{ - Q_D(String); - d->str->append(str.d_func()->str.operator*()); - return *this; -} - -bool shelllet::common::String::operator==(const String& str) const -{ - Q_D(const String); - return d->str == str.d_func()->str; -} - -shelllet::common::String shelllet::common::String::operator+(const String& str) const -{ - Q_D(const String); - - return std::move(clone().append(str)); -} - -bool shelllet::common::String::operator<(const String& str) const -{ - Q_D(const String); - return d->str < str.d_func()->str; -} - -std::string shelllet::common::String::toStdString() const -{ - Q_D(const String); - std::string result; - return std::move(d->str->toUTF8String(result)); -} - - -std::wstring shelllet::common::String::toStdWString() const -{ - Q_D(const String); - std::wstring wstr; - - int32_t requiredSize; - UErrorCode error = U_ZERO_ERROR; - - // obtain the size of string we need - u_strToWCS(nullptr, 0, &requiredSize, d->str->getBuffer(), d->str->length(), &error); - - // resize accordingly (this will not include any terminating null character, but it also doesn't need to either) - wstr.resize(requiredSize); - error = U_ZERO_ERROR; - - // copy the UnicodeString buffer to the std::wstring. - u_strToWCS(wstr.data(), wstr.size(), nullptr, d->str->getBuffer(), d->str->length(), &error); - - return wstr; -} - -QString* shelllet::common::String::toQString() const -{ - Q_D(const String); - static QString str; - str = QString::fromStdString(toStdString()); - return &str; -} - -const char16_t* shelllet::common::String::data() const -{ - Q_D(const String); - return d->str->getBuffer(); -} - -shelllet::common::String shelllet::common::String::clone() const -{ - Q_D(const String); - String temp; - temp.d_func()->str->setTo(*d->str->clone()); - return std::move(temp); -} - -shelllet::common::U8String shelllet::common::String::toUtf8() const -{ - Q_D(const String); - U8String temp; - d->str->toUTF8String(temp); - return temp; -} - - - -shelllet::common::String shelllet::common::String::subString(int32_t start, std::int32_t len) const -{ - Q_D(const String); - String temp; - temp.d_func()->str->setTo(d->str->tempSubString(start, len)); - return temp; -} - -shelllet::common::String shelllet::common::String::fromQString(const QString* str) -{ - return std::move(String(str->toStdString())); -} - -void shelllet::common::String::toLower() -{ - Q_D(String); - d->str->toLower(); -} - -int shelllet::common::String::toInt() const -{ - Q_D(const String); - return boost::lexical_cast(toUtf8()); -} - -shelllet::common::String shelllet::common::String::removeNamespace(const String& str) -{ - - auto pos = str.d_func()->str->lastIndexOf("::"); - if (pos == -1) - return str; - - String temp; - temp.d_func()->str->setTo(str.d_func()->str->tempSubString(pos + 2)); - - return std::move(temp); -} - -shelllet::common::Int32 shelllet::common::String::typeId() -{ - return qRegisterMetaType(); -} - -bool shelllet::common::String::isEquals(const char* ch1, const char* ch2) -{ - return std::strcmp(ch1, ch2) == 0; -} - -shelllet::common::String shelllet::common::String::toLower(const String& str) -{ - auto temp = const_cast(&str); - temp->toLower(); - return std::move(*temp); -} - -shelllet::common::String& shelllet::common::String::toLower(String&& str) -{ - str.toLower(); - return str; -} - -shelllet::common::String::String(const std::vector& v) - : String(*new StringPrivate) -{ - Q_D(String); - d->str->setTo(UnicodeString::fromUTF8(std::string(v.begin(), v.end()))); -} - -shelllet::common::String::String(const String& str) - : String(*new StringPrivate) -{ - Q_D(String); - d->str->setTo(str.d_func()->str.operator*()); -} - -shelllet::common::String::String() - : String(*new StringPrivate) -{ - -} - -shelllet::common::String::String(std::istream& stream) - : String(*new StringPrivate) -{ - Q_D(String); - d->str->setTo(UnicodeString::fromUTF8(std::string{ std::istreambuf_iterator(stream), std::istreambuf_iterator() })); -} -//shelllet::common::String::String(std::ifstream& stream) -// : Object(*new StringPrivate, nullptr) -//{ -// Q_D(String); -// d->str = { std::istreambuf_iterator(stream), std::istreambuf_iterator() }; -//} -shelllet::common::String::String(const std::string& str) - : String(*new StringPrivate) -{ - Q_D(String); - d->str->setTo(UnicodeString::fromUTF8(str)); -} - -shelllet::common::String::String(StringPrivate& d) - : Object(d, nullptr) -{ - d.str = std::make_unique(); - - if (!QMetaType::isRegistered(QMetaType::type(QUOTED(String)))) { - qRegisterMetaType(QUOTED(String)); - } -} - -//shelllet::common::String::operator std::string() const -//{ -// Q_D(const String); -// std::string result; -// return std::move(d->str->toUTF8String(result)); -//} - -shelllet::common::String& shelllet::common::String::operator=(const String& str) -{ - Q_D(String); - d->str->setTo(str.d_func()->str.operator*()); - - return *this; -} - - diff --git a/QtRpa/modules/common/src/worker_thread.cpp b/QtRpa/modules/common/src/worker_thread.cpp deleted file mode 100644 index bb01f40..0000000 --- a/QtRpa/modules/common/src/worker_thread.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "common.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include "events/message_output_event.h" - -WorkerThread::WorkerThread(const QString& src, QObject* object) - : QThread(object) - , source_dir_(src) -{ -} - -void WorkerThread::run() { -} \ No newline at end of file diff --git a/QtRpa/modules/common/src/xmlattribute.cpp b/QtRpa/modules/common/src/xmlattribute.cpp deleted file mode 100644 index f744c43..0000000 --- a/QtRpa/modules/common/src/xmlattribute.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "common/xmlattribute.h" -#include "pugixml.hpp" -#include "common/private/xmlattribute_p.h" -shelllet::common::XmlAttribute::XmlAttribute(XmlAttributePrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - -shelllet::common::XmlAttribute shelllet::common::XmlAttribute::from(const pugi::xml_attribute* attr) -{ - XmlAttribute temp; - temp.d_func()->attr.reset(new xml_attribute(*attr)); - return temp; -} - -shelllet::common::XmlAttribute& shelllet::common::XmlAttribute::operator=(const String& rhs) -{ - Q_D(XmlAttribute); - *d->attr = rhs.toUtf8(); - return *this; -} - -shelllet::common::XmlAttribute& shelllet::common::XmlAttribute::operator=(int32_t rhs) -{ - Q_D(XmlAttribute); - *d->attr = rhs; - return *this; -} - -shelllet::common::String shelllet::common::XmlAttribute::value() const -{ - Q_D(const XmlAttribute); - - return d->attr->value(); -} - -void shelllet::common::XmlAttribute::setValue(const String& rhs) -{ - Q_D(XmlAttribute); - d->attr->set_value(rhs.toUtf8()); -} - -shelllet::common::XmlAttribute::XmlAttribute(Object* parent /*= nullptr*/) - : XmlAttribute(*new XmlAttributePrivate, parent) -{ - -} diff --git a/QtRpa/modules/common/src/xmldocument.cpp b/QtRpa/modules/common/src/xmldocument.cpp deleted file mode 100644 index 9e343d9..0000000 --- a/QtRpa/modules/common/src/xmldocument.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include "common.hpp" -#include "pugixml.hpp" -#include "qsharedpointer.h" -#include "common/private/xmldocument_p.h" - -namespace shelllet { - namespace common { - using namespace pugi; - template - decltype(auto) __invoke__(const XmlDocumentPrivate* p, F fuc, TArgs&& ... args) { - if (std::holds_alternative>(p->node)) { - return (*std::get<1>(p->node).*fuc)(std::forward(args)...); - } - throw std::logic_error("The method or operation is not implemented."); - //return (*std::get<0>(p->node).*fuc)(std::forward(args)...); - } - std::ostream& operator<<(std::ostream& out, const XmlDocument& doc) - { - __invoke__(doc.d_func(), static_cast >& - , const char_t * - , unsigned int - , pugi::xml_encoding encoding - , unsigned int - ) const>(&pugi::xml_document::print), out, "\t", pugi::format_default, pugi::encoding_auto, 0); - return out; - } - - - } -} - - -shelllet::common::XmlDocument::XmlDocument(Object* parent/* = nullptr*/) - :XmlDocument(*new XmlDocumentPrivate, parent) -{ - -} - -shelllet::common::XmlNode shelllet::common::XmlDocument::documentElement() const -{ - Q_D(const XmlDocument); - auto node = __invoke__(d, &pugi::xml_document::document_element); - return XmlNode::from(&node); -} - -void shelllet::common::XmlDocument::addDeclaration() -{ - Q_D(XmlDocument); - pugi::xml_node decl = __invoke__(d, static_cast(&pugi::xml_document::append_child), pugi::node_declaration); - decl.append_attribute("version") = "1.0"; - decl.append_attribute("encoding") = "utf-8"; - decl.append_attribute("standalone") = "yes"; -} - -void shelllet::common::XmlDocument::loadFile(const Path& path) -{ - Q_D(XmlDocument); - - - pugi::xml_parse_result result = __invoke__(d, static_cast(&pugi::xml_document::load_file) - , path.toString().toUtf8() - , pugi::parse_default - , pugi::encoding_auto - ); - - if (!result) - { - LOG_WARNING(PROJECT_NAME) << "# error description: " << result.description() << "\n" - << "error offset: " << result.offset << " (error at " << result.offset << ".\n\n"; - } -} - -void shelllet::common::XmlDocument::print(std::ostream& stream) -{ - Q_D(XmlDocument); - stream << *this; -} - -shelllet::common::XmlDocument::XmlDocument(const Path& p, Object* parent /*= nullptr*/) - : XmlDocument(*new XmlDocumentPrivate, parent) -{ - loadFile(p); -} - -shelllet::common::XmlDocument::XmlDocument(XmlDocumentPrivate& d, Object* parent/* = nullptr*/) - : XmlNode(d, parent) -{ - d.node = std::make_shared(); -} \ No newline at end of file diff --git a/QtRpa/modules/common/src/xmlnode.cpp b/QtRpa/modules/common/src/xmlnode.cpp deleted file mode 100644 index 96223f0..0000000 --- a/QtRpa/modules/common/src/xmlnode.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include "common.hpp" -#include "pugixml.hpp" -#include "common/xmlnodeiterator.h" -#include "common/private/xmlnode_p.h" - - -namespace shelllet { - namespace common { - template - decltype(auto) __invoke__(const XmlNodePrivate* p, F fuc, TArgs&& ... args) { - if (std::holds_alternative>(p->node)) { - return (*std::get<0>(p->node).*fuc)(std::forward(args)...); - } - return (*std::get<1>(p->node).*fuc)(std::forward(args)...); - } - std::ostream& operator<<(std::ostream& out, const XmlNode& node) - { - __invoke__(node.d_func(), static_cast >& - , const char* - , unsigned int - , pugi::xml_encoding - , unsigned int) const>(&pugi::xml_node::print), out, "\t", pugi::format_default, pugi::encoding_auto, 0); - return out; - } - - - } -} - - - - -shelllet::common::XmlNode shelllet::common::XmlNode::appendChild(XmlNodeType type/*= XmlNodeType::Element*/) -{ - Q_D(XmlNode); - __invoke__(d, static_cast(&pugi::xml_node::append_child), static_cast(type)); - return *this; -} - - -void shelllet::common::XmlNode::setValue(const String& value) -{ - Q_D(XmlNode); - __invoke__(d, &pugi::xml_node::set_value, value.toUtf8()); -} - -bool shelllet::common::XmlNode::setName(const String& name) -{ - Q_D(XmlNode); - return __invoke__(d, &pugi::xml_node::set_name, name.toUtf8()); -} - -shelllet::common::XmlNode shelllet::common::XmlNode::appendChild(const String& name) -{ - Q_D(XmlNode); - auto node = __invoke__(d, static_cast(&pugi::xml_node::append_child), name.toUtf8()); - - return XmlNode::from(&node); -} - -shelllet::common::XmlNode shelllet::common::XmlNode::appendCopy(const XmlNode& proto) -{ - Q_D(XmlNode); - auto node = __invoke__(d, static_cast(&pugi::xml_node::append_copy), *std::get<0>(proto.d_func()->node)); - return XmlNode::from(&node); -} - -shelllet::common::XmlAttribute shelllet::common::XmlNode::appendAttribute(const String& name) -{ - Q_D(XmlNode); - auto attr = __invoke__(d, &pugi::xml_node::append_attribute, name.toUtf8()); - return XmlAttribute::from(&attr); -} - -shelllet::common::XmlAttribute shelllet::common::XmlNode::attribute(const String& name) const -{ - Q_D(const XmlNode); - auto temp = __invoke__(d, static_cast(&pugi::xml_node::attribute), name.toUtf8()); - return XmlAttribute::from(&temp); -} - -shelllet::common::XmlNode shelllet::common::XmlNode::parent() const -{ - Q_D(const XmlNode); - auto temp = __invoke__(d, &pugi::xml_node::parent); - return XmlNode::from(&temp); -} - -shelllet::common::XmlNodeRange shelllet::common::XmlNode::children() const -{ - Q_D(const XmlNode); - - return XmlNodeRange< XmlNodeIterator>(begin(), end()); - -} - -shelllet::common::String shelllet::common::XmlNode::name() const -{ - Q_D(const XmlNode); - return __invoke__(d, &pugi::xml_node::name); -} - -shelllet::common::XmlNodeType shelllet::common::XmlNode::type() const -{ - Q_D(const XmlNode); - return static_cast(__invoke__(d, &pugi::xml_node::type)); -} - -shelllet::common::XmlNodeIterator shelllet::common::XmlNode::begin() const -{ - Q_D(const XmlNode); - auto temp = __invoke__(d, &pugi::xml_node::begin); - return XmlNodeIterator::from(&temp); -} - -shelllet::common::XmlNodeIterator shelllet::common::XmlNode::end() const -{ - Q_D(const XmlNode); - auto temp = __invoke__(d, &pugi::xml_node::end); - return XmlNodeIterator::from(&temp); -} - -shelllet::common::XmlNode& shelllet::common::XmlNode::operator=(const XmlNode& node) -{ - Q_D(XmlNode); - - std::get<0>(d->node).reset(new pugi::xml_node(*std::get<0>(node.d_func()->node))); - return *this; -} - -shelllet::common::XmlNode::XmlNode(const XmlNode& node, Object* parent/* = nullptr*/) - : XmlNode(*new XmlNodePrivate, parent) -{ - Q_D(XmlNode); - std::get<0>(d->node).reset(new pugi::xml_node(*std::get<0>(node.d_func()->node))); -} - - - -shelllet::common::XmlNode::XmlNode(Object* parent /*= nullptr*/) - : XmlNode(*new XmlNodePrivate, parent) -{ - -} - -shelllet::common::XmlNode::XmlNode(XmlNodePrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - d.node = std::make_shared(); -} - -shelllet::common::XmlNode shelllet::common::XmlNode::from(const pugi::xml_node* n) -{ - XmlNode node; - std::get<0>(node.d_func()->node).reset(new pugi::xml_node(*n)); - return node; -} diff --git a/QtRpa/modules/common/src/xmlnodeiterator.cpp b/QtRpa/modules/common/src/xmlnodeiterator.cpp deleted file mode 100644 index 38f1a9c..0000000 --- a/QtRpa/modules/common/src/xmlnodeiterator.cpp +++ /dev/null @@ -1,91 +0,0 @@ -#include "pugixml.hpp" -#include "common/xmlnodeiterator.h" -#include "common/private/xmlnode_p.h" -#include "common/private/xmlnodeiterator_p.h" - -shelllet::common::XmlNodeIterator::XmlNodeIterator(Object* parent /*= nullptr*/) - : XmlNodeIterator(*new XmlNodeIteratorPrivate, parent) -{ - -} - -const shelllet::common::XmlNodeIterator& shelllet::common::XmlNodeIterator::operator++() -{ - Q_D(XmlNodeIterator); - d->iter->operator++(); - return *this; -} - -const shelllet::common::XmlNodeIterator& shelllet::common::XmlNodeIterator::operator--() -{ - Q_D(XmlNodeIterator); - d->iter->operator--(); - return *this; -} - -shelllet::common::XmlNodeIterator shelllet::common::XmlNodeIterator::from(pugi::xml_node_iterator* iter) -{ - XmlNodeIterator temp; - temp.d_func()->iter.reset(new xml_node_iterator(*iter)); - return temp; -} - -shelllet::common::XmlNodeIterator shelllet::common::XmlNodeIterator::operator--(int) -{ - Q_D(XmlNodeIterator); - d->iter->operator--(0); - return *this; -} - -shelllet::common::XmlNodeIterator shelllet::common::XmlNodeIterator::operator++(int) -{ - Q_D(XmlNodeIterator); - d->iter->operator++(0); - return *this; -} - -bool shelllet::common::XmlNodeIterator::operator!=(const XmlNodeIterator& rhs) const -{ - Q_D(const XmlNodeIterator); - return *d->iter != *rhs.d_func()->iter; -} - -bool shelllet::common::XmlNodeIterator::operator==(const XmlNodeIterator& rhs) const -{ - Q_D(const XmlNodeIterator); - return *d->iter == *rhs.d_func()->iter; -} - -shelllet::common::XmlNode& shelllet::common::XmlNodeIterator::operator*() const -{ - Q_D(const XmlNodeIterator); - d->node = XmlNode::from(d->iter->operator ->()); - return d->node; -} - -shelllet::common::XmlNode* shelllet::common::XmlNodeIterator::operator->() const -{ - Q_D(const XmlNodeIterator); - d->node = XmlNode::from(d->iter->operator ->()); - return &d->node; -} - -shelllet::common::XmlNodeIterator::XmlNodeIterator(const XmlNode& node, Object* parent /*= nullptr*/) - : XmlNodeIterator(*new XmlNodeIteratorPrivate, parent) -{ - Q_D(XmlNodeIterator); - d->iter.reset(new xml_node_iterator(*std::get<0>(node.d_func()->node))); -} - -shelllet::common::XmlNodeIterator::XmlNodeIterator(const XmlNodeIterator& iter, Object* parent /*= nullptr*/) - : XmlNodeIterator(*new XmlNodeIteratorPrivate, parent) -{ - Q_D(XmlNodeIterator); - d->iter.reset(new xml_node_iterator(*iter.d_func()->iter)); -} - -shelllet::common::XmlNodeIterator::XmlNodeIterator(XmlNodeIteratorPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} diff --git a/QtRpa/modules/common/src/zip_entry.cpp b/QtRpa/modules/common/src/zip_entry.cpp deleted file mode 100644 index 1860041..0000000 --- a/QtRpa/modules/common/src/zip_entry.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "common.hpp" -//zip_entry::zip_entry(int titleBarHeight) : -// m_titleBarHeight(titleBarHeight) -//{ -// //m_closeElement -// // = juce::parseXML(R"( -// // -// // -// // -// //)"); -//} - -//juce::Button* nametls::core::LookAndFeel_V5::createDocumentWindowButton(int buttonType) -//{ - // if (buttonType == DocumentWindow::maximiseButton) { - // XmlElement * element = XmlDocument::parse(R"( - // - // - // - //)"); - // ; - - // DrawableButton *button = new DrawableButton("msc", DrawableButton::ImageRaw); - - // button->setImages(Drawable::createFromSVG(*element)); - - // delete element; - - // return button; - // } - // else if (buttonType == DocumentWindow::minimiseButton) { - // XmlElement * element = XmlDocument::parse(R"( - // - // - // - //)"); - // ; - - // DrawableButton *button = new DrawableButton("min", DrawableButton::ImageRaw); - - // button->setImages(Drawable::createFromSVG(*element)); - - // delete element; - - // return button; - // } - -// return 0; -//} - -//juce::Typeface::Ptr nametls::core::LookAndFeel_V5::getTypefaceForFont(const Font&font) -//{ -// juce::String locale = juce::SystemStats::getDisplayLanguage(); -// -// if (locale == "zh-CN") { -// juce::Font f(font); -// f.setTypefaceName("MSYH"); -// return juce::Typeface::createSystemTypefaceFor(f); -// } -// -// return __super::getTypefaceForFont(font); -//} - -//void nametls::core::LookAndFeel_V5::drawDocumentWindowTitleBar(DocumentWindow&, Graphics&g, int, int, int, int, const Image*, bool) -//{ -// g.fillAll(Colour(222, 225, 230)); -//} \ No newline at end of file diff --git a/QtRpa/modules/creator/CMakeLists.txt b/QtRpa/modules/creator/CMakeLists.txt deleted file mode 100644 index 422847d..0000000 --- a/QtRpa/modules/creator/CMakeLists.txt +++ /dev/null @@ -1,167 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) - -cmake_policy(SET CMP0091 NEW) -project(creator) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - - -set(LLVM_SDK $ENV{LLVM_SDK}) -#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/property_browser PROPERTY_BROWSER) -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -aux_source_directory(${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME} HEADERS) -# graphics -#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/graphics SRC_GRAPHICS) - -#file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - - -file(GLOB ROOT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/resource_file.rc) - -file(GLOB WIZARD_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/wizard/*.cpp) -file(GLOB CREATOR_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/creator/*.cpp) -file(GLOB EVENTS_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/events/*.cpp) -file(GLOB COMMON_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/common/*.cpp) -file(GLOB PROPERTY_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/properties/*.cpp) -file(GLOB ACTIVITIES_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/activities/*.cpp) -file(GLOB EXTENSION_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/extension/*.cpp) -file(GLOB DATABASE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/database/*.cpp) -file(GLOB MODEL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/model/*.cpp) - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/engine ENGINE) - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - -add_compile_options(/FC) -add_compile_options(/wd4309 /wd4996 /wd4244 /wd4267 /wd4251 /wd4624) - -#qt5_add_resources(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/resource_file.rc) - -add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS} - ${INC_GRAPHICS} ${SRC_GRAPHICS} - ${ROOT_FILES} - #${PROPERTY_BROWSER} - ${WIZARD_FILES} - ${CREATOR_FILES} - ${PROPERTY_FILES} - ${PROPERTIES_FILES} - ${EVENTS_FILES} - ${COMMON_FILES} - ${ACTIVITIES_FILES} - ${EXTENSION_FILES} - ${DATABASE_FILES} - ${MODEL_FILES} - ${PROPERTY_BROWSER_FILES} - ${SCINTILLA_FILES} - ${ENGINE} -) - -find_package(Boost REQUIRED COMPONENTS serialization log) -#find_package(Tesseract CONFIG REQUIRED) -find_package(Qt5Sql CONFIG REQUIRED) -#find_package(sqlite3 CONFIG REQUIRED) -find_package(yaml-cpp CONFIG REQUIRED) -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Qt5Websockets CONFIG REQUIRED) -find_package(Qt5SerialBus CONFIG REQUIRED) -find_package(pugixml CONFIG REQUIRED) -find_package(libzip CONFIG REQUIRED) -find_package(OpenCV CONFIG REQUIRED) -find_package(unofficial-breakpad CONFIG REQUIRED) -find_package(Clang CONFIG REQUIRED) -find_package(LLVM CONFIG REQUIRED) -find_package(V8 CONFIG REQUIRED) -find_package(BZip2 REQUIRED) -find_package(libzippp CONFIG REQUIRED) -find_package(Qt5Svg CONFIG REQUIRED) - -if(PORT MATCHES "Boost") - set(VCPKG_LIBRARY_LINKAGE static) -endif() - -# https://vcpkg.readthedocs.io/en/latest/examples/installing-and-using-packages/ -find_path(BOOST_ASIO_INCLUDE_DIRS "boost/asio.hpp") -find_path(BOOST_BEAST_INCLUDE_DIRS "boost/beast.hpp") -#find_package(v8 CONFIG REQUIRED) -#file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/internal/*.h) - - - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR}/third-party/v8/include/ - ${Boost_INCLUDE_DIRS} - ${Tesseract_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} - ${OpenCV_INCLUDE_DIRS} - ${LLVM_SDK}/clang/include - ${LLVM_SDK}/llvm/include - ${LLVM_SDK}/build_ninja/include - ${LLVM_SDK}/build_ninja/tools/clang/include -) - - - - -#add_definitions(-DBOOST_ALL_DYN_LINK) - - -target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _WIN32_WINNT=0x0601) - - -target_link_directories(${PROJECT_NAME} PRIVATE ${LLVM_SDK}/build_ninja/lib) - - -target_link_libraries(${PROJECT_NAME} PRIVATE DXGI D3D11 ws2_32.lib - ${OpenCV_LIBS} - ${Boost_LIBRARIES} - ${YAML_CPP_LIBRARIES} - unofficial::breakpad::libbreakpad unofficial::breakpad::libbreakpad_client - #opencv_world - Qt::Widgets Qt5::WidgetsPrivate #Qt5::QWindowsVistaStylePlugin - Qt::WebSockets #Qt5::WebsocketsPrivate #Qt5::QWindowsVistaStylePlugin - Qt::SerialBus #Qt5::SerialBusPrivate #Qt5::PeakCanBusPlugin Qt5::TinyCanBusPlugin - Qt::Sql - pugixml - #libzip::zip - libzip::zip libzippp::libzippp - common - model - #properties - #graphics - events - frameless - wizard - property - - #Qt5::QSvgPlugin Qt5::QSvgIconPlugin - Qt::Svg #Qt5::Svg Qt::SvgPrivate Qt5::SvgPrivate - #V8::V8 - #clangBasic - #clangFormat - #clangRewrite - #clangToolingCore - #clangToolingInclusions - #clangLex - #LLVMCore LLVMSupport LLVMRemarks LLVMBitstreamReader LLVMBinaryFormat - interpreter - #scintilla - - clangAST clangLex libclang clangEdit - LTO LLVMMC LLVMLTO LLVMMCA -) - - - - - -#file(COPY ${SCINTILLA_ROOT}/bin/SciLexer.dll DESTINATION ${CMAKE_BINARY_DIR}) -file(COPY ${CMAKE_SOURCE_DIR}/assets DESTINATION ${CMAKE_BINARY_DIR}) - - diff --git a/QtRpa/modules/creator/src/application.cpp b/QtRpa/modules/creator/src/application.cpp deleted file mode 100644 index 68fff1c..0000000 --- a/QtRpa/modules/creator/src/application.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include -#include "creator/application.h" -#include "creator/private/application_p.h" -#include "events.hpp" -#include "interpreter.hpp" -#include "creator/gui_application.h" -#include "interpreter/consoleapplication.h" -namespace shelllet { - namespace creator { - - } -} -shelllet::creator::ApplicationPrivate::__Application::__Application(shelllet::creator::Application* self, int& argc, char** argv) - : QApplication(argc, argv) - , self(self) -{ - -} - -void shelllet::creator::ApplicationPrivate::__Application::customEvent(QEvent* event) -{ - self->customEvent(event); -} - -shelllet::creator::Application::Application(ApplicationPrivate& d, int& argc, char** argv, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - - d.app = std::make_unique(this, argc, argv); -} - -void shelllet::creator::Application::customEvent(QEvent* event) -{ - - if (auto* e = dynamic_cast(event)) { - ConsoleApplication::getInstance()->initialize(); - ConsoleApplication::getInstance()->run(e); - } - else if (dynamic_cast(event)) { - ConsoleApplication::getInstance()->initialize(); - GuiApplication::getInstance()->run(e); - } -} - -void shelllet::creator::Application::setWindowIcon(const QIcon& icon) -{ - Q_D(Application); - d->app->setWindowIcon(icon); -} - -void shelllet::creator::Application::setQuitOnLastWindowClosed(bool quit) -{ - Q_D(Application); - d->app->setQuitOnLastWindowClosed(quit); -} - -QApplication* shelllet::creator::Application::toQApplication() const -{ - Q_D(const Application); - return d->app.operator ->(); -} - -shelllet::creator::Application::Application(int& argc, char** argv, Object* parent /*= nullptr*/) - :Application(*new ApplicationPrivate, argc, argv, parent) -{ -} diff --git a/QtRpa/modules/creator/src/command_event_about.cpp b/QtRpa/modules/creator/src/command_event_about.cpp deleted file mode 100644 index 6ccd6c4..0000000 --- a/QtRpa/modules/creator/src/command_event_about.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "creator.hpp" -#include "creator/command_event_about.h" -#include "creator/about_window.h" -void shelllet::creator::About::messageCallback(Callback* call) -{ - auto* parent = dynamic_cast(call); - - auto * about = new AboutWindow(parent); - about->setAttribute(Qt::WA_DeleteOnClose); - about->show(); -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/command_event_exec.cpp b/QtRpa/modules/creator/src/command_event_exec.cpp deleted file mode 100644 index 6fa976d..0000000 --- a/QtRpa/modules/creator/src/command_event_exec.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "creator.hpp" -void shelllet::creator::Exec::messageCallback(Callback* call) -{ - call->callbk(this, 0); -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/command_event_new.cpp b/QtRpa/modules/creator/src/command_event_new.cpp deleted file mode 100644 index 06e4f2a..0000000 --- a/QtRpa/modules/creator/src/command_event_new.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "creator.hpp" -#include "common.hpp" -#include -#include -#include -#include -#include -#include -#include - - -namespace shelllet { - //using namespace libzippp; -} -void shelllet::creator::New::messageCallback(Callback* call) -{ - auto* parent = dynamic_cast(call); - - //auto fmt = boost::format("%1% (*%2%)") % QObject::tr("Project File").toStdString() % common::Environment::getInstance()->getOptions()->pkg_extension.toStdString(); - - auto fileName = QFileDialog::getSaveFileName(parent, QObject::tr("Save File"), QString::fromStdString(common::Environment::getInstance()->storagePath().string())); - - if (fileName.isEmpty()) - return; - Path file = String::fromQString(&fileName); - - std::filesystem::create_directories(file); - std::filesystem::create_directory(file / Environment::getInstance()->getPkgSrcName()); - YAML::Emitter config; - { - config << YAML::BeginMap; - config << YAML::Key << "name"; - config << YAML::Value << file.fileName(); - - config << YAML::Key << "created"; - config << YAML::Value << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss").toStdString(); - - config << YAML::EndMap; - - std::ofstream ss(file / Environment::getInstance()->getOptions()->config_filename.toStdString()); - ss << config.c_str(); - - } - std::string readme = "# description"; - { - - std::ofstream ss(file / "README.md"); - ss << readme; - } - - //std::string code = ""; - { - //XmlDocument doc; - //doc.addDeclaration(); - ///AddDocumentElement(doc); - - // auto prop = Helper::createRoot(); - - //auto* sequence = new PropParser(); - - //doc.appendCopy(std::make_unique()->getNode()->documentElement()); - - /*std::stringstream stream; - doc.print(stream); - xml = stream.str();*/ - - ; - - File::copy(Environment::getInstance()->getTemplatePath() / Environment::getInstance()->getIndexFileName(), - file / Environment::getInstance()->indexXmlPath()); - } - - - - call->callbk(this, 1, file); -} diff --git a/QtRpa/modules/creator/src/command_event_open.cpp b/QtRpa/modules/creator/src/command_event_open.cpp deleted file mode 100644 index 71bd1ee..0000000 --- a/QtRpa/modules/creator/src/command_event_open.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "common.hpp" -#include "creator.hpp" - -#include "qwidget.h" -#include -#include -#include - -void shelllet::creator::Open::messageCallback(Callback* call) -{ - auto* parent = dynamic_cast(call); - //auto fmt = boost::format("%1% (*%2%)") % QObject::tr("Project File").toStdString() % common::Environment::getInstance()->getOptions()->pkg_extension.toStdString(); - QString fileName = QFileDialog::getExistingDirectory(parent, QObject::tr("Open File"), QString::fromStdString(common::Environment::getInstance()->storagePath().string()), - QFileDialog::ShowDirsOnly - | QFileDialog::DontResolveSymlinks); - - if (!fileName.isEmpty()) - { - Path fullName = String::fromQString(&fileName); - - call->callbk(this, 1, fullName); - } -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/command_event_save.cpp b/QtRpa/modules/creator/src/command_event_save.cpp deleted file mode 100644 index 1ff9d88..0000000 --- a/QtRpa/modules/creator/src/command_event_save.cpp +++ /dev/null @@ -1,8 +0,0 @@ - -#include "creator.hpp" - -void shelllet::creator::Save::messageCallback(Callback* call) -{ - call->callbk(this, 0); - //ActionProjectSaveBroadcaster::getInstance()->emit(); -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/component.cpp b/QtRpa/modules/creator/src/component.cpp deleted file mode 100644 index 4ce67fc..0000000 --- a/QtRpa/modules/creator/src/component.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include -#include "property.hpp" -#include "interpreter.hpp" -#include "creator/component.h" -#include "events/activity_select_event.h" -#include "events/common_event.h" - -shelllet::creator::properties_component::properties_component(QWidget* parent) - : QWidget(parent) -{ - auto* layout = new QVBoxLayout; - browser_ = new PropertyBrowser(this); - layout->addWidget(browser_); - setLayout(layout); - - events::EventDispatcher::Dispatcher()->push(this); -} - -shelllet::creator::properties_component::~properties_component() -{ -} - -///void properties_component::updateProperty(const std::shared_ptr& property) -//{ - //String name = property->getUniqueName(); - - //if (global_activities.count(name.toRawUTF8())) - //{ - //display_.reset(global_activities[name.toRawUTF8()](db_, property)); - - //display_->display(); - //} -//} - -void shelllet::creator::properties_component::variable_changed(int action, const std::string& old_name, const std::string& new_name) -{ - //display_->variable_changed(action, old_name, new_name); -} - -void shelllet::creator::properties_component::customEvent(QEvent* event) -{ - if (event->type() == events::ActivitySelectEvent::Type) { - auto* e = dynamic_cast(event); - - browser_->clear(); - - auto p = e->getProp(); - if (p) { - for (auto* prop : p->getProp(browser_)) { - if (prop) - browser_->addProperty(prop); - } - - browser_->addProperty(e->getProp()->getInput(browser_)); - browser_->addProperty(e->getProp()->getOutput(browser_)); - browser_->addProperty(e->getProp()->getMisc(browser_)); - } - } -} - - - -QSize shelllet::creator::properties_component::sizeHint() const -{ - QSize size = __super::sizeHint(); - size.setWidth(size.width() * 0.7); - return size; -} diff --git a/QtRpa/modules/creator/src/creator/about_window.cpp b/QtRpa/modules/creator/src/creator/about_window.cpp deleted file mode 100644 index ebc9c06..0000000 --- a/QtRpa/modules/creator/src/creator/about_window.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "common.hpp" -#include -#include -#include -#include -#include -#include -#include -#include "creator/about_window.h" -#include "common/path.h" - -shelllet::creator::AboutWindow::AboutWindow(QWidget* parent /*= nullptr*/) - : MainWindow(parent, WindowType::CloseButtonHint) -{ - auto* centralWidget = new QWidget; - - auto* layout = new QHBoxLayout(centralWidget); - auto* background = new QLabel; - background->setPixmap(Environment::getInstance()->pixmap("/photo.jpg")); - background->setScaledContents(true); - layout->addWidget(background); - - auto* vlay = new QVBoxLayout; - auto* textEdit = new QTextEdit(centralWidget); - - textEdit->setEnabled(false); - - textEdit->setHtml(tr("\n" - "\n" - "

Studio - Robot

\n" - "


\n" - "

Version: 0.5.0

\n" - "

Url: http://shelllet.com

")); - textEdit->setFixedWidth(240); - vlay->addWidget(textEdit); - layout->addLayout(vlay); - - setFixedSize(600, 420); - - setCentralWidget(centralWidget); -} - -shelllet::creator::AboutWindow::~AboutWindow() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/activities_search_widget.cpp b/QtRpa/modules/creator/src/creator/activities_search_widget.cpp deleted file mode 100644 index 0df94a2..0000000 --- a/QtRpa/modules/creator/src/creator/activities_search_widget.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "common.hpp" -#include -#include -#include "activities_search_widget.h" -#include "model/activities_dom_item.h" -#include "events/activity_create_event.h" -#include "events/common_event.h" -#include "private/qwidget_p.h" - -using namespace shelllet::creator; -namespace shelllet { - namespace creator { - class ActivitiesSearchWidgetPrivate : public QWidgetPrivate { - public: - ActivitiesSearchInputWidget* lineEdit = nullptr; - ActivitiesSearchViewWidget* treeView = nullptr; - - void setupUi(ActivitiesSearchWidget *self) { - lineEdit = new ActivitiesSearchInputWidget(self); - treeView = new ActivitiesSearchViewWidget(self); - - self->setLayout(new QVBoxLayout); - - self->layout()->addWidget(lineEdit); - self->layout()->addWidget(treeView); - self->layout()->setContentsMargins(1, 1, 1, 1); - } - }; - } -} -ActivitiesSearchWidget::ActivitiesSearchWidget(QWidget* parent) - : QWidget(*new ActivitiesSearchWidgetPrivate, parent, {}) - -{ - Q_D(ActivitiesSearchWidget); - d->setupUi(this); - connect(d->treeView, &QAbstractItemView::doubleClicked, this, &ActivitiesSearchWidget::itemDoubleClicked); -} - -ActivitiesSearchWidget::~ActivitiesSearchWidget() -{ -} - -void ActivitiesSearchWidget::itemDoubleClicked(const QModelIndex& index) -{ - const auto* item = static_cast(index.internalPointer()); - auto meta = item->node().attribute("meta").value(); - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::ActivityCreateEvent(meta)); -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/activities_search_widget.h b/QtRpa/modules/creator/src/creator/activities_search_widget.h deleted file mode 100644 index 3cc3f5f..0000000 --- a/QtRpa/modules/creator/src/creator/activities_search_widget.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include -#include "search_input_widget.h" -#include "search_view_widget.h" - -namespace shelllet::creator { - class ActivitiesSearchWidgetPrivate; - class ActivitiesSearchWidget : public QWidget - { - Q_DECLARE_PRIVATE(ActivitiesSearchWidget) - public: - ActivitiesSearchWidget(QWidget* parent = nullptr); - ~ActivitiesSearchWidget(); - - public slots: - void itemDoubleClicked(const QModelIndex& index); - - protected: - - private: - - }; -} diff --git a/QtRpa/modules/creator/src/creator/creator_panel.cpp b/QtRpa/modules/creator/src/creator/creator_panel.cpp deleted file mode 100644 index fb88fb8..0000000 --- a/QtRpa/modules/creator/src/creator/creator_panel.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "creator.hpp" -#include "common.hpp" -#include "creator_panel.h" -#include -#include -#include -#include "left_panel.h" -#include "view_panel.h" -#include "output_panel.h" -#include "creator/component.h" -#include "database/db.h" -#include "events/message_output_event.h" - -namespace shelllet { - - namespace creator { - class HideBar : public QWidget { - - public: - QSize sizeHint() const override - { - return QSize(0, 0); - } - - - QSize minimumSizeHint() const override - { - return QSize(0, 0); - } - ~HideBar() { LOG_DEBUG("rpa") << "# ~HideBar." << std::endl; } - }; - } -} - - -shelllet::creator::CreatorPanel::CreatorPanel(QWidget* parent) - : QMainWindow(parent, Qt::Widget) -{ - //addAndMakeVisible(toolbar_); - /*QPalette pal; - pal.setColor(QPalette::Background, Qt::black); - setAutoFillBackground(true); - setPalette(pal);*/ - auto* toolbar = addToolBar("action"); - toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - toolbar->addAction(Environment::getInstance()->getIconByName("new"), "new", [this]() { New::messageCallback(this); }); - toolbar->addAction(Environment::getInstance()->getIconByName("open"), "open", [this]() { Open::messageCallback(this); }); - toolbar->addAction(Environment::getInstance()->getIconByName("save"), "save", [this]() { Save::messageCallback(this); }); - toolbar->addAction(Environment::getInstance()->getIconByName("exec"), "exec", [this]() { Exec::messageCallback(this); }); - toolbar->addAction(Environment::getInstance()->getIconByName("about"), "about", [this]() { About::messageCallback(this); }); - //toolbar->addAction(QIcon(":/new/toolbar/assets/icons/help.svg"), "new", this, &New::messageCallback); - - //addAndMakeVisible(m_right); - - //getTopLevelComponent()->addKeyListener(global::global_command::get_mutable_instance().getKeyMappings()); - - /*m_explorer.onDoubleClicked = std::bind(&component_right_project::openTab, - &m_right, std::placeholders::_1);*/ - - /*m_right.addListener(std::bind(&project::component_explorer_project::handleContentChangedEvent, - std::ref(m_explorer), std::placeholders::_1, std::placeholders::_2));*/ - - //global::global_event::get_mutable_instance().connect_files_dropped(std::bind(&component_content_project::fileDrops, - // this, std::placeholders::_1)); - - - panel[0] = new HideBar; - panel[1] = new HideBar; - panel[2] = new HideBar; - - setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - //setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); - //setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); - - QDockWidget* leftDock = new QDockWidget("", this); - leftDock->setAllowedAreas(Qt::LeftDockWidgetArea); - leftDock->setWidget(new LeftPanel); - leftDock->setTitleBarWidget(panel[0]); - leftDock->setFeatures(QDockWidget::NoDockWidgetFeatures); - addDockWidget(Qt::LeftDockWidgetArea, leftDock); - - QDockWidget* rightDock = new QDockWidget("", this); - rightDock->setAllowedAreas(Qt::RightDockWidgetArea); - rightDock->setWidget(new properties_component); - rightDock->setTitleBarWidget(panel[1]); - rightDock->setFeatures(QDockWidget::NoDockWidgetFeatures); - addDockWidget(Qt::RightDockWidgetArea, rightDock); - - setCentralWidget(new ViewPanel(this)); - - QDockWidget* bottomDock = new QDockWidget("", this); - bottomDock->setAllowedAreas(Qt::BottomDockWidgetArea); - bottomDock->setWidget(new OutputPanel); - bottomDock->setTitleBarWidget(panel[2]); - bottomDock->setFeatures(QDockWidget::NoDockWidgetFeatures); - addDockWidget(Qt::BottomDockWidgetArea, bottomDock); -} - -shelllet::creator::CreatorPanel::~CreatorPanel() -{ - qDeleteAll(panel); -} - -void shelllet::creator::CreatorPanel::callbk(shelllet::creator::CallbackMessage* callback, int num, ...) -{ - va_list arguments; - va_start(arguments, num); - QList widgets; - - for (auto* dock : findChildren()) { - widgets.append(dock->widget()); - } - - widgets.append(centralWidget()); - - if (dynamic_cast(callback) != nullptr || - dynamic_cast(callback) != nullptr) { - Path currentFile = va_arg(arguments, Path); - common::Environment::getInstanceRef()->setCurrentFilePath(currentFile); - for (auto w : widgets) - { - if (auto* serialization = dynamic_cast(w)) - { - serialization->load(common::Environment::getInstance()->indexXmlPath()); - } - } - } - else if (dynamic_cast(callback) != nullptr) - { - for (auto w : widgets) - { - if (auto* serialization = dynamic_cast(w)) { - if (!Environment::getInstance()->getCurrentProjectPath().isEmpty()) - serialization->save(Environment::getInstance()->getCurrentProjectPath()); - } - } - } - else if (dynamic_cast(callback) != nullptr) { - std::thread t([this]() { exec(); }); - t.detach(); - } - - va_end(arguments); -} - -void shelllet::creator::CreatorPanel::exec() -{ - - QProcess process; - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - - process.setProcessEnvironment(env); - connect(&process, &QProcess::readyReadStandardError, [&]() { - QTextCodec* codec = QTextCodec::codecForName("UTF-8"); - auto fmt = boost::format("[%1%]: %2%") % Environment::getInstance()->getCurrentProjectPath() % codec->toUnicode(process.readAllStandardError()).toStdString(); - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - }); - - connect(&process, &QProcess::readyReadStandardOutput, [&]() { - QTextCodec* codec = QTextCodec::codecForName("UTF-8"); - auto fmt = boost::format("[%1%]: %2%") % Environment::getInstance()->getCurrentProjectPath() % codec->toUnicode(process.readAllStandardOutput()).toStdString(); - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - }); - - connect(&process, &QProcess::errorOccurred, [&](QProcess::ProcessError error) { - if (error == QProcess::FailedToStart) { - auto fmt = boost::format("[%1%]: %2%") % Environment::getInstance()->getCurrentProjectPath() % "failed to start"; - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - } - else if (error == QProcess::Crashed) { - auto fmt = boost::format("[%1%]: %2%") % Environment::getInstance()->getCurrentProjectPath() % "crash"; - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - } - else if (error == QProcess::Timedout) { - auto fmt = boost::format("[%1%]: %2%") % Environment::getInstance()->getCurrentProjectPath() % "timeout"; - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - } - else if (error == QProcess::ReadError) { - auto fmt = boost::format("[%1%]: %2%") % Environment::getInstance()->getCurrentProjectPath() % "read error"; - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - } - else { - auto fmt = boost::format("[%1%]: %2%") % Environment::getInstance()->getCurrentProjectPath() % "unknown error"; - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - } - }); - - connect(&process, QOverload::of(&QProcess::finished), - [&](int, QProcess::ExitStatus exitStatus) { - auto fmt = boost::format("[%1%]: exit with %2%") % Environment::getInstance()->getCurrentProjectPath() % exitStatus; - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent(fmt.str())); - } - ); - - process.start(QCoreApplication::applicationFilePath(), { "--interpreter=true", *Environment::getInstance()->getCurrentProjectPath().toString().toQString() }); - process.waitForFinished(-1); - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::MessageOutputEvent("#->Exit.")); -} - -void shelllet::creator::CreatorPanel::git() -{ -} - -void shelllet::creator::CreatorPanel::create() -{ - New::messageCallback(this); -} - -void shelllet::creator::CreatorPanel::open() -{ - Open::messageCallback(this); -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/creator_panel.h b/QtRpa/modules/creator/src/creator/creator_panel.h deleted file mode 100644 index 4f98246..0000000 --- a/QtRpa/modules/creator/src/creator/creator_panel.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "creator.hpp" -#include "qmainwindow.h" - -namespace shelllet { - namespace creator { - class HideBar; - class CreatorPanel : public QMainWindow, public creator::Callback - , private creator::New - , private creator::Open - , private creator::Save - , private creator::Exec - , private creator::About - { - static inline const int kHideBarNum = 3; - public: - CreatorPanel(QWidget* parent = nullptr); - ~CreatorPanel(); - - void callbk(creator::CallbackMessage*, int num, ...) override; - public: - void git(); - void create(); - void open(); - protected: - void exec(); - private: - std::array panel; - }; - } -} diff --git a/QtRpa/modules/creator/src/creator/files_info_component.cpp b/QtRpa/modules/creator/src/creator/files_info_component.cpp deleted file mode 100644 index 9e623d9..0000000 --- a/QtRpa/modules/creator/src/creator/files_info_component.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "common.hpp" -#include -#include -#include -#include -#include "files_info_component.h" -#include "events/file_browser_event.h" -#include "events/common_event.h" -#include "private/qwidget_p.h" -#include "qmenu.h" -#include "qdesktopservices.h" -#include "qurl.h" -namespace shelllet { - enum Role - { - FileType = Qt::UserRole + 1 - }; - const int index_column = 0; - - namespace creator { - - class FilesInfoComponentPrivate : public QWidgetPrivate { - public: - QTreeWidget* treeWidget = new QTreeWidget; - QTreeWidgetItem* src_; - QTreeWidgetItem* res_; - - std::filesystem::path currentPath_; - - QVBoxLayout* layout; - - QMenu* menu; - - QAction* openFolder = nullptr; - }; - } - -} -shelllet::creator::FilesInfoComponent::FilesInfoComponent(QWidget* parent) - : FilesInfoComponent(*new FilesInfoComponentPrivate, parent) -{ - -} - -shelllet::creator::FilesInfoComponent::FilesInfoComponent(FilesInfoComponentPrivate& d, QWidget* parent /*= nullptr*/) - : QWidget(d, parent, Qt::WindowFlags()) -{ - d.src_ = new QTreeWidgetItem({ tr("src") }); - d.res_ = new QTreeWidgetItem({ tr("res") }); - d.layout = new QVBoxLayout(this); - - d.menu = new QMenu(d.treeWidget); - d.layout->setContentsMargins({ 0, 0, 0, 0 }); - - d.treeWidget->addTopLevelItem(d.src_); - d.treeWidget->addTopLevelItem(d.res_); - - d.layout->addWidget(d.treeWidget); - - connect(d.treeWidget, &QTreeWidget::itemDoubleClicked, this, &FilesInfoComponent::itemDoubleClicked); - - d.treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu); - d.openFolder = new QAction(tr("Open Folder")); - - d.treeWidget->addAction(d.openFolder); - connect(d.openFolder, &QAction::triggered, this, &FilesInfoComponent::openProjectFolder); -} - -shelllet::creator::FilesInfoComponent::~FilesInfoComponent() -{ -} - -void shelllet::creator::FilesInfoComponent::create() -{ - throw std::logic_error("The method or operation is not implemented."); -} - -void shelllet::creator::FilesInfoComponent::load(const Path& filename) -{ - Q_D(FilesInfoComponent); - - libzippp::ZipArchive zf(Environment::getInstance()->getCurrentProjectPath().toString().toStdString()); - zf.open(libzippp::ZipArchive::ReadOnly); - - for (auto& entry : zf.getEntries()) { - if (entry.isFile() && entry.getName().starts_with(common::Environment::getInstance()->getPkgSrcName().toStdString())) { - auto* item = new QTreeWidgetItem({ QString::fromStdString(entry.getName()) }); - item->setData(index_column, Role::FileType, QString::fromStdString(entry.getName())); - d->src_->addChild(item); - } - else if (entry.isFile() && entry.getName().starts_with(common::Environment::getInstance()->getOptions()->pkg_res.toStdString())) { - auto* item = new QTreeWidgetItem({ QString::fromStdString(entry.getName()) }); - item->setData(index_column, Role::FileType, QString::fromStdString(entry.getName())); - d->res_->addChild(item); - } - else if (entry.isFile()) { - auto* item = new QTreeWidgetItem({ QString::fromStdString(entry.getName()) }); - item->setData(index_column, Role::FileType, QString::fromStdString(entry.getName())); - d->treeWidget->addTopLevelItem(item); - } - } - - d->treeWidget->expandAll(); -} - -void shelllet::creator::FilesInfoComponent::save(const Path& filename) -{ - throw std::logic_error("The method or operation is not implemented."); -} - -void shelllet::creator::FilesInfoComponent::itemDoubleClicked(QTreeWidgetItem* item, int column) -{ - QVariant variant = item->data(index_column, Role::FileType); - if (variant.isValid()) - { - QString filename = variant.toString(); - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::FileBrowserEvent(filename.toStdString(), filename.toStdString())); - } -} - -void shelllet::creator::FilesInfoComponent::openProjectFolder() -{ - QDesktopServices::openUrl(QUrl::fromLocalFile(*Environment::getInstance()->getCurrentProjectPath().toString().toQString())); -} diff --git a/QtRpa/modules/creator/src/creator/files_info_component.h b/QtRpa/modules/creator/src/creator/files_info_component.h deleted file mode 100644 index b2d85b8..0000000 --- a/QtRpa/modules/creator/src/creator/files_info_component.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include "common/serialization.h" -namespace shelllet { - class FileSystemModel; - namespace creator{ - class FilesInfoComponentPrivate; - class FilesInfoComponent : public QWidget, public common::Serialization - { - Q_DECLARE_PRIVATE(FilesInfoComponent) - public: - FilesInfoComponent(QWidget* parent = nullptr); - ~FilesInfoComponent(); - - void create() override; - - void load(const Path& filename) override; - - void save(const Path& filename) override; - - private slots: - - void itemDoubleClicked(QTreeWidgetItem* item, int column); - void openProjectFolder(); - protected: - FilesInfoComponent(FilesInfoComponentPrivate& d, QWidget* parent = nullptr); - private: - - }; - } -} diff --git a/QtRpa/modules/creator/src/creator/graphics_view.cpp b/QtRpa/modules/creator/src/creator/graphics_view.cpp deleted file mode 100644 index c8ef339..0000000 --- a/QtRpa/modules/creator/src/creator/graphics_view.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include "creator.hpp" -#include -#include "graphics_view.h" -#include "interpreter.hpp" -#include "events/activity_select_event.h" -#include "creator/scene.h" -#include "events/common_event.h" -//#include "properties/helper.h" -#include "private/qgraphicsview_p.h" - -namespace shelllet { - - using namespace interpreter; - namespace creator { - class GraphicsViewPrivate : public QGraphicsViewPrivate { - public: - DiagramScene* scene; - Element* lastSelectItem = nullptr; - }; - } - - static void WalkCodeCall(std::ostringstream& ss, const QList& items) { - for (auto* i : items) { - if (auto* element = dynamic_cast(i)) { - element->prop()->getCode(ss); - ss << std::endl; - - WalkCodeCall(ss, i->childItems()); - } - } - } - - static void WalkCodeImport(QStringList& imports, QStringList& declares, QGraphicsItem* start) { - for (auto* item : start->childItems()) { - if (item) { - { - - std::ostringstream ss; - - if (auto* element = dynamic_cast(item)) { - element->prop()->getImport(); - - imports.push_back(QString::fromStdString(ss.str())); - } - - } - { - - std::ostringstream ss; - if (auto* element = dynamic_cast(item)) { - - element->prop()->getDefines(ss); - - declares.push_back(QString::fromStdString(ss.str())); - } - } - } - - - WalkCodeImport(imports, declares, item); - } - } - -} - -shelllet::creator::GraphicsView::GraphicsView(QWidget* parent /*= nullptr*/) - : QGraphicsView(*new GraphicsViewPrivate, parent) -{ - Q_D(GraphicsView); - QMenu* menu = nullptr; - d->scene = new DiagramScene(menu, this); - d->scene->setSceneRect(QRectF(0, 0, 5000, 5000));; - - setScene(d->scene); - DiagramScene::RegisterAllViews(); -} - -shelllet::creator::GraphicsView::~GraphicsView() -{ -} - -std::unique_ptr shelllet::creator::GraphicsView::getXml() const -{ - Q_D(const GraphicsView); - return d->scene->toXml(); -} - -void shelllet::creator::GraphicsView::setXml(const XmlDocument& doc) -{ - Q_D(GraphicsView); - //QGraphicsItem* first_item = nullptr; - - //auto* item = scene_->addItem(std::move(properties::CompositeProperty::CreateNode(node))); - - //for (auto& c : node.children()) - //{ - // /* std::shared_ptr data = std::make_shared(); - // data->display = node.attribute("display").value(); - // data->meta = node.attribute("meta").value(); - // data->height = node.attribute("h").value(); - // data->width = node.attribute("w").value(); - // data->x = node.attribute("x").value(); - // data->y = node.attribute("y").value(); - // data->type = node.attribute("type").value();*/ - // LOG_DEBUG("rpa") << "# c: " << properties::Helper::toString(c) << std::endl; - // scene_->addItem(std::move(properties::CompositeProperty::CreateNode(c))); - - //} - - d->scene->loadFromXml(doc); - ensureVisible(d->scene->rootItem()); -} - - -QString shelllet::creator::GraphicsView::getCode() const -{ - Q_D(const GraphicsView); - std::ostringstream ss; - - QStringList imports, declares; - - //ss << "import " << Environment::getInstance()->getOptions()->index_var_filename << std::endl; - - //WalkCodeImport(imports, declares, d->scene->rootItem()); - - ss << imports.join("\n") << std::endl; - - ss << declares.join("\n") << std::endl; - - Component* item = dynamic_cast(d->scene->rootItem()); - - WalkCodeCall(ss, item->childItems()); - - - return QString::fromStdString(ss.str()); - -} - -void shelllet::creator::GraphicsView::mouseDoubleClickEvent(QMouseEvent* event) -{ - //QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::ActivitiesShowEvent(nullptr)); -} - -void shelllet::creator::GraphicsView::mousePressEvent(QMouseEvent* event) -{ - Q_D(GraphicsView); - if (event->button() == Qt::LeftButton) - { - QGraphicsItem* item = itemAt(event->pos()); - Element* current = dynamic_cast(item); - if (current && current != d->lastSelectItem) { - d->lastSelectItem = current; - QCoreApplication::postEvent(events::EventDispatcher::Dispatcher(), new events::ActivitySelectEvent(current->prop())); - } - } - __super::mousePressEvent(event); -} diff --git a/QtRpa/modules/creator/src/creator/graphics_view.h b/QtRpa/modules/creator/src/creator/graphics_view.h deleted file mode 100644 index 57b24c2..0000000 --- a/QtRpa/modules/creator/src/creator/graphics_view.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include -#include -#include -#include "events/listener_manager.h" -#include "common/serialization.h" -#include "pugixml.hpp" -namespace shelllet { - namespace creator { - class DiagramScene; - class DiagramItem; - } - namespace creator { - /* struct Node { - void operator()(juce::PropertySet* fallbackProperties) const - { - std::cout << "Hello, World!" << std::endl; - } - };*/ - class GraphicsViewPrivate; - class GraphicsView : public QGraphicsView - { - Q_DECLARE_PRIVATE(GraphicsView) - public: - GraphicsView(QWidget* parent = nullptr); - ~GraphicsView(); - - std::unique_ptr getXml() const; - void setXml(const XmlDocument& doc); - QString getCode() const; - - protected: - - void mouseDoubleClickEvent(QMouseEvent* event) override; - - - void mousePressEvent(QMouseEvent* event) override; - - }; - } -} diff --git a/QtRpa/modules/creator/src/creator/left_panel.cpp b/QtRpa/modules/creator/src/creator/left_panel.cpp deleted file mode 100644 index 117b493..0000000 --- a/QtRpa/modules/creator/src/creator/left_panel.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "common.hpp" -#include -#include "left_panel.h" - -#include "files_info_component.h" -#include "packages_info_component.h" - -#include "activities_search_widget.h" -#include "private/qwidget_p.h" - -namespace shelllet { - namespace creator { - class LeftPanelPrivate : public QWidgetPrivate { - public: - QToolBox* toolBox =nullptr; - - }; - } -} -shelllet::creator::LeftPanel::LeftPanel(QWidget* parent) - : QWidget(*new LeftPanelPrivate, parent, {}) - -{ - Q_D(LeftPanel); - d->toolBox = new QToolBox(this); - setLayout(new QVBoxLayout()); - layout()->setContentsMargins({ 0, 0, 0,0 }); - - layout()->addWidget(d->toolBox); - d->toolBox->setContentsMargins(0, 0, 0, 0); - -} - -shelllet::creator::LeftPanel::~LeftPanel() -{ -} - -void shelllet::creator::LeftPanel::create() -{ -} - -void shelllet::creator::LeftPanel::save(const Path& filename) -{ -} - -void shelllet::creator::LeftPanel::load(const Path& filename) -{ - Q_D(LeftPanel); - for (auto i = 0; i < d->toolBox->count(); ++i) { - d->toolBox->removeItem(i); - } - - d->toolBox->addItem(new FilesInfoComponent,*filename.fileName().toQString()); - d->toolBox->addItem(new ActivitiesSearchWidget, tr("ToolBox")); - - for (auto i = 0; i < d->toolBox->count(); ++i) { - auto* w = dynamic_cast(d->toolBox->widget(i)); - if (w) - w->load(filename); - } -} - -QSize shelllet::creator::LeftPanel::sizeHint() const -{ - QSize size = __super::sizeHint(); - size.setWidth(size.width() * 0.7); - return size; -} diff --git a/QtRpa/modules/creator/src/creator/left_panel.h b/QtRpa/modules/creator/src/creator/left_panel.h deleted file mode 100644 index 1f02f83..0000000 --- a/QtRpa/modules/creator/src/creator/left_panel.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include -#include -#include -#include "common/serialization.h" - -namespace shelllet::creator { - class LeftPanelPrivate; - class LeftPanel : public QWidget, public common::Serialization - { - Q_DECLARE_PRIVATE(LeftPanel) - public: - LeftPanel(QWidget* parent = nullptr); - ~LeftPanel(); - - void create() override; - - void load(const Path& filename) override; - - void save(const Path& filename) override; - - - - public: - //void create(const juce::File& name); - - protected: - QSize sizeHint() const override; - - private: - - }; -} diff --git a/QtRpa/modules/creator/src/creator/main.cxx b/QtRpa/modules/creator/src/creator/main.cxx deleted file mode 100644 index c9a2cfb..0000000 --- a/QtRpa/modules/creator/src/creator/main.cxx +++ /dev/null @@ -1,26 +0,0 @@ -#include -#include -#include "common/kernel.h" -#include "creator_panel.cpp" -#include "left_panel.cpp" -#include "content_window.cpp" -#include "main_window.cpp" -#include "view_panel.cpp" -#include "output/output_panel.cpp" -#include "output/variable_table_component.cpp" -#include "output/output_component.cpp" -#include "properties/properties_component.cpp" -#include "project/files_info_component.cpp" -#include "project/packages_info_component.cpp" -#include "graphics/graphics_view.cxx" -//#include "properties/properties_component.cxx" - -#include "activities/activities_search_widget.cpp" -#include "activities/search_input_widget.cpp" -#include "activities/search_view_widget.cpp" - -#include "output/moc_variable_table_component.cpp" - -//#include "properties/activities/moc_sequence_property_component.cpp" -//#include "properties/activities/base/moc_activity_property_component.cpp" -//#include "properties/activities/base/moc_display_property_component.cpp" \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/main_window.cpp b/QtRpa/modules/creator/src/creator/main_window.cpp deleted file mode 100644 index 7515ab4..0000000 --- a/QtRpa/modules/creator/src/creator/main_window.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include "creator_panel.h" -#include "main_window.h" -#include "wizard/splash_guide.h" -#include "private/qobject_p.h" -#include "events.hpp" -#include "frameless.hpp" -#include "qdesktopwidget.h" -#include "qapplication.h" -#include "qstyle.h" -#include "qsize.h" -#include "qscreen.h" -#include "creator/component.h" -#include "frameless/private/mainwindow_p.h" - -namespace shelllet { - namespace creator { - class AppWindowPrivate : public MainWindowPrivate { - public: - std::map> funcs; - WizardWidget* wizardWidget = nullptr; - - }; - } -} - -shelllet::creator::AppWindow::AppWindow(QWidget* parent) - : MainWindow(*new AppWindowPrivate, parent, WindowType::AllButton) -{ - Q_D(AppWindow); - - d->wizardWidget = new WizardWidget(this); - setWindowTitle(Environment::getInstance()->getOptions()->applicationName); - setCentralWidget(new CreatorPanel); - - //properties_component::registerAllProperties(); - d->funcs[ResponseHandler::Exit::Create] = std::bind(&AppWindow::create, this); - d->funcs[ResponseHandler::Exit::Open] = std::bind(&AppWindow::open, this); - d->funcs[ResponseHandler::Exit::FromGit] = std::bind(&AppWindow::fromGit, this); - - //d->wizardWidget->setWindowModality(Qt::WindowModality::ApplicationModal); -} - -shelllet::creator::AppWindow::~AppWindow() -{ -} - -void shelllet::creator::AppWindow::finshed(Exit exit) -{ - Q_D(AppWindow); - if (d->funcs.contains(exit)) { - d->funcs[exit](); - d->wizardWidget->close(); - } -} - -void shelllet::creator::AppWindow::show() -{ - Q_D(AppWindow); - QSize size = QApplication::primaryScreen()->availableSize() * 0.8; - - setWindowIcon(qApp->windowIcon()); - resize(size); - moveToCentral(); - showNormal(); - d->wizardWidget->show(); -} - -void shelllet::creator::AppWindow::create() -{ - Q_D(AppWindow); - dynamic_cast(centralWidget())->create(); -} - -void shelllet::creator::AppWindow::fromGit() -{ - Q_D(AppWindow); - dynamic_cast(centralWidget())->git(); -} - -void shelllet::creator::AppWindow::open() -{ - Q_D(AppWindow); - dynamic_cast(centralWidget())->open(); -} diff --git a/QtRpa/modules/creator/src/creator/main_window.h b/QtRpa/modules/creator/src/creator/main_window.h deleted file mode 100644 index 0fa6cdc..0000000 --- a/QtRpa/modules/creator/src/creator/main_window.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once -#include "qobject.h" -#include "common/common_widget.h" -#include "wizard.hpp" - -namespace shelllet { - namespace creator { - class AppWindowPrivate; - class AppWindow : public MainWindow, public ResponseHandler - { - Q_DECLARE_PRIVATE_D(Object::d_ptr, AppWindow) - public: - AppWindow(QWidget* parent = nullptr); - ~AppWindow(); - public: - void finshed(Exit exit) override; - void show(); - void create(); - void fromGit(); - void open(); - - - }; - } -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/output_component.cpp b/QtRpa/modules/creator/src/creator/output_component.cpp deleted file mode 100644 index bcbc028..0000000 --- a/QtRpa/modules/creator/src/creator/output_component.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "common.hpp" -#include "output_component.h" -#include "events/message_output_event.h" -#include "events/common_event.h" -using namespace shelllet::creator; -OutputComponent::OutputComponent(QWidget* parent) -{ - events::EventDispatcher::Dispatcher()->push(this); -} - -OutputComponent::~OutputComponent() -{ -} - -void shelllet::creator::OutputComponent::customEvent(QEvent* event) -{ - auto* e = dynamic_cast(event); - if (e) { - addItem(new QListWidgetItem(QString::fromStdString(e->message()))); - } -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/output_component.h b/QtRpa/modules/creator/src/creator/output_component.h deleted file mode 100644 index 7d07b7c..0000000 --- a/QtRpa/modules/creator/src/creator/output_component.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include -#include "events/listener_manager.h" - -namespace shelllet::creator { - class OutputComponent : public QListWidget - { - public: - OutputComponent(QWidget* parent = nullptr); - ~OutputComponent(); - - protected: - - void customEvent(QEvent* event) override; - - protected: - - private: - - private: - }; -} diff --git a/QtRpa/modules/creator/src/creator/output_panel.cpp b/QtRpa/modules/creator/src/creator/output_panel.cpp deleted file mode 100644 index ef7cb45..0000000 --- a/QtRpa/modules/creator/src/creator/output_panel.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "common.hpp" -#include "output_panel.h" -#include "output_component.h" -#include "variable_table_component.h" -#include "common/serialization.h" - -// - //tabbed.addTab("Output", juce::Colours::darkorchid, new OutputComponent, true); -//// tabbed.addTab("Variable", juce::Colours::darkorchid, new VariableTableComponent(vs, db), true); - //addAndMakeVisible(tabbed); - -shelllet::creator::OutputPanel::OutputPanel(QWidget* parent /*= nullptr*/) - :QTabWidget(parent) -{ - addTab(new OutputComponent(), tr("Output")); - addTab(new VariableTableComponent(), tr("Variable")); -} - -shelllet::creator::OutputPanel::~OutputPanel() -{ -} - -void shelllet::creator::OutputPanel::create() -{ - throw std::logic_error("The method or operation is not implemented."); -} - -void shelllet::creator::OutputPanel::load(const Path& filename) -{ - for (auto i = 0; i < count(); ++i) - { - auto* w = dynamic_cast(this->widget(i)); - if (w) { - w->load(filename); - } - } -} - -void shelllet::creator::OutputPanel::save(const Path& filename) -{ - for (int i = 0; i < count(); ++i) - { - auto* serial = dynamic_cast(this->widget(i)); - - if (serial) { - serial->save(filename); - } - } -} - -QSize shelllet::creator::OutputPanel::sizeHint() const -{ - auto size = __super::sizeHint(); - - size.setHeight(size.height() * 0.6); - - return size; - -} diff --git a/QtRpa/modules/creator/src/creator/output_panel.h b/QtRpa/modules/creator/src/creator/output_panel.h deleted file mode 100644 index b7ac26e..0000000 --- a/QtRpa/modules/creator/src/creator/output_panel.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include -#include -#include "events/listener_manager.h" -#include "common/serialization.h" - -namespace shelllet::creator { - class OutputPanel : public QTabWidget, public common::Serialization { - public: - OutputPanel(QWidget* parent = nullptr); - ~OutputPanel(); - - void create() override; - - void load(const Path& filename) override; - - void save(const Path& filename) override; - - - - protected: - QSize sizeHint() const override; - - private: - }; -} diff --git a/QtRpa/modules/creator/src/creator/packages_info_component.cpp b/QtRpa/modules/creator/src/creator/packages_info_component.cpp deleted file mode 100644 index 03ae2b0..0000000 --- a/QtRpa/modules/creator/src/creator/packages_info_component.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include "packages_info_component.h" -using namespace shelllet::creator; -PackagesInfoComponent::PackagesInfoComponent(QWidget* parent) - : QWidget(parent) - , treeWidget(new QTreeWidget) -{ - setLayout(new QVBoxLayout); - layout()->setContentsMargins({ 0, 0, 0,0 }); - - layout()->addWidget(treeWidget); -} - -PackagesInfoComponent::~PackagesInfoComponent() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/packages_info_component.h b/QtRpa/modules/creator/src/creator/packages_info_component.h deleted file mode 100644 index decc99b..0000000 --- a/QtRpa/modules/creator/src/creator/packages_info_component.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include -#include -#include -#include "common/serialization.h" - -namespace shelllet::creator { - class PackagesInfoComponent : public QWidget - { - public: - PackagesInfoComponent(QWidget* parent = nullptr); - ~PackagesInfoComponent(); - - public: - - //void create(const juce::File& name); - - protected: - - private: - - QTreeWidget* treeWidget; - }; -} diff --git a/QtRpa/modules/creator/src/creator/search_input_widget.cpp b/QtRpa/modules/creator/src/creator/search_input_widget.cpp deleted file mode 100644 index e1764f7..0000000 --- a/QtRpa/modules/creator/src/creator/search_input_widget.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "search_input_widget.h" -#include "events/common_event.h" - -using namespace shelllet::creator; - -ActivitiesSearchInputWidget::ActivitiesSearchInputWidget(QWidget* parent /*= nullptr*/) - : QLineEdit(parent) -{ -} - -ActivitiesSearchInputWidget::~ActivitiesSearchInputWidget() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/search_input_widget.h b/QtRpa/modules/creator/src/creator/search_input_widget.h deleted file mode 100644 index 993f48d..0000000 --- a/QtRpa/modules/creator/src/creator/search_input_widget.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include - -namespace shelllet::creator { - class ActivitiesSearchInputWidget : public QLineEdit - { - public: - ActivitiesSearchInputWidget(QWidget* parent = nullptr); - ~ActivitiesSearchInputWidget(); - - public: - }; -} diff --git a/QtRpa/modules/creator/src/creator/search_view_widget.cpp b/QtRpa/modules/creator/src/creator/search_view_widget.cpp deleted file mode 100644 index 229adfc..0000000 --- a/QtRpa/modules/creator/src/creator/search_view_widget.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "common.hpp" -#include "creator.hpp" -#include -#include -#include -#include "search_view_widget.h" -#include "model.hpp" - -namespace shelllet { - static const char* DISPLAY_XML_ATTRIBUTE_NAME = "display"; -} - -shelllet::creator::ActivitiesSearchViewWidget::ActivitiesSearchViewWidget(QWidget* parent /*= nullptr*/) - : QTreeView(parent) -{ - /*std::filesystem::path p = Environment::getInstance()->getOptions()->assets; - LOG_DEBUG("rpa") << "# working dir: " << std::filesystem::current_path() << std::endl; - - p /= "activities/activities.xml";*/ - - ActivitiesManager::getInstance()->loadAll(); - - setDragEnabled(true); - setSelectionMode(QAbstractItemView::SingleSelection); - setDragDropMode(QAbstractItemView::DragOnly); - - setModel(new model::ActivitiesDomModel(ActivitiesManager::getInstance()->document(), this)); - - - header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -} - -shelllet::creator::ActivitiesSearchViewWidget::~ActivitiesSearchViewWidget() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/search_view_widget.h b/QtRpa/modules/creator/src/creator/search_view_widget.h deleted file mode 100644 index bfaf0c1..0000000 --- a/QtRpa/modules/creator/src/creator/search_view_widget.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once -#include -#include "model.hpp" -namespace shelllet::creator { - class ActivitiesSearchViewWidget : public QTreeView - { - public: - ActivitiesSearchViewWidget(QWidget* parent = nullptr); - ~ActivitiesSearchViewWidget(); - - public: - private: - private: - - protected: - }; -} diff --git a/QtRpa/modules/creator/src/creator/tabitem_page.cpp b/QtRpa/modules/creator/src/creator/tabitem_page.cpp deleted file mode 100644 index d20a172..0000000 --- a/QtRpa/modules/creator/src/creator/tabitem_page.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "common.hpp" -#include "creator.hpp" -#include -#include -#include -#include "tabitem_page.h" -#include "events/activity_create_event.h" -namespace { - using namespace shelllet; - using namespace libzippp; -} -shelllet::creator::TabItemPage::TabItemPage(QWidget* parent /*= nullptr*/) - : GraphicsView(parent) - - -{ - events::EventDispatcher::Dispatcher()->push(this); -} - -shelllet::creator::TabItemPage::~TabItemPage() -{ -} - -void shelllet::creator::TabItemPage::create() -{ - /*std::unique_ptr item = - std::make_unique(QStringList({ "main function" }), nullptr); - auto db = QSqlDatabase::database(); - - auto tableName = getTabName().remove(".js"); - LOG_TRACE(kMainModuleName) << "# db file" << db.databaseName() << std::endl; - if (!db.open()) { - LOG_ERROR(kMainModuleName) << db.lastError().text() << std::endl; - return; - } - - db.exec(QString("DROP TABLE IF EXIST %1 ").arg(tableName)); - db.exec(QString("CREATE TABLE %1 (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, meta TEXT, prop TEXT, parent INTEGER)").arg(tableName)); - - LOG_TRACE(kMainModuleName) << "# last error: " << db.lastError().text() << std::endl; - - QSqlQuery query; - query.prepare(QString("INSERT INTO %1 (name, meta, prop, parent) " - "VALUES (?, ?, ?, ?)").arg(tableName)); - query.bindValue(0, item->getDisplayName()); - query.bindValue(1, item->metaObject()->className() + QString("*")); - query.bindValue(2, item->toXml()); - query.bindValue(3, 0); - if (!query.exec()) { - LOG_ERROR(kMainModuleName) << "# sql error: " << query.lastError().text() << std::endl; - }*/ -} - -void shelllet::creator::TabItemPage::load(const Path& filename) -{ - - filename_ = filename; - - auto file = Environment::getInstance()->getCurrentProjectPath() / Environment::getInstance()->indexXmlPath(); - - XmlDocument doc; - doc.loadFile(file.toString()); - - - setXml(doc); - //model_ = std::make_unique(doc_, this); - - //setModel(model_.get()); -} - -void shelllet::creator::TabItemPage::save(const Path& filename) -{ - if (filename_.isEmpty()) { - return; - } - File file(Environment::getInstance()->getCurrentProjectPath()/ filename_); - - - std::stringstream stream; - std::unique_ptr< XmlDocument> doc = getXml(); - doc->print(stream); - std::string xml = stream.str(); - - - file.write(stream.str()); - - - /*{ - auto f = filename_; - f.replace_extension(Environment::getInstance()->getOptions()->script_extension.toUtf8().constData()); - std::ofstream ss(Environment::getInstance()->getOptions()->current_filepath.string() / f); - - QString code = getCode(); - - ss << code; - }*/ -} - -void shelllet::creator::TabItemPage::add(const std::function& f) -{ - /*ActivitiesWindow::launchAsync([this, f](XmlElement* element) - { - try - { - SQLite::Statement q(*db, (boost::format("INSERT INTO %1% (name, xml, parent) VALUES (?, ?, ?)") % filename.stem()).str()); - q.bind(1, element->getTagName().toRawUTF8()); - q.bind(2, element->toString().toRawUTF8()); - q.bind(3, parent_id()); - q.exec(); - f(element->getTagName().toRawUTF8(), db->getLastInsertRowid()); - } - catch (const SQLite::Exception & err) - { - LOG_ERROR(kMainModuleName) << "# add element error: " << err.what() << std::endl; - } - }, GET_APPLICATION->getMainWindow().getComponent());*/ -} - -void shelllet::creator::TabItemPage::customEvent(QEvent* event) -{ - if (event->type() == events::ActivityCreateEvent::Type) { - auto* e = dynamic_cast(event); - /*QModelIndex index = rootIndex(); - auto* sel = selectionModel(); - if (sel && !sel->selectedRows().isEmpty()) { - index = sel->selectedRows().first(); - }*/ - - // LOG_DEBUG("rpa") << "# create " << e->meta(); - - //int meta = QMetaType::type(e->meta().append("*").c_str()); - - //if (meta != QMetaType::UnknownType) { - // // - // model_->insertRow(0, index, QMetaType::metaObjectForType(meta)); - //} - } -} - -//void shelllet::widgets::TabItemPage::setXml(const std::string& xml) -//{ -//} -// -//std::string shelllet::widgets::TabItemPage::getXml() const -//{ -// return ""; -//} - -std::filesystem::path shelllet::creator::TabItemPage::relative() -{ - //return relative_; - assert(false); - return ""; -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/tabitem_page.h b/QtRpa/modules/creator/src/creator/tabitem_page.h deleted file mode 100644 index dc52d46..0000000 --- a/QtRpa/modules/creator/src/creator/tabitem_page.h +++ /dev/null @@ -1,54 +0,0 @@ -#pragma once -#include -#include -#include - -#include -#include -#include -#include -#include "events/listener_manager.h" -#include "common/serialization.h" -#include "graphics_view.h" - -namespace shelllet::creator { - /* struct Node { - void operator()(juce::PropertySet* fallbackProperties) const - { - std::cout << "Hello, World!" << std::endl; - } - };*/ - //class SwitchPage { - //public: - // virtual void switchView() = 0; - //}; - class TabItemPage : public GraphicsView, public common::Serialization, public common::Property - { - public: - TabItemPage(QWidget* parent = nullptr); - ~TabItemPage(); - - void create() override; - - void load(const Path& filename) override; - - void save(const Path& filename) override; - - void add(const std::function& f); - - //void setXml(const std::string& xml); - //std::string getXml() const; - - std::filesystem::path relative() override; - - private: - - private: - - Path filename_; - - - protected: - void customEvent(QEvent* event) override; - }; -} diff --git a/QtRpa/modules/creator/src/creator/variable_table_component.cpp b/QtRpa/modules/creator/src/creator/variable_table_component.cpp deleted file mode 100644 index 3f0ccf7..0000000 --- a/QtRpa/modules/creator/src/creator/variable_table_component.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include "common.hpp" -#include -#include -#include -#include -#include -#include "variable_table_component.h" -#include "common/variable.h" - -namespace { - using namespace libzippp; - using namespace shelllet::creator; - using namespace YAML; -} - -VariableTableComponent::ComboBoxItemDelegate::ComboBoxItemDelegate(QObject* parent /*= nullptr*/) - : QItemDelegate(parent) -{ -} - -QWidget* VariableTableComponent::ComboBoxItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - auto* comboBox = new QComboBox(parent); - QStringListModel* model = new QStringListModel({ "Auto", "String", "Object" }, comboBox); - comboBox->setModel(model); - return comboBox; -} -VariableTableComponent::VariableTableComponent(QWidget* parent) - : QWidget(parent) - , tableView_(new QTableView) - , toolbar_(new QToolBar()) -{ - setLayout(new QVBoxLayout); - layout()->setContentsMargins({ 0, 0, 0, 0 }); - - toolbar_->addAction(tr("new"), this, SLOT(addRow())); - toolbar_->addAction(tr("del"), this, SLOT(removeRow())); - toolbar_->addWidget(new QLineEdit()); - - layout()->addWidget(toolbar_); - layout()->addWidget(tableView_); - - tableView_->setItemDelegateForColumn(Columns::Type, new ComboBoxItemDelegate(this)); -} - -VariableTableComponent::~VariableTableComponent() -{ - //guard.reset(); - //thread.join(); -} - -void VariableTableComponent::create() -{ - //db->exec("DOROP TABLE IF EXISTS variables"); - //db->exec("CREATE TABLE variables (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, type TEXT, value TEXT, ref INTEGER, desc TEXT)"); -} - -void VariableTableComponent::load(const Path& /*filename*/) -{ - auto file = Environment::getInstance()->getCurrentProjectPath() / Environment::getInstance()->getOptions()->config_filename.toStdString(); - YAML::Node config; - try - { - config = YAML::LoadFile(file.toString().toStdString()); - - - - } - catch (const YAML::ParserException& e) - { - LOG_WARNING("rpa") << e.msg << std::endl; - } - - Node variables; - if (config) - variables = config["variables"]; - - model_ = new model::VariableModel(variables, this); - tableView_->setModel(model_); -} - -void VariableTableComponent::save(const Path& /*filename*/) -{ - - auto file = Environment::getInstance()->getCurrentProjectPath() - / Environment::getInstance()->getOptions()->config_filename.toUtf8().constData(); - - YAML::Node config = YAML::LoadFile(file.toString().toStdString()); - - config["variables"] = model_->node(); - std::string yaml; - std::ofstream stream(yaml); - stream << config; - - - File ss(file); - - ss.write(yaml.c_str()); - -} - -void VariableTableComponent::addRow() -{ - model_->insertRows(model_->rowCount(), 1); -} - -void VariableTableComponent::removeRow() -{ - auto s = tableView_->selectionModel()->selectedRows(); - - model_->removeRows(s.cbegin()->row(), s.count()); -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/variable_table_component.h b/QtRpa/modules/creator/src/creator/variable_table_component.h deleted file mode 100644 index 26ead4e..0000000 --- a/QtRpa/modules/creator/src/creator/variable_table_component.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include "events/listener_manager.h" -#include "common/variable.h" -#include "common/serialization.h" -#include -#include -#include "model.hpp" - -namespace shelllet::creator { - class VariableTableComponent : public QWidget, public common::Serialization - { - Q_OBJECT - public: - VariableTableComponent(QWidget* parent = nullptr); - ~VariableTableComponent(); - - void create() override; - - void load(const Path& filename) override; - - void save(const Path& filename) override; - - protected: - - protected: - private: - - class ComboBoxItemDelegate : public QItemDelegate { - public: - ComboBoxItemDelegate(QObject* parent = nullptr); - QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; - }; - - private slots: - void addRow(); - void removeRow(); - - private: - QTableView* tableView_; - QToolBar* toolbar_; - VariableModel* model_; - }; -} diff --git a/QtRpa/modules/creator/src/creator/view_panel.cpp b/QtRpa/modules/creator/src/creator/view_panel.cpp deleted file mode 100644 index 52f79f6..0000000 --- a/QtRpa/modules/creator/src/creator/view_panel.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "common.hpp" -#include "view_panel.h" -#include -#include "events/common_event.h" -#include "events/listener_manager.h" - -#pragma warning(disable: 4996) -#include -#include "tabitem_page.h" -#include "events/file_browser_event.h" - -namespace shelllet { - using namespace events; -} -using namespace shelllet::creator; - -ViewPanel::ViewPanel(QWidget* parent) - : QTabWidget(parent) -{ - using namespace events; - - //activity_deleted_event::get_mutable_instance().connect([&]() { resized(); }); - //activity_created_event::get_mutable_instance().connect([&]() { resized(); }); - //searchWidget = new ActivitiesSearchWidget(this); - - events::EventDispatcher::Dispatcher()->push(this); - auto* button = new QPushButton("additional", this); - - connect(button, &QPushButton::clicked, [this]() { - auto xy = mapToGlobal(QPoint(0, 0)); - //searchWidget->setGeometry(QRect(xy, QSize(geometry().width(), geometry().height() / 3 * 2))); - //searchWidget->show(); - }); - - setCornerWidget(button, Qt::TopLeftCorner); -} - -ViewPanel::~ViewPanel() -{ -} - -bool shelllet::creator::ViewPanel::tabOpened(const QString& tab) const -{ - for (auto i = 0; i < count(); ++i) { - if (tab == tabText(i)) { - return true; - } - } - return false; -} - -void shelllet::creator::ViewPanel::customEvent(QEvent* event) -{ - if (event->type() == events::ActivitiesShowEvent::eType) { - auto xy = mapToGlobal(QPoint(0, 0)); - searchWidget->setGeometry(QRect(xy, QSize(geometry().width(), geometry().height() / 3 * 2))); - searchWidget->show(); - } - else if (event->type() == events::FileBrowserEvent::Type) { - auto* e = dynamic_cast(event); - - if (!tabOpened(QString::fromStdString(e->getFileName().string()))) { - openTab(e->filePath()); - } - } -} - -void ViewPanel::create() -{ - //String name = std::filesystem::path(db->getFilename()).filename().c_str(); - //auto* view = new TabTreeView(signal_, db, "main.xml"); - //view->create(db); - //addTab("main.xml", juce::Colours::darkgrey, view, true); -} - -void ViewPanel::load(const Path& filename) -{ - openTab(filename); -} - -void shelllet::creator::ViewPanel::openTab(const Path& filename) -{ - common::Serialization* s = nullptr; - //if (filename.extension() == ".js") { - //s = new ScintillaPage(std::filesystem::relative(filename, currentDir_), this); - //} -// else if (filename.extension() == ".xml") { - s = new TabItemPage(this); - // } - s->load(filename); - - addTab(dynamic_cast(s), *filename.toString().toQString()); -} - -void ViewPanel::save(const Path& filename) -{ - for (auto i = 0; i < count(); i++) - { - auto c = dynamic_cast(widget(i)); - auto p = dynamic_cast(widget(i)); - - c->save(filename); - } -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/creator/view_panel.h b/QtRpa/modules/creator/src/creator/view_panel.h deleted file mode 100644 index 8324c11..0000000 --- a/QtRpa/modules/creator/src/creator/view_panel.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include -#include -#include "common/serialization.h" -#include "activities_search_widget.h" - -namespace shelllet::creator { - class ViewPanel : public QTabWidget, public common::Serialization - { - public: - ViewPanel(QWidget* parent = nullptr); - ~ViewPanel(); - - void create() override; - - void load(const Path& filename) override; - - void openTab(const Path& filename); - - void save(const Path& filename) override; - - bool tabOpened(const QString& tab) const; - protected: - virtual void customEvent(QEvent* event) override; - - private: - - ActivitiesSearchWidget* searchWidget; - }; -} diff --git a/QtRpa/modules/creator/src/database/db.cpp b/QtRpa/modules/creator/src/database/db.cpp deleted file mode 100644 index c9cb5f9..0000000 --- a/QtRpa/modules/creator/src/database/db.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "db.h" - -shelllet::database::Sqlite::Sqlite() -{ - const QString DRIVER("QSQLITE"); - if (QSqlDatabase::isDriverAvailable(DRIVER)) { - QSqlDatabase::addDatabase(DRIVER); - } -} diff --git a/QtRpa/modules/creator/src/database/db.h b/QtRpa/modules/creator/src/database/db.h deleted file mode 100644 index 7b9e5b4..0000000 --- a/QtRpa/modules/creator/src/database/db.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once -#include -namespace shelllet::database { - class Sqlite { - public: - Sqlite(); - }; - - Q_GLOBAL_STATIC(Sqlite, GlobalSqlite) -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/dump_dialog.cpp b/QtRpa/modules/creator/src/dump_dialog.cpp deleted file mode 100644 index ad83820..0000000 --- a/QtRpa/modules/creator/src/dump_dialog.cpp +++ /dev/null @@ -1,121 +0,0 @@ -#include "creator.hpp" -#include "common.hpp" -#include "creator/dump_dialog.h" -#include "qlabel.h" -#include "qtablewidget.h" -#include "qboxlayout.h" -#include "qdialogbuttonbox.h" -#include "qpushbutton.h" -#include "qdesktopservices.h" -#include "client/windows/sender/crash_report_sender.h" -#include "private/qdialog_p.h" -namespace shelllet { - static const wchar_t* kDmpFileExtension = L".dmp"; - using namespace creator; - - class DumpDialogPrivate : public QDialogPrivate { - Q_DECLARE_PUBLIC(DumpDialog) - public: - QLabel* label; - QTableWidget* tableWidget; - QDialogButtonBox* buttonBox; - }; -} -shelllet::creator::DumpDialog::DumpDialog(QWidget* parent /*= nullptr*/) - : QDialog(*new DumpDialogPrivate, parent) -{ - setLayout(new QVBoxLayout); - - Q_D(DumpDialog); - - d->label = new QLabel("The file has been successfully created.\n", this); - - layout()->addWidget(d->label); - - { - d->tableWidget = new QTableWidget(0, 3, this); - d->tableWidget->setHorizontalHeaderLabels({ tr("Filename"), tr("Date time"), tr("Size") }); - d->tableWidget->setSelectionBehavior(QAbstractItemView::SelectionBehavior::SelectRows); - d->tableWidget->setSelectionMode(QAbstractItemView::SelectionMode::SingleSelection); - d->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); - d->tableWidget->setSortingEnabled(false); - for (auto& it : std::filesystem::directory_iterator(common::Environment::getInstance()->dumpPath())) - { - if (!it.is_regular_file()) - continue; - - auto& temp = it.path(); - - if (temp.extension().wstring() != kDmpFileExtension) { - continue; - } - - auto* item = new QTableWidgetItem(QString::fromStdString(temp.filename().string())); - item->setFlags(Qt::ItemFlag::ItemIsUserCheckable | Qt::ItemFlag::ItemIsEnabled); - item->setCheckState(Qt::Unchecked); - d->tableWidget->insertRow(d->tableWidget->rowCount()); - - int row = d->tableWidget->rowCount() - 1; - d->tableWidget->setItem(row, 0, item); - - time_t t = std::chrono::duration_cast(it.last_write_time().time_since_epoch() - 11644473600s).count(); - std::stringstream buf; - buf << std::put_time(std::localtime(&t), "%Y-%m-%d %H:%M:%S"); - - d->tableWidget->setItem(row, 1, new QTableWidgetItem(QString::fromStdString(buf.str()))); - - item = new QTableWidgetItem(QString::fromStdString(std::to_string(static_cast(std::ceil(it.file_size() * 1.0 / 1024))) + "KB")); - item->setTextAlignment(Qt::AlignRight); - d->tableWidget->setItem(row, 2, item); - } - d->tableWidget->setSortingEnabled(true); - d->tableWidget->resizeColumnsToContents(); - - layout()->addWidget(d->tableWidget); - } - - - { - - d->buttonBox = new QDialogButtonBox(QDialogButtonBox::StandardButton::Reset | QDialogButtonBox::StandardButton::Ok, this); - d->buttonBox->button(QDialogButtonBox::Reset)->setText(tr("Browser")); - connect(d->buttonBox->button(QDialogButtonBox::Reset), &QPushButton::clicked, [this](bool) { - QDesktopServices::openUrl(QUrl::fromLocalFile(QString::fromStdString(common::Environment::getInstance()->dumpPath().string()))); - }); - - d->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Upload")); - connect(d->buttonBox->button(QDialogButtonBox::Ok), &QPushButton::clicked, [d](bool) { - google_breakpad::CrashReportSender sender(L"crash.checkpoint"); - std::map files; - std::map custom_data; - for (int i = 0; i < d->tableWidget->rowCount(); ++i) - { - auto* item = d->tableWidget->item(i, 0); - if (item->checkState() == Qt::Checked) - { - std::wstring filename = common::Environment::getInstance()->dumpPath().wstring(); - filename += L"\\"; - filename += item->text().toStdWString(); - - files.insert(std::make_pair(filename, filename)); - } - } - - if (!files.empty()) { - google_breakpad::ReportResult res = sender.SendCrashReport(common::Environment::getInstance()->getOptions()->dump_remote.toStdWString(), custom_data, files, 0); - LOG_INFO("rpa") << "# upload result: " << (res == google_breakpad::RESULT_SUCCEEDED) << std::endl; - } - - d->q_func()->accept(); - }); - - layout()->addWidget(d->buttonBox); - } - - setFixedSize(600, 420); -} - -shelllet::creator::DumpDialog::~DumpDialog() -{ - LOG_DEBUG("rpa") << "# dump dialog exit." << std::endl; -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/gui_application.cpp b/QtRpa/modules/creator/src/gui_application.cpp deleted file mode 100644 index bf793b3..0000000 --- a/QtRpa/modules/creator/src/gui_application.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "creator.hpp" -#include "creator/gui_application.h" -#include "common/kernel.h" -#include "common/common_widget.h" -#include "events/common_event.h" -#include "creator/main_window.h" -#include "common/format.h" -#include -//#include "properties/helper.h" -#include -#include -#include -#include -#include -#include "creator/main_window.h" -#include "frameless.hpp" -#include "common.hpp" -#include "wizard.hpp" -#include "common/private/object_p.h" -#include "qapplication.h" -#include "interpreter.hpp" -namespace shelllet { - namespace creator { - class GuiApplicationPrivate : public ObjectPrivate { - public: - QMenu menu; - QSystemTrayIcon tray; - AppWindow mainWindow; - }; - - Q_GLOBAL_STATIC(GuiApplication, __GuiApplication__) - } -} -shelllet::creator::GuiApplication::GuiApplication() - : Object(*new GuiApplicationPrivate, nullptr) -{ - common::glFormat->initialize(__argc, __argv); - - //ConsoleApplication::getInstance()->initialize(); - // Helper::register_meta_type(); -} - - -void shelllet::creator::GuiApplication::run(QEvent*) -{ - Q_D(GuiApplication); - BOOST_ASSERT(QSqlDatabase::isDriverAvailable("QSQLITE")); - - QSqlDatabase::addDatabase("QSQLITE"); - - d->menu.addAction(QObject::tr("Show"), [&]() { d->mainWindow.show(); }); - d->menu.addAction(QObject::tr("Exit"), [&]() { - QApplication::quit(); - }); - d->tray.setIcon(qApp->windowIcon()); - d->tray.setContextMenu(&d->menu); - QObject::connect(&d->tray, &QSystemTrayIcon::activated, [&](QSystemTrayIcon::ActivationReason reason) { - if (QSystemTrayIcon::DoubleClick == reason) { - d->mainWindow.show(); - }}); - - d->tray.show(); - d->mainWindow.show(); -} - -shelllet::creator::GuiApplication* shelllet::creator::GuiApplication::getInstance() -{ - return __GuiApplication__; -} diff --git a/QtRpa/modules/creator/src/items_callback.cpp b/QtRpa/modules/creator/src/items_callback.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/QtRpa/modules/creator/src/main.cc b/QtRpa/modules/creator/src/main.cc deleted file mode 100644 index af489b7..0000000 --- a/QtRpa/modules/creator/src/main.cc +++ /dev/null @@ -1,154 +0,0 @@ -#include "common.hpp" -#include "creator.hpp" -#include "events.hpp" -#include -#include "interpreter.hpp" -#include "creator/application.h" -#include -#include -#include -#include -#include -//#include -#include "qmessagebox.h" -#include "boost/scope_exit.hpp" -#include "creator/gui_application.h" -#include "qprocess.h" - -#ifdef Q_OS_WIN32 -#include "client/windows/common/ipc_protocol.h" -#include "client/windows/handler/exception_handler.h" -#endif // Q_OS_WIN32 - -#include "creator/mini_dump.h" -#include "creator/dump_dialog.h" - -//Q_IMPORT_PLUGIN(QSvgPlugin) - -namespace shelllet { - std::unique_ptr exception_handler; - - using namespace creator; - - void Run_ChildConsole(severity_level level, const std::filesystem::path& file, bool inspect) { - Logger::getInstance()->addFileSink(level, common::Environment::getInstance()->logsPath() / "console.log"); - Logger::getInstance()->initialize(); - QCoreApplication::postEvent(qApp, new ConsoleEvent(file, inspect)); - } - void Run_ChildGui(severity_level level) { - Logger::getInstance()->addFileSink(level, common::Environment::getInstance()->logsPath() / "rpa.log"); - Logger::getInstance()->initialize(); - - QCoreApplication::postEvent(qApp, new GuiEvent); - } - - - void Run_MainProcess(QProcess& process) { - - Logger::getInstance()->addFileSink(info, common::Environment::getInstance()->logsPath() / "main.log"); - Logger::getInstance()->initialize(); - process.start(QCoreApplication::applicationFilePath(), QCoreApplication::arguments()); - - QObject::connect(&process, &QProcess::errorOccurred, [&](QProcess::ProcessError error) { - LOG_INFO("rpa") << "# error occurred: " << process.errorString().toStdString() << std::endl; - //qApp->quit(); - }); - QObject::connect(&process, qOverload(&QProcess::finished), [](int exitCode, QProcess::ExitStatus exitStatus) { - LOG_INFO("rpa") << "# app exit." << std::endl; - //qApp->quit(); - }); - } - - void Run_Child(Application& application) { - google_breakpad::CustomClientInfo custom_info = { }; - - exception_handler = std::make_unique(common::Environment::getInstance()->dumpPath().wstring(), - nullptr, [](const wchar_t* dump_path, const wchar_t* minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool succeeded) - { - if (exception_handler->IsOutOfProcess()) - return exception_handler->RequestUpload(0); - return succeeded; - } - , nullptr - , google_breakpad::ExceptionHandler::HandlerType::HANDLER_ALL - , MiniDumpNormal, common::Environment::getInstance()->getOptions()->pipe_name.toStdWString().c_str(), - &custom_info); - - exception_handler->set_handle_debug_exceptions(true); - - application.setQuitOnLastWindowClosed(true); - - - QCommandLineParser parser; - parser.setApplicationDescription(QObject::tr("Robotic process automation")); - parser.addPositionalArgument("source", QObject::tr("Source file.")); - parser.addHelpOption(); - parser.addVersionOption(); - - QCommandLineOption logLevel = { "level", QObject::tr("logs level."), "error, warning ...", - #ifdef _DEBUG - "trace" - #else - "warning" - #endif // _DEBUG - }; - QCommandLineOption moduleDir = { "modules-dir", - QObject::tr("set modules dir."), "path", QString::fromStdString(common::Environment::getInstance()->getOptions()->modules_path.string()) }; - - QCommandLineOption inspectBrk = { "inspect-brk", QObject::tr("inspect break at js debug."), "boolean", "false" }; - - QCommandLineOption is_console = { "interpreter", QObject::tr("interpreter."), "boolean", "false" }; - - parser.addOptions({ logLevel, moduleDir, inspectBrk,is_console }); - - parser.process(*application.toQApplication()); - - const QStringList args = parser.positionalArguments(); - - common::Environment::getInstanceRef()->setModulePath(parser.value(moduleDir)); - - if (parser.isSet(is_console)) { - Run_ChildConsole(Logger::levelFromString(parser.value(logLevel).toStdString()), args[0].toStdString(), QVariant(parser.value(inspectBrk)).toBool()); - } - else { - Run_ChildGui(Logger::levelFromString(parser.value(logLevel).toStdString())); - - } - } -} -int main(int argc, char* argv[]) -{ - using namespace shelllet; - _CrtSetReportMode(_CRT_ASSERT, 0); - //Q_INIT_RESOURCE(creator); - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - QGuiApplication::setApplicationName("let"); - QGuiApplication::setApplicationVersion("0.5.0"); - QGuiApplication::setOrganizationName("shelllet"); - QGuiApplication::setOrganizationDomain("shelllet.com"); - Application application(argc, argv); - std::filesystem::create_directories(common::Environment::getInstance()->logsPath()); - std::filesystem::create_directories(common::Environment::getInstance()->dumpPath()); - application.setWindowIcon(QIcon(*(Environment::getInstance()->getAssetsPath() / "icons/favicon.png").toString().toQString())); - - QProcess process; -#ifndef _DEBUG - debug::MiniDump mini; - if (mini.startCrashServer(common::Environment::getInstance()->dumpPath())) { - Run_MainProcess(process); - } - else { -#endif // !_DEBUG - Run_Child(application); -#ifndef _DEBUG - } - BOOST_SCOPE_EXIT(&mini) { - mini.stopCrashServer(); - }BOOST_SCOPE_EXIT_END -#endif // !_DEBUG - - QApplication::exec(); - //worker.reset(); - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/mini_dump.cc b/QtRpa/modules/creator/src/mini_dump.cc deleted file mode 100644 index 7dfc6a5..0000000 --- a/QtRpa/modules/creator/src/mini_dump.cc +++ /dev/null @@ -1,108 +0,0 @@ -#include "creator.hpp" -#include "string" -#include "client/windows/crash_generation/crash_generation_server.h" -#include "client/windows/common/ipc_protocol.h" -#include "client/windows/crash_generation/client_info.h" - -#include "qcoreapplication.h" -#include "qcommandlineparser.h" -#include "creator/mini_dump.h" -#include "creator/dump_dialog.h" -#include "private/qobject_p.h" -#include "events/common_event.h" - -namespace shelllet { - class MiniDumpPrivate : public QObjectPrivate { - public: - google_breakpad::CrashGenerationServer* crash_server = nullptr; - std::mutex cv_m; - std::condition_variable cv; - - void reset() { - delete crash_server; - crash_server = nullptr; - } - - }; - ; - class Runner : public Runnable { - public: - Runner(std::condition_variable& cv) : cv(cv) {} - void run(QEvent* event) override - { - dialog = new creator::DumpDialog; - dialog->show(); - - QObject::connect(dialog, &creator::DumpDialog::finished, [this](int) { - cv.notify_one(); - }); - } - ~Runner() - { - QMetaObject::invokeMethod(dialog, "deleteLater", Qt::QueuedConnection); - } - private: - std::condition_variable& cv; - creator::DumpDialog* dialog = nullptr; - }; - - static void Client_ConnectedCallback(void* context, const google_breakpad::ClientInfo* client_info) { - LOG_INFO("rpa") << "# connected." << std::endl; - } - - static void Client_ExitedCallback(void* context, const google_breakpad::ClientInfo* client_info) { - LOG_INFO("rpa") << "# exit." << std::endl; - } - void Client_UploadRequestCallback(void* context, const DWORD crash_id) { - MiniDumpPrivate* d = static_cast(context); - std::unique_ptr p = std::make_unique(d->cv); - QCoreApplication::postEvent(qApp, new events::DumpRequestEvent(p.get())); - - std::unique_lock lk(d->cv_m); - d->cv.wait(lk); - } -} - -shelllet::debug::MiniDump::MiniDump(QObject* parent /*= nullptr*/) : QObject(*new MiniDumpPrivate, parent) -{ - -} - -shelllet::debug::MiniDump::~MiniDump() -{ - -} - -bool shelllet::debug::MiniDump::startCrashServer(const std::wstring& dump_path) { - Q_D(MiniDump); - if (d->crash_server) { - return true; - } - - d->crash_server = new google_breakpad::CrashGenerationServer(common::Environment::getInstance()->getOptions()->pipe_name.toStdWString().c_str(), - nullptr, - Client_ConnectedCallback, - nullptr, - [](void* /*context*/, const google_breakpad::ClientInfo* /*client_info*/, const std::wstring* /*dump_path*/) { - - }, - nullptr, - Client_ExitedCallback, - nullptr, - Client_UploadRequestCallback, - d, - true, - &dump_path); - - - if (!d->crash_server->Start()) { - d->reset(); - return false; - } - return true; -} - -void shelllet::debug::MiniDump::stopCrashServer() { - Q_D(MiniDump); - d->reset(); -} \ No newline at end of file diff --git a/QtRpa/modules/creator/src/resource_file.rc b/QtRpa/modules/creator/src/resource_file.rc deleted file mode 100644 index c7d70d7..0000000 Binary files a/QtRpa/modules/creator/src/resource_file.rc and /dev/null differ diff --git a/QtRpa/modules/creator/src/scene.cpp b/QtRpa/modules/creator/src/scene.cpp deleted file mode 100644 index 733b50e..0000000 --- a/QtRpa/modules/creator/src/scene.cpp +++ /dev/null @@ -1,204 +0,0 @@ -//#include "pybind11/pybind11.h" -#include -#include -#include -#include "boost/serialization/shared_ptr.hpp" -#include -#include "boost/serialization/export.hpp" -//#include "graphics/code.h" -#include "common.hpp" -#include "events.hpp" -//#include "properties/print.h" -#include "qbuffer.h" -#include "common/private/object_p.h" -#include "qgraphicslinearlayout.h" -#include "qtextedit.h" -#include "qgraphicsproxywidget.h" -#include "interpreter.hpp" -#include "creator/scene.h" - -namespace shelllet { - namespace creator { - // namespace py = pybind11; - class GraphicsWidget : public QGraphicsWidget { - public: - - protected: - QVariant itemChange(GraphicsItemChange change, const QVariant& value) override - { - if (change == QGraphicsItem::ItemChildRemovedChange) { - LOG_DEBUG("#pra") << "# child removed." << std::endl; - } - return __super::itemChange(change, value); - } - - }; - - class DiagramScenePrivate : public ObjectPrivate { - public: - QMenu* myItemMenu; - bool leftButtonDown; - QPointF startPoint; - - - QGraphicsItem* item = nullptr; - QGraphicsWidget* form; - QGraphicsLinearLayout* layout; - - void setupUi(QGraphicsScene* scene) { - form = new GraphicsWidget; - layout = new QGraphicsLinearLayout(Qt::Vertical, form); - layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - layout->setContentsMargins(0, 0, 0, 0); - - form->setPos(100, 100); - - scene->addItem(form); - } - }; - - - - } -} -shelllet::creator::DiagramScene::DiagramScene(QMenu* itemMenu, QObject* parent) - : QGraphicsScene(parent) - , Object(*new DiagramScenePrivate, nullptr) -{ - Q_D(DiagramScene); - d->setupUi(this); - - d->form->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); -} - - - - -QGraphicsItem* shelllet::creator::DiagramScene::rootItem() const -{ - Q_D(const DiagramScene); - return d->form->childItems().first(); -} - -QGraphicsItem* shelllet::creator::DiagramScene::startItem() const -{ - - return nullptr; -} - -std::unique_ptr shelllet::creator::DiagramScene::toXml() -{ - Q_D(DiagramScene); - std::unique_ptr doc = std::make_unique(); - doc->addDeclaration(); - Element* root = qgraphicsitem_cast(rootItem()); - doc->appendCopy(root->prop()->getNode()->documentElement()); - walkChildItem(doc->documentElement(), root->childItems()); - return doc; -} - -void shelllet::creator::DiagramScene::loadFromXml(const XmlDocument& doc) -{ - Q_D(DiagramScene); - - auto* sequence = new PropParser(doc.documentElement()); - addItem(sequence->element()); - walkChildNode(doc.documentElement(), sequence->element()); -} - -QGraphicsWidget* shelllet::creator::DiagramScene::rootWidget() const -{ - Q_D(const DiagramScene); - return d->form; -} - -void shelllet::creator::DiagramScene::walkChildNode(XmlNode node, Element* item) -{ - for (auto& c : node.children()) - { - if (c.type() == XmlNodeType::Element) { - //auto element = Element::CreateElement(CompositeProperty::CreateNode(c), item); - auto* sequence = new PropParser(c, item); - if (sequence) { - item->addItem(sequence->element()); - walkChildNode(c, sequence->element()); - } - } - } -} - -void shelllet::creator::DiagramScene::walkChildItem(XmlNode node, const QList& items) -{ - for (auto* i : items) { - if (auto* item = dynamic_cast(i)) { - auto doc = item->prop()->getNode(); - walkChildItem(node.appendCopy(doc->documentElement()), i->childItems()); - } - } -} - -//! [4] - -void shelllet::creator::DiagramScene::setMode(Mode mode) -{ - Q_D(DiagramScene); -} - -void shelllet::creator::DiagramScene::addItem(QGraphicsLayoutItem* item) -{ - Q_D(DiagramScene); - d->layout->addItem(item); - d->layout->setAlignment(item, Qt::AlignHCenter); -} - - - -void shelllet::creator::DiagramScene::RegisterAllViews() -{ - //qRegisterMetaType(); -// qRegisterMetaType(); - //qRegisterMetaType(); - //qRegisterMetaType(); -} - - -//! [14] -bool shelllet::creator::DiagramScene::isItemChange(int type) -{ - Q_D(DiagramScene); - foreach(QGraphicsItem * item, selectedItems()) { - if (item->type() == type) - return true; - } - return false; -} - - - - - - -void shelllet::creator::DiagramScene::dragEnterEvent(QGraphicsSceneDragDropEvent* event) -{ - __super::dragEnterEvent(event); -} - -void shelllet::creator::DiagramScene::dragMoveEvent(QGraphicsSceneDragDropEvent* event) -{ - __super::dragMoveEvent(event); -} - -void shelllet::creator::DiagramScene::dropEvent(QGraphicsSceneDragDropEvent* event) -{ - __super::dropEvent(event); -} - -void shelllet::creator::DiagramScene::customEvent(QEvent* event) -{ - //Q_D(DiagramScene); - if (auto* e = dynamic_cast(event)) { - rootWidget()->layout()->updateGeometry(); - rootWidget()->adjustSize(); - LOG_DEBUG("ppp") << "update size" << std::endl; - } -} diff --git a/QtRpa/modules/events/CMakeLists.txt b/QtRpa/modules/events/CMakeLists.txt deleted file mode 100644 index 79fc585..0000000 --- a/QtRpa/modules/events/CMakeLists.txt +++ /dev/null @@ -1,41 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(events) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/property_browser PROPERTY_BROWSER) -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h ${CMAKE_CURRENT_SOURCE_DIR}/include/events/*.h) -#file(GLOB GLOBAL_HEADERS ) - - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(Qt5Widgets CONFIG REQUIRED) - - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/third-party/v8/include/ - ${Boost_INCLUDE_DIRS} -) - -add_definitions(-DBOOST_ALL_DYN_LINK) - - -target_link_libraries(${PROJECT_NAME} PRIVATE DXGI D3D11 ws2_32.lib - ${Boost_LIBRARIES} - Qt::Widgets #Qt5::WidgetsPrivate #Qt5::QWindowsVistaStylePlugin -) - diff --git a/QtRpa/modules/events/src/activity_create_event.cpp b/QtRpa/modules/events/src/activity_create_event.cpp deleted file mode 100644 index ed044e4..0000000 --- a/QtRpa/modules/events/src/activity_create_event.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "common.hpp" -#include "events/activity_create_event.h" - -using namespace shelllet::events; -ActivityCreateEvent::ActivityCreateEvent(const String& meta) - : QEvent(ActivityCreateEvent::Type) - , meta_(meta) -{ -} - -String shelllet::events::ActivityCreateEvent::meta() const -{ - return meta_; -} \ No newline at end of file diff --git a/QtRpa/modules/events/src/activity_select_event.cpp b/QtRpa/modules/events/src/activity_select_event.cpp deleted file mode 100644 index 9c94efc..0000000 --- a/QtRpa/modules/events/src/activity_select_event.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "common.hpp" -#include "interpreter/composite_property.h" -#include "events/activity_select_event.h" - -using namespace shelllet::events; -ActivitySelectEvent::ActivitySelectEvent(shelllet::interpreter::CompositeProperty* prop) - : QEvent(ActivitySelectEvent::Type) - , prop_(prop) -{ -} - -shelllet::interpreter::CompositeProperty* ActivitySelectEvent::getProp() const -{ - return prop_; -} \ No newline at end of file diff --git a/QtRpa/modules/events/src/adjustsizeevent.cpp b/QtRpa/modules/events/src/adjustsizeevent.cpp deleted file mode 100644 index b449473..0000000 --- a/QtRpa/modules/events/src/adjustsizeevent.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "events/adjustsizeevent.h" - - -shelllet::events::AdjustSizeEvent::AdjustSizeEvent() - :QEvent(AdjustSizeEvent::Type) -{ - -} diff --git a/QtRpa/modules/events/src/closeevent.cpp b/QtRpa/modules/events/src/closeevent.cpp deleted file mode 100644 index b8c44a0..0000000 --- a/QtRpa/modules/events/src/closeevent.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "events/closeevent.h" - - -shelllet::events::CloseEvent::CloseEvent(int result) - :QEvent(CloseEvent::Type) - , result(result) -{ - -} diff --git a/QtRpa/modules/events/src/createevent.cpp b/QtRpa/modules/events/src/createevent.cpp deleted file mode 100644 index 1ad6d6e..0000000 --- a/QtRpa/modules/events/src/createevent.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "events/createevent.h" -shelllet::events::CreateSelectEvent::CreateSelectEvent() - : QEvent(CreateSelectEvent::Type) -{ - -} - diff --git a/QtRpa/modules/events/src/file_browser_event.cpp b/QtRpa/modules/events/src/file_browser_event.cpp deleted file mode 100644 index 6797ad0..0000000 --- a/QtRpa/modules/events/src/file_browser_event.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "events/file_browser_event.h" - -using namespace shelllet::events; -FileBrowserEvent::FileBrowserEvent(const std::filesystem::path& root, const std::filesystem::path& filename) - : QEvent(FileBrowserEvent::Type) - , fileName_(filename) - , root_(root) - -{ -} - -std::filesystem::path shelllet::events::FileBrowserEvent::getFileName() const -{ - return fileName_; -} - -std::filesystem::path shelllet::events::FileBrowserEvent::filePath() const -{ - return root_; -} \ No newline at end of file diff --git a/QtRpa/modules/events/src/gitcloneevent.cpp b/QtRpa/modules/events/src/gitcloneevent.cpp deleted file mode 100644 index 0e03ec9..0000000 --- a/QtRpa/modules/events/src/gitcloneevent.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "events/gitcloneevent.h" - -shelllet::events::GitCloneEvent::GitCloneEvent() - : QEvent(GitCloneEvent::Type) -{ - -} diff --git a/QtRpa/modules/events/src/global_events.cpp b/QtRpa/modules/events/src/global_events.cpp deleted file mode 100644 index 3fc4110..0000000 --- a/QtRpa/modules/events/src/global_events.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include "events/common_event.h" - -using namespace shelllet::events; -ActivitiesShowEvent::ActivitiesShowEvent(/*QTreeWidgetItem* item*/) - : QEvent(ActivitiesShowEvent::eType) - //, item(item) -{ -} -// -//QTreeWidgetItem* shelllet::events::ActivitiesShowEvent::getItem() const -//{ -// return item; -//} - -void shelllet::events::EventDispatcher::push(QObject* receiver) -{ - concerns.push_back(receiver); -} - -void shelllet::events::EventDispatcher::customEvent(QEvent* event) -{ - for (int i = 0; i < concerns.size(); ++i) { - QCoreApplication::sendEvent(concerns.at(i), event); - } -} - -shelllet::events::EventDispatcher::EventDispatcher() { -} \ No newline at end of file diff --git a/QtRpa/modules/events/src/listener_manager.cpp b/QtRpa/modules/events/src/listener_manager.cpp deleted file mode 100644 index 345b1e8..0000000 --- a/QtRpa/modules/events/src/listener_manager.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "events/listener_manager.h" \ No newline at end of file diff --git a/QtRpa/modules/events/src/message_output_event.cpp b/QtRpa/modules/events/src/message_output_event.cpp deleted file mode 100644 index e44a423..0000000 --- a/QtRpa/modules/events/src/message_output_event.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "events/message_output_event.h" - -shelllet::events::MessageOutputEvent::MessageOutputEvent(const std::string& msg) - : QEvent(MessageOutputEvent::Type) - , message_(msg) -{ -} - -std::string shelllet::events::MessageOutputEvent::message() const -{ - return message_; -} \ No newline at end of file diff --git a/QtRpa/modules/events/src/openevent.cpp b/QtRpa/modules/events/src/openevent.cpp deleted file mode 100644 index 025c421..0000000 --- a/QtRpa/modules/events/src/openevent.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "events/openevent.h" - -shelllet::events::OpenSelectEvent::OpenSelectEvent() - : QEvent(OpenSelectEvent::Type) -{ - -} diff --git a/QtRpa/modules/events/src/script_status_listener.cpp b/QtRpa/modules/events/src/script_status_listener.cpp deleted file mode 100644 index d221678..0000000 --- a/QtRpa/modules/events/src/script_status_listener.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "events/script_status_listener.h" \ No newline at end of file diff --git a/QtRpa/modules/events/src/showevent.cpp b/QtRpa/modules/events/src/showevent.cpp deleted file mode 100644 index 8edce0c..0000000 --- a/QtRpa/modules/events/src/showevent.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "events/showevent.h" - - -shelllet::events::ShowEvent::ShowEvent() : QEvent(ShowEvent::Type) -{ - -} diff --git a/QtRpa/modules/frameless/CMakeLists.txt b/QtRpa/modules/frameless/CMakeLists.txt deleted file mode 100644 index 9a7e42b..0000000 --- a/QtRpa/modules/frameless/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(frameless) - -set(CMAKE_AUTOMOC ON) - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Qt5Svg CONFIG REQUIRED) - - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Svg_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} -) - -add_definitions(-DBOOST_ALL_DYN_LINK) - - -target_link_libraries(${PROJECT_NAME} PRIVATE Qt::Svg Dwmapi.lib D2d1.lib) \ No newline at end of file diff --git a/QtRpa/modules/frameless/src/delegatewindow.cpp b/QtRpa/modules/frameless/src/delegatewindow.cpp deleted file mode 100644 index daaa6d3..0000000 --- a/QtRpa/modules/frameless/src/delegatewindow.cpp +++ /dev/null @@ -1,298 +0,0 @@ -#include "qt_windows.h" -#include "frameless/delegatewindow.h" -#include "common/private/object_p.h" -#include "frameless/titlebarwidget.h" -#include "qapplication.h" -#include "qlibrary.h" -#include "wrl.h" -#include "d2d1.h" -#include "qoperatingsystemversion.h" -#include "qwindow.h" -#include "qdebug.h" -namespace shelllet { - using namespace Microsoft::WRL; - namespace frameless { -#ifdef _DEBUG -#define JWF_RESOLVE_ERROR(funcName) Q_ASSERT(m_lp##funcName); -#else -#define JWF_RESOLVE_ERROR(funcName) \ - if (!m_lp##funcName) { \ - LOG_FATAL("frameless") << "Failed to resolve symbol: " #funcName << std::endl; \ - } -#endif - -#define JWF_GENERATE_WINAPI(funcName, retType, ...) \ - using WINAPI_##funcName = retType(WINAPI *)(__VA_ARGS__); \ - static WINAPI_##funcName m_lp##funcName = nullptr; - -#define JWF_RESOLVE_WINAPI(libName, funcName) \ - if (!m_lp##funcName) { \ - m_lp##funcName = reinterpret_cast( \ - QLibrary::resolve(QString::fromUtf8(#libName), #funcName)); \ - JWF_RESOLVE_ERROR(funcName) \ - } - - JWF_GENERATE_WINAPI(GetSystemMetricsForDpi, int, int, UINT) - JWF_GENERATE_WINAPI(GetDpiForWindow, UINT, HWND) - static ComPtr m_pDirect2dFactory; - - enum AppbarAutohideEdge { - EDGE_TOP = 1 << 0, - EDGE_LEFT = 1 << 1, - EDGE_BOTTOM = 1 << 2, - EDGE_RIGHT = 1 << 3, - }; - - class DelegateWindowPrivate : public ObjectPrivate { - public: - TitleBarWidget* titleBar; - }; - - bool __MonitorHasAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) { - APPBARDATA taskbarData = { sizeof(APPBARDATA), NULL, 0, edge }; - taskbarData.hWnd = ::GetForegroundWindow(); - // MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor - // rect and returns autohide bars on that monitor. This sounds like a good - // idea for multi-monitor systems. Unfortunately, it appears to not work at - // least some of the time (erroneously returning NULL) and there's almost no - // online documentation or other sample code using it that suggests ways to - // address this problem. We do the following:- - // 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid - // window we are done. - // 2. If the ABM_GETAUTOHIDEBAR message does not work we query the auto hide - // state of the taskbar and then retrieve its position. That call returns - // the edge on which the taskbar is present. If it matches the edge we - // are looking for, we are done. - // NOTE: This call spins a nested run loop. - HWND taskbar = reinterpret_cast(SHAppBarMessage(ABM_GETAUTOHIDEBAR, &taskbarData)); - if (!::IsWindow(taskbar)) { - APPBARDATA taskbarData = { sizeof(APPBARDATA), 0, 0, 0 }; - unsigned int taskbar_state = SHAppBarMessage(ABM_GETSTATE, &taskbarData); - if (!(taskbar_state & ABS_AUTOHIDE)) - return false; - taskbarData.hWnd = ::FindWindowW(L"Shell_TrayWnd", NULL); - if (!::IsWindow(taskbarData.hWnd)) - return false; - SHAppBarMessage(ABM_GETTASKBARPOS, &taskbarData); - if (taskbarData.uEdge == edge) - taskbar = taskbarData.hWnd; - } - // There is a potential race condition here: - // 1. A maximized chrome window is fullscreened. - // 2. It is switched back to maximized. - // 3. In the process the window gets a WM_NCCACLSIZE message which calls us to - // get the autohide state. - // 4. The worker thread is invoked. It calls the API to get the autohide - // state. On Windows versions earlier than Windows 7, taskbars could - // easily be always on top or not. - // This meant that we only want to look for taskbars which have the topmost - // bit set. However this causes problems in cases where the window on the - // main thread is still in the process of switching away from fullscreen. - // In this case the taskbar might not yet have the topmost bit set. - // 5. The main thread resumes and does not leave space for the taskbar and - // hence it does not pop when hovered. - // - // To address point 4 above, it is best to not check for the WS_EX_TOPMOST - // window style on the taskbar, as starting from Windows 7, the topmost - // style is always set. We don't support XP and Vista anymore. - if (::IsWindow(taskbar)) { - if (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor) - return true; - // In some cases like when the autohide taskbar is on the left of the - // secondary monitor, the MonitorFromWindow call above fails to return the - // correct monitor the taskbar is on. We fallback to MonitorFromPoint for - // the cursor position in that case, which seems to work well. - POINT cursorPos = { 0 }; - GetCursorPos(&cursorPos); - if (MonitorFromPoint(cursorPos, MONITOR_DEFAULTTONEAREST) == monitor) - return true; - } - return false; - } - int __GetAppbarAutohideEdges(HMONITOR monitor) { - int edges = 0; - if (__MonitorHasAutohideTaskbarForEdge(ABE_LEFT, monitor)) - edges |= EDGE_LEFT; - if (__MonitorHasAutohideTaskbarForEdge(ABE_TOP, monitor)) - edges |= EDGE_TOP; - if (__MonitorHasAutohideTaskbarForEdge(ABE_RIGHT, monitor)) - edges |= EDGE_RIGHT; - if (__MonitorHasAutohideTaskbarForEdge(ABE_BOTTOM, monitor)) - edges |= EDGE_BOTTOM; - return edges; - } - int __GetSystemMetricsForDpi(int nIndex, UINT dpi) { - if (m_lpGetSystemMetricsForDpi) - return m_lpGetSystemMetricsForDpi(nIndex, dpi); - - return GetSystemMetrics(nIndex); - } - UINT __GetDpiForWindow(HWND hWnd) { - if (m_lpGetDpiForWindow) - return m_lpGetDpiForWindow(hWnd); - - FLOAT dpiX = 96.0, dpiY = 96.0; - if (m_pDirect2dFactory) - m_pDirect2dFactory->GetDesktopDpi(&dpiX, &dpiY); - - return qRound(dpiX); - } - - MONITORINFO __GetMonitorInfoForWindow(HWND hWnd) - { - HMONITOR mon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi = { .cbSize = sizeof mi }; - GetMonitorInfoW(mon, &mi); - return mi; - } - - int __GetBorderWidthForWindow(HWND hWnd) { - uint dpi = __GetDpiForWindow(hWnd); - return __GetSystemMetricsForDpi(SM_CXSIZEFRAME, dpi) + __GetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi); - } - } -} - - -shelllet::frameless::DelegateWindow::DelegateWindow(TitleBarWidget* widget) - : Object(*new DelegateWindowPrivate, nullptr) -{ - Q_D(DelegateWindow); - - d->titleBar = widget; - - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) { - JWF_RESOLVE_WINAPI(User32, GetSystemMetricsForDpi) - JWF_RESOLVE_WINAPI(User32, GetDpiForWindow) - } - - if (!m_pDirect2dFactory) { - HRESULT hResult = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, m_pDirect2dFactory.GetAddressOf()); - if (FAILED(hResult)) { - LOG_WARNING("frameless") << "Failed to create d2d factory: " << std::system_category().message(hResult) << std::endl; - } - } -} - -bool shelllet::frameless::DelegateWindow::calcNcSize(HWND hWnd, WPARAM wParam, LPARAM lParam) -{ - Q_D(DelegateWindow); - union { - LPARAM lParam; - RECT* rect; - } params = { .lParam = lParam }; - RECT ncclient = *params.rect; - DefWindowProcW(hWnd, WM_NCCALCSIZE, wParam, params.lParam); - RECT client = *params.rect; - if (::IsZoomed(hWnd)) - { - int borderWidth = __GetBorderWidthForWindow(hWnd); - *params.rect = { - .left = client.left, - .top = ncclient.top + static_cast(borderWidth), // Maximized window always have a border around. - .right = client.right, - .bottom = client.bottom, - }; - - HMONITOR mon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi = __GetMonitorInfoForWindow(hWnd); - - // reduce size when same monitor's rectangle. - if (EqualRect(params.rect, &mi.rcMonitor)) { - if (__GetAppbarAutohideEdges(mon) == EDGE_TOP) { - params.rect->top++; - } - else if (__GetAppbarAutohideEdges(mon) == EDGE_LEFT) { - params.rect->left++; - } - else if (__GetAppbarAutohideEdges(mon) == EDGE_BOTTOM) { - params.rect->bottom--; - } - else if (__GetAppbarAutohideEdges(mon) == EDGE_RIGHT) { - params.rect->right--; - } - } - QWindow* window = QWindow::fromWinId(reinterpret_cast(hWnd)); - d->titleBar->setMaximumWidth(window->size().width()); - } - else { - *params.rect = ncclient; - - d->titleBar->setMaximumWidth(QWIDGETSIZE_MAX); - } - return true; -} - - -void shelllet::frameless::DelegateWindow::updateWindow(HWND hWnd, bool frameChange, bool redraw) -{ - if (frameChange) { - SetWindowPos(hWnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); - } - if (redraw) { - //RedrawWindow(hWnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); - RedrawWindow(hWnd, NULL, NULL, RDW_UPDATENOW | RDW_ERASENOW | RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_NOCHILDREN); - } -} - -int shelllet::frameless::DelegateWindow::getSystemTitleBarHeight(HWND hWnd) -{ - const UINT dpi = 96; - - if (IsZoomed(hWnd)) { - return qRound(__GetSystemMetricsForDpi(SM_CYCAPTION, dpi) * 0.75); - } - - return __GetSystemMetricsForDpi(SM_CYCAPTION, dpi); -} - -long shelllet::frameless::DelegateWindow::hitNcTest(HWND hWnd, const QPoint& pos, const QRect& geometry, const SizePolicyFlags& flags) -{ - Q_D(DelegateWindow); - int borderWidth = __GetBorderWidthForWindow(hWnd); - QRect rcMax = geometry; - QRect rcMin = geometry.marginsRemoved({ borderWidth, borderWidth, borderWidth, borderWidth }); - - QRect rcLeft = { QPoint{rcMax.left(), rcMin.top()}, rcMin.bottomLeft() }; - QRect rcTop = { QPoint{rcMin.left(), rcMax.top()}, rcMin.topRight() }; - - QRect rctRight = { rcMin.topRight(),QPoint(rcMax.right(), rcMin.bottom()) }; - QRect rcBottom = { rcMin.bottomLeft(), QPoint(rcMin.right(), rcMax.bottom()) }; - - - QRect rcTopLeft = { rcMax.topLeft(), rcMin.topLeft() }; - QRect rcTopRight = { QPoint{rcMin.right(), rcMax.top()}, QPoint(rcMax.right(), rcMin.top()) }; - - QRect rcBottomLeft = { QPoint(rcMax.left(), rcMin.bottom()),QPoint(rcMin.left(), rcMax.bottom()) }; - QRect rcBottomRight = { rcMin.bottomRight(), rcMax.bottomRight() }; - - if (rcLeft.contains(pos)) { - return flags.testFlag(SizePolicy::FixedWidth) ? HTCLIENT : HTLEFT; - } - else if (rctRight.contains(pos)) { - return flags.testFlag(SizePolicy::FixedWidth) ? HTCLIENT : HTRIGHT; - } - else if (rcBottom.contains(pos)) { - return flags.testFlag(SizePolicy::FixedHeigth) ? HTCLIENT : HTBOTTOM; - } - else if (rcTop.contains(pos)) { - return flags.testFlag(SizePolicy::FixedHeigth) ? HTCLIENT : HTTOP; - } - else if (rcBottomLeft.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTBOTTOMLEFT; - } - else if (rcBottomRight.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTBOTTOMRIGHT; - } - else if (rcTopRight.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTTOPRIGHT; - } - else if (rcTopLeft.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTTOPLEFT; - } - else if (d->titleBar->underMouse()) { - return HTCAPTION; - } - - return HTCLIENT; -} diff --git a/QtRpa/modules/frameless/src/framelesswindow.cpp b/QtRpa/modules/frameless/src/framelesswindow.cpp deleted file mode 100644 index 7165410..0000000 --- a/QtRpa/modules/frameless/src/framelesswindow.cpp +++ /dev/null @@ -1,245 +0,0 @@ -#include "frameless.hpp" -#include "common.hpp" -#include "qmenu.h" -#include "frameless/framelesswindow.h" -#include "frameless/titlebarwidget.h" -#include "frameless/delegatewindow.h" -#include "private/qwidget_p.h" -#include "qapplication.h" -#include "qdesktopwidget.h" -#include "qpainter.h" -#include "qpainterpath.h" -#include "qgraphicseffect.h" -#include "qscreen.h" -#include "qboxlayout.h" -#include "qstyleoption.h" -#include "events.hpp" -#include "qt_windows.h" -#include "windowsx.h" -#include "qstackedwidget.h" -#include "dwmapi.h" -#include "frameless/private/framelesswindow_p.h" - - - -shelllet::frameless::FramelessWindow::FramelessWindow(QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= {}*/) - : FramelessWindow(*new FramelessWindowPrivate, parent, flags) -{ - Q_D(FramelessWindow); - -} -shelllet::frameless::FramelessWindow::FramelessWindow(FramelessWindowPrivate& d, QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= WindowFlags()*/) - : QMainWindow(parent, Qt::FramelessWindowHint) - , Object(d, nullptr) -{ - d.flags = flags; - HWND hWnd = reinterpret_cast(winId()); - d.currentStyle = GetWindowLong(hWnd, GWL_STYLE); - d.currentExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); - setContentsMargins(1, 1, 1, 1); - disableNativeTitleBar(); -} - -shelllet::frameless::FramelessWindow::~FramelessWindow() { - Q_D(FramelessWindow); - delete d->delegateWindow; -} - -void shelllet::frameless::FramelessWindow::setCustomButton(QWidget* c) -{ - Q_D(FramelessWindow); - if (d->titleBar) - d->titleBar->setCustomButton(c); -} - - - -void shelllet::frameless::FramelessWindow::setContextMenu(QMenu* menu) -{ - Q_D(FramelessWindow); - d->menu = menu; -} - -void shelllet::frameless::FramelessWindow::setTitleTextBlurRadius(qreal blurRadius) -{ - Q_D(FramelessWindow); - if (d->titleBar) - d->titleBar->setTitleTextBlurRadius(blurRadius); -} - - -void shelllet::frameless::FramelessWindow::enableNativeTitleBar() -{ - Q_D(FramelessWindow); - HWND hWnd = reinterpret_cast(winId()); - { - SetWindowLongW(hWnd, GWL_STYLE, d->currentStyle); - SetWindowLongW(hWnd, GWL_EXSTYLE, d->currentExStyle); - - MARGINS margins = { 0 }; - DwmExtendFrameIntoClientArea(hWnd, &margins); - } - d->delegateWindow->updateWindow(hWnd, true, true); - if (d->titleBar) { - delete d->titleBar; - d->titleBar = nullptr; - } - setMenuWidget(nullptr); - if (d->delegateWindow) { - delete d->delegateWindow; - d->delegateWindow = nullptr; - } - setWindowFlag(Qt::FramelessWindowHint, false); - setWindowFlag(Qt::Window, true); -} - - -void shelllet::frameless::FramelessWindow::disableNativeTitleBar() -{ - Q_D(FramelessWindow); - HWND hWnd = reinterpret_cast(winId()); - { - SetWindowLongW(hWnd, GWL_STYLE, d->currentStyle | WS_OVERLAPPEDWINDOW | WS_SIZEBOX); - //SetWindowLongW(hWnd, GWL_EXSTYLE, d->currentExStyle | WS_EX_LAYERED); - //SetLayeredWindowAttributes(hWnd, RGB(255, 255, 255), 0, LWA_COLORKEY); - - DWMNCRENDERINGPOLICY ncrp = DWMNCRP_ENABLED; - DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp)); - MARGINS margins = { 1, 1, -1, -1 }; - DwmExtendFrameIntoClientArea(hWnd, &margins); - } - - d->titleBar = new TitleBarWidget; - d->delegateWindow = new DelegateWindow(d->titleBar); - d->titleBar->setWindowTypes(d->flags); - - d->titleBar->setFixedHeight(d->delegateWindow->getSystemTitleBarHeight(hWnd)); - connect(d->titleBar, &TitleBarWidget::closeButtonClicked, this, &FramelessWindow::closeButtonClicked); - connect(d->titleBar, &TitleBarWidget::minimizeButtonClicked, this, &FramelessWindow::minimizeButtonClicked); - connect(d->titleBar, &TitleBarWidget::maximizeButtonClicked, this, &FramelessWindow::maximizeButtonClicked); - connect(d->titleBar, &TitleBarWidget::restoreButtonClicked, this, &FramelessWindow::restoreButtonClicked); - connect(d->titleBar, &TitleBarWidget::iconDoubleClicked, this, &FramelessWindow::iconDoubleClicked); - - connect(this, &FramelessWindow::windowTitleChanged, d->titleBar, &TitleBarWidget::windowTitleChanged); - connect(this, &FramelessWindow::windowIconChanged, d->titleBar, &TitleBarWidget::windowIconChanged); - - setMenuWidget(d->titleBar); - setWindowFlag(Qt::FramelessWindowHint, true); - setWindowFlag(Qt::Window, false); -} - -void shelllet::frameless::FramelessWindow::minimizeButtonClicked() { - Q_D(FramelessWindow); - showMinimized(); -} - -void shelllet::frameless::FramelessWindow::restoreButtonClicked() { - Q_D(FramelessWindow); - showNormal(); -} - -void shelllet::frameless::FramelessWindow::maximizeButtonClicked() { - Q_D(FramelessWindow); - - showMaximized(); -} - -void shelllet::frameless::FramelessWindow::closeButtonClicked() { close(); } - - -void shelllet::frameless::FramelessWindow::iconDoubleClicked() -{ - close(); -} - - -void shelllet::frameless::FramelessWindow::paintEvent(QPaintEvent* event) -{ - Q_D(FramelessWindow); - if (d->titleBar) { - QStyleOption styleOption; - styleOption.initFrom(this); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - QPainterPath path; - path.addRoundedRect(rect(), 1, 1); - - painter.drawPath(path); - } - else { - __super::paintEvent(event); - } -} - -void shelllet::frameless::FramelessWindow::changeEvent(QEvent* event) -{ - Q_D(FramelessWindow); - if (event->type() == QEvent::WindowStateChange) - { - QWindowStateChangeEvent* e = dynamic_cast(event); - if (!(e->oldState() & Qt::WindowMaximized) && (windowState() & Qt::WindowMaximized)) - { - if (d->titleBar) { - d->titleBar->setFixedHeight(d->delegateWindow->getSystemTitleBarHeight(reinterpret_cast(winId()))); - d->titleBar->switchToRestoreButton(); - } - } - else if ((e->oldState() & Qt::WindowMaximized) && (windowState() != Qt::WindowMaximized)) - { - if (d->titleBar) { - d->titleBar->setFixedHeight(d->delegateWindow->getSystemTitleBarHeight(reinterpret_cast(winId()))); - d->titleBar->switchToMaxButton(); - } - } - } - __super::changeEvent(event); -} - -bool shelllet::frameless::FramelessWindow::nativeEvent(const QByteArray& eventType, void* message, long* result) -{ - Q_D(FramelessWindow); - LPMSG lpMsg = reinterpret_cast(message); - if (!d->titleBar) { - return __super::nativeEvent(eventType, message, result); - } - switch (lpMsg->message) { - case WM_NCCALCSIZE: - if (lpMsg->wParam) { - d->delegateWindow->calcNcSize(lpMsg->hwnd, lpMsg->wParam, lpMsg->lParam); - *result = WVR_REDRAW; - return true; - } - break; - case WM_NCHITTEST: - { - POINT pt = { GET_X_LPARAM(lpMsg->lParam), GET_Y_LPARAM(lpMsg->lParam) }; - - ScreenToClient(lpMsg->hwnd, &pt); - RECT rc; - GetClientRect(lpMsg->hwnd, &rc); - *result = d->delegateWindow->hitNcTest(lpMsg->hwnd, { pt.x, pt.y }, { rc.left,rc.top, rc.right - rc.left, rc.bottom - rc.top }, fixedSizeTypes()); - return *result != 0; - } - case WM_DPICHANGED: - d->delegateWindow->updateWindow(lpMsg->hwnd, true, true); - break; - case WM_GETMINMAXINFO: - *result = ::DefWindowProc(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam); - return true; - case WM_MOVE: - d->delegateWindow->updateWindow(lpMsg->hwnd, true, true); - break; - case WM_NCACTIVATE: - *result = DefWindowProcW(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, -1); - return true; - case WM_NCLBUTTONDBLCLK: - if (!d->flags.testFlag(WindowType::MaximizeButtonHint)) - return true; - *result = DefWindowProcW(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, -1); - return true; - case WM_NCRBUTTONDOWN: - if (d->menu) - d->menu->exec(QCursor::pos()); - } - return false; -} diff --git a/QtRpa/modules/frameless/src/mainwindow.cpp b/QtRpa/modules/frameless/src/mainwindow.cpp deleted file mode 100644 index bc78ec2..0000000 --- a/QtRpa/modules/frameless/src/mainwindow.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "frameless/mainwindow.h" -#include "qapplication.h" -#include "qstyle.h" -#include "qdesktopwidget.h" -#include "frameless/private/mainwindow_p.h" -namespace shelllet { - - -} - -shelllet::frameless::MainWindow::MainWindow(QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= WindowFlags()*/) - : MainWindow(*new MainWindowPrivate, parent, flags) -{ -} - -void shelllet::frameless::MainWindow::moveToCentral() -{ - // Q_D(FramelessWindow); - //QSize size = QApplication::primaryScreen()->availableSize() * 0.5; - - LOG_DEBUG(PROJECT_NAME) << "# geometry size: " << geometry() << std::endl; - setGeometry(QStyle::alignedRect( - Qt::LeftToRight, - Qt::AlignCenter, - geometry().size(), - qApp->desktop()->availableGeometry())); ; -} - -void shelllet::frameless::MainWindow::setFixedHeight(int h) -{ - - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedHeigth; - __super::setFixedHeight(h); -} - -void shelllet::frameless::MainWindow::setFixedWidth(int w) -{ - - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedWidth; - __super::setFixedWidth(w); -} - -void shelllet::frameless::MainWindow::setFixedSize(const QSize& s) -{ - - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedAll; - __super::setFixedSize(s); -} - -shelllet::frameless::SizePolicyFlags shelllet::frameless::MainWindow::fixedSizeTypes() const -{ - Q_D(const MainWindow); - - return d->fixedSize; -} - -shelllet::frameless::MainWindow::MainWindow(MainWindowPrivate& d, QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= WindowFlags()*/) - : FramelessWindow(d, parent, flags) -{ - -} - -void shelllet::frameless::MainWindow::setFixedSize(int w, int h) -{ - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedAll; - __super::setFixedSize(w, h); -} diff --git a/QtRpa/modules/frameless/src/standardbutton.cpp b/QtRpa/modules/frameless/src/standardbutton.cpp deleted file mode 100644 index b1c2e72..0000000 --- a/QtRpa/modules/frameless/src/standardbutton.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include "frameless/standardbutton.h" -#include "qstyleoption.h" -#include "qsvgrenderer.h" -#include "qpainter.h" -#include "common/private/object_p.h" -#include "qguiapplication.h" -#include "pugixml.hpp" -namespace shelllet { - namespace frameless { - static constexpr std::int32_t kNumTypes = 4; - enum class MouseStatus { - None, - Enter, - Leave, - Pressed, - Release - }; - - class StandardButtonPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(StandardButton) - public: - MouseStatus status = {}; - Qt::ApplicationState state = {}; - - std::array xmls; - - ButtonType type = {}; - QByteArray getXmlData(const QColor& c) const { - std::ostringstream stream; - auto& doc = xmls[static_cast(type)]; - doc.document_element().first_child().attribute("fill") = c.name().toUtf8().constData(); - doc.save(stream); - return QByteArray(stream.str().c_str()); - } - const QColor hoverColor = "#E5E5E5"; - const QColor pressColor = "#CCCCCC"; - const QColor hoverColorForClose = "#E81123"; - const QColor pressColorForClose = "#F1707A"; - void init() { - Q_Q(StandardButton); - xmls[static_cast(ButtonType::Close)].load_string(R"( - - )"); - - xmls[static_cast(ButtonType::Restore)].load_string(R"( - - )"); - - xmls[static_cast(ButtonType::Maximize)].load_string(R"( - - )"); - - xmls[static_cast(ButtonType::Minimize)].load_string(R"( - - )"); - } - }; - } -} -shelllet::frameless::StandardButton::StandardButton(ButtonType t, QWidget* parent /*= nullptr*/) - : QSvgWidget(parent) - , Object(*new StandardButtonPrivate, nullptr) -{ - Q_D(StandardButton); - d->type = t; - d->init(); - load(d->getXmlData(Qt::black)); - QObject::connect(qApp, &QGuiApplication::applicationStateChanged, this, &StandardButton::applicationStateChanged); -} - -QSize shelllet::frameless::StandardButton::sizeHint() const -{ - return { qRound(geometry().height() * 1.36) ,geometry().height() }; -} - -void shelllet::frameless::StandardButton::applicationStateChanged(Qt::ApplicationState state) -{ - Q_D(StandardButton); - d->state = state; - if (state == Qt::ApplicationActive) { - load(d->getXmlData(Qt::black)); - } - else { - load(d->getXmlData(Qt::darkGray)); - } - update(); -} - -void shelllet::frameless::StandardButton::paintEvent(QPaintEvent* event) -{ - Q_D(StandardButton); - - QStyleOption opt; - opt.initFrom(this); - QPainter painter(this); - - switch (d->status) - { - case MouseStatus::Enter: - painter.fillRect(rect(), d->type == ButtonType::Close ? d->hoverColorForClose : d->hoverColor); - break; - case MouseStatus::Pressed: - painter.fillRect(rect(), d->type == ButtonType::Close ? d->pressColorForClose : d->pressColor); - break; - case MouseStatus::Release: - painter.fillRect(rect(), palette().window()); - break; - case MouseStatus::Leave: - painter.fillRect(rect(), palette().window()); - break; - default: - break; - } - QRectF rc = QRectF({ .0f, .0f }, renderer()->defaultSize() * .7f); - rc.moveCenter(rect().center()); - - renderer()->render(&painter, rc); -} - -void shelllet::frameless::StandardButton::mousePressEvent(QMouseEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Pressed; - update(); -} - -void shelllet::frameless::StandardButton::enterEvent(QEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Enter; - update(); -} - -void shelllet::frameless::StandardButton::leaveEvent(QEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Leave; - update(); -} - -void shelllet::frameless::StandardButton::mouseReleaseEvent(QMouseEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Release; - update(); - if (event->button() == Qt::LeftButton && underMouse()) - emit clicked(); -} - diff --git a/QtRpa/modules/frameless/src/titlebarwidget.cpp b/QtRpa/modules/frameless/src/titlebarwidget.cpp deleted file mode 100644 index 3b0ec99..0000000 --- a/QtRpa/modules/frameless/src/titlebarwidget.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include "frameless.hpp" -#include "frameless/titlebarwidget.h" -#include "qpainter.h" -#include "qstyleoption.h" -#include "private/qwidget_p.h" -#include "qlabel.h" -#include "qtoolbutton.h" -#include "qapplication.h" -#include "qstackedwidget.h" -#include "frameless/standardbutton.h" -#include "qboxlayout.h" - -namespace shelllet { - namespace frameless { - class IconButton : public QLabel { - public: - IconButton(const std::function& doubleClicked, QWidget* parent) : QLabel(parent), doubleClicked(doubleClicked) { - } - - protected: - void mouseDoubleClickEvent(QMouseEvent* /*event*/) override - { - if (doubleClicked) - doubleClicked(); - } - - private: - std::function doubleClicked; - }; - - class TitleBarWidgetPrivate : public QWidgetPrivate { - public: - IconButton* icon; - QLabel* titleText; - StandardButton* minimizeButton; - StandardButton* restoreButton; - StandardButton* maximizeButton; - StandardButton* closeButton; - QStackedWidget* customButton; - QHBoxLayout* horizontalLayout; - const float factor = 0.8; - void setupUi(TitleBarWidget* parent) { - horizontalLayout = new QHBoxLayout(parent); - horizontalLayout->setSpacing(0); - horizontalLayout->setContentsMargins(0, 0, 0, 0); - horizontalLayout->addSpacing(2); - - icon = new IconButton([parent]() { parent->iconDoubleClicked(); }, parent); - auto extent = static_cast(parent->geometry().height() * factor); - icon->setPixmap(qApp->windowIcon().pixmap(extent)); - icon->setContextMenuPolicy(Qt::NoContextMenu); - - horizontalLayout->addWidget(icon); - horizontalLayout->addSpacing(1); - - titleText = new QLabel(parent); - titleText->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); - titleText->setContextMenuPolicy(Qt::CustomContextMenu); - - - titleText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - horizontalLayout->addWidget(titleText); - - horizontalLayout->addSpacing(9); - customButton = new QStackedWidget(parent); - horizontalLayout->addWidget(customButton); - - minimizeButton = new StandardButton(ButtonType::Minimize, parent); - horizontalLayout->addWidget(minimizeButton); - - restoreButton = new StandardButton(ButtonType::Restore, parent); - horizontalLayout->addWidget(restoreButton); - - maximizeButton = new StandardButton(ButtonType::Maximize, parent); - horizontalLayout->addWidget(maximizeButton); - - closeButton = new StandardButton(ButtonType::Close, parent); - horizontalLayout->addWidget(closeButton); - } - }; - } -} -shelllet::frameless::TitleBarWidget::TitleBarWidget(QWidget* parent /*= nullptr*/, WindowTypeFlags f /*= WindowTypes()*/) - : QWidget(*new TitleBarWidgetPrivate, parent, {}) { - Q_D(TitleBarWidget); - d->setupUi(this); - - - - d->restoreButton->setVisible(false); - connect(this, &TitleBarWidget::windowTitleChanged, [d](const QString& title) {d->titleText->setText(title); }); - connect(this, &TitleBarWidget::windowIconChanged, [this, d](const QIcon& icon) {d->icon->setPixmap(icon.pixmap(static_cast(geometry().height() * d->factor))); }); - - connect(d->closeButton, SIGNAL(clicked()), this, SIGNAL(closeButtonClicked())); - connect(d->minimizeButton, SIGNAL(clicked()), this, SIGNAL(minimizeButtonClicked())); - connect(d->maximizeButton, SIGNAL(clicked()), this, SIGNAL(maximizeButtonClicked())); - connect(d->restoreButton, SIGNAL(clicked()), this, SIGNAL(restoreButtonClicked())); -} - -void shelllet::frameless::TitleBarWidget::setWindowTypes(WindowTypeFlags f) -{ - Q_D(TitleBarWidget); - if (!f.testFlag(WindowType::CloseButtonHint)) { - d->closeButton->hide(); - } - if (!f.testFlag(WindowType::MinimizeButtonHint)) { - d->minimizeButton->hide(); - } - if (!f.testFlag(WindowType::MaximizeButtonHint)) { - d->maximizeButton->hide(); - } -} - -void shelllet::frameless::TitleBarWidget::setCustomButton(QWidget* c) -{ - Q_D(TitleBarWidget); - auto* widget = d->customButton->currentWidget(); - if (widget) { - d->customButton->removeWidget(widget); - widget->deleteLater(); - } - d->customButton->addWidget(c); -} - -bool shelllet::frameless::TitleBarWidget::underMouse() -{ - Q_D(TitleBarWidget); - QWidget* action = QApplication::widgetAt(QCursor::pos()); - if (action == this || action == d->titleText || action == d->customButton) { - return true; - } - return false; -} - -void shelllet::frameless::TitleBarWidget::switchToMaxButton() -{ - Q_D(TitleBarWidget); - d->restoreButton->setVisible(false); - d->maximizeButton->setVisible(true); -} - -void shelllet::frameless::TitleBarWidget::switchToRestoreButton() -{ - Q_D(TitleBarWidget); - d->restoreButton->setVisible(true); - d->maximizeButton->setVisible(false); -} - -void shelllet::frameless::TitleBarWidget::setTitleTextBlurRadius(qreal blurRadius) -{ - Q_D(TitleBarWidget); - QGraphicsDropShadowEffect* textShadow = new QGraphicsDropShadowEffect; - textShadow->setBlurRadius(blurRadius); - textShadow->setColor(QColor(0, 0, 0)); - textShadow->setOffset(.0f); - d->titleText->setGraphicsEffect(textShadow); -} - -void shelllet::frameless::TitleBarWidget::paintEvent(QPaintEvent* event) { - boost::ignore_unused(event); - QStyleOption styleOption; - styleOption.initFrom(this); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - style()->drawPrimitive(QStyle::PE_Widget, &styleOption, &painter, this); -} - -void shelllet::frameless::TitleBarWidget::resizeEvent(QResizeEvent* event) -{ - //throw std::logic_error("The method or operation is not implemented."); - Q_D(TitleBarWidget); - auto extent = static_cast(event->size().height() * d->factor); - d->icon->setPixmap(qApp->windowIcon().pixmap(extent)); -} - diff --git a/QtRpa/modules/graphics/CMakeLists.txt b/QtRpa/modules/graphics/CMakeLists.txt deleted file mode 100644 index f78ae72..0000000 --- a/QtRpa/modules/graphics/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(graphics) - -set(CMAKE_AUTOMOC ON) -#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/property_browser PROPERTY_BROWSER) -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -#aux_source_directory(${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME} HEADERS) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - - -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Qt5Svg CONFIG REQUIRED) - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} - ${Qt5Svg_INCLUDE_DIRS} -) - - -if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") - find_library(QSCINTILLA_LIBRARY NAMES qscintilla2_qt5d) - message(STATUS CMAKE_BUILD_TYPE2: ${CMAKE_BUILD_TYPE}) -else() - find_library(QSCINTILLA_LIBRARY NAMES qscintilla2_qt5) - message(STATUS CMAKE_BUILD_TYPE1: ${CMAKE_BUILD_TYPE}) -endif() - -#get_filename_component(SCINTILLA_ROOT ${SCINTILLA_LIBRARY} DIRECTORY) -#get_filename_component(SCINTILLA_ROOT ${SCINTILLA_ROOT} DIRECTORY) - -message(STATUS QSCINTILLA_LIBRARY: ${QSCINTILLA_LIBRARY}) - - -target_link_libraries(${PROJECT_NAME} PRIVATE - ${QSCINTILLA_LIBRARY} - ) diff --git a/QtRpa/modules/graphics/src/code.xxx b/QtRpa/modules/graphics/src/code.xxx deleted file mode 100644 index c22ef1c..0000000 --- a/QtRpa/modules/graphics/src/code.xxx +++ /dev/null @@ -1,78 +0,0 @@ -#include "graphics.hpp" -#include "graphics/code.h" -#include "graphics/private/code_p.h" -#include "qpushbutton.h" -namespace shelllet { - - namespace graphics { - - class CodeDialog : public MainWindow { - public: - CodeDialog() :MainWindow(nullptr, WindowType::AllButton) { - setCentralWidget(new QsciScintilla); - } - - QsciScintilla* scintillaWidget() { - return dynamic_cast(centralWidget()); - } - }; - } -} - - -void shelllet::graphics::CodePrivate::setupUi(Code* parent) -{ - layout = new QGraphicsLinearLayout(Qt::Orientation::Vertical, parent); - layout->setContentsMargins(11, 11, 11, 11); - - //new ScintillaPage(std::filesystem::relative(filename, currentDir_), this); - button = new QPushButton; - button->setText(QObject::tr("open code editor")); - dialog = new CodeDialog; - proxy = new QGraphicsProxyWidget(parent); - proxy->setWidget(button); - - lexer = new QsciLexerPython(parent); - layout->addItem(proxy); -} - - - - -shelllet::graphics::Code::Code(const std::shared_ptr& property, QGraphicsItem* parent /*= 0*/) - : ElementItem(*new CodePrivate, property, parent) -{ - Q_D(Code); - d->setupUi(this); - d->dialog->scintillaWidget()->setLexer(d->lexer); - - d->dialog->scintillaWidget()->setUtf8(true); - - - connect(d->button, &QPushButton::clicked, [d]() {d->dialog->show(); }); - - d->dialog->scintillaWidget()->installEventFilter(this); -} - -shelllet::graphics::Code::~Code() -{ - Q_D(Code); - delete d->dialog; -} - -bool shelllet::graphics::Code::eventFilter(QObject* watched, QEvent* event) -{ - Q_D(Code); - if (dynamic_cast(watched) - && event->type() == QEvent::Close) { - - d->pFunc()->setCode(String::fromQString(d->dialog->scintillaWidget()->text())); - - } - else if (dynamic_cast(watched) - && event->type() == QEvent::Show) { - d->dialog->scintillaWidget()->setText(d->pFunc()->code().toQString()); - } - - return false; -} diff --git a/QtRpa/modules/graphics/src/filedeleteitem.xxx b/QtRpa/modules/graphics/src/filedeleteitem.xxx deleted file mode 100644 index f9ecd76..0000000 --- a/QtRpa/modules/graphics/src/filedeleteitem.xxx +++ /dev/null @@ -1,85 +0,0 @@ -#include "properties/helper.h" -#include "graphics.hpp" -#include "properties.hpp" -#include "common/private/object_p.h" -#include "qpainter.h" -#include "qstyle.h" -#include "qstyleoption.h" -#include "graphics/filedeleteitem.h" -#include "qgraphicslinearlayout.h" -#include "graphics/arrowitem.h" -#include "graphics/simpletextitem.h" -#include "graphics/arrowitem.h" -#include "graphics/textitem.h" -#include "graphics/simpletextitem.h" -#include "graphics/private/elementitem_p.h" -namespace shelllet { - namespace graphics { - class FileDeletePrivate : public ElementItemPrivate { - public: - void setupUi(FileDelete* parent) { - - } - }; - } -} -shelllet::graphics::FileDelete::FileDelete(const std::shared_ptr& property, QGraphicsItem* parent /*= 0*/) - : ElementItem(*new FileDeletePrivate, property, parent) - -{ - Q_D(FileDelete); - d->layout = new QGraphicsLinearLayout(Qt::Orientation::Vertical, this); - d->layout->setContentsMargins(11, 11, 11, 11); - - setFlag(QGraphicsItem::ItemIsMovable, false); - //setFlag(QGraphicsItem::ItemIsSelectable, true); - //setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - -// setMinimumHeight(36); - //setWindowFlags(Qt::WindowTitleHint | Qt::CustomizeWindowHint); - //setAcceptHoverEvents(true); -} - -void shelllet::graphics::FileDelete::paintWindowFrame(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget /*= nullptr*/) -{ - QGraphicsWidget::paintWindowFrame(painter, option, widget); -} - -void shelllet::graphics::FileDelete::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget /*= nullptr*/) -{ - //throw std::logic_error("The method or operation is not implemented."); - -// __super::paint(painter, option, widget); - QRectF titleBarArea = rect(); - titleBarArea.setHeight(32); - - painter->fillRect(titleBarArea, Qt::yellow); - - { - QPixmap pix = prop()->icon().pixmap(24); - if (!pix.isNull()) { - pix = widget->style()->generatedIconPixmap(QIcon::Disabled, pix, option); - widget->style()->drawItemPixmap(painter, { 0, 0, 24, 24 }, Qt::AlignVCenter, pix); - } - - } - QRectF clientArea = rect(); - clientArea.setTopLeft(titleBarArea.bottomLeft()); - painter->fillRect(clientArea, Qt::blue); - - painter->drawRect(rect()); - painter->drawPoint(rect().center()); -} - -QSizeF shelllet::graphics::FileDelete::sizeHint(Qt::SizeHint which, const QSizeF& constraint /*= QSizeF()*/) const -{ - //throw std::logic_error("The method or operation is not implemented."); - - /*auto d = geometry(); - */if (which == Qt::PreferredSize) { - - return { -1, 64 }; - } - return __super::sizeHint(which, constraint); -} - diff --git a/QtRpa/modules/graphics/src/processstartitem.xxx b/QtRpa/modules/graphics/src/processstartitem.xxx deleted file mode 100644 index 73e3034..0000000 --- a/QtRpa/modules/graphics/src/processstartitem.xxx +++ /dev/null @@ -1,37 +0,0 @@ -#include "properties/helper.h" -#include "graphics.hpp" -#include "properties.hpp" -#include "common/private/object_p.h" -#include "qpainter.h" -#include "qstyle.h" -#include "qstyleoption.h" -#include "graphics/processstartitem.h" -#include "qgraphicslinearlayout.h" -#include "graphics/arrowitem.h" -#include "graphics/simpletextitem.h" -#include "graphics/arrowitem.h" -#include "graphics/textitem.h" -#include "graphics/simpletextitem.h" -#include "graphics/private/elementitem_p.h" -namespace shelllet { - namespace graphics { - class ProcessStartPrivate : public ElementItemPrivate { - public: - }; - } -} -shelllet::graphics::ProcessStart::ProcessStart(const std::shared_ptr& property, QGraphicsItem* parent /*= 0*/) - : ElementItem(*new ProcessStartPrivate, property, parent) - -{ - Q_D(ProcessStart); - d->layout = new QGraphicsLinearLayout(Qt::Orientation::Vertical, this); - d->layout->setContentsMargins(11, 11, 11, 11); - - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIsSelectable, true); - setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - - setAcceptHoverEvents(true); -} - diff --git a/QtRpa/modules/interpreter/CMakeLists.txt b/QtRpa/modules/interpreter/CMakeLists.txt deleted file mode 100644 index 28489a3..0000000 --- a/QtRpa/modules/interpreter/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(interpreter) -set(CMAKE_AUTOMOC ON) -set(Python3_USE_STATIC_LIBS TRUE) -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - -set(PYTHON_VER python3.9) -set(PYBIND11_FINDPYTHON ON) - -find_path(PYTHON_INCLUDE_DIRS "${PYTHON_VER}/Python.h") - -if (CMAKE_BUILD_TYPE MATCHES Debug) - find_library(PYTHON_LIBRARY python39_d) - find_library(QSCINTILLA_LIBRARY NAMES qscintilla2_qt5d) -else () - find_library(PYTHON_LIBRARY python39) - find_library(QSCINTILLA_LIBRARY NAMES qscintilla2_qt5) -endif () - - - -message(STATUS BUILD: ${CMAKE_BUILD_TYPE}) -message(STATUS PYTHON: ${PYTHON_INCLUDE_DIRS}) -message(STATUS PYTHON: ${PYTHON_LIBRARY}) - -find_package(Qt5Gui CONFIG REQUIRED) -find_package(libzippp CONFIG REQUIRED) -find_package(pugixml CONFIG REQUIRED) -find_package(pybind11 CONFIG REQUIRED) -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Qt5Svg CONFIG REQUIRED) -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - ${PYTHON_INCLUDE_DIRS}/${PYTHON_VER} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Svg_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} -) - - -target_link_libraries(${PROJECT_NAME} PRIVATE - ${Boost_LIBRARIES} - Qt::Gui Qt5::GuiPrivate - ${PYTHON_LIBRARIES} - ${QSCINTILLA_LIBRARY} - pybind11::lto pybind11::embed pybind11::module - Pathcch - ) diff --git a/QtRpa/modules/interpreter/src/arrowitem.cpp b/QtRpa/modules/interpreter/src/arrowitem.cpp deleted file mode 100644 index a7c1ffb..0000000 --- a/QtRpa/modules/interpreter/src/arrowitem.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "interpreter/arrowitem.h" -#include "qpainter.h" -#include "qsvgrenderer.h" -#include "qgraphicslinearlayout.h" -#include "interpreter/private/svgitem_p.h" -#include "interpreter/svgitem.h" -namespace shelllet { - namespace interpreter { - - class ArrowItemPrivate : public SvgItemPrivate { - public: - /*SvgItem* item; - void setupUi(ArrowItem* self) { - layout = new QGraphicsLinearLayout(Qt::Orientation::Horizontal, self); - layout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - layout->setContentsMargins(9, 9, 9, 9); - item = new SvgItem(Environment::getInstance()->getIconFileName("arrow"), self); - layout->addItem(item); - layout->setAlignment(item, Qt::AlignHCenter | Qt::AlignVCenter); - }*/ - }; - } -} - - -shelllet::interpreter::ArrowItem::ArrowItem(QGraphicsItem* parent /*= nullptr*/) - : SvgItem(*new ArrowItemPrivate, Environment::getInstance()->getIconFileName("arrow"), parent) -{ - //setRotation(180); - //setSize({ 24, 24 }); - Q_D(ArrowItem); - //d->setupUi(this); - setScale(-0.1); - - //setFocusPolicy(Qt::NoFocus); - setFlag(QGraphicsItem::ItemIsFocusable, false); -// - //renderer()->setViewBox(QRectF(QPoint(0, 0), renderer()->defaultSize() * 0.2)); - -} -// -//void shelllet::graphics::ArrowItem::setGeometry(const QRectF& rect) -//{ -// /*prepareGeometryChange(); -// QGraphicsLayoutItem::setGeometry({ rect.topLeft(), renderer()->defaultSize() * 0.2 }); -// setPos(rect.center() + (QRectF{ QPointF(0, 0), geometry().size() }).center());*/ -// __super::setGeometry(rect); -//} - diff --git a/QtRpa/modules/interpreter/src/component.cpp b/QtRpa/modules/interpreter/src/component.cpp deleted file mode 100644 index 54e3409..0000000 --- a/QtRpa/modules/interpreter/src/component.cpp +++ /dev/null @@ -1,154 +0,0 @@ -//#include "properties/helper.h" -#include "interpreter/component.h" -#include "common/private/object_p.h" -#include "qgraphicslinearlayout.h" -#include "qpainter.h" -#include "qstyleoption.h" -#include "qapplication.h" -#include "interpreter/private/component_p.h" -#include "qpropertyanimation.h" -#include "qgraphicssceneevent.h" -#include "private//qgraphicslayoutitem_p.h" -namespace shelllet { -} - -shelllet::interpreter::Component::Component(ComponentPrivate& d, QGraphicsItem* parent /*= nullptr*/, Qt::WindowFlags wFlags /*= Qt::WindowFlags()*/) - : QGraphicsWidget(parent, wFlags) - , Object(d, nullptr) -{ - -} - -void shelllet::interpreter::Component::removeItem(QGraphicsLayoutItem* item) -{ - throw std::logic_error("The method or operation is not implemented."); - -} - - -shelllet::interpreter::Component* shelllet::interpreter::Component::nextItem() const -{ - Q_D(const Component); - return d->next; - -} - -shelllet::interpreter::Component* shelllet::interpreter::Component::previousItem() const -{ - Q_D(const Component); - return d->previous; -} - -void shelllet::interpreter::Component::setNextItem(const Component* item) -{ - Q_D(Component); - d->next = const_cast(item); -} - -void shelllet::interpreter::Component::setPreviousItem(const Component* item) -{ - Q_D(Component); - d->previous = const_cast(item); -} - -void shelllet::interpreter::Component::setGeometry(const QRectF& rect) -{ - /*auto ge2 = geometry(); - QPropertyAnimation* animation = new QPropertyAnimation(this, "geometry"); - animation->setDuration(30000); - animation->setStartValue(geometry()); - animation->setEndValue(ge2); - - animation->start();*/ - __super::setGeometry(rect); -// QGraphicsWidgetPrivate* wd = QGraphicsWidget::d_func(); -// QGraphicsLayoutItemPrivate* d = QGraphicsLayoutItem::d_ptr.data(); -// QRectF newGeom; -// QPointF oldPos = d->geom.topLeft(); -// if (!wd->inSetPos) { -// setAttribute(Qt::WA_Resized); -// newGeom = rect; -// newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize)) -// .boundedTo(effectiveSizeHint(Qt::MaximumSize))); -// -// if (newGeom == d->geom) { -// goto relayoutChildrenAndReturn; -// } -// -// // setPos triggers ItemPositionChange, which can adjust position -// wd->inSetGeometry = 1; -// setPos(newGeom.topLeft()); -// wd->inSetGeometry = 0; -// newGeom.moveTopLeft(pos()); -// -// if (newGeom == d->geom) { -// goto relayoutChildrenAndReturn; -// } -// -// // Update and prepare to change the geometry (remove from index) if the size has changed. -// if (wd->scene) { -// if (rect.topLeft() == d->geom.topLeft()) { -// prepareGeometryChange(); -// } -// } -// } -// -// // Update the layout item geometry -// { -// bool moved = oldPos != pos(); -// if (moved) { -// // Send move event. -// QGraphicsSceneMoveEvent event; -// event.setOldPos(oldPos); -// event.setNewPos(pos()); -// QCoreApplication::sendEvent(this, &event); -// if (wd->inSetPos) { -// //set the new pos -// d->geom.moveTopLeft(pos()); -// emit geometryChanged(); -// goto relayoutChildrenAndReturn; -// } -// } -// QSizeF oldSize = size(); -// QGraphicsLayoutItem::setGeometry(newGeom); -// // Send resize event -// bool resized = newGeom.size() != oldSize; -// if (resized) { -// QGraphicsSceneResizeEvent re; -// re.setOldSize(oldSize); -// re.setNewSize(newGeom.size()); -// if (oldSize.width() != newGeom.size().width()) -// emit widthChanged(); -// if (oldSize.height() != newGeom.size().height()) -// emit heightChanged(); -// QGraphicsLayout* lay = wd->layout; -// if (QGraphicsLayout::instantInvalidatePropagation()) { -// if (!lay || lay->isActivated()) { -// QCoreApplication::sendEvent(this, &re); -// } -// } -// else { -// QCoreApplication::sendEvent(this, &re); -// } -// } -// } -// -// emit geometryChanged(); -//relayoutChildrenAndReturn: -// if (QGraphicsLayout::instantInvalidatePropagation()) { -// if (QGraphicsLayout* lay = wd->layout) { -// if (!lay->isActivated()) { -// QEvent layoutRequest(QEvent::LayoutRequest); -// QCoreApplication::sendEvent(this, &layoutRequest); -// } -// } -// } -} - -// -//QGraphicsLinearLayout* shelllet::graphics::GraphicsItem::linearLayout() const -//{ -// Q_D(const GraphicsItem); -// return d->layout; -//} - diff --git a/QtRpa/modules/interpreter/src/composite_property.cpp b/QtRpa/modules/interpreter/src/composite_property.cpp deleted file mode 100644 index ef304bf..0000000 --- a/QtRpa/modules/interpreter/src/composite_property.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include "common.hpp" -#include "property.hpp" -#include "interpreter/composite_property.h" -#include "interpreter/private/composite_property_p.h" -#include "qjsondocument.h" -#include "qjsonobject.h" -#include "qjsonvalue.h" -#include "qmetaobject.h" -#include "interpreter.hpp" -#include "interpreter/scriptparser.h" -namespace shelllet { - -} - - -shelllet::interpreter::CompositeProperty::CompositeProperty(CompositePropertyPrivate& d, const XmlNode& node, QObject* parent /*= nullptr*/) - : Property(d, node, parent) -{ - /*d.x_ = std::atof(node.attribute("x").value()); - d.y_ = std::atof(node.attribute("y").value()); - d.width_ = std::atof(node.attribute("width").value()); - d.height_ = std::atof(node.attribute("height").value());*/ - //d.dtype_ = static_cast(node.attribute("type").value().toInt()); - d.category = node.attribute("category").value(); - d.meta = node.attribute("meta").value(); -} - -shelllet::interpreter::CompositeProperty::CompositeProperty(const XmlNode& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new CompositePropertyPrivate, node, parent) - -{ -} - - -void shelllet::interpreter::CompositeProperty::restore_from_xml(const std::string& xml) -{ -} - - - -shelllet::common::String shelllet::interpreter::CompositeProperty::category() const -{ - Q_D(const CompositeProperty); - return d->category; -} - -int32_t shelllet::interpreter::CompositeProperty::getId() const -{ - Q_D(const CompositeProperty); - return d->id_; -} - -void shelllet::interpreter::CompositeProperty::setId(int32_t id) -{ - Q_D(CompositeProperty); - d->id_ = id; -} - -int32_t shelllet::interpreter::CompositeProperty::getParentId() const -{ - Q_D(const CompositeProperty); - return d->pid_; -} - -void shelllet::interpreter::CompositeProperty::setParentId(int32_t id) -{ - Q_D(CompositeProperty); - d->pid_ = id; -} - - - -String shelllet::interpreter::CompositeProperty::getImport() const -{ - LOG_DEBUG(PROJECT_NAME) << "# object name: " << metaObject()->className(); - auto path = Environment::getInstance()->getViewPath() / String::toLower(String::removeNamespace(metaObject()->className())); - path.replaceExtension(Environment::getInstance()->getScriptExtension()); - ScriptParser parser; - parser.loadFile(path); - - return parser.parseImports(); -} - -void shelllet::interpreter::CompositeProperty::exec() -{ - /*LOG_DEBUG(PROJECT_NAME) << "# object name: " << metaObject()->className(); - auto path = Environment::getInstance()->getModePath() - / category() - / String::toLower(String::removeNamespace(metaObject()->className())); - path.replaceExtension(Environment::getInstance()->getScriptExtension()); - - ScriptParser::getInstance()->exec(path, this, metaObject());*/ -} - -void shelllet::interpreter::CompositeProperty::getDefines(std::ostringstream& oss) -{ - -} - -std::shared_ptr shelllet::interpreter::CompositeProperty::getNode() -{ - auto doc = __super::getNode(); - doc->documentElement().appendAttribute("meta") = meta(); - //doc->documentElement().appendAttribute("x") = x(); - //doc->documentElement().appendAttribute("y") = y(); - //doc->documentElement().appendAttribute("width") = width(); - //doc->documentElement().appendAttribute("height") = height(); - //doc->documentElement().appendAttribute("type") = type(); - doc->documentElement().appendAttribute("category") = category(); - doc->documentElement().setName(tagName()); - return doc; -} - -std::string shelllet::interpreter::CompositeProperty::json() const -{ - QJsonObject object; - for (int i = metaObject()->propertyOffset(); i < metaObject()->propertyCount(); ++i) { - //qDebug() << metaObj->property(i).type() << " " << metaObj->property(i).typeName(); - object.insert(metaObject()->property(i).name(), QJsonValue::fromVariant(metaObject()->property(i).read(this))); - } - - QJsonDocument document(object); - return QString(document.toJson(QJsonDocument::Indented)).toStdString();; -} - -PropertySheet* shelllet::interpreter::CompositeProperty::getInput(PropertyBrowser*) -{ - Q_D(CompositeProperty); - GroupPropertyManager* groupManager = new GroupPropertyManager(); - - d->m_input = groupManager->addProperty(String::fromQString(&static_cast(QObject::tr("Input")))); - - return d->m_input; -} - -PropertySheet* shelllet::interpreter::CompositeProperty::getOutput(PropertyBrowser*) -{ - Q_D(CompositeProperty); - GroupPropertyManager* groupManager = new GroupPropertyManager(); - - d->m_output = groupManager->addProperty(String::fromQString(&static_cast(QObject::tr("Output")))); - - return d->m_output; -} - -shelllet::interpreter::DiagramType shelllet::interpreter::CompositeProperty::type() -{ - Q_D(CompositeProperty); - return d->dtype_; -} - -float shelllet::interpreter::CompositeProperty::x() const -{ - Q_D(const CompositeProperty); - return d->x_; -} - -float shelllet::interpreter::CompositeProperty::y() const -{ - Q_D(const CompositeProperty); - return d->y_; -} - -void shelllet::interpreter::CompositeProperty::setX(float x) -{ - Q_D(CompositeProperty); - d->x_ = x; -} - -void shelllet::interpreter::CompositeProperty::setY(float y) -{ - Q_D(CompositeProperty); - d->y_ = y; -} - -float shelllet::interpreter::CompositeProperty::width() const -{ - Q_D(const CompositeProperty); - return d->width_; -} - -float shelllet::interpreter::CompositeProperty::height() const -{ - Q_D(const CompositeProperty); - return d->height_; -} - -shelllet::common::String shelllet::interpreter::CompositeProperty::meta() const -{ - Q_D(const CompositeProperty); - return d->meta; -} - -QPointF shelllet::interpreter::CompositeProperty::pos() const -{ - Q_D(const CompositeProperty); - return { d->x_, d->y_ }; -} - -UniquePointer shelllet::interpreter::CompositeProperty::CreateNode(const XmlNode& node) -{ - //CompositeProperty* child = nullptr; - - //QString n = Prefix() + "::" + node.attribute("meta").value() + "*"; - - ////LOG_TRACE(__FUNCTION__) << "# record meta: " << n << std::endl; - //int id = QMetaType::type(n.toUtf8()); - - //if (id != QMetaType::UnknownType) { - // const auto* meta = QMetaType::metaObjectForType(id); - // child = dynamic_cast(meta->newInstance(Q_ARG(pugi::xml_node, node))); - //} - //else { - // LOG_WARNING("rpa") << "# meta type is unknown: " << node.name() << "-" << node.attribute("meta").value() << std::endl; - //} - //BOOST_ASSERT_MSG(child != nullptr, "create failed."); - - // load prop py - // exec prop py - //return PropParser::getInstance()->loadPy(node); - return nullptr; - //return std::unique_ptr(child); -} - -//std::unique_ptr shelllet::properties::CompositeProperty::CreateNode(const QString& name) -//{ -// pugi::xml_node node; -// node.attribute("meta") = name.toUtf8().constData(); -// return CreateNode(node); -//} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/consoleapplication.cpp b/QtRpa/modules/interpreter/src/consoleapplication.cpp deleted file mode 100644 index 261740c..0000000 --- a/QtRpa/modules/interpreter/src/consoleapplication.cpp +++ /dev/null @@ -1,202 +0,0 @@ -#include "interpreter/framework.h" -#include "common.hpp" -#include "events.hpp" -#include "interpreter/composite_property.h" -#include "interpreter/consoleapplication.h" -#include "common/private/object_p.h" -#include "interpreter/private/consoleapplication_p.h" -#include "interpreter/mybase.h" -#include "qcoreapplication.h" -#include "libzippp/libzippp.h" -#include -#include "interpreter/pystderroutstreamredirect.h" -#include "interpreter/pymodule.h" -#include "qglobalstatic.h" -#include "interpreter/propparser.h" -//extern "C" PyObject * PyInit_example(); - -namespace py = pybind11; - -namespace shelllet { - using namespace pugi; - using namespace libzippp; - using boost::adaptors::transformed; - - /*static void WalkImportCall(Set& v, const XmlNodeRange& items) { - for (const auto& i : items) { - if (i.type() == XmlNodeType::Element) { - auto prop = CompositeProperty::CreateNode(i); - if (prop) { - v.insert(prop->getImport()); - } - - WalkImportCall(v, i.children()); - } - } - } - static void WalkCodeCall(std::ostringstream& ss, const xml_object_range& items) { - for (const auto& i : items) { - if (i.type() == pugi::node_element) { - auto prop = CompositeProperty::CreateNode(i); - if (prop) { - prop->getCode(ss); - } - ss << std::endl; - WalkCodeCall(ss, i.children()); - } - } - }*/ - static void WalkCodeCall2(const XmlNodeRange& items) { - for (const auto& i : items) { - if (i.type() == XmlNodeType::Element) { - auto prop = new interpreter::PropParser(i); - if (prop) { - prop->prop()->exec(); - } - - WalkCodeCall2(i.children()); - } - } - } - - namespace interpreter { - - - Q_GLOBAL_STATIC(ConsoleApplication, __ConsoleApplication__) - } - -} - - - - - -shelllet::interpreter::ConsoleApplication::ConsoleApplication() - :ConsoleApplication(*new ConsoleApplicationPrivate) -{ - -} -shelllet::interpreter::ConsoleApplication::ConsoleApplication(ConsoleApplicationPrivate& d) - : Object(d, nullptr) -{ - // Helper::register_meta_type(); -} - -shelllet::interpreter::ConsoleApplication::~ConsoleApplication() -{ - -} - -String shelllet::interpreter::ConsoleApplication::translate(const String& xml) -{ - std::ostringstream ss; - xml_document doc; - doc.load_string(xml.toStdString().c_str()); - Set v; - //WalkImportCall(v, doc.document_element().children()); -// ss << common::join(v | transformed([](const String& d) { return std::move(d.toStdString()); }), endline()) << std::endl; - //WalkCodeCall(ss, doc.document_element().children()); - - - LOG_DEBUG("Velkhana") << "# generate code: " << std::endl - << ss.str(); - return ss.str(); -} - -void shelllet::interpreter::ConsoleApplication::run(QEvent* event) -{ - ConsoleEvent* e = dynamic_cast(event); - BOOST_SCOPE_EXIT(void) { - PyStdErrOutStreamRedirect::getInstance()->release(); - qApp->quit(); - }BOOST_SCOPE_EXIT_END - - if (!e->filename().isExist()) { - LOG_WARNING("engine") << "# the file not exist: " << e->filename(); - return; - } - //std::streambuf* coutbuf = std::cerr.rdbuf(); -// - //std::stringstream out; - - //std::cerr.rdbuf(out.rdbuf()); - //String code; - Path src = e->filename(); - if (src.isDir()) { - src /= Environment::getInstance()->indexXmlPath(); - } - - - - bool is_zip = false; - //if (file.extension() == Environment::getInstance()->getOptions()->pkg_extension) { - //ZipArchive zf(src.toString().toStdString()); - //zf.open(ZipArchive::ReadOnly); - - // ZipEntry entry2 = zf.getEntry(common::Environment::getInstance()->indexJsPath().string()); - //code = entry2.readAsText(); - is_zip = true; - //} -// else { -// //code = translate(File::readAllAsText(src)); -// } - - - try { - //Py_SetPythonHome(L"C://Python39"); - // Py_SetPath(Environment::getInstance()->getOptions()->module_search_path.wstring().c_str()); - //Py_SetProgramName(QCoreApplication::applicationName().toStdWString().c_str()); - - py::object scope = py::module_::import("__main__").attr("__dict__"); - - // py::exec("import example; example.StringIO.write('sss')", scope); - // main_namespace["precreated_object"] = Mybase(); - //py::exec(code.toStdString(), scope); - XmlDocument doc; - doc.loadFile(src); - WalkCodeCall2(doc.documentElement().children()); - } - catch (py::error_already_set& eas) { - // Discard the Python error using Python APIs, using the C++ magic - // variable __func__. Python already knows the type and value and of the - // exception object. - QByteArray data = QString::fromUtf8(eas.what()).toUtf8(); - auto s = data.constData(); - LOG_WARNING("rap") << eas.what() << std::endl; - //eas.discard_as_unraisable(__func__); - } - - - - //std::cerr.rdbuf(coutbuf); -} - -void shelllet::interpreter::ConsoleApplication::initialize() -{ - Q_D(ConsoleApplication); - PyModule::getInstance()->initLibPath(); - d->guard = std::make_unique(); - - - PyModule::getInstance()->importModules(); - PyStdErrOutStreamRedirect::getInstance()->initialize(); - - { -#ifdef _DEBUG - - py::exec("import sys; print(sys.path);"); - -#endif // _DEBUG - } - - { -#ifdef _DEBUG - py::exec("import interpreter; import pprint; print(pprint.pformat(interpreter.__dict__))"); -#endif // _DEBUG - } -} - -shelllet::interpreter::ConsoleApplication* shelllet::interpreter::ConsoleApplication::getInstance() -{ - return __ConsoleApplication__; -} diff --git a/QtRpa/modules/interpreter/src/containeritem.cpp b/QtRpa/modules/interpreter/src/containeritem.cpp deleted file mode 100644 index 7fe6cb8..0000000 --- a/QtRpa/modules/interpreter/src/containeritem.cpp +++ /dev/null @@ -1,310 +0,0 @@ -//#include "properties/helper.h" -#include "interpreter/composite_property.h" -#include "interpreter/propparser.h" -#include "events.hpp" -#include "common/private/object_p.h" -#include "qpainter.h" -#include "qstyle.h" -#include "qcoreapplication.h" -#include "qstyleoption.h" -#include "interpreter/containeritem.h" -#include "qgraphicslinearlayout.h" -#include "interpreter/simpletextitem.h" -#include "interpreter/simpletextitem.h" -#include "interpreter/private/containeritem_p.h" -#include "interpreter/dropareaitem.h" -#include "interpreter/element.h" -#include "qpropertyanimation.h" -#include "qgraphicssceneevent.h" -#include "interpreter/elementmimedata.h" -#include "pugixml.hpp" -#include "model.hpp" -#include "interpreter.hpp" -#include "qgraphicsscene.h" -namespace shelllet { - namespace interpreter { - class UpdateEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - UpdateEvent() : QEvent(Type) { - - } - }; - } -} - -shelllet::interpreter::Container::Container(ContainerPrivate& d, Element* parent /*= nullptr*/, Object*p /*= nullptr*/) - : Element(d, parent, p) -{ - d.layout = new QGraphicsLinearLayout(Qt::Orientation::Vertical, this); - d.layout->setContentsMargins(11, 11, 11, 11); - d.layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - addItem(new DropArea(this)); - - //setFlag(QGraphicsItem::ItemIsMovable, true); - //setFlag(QGraphicsItem::ItemIsSelectable, true); - //setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - - //setAcceptHoverEvents(true); - - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); -} - - - -void shelllet::interpreter::Container::removeItem(int index) -{ - Q_D(Container); - //auto* item = d->layout->itemAt(index); - - //if (auto *temp = dynamic_cast(item)) { - // removeItem(temp); - //} - throw std::runtime_error(""); -} - - -void shelllet::interpreter::Container::hideExtraItem() -{ - Q_D(Container); - if (d->description) { - removeItem(d->description); - d->description = nullptr; - } -} - -void shelllet::interpreter::Container::showExtraItem() -{ - Q_D(Container); - if (d->description) { - d->description = new SimpleTextItem(tr("put activities in here"), this); - addItem(d->description); - } -} - -void shelllet::interpreter::Container::updateExtraItem() -{ - if (isEmpty()) { - showExtraItem(); - } - else { - hideExtraItem(); - QCoreApplication::postEvent(scene(), new AdjustSizeEvent, Qt::LowEventPriority); - } -} - -void shelllet::interpreter::Container::customEvent(QEvent* event) -{ - if (dynamic_cast(event)) { - updateExtraItem(); - } -} -void shelllet::interpreter::Container::dropItem(const QMimeData* mimeData, Component* current) -{ - Q_D(Container); - //throw std::logic_error("The method or operation is not implemented."); - //ElementItem* element = nullptr; - //GraphicsItem* nextItem = nullptr; - - //if (auto* temp = dynamic_cast(const_cast(mimeData))) { - /*element = temp->elementItem(); - nextItem = temp->elementItem()->nextItem();*/ - - // std::shared_ptr property = std::move(CompositeProperty::CreateNode(temp->node())); - //element = ElementItem::CreateElement(property, nullptr); - // nextItem = new DropArea(nullptr); - // } - if (auto* temp = dynamic_cast(const_cast(mimeData))) { - // QByteArray bytes = mimeData->data(Environment::getInstance()->getOptions()->mime_data_type); - - //if (!bytes.isEmpty()) { - //pugi::xml_document doc; - // doc.load_string(bytes.constData()); - - LOG_DEBUG("rpa") << temp->documentElement(); - - - //auto element = ElementItem::CreateElement(CompositeProperty::CreateNode(temp->documentElement()), this); - auto* sequence = new PropParser(temp->documentElement(), this); - //} - if (sequence) { - - insertItem(indexWidget(current) + 1, sequence->element()); - } - //insertItem(indexWidget(element) + 1, nextItem); - - if (temp->sourceItem()) { - auto* p = temp->sourceItem(); - if (auto* parent = dynamic_cast(p->parentItem())) { - parent->removeItem(dynamic_cast(p)); - } - } - } - - - //// update index - //element->setPreviousItem(current); - //element->setNextItem(nextItem); - - //nextItem->setPreviousItem(element); - //nextItem->setNextItem(dynamic_cast(d->layout->itemAt(index + 1))); - - //d->layout->invalidate(); -} - - - -Component* shelllet::interpreter::Container::itemAt(int index) const -{ - Q_D(const Container); - return dynamic_cast(d->layout->itemAt(index)); -} - -void shelllet::interpreter::Container::addItem(QGraphicsLayoutItem* item) -{ - Q_D(Container); - d->layout->addItem(item); - d->layout->setAlignment(item, Qt::AlignHCenter); -} - -void shelllet::interpreter::Container::addItem(Element* item) -{ - //throw std::logic_error("The method or operation is not implemented."); - Q_D(Container); - /*d->layout->addItem(item); - d->layout->setAlignment(item, Qt::AlignHCenter); - - addItem(new DropArea(this));*/ - std::invoke(static_cast(&Container::addItem), this, item); - //addItem(item); - auto* extra = new DropArea(this); - d->layout->addItem(extra); - d->layout->setAlignment(extra, Qt::AlignHCenter); -} - -int shelllet::interpreter::Container::insertItem(int index, QGraphicsLayoutItem* item) -{ - Q_D(Container); - d->layout->insertItem(index, item); - d->layout->setAlignment(item, Qt::AlignHCenter); - if (auto* temp = dynamic_cast(item); temp->parentItem() != this) { - temp->setParentItem(this); - } - auto* extra = new DropArea(this); - - d->layout->insertItem(index + 1, extra); - d->layout->setAlignment(extra, Qt::AlignHCenter); - ///setParentLayoutItem(); - //addItem(new DropArea(this)); - - int newIndex = indexWidget(item); - - //Q_ASSERT_X(newIndex == index, "insert item", "index not equal"); - return newIndex; -} - -int shelllet::interpreter::Container::indexWidget(const QGraphicsLayoutItem* item) const -{ - //Q_D(Container); - for (int i = 0; i < layout()->count(); i++) { - if (item == dynamic_cast(layout()->itemAt(i))) { - return i; - } - } - - return -1; - -} - - -bool shelllet::interpreter::Container::isEmpty() const -{ - for (int i = 0; i < layout()->count(); i++) { - if (auto* item = itemAt(i)) { - return false; - } - } - return true; -} - -void shelllet::interpreter::Container::setGeometry(const QRectF& rect) -{ - __super::setGeometry(rect); - - -} - -void shelllet::interpreter::Container::removeItem(QGraphicsLayoutItem* item) -{ - Q_D(Container); - - auto* p = dynamic_cast(item); - - if (p) - { - p->hide(); - if (auto* temp = dynamic_cast(p->nextItem())) { - d->layout->removeItem(temp); - scene()->removeItem(temp); - delete temp; - } - - d->layout->removeItem(p); - scene()->removeItem(p); - delete p; - } - //for (int i = 0; i < layout()->count(); i++) { - // if (item == dynamic_cast(layout()->itemAt(i))) { - - // auto* area = dynamic_cast(layout()->itemAt(i + 1)); - - // if (area) { - // removeItem(area); - // break; - // } - - // } - //} - - - -} - - -void shelllet::interpreter::Container::hoverEnterEvent(QGraphicsSceneHoverEvent* event) -{ - //LOG_TRACE("rpa") << "# enter" << std::endl; - Component::hoverEnterEvent(event); -} - -void shelllet::interpreter::Container::hoverMoveEvent(QGraphicsSceneHoverEvent* event) -{ - //LOG_TRACE("rpa") << "# move" << std::endl; - Component::hoverMoveEvent(event); -} - -void shelllet::interpreter::Container::hoverLeaveEvent(QGraphicsSceneHoverEvent* event) -{ - //throw std::logic_error("The method or operation is not implemented."); - //LOG_TRACE("rpa") << "# leave" << std::endl; - Component::hoverLeaveEvent(event); -} - -QVariant shelllet::interpreter::Container::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) -{ - Q_D(Container); - if (change == QGraphicsItem::ItemChildAddedChange || change == QGraphicsItem::ItemChildRemovedChange) { - if (auto* item = value.value(); item->isWidget()) { - //QTimer::singleShot(0.1s, this, Q_SLOT(updateExtraItem())); - QCoreApplication::postEvent(this, new UpdateEvent, Qt::LowEventPriority); - } - } - - return __super::itemChange(change, value); -} - -shelllet::interpreter::Container::Container(Element* parent /*= nullptr*/, Object* p /*= nullptr*/) - : Container(*new ContainerPrivate, parent, p) -{ - -} diff --git a/QtRpa/modules/interpreter/src/dropareaitem.cpp b/QtRpa/modules/interpreter/src/dropareaitem.cpp deleted file mode 100644 index 14debb0..0000000 --- a/QtRpa/modules/interpreter/src/dropareaitem.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "interpreter/composite_property.h" -#include "interpreter/dropareaitem.h" -#include "common/private/object_p.h" -#include "interpreter/private/component_p.h" -#include "interpreter/arrowitem.h" -#include "qgraphicslinearlayout.h" -#include "qgraphicssceneevent.h" -#include "qmimedata.h" -#include "events.hpp" -#include "qcoreapplication.h" -#include "qgraphicsscene.h" -#include "qpainter.h" -#include "interpreter/containeritem.h" -#include "interpreter/placeholderitem.h" - -#include "qpropertyanimation.h" -#include "qgraphicssceneevent.h" - -namespace shelllet { - namespace interpreter { - class DropAreaPrivate : public ComponentPrivate { - Q_DECLARE_PUBLIC(DropArea) - public: - ArrowItem* arrow = nullptr; - ArrowItem* arrowNext = nullptr; - PlaceholderItem* placeholder = nullptr; - void setupUi(DropArea* self) { - layout = new QGraphicsLinearLayout(Qt::Orientation::Vertical, self); - layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - layout->setContentsMargins(11, 11, 11, 11); - arrow = new ArrowItem(self); - self->addItem(arrow); - } - }; - } -} - - -shelllet::interpreter::DropArea::DropArea(QGraphicsItem* parent /*= nullptr*/) - : Component(*new DropAreaPrivate, parent, Qt::Window | Qt::FramelessWindowHint) -{ - Q_D(DropArea); - d->setupUi(this); - setAcceptDrops(true); - //setMinimumSize(240, 36); - setMinimumWidth(240); - - - //showExtraItem(); -} - -void shelllet::interpreter::DropArea::setGeometry(const QRectF& rect) -{ - - __super::setGeometry(rect); -} - -void shelllet::interpreter::DropArea::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget /*= nullptr*/) -{ - __super::paint(painter, option, widget); - - //painter->fillRect(rect(), Qt::red); - - painter->drawPoint(rect().center()); -} - - - -void shelllet::interpreter::DropArea::dragEnterEvent(QGraphicsSceneDragDropEvent* event) -{ - Q_D(DropArea); - auto geo = geometry(); - showExtraItem(); - auto s = event->source(); - event->acceptProposedAction(); - /*d->layout->invalidate(); - d->layout->activate(); - emit geometryChanged();*/ - //adjustSize(); - event->accept(); - //update(); - -} - -void shelllet::interpreter::DropArea::dragLeaveEvent(QGraphicsSceneDragDropEvent* event) -{ - Q_D(DropArea); - hideExtraItem(); - //dynamic_cast(scene())->rootWidget()->layout()->updateGeometry(); - //dynamic_cast(scene())->rootWidget()->adjustSize(); - QCoreApplication::postEvent(scene(), new AdjustSizeEvent, Qt::LowEventPriority); - //event->accept(); -} - -void shelllet::interpreter::DropArea::dropEvent(QGraphicsSceneDragDropEvent* event) -{ - auto* parent = dynamic_cast(parentWidget()); - - hideExtraItem(); - parent->dropItem(event->mimeData(), this); - QCoreApplication::postEvent(scene(), new AdjustSizeEvent, Qt::LowEventPriority); - //event->accept(); -} - -QSizeF shelllet::interpreter::DropArea::sizeHint(Qt::SizeHint which, const QSizeF& constraint /*= QSizeF()*/) const -{ - if (which == Qt::MinimumSize) { - return QSizeF(-1, 48); - } - //return constraint; - - auto size = __super::sizeHint(which, constraint); - //size.setHeight(80); - LOG_DEBUG("rap") << "# sizehint: " << size << std::endl; - return size; -} - -void shelllet::interpreter::DropArea::removeItem(QGraphicsLayoutItem* item) -{ - Q_D(DropArea); - d->layout->removeItem(item); - scene()->removeItem(dynamic_cast(item)); - delete item; -} - -void shelllet::interpreter::DropArea::addItem(QGraphicsLayoutItem* item) -{ - Q_D(DropArea); - d->layout->addItem(item); - d->layout->setAlignment(item, Qt::AlignHCenter | Qt::AlignVCenter); -} - - - -void shelllet::interpreter::DropArea::hideExtraItem() -{ - Q_D(DropArea); - removeItem(d->arrowNext); - removeItem(d->placeholder); - d->arrowNext = nullptr; - d->placeholder = nullptr; - d->layout->invalidate(); -} - -void shelllet::interpreter::DropArea::showExtraItem() -{ - Q_D(DropArea); - d->placeholder = new PlaceholderItem(this); - d->arrowNext = new ArrowItem(this); - addItem(d->placeholder); - addItem(d->arrowNext); -} - diff --git a/QtRpa/modules/interpreter/src/element.cpp b/QtRpa/modules/interpreter/src/element.cpp deleted file mode 100644 index da6ce08..0000000 --- a/QtRpa/modules/interpreter/src/element.cpp +++ /dev/null @@ -1,290 +0,0 @@ -//#include "properties/helper.h" -#include "interpreter/composite_property.h" -#include "interpreter/containeritem.h" -#include "interpreter/element.h" -#include "common/private/object_p.h" -#include "qgraphicslinearlayout.h" -#include "qpainter.h" -#include "qstyleoption.h" -#include "qapplication.h" -#include "qgraphicsscene.h" -#include "qaction.h" -#include "qmenu.h" -#include "events.hpp" -#include "qgraphicssceneevent.h" -#include "interpreter/private/element_p.h" -#include "interpreter/elementmimedata.h" -#include "qdrag.h" -#include "qmimedata.h" -#include "qpixmap.h" -#include "qbitmap.h" -#include "model.hpp" -namespace shelllet { - namespace interpreter { - } - -} - -shelllet::interpreter::Element::Element(ElementPrivate& d, QGraphicsItem* parent /*= nullptr*/, Object* p /*= nullptr*/) - : Component(d, parent, Qt::Window /*| Qt::WindowTitleHint*/) -{ - //setWindowTitle(*property->displayName().toQString()); - - QAction* action = new QAction("delete", this); - QAction* refresh = new QAction("refresh", this); - connect(action, &QAction::triggered, this, [this]() { - auto* parent = dynamic_cast(parentWidget()); - if (parent) { - auto* sc = scene(); - //parent->removeItem(parent->indexWidget(this)+1); - parent->removeItem(this); - QCoreApplication::postEvent(sc, new AdjustSizeEvent, Qt::LowEventPriority); - } - }); - - connect(refresh, &QAction::triggered, this, [this]() { - QCoreApplication::postEvent(scene(), new AdjustSizeEvent, Qt::LowEventPriority); - }); - - //connect(prop(), &CompositeProperty::displayNameChanged, [this]() { - // setWindowTitle(*prop()->displayName().toQString()); - // update(); - //}); - addAction(action); - addAction(refresh); - - setFlag(QGraphicsItem::ItemIsSelectable); - -} - -shelllet::interpreter::Element::Element(QGraphicsItem* parent /*= nullptr*/, Object* p /*= nullptr*/) - : Element(*new ElementPrivate, parent, p) -{ - -} - -void shelllet::interpreter::Element::contextMenuEvent(QGraphicsSceneContextMenuEvent* event) -{ - QMenu menu; - menu.addActions(actions()); - menu.exec(event->screenPos()); -} - - - -Qt::WindowFrameSection shelllet::interpreter::Element::windowFrameSectionAt(const QPointF& pos) const -{ - //throw std::logic_error("The method or operation is not implemented."); - auto section = __super::windowFrameSectionAt(pos); - //switch (section) - //{ - if (section != Qt::TitleBarArea) { - //return Qt::NoSection; - } - // return Qt::NoSection; - //default: - // break; - //} - return section; -} - -bool shelllet::interpreter::Element::windowFrameEvent(QEvent* e) -{ - Q_D(Element); - //return __super::windowFrameEvent(e); - //throw std::logic_error("The method or operation is not implemented."); - if (e->type() == QEvent::GraphicsSceneMouseMove) { - if (windowFrameSectionAt(dynamic_cast(e)->pos()) == Qt::TitleBarArea) { - - QDrag* drag = new QDrag(this); - - drag->setMimeData(mimeData()); - - QPixmap pixmap(34, 34); - pixmap.fill(Qt::white); - - QPainter painter(&pixmap); - painter.translate(15, 15); - painter.setRenderHint(QPainter::Antialiasing); - paint(&painter, nullptr, nullptr); - painter.end(); - - pixmap.setMask(pixmap.createHeuristicMask()); - - drag->setPixmap(pixmap); - drag->setHotSpot(QPoint(15, 20)); - - drag->exec(); - // setCursor(Qt::OpenHandCursor); - - e->accept(); - - return e->isAccepted(); - } - } - return __super::windowFrameEvent(e); -} - -QMimeData* shelllet::interpreter::Element::mimeData() -{ - Q_D(const Element); - //XmlMimeData* mime = new ElementMimeData; -// mime->setElementItem(this); - //XmlByteArrayWriter writer; - //d->prop->getNode()->print(writer); - - //mime->setData(Environment::getInstance()->getOptions()->mime_data_type, writer.result); - - auto* mime_data = new XmlMimeData(prop()->getNode()->documentElement()); - - mime_data->setSourceItem(this); - - return mime_data; -} - - -void shelllet::interpreter::Element::addItem(Element* item) -{ - throw std::logic_error("The method or operation is not implemented."); -} - - - - -// -//void shelllet::graphics::Element::removeItem(QGraphicsLayoutItem* item) -//{ -// -//} - -void shelllet::interpreter::Element::paintWindowFrame(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget /*= nullptr*/) -{ - Q_D(Element); - //const bool fillBackground = !testAttribute(Qt::WA_OpaquePaintEvent) - // && !testAttribute(Qt::WA_NoSystemBackground); - //QGraphicsProxyWidget* proxy = qobject_cast(this); - //const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget(); - - //if (rect().contains(option->exposedRect)) { - // if (fillBackground && !embeddedWidgetFillsOwnBackground) - //painter->fillRect(option->exposedRect, palette().window()); - // return; - //} - - - - QRect windowFrameRect = QRect(QPoint(), windowFrameGeometry().size().toSize()); - - QStyleOptionTitleBar bar; - bar.initFrom(widget); - bar.icon = prop()->icon(); - bar.text = windowTitle(); - bar.QStyleOption::operator=(*option); - - bar.subControls = QStyle::SC_TitleBarCloseButton | QStyle::SC_TitleBarLabel; - - // d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state - //d->ensureWindowData(); - //bar.state.setFlag(QStyle::State_MouseOver, d->windowData->buttonMouseOver); - //bar.state.setFlag(QStyle::State_Sunken, d->windowData->buttonSunken); - bar.rect = windowFrameRect; - - // translate painter to make the style happy - const QPointF styleOrigin = this->windowFrameRect().topLeft(); - painter->translate(styleOrigin); - - - // Fill background - //QStyleHintReturnMask mask; - //bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty(); - //bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget); - //int frameWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, &bar, widget); - //if (setMask) { - // painter->save(); - // painter->setClipRegion(mask.region, Qt::IntersectClip); - //} - //if (fillBackground) { - // if (embeddedWidgetFillsOwnBackground) { - // // Don't fill the background twice. - // QPainterPath windowFrameBackground; - // windowFrameBackground.addRect(windowFrameRect); - // // Adjust with 0.5 to avoid border artifacts between - // // widget background and frame background. - // windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5)); - // painter->fillPath(windowFrameBackground, palette().window()); - // } - // else { - // painter->fillRect(windowFrameRect, palette().window()); - // } - //} - - //// Draw title - int height = style()->pixelMetric(QStyle::PM_TitleBarHeight, &bar); - bar.rect.setHeight(height); - //if (hasBorder) // Frame is painted by PE_FrameWindow - //bar.rect.adjust(d->frameWidth, d->frameWidth, -d->frameWidth, 0); - - //painter->save(); - //painter->setFont(QApplication::font("QMdiSubWindowTitleBar")); - style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget); - //painter->restore(); - //if (setMask) - // painter->restore(); - //// Draw window frame - QStyleOptionGroupBox frameOptions; - frameOptions.QStyleOption::operator=(*option); - //initStyleOption(&frameOptions); - //if (!hasBorder) - // painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip); - //frameOptions.state.setFlag(QStyle::State_HasFocus, hasFocus()); - bool isActive = isActiveWindow(); - //frameOptions.state.setFlag(QStyle::State_Active, isActive); - - frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal); - frameOptions.rect = windowFrameRect; - frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, nullptr, widget); - frameOptions.midLineWidth = 1; - style()->drawPrimitive(QStyle::PE_FrameGroupBox, &frameOptions, painter, widget); - - //QGraphicsWidget::paintWindowFrame(painter, option, widget); -} -shelllet::interpreter::CompositeProperty* shelllet::interpreter::Element::prop() -{ - Q_D(Element); - //return nullptr; - throw std::logic_error(""); - //return d->prop; -} - -shelllet::interpreter::Component* shelllet::interpreter::Element::nextItem() const -{ - //throw std::logic_error("The method or operation is not implemented."); - - auto* parent = dynamic_cast(parentWidget()); - if (parent) { - - //parent->removeItem(); - //parent->removeItem(this); - - return parent->itemAt(parent->indexWidget(this) + 1); - - //QCoreApplication::postEvent(sc, new AdjustSizeEvent, Qt::LowEventPriority); - } - - return nullptr; -} -// -//shelllet::graphics::Element* shelllet::graphics::Element::CreateElement(const py::object& property, QGraphicsItem* parent /*= nullptr*/) -//{ -// Element* element = nullptr; -// QString ns = GetNamespace(QUOTED(Container)) + property->metaName() + "*"; -// if (int id = QMetaType::type(ns.toUtf8()); id != QMetaType::UnknownType) { -// const auto* meta = QMetaType::metaObjectForType(id); -// element = dynamic_cast(meta->newInstance(Q_ARG(SharedPointer, property), Q_ARG(QGraphicsItem*, parent))); -// } -// else { -// LOG_WARNING("rpa") << "# meta type is unknown: " << property->metaName() << "-" << std::endl; -// } -// Q_ASSERT_X(element != nullptr, "Create Graphics Widget", "element is null"); -// return element; -//} diff --git a/QtRpa/modules/interpreter/src/elementmimedata.cpp b/QtRpa/modules/interpreter/src/elementmimedata.cpp deleted file mode 100644 index dfff3e7..0000000 --- a/QtRpa/modules/interpreter/src/elementmimedata.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "interpreter/elementmimedata.h" -#include "interpreter/private/elementmimedata_p.h" - -shelllet::interpreter::ElementMimeData::ElementMimeData() - : MimeData(*new ElementMimeDataPrivate) -{ - -} - -void shelllet::interpreter::ElementMimeData::setElementItem(Element* item) -{ - Q_D(ElementMimeData); - d->item = item; -} - -shelllet::interpreter::Element* shelllet::interpreter::ElementMimeData::elementItem() const -{ - Q_D(const ElementMimeData); - return d->item; -} diff --git a/QtRpa/modules/interpreter/src/image_match_implement.cpp b/QtRpa/modules/interpreter/src/image_match_implement.cpp deleted file mode 100644 index f009aaf..0000000 --- a/QtRpa/modules/interpreter/src/image_match_implement.cpp +++ /dev/null @@ -1,166 +0,0 @@ -//#include "framework.h" -//#include "context_module.h" -//#include "v8_object_wrapped.h" -//#include "image_wrapped.h" -// -//namespace shelllet { -// const int kMax = 0xff; -// static std::list MatchingMethod(const cv::Mat& m1, const cv::Mat& tm, double threshold, std::uint32_t match_method, std::uint8_t max) -// { -// int result_cols = m1.cols - tm.cols + 1; -// int result_rows = m1.rows - tm.rows + 1; -// -// cv::Mat result; -// result.create(result_rows, result_cols, CV_32FC1); -// -// cv::matchTemplate(m1, tm, result, match_method); -// std::list rects; -// -// if (match_method == cv::TM_SQDIFF || match_method == cv::TM_SQDIFF_NORMED) -// { -// //cv::threshold(result, result, threshold, 0, THRESH_TOZERO_INV); -// -// while (true) -// { -// double min_value; -// cv::Point min_loc; -// -// minMaxLoc(result, &min_value, 0, &min_loc, 0); -// -// if (min_value <= threshold) { -// floodFill(result, min_loc, cv::Scalar(1), 0, cv::Scalar(0), cv::Scalar(0)); -// rects.push_back({ min_loc.x, min_loc.y , tm.cols, tm.rows }); -// if (rects.size() >= max || rects.size() >= kMax) // avoid dead loop -// break; -// } -// else { -// break; -// } -// } -// -// return rects; -// } -// -// // cv::threshold(result, result, threshold, 0, cv::THRESH_TOZERO); -// -// while (true) { -// double max_value; -// cv::Point max_loc; -// minMaxLoc(result, 0, &max_value, 0, &max_loc); -// -// if (max_value >= threshold) { -// floodFill(result, max_loc, cv::Scalar(0), 0, cv::Scalar(), cv::Scalar()); -// rects.push_back({ max_loc.x, max_loc.y, tm.cols, tm.rows }); -// if (rects.size() >= max || rects.size() >= kMax) -// break; -// } -// else { -// break; -// } -// } -// -// return rects; -// } -//} -// -//std::list shelllet::image::Image::match(const cv::Mat& tpl, double threshold, int method, int max) -//{ -// cv::Mat grey; -// cv::Mat grey_template; -// -// // cvtColor(image_, grey, cv::COLOR_BGR2GRAY); -// cvtColor(tpl, grey_template, cv::COLOR_BGR2GRAY); -// -// return MatchingMethod(grey, grey_template, threshold, method, max); -//} -// -//void shelllet::image::Image::Match(const v8::FunctionCallbackInfo& args) -//{ -// V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) -// { -// cv::Mat template_image; -// -// if (args.Length() < 1 || !args[0]->IsString()) { -// //THROW_EXCEPTION_VAR(isolate, CONTEXT_CAST(isolate)->getLanguageText("plugin.l1").c_str()); -// return; -// } -// -// v8::String::Utf8Value value(isolate, args[0]); -// if (std::filesystem::exists(std::filesystem::path(*value))) { -// try -// { -// template_image = cv::imread(*value); -// } -// catch (const cv::Exception& exception) -// { -// //THROW_EXCEPTION_VAR(isolate, exception.msg.c_str()); -// return; -// } -// } -// else { -// //auto& images = CONTEXT_CAST(isolate)->getModel()->images; -// } -// //auto itor = images.find(*value); -// //if (itor == images.end()) { -// //boost::format format = boost::format(CONTEXT_CAST(isolate)->getLanguageText("model.image.l1").c_str()) % *value; -// //THROW_EXCEPTION_VAR(isolate, format.str().c_str()); -// // return; -// // } -// // else { -// try -// { -// // template_image = cv::imdecode(cv::Mat(1, static_cast(itor->second.size()), CV_8UC1, itor->second.data()), cv::IMREAD_UNCHANGED); -// } -// catch (const cv::Exception& exception) -// { -// //THROW_EXCEPTION_VAR(isolate, exception.msg.c_str()); -// return; -// } -// //} -// -// if (template_image.empty()) { -// //THROW_EXCEPTION_VAR(isolate, CONTEXT_CAST(isolate)->getLanguageText("image.l1").c_str()); -// return; -// } -// -// double threshold = 1.0; -// std::uint32_t method = cv::TM_CCORR_NORMED; -// std::uint8_t max = 1; -// -// if (args.Length() > 1 && args[1]->IsNumber()) -// { -// threshold = args[1]->NumberValue(isolate->GetCurrentContext()).FromJust(); -// } -// -// if (args.Length() > 2 && args[2]->IsUint32()) -// { -// method = args[2]->Uint32Value(isolate->GetCurrentContext()).FromJust(); -// } -// -// if (args.Length() > 3 && args[3]->IsUint32()) -// { -// max = args[3]->Uint32Value(isolate->GetCurrentContext()).FromJust(); -// } -// -// Image* image = UnWrap(args.This()); -// -// std::list rects = image->match(template_image, threshold, method, max); -// -// v8::Local< v8::Array> array = v8::Array::New(isolate, rects.size()); -// int i = 0; -// -// while (!rects.empty()) -// { -// auto& rc = rects.front(); -// v8::Local argv[] = { v8::Int32::New(isolate, rc.x()), -// v8::Int32::New(isolate, rc.y()), -// v8::Int32::New(isolate, rc.width()), -// v8::Int32::New(isolate, rc.height()) -// }; -// array->Set(context, i++, Wrap(isolate, context, "Rect", std::size(argv), argv)); -// rects.pop_front(); -// } -// -// args.GetReturnValue().Set(array); -// } -//} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/keyboard.xx b/QtRpa/modules/interpreter/src/keyboard.xx deleted file mode 100644 index b53f6b0..0000000 --- a/QtRpa/modules/interpreter/src/keyboard.xx +++ /dev/null @@ -1,149 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/keyboard.h" -#include "qt_windows.h" -namespace shelllet { - namespace interpreter { - - - class KeyboardPrivate : public ObjectPrivate { - - std::pair>> Keyboard::hhk; - }; - } - - -} - -shelllet::interpreter::Keyboard::Keyboard(const v8::FunctionCallbackInfo& args) - : Keyboard(*KeyboardPrivate) -{ -} - -shelllet::interpreter::Keyboard::Keyboard(KeyboardPrivate& d) - : Object(d, nullptr) -{ - -} - - -LPINPUT shelllet::interpreter::Keyboard::SendInput(WORD wVk, BOOL u) -{ - LPINPUT input = new INPUT{ 0 }; - - input->type = INPUT_KEYBOARD; - input->ki.wScan = u ? wVk : 0; - input->ki.time = 0; - input->ki.dwExtraInfo = 0; - - input->ki.dwFlags = u ? KEYEVENTF_UNICODE : 0; - input->ki.wVk = u ? 0 : wVk; - - if (Invoke<&::SendInput>(1, input, sizeof(INPUT)) == 0) - return nullptr; - - return input; -} - -UINT shelllet::interpreter::Keyboard::Release(LPINPUT input) -{ - if (!input) - return 0; - - if (input->ki.dwFlags & KEYEVENTF_UNICODE) { - input->ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; - } - else { - input->ki.dwFlags = KEYEVENTF_KEYUP; - } - - BOOST_SCOPE_EXIT(input) { - delete input; - }BOOST_SCOPE_EXIT_END - - return Invoke<&::SendInput>(1, input, sizeof(INPUT)); -} - -void shelllet::interpreter::Keyboard::SendText(const std::wstring& text) -{ - std::for_each(text.begin(), text.end(), [](wchar_t ch) { - Release(SendInput(ch, TRUE)); - }); -} - -SHORT shelllet::interpreter::Keyboard::KeyCode(char ch) -{ - return Invoke<&::VkKeyScanExA>(ch, GetKeyboardLayout(0)); -} - -void shelllet::interpreter::Keyboard::Simulate(const std::vector& wVks) -{ - std::stack inputs; - std::random_device gen; - std::uniform_int_distribution<> dist{ 50, 150 }; - - for (auto& k : wVks) { - inputs.push(SendInput(k, FALSE)); - std::this_thread::sleep_for(std::chrono::milliseconds(dist(gen))); - } - - while (!inputs.empty()) { - LPINPUT input = inputs.top(); - Release(input); - std::this_thread::sleep_for(std::chrono::milliseconds(dist(gen))); - inputs.pop(); - } -} - -std::string shelllet::interpreter::Keyboard::KeyName(WORD wVk) -{ - UINT wScan = Invoke<&::MapVirtualKey>(wVk, MAPVK_VK_TO_VSC); - std::vector buffer(0xff, '\0'); - - switch (wVk) { - case VK_LEFT: case VK_UP: case VK_RIGHT: case VK_DOWN: - case VK_RCONTROL: case VK_RMENU: - case VK_LWIN: case VK_RWIN: case VK_APPS: - case VK_PRIOR: case VK_NEXT: - case VK_END: case VK_HOME: - case VK_INSERT: case VK_DELETE: - case VK_DIVIDE: - case VK_NUMLOCK: - wScan |= KF_EXTENDED; - default: - Invoke<&::GetKeyNameTextW>(wScan << 16, buffer.data(), 0xff); - } - - return std::string(buffer.begin(), buffer.end()); -} - -void shelllet::interpreter::Keyboard::InstallHook(const v8::Local& fn) -{ - if (Keyboard::hhk.first && !Invoke<&::UnhookWindowsHookEx>(Keyboard::hhk.first)) - return; - - Keyboard::hhk = std::make_pair(Invoke<&::SetWindowsHookEx>(WH_KEYBOARD_LL, [](int nCode, WPARAM wParam, LPARAM lParam) -> LRESULT - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - //V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - if (nCode == HC_ACTION) - { - if (!Keyboard::hhk.second.IsEmpty()) - { - v8::Local argv[] = { v8::Int32::New(isolate, wParam), Keyboard::Convert(context, reinterpret_cast(lParam)) }; - Keyboard::hhk.second.Get(isolate)->Call(context, context->Global(), std::size(argv), argv); - } - } - - return ::CallNextHookEx(NULL, nCode, wParam, lParam); - } - // V8_CREATE_LOCAL_CONTEXT_END - }, ::GetModuleHandle(NULL), 0), v8::Persistent>(isolate, fn)); -} - -BOOL shelllet::interpreter::Keyboard::RemoveHook() -{ - auto ret = Invoke<&::UnhookWindowsHookEx>(Keyboard::hhk.first); - Keyboard::hhk.first = nullptr; - return ret; -} diff --git a/QtRpa/modules/interpreter/src/mouse.xx b/QtRpa/modules/interpreter/src/mouse.xx deleted file mode 100644 index 44f4926..0000000 --- a/QtRpa/modules/interpreter/src/mouse.xx +++ /dev/null @@ -1,118 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/mouse.h" -#include "windows.h" -namespace shelllet { - - namespace interpreter { - - - class MousePrivate : public ObjectPrivate { - public: - HHOOK hhk; - - }; - } - -} - -shelllet::interpreter::Mouse::Mouse() - : Mouse(*new MousePrivate) -{ -} - -shelllet::interpreter::Mouse::Mouse(MousePrivate& d) - : Object(d, nullptr) -{ - -} - - - - -void shelllet::interpreter::Mouse::Move(int x, int y) -{ - INPUT input = { 0 }; - input.type = INPUT_MOUSE; - input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_VIRTUALDESK | MOUSEEVENTF_ABSOLUTE; - input.mi.mouseData = 0; - input.mi.time = 0; - input.mi.dwExtraInfo = 0; - //The cursor is divided into 65535 pieces in the screen - input.mi.dx = std::ceil(x * (65535.0f / (::GetSystemMetrics(SM_CXSCREEN) - 1))); - input.mi.dy = std::ceil(y * (65535.0f / (::GetSystemMetrics(SM_CYSCREEN) - 1))); - - Invoke<&::SendInput>(1, &input, sizeof(INPUT)); -} - -void shelllet::interpreter::Mouse::Click() -{ - INPUT input = { 0 }; - input.type = INPUT_MOUSE; - input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; - Invoke< &::SendInput>(1, &input, sizeof(INPUT)); - - std::random_device gen; - std::uniform_int_distribution<> dist{ 10, 50 }; - std::this_thread::sleep_for(std::chrono::milliseconds(dist(gen))); - - ::ZeroMemory(&input, sizeof(INPUT)); - input.type = INPUT_MOUSE; - input.mi.dwFlags = MOUSEEVENTF_LEFTUP; - Invoke<&::SendInput>(1, &input, sizeof(INPUT)); -} - -void shelllet::interpreter::Mouse::RightClick() -{ - INPUT input = { 0 }; - input.type = INPUT_MOUSE; - input.mi.dwFlags = MOUSEEVENTF_RIGHTDOWN; - - Invoke<&::SendInput>(1, &input, sizeof(INPUT)); - - ::ZeroMemory(&input, sizeof(INPUT)); - input.type = INPUT_MOUSE; - input.mi.dwFlags = MOUSEEVENTF_RIGHTUP; - Invoke<&::SendInput>(1, &input, sizeof(INPUT)); -} - -void shelllet::interpreter::Mouse::MoveAndClick(int x, int y) -{ - Move(x, y); - std::random_device gen; - std::uniform_int_distribution<> dist{ 100, 200 }; - std::this_thread::sleep_for(std::chrono::milliseconds(dist(gen))); - Click(); -} - -void shelllet::interpreter::Mouse::InstallHook() -{ - if (Mouse::hhk.first && !Invoke<&::UnhookWindowsHookEx>(Mouse::hhk.first)) - return; - - Mouse::hhk = std::make_pair(Invoke<&::SetWindowsHookEx>(WH_MOUSE_LL, [](int nCode, WPARAM wParam, LPARAM lParam) -> LRESULT - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - if (nCode == HC_ACTION) - { - if (!Mouse::hhk.second.IsEmpty()) - { - v8::Local argv[] = { v8::Int32::New(isolate, wParam), Mouse::Convert(context, reinterpret_cast(lParam)) }; - - Mouse::hhk.second.Get(isolate)->Call(context, context->Global(), std::size(argv), argv); - } - } - - return ::CallNextHookEx(NULL, nCode, wParam, lParam); - } - V8_CREATE_LOCAL_CONTEXT_END - }, ::GetModuleHandle(NULL), 0), v8::Persistent>(isolate, fn)); -} - -BOOL shelllet::interpreter::Mouse::RemoveHook() -{ - auto ret = Invoke<&::UnhookWindowsHookEx>(Mouse::hhk.first); - Mouse::hhk.first = nullptr; - return ret; -} diff --git a/QtRpa/modules/interpreter/src/mybase.cpp b/QtRpa/modules/interpreter/src/mybase.cpp deleted file mode 100644 index a49e786..0000000 --- a/QtRpa/modules/interpreter/src/mybase.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "pybind11/pybind11.h" -#include "common.hpp" -#include "interpreter/mybase.h" -#include "common/private/object_p.h" -#include "interpreter/private/mybase_p.h" - -shelllet::interpreter::Mybase::Mybase() - //:Object(*new MybasePrivate, nullptr) -{ -}; - -std::string shelllet::interpreter::Mybase::name() -{ - return ""; -} - - - -PYBIND11_MODULE(example, m) { - -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/placeholderitem.cpp b/QtRpa/modules/interpreter/src/placeholderitem.cpp deleted file mode 100644 index 93416ed..0000000 --- a/QtRpa/modules/interpreter/src/placeholderitem.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "interpreter/placeholderitem.h" -#include "qpainter.h" -#include "qsvgrenderer.h" -#include "common/private/object_p.h" -namespace shelllet { - namespace interpreter { - class PlaceholderItemPrivate : public ObjectPrivate { - public: - - }; - - } -} - -shelllet::interpreter::PlaceholderItem::PlaceholderItem(QGraphicsItem* parent) - : QGraphicsRectItem(parent) - , Object(*new PlaceholderItemPrivate, nullptr) -{ - Q_D(PlaceholderItem); - setGraphicsItem(this); -} - - - -QRectF shelllet::interpreter::PlaceholderItem::boundingRect() const -{ - return { QPointF(0, 0), geometry().size() }; -} - -void shelllet::interpreter::PlaceholderItem::setGeometry(const QRectF& rect) -{ - prepareGeometryChange(); - QGraphicsLayoutItem::setGeometry(rect); - setPos(rect.topLeft()); -} - -QSizeF shelllet::interpreter::PlaceholderItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint /*= QSizeF()*/) const -{ - if (which == Qt::MinimumSize) { - return QSizeF(-1, 24); - } - return constraint; -} - -void shelllet::interpreter::PlaceholderItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget /*= nullptr*/) -{ - Q_UNUSED(widget); - - painter->fillRect(boundingRect(), Qt::Dense3Pattern); -} diff --git a/QtRpa/modules/interpreter/src/process.xx b/QtRpa/modules/interpreter/src/process.xx deleted file mode 100644 index 84c502c..0000000 --- a/QtRpa/modules/interpreter/src/process.xx +++ /dev/null @@ -1,321 +0,0 @@ -#include "interpreter/process.h" -#include "boost/range.hpp" -#include "boost/range/adaptors.hpp" -#include "boost/range/adaptor/transformed.hpp" -bool shelllet::interpreter::Process::Start(const String& filename, const Vector& args) -{ - const char* quoted = R"(")"; - QString fixed = QString::fromStdString(file); - if (fixed.contains(" ")) { - if (!fixed.startsWith(quoted)) { - fixed = quoted + fixed; - } - - if (!fixed.endsWith(quoted)) { - fixed = fixed + quoted; - } - } - - if (args.empty()) { - return QProcess::startDetached(fixed); - } - QVector arguments(args.size()); - std::for_each(args.begin(), args.end(), [&arguments](const std::string& arg) { - arguments.push_back(QString::fromStdString(arg)); - }); - return QProcess::startDetached(fixed, QStringList::fromVector(arguments)); -} - - -BOOL shelllet::windows::__Process::EnumModule(DWORD th32ProcessID, const std::function& cb) -{ - HANDLE hSnapshot = Invoke<&::CreateToolhelp32Snapshot>(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, th32ProcessID); - if (hSnapshot == INVALID_HANDLE_VALUE) { - return FALSE; - } - - BOOST_SCOPE_EXIT(hSnapshot) { - Invoke<&::CloseHandle>(hSnapshot); - }BOOST_SCOPE_EXIT_END; - - MODULEENTRY32W entry = { 0 }; - entry.dwSize = sizeof(MODULEENTRY32W); - - if (!Invoke<&::Module32FirstW>(hSnapshot, &entry)) { - return FALSE; - } - - do { - if (!cb || !cb(&entry)) break; - } while (Invoke<&::Module32NextW>(hSnapshot, &entry)); - - return ::GetLastError() != ERROR_NO_MORE_FILES; -} - -BOOL shelllet::windows::__Process::EnumProcess(const std::function& cb) -{ - HANDLE hSnapshot = Invoke<&::CreateToolhelp32Snapshot>(TH32CS_SNAPPROCESS, 0); - if (hSnapshot == INVALID_HANDLE_VALUE) { - return FALSE; - } - - BOOST_SCOPE_EXIT(hSnapshot) { - Invoke<&::CloseHandle>(hSnapshot); - }BOOST_SCOPE_EXIT_END; - - PROCESSENTRY32W entry = { 0 }; - entry.dwSize = sizeof(PROCESSENTRY32W); - - if (!Invoke<&::Process32FirstW>(hSnapshot, &entry)) { - return FALSE; - } - - do { - if (!cb || !cb(&entry)) break; - } while (Invoke<&::Process32NextW>(hSnapshot, &entry)); - - return ::GetLastError() != ERROR_NO_MORE_FILES; -} - -BOOL shelllet::windows::__Process::EnumThread(const std::function& cb) -{ - HANDLE hSnapshot = Invoke<&::CreateToolhelp32Snapshot>(TH32CS_SNAPTHREAD, 0); - if (hSnapshot == INVALID_HANDLE_VALUE) { - return FALSE; - } - - BOOST_SCOPE_EXIT(hSnapshot) { - Invoke<&::CloseHandle>(hSnapshot); - }BOOST_SCOPE_EXIT_END; - - THREADENTRY32 entry = { 0 }; - entry.dwSize = sizeof(THREADENTRY32); - - if (!Invoke<&::Thread32First>(hSnapshot, &entry)) { - return FALSE; - } - - do { - if (!cb || !cb(&entry)) break; - } while (Invoke<&::Thread32Next>(hSnapshot, &entry)); - - return ::GetLastError() != ERROR_NO_MORE_FILES; -} - -BOOL shelllet::windows::__Process::RunAs(const std::wstring& username, const std::wstring& password, const std::wstring& application, const std::wstring& commandLine, const std::wstring& currentDirectory) -{ - STARTUPINFOW siw = { 0 }; - siw.cb = sizeof(STARTUPINFOW); - - std::wstring wch = commandLine; - int maxSize = wch.length() > 1024 ? 1024 : wch.length(); // The maximum length of this string is 1024 characters. - std::vector buffer(maxSize, 0); - std::wmemcpy(buffer.data(), wch.c_str(), maxSize); - PROCESS_INFORMATION processInformation = { 0 }; - // including the Unicode terminating null character - if (Invoke<&::CreateProcessWithLogonW>( - username.c_str(), - nullptr, // change to L"." to use local account database only - password.c_str(), - LOGON_WITH_PROFILE, - application.c_str(), - buffer.data(), - CREATE_UNICODE_ENVIRONMENT, nullptr, currentDirectory.empty() ? nullptr : currentDirectory.c_str(), &siw, &processInformation)) { - ::CloseHandle(siw.hStdError); - ::CloseHandle(siw.hStdInput); - ::CloseHandle(siw.hStdOutput); - ::CloseHandle(processInformation.hThread); - ::CloseHandle(processInformation.hProcess); - return TRUE; - } - return FALSE; -} - -BOOL shelllet::windows::__Process::CreateProcessWithToken(HANDLE hToken, const std::wstring& application, const std::wstring& commandLine, const std::wstring& currentDirectory) -{ - STARTUPINFOW siw = { 0 }; - siw.cb = sizeof(STARTUPINFOW); - - SECURITY_ATTRIBUTES security = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; - - std::wstring wch = commandLine; - int maxSize = wch.length() > 1024 ? 1024 : wch.length(); // The maximum length of this string is 1024 characters. - std::vector buffer(maxSize, 0); - std::wmemcpy(buffer.data(), wch.c_str(), maxSize); - PROCESS_INFORMATION processInformation = { 0 }; - - if (Invoke < &::CreateProcessWithTokenW>(hToken, LOGON_WITH_PROFILE, - application.c_str(), - buffer.data(), - NORMAL_PRIORITY_CLASS, // dwCreationFlags - nullptr, - currentDirectory.empty() ? nullptr : currentDirectory.c_str(), - &siw, &processInformation)) { - ::CloseHandle(siw.hStdError); - ::CloseHandle(siw.hStdInput); - ::CloseHandle(siw.hStdOutput); - ::CloseHandle(processInformation.hThread); - ::CloseHandle(processInformation.hProcess); - return TRUE; - } - return FALSE; -} - -HANDLE shelllet::windows::__Process::OpenProcessToken(DWORD dwProcessId, DWORD desiredAccess /*= TOKEN_QUERY | TOKEN_DUPLICATE*/) -{ - HANDLE hProcess = Invoke<&::OpenProcess>(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, dwProcessId); - if (hProcess == NULL) { - return INVALID_HANDLE_VALUE; - } - - BOOST_SCOPE_EXIT(hProcess) { - ::CloseHandle(hProcess); - }BOOST_SCOPE_EXIT_END - ; - HANDLE hToken; - if (!Invoke<&::OpenProcessToken>(hProcess, TOKEN_QUERY | TOKEN_DUPLICATE, &hToken)) { - return INVALID_HANDLE_VALUE; - } - return hToken; -} - -HANDLE shelllet::windows::__Process::OpenProcessToken() -{ - HANDLE hToken = INVALID_HANDLE_VALUE; - if (!Invoke<&::OpenThreadToken>(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, TRUE, &hToken)) { - if (GetLastError() != ERROR_NO_TOKEN) { - return FALSE; - } - - // Retry against process token if no thread token exists. - if (!Invoke<&::OpenProcessToken>(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { - return FALSE; - } - } - return hToken; -} - -BOOL shelllet::windows::__Process::AdjustTokenPrivileges(HANDLE hToken, const std::wstring& name, bool e) -{ - LUID luid; - TOKEN_PRIVILEGES tp; - - if (!Invoke<&::LookupPrivilegeValueW>( - nullptr, // lookup privilege on local system - name.c_str(), // privilege to lookup - &luid)) { // receives LUID of privilege - return FALSE; - } - - tp.PrivilegeCount = 1; - tp.Privileges[0].Luid = luid; - tp.Privileges[0].Attributes = e ? SE_PRIVILEGE_ENABLED : 0; - - if (!Invoke<&::AdjustTokenPrivileges>( - hToken, - FALSE, - &tp, - sizeof(TOKEN_PRIVILEGES), - nullptr, - nullptr)) { - return FALSE; - } - - if (GetLastError() != ERROR_SUCCESS) { - return FALSE; - } - return TRUE; -} - -BOOL shelllet::windows::__Process::RunAsDesktop(const std::wstring& application, const std::wstring& commandLine, const std::wstring& currentDirectory) -{ - // Enable SeIncreaseQuotaPrivilege in this process. (This won't work if current process is not elevated.) - { - HANDLE hToken = OpenProcessToken(); - BOOST_SCOPE_EXIT(hToken) { - ::CloseHandle(hToken); - }BOOST_SCOPE_EXIT_END; - - if (!AdjustTokenPrivileges(hToken, SE_INCREASE_QUOTA_NAME, true)) - return FALSE; - } - - // Get an HWND representing the desktop shell. - // CAVEATS: This will fail if the shell is not running (crashed or terminated), or the default shell has been - // replaced with a custom shell. This also won't return what you probably want if Explorer has been terminated and - // restarted elevated. - DWORD dwProcessId = 0; - { - HWND hWnd = Invoke<&::GetShellWindow>(); - if (hWnd == NULL) { - return FALSE; - } - // Get the PID of the desktop shell process. - GetWindowThreadProcessId(hWnd, &dwProcessId); - } - - // Get the process token of the desktop shell. - HANDLE hExistingToken = OpenProcessToken(dwProcessId); - BOOST_SCOPE_EXIT(hExistingToken) { - CloseHandle(hExistingToken); - }BOOST_SCOPE_EXIT_END; - HANDLE hNewToken = NULL; - - // Duplicate the shell's process token to get a primary token. - // Based on experimentation, this is the minimal set of rights required for CreateProcessWithTokenW (contrary to current documentation). - const DWORD dwDesiredAccess = TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_ADJUST_SESSIONID; - if (!Invoke<&::DuplicateTokenEx>(hExistingToken, dwDesiredAccess, nullptr, SecurityImpersonation, TokenPrimary, &hNewToken)) { - return FALSE; - } - - BOOST_SCOPE_EXIT(hNewToken) { - CloseHandle(hNewToken); - }BOOST_SCOPE_EXIT_END; - - return CreateProcessWithToken(hNewToken, application, commandLine, currentDirectory); -} - -std::pair shelllet::windows::__Process::GetUserFromProcess(DWORD dwProcessId) -{ - PTOKEN_USER tokenUser = TokenInformation(dwProcessId); - - BOOST_SCOPE_EXIT(tokenUser) { - ::HeapFree(GetProcessHeap(), 0, (LPVOID)tokenUser); - }BOOST_SCOPE_EXIT_END; - - SID_NAME_USE peUse; - DWORD cchName = 0; - DWORD cchReferencedDomainName = 0; - - if (!Invoke<&::LookupAccountSidW>(nullptr, tokenUser->User.Sid, nullptr, &cchName, nullptr, &cchReferencedDomainName, &peUse)) { - return std::make_pair(L"", L""); - } - - std::vector name(cchName); - std::vector referencedDomainName(cchReferencedDomainName); - - if (!Invoke<&::LookupAccountSidW>(nullptr, tokenUser->User.Sid, name.data(), nullptr, referencedDomainName.data(), nullptr, &peUse)) { - return std::make_pair(L"", L""); - } - - return std::make_pair(std::wstring(name.begin(), name.end()), std::wstring(referencedDomainName.begin(), referencedDomainName.end())); -} - -void shelllet::interpreter::Process::Embedded(py::module_& m) -{ - const char* name = "Process"; - py::class_(m, name) - .def(py::init<>()) - .def_static("start", [](py::args args, py::kwargs kwargs) { - - Vector args; - /* for (const auto& iter = kwargs.cbegin(); iter != kwargs.cend(); ++iter) - { - args.push_back(iter. - }*/ - - boost::algorithm::join(kwargs | boost::adaptors::map_keys, "= "); - Start(py::str(args[0]), args); - }) - ; -} diff --git a/QtRpa/modules/interpreter/src/property.cpp b/QtRpa/modules/interpreter/src/property.cpp deleted file mode 100644 index 87b4dc2..0000000 --- a/QtRpa/modules/interpreter/src/property.cpp +++ /dev/null @@ -1,157 +0,0 @@ -#include "common.hpp" -#include "property.hpp" -#include "interpreter/property.h" -#include "interpreter/private/property_p.h" - - -//NamedProperty::NamedProperty(const pugi::xml_node& node, QObject* parent /*= nullptr*/) -// : QObject(parent) -//{ -//} - - -shelllet::interpreter::Property::Property(const XmlNode& node, QObject* parent /*= nullptr*/) - : Property(*new PropertyPrivate, node, parent) -{ -} - -void shelllet::interpreter::Property::initialize() -{ -} - -//void UniqueNamedProperty::toXml(pugi::xml_node& node) -//{ -// NamedProperty::toXml(node); -// -// node.append_attribute("meta") = metaName().c_str(); -//} -//void UniqueNamedProperty::fromXml(const pugi::xml_node& node) -//{ -// NamedProperty::fromXml(node); -//} - -String shelllet::interpreter::Property::displayName() const -{ - Q_D(const Property); - return d->m_displayName; -} - -shelllet::interpreter::Property::Property(QObject* parent /*= nullptr*/) - : QObject(parent) -{ -} - -void shelllet::interpreter::Property::deleteLater() -{ - QObject::deleteLater(); -} - -std::vector shelllet::interpreter::Property::getProp(PropertyBrowser* browser) -{ - return {}; -} - -PropertySheet* shelllet::interpreter::Property::getMisc(PropertyBrowser* browser) -{ - Q_D(Property); - GroupPropertyManager* groupManager = new GroupPropertyManager(); - d->m_misc = groupManager->addProperty(String::fromQString(&static_cast(QObject::tr("Misc")))); - - LineEditFactory* lineEdit = new LineEditFactory(); - StringPropertyManager* strManager = new StringPropertyManager(); - - PropertySheet* display = strManager->addProperty(String::fromQString(&static_cast(QObject::tr("Display Name")))); - - d->m_misc->addSubProperty(display); - - strManager->setValue(display, displayName()); - - connect(strManager, &StringPropertyManager::valueChanged, [this](PropertySheet* property, const String& val) { - Q_D(Property); - d->m_displayName = val; - emit displayNameChanged(); - }); - - browser->setFactoryForManager(strManager, lineEdit); - return d->m_misc; -} - -std::shared_ptr shelllet::interpreter::Property::getNode() -{ - Q_D(Property); - auto doc = std::make_shared(); - XmlNode node = doc->appendChild(d->tagName); - node.appendAttribute("display") = d->m_displayName; - return doc; -} - -QString shelllet::interpreter::Property::metaName() const -{ - std::string name = metaObject()->className(); - std::vector result; - boost::split_regex(result, name, boost::regex("::")); - - return QString::fromStdString(result.back()); -} - -String shelllet::interpreter::Property::tagName() const -{ - Q_D(const Property); - return d->tagName; -} - -QIcon shelllet::interpreter::Property::icon() const -{ - Q_D(const Property); - return d->icon; -} - -QString shelllet::interpreter::Property::Prefix() -{ - static QString p; - if (p.isEmpty()) { - std::string name = Property::staticMetaObject.className(); - std::vector vec; - boost::split_regex(vec, name, boost::regex("::")); - - vec.pop_back(); - p = QString::fromStdString(boost::join(vec, "::")); - } - return p; -} - -PropertySheet* shelllet::interpreter::Property::getOutput(PropertyBrowser*) -{ - throw std::logic_error("The method or operation is not implemented."); -} - -PropertySheet* shelllet::interpreter::Property::getInput(PropertyBrowser*) -{ - throw std::logic_error("The method or operation is not implemented."); -} - -//void shelllet::properties::NamedProperty::toXml(pugi::xml_node& node) -//{ -// node.append_attribute("display") = m_displayName.c_str(); -//} - -//void shelllet::properties::NamedProperty::fromXml(const pugi::xml_node& node) -//{ -// m_displayName = node.attribute("display").value(); -//} - -//UniqueNamedProperty::UniqueNamedProperty(QObject* parent /*= nullptr*/) -// : NamedProperty(parent) -//{ -//} - - -shelllet::interpreter::Property::Property(PropertyPrivate& d, const XmlNode& node, QObject* parent /*= nullptr*/) - : QObject(d, parent) -{ - d.m_displayName = node.attribute("display").value(); - d.icon = Environment::getInstance()->getIconByName(node.attribute("display").value()); - d.tagName = node.name(); - - emit displayNameChanged(); -} diff --git a/QtRpa/modules/interpreter/src/propparser.cpp b/QtRpa/modules/interpreter/src/propparser.cpp deleted file mode 100644 index 91e47ed..0000000 --- a/QtRpa/modules/interpreter/src/propparser.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/composite_property.h" -#include "qglobalstatic.h" -#include "interpreter/element.h" -#include "interpreter/propparser.h" -#include "private/qobject_p.h" -#include "interpreter/private/propparser_p.h" -#include "interpreter/pyelement.h" -#include "interpreter/containeritem.h" -//#include "qgraphicsitem.h" -namespace shelllet { - namespace interpreter { - // namespace py = pybind11; - //Q_GLOBAL_STATIC(PropParser, __propparser__) - } -} -//py::object shelllet::interpreter::PropParser::loadPy(const XmlNode& node) -//{ -// Q_D(PropParser); -// -// return py::cast(nullptr); -//} - -//shelllet::interpreter::PropParser* shelllet::interpreter::PropParser::getInstance() -//{ -// return __propparser__; -//} - -//shelllet::interpreter::PropParser::PropParser(QObject* parent /*= nullptr*/) -// : Object(*new PropParserPrivate, parent) -//{ -// -//} - -shelllet::interpreter::Element* shelllet::interpreter::PropParser::element() -{ - Q_D(PropParser); - - try - { - - //auto* c = py::cast(d->ooo); - - //auto* cc = dynamic_cast(c); - return py::cast(d->ooo); - - - } - catch (const py::cast_error& err) - { - LOG_ERROR(PROJECT_NAME) << err.what(); - } - -} - -shelllet::interpreter::CompositeProperty* shelllet::interpreter::PropParser::prop() -{ - return element()->prop(); -} - -shelllet::interpreter::PropParser::PropParser(const XmlNode& node, Element* parentItem /*= nullptr*/, Object* parent /*= nullptr*/) - : Object(*new PropParserPrivate, parent) -{ - Q_D(PropParser); - try - { - using namespace py::literals; - // py::dict locals = py::dict("data"_a = py::cast(node)); - - - //py::eval_file(p.toString().toStdString(), py::globals(), locals); - - LOG_DEBUG(PROJECT_NAME) << "category: " << node.attribute("category").value(); - LOG_DEBUG(PROJECT_NAME) << "class: " << node.attribute("meta").value(); - - py::object Decimal = py::module_::import((node.attribute("category").value() + "." + node.name()).toUtf8()) - .attr(node.attribute("meta").value().toUtf8()); - - - d->ooo = Decimal(py::cast(node), py::cast(parentItem)); - - //auto result = locals["result"].cast(); - //return pi; - - element()->setWindowTitle(*prop()->displayName().toQString()); - - QObject::connect(prop(), &CompositeProperty::displayNameChanged, [this]() { element()->setWindowTitle(*prop()->displayName().toQString()); }); - //return UniquePointer(py::cast(pi)); - - } - catch (py::error_already_set& eas) - { - LOG_WARNING("rap") << eas.what(); - } - -} diff --git a/QtRpa/modules/interpreter/src/pyabstracteditorfactory.cpp b/QtRpa/modules/interpreter/src/pyabstracteditorfactory.cpp deleted file mode 100644 index 5053913..0000000 --- a/QtRpa/modules/interpreter/src/pyabstracteditorfactory.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "interpreter/framework.h" -#include "property.hpp" -#include "interpreter/pyabstracteditorfactory.h" -#include "interpreter/private/pyabstracteditorfactory_p.h" - -namespace shelllet{ - namespace interpreter{ - - - - } -} -using namespace shelllet::interpreter; -PyAbstractEditorFactory::PyAbstractEditorFactory(Object* parent /*= nullptr*/) - :PyAbstractEditorFactory(*new PyAbstractEditorFactoryPrivate, parent) -{ - -} -PyAbstractEditorFactory::PyAbstractEditorFactory(PyAbstractEditorFactoryPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - - -void PyAbstractEditorFactory::embedded(py::module_& m) -{ - py::class_>(m, "AbstractEditorFactory") - ; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/pyactivityproperty.cpp b/QtRpa/modules/interpreter/src/pyactivityproperty.cpp deleted file mode 100644 index c98f773..0000000 --- a/QtRpa/modules/interpreter/src/pyactivityproperty.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "interpreter/framework.h" -#include "property.hpp" -#include "interpreter/composite_property.h" -#include "interpreter/pyactivityproperty.h" -#include "interpreter/private/pyactivityproperty_p.h" - -std::shared_ptr shelllet::interpreter::PyActivityProperty::getNode() -{ - try - { - - PYBIND11_OVERRIDE_NAME(std::shared_ptr, CompositeProperty, "get_doc", getNode); - } - catch (const py::error_already_set& err) - { - LOG_ERROR(PROJECT_NAME) << err.what(); - } - //return CompositeProperty::getNode().release(); -} - -void shelllet::interpreter::PyActivityProperty::exec() -{ - try - { - PYBIND11_OVERRIDE(void, CompositeProperty, exec); - } - catch (const py::error_already_set& err) - { - LOG_ERROR(PROJECT_NAME) << err.what(); - } -} - -void shelllet::interpreter::PyActivityProperty::embedded(py::module_& m) -{ - py::class_(m, "Property") - .def(py::init()) - .def("get_input", &CompositeProperty::getInput) - .def("get_output", &CompositeProperty::getOutput) - .def("get_doc", &CompositeProperty::getNode) - ; - -} - -void shelllet::interpreter::PyActivityProperty::importModule() -{ - py::module::import("interpreter").attr(QUOTED(Property)); -} - -shelllet::interpreter::PyActivityProperty::PyActivityProperty(const XmlNode& node) - : PyActivityProperty(*new PyActivityPropertyPrivate, node) -{ - -} - -shelllet::interpreter::PyActivityProperty::PyActivityProperty(PyActivityPropertyPrivate& d, const XmlNode& node) - : CompositeProperty(d, node, nullptr) -{ - -} - -PropertySheet* shelllet::interpreter::PyActivityProperty::getInput(PropertyBrowser* browser) -{ - try - { - PYBIND11_OVERRIDE_NAME(PropertySheet*, CompositeProperty, "get_input", getInput, browser); - - } - catch (const py::error_already_set& err) - { - LOG_ERROR(PROJECT_NAME) << err.what(); - } - return nullptr; -} - -PropertySheet* shelllet::interpreter::PyActivityProperty::getOutput(PropertyBrowser* browser) -{ - PYBIND11_OVERRIDE(PropertySheet*, CompositeProperty, getOutput, browser); -} diff --git a/QtRpa/modules/interpreter/src/pycontainer.cpp b/QtRpa/modules/interpreter/src/pycontainer.cpp deleted file mode 100644 index 7c945ad..0000000 --- a/QtRpa/modules/interpreter/src/pycontainer.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/composite_property.h" -#include "interpreter/element.h" -#include "interpreter/containeritem.h" -#include "interpreter/pycontainer.h" -#include "interpreter/private/pycontainer_p.h" -#include "interpreter/pyelement.h" - - -// -//shelllet::interpreter::PyContainer::PyContainer(PyContainerPrivate& d, ElementItem* parentItem /*= nullptr*/, Object* parent /*= nullptr*/) -// : Container(d, parentItem) -//{ -// -//} diff --git a/QtRpa/modules/interpreter/src/pyelement.cpp b/QtRpa/modules/interpreter/src/pyelement.cpp deleted file mode 100644 index 4a17ffc..0000000 --- a/QtRpa/modules/interpreter/src/pyelement.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/composite_property.h" -#include "interpreter/element.h" -#include "interpreter/pyelement.h" -#include "interpreter/private/pyelement_p.h" - diff --git a/QtRpa/modules/interpreter/src/pyitem.cpp b/QtRpa/modules/interpreter/src/pyitem.cpp deleted file mode 100644 index a94f08f..0000000 --- a/QtRpa/modules/interpreter/src/pyitem.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pyitem.h" -#include "interpreter/private/pyitem_p.h" -#include "qgraphicsitem.h" - -namespace shelllet{ - namespace interpreter{ - - - - } -} -using namespace shelllet::interpreter; -PyItem::PyItem(Object* parent /*= nullptr*/) - :PyItem(*new PyItemPrivate, parent) -{ - -} -PyItem::PyItem(PyItemPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - -void PyItem::embeddedModule(py::module_& m) -{ - py::class_(m, "Item"); - ; -} diff --git a/QtRpa/modules/interpreter/src/pylayout.cpp b/QtRpa/modules/interpreter/src/pylayout.cpp deleted file mode 100644 index 0b8724f..0000000 --- a/QtRpa/modules/interpreter/src/pylayout.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pylayout.h" -#include "interpreter/private/pylayout_p.h" -#include "qgraphicslayout.h" - -namespace shelllet { - namespace interpreter { - - - - } -} -using namespace shelllet::interpreter; -PyLayout::PyLayout(Object* parent /*= nullptr*/) - :PyLayout(*new PyLayoutPrivate, parent) -{ - -} -PyLayout::PyLayout(PyLayoutPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} -void PyLayout::embeddedModule(py::module_& m) -{ - py::class_(m, "Layout") - ; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/pylayoutitem.cpp b/QtRpa/modules/interpreter/src/pylayoutitem.cpp deleted file mode 100644 index 173f889..0000000 --- a/QtRpa/modules/interpreter/src/pylayoutitem.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pylayoutitem.h" -#include "interpreter/private/pylayoutitem_p.h" -#include "qgraphicslayoutitem.h" - -namespace shelllet { - namespace interpreter { - - - - } -} -using namespace shelllet::interpreter; -PyLayoutItem::PyLayoutItem(Object* parent /*= nullptr*/) - :PyLayoutItem(*new PyLayoutItemPrivate, parent) -{ - -} -PyLayoutItem::PyLayoutItem(PyLayoutItemPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} -void PyLayoutItem::embeddedModule(py::module_& m) -{ - py::class_(m, "LayoutItem"); - ; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/pylexerpython.cpp b/QtRpa/modules/interpreter/src/pylexerpython.cpp deleted file mode 100644 index bd73f41..0000000 --- a/QtRpa/modules/interpreter/src/pylexerpython.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pylexerpython.h" -#include "interpreter/private/pylexerpython_p.h" -#include "Qsci/qscilexerpython.h" -namespace shelllet{ - namespace interpreter{ - - - - } -} -using namespace shelllet::interpreter; -PyLexerPython::PyLexerPython(Object* parent /*= nullptr*/) - :PyLexerPython(*new PyLexerPythonPrivate, parent) -{ - -} -PyLexerPython::PyLexerPython(PyLexerPythonPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} -void PyLexerPython::importAttr() -{ - -} - -void PyLexerPython::embeddedModule(py::module_& m) -{ - py::class_(m, "LexerPython") - .def(py::init()) - ; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/pylinearlayout.cpp b/QtRpa/modules/interpreter/src/pylinearlayout.cpp deleted file mode 100644 index a552d84..0000000 --- a/QtRpa/modules/interpreter/src/pylinearlayout.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pylinearlayout.h" -#include "interpreter/private/pylinearlayout_p.h" -#include "qgraphicslinearlayout.h" - -namespace shelllet { - namespace interpreter { - - - - } -} -using namespace shelllet::interpreter; -PyLinearLayout::PyLinearLayout(Object* parent /*= nullptr*/) - :PyLinearLayout(*new PyLinearLayoutPrivate, parent) -{ - -} -PyLinearLayout::PyLinearLayout(PyLinearLayoutPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - - -void PyLinearLayout::importAttr() -{ - -} - -void PyLinearLayout::embeddedModule(py::module_& m) -{ - py::class_ layout(m, "LinearLayout"); - layout.def(py::init()) - .def("set_contents_margins", &QGraphicsLinearLayout::setContentsMargins) - .def("add_item", &QGraphicsLinearLayout::addItem) - .def_static("create", [](Qt::Orientation orientation, QGraphicsLayoutItem* parent) { return new QGraphicsLinearLayout(orientation,parent); }) - ; - py::enum_(layout, "Orientation") - .value("Vertical", Qt::Orientation::Vertical) - .value("Horizontal", Qt::Orientation::Horizontal) - .export_values(); -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/pylineeditfactory.cpp b/QtRpa/modules/interpreter/src/pylineeditfactory.cpp deleted file mode 100644 index 382ab1e..0000000 --- a/QtRpa/modules/interpreter/src/pylineeditfactory.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "interpreter/framework.h" -#include "property.hpp" -#include "interpreter/pylineeditfactory.h" -#include "interpreter/private/pylineeditfactory_p.h" - -shelllet::interpreter::PyLineEditFactory::PyLineEditFactory(Object* parent /*= nullptr*/) - :PyLineEditFactory(*new PyLineEditFactoryPrivate, parent) -{ - -} - -void shelllet::interpreter::PyLineEditFactory::embedded(py::module_& m) -{ - using StringEditorFactory = AbstractEditorFactory; - py::class_>(m, "LineEditFactory") - .def(py::init<>()) - .def_static("create", []() { return new LineEditFactory; }) - ; -} - -shelllet::interpreter::PyLineEditFactory::PyLineEditFactory(PyLineEditFactoryPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} diff --git a/QtRpa/modules/interpreter/src/pymodule.cpp b/QtRpa/modules/interpreter/src/pymodule.cpp deleted file mode 100644 index ed5d28b..0000000 --- a/QtRpa/modules/interpreter/src/pymodule.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pymodule.h" -//#include "interpreter/process.h" -#include "interpreter/composite_property.h" -#include "interpreter/containeritem.h" -#include "interpreter/stringio.h" -#include "interpreter/pyactivityproperty.h" -#include "interpreter/pyxmldocument.h" -#include "interpreter/pyxmlnode.h" -#include "interpreter/pyxmlattribute.h" -#include "interpreter/pystring.h" -#include "interpreter/pycontainer.h" -#include "interpreter/pyelement.h" -#include "interpreter/pylineeditfactory.h" -#include "interpreter/pystringpropertymanager.h" -#include "interpreter/pypropertybrowser.h" -#include "interpreter/pypropertysheet.h" -#include "interpreter/pyabstracteditorfactory.h" -#include "interpreter/pylinearlayout.h" -#include "interpreter/pyscintilla.h" -#include "interpreter/pylexerpython.h" -#include "interpreter/pylayoutitem.h" -#include "interpreter/pylayout.h" -#include "interpreter/pyitem.h" -#include "interpreter/pywidget.h" -namespace shelllet { - namespace py = pybind11; - namespace interpreter - { - class PyModulePrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(PyModule) - public: - }; - - Q_GLOBAL_STATIC(PyModule, __pymodule__) - - } -} - -using namespace shelllet::interpreter; -shelllet::interpreter::PyModule::PyModule() - : Object(*new PyModulePrivate, nullptr) -{ - -} - -void shelllet::interpreter::PyModule::importModules() -{ - try - { - - - py::module::import("interpreter").attr(QUOTED(StringIO)); - py::module::import("interpreter").attr(QUOTED(String)); - PyActivityProperty::importModule(); - py::module::import("interpreter").attr(QUOTED(XmlDocument)); - py::module::import("interpreter").attr(QUOTED(XmlNode)); - py::module::import("interpreter").attr(QUOTED(XmlAttribute)); - PyElement<>::importModule(); - py::module::import("interpreter").attr(QUOTED(Container)); - py::module::import("interpreter").attr(QUOTED(WrapperElement)); - py::module::import("interpreter").attr(QUOTED(LineEditFactory)); - py::module::import("interpreter").attr(QUOTED(PropertyBrowser)); - py::module::import("interpreter").attr(QUOTED(AbstractEditorFactory)); - PyStringPropertyManager::importModule(); - - PyLinearLayout::importAttr(); - PyScintilla::importAttr(); - PyLexerPython::importAttr(); - } - catch (const py::error_already_set& err) - { - LOG_ERROR(PROJECT_NAME) << err.what(); - } -} - -void shelllet::interpreter::PyModule::initLibPath() -{ - std::vector ss; - ss.push_back( L"D:\\vcpkg\\installed\\x64-windows-mixed\\share\\python3\\Lib"); - ss.push_back( Environment::getInstance()->getViewPath().toString().toStdWString()); - Py_SetPath((boost::join(ss, ";")).c_str()); - Py_SetProgramName(L"creator.exe"); - Py_SetPythonHome(Path::applicationDirPath().toString().toStdWString().c_str()); - //py::module_::import("sys").attr("path").cast().append("D:\\vcpkg\\installed\\x64-windows-mixed\\share\\python3\\Lib"); - //py::module_::import("sys").attr("path").cast().append("C:\\Users\\admin\\Source\\Repos\\rpa\\library"); - //py::module_::import("sys").attr("path").cast().append(Environment::getInstance()->getViewPath().toString().toStdString()); -} - -shelllet::interpreter::PyModule* shelllet::interpreter::PyModule::getInstance() -{ - return __pymodule__; -} - - - -PYBIND11_EMBEDDED_MODULE(interpreter, m) { - shelllet::interpreter::StringIO::embedded(m); - shelllet::interpreter::PyActivityProperty::embedded(m); - shelllet::interpreter::PyXmlDocument::embedded(m); - shelllet::interpreter::PyXmlNode::embedded(m); - shelllet::interpreter::PyXmlAttribute::embedded(m); - shelllet::interpreter::PyString::embedded(m); - - shelllet::interpreter::PyStringPropertyManager::embedded(m); - shelllet::interpreter::PyPropertyBrowser::embedded(m); - shelllet::interpreter::PyPropertySheet::embedded(m); - shelllet::interpreter::PyAbstractEditorFactory::embedded(m); - shelllet::interpreter::PyLineEditFactory::embedded(m); - PyLayoutItem::embeddedModule(m); - PyItem::embeddedModule(m); - PyWidget::embeddedModule(m); - PyElement<>::embedded(m); - PyContainer<>::embedded(m); - PyLayout::embeddedModule(m); - PyLinearLayout::embeddedModule(m); - - PyScintilla::embeddedModule(m); - PyLexerPython::embeddedModule(m); - -} - diff --git a/QtRpa/modules/interpreter/src/pypropertybrowser.cpp b/QtRpa/modules/interpreter/src/pypropertybrowser.cpp deleted file mode 100644 index be67a53..0000000 --- a/QtRpa/modules/interpreter/src/pypropertybrowser.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "interpreter/framework.h" -#include "property.hpp" -#include "interpreter/pypropertybrowser.h" -#include "interpreter/private/pypropertybrowser_p.h" - -shelllet::interpreter::PyPropertyBrowser::PyPropertyBrowser(Object* parent /*= nullptr*/) - :PyPropertyBrowser(*new PyPropertyBrowserPrivate, parent) -{ - -} - -void shelllet::interpreter::PyPropertyBrowser::embedded(py::module_& m) -{ - py::class_(m, "PropertyBrowser") - .def(py::init<>()) - .def("set_factory_for_manager", &PropertyBrowser::setFactoryForManager) - ; -} - -shelllet::interpreter::PyPropertyBrowser::PyPropertyBrowser(PyPropertyBrowserPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} diff --git a/QtRpa/modules/interpreter/src/pypropertysheet.cpp b/QtRpa/modules/interpreter/src/pypropertysheet.cpp deleted file mode 100644 index d121746..0000000 --- a/QtRpa/modules/interpreter/src/pypropertysheet.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "interpreter/framework.h" -#include "qwidget.h" -#include "property.hpp" -#include "interpreter/pypropertysheet.h" -#include "interpreter/private/pypropertysheet_p.h" - -shelllet::interpreter::PyPropertySheet::PyPropertySheet(Object* parent /*= nullptr*/) - :PyPropertySheet(*new PyPropertySheetPrivate, parent) -{ - -} - -void shelllet::interpreter::PyPropertySheet::embedded(py::module_& m) -{ - py::class_>(m, "PropertySheet") - //.def(py::init()) - .def("add_sub_property", &PropertySheet::addSubProperty) - ; -} - -shelllet::interpreter::PyPropertySheet::PyPropertySheet(PyPropertySheetPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} diff --git a/QtRpa/modules/interpreter/src/pypushbutton.cpp b/QtRpa/modules/interpreter/src/pypushbutton.cpp deleted file mode 100644 index 1d7b744..0000000 --- a/QtRpa/modules/interpreter/src/pypushbutton.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pypushbutton.h" -#include "interpreter/private/pypushbutton_p.h" -#include "qpushbutton.h" - -namespace shelllet{ - namespace interpreter{ - - - - } -} -using namespace shelllet::interpreter; -PyPushButton::PyPushButton(Object* parent /*= nullptr*/) - :PyPushButton(*new PyPushButtonPrivate, parent) -{ - -} -PyPushButton::PyPushButton(PyPushButtonPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} -void PyPushButton::importAttr() -{ - -} - -void PyPushButton::embeddedModule(py::module_& m) -{ - py::class_(m, "QPushButton") - .def(py::init()) - .def("set_text", &QPushButton::setText) - ; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/pyscintilla.cpp b/QtRpa/modules/interpreter/src/pyscintilla.cpp deleted file mode 100644 index fd1cc53..0000000 --- a/QtRpa/modules/interpreter/src/pyscintilla.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include "interpreter/framework.h" -#include "Qsci/qsciscintilla.h" -#include "Qsci/qscilexerpython.h" -#include "qgraphicsproxywidget.h" -#include "qgraphicsitem.h" -#include "interpreter/pyscintilla.h" -#include "interpreter/private/pyscintilla_p.h" - -namespace shelllet { - namespace interpreter { - - - - } -} -using namespace shelllet::interpreter; -PyScintilla::PyScintilla(QGraphicsItem* parent, Object* /*parent*/ /*= nullptr*/) - :PyScintilla(*new PyScintillaPrivate, parent) -{ - -} -PyScintilla::PyScintilla(PyScintillaPrivate& d, QGraphicsItem* parent, Object* /*parent*/ /*= nullptr*/) - : Object(d, nullptr) -{ - d.scintilla = std::make_unique(); - d.proxyWidget = std::make_unique(parent); - d.proxyWidget->setWidget(d.scintilla.get()); -} - -void PyScintilla::importAttr() -{ - -} - -void PyScintilla::embeddedModule(py::module_& m) -{ - py::class_(m, "Scintilla") - .def(py::init()) - .def("set_lexer", [](PyScintilla& sci, QsciLexer* lexer) {sci.d_func()->scintilla->setLexer(lexer); }) - .def("set_utf8", [](PyScintilla& sci, bool cp) {sci.d_func()->scintilla->setUtf8(cp); }) - .def("set_text", [](PyScintilla& sci, const String& text) {sci.d_func()->scintilla->setText(*text.toQString()); }) - .def("widget", [](PyScintilla& sci) { return sci.d_func()->proxyWidget.get(); }) - //.def_static("create", [](QGraphicsItem* parent) { return new PyScintilla(parent); }) - ; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter/src/pystderroutstreamredirect.cpp b/QtRpa/modules/interpreter/src/pystderroutstreamredirect.cpp deleted file mode 100644 index a9698b9..0000000 --- a/QtRpa/modules/interpreter/src/pystderroutstreamredirect.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "pybind11/embed.h" -#include "interpreter/pystderroutstreamredirect.h" -#include "interpreter/private/pystderroutstreamredirect_p.h" -namespace shelllet { - namespace interpreter { - namespace py = pybind11; - Q_GLOBAL_STATIC(PyStdErrOutStreamRedirect, __pystderroutstreamredirect__) - } -} - -shelllet::interpreter::PyStdErrOutStreamRedirect::PyStdErrOutStreamRedirect() - : PyStdErrOutStreamRedirect(*new PyStdErrOutStreamRedirectPrivate) -{ - -} - -shelllet::interpreter::PyStdErrOutStreamRedirect::~PyStdErrOutStreamRedirect() -{ - -} - -shelllet::common::String shelllet::interpreter::PyStdErrOutStreamRedirect::stdoutString() const -{ - Q_D(const PyStdErrOutStreamRedirect); - d->stdout_buffer->attr("seek")(0); - return std::string(py::str(d->stdout_buffer->attr("read")())); -} - -shelllet::common::String shelllet::interpreter::PyStdErrOutStreamRedirect::stderrString() const -{ - - Q_D(const PyStdErrOutStreamRedirect); - d->stderr_buffer->attr("seek")(0); - return std::string(py::str(d->stderr_buffer->attr("read")())); -} - -void shelllet::interpreter::PyStdErrOutStreamRedirect::initialize() -{ - Q_D(PyStdErrOutStreamRedirect); - auto sysm = py::module::import("sys"); - - d->stdout_raw = std::make_unique(sysm.attr("stdout")); - d->stderr_raw = std::make_unique(sysm.attr("stderr")); - - auto stringio = py::module::import("interpreter").attr("StringIO"); - d->stdout_buffer = std::make_unique(stringio); - d->stderr_buffer = std::make_unique(stringio); - - sysm.attr("stdout") = *d->stdout_buffer; - sysm.attr("stderr") = *d->stderr_buffer; -} - -void shelllet::interpreter::PyStdErrOutStreamRedirect::release() -{ - Q_D(PyStdErrOutStreamRedirect); - auto sysm = py::module::import("sys"); - sysm.attr("stdout") = *d->stdout_raw; - sysm.attr("stderr") = *d->stderr_raw; -} - -shelllet::interpreter::PyStdErrOutStreamRedirect* shelllet::interpreter::PyStdErrOutStreamRedirect::getInstance() -{ - return __pystderroutstreamredirect__; -} - -shelllet::interpreter::PyStdErrOutStreamRedirect::PyStdErrOutStreamRedirect(PyStdErrOutStreamRedirectPrivate& d) - : Object(d, nullptr) -{ - -} diff --git a/QtRpa/modules/interpreter/src/pystring.cpp b/QtRpa/modules/interpreter/src/pystring.cpp deleted file mode 100644 index 93400a4..0000000 --- a/QtRpa/modules/interpreter/src/pystring.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "interpreter/framework.h" -#include "common.hpp" -#include "interpreter/pystring.h" -#include "interpreter/private/pystring_p.h" - -shelllet::interpreter::PyString::PyString(Object* parent /*= nullptr*/) - :PyString(*new PyStringPrivate, parent) -{ - -} -shelllet::interpreter::PyString::PyString(PyStringPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - -void shelllet::interpreter::PyString::embedded(py::module_& m) -{ - py::class_(m, "String") - .def(py::init()) - .def(py::init()) - .def("__repr__", [](const String& s) { return s.toStdString(); }) - ; -} diff --git a/QtRpa/modules/interpreter/src/pystringpropertymanager.cpp b/QtRpa/modules/interpreter/src/pystringpropertymanager.cpp deleted file mode 100644 index 85c26b9..0000000 --- a/QtRpa/modules/interpreter/src/pystringpropertymanager.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "interpreter/framework.h" -#include "property.hpp" -#include "interpreter/pystringpropertymanager.h" -#include "interpreter/private/pystringpropertymanager_p.h" - -namespace shelllet { - - namespace interpreter { - class StringPropertyManager_valueChanged { - public: - StringPropertyManager_valueChanged(StringPropertyManager& self) : self(self) {} - void connect(py::object func) { - QObject::connect(&self, &StringPropertyManager::valueChanged, [func](auto...args) { - auto second = std::get<1>(std::forward_as_tuple(args...)); - func(second.toStdString()); }); - } - StringPropertyManager& self; - }; - } -} -shelllet::interpreter::PyStringPropertyManager::PyStringPropertyManager(Object* parent /*= nullptr*/) - :PyStringPropertyManager(*new PyStringPropertyManagerPrivate, parent) -{ - -} - -void shelllet::interpreter::PyStringPropertyManager::embedded(py::module_& m) -{ - py::class_(m, QUOTED(StringPropertyManager_valueChanged)) - .def("connect", &StringPropertyManager_valueChanged::connect) - ; - - py::class_>(m, "StringPropertyManager") - .def(py::init<>()) - .def("add_property", [](StringPropertyManager& self, const std::string& name) { return self.addProperty(name); }) - .def("set_value", [](StringPropertyManager& self, PropertySheet* property, const std::string& value) { self.setValue(property, value); }) - .def_property_readonly("value_changed", [](StringPropertyManager& self) { - return StringPropertyManager_valueChanged(self); - }) - //.def("connect", [](StringPropertyManager& self, py::object func) { - //QObject::connect(&self, &StringPropertyManager::valueChanged, [func](auto...args) { - // auto second = std::get<1>(std::forward_as_tuple(args...)); - // func(second.toStdString()); }); }) - .def_static("create", []() { return new StringPropertyManager; }) - //.def("connect", &StringPropertyManager::connect) - ; -} - -void shelllet::interpreter::PyStringPropertyManager::importModule() -{ - py::module::import("interpreter").attr(QUOTED(StringPropertyManager)); - py::module::import("interpreter").attr(QUOTED(StringPropertyManager_valueChanged)); -} - -shelllet::interpreter::PyStringPropertyManager::PyStringPropertyManager(PyStringPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} diff --git a/QtRpa/modules/interpreter/src/pywidget.cpp b/QtRpa/modules/interpreter/src/pywidget.cpp deleted file mode 100644 index 5376582..0000000 --- a/QtRpa/modules/interpreter/src/pywidget.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pywidget.h" -#include "interpreter/private/pywidget_p.h" -#include "qgraphicswidget.h" - -namespace shelllet{ - namespace interpreter{ - - } -} -using namespace shelllet::interpreter; -PyWidget::PyWidget(Object* parent /*= nullptr*/) - :PyWidget(*new PyWidgetPrivate, parent) -{ - -} -PyWidget::PyWidget(PyWidgetPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - -void PyWidget::embeddedModule(py::module_& m) -{ - py::class_(m, "Widget", py::multiple_inheritance()); - ; -} - - diff --git a/QtRpa/modules/interpreter/src/pyxmlattribute.cpp b/QtRpa/modules/interpreter/src/pyxmlattribute.cpp deleted file mode 100644 index 26b8623..0000000 --- a/QtRpa/modules/interpreter/src/pyxmlattribute.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pyxmlattribute.h" - -void shelllet::interpreter::PyXmlAttribute::embedded(py::module_& m) -{ - py::class_(m, "XmlAttribute") - .def("value", [](XmlAttribute& attr) { return attr.value().toStdString(); }) - .def("set_value", [](XmlAttribute& attr, const std::string& value) { attr.setValue(value); }) - ; -} diff --git a/QtRpa/modules/interpreter/src/pyxmldocument.cpp b/QtRpa/modules/interpreter/src/pyxmldocument.cpp deleted file mode 100644 index f071498..0000000 --- a/QtRpa/modules/interpreter/src/pyxmldocument.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pyxmldocument.h" - -void shelllet::interpreter::PyXmlDocument::embedded(py::module_& m) -{ - py::class_>(m, "XmlDocument") - .def(py::init<>()) - .def("document_element", &XmlDocument::documentElement) - ; -} diff --git a/QtRpa/modules/interpreter/src/pyxmlnode.cpp b/QtRpa/modules/interpreter/src/pyxmlnode.cpp deleted file mode 100644 index e2de709..0000000 --- a/QtRpa/modules/interpreter/src/pyxmlnode.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/pyxmlnode.h" -void shelllet::interpreter::PyXmlNode::embedded(py::module_& m) -{ - py::class_ node(m, "XmlNode"); - - node.def("append_child", [](XmlNode& node, const std::string& name) { return node.appendChild(name); }) - .def("append_attribute", [](XmlNode& node, const std::string& name) { return node.appendAttribute(name); }) - .def("append_child", static_cast(&XmlNode::appendChild)) - .def("set_value", [](XmlNode& node, const std::string& value) { node.setValue(value); }) - .def("attribute", [](XmlNode& node, const std::string& name) { return node.attribute(name); }) - ; - - py::enum_(node, "Type") - .value("Null", XmlNodeType::Null) - .value("Document", XmlNodeType::Document) - .value("Element", XmlNodeType::Element) - .value("PCData", XmlNodeType::PCData) - .value("CData", XmlNodeType::CData) - .value("Comment", XmlNodeType::Comment) - .value("PI", XmlNodeType::PI) - .value("Declaration", XmlNodeType::Declaration) - .value("DocType", XmlNodeType::DocType) - .export_values(); -} diff --git a/QtRpa/modules/interpreter/src/scriptparser.cpp b/QtRpa/modules/interpreter/src/scriptparser.cpp deleted file mode 100644 index 1645a1e..0000000 --- a/QtRpa/modules/interpreter/src/scriptparser.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include -#include "interpreter/scriptparser.h" -#include "interpreter/private/scriptparser_p.h" -#include "qmetaobject.h" -#include "qvariant.h" -namespace shelllet { - namespace py = pybind11; - using namespace py::literals; - namespace interpreter { - Q_GLOBAL_STATIC(ScriptParser, __scriptparser__) - } - -} -shelllet::interpreter::ScriptParser::ScriptParser() - :Object(*new ScriptParserPrivate, nullptr) -{ - Q_D(ScriptParser); - //d->guard = std::make_unique(); -} - -void shelllet::interpreter::ScriptParser::loadFile(const Path& path) -{ - Q_D(ScriptParser); - - d->code = File::readAllAsText(path); -} - -shelllet::common::String shelllet::interpreter::ScriptParser::parseImports() const -{ - Q_D(const ScriptParser); - std::string result; - try - { - auto locals = py::dict("code"_a = d->code.toStdString()); - - py::eval_file(R"(C:\Users\admin\Source\Repos\rpa\assets\scripts\parse.py)", py::globals(), locals); - - //result = locals["result"].cast(); - - } - catch (py::error_already_set& eas) - { - LOG_WARNING("rap") << eas.what(); - } - - return result; -} - -shelllet::common::String shelllet::interpreter::ScriptParser::parseCode(std::int32_t hash) -{ - return ""; -} - -void shelllet::interpreter::ScriptParser::exec(const Path& path, QObject* obj, const QMetaObject* meta) -{ - Q_D(const ScriptParser); - std::string result; - try - { - py::dict locals;//= py::dict("filename"_a = "abc"); - for (int i = meta->propertyOffset(); i < meta->propertyCount(); ++i) - { - LOG_DEBUG(PROJECT_NAME) << "property name: " << meta->property(i).name() - << "\ttypenane: " << meta->property(i).typeName(); - - QVariant data = meta->property(i).read(obj); - switch (data.type()) - { - case QVariant::String: - locals[meta->property(i).name()] = data.toString().toStdString(); - break; - default: - if (String::isEquals(data.typeName(), QMetaType::typeName(qMetaTypeId()))) { - locals[meta->property(i).name()] = data.value().toStdString(); - } - } - - } - - py::eval_file(path.toString().toStdString(), py::globals(), locals); - } - catch (py::error_already_set& eas) - { - LOG_WARNING("rap") << eas.what(); - } - -} - -shelllet::interpreter::ScriptParser* shelllet::interpreter::ScriptParser::getInstance() -{ - return __scriptparser__; -} diff --git a/QtRpa/modules/interpreter/src/simpletextitem.cpp b/QtRpa/modules/interpreter/src/simpletextitem.cpp deleted file mode 100644 index 091d371..0000000 --- a/QtRpa/modules/interpreter/src/simpletextitem.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "interpreter/simpletextitem.h" -#include "common/private/object_p.h" -namespace shelllet { - namespace interpreter { - class SimpleTextItemPrivate : public ObjectPrivate { - public: - - - - }; - - - } -} -shelllet::interpreter::SimpleTextItem::SimpleTextItem(QGraphicsItem* parent/* = nullptr*/) - : SimpleTextItem("", parent) -{ - -} - - -shelllet::interpreter::SimpleTextItem::~SimpleTextItem() -{ - -} - -shelllet::interpreter::SimpleTextItem::SimpleTextItem(const QString& text, QGraphicsItem* parent /*= nullptr*/) - : QGraphicsSimpleTextItem(text,parent) - , Object(*new SimpleTextItemPrivate, nullptr) -{ - Q_D(SimpleTextItem); - -} - -void shelllet::interpreter::SimpleTextItem::setColor(const QColor& color) -{ - Q_D(SimpleTextItem); -} - - - -void shelllet::interpreter::SimpleTextItem::setGeometry(const QRectF& rect) -{ - prepareGeometryChange(); - QGraphicsLayoutItem::setGeometry(rect); - setPos(rect.topLeft()); -} - -QSizeF shelllet::interpreter::SimpleTextItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint /*= QSizeF()*/) const -{ - return boundingRect().size(); -} diff --git a/QtRpa/modules/interpreter/src/stringio.cpp b/QtRpa/modules/interpreter/src/stringio.cpp deleted file mode 100644 index a699989..0000000 --- a/QtRpa/modules/interpreter/src/stringio.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/stringio.h" - - -namespace shelllet { - -} -void shelllet::interpreter::StringIO::write(const std::string& message) -{ - LOG_INFO(PROJECT_NAME) << message; -} - -void shelllet::interpreter::StringIO::embedded(py::module_& m) -{ - py::class_(m, "StringIO") - .def(py::init<>()) - .def_static("write", &shelllet::interpreter::StringIO::write) - ; -} - - - diff --git a/QtRpa/modules/interpreter/src/svgitem.cpp b/QtRpa/modules/interpreter/src/svgitem.cpp deleted file mode 100644 index 04d69fc..0000000 --- a/QtRpa/modules/interpreter/src/svgitem.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "interpreter/svgitem.h" -#include "common.hpp" -#include "qpainter.h" -#include "qsvgrenderer.h" -#include "interpreter/private/svgitem_p.h" -namespace shelllet { - namespace interpreter { - - } -} - -shelllet::interpreter::SvgItem::SvgItem(const String& fileName, QGraphicsItem* parent) - : //QGraphicsSvgItem(fileName, parent) - SvgItem(*new SvgItemPrivate, fileName, parent) - //, Object(*new SvgItemPrivate, nullptr) -{ - Q_D(SvgItem); - - -} - - - -void shelllet::interpreter::SvgItem::setSize(const QSize& size) -{ - Q_D(SvgItem); - //d->size = size; -} - -shelllet::interpreter::SvgItem::SvgItem(SvgItemPrivate& d, const String& fileName, QGraphicsItem* parent /*= 0*/) - : QGraphicsSvgItem(*fileName.toQString(), parent) - , Object(d, nullptr) -{ - setGraphicsItem(this); -} - -//QRectF shelllet::graphics::SvgItem::boundingRect() const -//{ -// if (!renderer()->isValid()) { -// return { 0, 0, 0, 0 }; -// } -// return { QPointF(0, 0),renderer()->defaultSize() * std::abs(scale()) }; -//} - -void shelllet::interpreter::SvgItem::setGeometry(const QRectF& rect) -{ - /*prepareGeometryChange(); - setPos(rect.topLeft());*/ - prepareGeometryChange(); - QGraphicsLayoutItem::setGeometry(rect); - // QGraphicsLayoutItem::setGeometry({ rect.topLeft(), boundingRect().size() }); - //setPos(rect.topLeft()); - QSize c = renderer()->defaultSize() * scale() / 2; - - setPos(rect.center() - QPoint{ c.width(), c.height() }); -} - -//void shelllet::graphics::SvgItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget /*= nullptr*/) -//{ -// //if (!renderer()->isValid()) -// // return; -// -// //QRectF adjust = { QPointF(0, 0), geometry().size() }; -// //setTransformOriginPoint(adjust.center() - boundingRect().center()); -// LOG_TRACE("rpa") << transformOriginPoint() << std::endl; -// LOG_TRACE("rpa") << boundingRect() << std::endl; -// LOG_TRACE("rpa") << geometry() << std::endl; -// LOG_TRACE("rpa") << renderer()->viewBox() << std::endl; -// if (elementId().isEmpty()) -// renderer()->render(painter, boundingRect()); -// else -// renderer()->render(painter, elementId(), boundingRect()); -// -// //__super::paint(painter, option, widget); -//} - -QSizeF shelllet::interpreter::SvgItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint /*= QSizeF()*/) const -{ - //Q_D(const SvgItem); - //if (which == Qt::MinimumSize) { - //return d->size; - //} - return { -1, -1 }; -} diff --git a/QtRpa/modules/interpreter/src/textitem.cpp b/QtRpa/modules/interpreter/src/textitem.cpp deleted file mode 100644 index 69fdd91..0000000 --- a/QtRpa/modules/interpreter/src/textitem.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "interpreter/textitem.h" -namespace shelllet { - namespace interpreter { - class TextItemPrivate : public ObjectPrivate { - public: - - - - }; - - - } -} -shelllet::interpreter::TextItem::TextItem(QGraphicsItem* parent/* = nullptr*/) - : QGraphicsTextItem(parent) - , Object(*new TextItemPrivate, nullptr) -{ - Q_D(TextItem); - -} - - -void shelllet::interpreter::TextItem::setColor(const QColor& color) -{ - Q_D(TextItem); -} - - - -QSizeF shelllet::interpreter::TextItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint /*= QSizeF()*/) const -{ - return boundingRect().size(); -} diff --git a/QtRpa/modules/interpreter/src/winapi.xx b/QtRpa/modules/interpreter/src/winapi.xx deleted file mode 100644 index 04fa4c3..0000000 --- a/QtRpa/modules/interpreter/src/winapi.xx +++ /dev/null @@ -1,285 +0,0 @@ -#include "interpreter/framework.h" -#include "interpreter/win.h" -//#include "interpreter/winapi.h" -#include -#include -#include -#include -#include -#include - -namespace shelllet { - namespace interpreter { - class WinApiPrivate : public ObjectPrivate { - - }; - } -} - -HWND shelllet::interpreter::WinApi::FindWindow(const String& windowName, const String& className) -{ - return Invoke<&::FindWindowW>(className.isEmpty() ? nullptr : reinterpret_cast(className.data()), - windowName.isEmpty() ? nullptr : reinterpret_cast(windowName.data())); -} - -bool shelllet::interpreter::WinApi::MouseClick(HWND hWnd, const Point& point) -{ - LPARAM lParam = MAKELPARAM(point.x(), point.y()); - if (HRESULT hr = Invoke<&::SendMessage>(hWnd, WM_LBUTTONDOWN, MK_LBUTTON, lParam); SUCCEEDED(hr)) { - std::random_device gen; - std::uniform_int_distribution<> dist{ 10, 50 }; - std::this_thread::sleep_for(std::chrono::milliseconds(dist(gen))); - if (hr = Invoke<&::SendMessage>(hWnd, WM_LBUTTONUP, 0, lParam); SUCCEEDED(hr)) - return true; - } - return false; -} - -bool shelllet::interpreter::WinApi::CloseWindow(HWND hWnd) -{ - if (HRESULT hr = Invoke<&::SendMessage>(hWnd, WM_SYSCOMMAND, SC_CLOSE, NULL); SUCCEEDED(hr)) { - if (hr = Invoke<&::SendMessage>(hWnd, WM_CLOSE, NULL, NULL); SUCCEEDED(hr)) - return true; - } - return false; -} - -HWND shelllet::interpreter::WinApi::GetDesktopWindow() -{ - return Invoke<&::GetDesktopWindow>(); -} - -Bool shelllet::interpreter::WinApi::EnumWindows(const std::function& cb) -{ - return Invoke<&::EnumWindows>([](HWND hWnd, LPARAM lParam) ->BOOL { - auto* f = reinterpret_cast*>(lParam); - return (*f)(hWnd); - }, reinterpret_cast(&cb)); -} - -BOOL shelllet::interpreter::WinApi::EnumChildWindows(HWND hWnd, const std::function& cb) -{ - return Invoke<&::EnumChildWindows>(hWnd, [](HWND hWnd, LPARAM lParam) ->BOOL { - auto* f = reinterpret_cast*>(lParam); - return (*f)(hWnd); - }, reinterpret_cast(&cb)); -} - -std::wstring shelllet::interpreter::WinApi::GetWindowTitle(HWND hWnd) -{ - std::wstring ws; - if (auto size = ::GetWindowTextLengthW(hWnd); size != 0) { - // auto size = len + sizeof(wchar_t); // * sizeof(wchar_t); - std::vector buf(size, '\0'); - ::GetWindowTextW(hWnd, buf.data(), size); - ws = std::wstring(buf.begin(), buf.begin() + size); - } - return ws; -} - -BOOL shelllet::interpreter::WinApi::SetForegroundWindow(HWND hWnd) -{ - UINT_PTR timeout = 0; - HWND hWndForeground = Invoke<&::GetForegroundWindow>(); - DWORD currentThreadID = Invoke<&::GetCurrentThreadId>(), - windowThreadID = Invoke<&::GetWindowThreadProcessId>(hWndForeground, nullptr); - - if (currentThreadID != windowThreadID) - { - Invoke<&::AttachThreadInput>(currentThreadID, windowThreadID, TRUE); - Invoke<&::SystemParametersInfoA>(SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &timeout, 0); - Invoke<&::SystemParametersInfoA>(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nullptr, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE); - Invoke<&::AllowSetForegroundWindow>(ASFW_ANY); - } - - BOOL ret = Invoke<&::SetForegroundWindow>(hWnd); - - if (currentThreadID != windowThreadID) - { - Invoke<&::SystemParametersInfoA>(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, LPVOID(timeout), SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE); - Invoke<&::AttachThreadInput>(currentThreadID, windowThreadID, FALSE); - } - - return ret; -} - -Image shelllet::interpreter::WinApi::GrabDesktop(const Rect& rect) -{ - using namespace Microsoft::WRL; - const int kAcquireTimeoutMs = 10; - Rect availableRect = rect; - if (!rect.isEmpty()) { - auto temp = qGuiApp->primaryScreen()->availableGeometry(); - availableRect = { static_cast(&temp) }; - } - else if (!rect.isValid()) { - throw std::logic_error("invalid rect."); - } - - ComPtr device; - ComPtr duplication; - ComPtr context; - ComPtr factory; - - CreateDXGIFactory1(__uuidof(IDXGIFactory1), &factory); - - std::vector> adapters; - HRESULT hr = NOERROR; - - int i = 0; - ComPtr adapter; - while (factory->EnumAdapters1(i, &adapter) != DXGI_ERROR_NOT_FOUND) { - adapters.push_back(adapter); - ++i; - } - - for (auto& adapter : adapters) - { - D3D_FEATURE_LEVEL feature[] = { - D3D_FEATURE_LEVEL_9_1, - D3D_FEATURE_LEVEL_9_2, - D3D_FEATURE_LEVEL_9_3, - D3D_FEATURE_LEVEL_10_0, - D3D_FEATURE_LEVEL_10_1, - D3D_FEATURE_LEVEL_11_0, - D3D_FEATURE_LEVEL_11_1, - D3D_FEATURE_LEVEL_12_0, - D3D_FEATURE_LEVEL_12_1 - }; - - hr = D3D11CreateDevice( - adapter.Get(), - D3D_DRIVER_TYPE_UNKNOWN, // There is no need to create a real hardware device. - NULL, - D3D11_CREATE_DEVICE_SINGLETHREADED, // Check for the SDK layers. - feature, // Any feature level will do. - _countof(feature), - D3D11_SDK_VERSION, - &device, // No need to keep the D3D device reference. - NULL, // No need to know the feature level. - &context // No need to keep the D3D device context reference. - ); - - if (FAILED(hr)) - continue; - - ComPtr output; - ComPtr output5; - - i = 0; - while (adapter->EnumOutputs(i, &output) != DXGI_ERROR_NOT_FOUND) { - hr = output.As(&output5); - - if (SUCCEEDED(hr)) { - DXGI_FORMAT formats[] = { DXGI_FORMAT_B8G8R8A8_UNORM }; - hr = output5->DuplicateOutput1(device.Get(), - 0, // Reserved for future use; must be zero. - _countof(formats), formats, &duplication); - - if (SUCCEEDED(hr)) { - break; - } - } - - ++i; - } - - if (duplication) { - break; - } - } - - if (!duplication) { - throw std::system_error(hr, std::system_category()); - } - - DXGI_OUTDUPL_DESC dupDescription; - duplication->GetDesc(&dupDescription); - - D3D11_TEXTURE2D_DESC desc; - - // Create CPU access texture - desc.Width = dupDescription.ModeDesc.Width; - desc.Height = dupDescription.ModeDesc.Height; - desc.Format = dupDescription.ModeDesc.Format; - desc.ArraySize = 1; - desc.BindFlags = 0; - desc.MiscFlags = 0; - desc.SampleDesc.Count = 1; - desc.SampleDesc.Quality = 0; - desc.MipLevels = 1; - desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; - desc.Usage = D3D11_USAGE_STAGING; - - ComPtr texture; - - hr = device->CreateTexture2D(&desc, NULL, &texture); - - if (FAILED(hr)) { - throw std::system_error(hr, std::system_category()); - } - - DXGI_OUTDUPL_FRAME_INFO frameInfo; - ComPtr desktopResource; - ComPtr desktopImage; - int tryCount = 3; - do - { - std::random_device gen; - std::uniform_int_distribution<> dist{ 300, 500 }; // black image - std::this_thread::sleep_for(std::chrono::milliseconds(dist(gen))); - - hr = duplication->AcquireNextFrame(kAcquireTimeoutMs, &frameInfo, &desktopResource); - - if (SUCCEEDED(hr)) - { - break; - } - if (hr == DXGI_ERROR_WAIT_TIMEOUT) - { - continue; - } - if (FAILED(hr)) { - throw std::system_error(hr, std::system_category()); - } - } while (--tryCount > 0); - - BOOST_SCOPE_EXIT(duplication) { - duplication->ReleaseFrame(); - }BOOST_SCOPE_EXIT_END; - - hr = desktopResource.As(&desktopImage); - if (FAILED(hr)) { - throw std::system_error(hr, std::system_category()); - } - - const D3D11_BOX region = { - static_cast (rect.x()), static_cast(rect.y()), - 0, - static_cast(rect.x() + rect.width()), static_cast(rect.y() + rect.height()), - 1 }; - - UINT subResource = D3D11CalcSubresource(0, 0, 1); - // Copy image into CPU access texture - context->CopySubresourceRegion(texture.Get(), subResource, 0, 0, 0, desktopImage.Get(), subResource, !rect.isEmpty() ? ®ion : nullptr); - // Copy from CPU access texture to bitmap buffer - D3D11_MAPPED_SUBRESOURCE resource; - - hr = context->Map(texture.Get(), subResource, D3D11_MAP_READ_WRITE, 0, &resource); - if (FAILED(hr)) { - throw std::system_error(hr, std::system_category()); - } - - BOOST_SCOPE_EXIT(context, texture) { - context->Unmap(texture.Get(), 0); - }BOOST_SCOPE_EXIT_END; - - // return { rect.height(), rect.width(), CV_8UC4, (BYTE*)resource.pData, resource.RowPitch }; - return { (BYTE*)resource.pData, rect.width(), rect.height() , resource.RowPitch, QImage::Format_RGB32 }; -} - -Image shelllet::interpreter::WinApi::GrabWindow(HWND hWnd, const Rect& rc) -{ - QPixmap pixmap = qGuiApp->primaryScreen()->grabWindow(reinterpret_cast(hWnd), rc.x(), rc.y(), rc.width(), rc.height()); - return &pixmap; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/CMakeLists.txt b/QtRpa/modules/interpreter2/CMakeLists.txt deleted file mode 100644 index 32bb351..0000000 --- a/QtRpa/modules/interpreter2/CMakeLists.txt +++ /dev/null @@ -1,101 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) - -cmake_policy(SET CMP0091 NEW) - -project(interpreter2) - - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h) - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -#find_package(Tesseract CONFIG REQUIRED) -find_package(Qt5Sql CONFIG REQUIRED) -#find_package(sqlite3 CONFIG REQUIRED) -find_package(yaml-cpp CONFIG REQUIRED) -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Qt5Websockets CONFIG REQUIRED) -find_package(Qt5SerialBus CONFIG REQUIRED) -find_package(pugixml CONFIG REQUIRED) -find_package(libzip CONFIG REQUIRED) -find_package(OpenCV CONFIG REQUIRED) -find_package(Clang CONFIG REQUIRED) -find_package(LLVM CONFIG REQUIRED) -find_package(V8 CONFIG REQUIRED) -find_package(libzippp CONFIG REQUIRED) - -# https://vcpkg.readthedocs.io/en/latest/examples/installing-and-using-packages/ -find_path(BOOST_ASIO_INCLUDE_DIRS "boost/asio.hpp") -find_path(BOOST_BEAST_INCLUDE_DIRS "boost/beast.hpp") -#find_package(v8 CONFIG REQUIRED) -#file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/internal/*.h) - - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/src - ${CMAKE_CURRENT_SOURCE_DIR}/third-party/v8/include/ - ${Boost_INCLUDE_DIRS} - ${Tesseract_INCLUDE_DIRS} - ${OpenCV_INCLUDE_DIRS} - ${LLVM_SDK}/clang/include - ${LLVM_SDK}/llvm/include - ${LLVM_SDK}/build_ninja/include - ${LLVM_SDK}/build_ninja/tools/clang/include - ${V8_INCLUDE_DIR} -) - - -#add_definitions(-DBOOST_ALL_DYN_LINK) -add_definitions(-DV8_COMPRESS_POINTERS) -add_definitions(-DSHELL_GUI_APPLICATION) -add_definitions(-DCURRENT_ASSETS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/assets") - -target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX _WIN32_WINNT=0x0601) - - -target_link_directories(${PROJECT_NAME} PRIVATE ${LLVM_SDK}/build_ninja/lib) - -target_link_libraries(${PROJECT_NAME} PRIVATE DXGI D3D11 ws2_32.lib - ${OpenCV_LIBS} - ${Boost_LIBRARIES} - ${YAML_CPP_LIBRARIES} - #opencv_world - Qt::Widgets #Qt5::WidgetsPrivate #Qt5::QWindowsVistaStylePlugin - Qt::WebSockets #Qt5::WebsocketsPrivate #Qt5::QWindowsVistaStylePlugin - Qt::SerialBus #Qt5::SerialBusPrivate #Qt5::PeakCanBusPlugin Qt5::TinyCanBusPlugin - - Qt::Sql - pugixml - #libzip::zip libzippp::libzippp - #zip - ${V8_LIBRARIES} - #clangAST clangLex libclang clangEdit - #LTO LLVMMC LLVMLTO LLVMMCA - clangTooling - #clangBasic - clangFormat - #clangRewrite - #clangToolingCore - #clangToolingInclusions - #clangLex - #LLVMCore LLVMSupport LLVMRemarks LLVMBitstreamReader LLVMBinaryFormat -) - -if(EXISTS ${V8_SNAPSHOT_BLOB}) - file(COPY ${V8_SNAPSHOT_BLOB} DESTINATION ${CMAKE_BINARY_DIR}) -else() - file(COPY ${V8_SNAPSHOT_BLOB_RELEASE} DESTINATION ${CMAKE_BINARY_DIR}) -endif() \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/consoleapplication.cpp b/QtRpa/modules/interpreter2/src/consoleapplication.cpp deleted file mode 100644 index e1d7e1b..0000000 --- a/QtRpa/modules/interpreter2/src/consoleapplication.cpp +++ /dev/null @@ -1,128 +0,0 @@ -#include -#include -#include -#include "interpreter/consoleapplication.h" -#include "interpreter/inspector_agent.h" -#include "interpreter/tcp_server.h" -#include "common.hpp" -#include "properties.hpp" -#include "events/common_event.h" -namespace shelllet { - using namespace inspect; - using namespace interpreter; - extern std::string FrontendUrl(const std::string& address, uint16_t port); - - namespace interpreter { - class ConsoleApplicationPrivate { - public: - std::unique_ptr agent_; - std::unique_ptr platform_; - inspect::TcpServer* worker_thread_ = nullptr; - }; - - - } -} - -shelllet::inspect::InspectorVersion shelllet::interpreter::ConsoleApplication::requestInspectorVersion() -{ - return { "1.2","v8inspector" }; -} - -shelllet::inspect::InspectorList shelllet::interpreter::ConsoleApplication::requestInspectorList() -{ - return { - "v8inspector instance", - "node", - "Debug", - "file:///", - "127.0.0.1", - 9229 - }; -} - -shelllet::interpreter::ConsoleApplication::ConsoleApplication() -//: d_ptr(new ConsoleApplicationPrivate) - : p_(new ConsoleApplicationPrivate) -{ -#ifdef _DEBUG - v8::V8::SetFlagsFromString("--expose-gc"); -#endif // _DEBUG - v8::V8::InitializeICUDefaultLocation(__argv[0]); - v8::V8::InitializeExternalStartupData(__argv[0]); - - d_func()->platform_ = v8::platform::NewDefaultPlatform(); - v8::V8::InitializePlatform(d_func()->platform_.get()); - v8::V8::Initialize(); - - Helper::register_meta_type(); -} - -shelllet::interpreter::ConsoleApplication::~ConsoleApplication() -{ - v8::V8::Dispose(); - v8::V8::ShutdownPlatform(); - delete p_; -} - - -void shelllet::interpreter::ConsoleApplication::run(QEvent* event) -{ - events::ConsoleEvent* e = dynamic_cast(event); - - if (!std::filesystem::exists(e->filename())) { - LOG_ERROR("engine") << "# the file not exist: " << e->filename(); - return; - } - - if (e->inspectBrk()) { - d_func()->worker_thread_ = new TcpServer(this, QHostAddress::LocalHost, 9229); - connect(d_func()->worker_thread_, &TcpServer::finished, d_func()->worker_thread_, &QObject::deleteLater); - d_func()->worker_thread_->start(); - auto info = requestInspectorList(); - std::cout << "# debugger connection success; copy URL and open in Chrome browser: " << FrontendUrl(info.address, info.port) << std::endl; - } - - d_func()->agent_ = std::make_unique(this, d_func()->platform_.get(), e->filename(), e->inspectBrk()); - d_func()->agent_->run(); -} - - - - -void shelllet::interpreter::ConsoleApplication::finished() -{ - if (d_func()->worker_thread_ && d_func()->worker_thread_->isRunning()) { - d_func()->worker_thread_->requestInterruption(); - d_func()->worker_thread_->wait(); - } -} - -void shelllet::interpreter::ConsoleApplication::customEvent(QEvent* event) -{ - if (auto* e = dynamic_cast(event)) { - d_func()->agent_->postInspectorMessage(QString::fromStdString(e->message)); - } - else if (auto* e = dynamic_cast(event)) { - dispatchInspectorMessage(e->message); - } - else if (auto* e = dynamic_cast(event)) { - d_func()->agent_->evaluate(); - d_func()->agent_->cleanup(); - finished(); - QCoreApplication::removePostedEvents(this); - QTimer::singleShot(100, qApp, [this]() { - d_func()->agent_.reset(nullptr); - QCoreApplication::quit(); - }); - QCoreApplication::processEvents(); - LOG_TRACE("inspect") << "# evaluate end." << std::endl; - } - else if (auto* e = dynamic_cast(event)) { - d_func()->agent_->pumpMessageLoop(); - } - - else if (auto* e = dynamic_cast(event)) { - d_func()->agent_->disconnectInspector(); - } -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/error.cpp b/QtRpa/modules/interpreter2/src/error.cpp deleted file mode 100644 index 2402240..0000000 --- a/QtRpa/modules/interpreter2/src/error.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "common.hpp" -#include "interpreter/error.h" - -namespace shelllet { - thread_local std::string glErrorMessage; -} -std::string shelllet::error::GetLastErrorMessage() -{ - return glErrorMessage; -} - -void shelllet::error::SetLastErrorMessage(const std::variant& err) -{ - if (std::holds_alternative(err)) { - glErrorMessage = std::system_category().message(std::get(err)); - } - else if (std::holds_alternative(err)) { - glErrorMessage = std::get(err); - } -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/global.cpp b/QtRpa/modules/interpreter2/src/global.cpp deleted file mode 100644 index 2524499..0000000 --- a/QtRpa/modules/interpreter2/src/global.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "common.hpp" -#include -#include -#include -#include -#include -#include "interpreter/error.h" -#include "interpreter/global/global.h" - - -QString shelllet::global::MyGlobal::Version() -{ - return QCoreApplication::applicationVersion(); -} - -std::string shelllet::global::MyGlobal::dirname() -{ - return std::filesystem::current_path().string(); -} - -std::string shelllet::global::MyGlobal::Chdir(const std::string& tar) -{ - std::filesystem::path target = { tar }; - std::filesystem::path dir = std::filesystem::current_path().string(); - - if (!target.empty() && std::filesystem::exists(target)) { - std::filesystem::current_path(target); - } - return dir.string(); -} - -bool shelllet::global::MyGlobal::IEquals(const std::string& s1, const std::string& s2) -{ - return std::equal(s1.begin(), s1.end(), s2.begin(), s2.end(), [](char ch1, char ch2) { - return tolower(ch1) == tolower(ch2); - }); -} - -bool shelllet::global::MyGlobal::Start(const std::string& file, const std::vector& args) -{ - const char* quoted = R"(")"; - QString fixed = QString::fromStdString(file); - if (fixed.contains(" ")) { - if (!fixed.startsWith(quoted)) { - fixed = quoted + fixed; - } - - if (!fixed.endsWith(quoted)) { - fixed = fixed + quoted; - } - } - - if (args.empty()) { - return QProcess::startDetached(fixed); - } - QVector arguments(args.size()); - std::for_each(args.begin(), args.end(), [&arguments](const std::string& arg) { - arguments.push_back(QString::fromStdString(arg)); - }); - return QProcess::startDetached(fixed, QStringList::fromVector(arguments)); -} - -void shelllet::global::MyGlobal::Sleep(int64_t ms) -{ - std::this_thread::sleep_for(std::chrono::milliseconds(ms)); -} - -std::filesystem::path shelllet::global::MyGlobal::GetExePath() -{ - return QCoreApplication::applicationDirPath().toStdString(); -} - -std::filesystem::path shelllet::global::MyGlobal::GetHomePath() -{ - return QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString(); -} - -std::string shelllet::global::MyGlobal::Now() -{ - std::time_t t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - std::vector buf(0xff, '\0'); - if (size_t size = std::strftime(buf.data(), buf.size(), "%F %T", std::localtime(&t))) { - return std::string(buf.begin(), buf.begin() + size); - } - return QDateTime::currentDateTime().toString().toStdString(); -} - -void shelllet::global::MyGlobal::WriteFile(const std::string& filename, const std::string& txt, std::ios_base::openmode mode /*= std::ios_base::trunc*/) -{ - std::ofstream file(filename, std::ofstream::out | mode); - if (file.is_open()) { - file << txt; - } -} - -std::string shelllet::global::MyGlobal::ToUpperCase(const std::string& string, int index /*= -1*/) -{ - std::string result = string; - if (index == -1) { - result = boost::to_upper_copy(string); - } - else if (index < string.length() && index >= 0) { - result[index] = std::toupper(result[index]); - } - return result; -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/http_session.cpp b/QtRpa/modules/interpreter2/src/http_session.cpp deleted file mode 100644 index 4a82bb7..0000000 --- a/QtRpa/modules/interpreter2/src/http_session.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "common.hpp" -#include "interpreter/http_session.h" -#include "interpreter/websocket_session.h" - -namespace shelllet { - // https://github.com/boostorg/beast/blob/develop/example/advanced/server/advanced_server.cpp - static std::string id = QUuid::createUuid().toString(QUuid::WithoutBraces).toStdString(); - - std::string FrontendUrl(const std::string& address, uint16_t port) { - std::ostringstream frontendUrl; - frontendUrl << "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws="; - frontendUrl << address << ":" << port << "/" << id; - return frontendUrl.str(); - } - std::string HandleReqVersion(inspect::Receiver* receiver) - { - // https://chromedevtools.github.io/devtools-protocol/ - auto version = receiver->requestInspectorVersion(); - - QJsonObject json = { {"Browser", QString::fromStdString(version.browser)}, {"Protocol-Version", QString::fromStdString(version.version)} }; - QJsonDocument document(json); - return document.toJson(QJsonDocument::Indented).constData(); - } - - std::string HandleReqList(inspect::Receiver* receiver) - { - // https://chromedevtools.github.io/devtools-protocol/ - - auto info = receiver->requestInspectorList(); - - std::ostringstream ws; - ws << "ws://" << info.address << ":" << info.port << "/" << id; - - std::string frontend_url = FrontendUrl(info.address, info.port); - - QJsonObject obj = { {"id", QString::fromStdString(id) }, {"description", QString::fromStdString(info.description)}, - {"type", QString::fromStdString(info.type)}, - {"title", QString::fromStdString(info.title)}, - {"url", QString::fromStdString(info.url)}, - {"webSocketDebuggerUrl", QString::fromStdString(ws.str())}, - {"devtoolsFrontendUrl", QString::fromStdString(frontend_url)}, - }; - QJsonArray array = { obj }; - QJsonDocument document(array); - - return document.toJson(QJsonDocument::Indented).constData(); - } - - template - void HandleRequest(inspect::Receiver* receiver, boost::beast::http::request>&& req, Send&& send) { - static std::map> handlers = { - {"/json/version", HandleReqVersion }, - {"/json", HandleReqList }, - {"/json/list", HandleReqList } - }; - - auto const bad_request = [&req](boost::beast::string_view why) - { - boost::beast::http::response res{ boost::beast::http::status::bad_request, req.version() }; - res.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING); - res.set(boost::beast::http::field::content_type, "text/html"); - res.keep_alive(req.keep_alive()); - res.body() = std::string(why); - res.prepare_payload(); - return res; - }; - - if (!handlers.contains(req.target())) { - LOG_WARN("inspect") << "# target: `" << req.target() << "` not supported." << std::endl; - return send(bad_request("Illegal request-target")); - } - boost::beast::http::dynamic_body::value_type body; - boost::beast::ostream(body) << handlers[req.target()](receiver).c_str(); - auto const size = body.size(); - - boost::beast::http::response res{ - std::piecewise_construct, - std::make_tuple(std::move(body)), - std::make_tuple(boost::beast::http::status::ok, req.version()) }; - res.set(boost::beast::http::field::content_type, "application/json; charset=UTF-8"); - res.set(boost::beast::http::field::cache_control, "no-cache"); - res.content_length(size); - res.keep_alive(req.keep_alive()); - return send(std::move(res)); - } -} -shelllet::inspect::HttpSession::HttpSession(shelllet::inspect::Receiver* receiver, boost::asio::ip::tcp::socket&& socket) - : receiver_(receiver) - , stream_(std::move(socket)) - , queue_(*this) -{ -} - -void shelllet::inspect::HttpSession::run() -{ - boost::asio::dispatch(stream_.get_executor(), boost::beast::bind_front_handler(&HttpSession::doRead, this->shared_from_this())); -} - -void shelllet::inspect::HttpSession::doRead() -{ - parser_.emplace(); - - boost::beast::http::async_read(stream_, buffer_, *parser_, boost::beast::bind_front_handler(&HttpSession::onRead, shared_from_this())); -} - -void shelllet::inspect::HttpSession::onRead(boost::beast::error_code ec, std::size_t bytes_transferred) -{ - boost::ignore_unused(bytes_transferred); - - if (ec == boost::beast::http::error::end_of_stream) - return doClose(); - - if (ec) { - LOG_ERROR("inspect") << "# read error " << ec.message() << std::endl; - return; - } - if (boost::beast::websocket::is_upgrade(parser_->get())) - { - LOG_TRACE("inspect") << "# websocket created." << std::endl; - std::make_shared(receiver_, stream_.release_socket())->doAccept(parser_->release()); - return; - } - - HandleRequest(receiver_, parser_->release(), queue_); - - if (!queue_.isFull()) - doRead(); -} - -void shelllet::inspect::HttpSession::onWrite(bool close, boost::beast::error_code ec, std::size_t bytes_transferred) -{ - boost::ignore_unused(bytes_transferred); - - if (ec) { - LOG_ERROR("inspect") << "# read error " << ec.message() << std::endl; - return; - } - - if (close) - { - return doClose(); - } - if (queue_.onWrite()) - { - doRead(); - } -} - -void shelllet::inspect::HttpSession::doClose() -{ - boost::system::error_code ec; - stream_.socket().shutdown(boost::asio::ip::tcp::socket::shutdown_send, ec); -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/inspector_agent.cpp b/QtRpa/modules/interpreter2/src/inspector_agent.cpp deleted file mode 100644 index 4497cee..0000000 --- a/QtRpa/modules/interpreter2/src/inspector_agent.cpp +++ /dev/null @@ -1,291 +0,0 @@ -#include "common.hpp" -#include -#include -#include -#include "interpreter/error.h" -#include "interpreter/inspector_agent.h" -#include "interpreter/global/global_implement.h" -#include "interpreter/global/console_implement.h" -//#include "modules/core/initialize.h" -//#include "modules/gui/initialize.h" -//#include "opencv/initialize.h" -#include "interpreter/native_library.h" -#include "properties.hpp" -namespace shelllet { - static v8::ScriptOrigin NewScriptOrigin(const std::string& resourceName, v8::Isolate* isolate) { - return { V8_NEW_STRING_VAR(isolate, resourceName.c_str()), - v8::Integer::New(isolate, 0), - v8::Integer::New(isolate, 0), - v8::False(isolate), - v8::Local(), - v8::Local(), - False(isolate), - False(isolate), - True(isolate) - }; - } - - using namespace global; - using namespace interpreter; - using namespace inspect; - using namespace library; - using namespace pugi; - v8::Global global_context; - static void WalkCodeCall(std::ostringstream& ss, const xml_object_range& items) { - for (const auto& i : items) { - - auto prop = CompositeProperty::CreateNode(i); - - if (prop) { - prop->getCode(ss); - } - ss << std::endl; - - - WalkCodeCall(ss, i.children()); - } - } - -} - -void shelllet::interpreter::InspectorAgent::disconnectInspector() -{ - if (inspector_client_) - inspector_client_->disconnectFrontend(); -} - -void shelllet::interpreter::InspectorAgent::postInspectorMessage(const QString& message) -{ - inspector_client_->postInspectorMessage(message.toStdString()); -} - -void shelllet::interpreter::InspectorAgent::pumpMessageLoop() -{ - if (inspector_client_) - inspector_client_->pumpMessageLoop(); -} - -shelllet::interpreter::InspectorAgent::InspectorAgent(QObject* receiver, v8::Platform* platform, const std::filesystem::path& filename, bool inspect_brk) - : receiver_(receiver) - , platform_(platform) - , filename_(filename) - , inspect_brk_(inspect_brk) -{ - create_params_.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); - - isolate_ = v8::Isolate::New(create_params_); - isolate_->SetData(static_cast(IsolateData::GlobalContext), &global_context); - //isolate->SetData(static_cast(IsolateData::GlobalValue), &resources); - isolate_->SetData(static_cast(IsolateData::SetErrorAddress), error::SetLastErrorMessage); -} - -shelllet::InspectorAgent::~InspectorAgent() -{ - { - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - while (v8::platform::PumpMessageLoop(platform_, isolate_)) { - QCoreApplication::processEvents(); - } - inspector_client_.reset(nullptr); - } - isolate_->Dispose(); - - delete create_params_.array_buffer_allocator; -} - -void shelllet::interpreter::InspectorAgent::evaluate() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - v8::TryCatch try_catch(isolate_); - v8::Local context = v8::Local::New(isolate_, global_context); - v8::Context::Scope context_scope(context); - - v8::ScriptOrigin origin = NewScriptOrigin(filename_.string(), isolate_); - v8::ScriptCompiler::Source sourceText(V8_NEW_STRING_VAR(isolate_, translate(index_code_).c_str()), origin); - - v8::Local js_module; - - if (!v8::ScriptCompiler::CompileModule(isolate_, &sourceText).ToLocal(&js_module) && try_catch.HasCaught()) { - LOG_ERROR("engine") << GetException(isolate_, try_catch); - return; - } - if (!js_module->InstantiateModule(context, [](v8::Local context, - v8::Local specifier, - v8::Local referrer)->v8::MaybeLocal { - v8::String::Utf8Value param(context->GetIsolate(), specifier); - std::string filename = *param; - v8::Isolate* isolate = context->GetIsolate(); - v8::TryCatch tryCatch(isolate); - std::string code; - if (context->GetEmbedderData(static_cast(ContextEmbedderData::IsZip))->BooleanValue(isolate)) - { - v8::String::Utf8Value u8(isolate, context->GetEmbedderData(static_cast(ContextEmbedderData::ZipSource))); - std::filesystem::path path = std::filesystem::path(*u8).append(filename).lexically_normal(); - - libzippp::ZipArchive zf(path.string()); - - zf.open(libzippp::ZipArchive::ReadOnly); - - libzippp::ZipEntry entry2 = zf.getEntry(common::Environment::getInstance()->getOptions()->pkg_src.toStdString() + filename); - code = entry2.readAsText(); - } - else { - v8::String::Utf8Value u8(isolate, context->GetEmbedderData(static_cast(ContextEmbedderData::WorkingDirectory))); - std::filesystem::path path = std::filesystem::path(*u8).append(filename).lexically_normal(); - - std::ifstream ifs(path); - code = std::string(std::istreambuf_iterator(ifs), std::istreambuf_iterator()); - } - - v8::ScriptOrigin origin = NewScriptOrigin(filename, context->GetIsolate()); - v8::ScriptCompiler::Source source(V8_NEW_STRING_VAR(isolate, translate(code).c_str()), origin); - v8::MaybeLocal result = v8::ScriptCompiler::CompileModule(context->GetIsolate(), &source); - - if (tryCatch.HasCaught()) { - LOG_WARN("engine") << GetException(isolate, tryCatch); - v8::ScriptCompiler::Source source(V8_NEW_STRING_VAR(isolate, ""), origin); - return v8::ScriptCompiler::CompileModule(context->GetIsolate(), &source); - } - return result; - }).IsNothing()) { - auto value = js_module->Evaluate(context); - if (auto tmp = value.ToLocalChecked()) - { - v8::Local f; - f->IsAsyncFunction(); - v8::Isolate::wai - - } - } - - if (try_catch.HasCaught()) { - LOG_ERROR("engine") << GetException(isolate_, try_catch); - } -} - -std::string shelllet::InspectorAgent::translate(const std::string& xml) -{ - - std::ostringstream ss; - xml_document doc; - doc.load_string(xml.c_str()); - - //ss << "await (async () => {" << std::endl; - - //WalkCodeCall(ss, doc.document_element().children()); - - //ss << "})();" << std::endl; - - ss << R"(await (async () =>{})())"; - LOG_TRACE("Velkhana") << "# generate code: " << std::endl - << ss.str(); - return ss.str(); -} - -void shelllet::interpreter::InspectorAgent::run() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - v8::TryCatch try_catch(isolate_); - - std::filesystem::path src = filename_; - std::filesystem::path dir = src.parent_path(); - if (std::filesystem::is_directory(src)) { - dir = src; - src /= "src/index.xml"; - } - - std::string name = src.filename().string(); - - bool is_zip = false; - if (src.extension() == common::Environment::getInstance()->getOptions()->pkg_extension.toStdWString()) { - libzippp::ZipArchive zf(src.string()); - zf.open(libzippp::ZipArchive::ReadOnly); - - libzippp::ZipEntry entry2 = zf.getEntry(common::Environment::getInstance()->indexJsPath().string()); - index_code_ = entry2.readAsText(); - is_zip = true; - } - else { - std::ifstream stream(src); - index_code_ = std::string((std::istreambuf_iterator(stream)), std::istreambuf_iterator()); - - } - - { - v8::Local objectTemplate = v8::ObjectTemplate::New(isolate_); - { - static_cast(std::make_unique(isolate_, objectTemplate)); - // qtcore::initialize(isolate_, objectTemplate); - NativeLibrary::getInstance()->initialize(isolate_, objectTemplate); - } - - v8::Local context = v8::Context::New(isolate_, nullptr, objectTemplate); - context->SetEmbedderData(static_cast(ContextEmbedderData::WorkingDirectory), V8_NEW_STRING_VAR(isolate_, dir.string().c_str())); - context->SetEmbedderData(static_cast(ContextEmbedderData::IsZip), v8::Boolean::New(isolate_, is_zip)); - context->SetEmbedderData(static_cast(ContextEmbedderData::ZipSource), V8_NEW_STRING_VAR(isolate_, filename_.string().c_str())); - - v8::Context::Scope contextScope(context); - - { - context->Global()->Set(context, V8_NEW_STRING_VAR(isolate_, Console::Name()), Console::WrapClass(isolate_)->GetFunction(context).ToLocalChecked()); - } - - //// opencv - //{ - // v8::Local proto = v8::ObjectTemplate::New(isolate_); - // opencv::initialize(isolate_, proto); - - // auto instance = proto->NewInstance(context); - - // if (auto result = context->Global()->Set(context, V8_NEW_STRING_VAR(isolate_, "cv"), instance.ToLocalChecked()); result.IsNothing()) { - // LOG_ERROR("v8") << GetException(isolate_, try_catch); - // return; - // } - //} - { - v8::Local args = v8::Array::New(isolate_, __argc); - for (int i = 0; i < __argc; ++i) { - args->Set(context, i, V8_NEW_STRING_VAR(isolate_, __argv[i])); - } - context->Global()->Set(context, V8_NEW_STRING_VAR(isolate_, "arguments"), args); - } - if (try_catch.HasCaught()) { - LOG_ERROR("engine") << GetException(isolate_, try_catch); - return; - } - global_context.Reset(isolate_, context); - } - - if (inspect_brk_) { - inspector_client_.reset(new InspectorClient(receiver_, global_context.Get(isolate_), platform_)); - isolate_->RequestInterrupt([](v8::Isolate* isolate, void* data) { - InspectorAgent* agent = static_cast(data); - agent->pumpMessageLoop(); - }, this); - } - else { - QCoreApplication::postEvent(receiver_, new ContinueRunEvent); - } -} - -void shelllet::interpreter::InspectorAgent::cleanup() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - if (inspect_brk_) { - disconnectInspector(); - } - -#ifdef _DEBUG - isolate_->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection); -#endif // _DEBUG - - global_context.Reset(); -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/inspector_channel.cpp b/QtRpa/modules/interpreter2/src/inspector_channel.cpp deleted file mode 100644 index cdadee1..0000000 --- a/QtRpa/modules/interpreter2/src/inspector_channel.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "interpreter/inspector_channel.h" -#include "interpreter/inspector_client.h" -void shelllet::inspect::InspectorChannel::sendResponse(int call_id, std::unique_ptr message) -{ - boost::ignore_unused(call_id); - client_->sendMessageToFrontend(message->string()); -} - -void shelllet::inspect::InspectorChannel::sendNotification(std::unique_ptr message) -{ - client_->sendMessageToFrontend(message->string()); -} - -void shelllet::inspect::InspectorChannel::pauseOnNextJavascriptStatement(const std::string& reason) -{ - auto buffer = v8_inspector::StringBuffer::create({ reinterpret_cast(reason.c_str()), reason.length() }); - session_->schedulePauseOnNextStatement(buffer->string(), buffer->string()); -} - -void shelllet::inspect::InspectorChannel::dispatchProtocolMessage(const std::string& message) -{ - session_->dispatchProtocolMessage({ reinterpret_cast(message.c_str()), message.length() }); -} - -shelllet::inspect::InspectorChannel::InspectorChannel(v8_inspector::V8Inspector* inspector, InspectorClient* c) :client_(c) -{ - std::string debugger = "{}"; - session_ = inspector->connect(1, this, v8_inspector::StringView(reinterpret_cast(debugger.c_str()), debugger.length())); -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/inspector_client.cpp b/QtRpa/modules/interpreter2/src/inspector_client.cpp deleted file mode 100644 index 39b1efd..0000000 --- a/QtRpa/modules/interpreter2/src/inspector_client.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include "common.hpp" -#include "v8.hpp" -#include -#include -#include -#include -#include "interpreter/inspector_client.h" - -namespace shelllet { - const int kContextGroupId = 1; - class DispatchMessagesTask : public v8::Task { - public: - explicit DispatchMessagesTask(inspect::InspectorClient* agent, const std::string& message) - : agent_(agent) - , message_(message) { - } - - void Run() override { - if (agent_ != nullptr) { - agent_->dispatchProtocolMessage(message_); - } - } - - private: - inspect::InspectorClient* agent_; - std::string message_; - }; - - extern v8::Global global_context; -} -shelllet::inspect::InspectorClient::InspectorClient(QObject* receiver, const v8::Local& context, v8::Platform* platform) - : isolate_(context->GetIsolate()) - , platform_(platform) - , receiver_(receiver) -{ - std::string name = "{}"; - inspector_ = v8_inspector::V8Inspector::create(isolate_, this); - inspector_->contextCreated(v8_inspector::V8ContextInfo( - context, kContextGroupId, v8_inspector::StringView(reinterpret_cast(name.c_str()), name.length()))); - - channel_.reset(new InspectorChannel(inspector_.get(), this)); -} - -void shelllet::inspect::InspectorClient::sendMessageToFrontend(const v8_inspector::StringView& string) -{ - int length = static_cast(string.length()); - - v8::Local message = (string.is8Bit() - ? v8::String::NewFromOneByte( - isolate_, - reinterpret_cast(string.characters8())/*, - v8::NewStringType::kNormal, length*/) - : v8::String::NewFromTwoByte( - isolate_, - reinterpret_cast(string.characters16())/*, - v8::NewStringType::kNormal, length*/)) - .ToLocalChecked(); - std::string resp = ToString({ isolate_, message }); - QCoreApplication::postEvent(receiver_, new MessageOutEvent(resp)); -} - -void shelllet::inspect::InspectorClient::runMessageLoopOnPause(int contextGroupId) -{ - is_paused_ = true; - while (is_paused_ && waitForFrontendMessageWhilePaused()) { - pumpMessageLoop(); - } - is_paused_ = false; -} - -void shelllet::inspect::InspectorClient::quitMessageLoopOnPause() -{ - is_paused_ = false; -} - -void shelllet::inspect::InspectorClient::pauseOnNextJavascriptStatement(const std::string& reason) -{ - if (channel_) - channel_->pauseOnNextJavascriptStatement(reason); -} - -double shelllet::inspect::InspectorClient::currentTimeMS() -{ - return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); -} - -void shelllet::inspect::InspectorClient::runIfWaitingForDebugger(int contextGroupId) -{ - pauseOnNextJavascriptStatement("Break at bootstrap"); - QCoreApplication::postEvent(receiver_, new ContinueRunEvent); -} -// -//std::unique_ptr shelllet::inspect::InspectorClient::resourceNameToUrl(const v8_inspector::StringView& resourceName) -//{ -// v8::Locker locker(isolate_); -// v8::HandleScope handle_scope(isolate_); -// int length = static_cast(resourceName.length()); -// //DCHECK_LT(length, v8::String::kMaxLength); -// v8::Local message = -// (resourceName.is8Bit() -// ? v8::String::NewFromOneByte( -// isolate_, -// reinterpret_cast(resourceName.characters8()), -// v8::NewStringType::kNormal, length) -// : v8::String::NewFromTwoByte( -// isolate_, -// reinterpret_cast(resourceName.characters16()), -// v8::NewStringType::kNormal, length)) -// .ToLocalChecked(); -// std::filesystem::path file = shelllet::ToString({ isolate_, message }); -// //file = "E:\\vision\\debug.js"; -// if (!std::filesystem::is_regular_file(file)) -// return nullptr; -// -// std::string url = QUrl::fromLocalFile(QString::fromUtf8(file.string().c_str())).url().toStdString(); -// return v8_inspector::StringBuffer::create({ reinterpret_cast (url.c_str()), url.size() }); -//} - -void shelllet::inspect::InspectorClient::postInspectorMessage(const std::string& message) -{ - //v8::Locker locker(isolate_); - //v8::Isolate::Scope isolate_scope(isolate_); - //v8::HandleScope handle_scope(isolate_); - platform_->GetForegroundTaskRunner(isolate_)->PostTask(std::make_unique(this, message)); - if (is_paused_) - is_ready_ = true; - else { - QCoreApplication::postEvent(receiver_, new PumpMessageLoopEvent); - } -} - -void shelllet::inspect::InspectorClient::consoleAPIMessage(int contextGroupId, v8::Isolate::MessageErrorLevel level, const v8_inspector::StringView& message, const v8_inspector::StringView& url, unsigned lineNumber, unsigned columnNumber, v8_inspector::V8StackTrace*) -{ - throw std::logic_error("The method or operation is not implemented."); -} - -v8::Local shelllet::inspect::InspectorClient::ensureDefaultContextInGroup(int groupId) -{ - return global_context.Get(isolate_); -} - -void shelllet::inspect::InspectorClient::dispatchProtocolMessage(const std::string& message) -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - channel_->dispatchProtocolMessage(message); -} - -bool shelllet::inspect::InspectorClient::waitForFrontendMessageWhilePaused() -{ - while (!is_ready_) { - QCoreApplication::processEvents(); - } - is_ready_ = !is_ready_; - return true; -} - -void shelllet::inspect::InspectorClient::disconnectFrontend() -{ - is_ready_ = true; - quitMessageLoopOnPause(); -} - -void shelllet::inspect::InspectorClient::pumpMessageLoop() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - while (v8::platform::PumpMessageLoop(platform_, isolate_)) { - QCoreApplication::processEvents(); - } -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/native_library.cpp b/QtRpa/modules/interpreter2/src/native_library.cpp deleted file mode 100644 index 4df869d..0000000 --- a/QtRpa/modules/interpreter2/src/native_library.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "common.hpp" -#include "v8.hpp" -#include "interpreter/native_library.h" - -#include "libs/core/qobject_implement.h" -//#include "libs/core/randomdevice_implement.h" -//#include "libs/core/uniformintdistribution_implement.h" -#include "libs/core/qcoreapplication_implement.h" -#include "libs/core/qsize_implement.h" -#include "libs/core/qrect_implement.h" -#include "libs/core/qurl_implement.h" -#include "libs/core/qpoint_implement.h" -#include "libs/core/qtimer_implement.h" -#include "libs/core/qdiriterator_implement.h" -#include "libs/core/qdir_implement.h" -#include "libs/core/qfile_implement.h" - - -namespace shelllet { - namespace library { - - Q_GLOBAL_STATIC(NativeLibrary, global_native_library) - - - - - } - - namespace core { - void initialize(v8::Isolate* isolate, const v8::Local& global) { - using namespace shelllet::core; - { - //objectTemplate->Set(isolate, RandomDevice::Name(), RandomDevice::WrapClass(isolate)); - //objectTemplate->Set(isolate, UniformIntDistribution::Name(), UniformIntDistribution::WrapClass(isolate)); - - global->Set(isolate, Object::Name(), Object::WrapClass(isolate)); - global->Set(isolate, CoreApplication::Name(), CoreApplication::WrapClass(isolate)); - global->Set(isolate, Size::Name(), Size::WrapClass(isolate)); - global->Set(isolate, Rect::Name(), Rect::WrapClass(isolate)); - global->Set(isolate, Url::Name(), Url::WrapClass(isolate)); - global->Set(isolate, Point::Name(), Point::WrapClass(isolate)); - global->Set(isolate, Timer::Name(), Timer::WrapClass(isolate)); - global->Set(isolate, DirIterator::Name(), DirIterator::WrapClass(isolate)); - global->Set(isolate, Dir::Name(), Dir::WrapClass(isolate)); - global->Set(isolate, File::Name(), File::WrapClass(isolate)); - } - } - } - -} -bool shelllet::library::NativeLibrary::initialize(v8::Isolate* isolate, const v8::Local& global) -{ - core::initialize(isolate, global); - - return true; -} - - -shelllet::library::NativeLibrary* shelllet::library::NativeLibrary::getInstance() -{ - return global_native_library; -} - -shelllet::library::NativeLibrary::~NativeLibrary() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/plugin_load.cpp b/QtRpa/modules/interpreter2/src/plugin_load.cpp deleted file mode 100644 index 964021a..0000000 --- a/QtRpa/modules/interpreter2/src/plugin_load.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "interpreter/inspector_agent.h" -#include "interpreter/native_library.h" -namespace shelllet { - using namespace library; - extern v8::Global global_context; -} diff --git a/QtRpa/modules/interpreter2/src/tcp_server.cpp b/QtRpa/modules/interpreter2/src/tcp_server.cpp deleted file mode 100644 index b68e36a..0000000 --- a/QtRpa/modules/interpreter2/src/tcp_server.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include "interpreter/tcp_server.h" -#include "interpreter/websocket_listener.h" -void shelllet::inspect::TcpServer::run() -{ - std::make_shared(receiver_, io_, boost::asio::ip::tcp::endpoint{ boost::asio::ip::make_address(address_.toString().toStdString()), port_ })->run(); - io_.run(); -} - -shelllet::inspect::TcpServer::TcpServer(Receiver* receiver, const QHostAddress& address, uint16_t port) - : receiver_(receiver) - , address_(address) - , port_(port) -{ -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/timer_resource.cpp b/QtRpa/modules/interpreter2/src/timer_resource.cpp deleted file mode 100644 index 74cf59e..0000000 --- a/QtRpa/modules/interpreter2/src/timer_resource.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "common.hpp" -#include -#include "interpreter/error.h" -#include "interpreter/timer_resource.h" -#include "interpreter/global/global_implement.h" - -namespace shelllet { - using namespace global; -} -shelllet::resource::TimerPrivate::TimerPrivate(v8::Isolate* isolate, const v8::Local& f) - : fn(isolate, f) -{ -} - -void shelllet::resource::TimerPrivate::setTimeout(const std::function& cb, uint64_t timeout) -{ - timer = std::make_unique(); - connection = timer->callOnTimeout([this, cb]() { - cb(this); - }); - timer->setSingleShot(true); - timer->setTimerType(Qt::CoarseTimer); - timer->start(timeout); -} - -void shelllet::resource::TimerPrivate::clearTimeout() -{ - timer->stop(); - timer->disconnect(connection); -} - -void shelllet::resource::TimerPrivate::setInterval(const std::function& cb, uint64_t repeat) -{ - timer = std::make_unique(); - connection = timer->callOnTimeout([this, cb]() { - cb(this); - }); - timer->setSingleShot(false); - timer->setInterval(repeat); - timer->setTimerType(Qt::CoarseTimer); - timer->start(); -} - -void shelllet::resource::TimerPrivate::clearInterval() -{ - timer->stop(); - timer->disconnect(connection); -} - -void shelllet::resource::TimerPrivate::cleanup() -{ - clearTimeout(); - clearInterval(); - fn.Reset(); -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/websocket_listener.cpp b/QtRpa/modules/interpreter2/src/websocket_listener.cpp deleted file mode 100644 index 0e2a6d6..0000000 --- a/QtRpa/modules/interpreter2/src/websocket_listener.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "common.hpp" -#include "interpreter/websocket_listener.h" -#include "interpreter/http_session.h" - -namespace shelllet { -} - -shelllet::inspect::WebSocketListener::WebSocketListener(shelllet::inspect::Receiver* receiver, boost::asio::io_context& ioc, boost::asio::ip::tcp::endpoint endpoint) - : receiver_(receiver) - , ioc_(ioc) - , acceptor_(ioc) -{ - boost::beast::error_code ec; - acceptor_.open(endpoint.protocol(), ec); - if (ec) - { - LOG_ERROR("inspect") << "# open error: " << ec.message() << std::endl; - return; - } - - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); - if (ec) - { - LOG_ERROR("inspect") << "# set option error: " << ec.message() << std::endl; - return; - } - acceptor_.bind(endpoint, ec); - if (ec) - { - LOG_ERROR("inspect") << "# bind error: " << ec.message() << std::endl; - return; - } - - acceptor_.listen(boost::asio::socket_base::max_listen_connections, ec); - if (ec) - { - LOG_ERROR("inspect") << "# set option error: " << ec.message() << std::endl; - } -} - -void shelllet::inspect::WebSocketListener::run() -{ - boost::asio::dispatch(acceptor_.get_executor(), boost::beast::bind_front_handler(&WebSocketListener::doAccept, this->shared_from_this())); -} - -void shelllet::inspect::WebSocketListener::doAccept() -{ - acceptor_.async_accept(boost::asio::make_strand(ioc_), boost::beast::bind_front_handler(&WebSocketListener::onAccept, shared_from_this())); -} - -void shelllet::inspect::WebSocketListener::onAccept(boost::beast::error_code ec, boost::asio::ip::tcp::socket socket) -{ - if (ec) - { - LOG_ERROR("inspect") << "# accept error: " << ec.message() << std::endl; - } - else - { - std::make_shared(receiver_, std::move(socket))->run(); - } - if (QThread::currentThread()->isInterruptionRequested()) { - ioc_.stop(); - return; - } - doAccept(); -} \ No newline at end of file diff --git a/QtRpa/modules/interpreter2/src/websocket_session.cpp b/QtRpa/modules/interpreter2/src/websocket_session.cpp deleted file mode 100644 index a8bc027..0000000 --- a/QtRpa/modules/interpreter2/src/websocket_session.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "common.hpp" -#include "interpreter/websocket_session.h" -namespace shelllet { - std::mutex mutex; -} -shelllet::inspect::WebsocketSession::WebsocketSession(shelllet::inspect::Receiver* receiver, boost::asio::ip::tcp::socket&& socket) - : receiver_(receiver) - , ws_(std::move(socket)) -{ - receiver_->callback = [this](auto& message) { - std::lock_guard lock_guard(mutex); - messages_.emplace_front(message); - }; -} - -shelllet::inspect::WebsocketSession::~WebsocketSession() -{ - receiver_->callback = {}; - LOG_TRACE("inspect") << "# ~websocket_session." << std::endl; -} - -//void shelllet::inspect::WebsocketSession::customEvent(QEvent* event) -//{ -// if (auto* e = dynamic_cast(event)) { -// doRead(); -// } -// else if (auto* e = dynamic_cast(event)) { -// doWrite(messages_.back()); -// messages_.pop_back(); -// } -//} - -void shelllet::inspect::WebsocketSession::onAccept(boost::beast::error_code ec) -{ - if (ec) { - LOG_ERROR("inspect") << "# accept error: " << ec.message() << std::endl; - return; - } - - class Runnable : public QRunnable { - public: - Runnable(const std::shared_ptr& session) :self_(session) { - } - void run() override { - self_->thread_ = QThread::currentThread(); - while (true) { - if (QThread::currentThread()->isInterruptionRequested()) { - break; - } - if (self_->messages_.empty()) { - self_->doRead(); - } - else { - std::lock_guard lock_guard(mutex); - self_->doWrite(self_->messages_.back()); - self_->messages_.pop_back(); - } - QCoreApplication::processEvents(); - std::this_thread::sleep_for(10ms); - } - QCoreApplication::postEvent(self_->receiver_, new DisconnectEvent); - - LOG_INFO("inspect") << "# message runnable exit." << std::endl; - } - private: - std::shared_ptr self_; - }; - QThreadPool::globalInstance()->start(new Runnable(shared_from_this())); -} - -void shelllet::inspect::WebsocketSession::doRead() -{ - if (is_read_ok_) { - is_read_ok_ = false; - ws_.async_read(buffer_, boost::beast::bind_front_handler(&WebsocketSession::onRead, shared_from_this())); - } -} - -void shelllet::inspect::WebsocketSession::onRead(boost::beast::error_code ec, std::size_t bytes_transferred) -{ - boost::ignore_unused(bytes_transferred); - - if (ec == boost::beast::websocket::error::closed) { - if (thread_) { - thread_->requestInterruption(); - } - return; - } - - if (ec) { - LOG_ERROR("inspect") << "# read error: " << ec.message() << std::endl; - if (thread_) { - thread_->requestInterruption(); - } - return; - } - - std::string message = boost::beast::buffers_to_string(buffer_.cdata()); - QCoreApplication::postEvent(receiver_, new MessageInEvent(message)); - - is_read_ok_ = true; - buffer_.consume(buffer_.size()); - LOG_TRACE("inspct") << "# incoming: " << message << std::endl; -} -void shelllet::inspect::WebsocketSession::doWrite(const std::string& message) -{ - ws_.text(true); - - boost::beast::error_code ec; - - std::size_t size = ws_.write(boost::asio::buffer(message), ec); - - if (ec) { - LOG_ERROR("inspect") << "# write error: " << ec.message() << std::endl; - if (thread_) { - thread_->requestInterruption(); - } - return; - } - assert(size == message.length()); - - LOG_TRACE("inspct") << "# outgoing: " << message << std::endl; -} \ No newline at end of file diff --git a/QtRpa/modules/model/CMakeLists.txt b/QtRpa/modules/model/CMakeLists.txt deleted file mode 100644 index 61a5e38..0000000 --- a/QtRpa/modules/model/CMakeLists.txt +++ /dev/null @@ -1,29 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.17) -cmake_policy(SET CMP0091 NEW) - -project(model) - -set(CMAKE_AUTOMOC ON) - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(pugixml CONFIG REQUIRED) -#find_package(Qt5Core CONFIG REQUIRED) -find_package(Qt5Gui CONFIG REQUIRED) - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - #${Qt5Core_INCLUDE_DIRS} - #${Qt5Core_PRIVATE_INCLUDE_DIRS} - ${Qt5Gui_INCLUDE_DIRS} - ${Qt5Gui_PRIVATE_INCLUDE_DIRS} -) - diff --git a/QtRpa/modules/model/src/activities_dom_item.cpp b/QtRpa/modules/model/src/activities_dom_item.cpp deleted file mode 100644 index f42c407..0000000 --- a/QtRpa/modules/model/src/activities_dom_item.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "common.hpp" -#include "model/activities_dom_item.h" -#include "common/private/object_p.h" -#include "model/private/elementdomitem_p.h" - -shelllet::model::ActivitiesDomItem::ActivitiesDomItem(const XmlNode& node, int row, int depth, ActivitiesDomItem* parent) - : Object(*new ActivitiesDomItemPrivate, nullptr) -{ - Q_D(ActivitiesDomItem); - d->domNode = node; - d->parentItem = parent; - d->rowNumber = row; - d->depth = depth; -} - -shelllet::model::ActivitiesDomItem::~ActivitiesDomItem() -{ - Q_D(ActivitiesDomItem); - qDeleteAll(d->childItems); -} - -XmlNode shelllet::model::ActivitiesDomItem::node() const -{ - Q_D(const ActivitiesDomItem); - return d->domNode; -} - -shelllet::model::ActivitiesDomItem* shelllet::model::ActivitiesDomItem::parent() -{ - Q_D(ActivitiesDomItem); - return d->parentItem; -} - -shelllet::model::ActivitiesDomItem* shelllet::model::ActivitiesDomItem::child(int i) -{ - Q_D(ActivitiesDomItem); - - ActivitiesDomItem* childItem = d->childItems.value(i); - if (childItem) - return childItem; - - // if child does not yet exist, create it - auto children = d->domNode.children(); - - if (d->depth <= Environment::getInstance()->getOptions()->depth) { - auto vi = children.begin(); - std::advance(vi, i); - - if (vi->type() == XmlNodeType::Element && vi != children.end()) { - if (i >= 0) { - - childItem = new ActivitiesDomItem(*vi, i, d->depth + 1, this); - d->childItems[i] = childItem; - } - } - } - - return childItem; -} - -int shelllet::model::ActivitiesDomItem::row() const -{ - Q_D(const ActivitiesDomItem); - return d->rowNumber; -} \ No newline at end of file diff --git a/QtRpa/modules/model/src/activities_search_model.cpp b/QtRpa/modules/model/src/activities_search_model.cpp deleted file mode 100644 index 0ef7117..0000000 --- a/QtRpa/modules/model/src/activities_search_model.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "common.hpp" -#include -#include "model/activities_search_model.h" -#include "model/activities_dom_item.h" -#include "qbuffer.h" -#include "model/xmlmimedata.h" - - - -shelllet::model::ActivitiesDomModel::ActivitiesDomModel(const SharedPointer& doc, QObject* parent) - : QAbstractItemModel(parent) - , rootItem(new ActivitiesDomItem(doc->documentElement(), 0, 0)) -{ -} - -shelllet::model::ActivitiesDomModel::~ActivitiesDomModel() -{ - delete rootItem; -} - -int shelllet::model::ActivitiesDomModel::columnCount(const QModelIndex& parent) const -{ - Q_UNUSED(parent); - return 3; -} - -QVariant shelllet::model::ActivitiesDomModel::data(const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role != Qt::DisplayRole) - return QVariant(); - - const auto* item = static_cast(index.internalPointer()); - - if (index.column() == 0) { - { - if (role == Qt::DisplayRole) { - - return *item->node().attribute(ElementParser::get_const_instance().keyDisplay()).value().toQString(); - - } - else if (role == Qt::DecorationRole) { - const auto icon_name = item->node().attribute(ElementParser::get_const_instance().keyDecoration()).value(); - if (auto name = item->node().parent().name(); name == ElementParser::get_const_instance().keySystem()) { - return Environment::getInstance()->getIconByName(icon_name); - } - else { - return Environment::getInstance()->iconMods((boost::format("%1%/%2% ") % name % icon_name).str()); - } - } - - } - } - - - - return QVariant(); -} - -Qt::ItemFlags shelllet::model::ActivitiesDomModel::flags(const QModelIndex& index) const -{ - Qt::ItemFlags defaultFlags = QAbstractItemModel::flags(index); - - if (index.isValid()) - return Qt::ItemIsDragEnabled | defaultFlags; - return defaultFlags; -} - -QVariant shelllet::model::ActivitiesDomModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch (section) { - case 0: - return tr("Name"); - default: - break; - } - } - return QVariant(); -} - -QModelIndex shelllet::model::ActivitiesDomModel::index(int row, int column, const QModelIndex& parent) const -{ - if (!hasIndex(row, column, parent)) - return QModelIndex(); - - ActivitiesDomItem* parentItem; - - if (!parent.isValid()) - parentItem = rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - ActivitiesDomItem* childItem = parentItem->child(row); - - if (childItem) { - QModelIndex index = createIndex(row, column, childItem); - - LOG_DEBUG("rpa") << "# child index: " << "(" << row << " - " << column << ")" << index.data(Qt::DisplayRole).toString(); - - return index; - } - return QModelIndex(); -} - -QModelIndex shelllet::model::ActivitiesDomModel::parent(const QModelIndex& child) const -{ - if (!child.isValid()) - return QModelIndex(); - - auto* childItem = static_cast(child.internalPointer()); - auto* parentItem = childItem->parent(); - - if (!parentItem || parentItem == rootItem) - return QModelIndex(); - - QModelIndex index = createIndex(parentItem->row(), 0, parentItem); - - - return index; -} - -int shelllet::model::ActivitiesDomModel::rowCount(const QModelIndex& parent) const -{ - //if (parent.column() > 0) - // return 0; - - ActivitiesDomItem* parentItem; - - if (!parent.isValid()) - parentItem = rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - const auto& children = parentItem->node().children(); - - return std::distance(children.begin(), children.end()); -} - -QMimeData* shelllet::model::ActivitiesDomModel::mimeData(const QModelIndexList& indexes) const -{ - if (indexes.count() <= 0) - return nullptr; - - //auto type = common::Environment::getInstance()->getOptions()->mime_data_type; - auto* item = static_cast(indexes[0].internalPointer()); - - - //XmlByteArrayWriter writer; - //item->node().print(writer); - - //QMimeData* data = new XmlMimeData(item->node()); - - //pugi::xml_document doc; - //doc.append_copy(item->node()); - - return new XmlMimeData(item->node()); - //data->setData(type, writer.result); - //return data; -} \ No newline at end of file diff --git a/QtRpa/modules/model/src/activitiesmanager.cpp b/QtRpa/modules/model/src/activitiesmanager.cpp deleted file mode 100644 index 2a6ac48..0000000 --- a/QtRpa/modules/model/src/activitiesmanager.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "qobject.h" -#include "qdiriterator.h" -#include "qsharedpointer.h" -#include "qglobalstatic.h" -#include "model/activitiesmanager.h" -#include "private/qobject_p.h" -namespace shelllet { - namespace model { - class ActivitiesManagerPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(ActivitiesManager) - public: - SharedPointer doc = std::make_shared(); - }; - - Q_GLOBAL_STATIC(ActivitiesManager, __activitiesmanager__) - } -} -shelllet::model::ActivitiesManager::ActivitiesManager(ActivitiesManagerPrivate& d, QObject* parent /*= nullptr*/) - : QObject(d, parent) -{ - - d.doc->appendChild("activities").appendAttribute("display") = tr("activities").toStdString().c_str(); - -} - -void shelllet::model::ActivitiesManager::loadAll() -{ - Q_D(ActivitiesManager); - Path root = Environment::getInstance()->getActivitiesPath(); - - - //QDirIterator it(root.toString().toQString(), QStringList() << "*.xml", QDir::Files, QDirIterator::NoIteratorFlags); - - for (auto& p : DirectoryIterator(root)) - { - XmlDocument doc(root / p.path()); - LOG_DEBUG(PROJECT_NAME) << "doc: \n" << doc; - d->doc->documentElement().appendCopy(doc.documentElement()); - } - //while (it.hasNext()) { - - //} - - LOG_DEBUG(PROJECT_NAME) << "activities: " << "\n\t" << *d->doc; -} - -SharedPointer shelllet::model::ActivitiesManager::document() const -{ - Q_D(const ActivitiesManager); - return d->doc; -} - -shelllet::model::ActivitiesManager* shelllet::model::ActivitiesManager::getInstance() -{ - return __activitiesmanager__; -} - -shelllet::model::ActivitiesManager::ActivitiesManager(QObject* parent /*= nullptr*/) - : ActivitiesManager(*new ActivitiesManagerPrivate, parent) -{ - -} diff --git a/QtRpa/modules/model/src/variable_model.cpp b/QtRpa/modules/model/src/variable_model.cpp deleted file mode 100644 index 7180b6c..0000000 --- a/QtRpa/modules/model/src/variable_model.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include "common.hpp" -#include -#include "common/variable.h" -#include "model/variable_model.h" - - -shelllet::model::VariableModel::VariableModel(const YAML::Node& node, QObject* parent) - : QAbstractTableModel(parent) - , node_(node) -{ -#ifdef _DEBUG - std::ostringstream ss; - ss << node; - LOG_DEBUG("rpa") << "# variables: \n" << ss.str(); -#endif // _DEBUG -} - -shelllet::model::VariableModel::~VariableModel() -{ -} - -int shelllet::model::VariableModel::columnCount(const QModelIndex& parent) const -{ - Q_UNUSED(parent); - return Columns::Count; -} - -QVariant shelllet::model::VariableModel::data(const QModelIndex& index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role == Qt::DisplayRole || role == Qt::EditRole) - { - //Var var = node_[index.row()].as(); - - switch (index.column()) { - case Columns::Name: - case Columns::Type: - case Columns::Value: - case Columns::Desc: - { - try - { - return QString::fromStdString(node_[index.row()][Var::keys[static_cast(index.column())]].as()); - } - catch (const std::exception& err) - { - LOG_WARNING("rpa") << "# variables error: " << err.what(); - } - break; - } - case Columns::Ref: - try - { - return node_[index.row()][Var::keys[static_cast(index.column())]].as(); - } - catch (const std::exception&) - { - return 0; - } - break; - default: - break; - } - } - return QVariant(); -} - -Qt::ItemFlags shelllet::model::VariableModel::flags(const QModelIndex& index) const -{ - if (!index.isValid()) - return Qt::NoItemFlags; - - if (index.column() == Columns::Ref) { - return QAbstractTableModel::flags(index); - } - return QAbstractTableModel::flags(index) | Qt::ItemIsEditable; -} - -QVariant shelllet::model::VariableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - switch (section) { - case Columns::Name: - return tr("Name"); - case Columns::Type: - return tr("Type"); - case Columns::Value: - return tr("Value"); - case Columns::Ref: - return tr("Ref"); - case Columns::Desc: - return tr("Desc"); - default: - break; - } - } - return QVariant(); -} - -int shelllet::model::VariableModel::rowCount(const QModelIndex& parent) const -{ - return node_.size(); -} - -YAML::Node shelllet::model::VariableModel::node() const -{ - return node_; -} - -bool shelllet::model::VariableModel::setData(const QModelIndex& index, const QVariant& value, int role /*= Qt::EditRole*/) -{ - if (!index.isValid()) - return false; - - if (role == Qt::EditRole) { - switch (index.column()) { - case Columns::Name: - case Columns::Type: - case Columns::Value: - case Columns::Desc: - { - node_[index.row()][Var::keys[static_cast(index.column())]] = value.toString().toStdString(); - break; - } - default: - break; - } -#ifdef _DEBUG - std::ostringstream ss; - ss << node_; - LOG_DEBUG("rpa") << "# variables: \n" << ss.str(); -#endif // _DEBUG - emit dataChanged(index, index, { Qt::DisplayRole }); - return true; - } - - return false; -} - -bool shelllet::model::VariableModel::insertRows(int row, int count, const QModelIndex& parent /*= QModelIndex()*/) -{ - std::string name = "name"; - - if (rowCount() != 0) { - name.append(std::to_string(rowCount()).c_str()); - } - beginInsertRows(parent, row, row); - node_.push_back(Var{ name, "Auto", "", 0, "" }); - endInsertRows(); - return true; -} - -bool shelllet::model::VariableModel::removeRows(int row, int count, const QModelIndex& parent /*= QModelIndex()*/) -{ - beginRemoveRows(parent, row, row); - - node_.remove(node_[row]); - - endRemoveRows(); - - return true; -} \ No newline at end of file diff --git a/QtRpa/modules/model/src/xmlmimedata.cpp b/QtRpa/modules/model/src/xmlmimedata.cpp deleted file mode 100644 index 02c1f83..0000000 --- a/QtRpa/modules/model/src/xmlmimedata.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "model/xmlmimedata.h" -#include "model/private/xmlmimedata_p.h" -shelllet::model::XmlMimeData::XmlMimeData(const XmlNode& node) - : MimeData(*new XmlMimeDataPrivate) -{ - Q_D(XmlMimeData); - d->doc.appendCopy(node); -} - -XmlNode shelllet::model::XmlMimeData::documentElement() const -{ - Q_D(const XmlMimeData); - - return d->doc.documentElement(); -} - -void shelllet::model::XmlMimeData::setSourceItem(QGraphicsItem* source) -{ - Q_D(XmlMimeData); - d->source = source; -} - -QGraphicsItem* shelllet::model::XmlMimeData::sourceItem() const -{ - Q_D(const XmlMimeData); - return d->source; -} diff --git a/QtRpa/modules/properties/src/code.xxx b/QtRpa/modules/properties/src/code.xxx deleted file mode 100644 index e2b87b2..0000000 --- a/QtRpa/modules/properties/src/code.xxx +++ /dev/null @@ -1,120 +0,0 @@ -#include "properties/code.h" -#include "properties.hpp" -#include "properties/private/code_p.h" -#include "property_browser/qteditorfactory.h" -#include "qjsonobject.h" -#include "qjsondocument.h" -#include "quuid.h" -#include "common.hpp" -shelllet::properties::Code::Code(const pugi::xml_node& node /*= pugi::xml_node()*/, QObject* parent /*= nullptr*/) - : CompositeProperty(*new CodePrivate, node, parent) - -{ - Q_D(Code); - - //d->m_displayName = "Start"; - //d->dtype_ = DiagramType::StartEnd; - //d->tagName = "start"; - - d->code = node.child_value(); -} - -void shelllet::properties::Code::setCode(const String& filename) -{ - Q_D(Code); - d->code = filename; -} - -void shelllet::properties::Code::getCode(std::ostringstream& oss) -{ - - Q_D(Code); - oss << d->code; -} - - - -void shelllet::properties::Code::getDefines(std::ostringstream& oss) -{ - Q_D(Code); -} - - - - -//QByteArray shelllet::properties::Print::toData() const -//{ -// Q_D(Print); -// std::stringbuf string_buf; -// boost::archive::binary_oarchive oa(string_buf); -// oa << d; -// std::string buf = string_buf.str(); -// return QByteArray(buf.c_str(), buf.size()); -//} -// -//void shelllet::properties::Print::fromData(const QByteArray& data) -//{ -// Q_D(Print); -// std::stringbuf string_buf(data.constData()); -// boost::archive::binary_iarchive oi(string_buf); -// -// oi >> d; -//} - -//std::unique_ptr shelllet::properties::Code::getNode() -//{ -// Q_D(Code); -// -// auto doc = __super::getNode(); -// -// -// doc->document_element().append_child(pugi::node_pcdata).set_value(d->code.toStdString().c_str()); -// -// -// return doc; -//} - - - -String shelllet::properties::Code::code() const -{ - Q_D(const Code); - return d->code; -} - -//void shelllet::properties::print::toXml(pugi::xml_node& node) -//{ -// UniqueNamedProperty::toXml(node); -// node.append_attribute("message") = message_.c_str(); -//} - -//void shelllet::properties::print::fromXml(const pugi::xml_node& node) -//{ -// UniqueNamedProperty::fromXml(node); -// message_ = node.attribute("message").value(); -//} - -QtProperty* shelllet::properties::Code::getInput(QtTreePropertyBrowser* browser) -{ - Q_D(Code); - auto* input = __super::getInput(browser); - - QtLineEditFactory* lineEdit = new QtLineEditFactory(); - QtStringPropertyManager* strManager = new QtStringPropertyManager(); - - QtProperty* imports = strManager->addProperty(tr("Imports")); - input->addSubProperty(imports); - strManager->setValue(imports, d->import.toQString()); - - connect(strManager, &QtStringPropertyManager::valueChanged, [d](QtProperty* property, const QString& val) { - d->import = String::fromQString(val); - }); - - browser->setFactoryForManager(strManager, lineEdit); - return input; - - - return nullptr; -} - -//#include "moc_print.cpp" \ No newline at end of file diff --git a/QtRpa/modules/properties/src/filedelete.xxx b/QtRpa/modules/properties/src/filedelete.xxx deleted file mode 100644 index a6eadee..0000000 --- a/QtRpa/modules/properties/src/filedelete.xxx +++ /dev/null @@ -1,83 +0,0 @@ -#include "common.hpp" -#include "properties/filedelete.h" -#include "properties/private/filedelete_p.h" -#include "property_browser/qteditorfactory.h" - -#include "qjsonobject.h" -#include "qjsondocument.h" -#include "common/environment.h" - - -shelllet::properties::FileDelete::FileDelete(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new FileDeletePrivate, node, parent) -{ - Q_D(FileDelete); - d->fileName = node.attribute("filename").value(); -} -void shelllet::properties::FileDelete::setFileName(const QString& fileName) -{ - Q_D(FileDelete); - d->fileName = fileName; -} - -QString shelllet::properties::FileDelete::fileName() const -{ - Q_D(const FileDelete); - return d->fileName; -} - -int shelllet::properties::FileDelete::getPropertyMetaTypeID() const -{ - throw std::logic_error("The method or operation is not implemented."); -} - -void shelllet::properties::FileDelete::getCode(std::ostringstream& oss) -{ - Q_D(const FileDelete); - - QJsonObject object{ {"filename", d->fileName} }; - - QJsonDocument document(object); - - oss //<< "{" << std::endl - // << "from system import file_remove" - << std::endl - << "file_remove.invoke" - << "(" << document.toJson() << ");" - << std::endl - //<< "}" - << std::endl; - - -} -// -//std::string shelllet::properties::FileDelete::getImport() const -//{ -// Q_D(const FileDelete); -// //return "import system.file_remove"; -// //return "from system import file_remove"; -// -// return __super::getImport(); -// -//} - -QtProperty* shelllet::properties::FileDelete::getInput(QtTreePropertyBrowser* browser) -{ - Q_D(FileDelete); - auto* input = __super::getInput(browser); - - QtLineEditFactory* lineEdit = new QtLineEditFactory(); - QtStringPropertyManager* strManager = new QtStringPropertyManager(); - - QtProperty* fileName = strManager->addProperty(tr("Filename")); - input->addSubProperty(fileName); - strManager->setValue(fileName, d->fileName); - - connect(strManager, &QtStringPropertyManager::valueChanged, [d](QtProperty* property, const QString& val) { - d->fileName = val; - }); - - browser->setFactoryForManager(strManager, lineEdit); - return input; -} - diff --git a/QtRpa/modules/properties/src/helper.xxx b/QtRpa/modules/properties/src/helper.xxx deleted file mode 100644 index be164f7..0000000 --- a/QtRpa/modules/properties/src/helper.xxx +++ /dev/null @@ -1,102 +0,0 @@ -#include "properties/helper.h" - -#include "properties/sequence.h" -#include "properties/print.h" -#include "properties/code.h" -#include "properties/filedelete.h" -#include "properties/processstart.h" - -//BOOST_CLASS_EXPORT(shelllet::properties::Print) - - -void shelllet::properties::Helper::register_meta_type() -{ - //qRegisterMetaType(); - //qRegisterMetaType(); - - //qRegisterMetaType(); - //qRegisterMetaType(); - //qRegisterMetaType(); - //qRegisterMetaType(); - //qRegisterMetaType(); - -} - -//shelllet::properties::tree_property_browser* shelllet::properties::my_plugin_properties::create_tree_property_browser(QWidget* parent) -//{ -// throw std::logic_error("The method or operation is not implemented."); -//} -// -//std::unique_ptr shelllet::properties::Helper::create_node(const std::string& meta, const std::string& name) -//{ -// properties::CompositeProperty* childItem = nullptr; -// std::string n = properties::CompositeProperty::Prefix() + "::" + meta + "*"; -// -// //LOG_TRACE(__FUNCTION__) << "# record meta: " << n << std::endl; -// int id = QMetaType::type(n.c_str()); -// -// if (id != QMetaType::UnknownType) { -// const auto* meta = QMetaType::metaObjectForType(id); -// BOOST_ASSERT(false); -// //childItem = dynamic_cast(meta->newInstance(Q_ARG(std::string, name))); -// //childItem->fromXml(node); -// } -// else { -// // LOG_TRACE(__FUNCTION__) << "# meta type is unknown: " << node.name() << "-" << node.attribute("meta").value() << std::endl; -// } -// -// return std::unique_ptr(childItem); -//} -// -//std::unique_ptr shelllet::properties::Helper::create_node(pugi::xml_node node) -//{ -// properties::CompositeProperty* childItem = nullptr; -// -// std::string n = properties::CompositeProperty::prefix() + "::" + node.attribute("meta").value() + "*"; -// -// //LOG_TRACE(__FUNCTION__) << "# record meta: " << n << std::endl; -// int id = QMetaType::type(n.c_str()); -// -// if (id != QMetaType::UnknownType) { -// const auto* meta = QMetaType::metaObjectForType(id); -// childItem = dynamic_cast(meta->newInstance(Q_ARG(pugi::xml_node, node))); -// //childItem->fromXml(node); -// } -// else { -// // LOG_TRACE(__FUNCTION__) << "# meta type is unknown: " << node.name() << "-" << node.attribute("meta").value() << std::endl; -// } -// -// return std::unique_ptr(childItem); -//} - -//std::string shelllet::properties::Helper::toData(const std::shared_ptr& data) -//{ -// std::stringbuf string_buf; -// boost::archive::binary_oarchive oa(string_buf); -// oa << data; -// -// return string_buf.str(); -//} -// -//std::shared_ptr shelllet::properties::Helper::fromData(const std::string& data) -//{ -// std::stringbuf string_buf(data); -// boost::archive::binary_iarchive oi(string_buf); -// std::shared_ptr prop; -// -// oi >> prop; -// -// return prop; -//} - -std::string shelllet::properties::Helper::toString(const pugi::xml_node& node) -{ - std::ostringstream os; - node.print(os); - return os.str(); -} - -std::unique_ptr shelllet::properties::Helper::createRoot() -{ - return std::move(std::make_unique()); -} diff --git a/QtRpa/modules/properties/src/network_send.xxx b/QtRpa/modules/properties/src/network_send.xxx deleted file mode 100644 index e8565b8..0000000 --- a/QtRpa/modules/properties/src/network_send.xxx +++ /dev/null @@ -1,39 +0,0 @@ -#include "properties.hpp" -#include "properties/network_send.h" -#include "properties/private/network_send_p.h" -#include "qwidget.h" - - -shelllet::properties::NetworkSend::NetworkSend(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new CompositePropertyPrivate, node, parent) -{ -} -void shelllet::properties::NetworkSend::setData(const QString& data) -{ - Q_D(NetworkSend); - d->m_data = data; -} - -QString shelllet::properties::NetworkSend::getData() const -{ - Q_D(const NetworkSend); - return d->m_data; -} - -void shelllet::properties::NetworkSend::setOwner(const QString& owner) -{ - Q_D(NetworkSend); - d->m_owner = owner; -} - -QString shelllet::properties::NetworkSend::getOwner() const -{ - Q_D(const NetworkSend); - return d->m_owner; -} - -int shelllet::properties::NetworkSend::getPropertyMetaTypeID() const -{ - throw std::logic_error("The method or operation is not implemented."); -} - diff --git a/QtRpa/modules/properties/src/network_udp_client.xxx b/QtRpa/modules/properties/src/network_udp_client.xxx deleted file mode 100644 index 379c342..0000000 --- a/QtRpa/modules/properties/src/network_udp_client.xxx +++ /dev/null @@ -1,63 +0,0 @@ -#include "properties.hpp" -#include "properties/network_udp_client.h" -#include "properties/private/network_udp_client_p.h" - - -shelllet::properties::NetworkUDPClient::NetworkUDPClient(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new NetworkUDPClientPrivate, node, parent) -{ -} - -void shelllet::properties::NetworkUDPClient::setCode(const QString& code) -{ - Q_D(NetworkUDPClient); - d->m_code = code; -} - -QString shelllet::properties::NetworkUDPClient::getCode() const -{ - Q_D(const NetworkUDPClient); - return d->m_code; -} - -void shelllet::properties::NetworkUDPClient::setIP(const QString& ip) -{ - Q_D(NetworkUDPClient); - d->m_ip = ip; -} - -QString shelllet::properties::NetworkUDPClient::getIP() const -{ - Q_D(const NetworkUDPClient); - return d->m_ip; -} - -int16_t shelllet::properties::NetworkUDPClient::getPort() const -{ - Q_D(const NetworkUDPClient); - return d->m_port; -} - -void shelllet::properties::NetworkUDPClient::setPort(int16_t port) -{ - Q_D(NetworkUDPClient); - d->m_port = port; -} - -QString shelllet::properties::NetworkUDPClient::getOutputVariable() const -{ - Q_D(const NetworkUDPClient); - return d->m_outputVariable; -} - -void shelllet::properties::NetworkUDPClient::setOutputVariable(const QString& variable) -{ - Q_D(NetworkUDPClient); - d->m_outputVariable = variable; -} - -int shelllet::properties::NetworkUDPClient::getPropertyMetaTypeID() const -{ - throw std::logic_error("The method or operation is not implemented."); -} - diff --git a/QtRpa/modules/properties/src/network_udp_server.xxx b/QtRpa/modules/properties/src/network_udp_server.xxx deleted file mode 100644 index 54b9b70..0000000 --- a/QtRpa/modules/properties/src/network_udp_server.xxx +++ /dev/null @@ -1,63 +0,0 @@ -#include "properties.hpp" -#include "properties/network_udp_server.h" -#include "properties/private/network_udp_server_p.h" - - -shelllet::properties::NetworkUDPServer::NetworkUDPServer(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new NetworkUDPServerPrivate, node, parent) -{ -} - -void shelllet::properties::NetworkUDPServer::setCode(const QString& code) -{ - Q_D(NetworkUDPServer); - d->m_code = code; -} - -QString shelllet::properties::NetworkUDPServer::getCode() const -{ - Q_D(const NetworkUDPServer); - return d->m_code; -} - -void shelllet::properties::NetworkUDPServer::setIP(const QString& ip) -{ - Q_D(NetworkUDPServer); - d->m_ip = ip; -} - -QString shelllet::properties::NetworkUDPServer::getIP() const -{ - Q_D(const NetworkUDPServer); - return d->m_ip; -} - -int16_t shelllet::properties::NetworkUDPServer::getPort() const -{ - Q_D(const NetworkUDPServer); - return d->m_port; -} - -void shelllet::properties::NetworkUDPServer::setPort(int16_t port) -{ - Q_D(NetworkUDPServer); - d->m_port = port; -} - -QString shelllet::properties::NetworkUDPServer::getOutputVariable() const -{ - Q_D(const NetworkUDPServer); - return d->m_outputVariable; -} - -void shelllet::properties::NetworkUDPServer::setOutputVariable(const QString& variable) -{ - Q_D(NetworkUDPServer); - d->m_outputVariable = variable; -} - -int shelllet::properties::NetworkUDPServer::getPropertyMetaTypeID() const -{ - throw std::logic_error("The method or operation is not implemented."); -} - diff --git a/QtRpa/modules/properties/src/print.xxx b/QtRpa/modules/properties/src/print.xxx deleted file mode 100644 index 4299a44..0000000 --- a/QtRpa/modules/properties/src/print.xxx +++ /dev/null @@ -1,102 +0,0 @@ -#include "common.hpp" -#include "properties.hpp" -#include "properties/print.h" -#include "properties/private/print_p.h" -#include "property_browser/qteditorfactory.h" -#include "qjsonobject.h" -#include "qjsondocument.h" -#include "quuid.h" -shelllet::properties::Print::Print(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new PrintPrivate, node, parent) - -{ - Q_D(Print); - d->message_ = node.attribute("message").value(); - d->id = QUuid::createUuid().toString(QUuid::Id128); -} - - - -void shelllet::properties::Print::getCode(std::ostringstream& oss) -{ - Q_D(Print); - oss << "__print.print(" << tagName() << "_" << d->id << ".message)" << std::endl; -} - - -//std::string shelllet::properties::Print::getImport() const -//{ -// return ""; -//} - -void shelllet::properties::Print::getDefines(std::ostringstream& oss) -{ - Q_D(Print); - QJsonObject object; - object["message"] = d->message_; - QJsonDocument document(object); - oss << "var " << tagName() << "_" << d->id << " = " << document.toJson().constData() << std::endl; -} - - -//QByteArray shelllet::properties::Print::toData() const -//{ -// Q_D(Print); -// std::stringbuf string_buf; -// boost::archive::binary_oarchive oa(string_buf); -// oa << d; -// std::string buf = string_buf.str(); -// return QByteArray(buf.c_str(), buf.size()); -//} -// -//void shelllet::properties::Print::fromData(const QByteArray& data) -//{ -// Q_D(Print); -// std::stringbuf string_buf(data.constData()); -// boost::archive::binary_iarchive oi(string_buf); -// -// oi >> d; -//} -// -//std::unique_ptr shelllet::properties::Print::getNode() -//{ -// Q_D(Print); -// auto doc = __super::getNode(); -// doc->document_element().append_attribute("message") = d->message_.toUtf8().constData(); -// return doc; -//} - -//void shelllet::properties::print::toXml(pugi::xml_node& node) -//{ -// UniqueNamedProperty::toXml(node); -// node.append_attribute("message") = message_.c_str(); -//} - -//void shelllet::properties::print::fromXml(const pugi::xml_node& node) -//{ -// UniqueNamedProperty::fromXml(node); -// message_ = node.attribute("message").value(); -//} - -QtProperty* shelllet::properties::Print::getInput(QtTreePropertyBrowser* browser) -{ - Q_D(Print); - QtLineEditFactory* lineEdit = new QtLineEditFactory(); - QtStringPropertyManager* strManager = new QtStringPropertyManager(); - - QtProperty* display = strManager->addProperty(tr("Message")); - - auto* input = CompositeProperty::getInput(browser); - input->addSubProperty(display); - - strManager->setValue(display, d->message_); - - connect(strManager, &QtStringPropertyManager::valueChanged, [d](QtProperty* property, const QString& val) { - d->message_ = val; - }); - - browser->setFactoryForManager(strManager, lineEdit); - return input; -} - -//#include "moc_print.cpp" \ No newline at end of file diff --git a/QtRpa/modules/properties/src/processstart.xxx b/QtRpa/modules/properties/src/processstart.xxx deleted file mode 100644 index f4cf427..0000000 --- a/QtRpa/modules/properties/src/processstart.xxx +++ /dev/null @@ -1,82 +0,0 @@ -#include "properties.hpp" -#include "properties/private/processstart_p.h" -#include "properties/processstart.h" - - -shelllet::properties::ProcessStart::ProcessStart(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new ProcessStartPrivate, node, parent) -{ - Q_D(ProcessStart); - d->m_fileName = node.attribute("filename").value(); -} - -void shelllet::properties::ProcessStart::setFileName(const String& fileName) -{ - Q_D(ProcessStart); - d->m_fileName = fileName; -} - -void shelllet::properties::ProcessStart::setParameters(const QStringList& parameters) -{ - Q_D(ProcessStart); - d->m_parameters = parameters; -} - -void shelllet::properties::ProcessStart::setWorkingDirectory(const QString& workingDirectory) -{ - Q_D(ProcessStart); - d->m_workingDirectory = workingDirectory; -} - -String shelllet::properties::ProcessStart::fileName() const -{ - Q_D(const ProcessStart); - return d->m_fileName; -} - -QStringList shelllet::properties::ProcessStart::parameters() const -{ - Q_D(const ProcessStart); - return d->m_parameters; -} - -QString shelllet::properties::ProcessStart::workingDirectory() const -{ - Q_D(const ProcessStart); - return d->m_workingDirectory; -} - -int shelllet::properties::ProcessStart::getPropertyMetaTypeID() const -{ - throw std::logic_error("The method or operation is not implemented."); -} - -void shelllet::properties::ProcessStart::getCode(std::ostringstream& oss) -{ - Q_D(ProcessStart); - - oss //<< "{" << std::endl - // << "from system import file_remove" - << std::endl - << "process_start.invoke" - << "(" << json() << ");" - << std::endl - //<< "}" - << std::endl; -} - - -//std::string shelllet::properties::ProcessStart::getImport() const -//{ -// return "from system import process_start"; -//} - -//std::unique_ptr shelllet::properties::ProcessStart::getNode() -//{ -// Q_D(ProcessStart); -// auto doc = __super::getNode(); -// doc->document_element().append_attribute("filename") = d->m_fileName.data(); -// -// LOG_DEBUG(PROJECT_NAME) << *doc; -// return doc; -//} diff --git a/QtRpa/modules/properties/src/sequence.cpp b/QtRpa/modules/properties/src/sequence.cpp deleted file mode 100644 index f910476..0000000 --- a/QtRpa/modules/properties/src/sequence.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "properties.hpp" -#include "properties/sequence.h" -#include "properties/private/sequence_p.h" - -shelllet::properties::Sequence::Sequence(const XmlNode& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new SequencePrivate, node, parent) -{ - Q_D(Sequence); - d->m_displayName = "Sequence"; - d->tagName = "sequence"; -} - - -void shelllet::properties::Sequence::getCode(std::ostringstream& oss) -{ - throw std::logic_error("The method or operation is not implemented."); -} - - -//std::string shelllet::properties::Sequence::getImport() const -//{ -// throw std::logic_error("The method or operation is not implemented."); -//} - -//std::unique_ptr shelllet::properties::Sequence::getNode() -//{ -// Q_D(Sequence); -// -// auto doc = __super::getNode(); -// return doc; -//} \ No newline at end of file diff --git a/QtRpa/modules/properties/src/workflow_assign.xxx b/QtRpa/modules/properties/src/workflow_assign.xxx deleted file mode 100644 index 5a5232d..0000000 --- a/QtRpa/modules/properties/src/workflow_assign.xxx +++ /dev/null @@ -1,39 +0,0 @@ -#include "properties.hpp" -#include "properties/workflow_assign.h" -#include "properties/private/workflow_assign_p.h" - - - -shelllet::properties::WorkflowAssign::WorkflowAssign(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new WorkflowAssignPrivate, node, parent) -{ -} - -QString shelllet::properties::WorkflowAssign::varName() const -{ - Q_D(const WorkflowAssign); - return d->m_name; -} - -void shelllet::properties::WorkflowAssign::setVarName(const QString& val) -{ - Q_D(WorkflowAssign); - d->m_name = val; -} - -QVariant shelllet::properties::WorkflowAssign::varValue() const -{ - Q_D(const WorkflowAssign); - return d->m_value; -} - -void shelllet::properties::WorkflowAssign::setVarValue(const QVariant& val) -{ - Q_D(WorkflowAssign); - d->m_value = val; -} - -int shelllet::properties::WorkflowAssign::getPropertyMetaTypeID() const -{ - throw std::logic_error("The method or operation is not implemented."); -} diff --git a/QtRpa/modules/properties/src/workflow_while.xx b/QtRpa/modules/properties/src/workflow_while.xx deleted file mode 100644 index 7017568..0000000 --- a/QtRpa/modules/properties/src/workflow_while.xx +++ /dev/null @@ -1,10 +0,0 @@ -#include "properties.hpp" -#include "properties/workflow_while.h" -#include "properties/private/workflow_while_p.h" - - - -shelllet::properties::WorkflowWhile::WorkflowWhile(const pugi::xml_node& node, QObject* parent /*= nullptr*/) - : CompositeProperty(*new WorkflowWhilePrivate, node, parent) -{ -} \ No newline at end of file diff --git a/QtRpa/modules/property/CMakeLists.txt b/QtRpa/modules/property/CMakeLists.txt deleted file mode 100644 index a8080e9..0000000 --- a/QtRpa/modules/property/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(property) - -set(CMAKE_AUTOMOC ON) -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - -add_library(${PROJECT_NAME} STATIC - ${SOURCES} - ${HEADERS} -) - -find_package(Boost REQUIRED COMPONENTS serialization) -find_package(Qt5Widgets CONFIG REQUIRED) - - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/include - #${CMAKE_CURRENT_SOURCE_DIR}/third-party/v8/include/ - ${Boost_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} -) - -#add_definitions(-DBOOST_ALL_DYN_LINK) - - -target_link_libraries(${PROJECT_NAME} PRIVATE DXGI D3D11 ws2_32.lib - ${Boost_LIBRARIES} - Qt::Widgets #Qt5::WidgetsPrivate #Qt5::QWindowsVistaStylePlugin -) - diff --git a/QtRpa/modules/property/src/abstracteditorfactorybase.cpp b/QtRpa/modules/property/src/abstracteditorfactorybase.cpp deleted file mode 100644 index 849f06f..0000000 --- a/QtRpa/modules/property/src/abstracteditorfactorybase.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "property/framework.h" -#include "property/abstracteditorfactorybase.h" -#include "private/qobject_p.h" -#include "property/private/abstracteditorfactorybaseprivate_p.h" -namespace shelllet { - namespace property { - - } -} -using namespace shelllet::property; - - -AbstractEditorFactoryBase::AbstractEditorFactoryBase(AbstractEditorFactoryBasePrivate& d, QObject* parent) - :QObject(d, parent) -{ - -} - diff --git a/QtRpa/modules/property/src/abstractpropertybrowser.cpp b/QtRpa/modules/property/src/abstractpropertybrowser.cpp deleted file mode 100644 index e293288..0000000 --- a/QtRpa/modules/property/src/abstractpropertybrowser.cpp +++ /dev/null @@ -1,751 +0,0 @@ -#include "property/framework.h" -#include "qwidget.h" -#include "qtreewidget.h" -#include "property/propertysheet.h" -#include "property/qtpropertybrowser.h" -#include "property/browseritem.h" -#include "property/abstracteditorfactorybase.h" -#include "property/abstracteditorfactory.h" -#include "property/abstractpropertymanager.h" -#include "property/abstractpropertybrowser.h" -#include "private/qwidget_p.h" -#include "property/private/browseritem_p.h" -#include "property/private/abstractpropertybrowser_p.h" - -namespace shelllet { - namespace property { - } -} -using namespace shelllet::property; - - -AbstractPropertyBrowser::AbstractPropertyBrowser(AbstractPropertyBrowserPrivate& d, QWidget* parent /*= nullptr*/) - : QWidget(d, parent, Qt::WindowFlags()) -{ - -} - - - - -//////////////////////////////////// - -typedef QMap > Map1; -typedef QMap > > Map2; -Q_GLOBAL_STATIC(Map1, m_viewToManagerToFactory) -Q_GLOBAL_STATIC(Map2, m_managerToFactoryToViews) - -AbstractPropertyBrowserPrivate::AbstractPropertyBrowserPrivate() : - m_currentItem(0) -{ -} - -void AbstractPropertyBrowserPrivate::insertSubTree(PropertySheet* property, - PropertySheet* parentProperty) -{ - Q_Q(AbstractPropertyBrowser); - if (m_propertyToParents.contains(property)) { - // property was already inserted, so its manager is connected - // and all its children are inserted and theirs managers are connected - // we just register new parent (parent has to be new). - m_propertyToParents[property].append(parentProperty); - // don't need to update m_managerToProperties map since - // m_managerToProperties[manager] already contains property. - return; - } - AbstractPropertyManager* manager = property->propertyManager(); - if (m_managerToProperties[manager].isEmpty()) { - // connect manager's signals - connect(manager, &AbstractPropertyManager::propertyInserted, this, &AbstractPropertyBrowserPrivate::slotPropertyInserted); - connect(manager, &AbstractPropertyManager::propertyRemoved, this, &AbstractPropertyBrowserPrivate::slotPropertyRemoved); - connect(manager, &AbstractPropertyManager::propertyDestroyed, this, &AbstractPropertyBrowserPrivate::slotPropertyDestroyed); - connect(manager, &AbstractPropertyManager::propertyChanged, this, &AbstractPropertyBrowserPrivate::slotPropertyDataChanged); - } - m_managerToProperties[manager].append(property); - m_propertyToParents[property].append(parentProperty); - - const QList subList = property->subProperties(); - for (PropertySheet* subProperty : subList) - insertSubTree(subProperty, property); -} - -void AbstractPropertyBrowserPrivate::removeSubTree(PropertySheet* property, - PropertySheet* parentProperty) -{ - Q_Q(AbstractPropertyBrowser); - if (!m_propertyToParents.contains(property)) { - // ASSERT - return; - } - - m_propertyToParents[property].removeAll(parentProperty); - if (!m_propertyToParents[property].isEmpty()) - return; - - m_propertyToParents.remove(property); - AbstractPropertyManager* manager = property->propertyManager(); - m_managerToProperties[manager].removeAll(property); - if (m_managerToProperties[manager].isEmpty()) { - // disconnect manager's signals - disconnect(manager, &AbstractPropertyManager::propertyInserted, this, &AbstractPropertyBrowserPrivate::slotPropertyInserted); - disconnect(manager, &AbstractPropertyManager::propertyRemoved, this, &AbstractPropertyBrowserPrivate::slotPropertyRemoved); - disconnect(manager, &AbstractPropertyManager::propertyDestroyed, this, &AbstractPropertyBrowserPrivate::slotPropertyDestroyed); - disconnect(manager, &AbstractPropertyManager::propertyChanged, this, &AbstractPropertyBrowserPrivate::slotPropertyDataChanged); - - m_managerToProperties.remove(manager); - } - - const QList subList = property->subProperties(); - for (PropertySheet* subProperty : subList) - removeSubTree(subProperty, property); -} - -void AbstractPropertyBrowserPrivate::createBrowserIndexes(PropertySheet* property, PropertySheet* parentProperty, PropertySheet* afterProperty) -{ - QMap parentToAfter; - if (afterProperty) { - QMap >::ConstIterator it = - m_propertyToIndexes.constFind(afterProperty); - if (it == m_propertyToIndexes.constEnd()) - return; - - for (BrowserItem* idx : it.value()) { - BrowserItem* parentIdx = idx->parent(); - if ((parentProperty && parentIdx && parentIdx->property() == parentProperty) || (!parentProperty && !parentIdx)) - parentToAfter[idx->parent()] = idx; - } - } - else if (parentProperty) { - QMap >::ConstIterator it = - m_propertyToIndexes.find(parentProperty); - if (it == m_propertyToIndexes.constEnd()) - return; - - for (BrowserItem* idx : it.value()) - parentToAfter[idx] = 0; - } - else { - parentToAfter[0] = 0; - } - - const QMap::ConstIterator pcend = parentToAfter.constEnd(); - for (QMap::ConstIterator it = parentToAfter.constBegin(); it != pcend; ++it) - createBrowserIndex(property, it.key(), it.value()); -} - -BrowserItem* AbstractPropertyBrowserPrivate::createBrowserIndex(PropertySheet* property, - BrowserItem* parentIndex, BrowserItem* afterIndex) -{ - Q_Q(AbstractPropertyBrowser); - BrowserItem* newIndex = new BrowserItem(q, property, parentIndex); - if (parentIndex) { - parentIndex->d_func()->addChild(newIndex, afterIndex); - } - else { - m_topLevelPropertyToIndex[property] = newIndex; - m_topLevelIndexes.insert(m_topLevelIndexes.indexOf(afterIndex) + 1, newIndex); - } - m_propertyToIndexes[property].append(newIndex); - - q->itemInserted(newIndex, afterIndex); - - const QList subItems = property->subProperties(); - BrowserItem* afterChild = 0; - for (PropertySheet* child : subItems) - afterChild = createBrowserIndex(child, newIndex, afterChild); - return newIndex; -} - -void AbstractPropertyBrowserPrivate::removeBrowserIndexes(PropertySheet* property, PropertySheet* parentProperty) -{ - QList toRemove; - QMap >::ConstIterator it = - m_propertyToIndexes.constFind(property); - if (it == m_propertyToIndexes.constEnd()) - return; - - for (BrowserItem* idx : it.value()) { - BrowserItem* parentIdx = idx->parent(); - if ((parentProperty && parentIdx && parentIdx->property() == parentProperty) || (!parentProperty && !parentIdx)) - toRemove.append(idx); - } - - for (BrowserItem* index : qAsConst(toRemove)) - removeBrowserIndex(index); -} - -void AbstractPropertyBrowserPrivate::removeBrowserIndex(BrowserItem* index) -{ - Q_Q(AbstractPropertyBrowser); - QList children = index->children(); - for (int i = children.count(); i > 0; i--) { - removeBrowserIndex(children.at(i - 1)); - } - - q->itemRemoved(index); - - if (index->parent()) { - index->parent()->d_func()->removeChild(index); - } - else { - m_topLevelPropertyToIndex.remove(index->property()); - m_topLevelIndexes.removeAll(index); - } - - PropertySheet* property = index->property(); - - m_propertyToIndexes[property].removeAll(index); - if (m_propertyToIndexes[property].isEmpty()) - m_propertyToIndexes.remove(property); - - delete index; -} - -void AbstractPropertyBrowserPrivate::clearIndex(BrowserItem* index) -{ - const QList children = index->children(); - for (BrowserItem* item : children) - clearIndex(item); - delete index; -} - -void AbstractPropertyBrowserPrivate::slotPropertyInserted(PropertySheet* property, - PropertySheet* parentProperty, PropertySheet* afterProperty) -{ - if (!m_propertyToParents.contains(parentProperty)) - return; - createBrowserIndexes(property, parentProperty, afterProperty); - insertSubTree(property, parentProperty); - //q_ptr->propertyInserted(property, parentProperty, afterProperty); -} - -void AbstractPropertyBrowserPrivate::slotPropertyRemoved(PropertySheet* property, - PropertySheet* parentProperty) -{ - if (!m_propertyToParents.contains(parentProperty)) - return; - removeSubTree(property, parentProperty); // this line should be probably moved down after propertyRemoved call - //q_ptr->propertyRemoved(property, parentProperty); - removeBrowserIndexes(property, parentProperty); -} - -void AbstractPropertyBrowserPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - Q_Q(AbstractPropertyBrowser); - if (!m_subItems.contains(property)) - return; - q->removeProperty(property); -} - -void AbstractPropertyBrowserPrivate::slotPropertyDataChanged(PropertySheet* property) -{ - Q_Q(AbstractPropertyBrowser); - if (!m_propertyToParents.contains(property)) - return; - - QMap >::ConstIterator it = - m_propertyToIndexes.find(property); - if (it == m_propertyToIndexes.constEnd()) - return; - - const QList indexes = it.value(); - for (BrowserItem* idx : indexes) - q->itemChanged(idx); - //q_ptr->propertyChanged(property); -} - -/*! - \class AbstractPropertyBrowser - \internal - \inmodule QtDesigner - \since 4.4 - - \brief AbstractPropertyBrowser provides a base class for - implementing property browsers. - - A property browser is a widget that enables the user to edit a - given set of properties. Each property is represented by a label - specifying the property's name, and an editing widget (e.g. a line - edit or a combobox) holding its value. A property can have zero or - more subproperties. - - \image qtpropertybrowser.png - - The top level properties can be retrieved using the - properties() function. To traverse each property's - subproperties, use the PropertySheet::subProperties() function. In - addition, the set of top level properties can be manipulated using - the addProperty(), insertProperty() and removeProperty() - functions. Note that the PropertySheet class provides a corresponding - set of functions making it possible to manipulate the set of - subproperties as well. - - To remove all the properties from the property browser widget, use - the clear() function. This function will clear the editor, but it - will not delete the properties since they can still be used in - other editors. - - The properties themselves are created and managed by - implementations of the QtAbstractPropertyManager class. A manager - can handle (i.e. create and manage) properties of a given type. In - the property browser the managers are associated with - implementations of the QtAbstractEditorFactory: A factory is a - class able to create an editing widget of a specified type. - - When using a property browser widget, managers must be created for - each of the required property types before the properties - themselves can be created. To ensure that the properties' values - will be displayed using suitable editing widgets, the managers - must be associated with objects of the preferred factory - implementations using the setFactoryForManager() function. The - property browser will use these associations to determine which - factory it should use to create the preferred editing widget. - - Note that a factory can be associated with many managers, but a - manager can only be associated with one single factory within the - context of a single property browser. The associations between - managers and factories can at any time be removed using the - unsetFactoryForManager() function. - - Whenever the property data changes or a property is inserted or - removed, the itemChanged(), itemInserted() or - itemRemoved() functions are called, respectively. These - functions must be reimplemented in derived classes in order to - update the property browser widget. Be aware that some property - instances can appear several times in an abstract tree - structure. For example: - - \table 100% - \row - \li - \snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp 2 - \li \image qtpropertybrowser-duplicate.png - \endtable - - The addProperty() function returns a BrowserItem that uniquely - identifies the created item. - - To make a property editable in the property browser, the - createEditor() function must be called to provide the - property with a suitable editing widget. - - Note that there are two ready-made property browser - implementations: - - \list - \li QtGroupBoxPropertyBrowser - \li QtTreePropertyBrowser - \endlist - - \sa QtAbstractPropertyManager, QtAbstractEditorFactoryBase -*/ - -/*! - \fn void AbstractPropertyBrowser::setFactoryForManager(PropertyManager *manager, - QtAbstractEditorFactory *factory) - - Connects the given \a manager to the given \a factory, ensuring - that properties of the \a manager's type will be displayed with an - editing widget suitable for their value. - - For example: - - \snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp 3 - - In this example the \c myInteger property's value is displayed - with a QSpinBox widget, while the \c myDouble property's value is - displayed with a QDoubleSpinBox widget. - - Note that a factory can be associated with many managers, but a - manager can only be associated with one single factory. If the - given \a manager already is associated with another factory, the - old association is broken before the new one established. - - This function ensures that the given \a manager and the given \a - factory are compatible, and it automatically calls the - QtAbstractEditorFactory::addPropertyManager() function if necessary. - - \sa unsetFactoryForManager() -*/ - -/*! - \fn virtual void AbstractPropertyBrowser::itemInserted(BrowserItem *insertedItem, - BrowserItem *precedingItem) = 0 - - This function is called to update the widget whenever a property - is inserted or added to the property browser, passing pointers to - the \a insertedItem of property and the specified - \a precedingItem as parameters. - - If \a precedingItem is 0, the \a insertedItem was put at - the beginning of its parent item's list of subproperties. If - the parent of \a insertedItem is 0, the \a insertedItem was added as a top - level property of \e this property browser. - - This function must be reimplemented in derived classes. Note that - if the \a insertedItem's property has subproperties, this - method will be called for those properties as soon as the current call is finished. - - \sa insertProperty(), addProperty() -*/ - -/*! - \fn virtual void AbstractPropertyBrowser::itemRemoved(BrowserItem *item) = 0 - - This function is called to update the widget whenever a property - is removed from the property browser, passing the pointer to the - \a item of the property as parameters. The passed \a item is - deleted just after this call is finished. - - If the the parent of \a item is 0, the removed \a item was a - top level property in this editor. - - This function must be reimplemented in derived classes. Note that - if the removed \a item's property has subproperties, this - method will be called for those properties just before the current call is started. - - \sa removeProperty() -*/ - -/*! - \fn virtual void AbstractPropertyBrowser::itemChanged(BrowserItem *item) = 0 - - This function is called whenever a property's data changes, - passing a pointer to the \a item of property as parameter. - - This function must be reimplemented in derived classes in order to - update the property browser widget whenever a property's name, - tool tip, status tip, "what's this" text, value text or value icon - changes. - - Note that if the property browser contains several occurrences of - the same property, this method will be called once for each - occurrence (with a different item each time). - - \sa PropertySheet, items() -*/ - -/*! - Creates an abstract property browser with the given \a parent. -*/ -AbstractPropertyBrowser::AbstractPropertyBrowser(QWidget* parent) - : AbstractPropertyBrowser(*new AbstractPropertyBrowserPrivate, parent) -{ -} - -/*! - Destroys the property browser, and destroys all the items that were - created by this property browser. - - Note that the properties that were displayed in the editor are not - deleted since they still can be used in other editors. Neither - does the destructor delete the property managers and editor - factories that were used by this property browser widget unless - this widget was their parent. - - \sa QtAbstractPropertyManager::~QtAbstractPropertyManager() -*/ -AbstractPropertyBrowser::~AbstractPropertyBrowser() -{ - Q_D(AbstractPropertyBrowser); - const QList indexes = topLevelItems(); - for (BrowserItem* item : indexes) - d->clearIndex(item); -} - -/*! - Returns the property browser's list of top level properties. - - To traverse the subproperties, use the PropertySheet::subProperties() - function. - - \sa addProperty(), insertProperty(), removeProperty() -*/ -QList AbstractPropertyBrowser::properties() const -{ - Q_D(const AbstractPropertyBrowser); - return d->m_subItems; -} - -/*! - Returns the property browser's list of all items associated - with the given \a property. - - There is one item per instance of the property in the browser. - - \sa topLevelItem() -*/ - -QList AbstractPropertyBrowser::items(PropertySheet* property) const -{ - Q_D(const AbstractPropertyBrowser); - return d->m_propertyToIndexes.value(property); -} - -/*! - Returns the top-level items associated with the given \a property. - - Returns 0 if \a property wasn't inserted into this property - browser or isn't a top-level one. - - \sa topLevelItems(), items() -*/ - -BrowserItem* AbstractPropertyBrowser::topLevelItem(PropertySheet* property) const -{ - Q_D(const AbstractPropertyBrowser); - return d->m_topLevelPropertyToIndex.value(property); -} - -/*! - Returns the list of top-level items. - - \sa topLevelItem() -*/ - -QList AbstractPropertyBrowser::topLevelItems() const -{ - Q_D(const AbstractPropertyBrowser); - return d->m_topLevelIndexes; -} - -/*! - Removes all the properties from the editor, but does not delete - them since they can still be used in other editors. - - \sa removeProperty(), QtAbstractPropertyManager::clear() -*/ -void AbstractPropertyBrowser::clear() -{ - const QList subList = properties(); - for (auto rit = subList.crbegin(), rend = subList.crend(); rit != rend; ++rit) - removeProperty(*rit); -} - -/*! - Appends the given \a property (and its subproperties) to the - property browser's list of top level properties. Returns the item - created by property browser which is associated with the \a property. - In order to get all children items created by the property - browser in this call, the returned item should be traversed. - - If the specified \a property is already added, this function does - nothing and returns 0. - - \sa insertProperty(), PropertySheet::addSubProperty(), properties() -*/ -BrowserItem* AbstractPropertyBrowser::addProperty(PropertySheet* property) -{ - Q_D(AbstractPropertyBrowser); - PropertySheet* afterProperty = 0; - if (d->m_subItems.count() > 0) - afterProperty = d->m_subItems.last(); - return insertProperty(property, afterProperty); -} - -/*! - \fn BrowserItem *AbstractPropertyBrowser::insertProperty(PropertySheet *property, - PropertySheet *afterProperty) - - Inserts the given \a property (and its subproperties) after - the specified \a afterProperty in the browser's list of top - level properties. Returns item created by property browser which - is associated with the \a property. In order to get all children items - created by the property browser in this call returned item should be traversed. - - If the specified \a afterProperty is 0, the given \a property is - inserted at the beginning of the list. If \a property is - already inserted, this function does nothing and returns 0. - - \sa addProperty(), PropertySheet::insertSubProperty(), properties() -*/ -BrowserItem* AbstractPropertyBrowser::insertProperty(PropertySheet* property, - PropertySheet* afterProperty) -{ - Q_D(AbstractPropertyBrowser); - if (!property) - return 0; - - // if item is already inserted in this item then cannot add. - QList pendingList = properties(); - int pos = 0; - int newPos = 0; - while (pos < pendingList.count()) { - PropertySheet* prop = pendingList.at(pos); - if (prop == property) - return 0; - if (prop == afterProperty) { - newPos = pos + 1; - } - pos++; - } - d->createBrowserIndexes(property, 0, afterProperty); - - // traverse inserted subtree and connect to manager's signals - d->insertSubTree(property, 0); - - d->m_subItems.insert(newPos, property); - //propertyInserted(property, 0, properAfterProperty); - return topLevelItem(property); -} - -/*! - Removes the specified \a property (and its subproperties) from the - property browser's list of top level properties. All items - that were associated with the given \a property and its children - are deleted. - - Note that the properties are \e not deleted since they can still - be used in other editors. - - \sa clear(), PropertySheet::removeSubProperty(), properties() -*/ -void AbstractPropertyBrowser::removeProperty(PropertySheet* property) -{ - Q_D(AbstractPropertyBrowser); - if (!property) - return; - - QList pendingList = properties(); - int pos = 0; - while (pos < pendingList.count()) { - if (pendingList.at(pos) == property) { - d->m_subItems.removeAt(pos); //perhaps this two lines - d->removeSubTree(property, 0); //should be moved down after propertyRemoved call. - //propertyRemoved(property, 0); - - d->removeBrowserIndexes(property, 0); - - // when item is deleted, item will call removeItem for top level items, - // and itemRemoved for nested items. - - return; - } - pos++; - } -} - -/*! - Creates an editing widget (with the given \a parent) for the given - \a property according to the previously established associations - between property managers and editor factories. - - If the property is created by a property manager which was not - associated with any of the existing factories in \e this property - editor, the function returns 0. - - To make a property editable in the property browser, the - createEditor() function must be called to provide the - property with a suitable editing widget. - - Reimplement this function to provide additional decoration for the - editing widgets created by the installed factories. - - \sa setFactoryForManager() -*/ -QWidget* AbstractPropertyBrowser::createEditor(PropertySheet* property, - QWidget* parent) -{ - AbstractEditorFactoryBase* factory = 0; - AbstractPropertyManager* manager = property->propertyManager(); - - if (m_viewToManagerToFactory()->contains(this) && - (*m_viewToManagerToFactory())[this].contains(manager)) { - factory = (*m_viewToManagerToFactory())[this][manager]; - } - - if (!factory) - return 0; - QWidget* w = factory->createEditor(property, parent); - // Since some editors can be QComboBoxes, and we changed their focus policy in Qt 5 - // to make them feel more native on Mac, we need to relax the focus policy to something - // more permissive to keep the combo box from losing focus, allowing it to stay alive, - // when the user clicks on it to show the popup. - if (w) - w->setFocusPolicy(Qt::WheelFocus); - return w; -} - -bool AbstractPropertyBrowser::addFactory(AbstractPropertyManager* abstractManager, - AbstractEditorFactoryBase* abstractFactory) -{ - bool connectNeeded = false; - if (!m_managerToFactoryToViews()->contains(abstractManager) || - !(*m_managerToFactoryToViews())[abstractManager].contains(abstractFactory)) { - connectNeeded = true; - } - else if ((*m_managerToFactoryToViews())[abstractManager][abstractFactory] - .contains(this)) { - return connectNeeded; - } - - if (m_viewToManagerToFactory()->contains(this) && - (*m_viewToManagerToFactory())[this].contains(abstractManager)) { - unsetFactoryForManager(abstractManager); - } - - (*m_managerToFactoryToViews())[abstractManager][abstractFactory].append(this); - (*m_viewToManagerToFactory())[this][abstractManager] = abstractFactory; - - return connectNeeded; -} - -/*! - Removes the association between the given \a manager and the - factory bound to it, automatically calling the - QtAbstractEditorFactory::removePropertyManager() function if necessary. - - \sa setFactoryForManager() -*/ -void AbstractPropertyBrowser::unsetFactoryForManager(AbstractPropertyManager* manager) -{ - if (!m_viewToManagerToFactory()->contains(this) || - !(*m_viewToManagerToFactory())[this].contains(manager)) { - return; - } - - AbstractEditorFactoryBase* abstractFactory = - (*m_viewToManagerToFactory())[this][manager]; - (*m_viewToManagerToFactory())[this].remove(manager); - if ((*m_viewToManagerToFactory())[this].isEmpty()) { - (*m_viewToManagerToFactory()).remove(this); - } - - (*m_managerToFactoryToViews())[manager][abstractFactory].removeAll(this); - if ((*m_managerToFactoryToViews())[manager][abstractFactory].isEmpty()) { - (*m_managerToFactoryToViews())[manager].remove(abstractFactory); - abstractFactory->breakConnection(manager); - if ((*m_managerToFactoryToViews())[manager].isEmpty()) { - (*m_managerToFactoryToViews()).remove(manager); - } - } -} - -/*! - Returns the current item in the property browser. - - \sa setCurrentItem() -*/ -BrowserItem* AbstractPropertyBrowser::currentItem() const -{ - Q_D(const AbstractPropertyBrowser); - return d->m_currentItem; -} - -/*! - Sets the current item in the property browser to \a item. - - \sa currentItem(), currentItemChanged() -*/ -void AbstractPropertyBrowser::setCurrentItem(BrowserItem* item) -{ - Q_D(AbstractPropertyBrowser); - BrowserItem* oldItem = d->m_currentItem; - d->m_currentItem = item; - if (oldItem != item) - emit currentItemChanged(item); -} - - diff --git a/QtRpa/modules/property/src/abstractpropertymanager.cpp b/QtRpa/modules/property/src/abstractpropertymanager.cpp deleted file mode 100644 index 99f9bca..0000000 --- a/QtRpa/modules/property/src/abstractpropertymanager.cpp +++ /dev/null @@ -1,589 +0,0 @@ -#include "property/framework.h" -#include "property/browseritem.h" -#include "property/propertysheet.h" -#include "property/abstractpropertymanager.h" -#include "private/qobject_p.h" -#include "property/private/abstractpropertymanager_p.h" -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -AbstractPropertyManager::AbstractPropertyManager(QObject* parent /*= nullptr*/) - :AbstractPropertyManager(*new AbstractPropertyManagerPrivate, parent) -{ - -} -AbstractPropertyManager::AbstractPropertyManager(AbstractPropertyManagerPrivate& d, QObject* parent /*= nullptr*/) - : QObject(d, parent) -{ - -} - -//////////////////////////////// - -void AbstractPropertyManagerPrivate::propertyDestroyed(PropertySheet* property) -{ - Q_Q(AbstractPropertyManager); - if (m_properties.contains(property)) { - emit q->propertyDestroyed(property); - q->uninitializeProperty(property); - m_properties.remove(property); - } -} - -void AbstractPropertyManagerPrivate::propertyChanged(PropertySheet* property) -{ - Q_Q(AbstractPropertyManager); - emit q->propertyChanged(property); -} - -void AbstractPropertyManagerPrivate::propertyRemoved(PropertySheet* property, - PropertySheet* parentProperty) -{ - Q_Q(AbstractPropertyManager); - emit q->propertyRemoved(property, parentProperty); -} - -void AbstractPropertyManagerPrivate::propertyInserted(PropertySheet* property, - PropertySheet* parentProperty, PropertySheet* afterProperty) -{ - Q_Q(AbstractPropertyManager); - emit q->propertyInserted(property, parentProperty, afterProperty); -} - -/*! - \class AbstractPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The AbstractPropertyManager provides an interface for - property managers. - - A manager can create and manage properties of a given type, and is - used in conjunction with the AbstractPropertyBrowser class. - - When using a property browser widget, the properties are created - and managed by implementations of the AbstractPropertyManager - class. To ensure that the properties' values will be displayed - using suitable editing widgets, the managers are associated with - objects of QtAbstractEditorFactory subclasses. The property browser - will use these associations to determine which factories it should - use to create the preferred editing widgets. - - The AbstractPropertyManager class provides common functionality - like creating a property using the addProperty() function, and - retrieving the properties created by the manager using the - properties() function. The class also provides signals that are - emitted when the manager's properties change: propertyInserted(), - propertyRemoved(), propertyChanged() and propertyDestroyed(). - - AbstractPropertyManager subclasses are supposed to provide their - own type specific API. Note that several ready-made - implementations are available: - - \list - \li QtBoolPropertyManager - \li QtColorPropertyManager - \li QtDatePropertyManager - \li QtDateTimePropertyManager - \li QtDoublePropertyManager - \li QtEnumPropertyManager - \li QtFlagPropertyManager - \li QtFontPropertyManager - \li QtGroupPropertyManager - \li QtIntPropertyManager - \li QtPointPropertyManager - \li QtRectPropertyManager - \li QtSizePropertyManager - \li QtSizePolicyPropertyManager - \li QtStringPropertyManager - \li QtTimePropertyManager - \li QtVariantPropertyManager - \endlist - - \sa QtAbstractEditorFactoryBase, AbstractPropertyBrowser, PropertySheet -*/ - -/*! - \fn void AbstractPropertyManager::propertyInserted(PropertySheet *newProperty, - PropertySheet *parentProperty, PropertySheet *precedingProperty) - - This signal is emitted when a new subproperty is inserted into an - existing property, passing pointers to the \a newProperty, \a - parentProperty and \a precedingProperty as parameters. - - If \a precedingProperty is 0, the \a newProperty was inserted at - the beginning of the \a parentProperty's subproperties list. - - Note that signal is emitted only if the \a parentProperty is created - by this manager. - - \sa AbstractPropertyBrowser::itemInserted() -*/ - -/*! - \fn void AbstractPropertyManager::propertyChanged(PropertySheet *property) - - This signal is emitted whenever a property's data changes, passing - a pointer to the \a property as parameter. - - Note that signal is only emitted for properties that are created by - this manager. - - \sa AbstractPropertyBrowser::itemChanged() -*/ - -/*! - \fn void AbstractPropertyManager::propertyRemoved(PropertySheet *property, PropertySheet *parent) - - This signal is emitted when a subproperty is removed, passing - pointers to the removed \a property and the \a parent property as - parameters. - - Note that signal is emitted only when the \a parent property is - created by this manager. - - \sa AbstractPropertyBrowser::itemRemoved() -*/ - -/*! - \fn void AbstractPropertyManager::propertyDestroyed(PropertySheet *property) - - This signal is emitted when the specified \a property is about to - be destroyed. - - Note that signal is only emitted for properties that are created - by this manager. - - \sa clear(), uninitializeProperty() -*/ - -/*! - \fn void AbstractPropertyBrowser::currentItemChanged(QtBrowserItem *current) - - This signal is emitted when the current item changes. The current item is specified by \a current. - - \sa AbstractPropertyBrowser::setCurrentItem() -*/ - -/*! - Creates an abstract property manager with the given \a parent. -*/ - -/*! - Destroys the manager. All properties created by the manager are - destroyed. -*/ -AbstractPropertyManager::~AbstractPropertyManager() -{ - clear(); -} - -/*! - Destroys all the properties that this manager has created. - - \sa propertyDestroyed(), uninitializeProperty() -*/ -void AbstractPropertyManager::clear() const -{ - Q_D(const AbstractPropertyManager); - while (!d->m_properties.isEmpty()) - delete* d->m_properties.cbegin(); -} - -/*! - Returns the set of properties created by this manager. - - \sa addProperty() -*/ -QSet AbstractPropertyManager::properties() const -{ - Q_D(const AbstractPropertyManager); - return d->m_properties; -} - -/*! - Returns whether the given \a property has a value. - - The default implementation of this function returns true. - - \sa PropertySheet::hasValue() -*/ -bool AbstractPropertyManager::hasValue(const PropertySheet* property) const -{ - Q_UNUSED(property); - return true; -} - -/*! - Returns an icon representing the current state of the given \a - property. - - The default implementation of this function returns an invalid - icon. - - \sa PropertySheet::valueIcon() -*/ -QIcon AbstractPropertyManager::valueIcon(const PropertySheet* property) const -{ - Q_UNUSED(property); - return QIcon(); -} - -/*! - Returns a string representing the current state of the given \a - property. - - The default implementation of this function returns an empty - string. - - \sa PropertySheet::valueText() -*/ -String AbstractPropertyManager::valueText(const PropertySheet* property) const -{ - Q_UNUSED(property); - return String(); -} - -/*! - Creates a property with the given \a name which then is owned by this manager. - - Internally, this function calls the createProperty() and - initializeProperty() functions. - - \sa initializeProperty(), properties() -*/ -PropertySheet* AbstractPropertyManager::addProperty(const String& name) -{ - Q_D(AbstractPropertyManager); - PropertySheet* property = createProperty(); - if (property) { - property->setPropertyName(*name.toQString()); - d->m_properties.insert(property); - initializeProperty(property); - } - return property; -} - -/*! - Creates a property. - - The base implementation produce PropertySheet instances; Reimplement - this function to make this manager produce objects of a PropertySheet - subclass. - - \sa addProperty(), initializeProperty() -*/ -PropertySheet* AbstractPropertyManager::createProperty() -{ - return new PropertySheet(this); -} - -/*! - \fn void AbstractPropertyManager::initializeProperty(PropertySheet *property) = 0 - - This function is called whenever a new valid property pointer has - been created, passing the pointer as parameter. - - The purpose is to let the manager know that the \a property has - been created so that it can provide additional attributes for the - new property, e.g. QtIntPropertyManager adds \l - {QtIntPropertyManager::value()}{value}, \l - {QtIntPropertyManager::minimum()}{minimum} and \l - {QtIntPropertyManager::maximum()}{maximum} attributes. Since each manager - subclass adds type specific attributes, this function is pure - virtual and must be reimplemented when deriving from the - AbstractPropertyManager class. - - \sa addProperty(), createProperty() -*/ - -/*! - This function is called just before the specified \a property is destroyed. - - The purpose is to let the property manager know that the \a - property is being destroyed so that it can remove the property's - additional attributes. - - \sa clear(), propertyDestroyed() -*/ -void AbstractPropertyManager::uninitializeProperty(PropertySheet* property) -{ - Q_UNUSED(property); -} - -//////////////////////////////////// - -/*! - \class QtAbstractEditorFactoryBase - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtAbstractEditorFactoryBase provides an interface for - editor factories. - - An editor factory is a class that is able to create an editing - widget of a specified type (e.g. line edits or comboboxes) for a - given PropertySheet object, and it is used in conjunction with the - AbstractPropertyManager and AbstractPropertyBrowser classes. - - When using a property browser widget, the properties are created - and managed by implementations of the AbstractPropertyManager - class. To ensure that the properties' values will be displayed - using suitable editing widgets, the managers are associated with - objects of QtAbstractEditorFactory subclasses. The property browser - will use these associations to determine which factories it should - use to create the preferred editing widgets. - - Typically, an editor factory is created by subclassing the - QtAbstractEditorFactory template class which inherits - QtAbstractEditorFactoryBase. But note that several ready-made - implementations are available: - - \list - \li QtCheckBoxFactory - \li QtDateEditFactory - \li QtDateTimeEditFactory - \li QtDoubleSpinBoxFactory - \li QtEnumEditorFactory - \li QtLineEditFactory - \li QtScrollBarFactory - \li QtSliderFactory - \li QtSpinBoxFactory - \li QtTimeEditFactory - \li QtVariantEditorFactory - \endlist - - \sa AbstractPropertyManager, AbstractPropertyBrowser -*/ - -/*! - \fn virtual QWidget *QtAbstractEditorFactoryBase::createEditor(PropertySheet *property, - QWidget *parent) = 0 - - Creates an editing widget (with the given \a parent) for the given - \a property. - - This function is reimplemented in QtAbstractEditorFactory template class - which also provides a pure virtual convenience overload of this - function enabling access to the property's manager. - - \sa QtAbstractEditorFactory::createEditor() -*/ - -/*! - \fn QtAbstractEditorFactoryBase::QtAbstractEditorFactoryBase(QObject *parent = 0) - - Creates an abstract editor factory with the given \a parent. -*/ - -/*! - \fn virtual void QtAbstractEditorFactoryBase::breakConnection(AbstractPropertyManager *manager) = 0 - - \internal - - Detaches property manager from factory. - This method is reimplemented in QtAbstractEditorFactory template subclass. - You don't need to reimplement it in your subclasses. Instead implement more convenient - QtAbstractEditorFactory::disconnectPropertyManager() which gives you access to particular manager subclass. -*/ - -/*! - \fn virtual void QtAbstractEditorFactoryBase::managerDestroyed(QObject *manager) = 0 - - \internal - - This method is called when property manager is being destroyed. - Basically it notifies factory not to produce editors for properties owned by \a manager. - You don't need to reimplement it in your subclass. This method is implemented in - QtAbstractEditorFactory template subclass. -*/ - -/*! - \class QtAbstractEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtAbstractEditorFactory is the base template class for editor - factories. - - An editor factory is a class that is able to create an editing - widget of a specified type (e.g. line edits or comboboxes) for a - given PropertySheet object, and it is used in conjunction with the - AbstractPropertyManager and AbstractPropertyBrowser classes. - - Note that the QtAbstractEditorFactory functions are using the - PropertyManager template argument class which can be any - AbstractPropertyManager subclass. For example: - - \snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp 0 - - Note that QtSpinBoxFactory by definition creates editing widgets - \e only for properties created by QtIntPropertyManager. - - When using a property browser widget, the properties are created - and managed by implementations of the AbstractPropertyManager - class. To ensure that the properties' values will be displayed - using suitable editing widgets, the managers are associated with - objects of QtAbstractEditorFactory subclasses. The property browser will - use these associations to determine which factories it should use - to create the preferred editing widgets. - - A QtAbstractEditorFactory object is capable of producing editors for - several property managers at the same time. To create an - association between this factory and a given manager, use the - addPropertyManager() function. Use the removePropertyManager() function to make - this factory stop producing editors for a given property - manager. Use the propertyManagers() function to retrieve the set of - managers currently associated with this factory. - - Several ready-made implementations of the QtAbstractEditorFactory class - are available: - - \list - \li QtCheckBoxFactory - \li QtDateEditFactory - \li QtDateTimeEditFactory - \li QtDoubleSpinBoxFactory - \li QtEnumEditorFactory - \li QtLineEditFactory - \li QtScrollBarFactory - \li QtSliderFactory - \li QtSpinBoxFactory - \li QtTimeEditFactory - \li QtVariantEditorFactory - \endlist - - When deriving from the QtAbstractEditorFactory class, several pure virtual - functions must be implemented: the connectPropertyManager() function is - used by the factory to connect to the given manager's signals, the - createEditor() function is supposed to create an editor for the - given property controlled by the given manager, and finally the - disconnectPropertyManager() function is used by the factory to disconnect - from the specified manager's signals. - - \sa QtAbstractEditorFactoryBase, AbstractPropertyManager -*/ - -/*! - \fn QtAbstractEditorFactory::QtAbstractEditorFactory(QObject *parent = 0) - - Creates an editor factory with the given \a parent. - - \sa addPropertyManager() -*/ - -/*! - \fn QWidget *QtAbstractEditorFactory::createEditor(PropertySheet *property, QWidget *parent) - - Creates an editing widget (with the given \a parent) for the given - \a property. -*/ - -/*! - \fn void QtAbstractEditorFactory::addPropertyManager(PropertyManager *manager) - - Adds the given \a manager to this factory's set of managers, - making this factory produce editing widgets for properties created - by the given manager. - - The PropertyManager type is a template argument class, and represents the chosen - AbstractPropertyManager subclass. - - \sa propertyManagers(), removePropertyManager() -*/ - -/*! - \fn void QtAbstractEditorFactory::removePropertyManager(PropertyManager *manager) - - Removes the given \a manager from this factory's set of - managers. The PropertyManager type is a template argument class, and may be - any AbstractPropertyManager subclass. - - \sa propertyManagers(), addPropertyManager() -*/ - -/*! - \fn virtual void QtAbstractEditorFactory::connectPropertyManager(PropertyManager *manager) = 0 - - Connects this factory to the given \a manager's signals. The - PropertyManager type is a template argument class, and represents - the chosen AbstractPropertyManager subclass. - - This function is used internally by the addPropertyManager() function, and - makes it possible to update an editing widget when the associated - property's data changes. This is typically done in custom slots - responding to the signals emitted by the property's manager, - e.g. QtIntPropertyManager::valueChanged() and - QtIntPropertyManager::rangeChanged(). - - \sa propertyManagers(), disconnectPropertyManager() -*/ - -/*! - \fn virtual QWidget *QtAbstractEditorFactory::createEditor(PropertyManager *manager, PropertySheet *property, - QWidget *parent) = 0 - - Creates an editing widget with the given \a parent for the - specified \a property created by the given \a manager. The - PropertyManager type is a template argument class, and represents - the chosen AbstractPropertyManager subclass. - - This function must be implemented in derived classes: It is - recommended to store a pointer to the widget and map it to the - given \a property, since the widget must be updated whenever the - associated property's data changes. This is typically done in - custom slots responding to the signals emitted by the property's - manager, e.g. QtIntPropertyManager::valueChanged() and - QtIntPropertyManager::rangeChanged(). - - \sa connectPropertyManager() -*/ - -/*! - \fn virtual void QtAbstractEditorFactory::disconnectPropertyManager(PropertyManager *manager) = 0 - - Disconnects this factory from the given \a manager's signals. The - PropertyManager type is a template argument class, and represents - the chosen AbstractPropertyManager subclass. - - This function is used internally by the removePropertyManager() function. - - \sa propertyManagers(), connectPropertyManager() -*/ - -/*! - \fn QSet QtAbstractEditorFactory::propertyManagers() const - - Returns the factory's set of associated managers. The - PropertyManager type is a template argument class, and represents - the chosen AbstractPropertyManager subclass. - - \sa addPropertyManager(), removePropertyManager() -*/ - -/*! - \fn PropertyManager *QtAbstractEditorFactory::propertyManager(PropertySheet *property) const - - Returns the property manager for the given \a property, or 0 if - the given \a property doesn't belong to any of this factory's - registered managers. - - The PropertyManager type is a template argument class, and represents the chosen - AbstractPropertyManager subclass. - - \sa propertyManagers() -*/ - -/*! - \fn virtual void QtAbstractEditorFactory::managerDestroyed(QObject *manager) - - \internal -*/ - -//////////////////////////////////// \ No newline at end of file diff --git a/QtRpa/modules/property/src/booledit.cpp b/QtRpa/modules/property/src/booledit.cpp deleted file mode 100644 index 11d9efb..0000000 --- a/QtRpa/modules/property/src/booledit.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include "property/framework.h" -#include "qcheckbox.h" -#include "qlayout.h" -#include "property/booledit.h" -#include "private/qwidget_p.h" -#include "property/private/booledit_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -BoolEdit::BoolEdit(Object* parent /*= nullptr*/) - :BoolEdit(*new BoolEditPrivate, nullptr) -{ - -} -BoolEdit::BoolEdit(BoolEditPrivate& d, QWidget* parent /*= nullptr*/) - : QWidget(d, parent, Qt::WindowFlags()) - , m_checkBox(new QCheckBox(this)), - m_textVisible(true) -{ - QHBoxLayout* lt = new QHBoxLayout; - if (QApplication::layoutDirection() == Qt::LeftToRight) - lt->setContentsMargins(4, 0, 0, 0); - else - lt->setContentsMargins(0, 0, 4, 0); - lt->addWidget(m_checkBox); - setLayout(lt); - connect(m_checkBox, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool))); - setFocusProxy(m_checkBox); - m_checkBox->setText(tr("True")); -} - - - -void BoolEdit::setTextVisible(bool textVisible) -{ - if (m_textVisible == textVisible) - return; - - m_textVisible = textVisible; - if (m_textVisible) - m_checkBox->setText(isChecked() ? tr("True") : tr("False")); - else - m_checkBox->setText(QString()); -} - -Qt::CheckState BoolEdit::checkState() const -{ - return m_checkBox->checkState(); -} - -void BoolEdit::setCheckState(Qt::CheckState state) -{ - m_checkBox->setCheckState(state); -} - -bool BoolEdit::isChecked() const -{ - return m_checkBox->isChecked(); -} - -void BoolEdit::setChecked(bool c) -{ - m_checkBox->setChecked(c); - if (!m_textVisible) - return; - m_checkBox->setText(isChecked() ? tr("True") : tr("False")); -} - -bool BoolEdit::blockCheckBoxSignals(bool block) -{ - return m_checkBox->blockSignals(block); -} - -void BoolEdit::mousePressEvent(QMouseEvent* event) -{ - if (event->buttons() == Qt::LeftButton) { - m_checkBox->click(); - event->accept(); - } - else { - QWidget::mousePressEvent(event); - } -} \ No newline at end of file diff --git a/QtRpa/modules/property/src/boolpropertymanager.cpp1 b/QtRpa/modules/property/src/boolpropertymanager.cpp1 deleted file mode 100644 index 825ae29..0000000 --- a/QtRpa/modules/property/src/boolpropertymanager.cpp1 +++ /dev/null @@ -1,143 +0,0 @@ -#include "property/framework.h" -#include "property/abstractpropertymanager.h" -#include "property/boolpropertymanager.h" -#include "private/qobject_p.h" -#include "property/private/abstractpropertymanager_p.h" -#include "property/private/boolpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -BoolPropertyManager::BoolPropertyManager(Object* parent /*= nullptr*/) - :BoolPropertyManager(*new BoolPropertyManagerPrivate, parent) -{ - -} -BoolPropertyManager::BoolPropertyManager(BoolPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} - - -QtBoolPropertyManagerPrivate::QtBoolPropertyManagerPrivate() : - m_checkedIcon(drawCheckBox(true)), - m_uncheckedIcon(drawCheckBox(false)) -{ -} - -/*! - \class QtBoolPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtBoolPropertyManager class provides and manages boolean properties. - - The property's value can be retrieved using the value() function, - and set using the setValue() slot. - - In addition, QtBoolPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes. - - \sa AbstractPropertyManager, QtCheckBoxFactory -*/ - -/*! - \fn void QtBoolPropertyManager::valueChanged(PropertySheet *property, bool value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtBoolPropertyManager::QtBoolPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtBoolPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtBoolPropertyManager::~QtBoolPropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by \e this manager, this - function returns false. - - \sa setValue() -*/ -bool QtBoolPropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, false); -} - -/*! - \reimp -*/ -QString QtBoolPropertyManager::valueText(const PropertySheet* property) const -{ - const QMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - static const QString trueText = tr("True"); - static const QString falseText = tr("False"); - return it.value() ? trueText : falseText; -} - -/*! - \reimp -*/ -QIcon QtBoolPropertyManager::valueIcon(const PropertySheet* property) const -{ - const QMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); - - return it.value() ? d_ptr->m_checkedIcon : d_ptr->m_uncheckedIcon; -} - -/*! - \fn void QtBoolPropertyManager::setValue(PropertySheet *property, bool value) - - Sets the value of the given \a property to \a value. - - \sa value() -*/ -void QtBoolPropertyManager::setValue(PropertySheet* property, bool val) -{ - setSimpleValue(d_ptr->m_values, this, - &QtBoolPropertyManager::propertyChanged, - &QtBoolPropertyManager::valueChanged, - property, val); -} - -/*! - \reimp -*/ -void QtBoolPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = false; -} - -/*! - \reimp -*/ -void QtBoolPropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} diff --git a/QtRpa/modules/property/src/browseritem.cpp b/QtRpa/modules/property/src/browseritem.cpp deleted file mode 100644 index eba188f..0000000 --- a/QtRpa/modules/property/src/browseritem.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "property/framework.h" -#include "qwidget.h" -#include "property/propertysheet.h" -#include "property/qtpropertybrowser.h" -#include "property/abstractpropertybrowser.h" -#include "property/browseritem.h" -#include "property/private/browseritem_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; - -BrowserItem::BrowserItem(BrowserItemPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - - -void BrowserItemPrivate::addChild(BrowserItem* index, BrowserItem* after) -{ - if (m_children.contains(index)) - return; - int idx = m_children.indexOf(after) + 1; // we insert after returned idx, if it was -1 then we set idx to 0; - m_children.insert(idx, index); -} - -void BrowserItemPrivate::removeChild(BrowserItem* index) -{ - m_children.removeAll(index); -} - -/*! - \class BrowserItem - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The BrowserItem class represents a property in - a property browser instance. - - Browser items are created whenever a PropertySheet is inserted to the - property browser. A BrowserItem uniquely identifies a - browser's item. Thus, if the same PropertySheet is inserted multiple - times, each occurrence gets its own unique BrowserItem. The - items are owned by AbstractPropertyBrowser and automatically - deleted when they are removed from the browser. - - You can traverse a browser's properties by calling parent() and - children(). The property and the browser associated with an item - are available as property() and browser(). - - \sa AbstractPropertyBrowser, PropertySheet -*/ - -/*! - Returns the property which is accosiated with this item. Note that - several items can be associated with the same property instance in - the same property browser. - - \sa AbstractPropertyBrowser::items() -*/ - -PropertySheet* BrowserItem::property() const -{ - Q_D(const BrowserItem); - return d->m_property; -} - -/*! - Returns the parent item of \e this item. Returns 0 if \e this item - is associated with top-level property in item's property browser. - - \sa children() -*/ - -BrowserItem* BrowserItem::parent() const -{ - Q_D(const BrowserItem); - return d->m_parent; -} - -/*! - Returns the children items of \e this item. The properties - reproduced from children items are always the same as - reproduced from associated property' children, for example: - - \snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtpropertybrowser.cpp 1 - - The \e childrenItems list represents the same list as \e childrenProperties. -*/ - -QList BrowserItem::children() const -{ - Q_D(const BrowserItem); - return d->m_children; -} - -/*! - Returns the property browser which owns \e this item. -*/ - -AbstractPropertyBrowser* BrowserItem::browser() const -{ - Q_D(const BrowserItem); - return d->m_browser; -} - -BrowserItem::BrowserItem(AbstractPropertyBrowser* browser, PropertySheet* property, BrowserItem* parent) - : BrowserItem(*new BrowserItemPrivate(browser, property, parent)) -{ - d_ptr->q_ptr = this; -} - -BrowserItem::~BrowserItem() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/property/src/buttonpropertybrowser.cpp b/QtRpa/modules/property/src/buttonpropertybrowser.cpp deleted file mode 100644 index b59c829..0000000 --- a/QtRpa/modules/property/src/buttonpropertybrowser.cpp +++ /dev/null @@ -1,566 +0,0 @@ -#include "property/framework.h" -#include "qwidget.h" -#include "qtoolbutton.h" -#include "qlabel.h" -#include "qgridlayout.h" -#include "qtimer.h" -#include "property/propertysheet.h" -#include "property/browseritem.h" -#include "property/abstracteditorfactorybase.h" -#include "property/abstracteditorfactory.h" -#include "property/abstractpropertybrowser.h" -#include "property/buttonpropertybrowser.h" -#include "private/qwidget_p.h" -#include "property/private/abstractpropertybrowser_p.h" -#include "property/private/buttonpropertybrowser_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -ButtonPropertyBrowser::ButtonPropertyBrowser(Object* parent /*= nullptr*/) - :ButtonPropertyBrowser(*new ButtonPropertyBrowserPrivate, nullptr, parent) -{ - -} -ButtonPropertyBrowser::ButtonPropertyBrowser(ButtonPropertyBrowserPrivate& d, QWidget* parent1, Object* parent /*= nullptr*/) - : AbstractPropertyBrowser(d, parent1) -{ - d.init(this); - -} - - - -QToolButton* ButtonPropertyBrowserPrivate::createButton(QWidget* parent) const -{ - QToolButton* button = new QToolButton(parent); - button->setCheckable(true); - button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); - button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - button->setArrowType(Qt::DownArrow); - button->setIconSize(QSize(3, 16)); - /* - QIcon icon; - icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowDown), QIcon::Normal, QIcon::Off); - icon.addPixmap(q_ptr->style()->standardPixmap(QStyle::SP_ArrowUp), QIcon::Normal, QIcon::On); - button->setIcon(icon); - */ - return button; -} - -int ButtonPropertyBrowserPrivate::gridRow(WidgetItem* item) const -{ - QList siblings; - if (item->parent) - siblings = item->parent->children; - else - siblings = m_children; - - int row = 0; - for (WidgetItem* sibling : qAsConst(siblings)) { - if (sibling == item) - return row; - row += gridSpan(sibling); - } - return -1; -} - -int ButtonPropertyBrowserPrivate::gridSpan(WidgetItem* item) const -{ - if (item->container && item->expanded) - return 2; - return 1; -} - -void ButtonPropertyBrowserPrivate::init(QWidget* parent) -{ - m_mainLayout = new QGridLayout(); - parent->setLayout(m_mainLayout); - QLayoutItem* item = new QSpacerItem(0, 0, - QSizePolicy::Fixed, QSizePolicy::Expanding); - m_mainLayout->addItem(item, 0, 0); -} - -void ButtonPropertyBrowserPrivate::slotEditorDestroyed() -{ - Q_Q(ButtonPropertyBrowser); - QWidget* editor = qobject_cast(q->sender()); - if (!editor) - return; - if (!m_widgetToItem.contains(editor)) - return; - m_widgetToItem[editor]->widget = 0; - m_widgetToItem.remove(editor); -} - -void ButtonPropertyBrowserPrivate::slotUpdate() -{ - Q_Q(ButtonPropertyBrowser); - for (WidgetItem* item : qAsConst(m_recreateQueue)) { - WidgetItem* parent = item->parent; - QWidget* w = 0; - QGridLayout* l = 0; - const int oldRow = gridRow(item); - if (parent) { - w = parent->container; - l = parent->layout; - } - else { - w = q; - l = m_mainLayout; - } - - int span = 1; - if (!item->widget && !item->widgetLabel) - span = 2; - item->label = new QLabel(w); - item->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - l->addWidget(item->label, oldRow, 0, 1, span); - - updateItem(item); - } - m_recreateQueue.clear(); -} - -void ButtonPropertyBrowserPrivate::setExpanded(WidgetItem* item, bool expanded) -{ - if (item->expanded == expanded) - return; - - if (!item->container) - return; - - item->expanded = expanded; - const int row = gridRow(item); - WidgetItem* parent = item->parent; - QGridLayout* l = 0; - if (parent) - l = parent->layout; - else - l = m_mainLayout; - - if (expanded) { - insertRow(l, row + 1); - l->addWidget(item->container, row + 1, 0, 1, 2); - item->container->show(); - } - else { - l->removeWidget(item->container); - item->container->hide(); - removeRow(l, row + 1); - } - - item->button->setChecked(expanded); - item->button->setArrowType(expanded ? Qt::UpArrow : Qt::DownArrow); -} - -void ButtonPropertyBrowserPrivate::slotToggled(bool checked) -{ - Q_Q(ButtonPropertyBrowser); - WidgetItem* item = m_buttonToItem.value(q->sender()); - if (!item) - return; - - setExpanded(item, checked); - - if (checked) - emit q->expanded(m_itemToIndex.value(item)); - else - emit q->collapsed(m_itemToIndex.value(item)); -} - -void ButtonPropertyBrowserPrivate::updateLater() -{ - Q_Q(ButtonPropertyBrowser); - QTimer::singleShot(0, q, SLOT(slotUpdate())); -} - -void ButtonPropertyBrowserPrivate::propertyInserted(BrowserItem* index, BrowserItem* afterIndex) -{ - Q_Q(ButtonPropertyBrowser); - WidgetItem* afterItem = m_indexToItem.value(afterIndex); - WidgetItem* parentItem = m_indexToItem.value(index->parent()); - - WidgetItem* newItem = new WidgetItem(); - newItem->parent = parentItem; - - QGridLayout* layout = 0; - QWidget* parentWidget = 0; - int row = -1; - if (!afterItem) { - row = 0; - if (parentItem) - parentItem->children.insert(0, newItem); - else - m_children.insert(0, newItem); - } - else { - row = gridRow(afterItem) + gridSpan(afterItem); - if (parentItem) - parentItem->children.insert(parentItem->children.indexOf(afterItem) + 1, newItem); - else - m_children.insert(m_children.indexOf(afterItem) + 1, newItem); - } - - if (!parentItem) { - layout = m_mainLayout; - parentWidget = q; - } - else { - if (!parentItem->container) { - m_recreateQueue.removeAll(parentItem); - WidgetItem* grandParent = parentItem->parent; - QGridLayout* l = 0; - const int oldRow = gridRow(parentItem); - if (grandParent) { - l = grandParent->layout; - } - else { - l = m_mainLayout; - } - QFrame* container = new QFrame(); - container->setFrameShape(QFrame::Panel); - container->setFrameShadow(QFrame::Raised); - parentItem->container = container; - parentItem->button = createButton(); - m_buttonToItem[parentItem->button] = parentItem; - q->connect(parentItem->button, SIGNAL(toggled(bool)), q_ptr, SLOT(slotToggled(bool))); - parentItem->layout = new QGridLayout(); - container->setLayout(parentItem->layout); - if (parentItem->label) { - l->removeWidget(parentItem->label); - delete parentItem->label; - parentItem->label = 0; - } - int span = 1; - if (!parentItem->widget && !parentItem->widgetLabel) - span = 2; - l->addWidget(parentItem->button, oldRow, 0, 1, span); - updateItem(parentItem); - } - layout = parentItem->layout; - parentWidget = parentItem->container; - } - - newItem->label = new QLabel(parentWidget); - newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - newItem->widget = createEditor(index->property(), parentWidget); - if (newItem->widget) { - QObject::connect(newItem->widget, SIGNAL(destroyed()), q, SLOT(slotEditorDestroyed())); - m_widgetToItem[newItem->widget] = newItem; - } - else if (index->property()->hasValue()) { - newItem->widgetLabel = new QLabel(parentWidget); - newItem->widgetLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed)); - } - - insertRow(layout, row); - int span = 1; - if (newItem->widget) - layout->addWidget(newItem->widget, row, 1); - else if (newItem->widgetLabel) - layout->addWidget(newItem->widgetLabel, row, 1); - else - span = 2; - layout->addWidget(newItem->label, row, 0, span, 1); - - m_itemToIndex[newItem] = index; - m_indexToItem[index] = newItem; - - updateItem(newItem); -} - -void ButtonPropertyBrowserPrivate::propertyRemoved(BrowserItem* index) -{ - WidgetItem* item = m_indexToItem.value(index); - - m_indexToItem.remove(index); - m_itemToIndex.remove(item); - - WidgetItem* parentItem = item->parent; - - const int row = gridRow(item); - - if (parentItem) - parentItem->children.removeAt(parentItem->children.indexOf(item)); - else - m_children.removeAt(m_children.indexOf(item)); - - const int colSpan = gridSpan(item); - - m_buttonToItem.remove(item->button); - - if (item->widget) - delete item->widget; - if (item->label) - delete item->label; - if (item->widgetLabel) - delete item->widgetLabel; - if (item->button) - delete item->button; - if (item->container) - delete item->container; - - if (!parentItem) { - removeRow(m_mainLayout, row); - if (colSpan > 1) - removeRow(m_mainLayout, row); - } - else if (parentItem->children.count() != 0) { - removeRow(parentItem->layout, row); - if (colSpan > 1) - removeRow(parentItem->layout, row); - } - else { - const WidgetItem* grandParent = parentItem->parent; - QGridLayout* l = 0; - if (grandParent) { - l = grandParent->layout; - } - else { - l = m_mainLayout; - } - - const int parentRow = gridRow(parentItem); - const int parentSpan = gridSpan(parentItem); - - l->removeWidget(parentItem->button); - l->removeWidget(parentItem->container); - delete parentItem->button; - delete parentItem->container; - parentItem->button = 0; - parentItem->container = 0; - parentItem->layout = 0; - if (!m_recreateQueue.contains(parentItem)) - m_recreateQueue.append(parentItem); - if (parentSpan > 1) - removeRow(l, parentRow + 1); - - updateLater(); - } - m_recreateQueue.removeAll(item); - - delete item; -} - -void ButtonPropertyBrowserPrivate::insertRow(QGridLayout* layout, int row) const -{ - QMap itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r >= row) { - itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs); - } - else { - idx++; - } - } - - for (auto it = itemToPos.constBegin(), icend = itemToPos.constEnd(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); - } -} - -void ButtonPropertyBrowserPrivate::removeRow(QGridLayout* layout, int row) const -{ - QMap itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r > row) { - itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs); - } - else { - idx++; - } - } - - for (auto it = itemToPos.constBegin(), icend = itemToPos.constEnd(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); - } -} - -void ButtonPropertyBrowserPrivate::propertyChanged(BrowserItem* index) -{ - WidgetItem* item = m_indexToItem.value(index); - - updateItem(item); -} - -void ButtonPropertyBrowserPrivate::updateItem(WidgetItem* item) -{ - PropertySheet* property = m_itemToIndex[item]->property(); - if (item->button) { - QFont font = item->button->font(); - font.setUnderline(property->isModified()); - item->button->setFont(font); - item->button->setText(property->propertyName()); - item->button->setToolTip(property->descriptionToolTip()); - item->button->setStatusTip(property->statusTip()); - item->button->setWhatsThis(property->whatsThis()); - item->button->setEnabled(property->isEnabled()); - } - if (item->label) { - QFont font = item->label->font(); - font.setUnderline(property->isModified()); - item->label->setFont(font); - item->label->setText(property->propertyName()); - item->label->setToolTip(property->descriptionToolTip()); - item->label->setStatusTip(property->statusTip()); - item->label->setWhatsThis(property->whatsThis()); - item->label->setEnabled(property->isEnabled()); - } - if (item->widgetLabel) { - QFont font = item->widgetLabel->font(); - font.setUnderline(false); - item->widgetLabel->setFont(font); - item->widgetLabel->setText(*property->valueText().toQString()); - item->widgetLabel->setToolTip(*property->valueText().toQString()); - item->widgetLabel->setEnabled(property->isEnabled()); - } - if (item->widget) { - QFont font = item->widget->font(); - font.setUnderline(false); - item->widget->setFont(font); - item->widget->setEnabled(property->isEnabled()); - const QString valueToolTip = property->valueToolTip(); - item->widget->setToolTip(valueToolTip.isEmpty() ? *property->valueText().toQString() : valueToolTip); - } -} - -/*! - \class ButtonPropertyBrowser - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The ButtonPropertyBrowser class provides a drop down QToolButton - based property browser. - - A property browser is a widget that enables the user to edit a - given set of properties. Each property is represented by a label - specifying the property's name, and an editing widget (e.g. a line - edit or a combobox) holding its value. A property can have zero or - more subproperties. - - ButtonPropertyBrowser provides drop down button for all nested - properties, i.e. subproperties are enclosed by a container associated with - the drop down button. The parent property's name is displayed as button text. For example: - - \image qtbuttonpropertybrowser.png - - Use the QtAbstractPropertyBrowser API to add, insert and remove - properties from an instance of the ButtonPropertyBrowser - class. The properties themselves are created and managed by - implementations of the QtAbstractPropertyManager class. - - \sa QtTreePropertyBrowser, QtAbstractPropertyBrowser -*/ - -/*! - \fn void ButtonPropertyBrowser::collapsed(BrowserItem *item) - - This signal is emitted when the \a item is collapsed. - - \sa expanded(), setExpanded() -*/ - -/*! - \fn void ButtonPropertyBrowser::expanded(BrowserItem *item) - - This signal is emitted when the \a item is expanded. - - \sa collapsed(), setExpanded() -*/ - -/*! - Creates a property browser with the given \a parent. -*/ -ButtonPropertyBrowser::ButtonPropertyBrowser(QWidget* parent) - : ButtonPropertyBrowser(*new ButtonPropertyBrowserPrivate, parent) -{ - - -} - -/*! - Destroys this property browser. - - Note that the properties that were inserted into this browser are - \e not destroyed since they may still be used in other - browsers. The properties are owned by the manager that created - them. - - \sa PropertySheet, QtAbstractPropertyManager -*/ -ButtonPropertyBrowser::~ButtonPropertyBrowser() -{ - Q_D(ButtonPropertyBrowser); - const QMap::ConstIterator icend = d->m_itemToIndex.constEnd(); - for (QMap::ConstIterator it = d->m_itemToIndex.constBegin(); it != icend; ++it) - delete it.key(); -} - -/*! - \reimp -*/ -void ButtonPropertyBrowser::itemInserted(BrowserItem* item, BrowserItem* afterItem) -{ - Q_D(ButtonPropertyBrowser); - d->propertyInserted(item, afterItem); -} - -/*! - \reimp -*/ -void ButtonPropertyBrowser::itemRemoved(BrowserItem* item) -{ - Q_D(ButtonPropertyBrowser); - d->propertyRemoved(item); -} - -/*! - \reimp -*/ -void ButtonPropertyBrowser::itemChanged(BrowserItem* item) -{ - Q_D(ButtonPropertyBrowser); - d->propertyChanged(item); -} - -/*! - Sets the \a item to either collapse or expanded, depending on the value of \a expanded. - - \sa isExpanded(), expanded(), collapsed() -*/ - -void ButtonPropertyBrowser::setExpanded(BrowserItem* item, bool expanded) -{ - Q_D(ButtonPropertyBrowser); - ButtonPropertyBrowserPrivate::WidgetItem* itm = d->m_indexToItem.value(item); - if (itm) - d->setExpanded(itm, expanded); -} - -/*! - Returns true if the \a item is expanded; otherwise returns false. - - \sa setExpanded() -*/ - -bool ButtonPropertyBrowser::isExpanded(BrowserItem* item) const -{ - Q_D(const ButtonPropertyBrowser); - ButtonPropertyBrowserPrivate::WidgetItem* itm = d->m_indexToItem.value(item); - if (itm) - return itm->expanded; - return false; -} diff --git a/QtRpa/modules/property/src/charpropertymanager.cpp1 b/QtRpa/modules/property/src/charpropertymanager.cpp1 deleted file mode 100644 index b3a8be1..0000000 --- a/QtRpa/modules/property/src/charpropertymanager.cpp1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/charpropertymanager.h" -#include "property/private/charpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -CharPropertyManager::CharPropertyManager(Object* parent /*= nullptr*/) - :CharPropertyManager(*new CharPropertyManagerPrivate, parent) -{ - -} -CharPropertyManager::CharPropertyManager(CharPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/colorpropertymanager.cpp1 b/QtRpa/modules/property/src/colorpropertymanager.cpp1 deleted file mode 100644 index c17d6e2..0000000 --- a/QtRpa/modules/property/src/colorpropertymanager.cpp1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/colorpropertymanager.h" -#include "property/private/colorpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -ColorPropertyManager::ColorPropertyManager(Object* parent /*= nullptr*/) - :ColorPropertyManager(*new ColorPropertyManagerPrivate, parent) -{ - -} -ColorPropertyManager::ColorPropertyManager(ColorPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/cursordatabase.cpp b/QtRpa/modules/property/src/cursordatabase.cpp deleted file mode 100644 index 9ff2f8a..0000000 --- a/QtRpa/modules/property/src/cursordatabase.cpp +++ /dev/null @@ -1,131 +0,0 @@ -#include "property/framework.h" -#include "qcursor.h" -#include "qglobalstatic.h" -#include "qcoreapplication.h" -#include "property/cursordatabase.h" -#include "property/private/cursordatabase_p.h" - -namespace shelllet{ - namespace property{ - - - Q_GLOBAL_STATIC(CursorDatabase, cursorDatabase) - - } -} -using namespace shelllet::property; -CursorDatabase::CursorDatabase(Object* parent /*= nullptr*/) - :CursorDatabase(*new CursorDatabasePrivate, parent) -{ - -} -CursorDatabase::CursorDatabase(CursorDatabasePrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - appendCursor(Qt::ArrowCursor, QCoreApplication::translate("CursorDatabase", "Arrow"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-arrow.png"))); - appendCursor(Qt::UpArrowCursor, QCoreApplication::translate("CursorDatabase", "Up Arrow"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-uparrow.png"))); - appendCursor(Qt::CrossCursor, QCoreApplication::translate("CursorDatabase", "Cross"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-cross.png"))); - appendCursor(Qt::WaitCursor, QCoreApplication::translate("CursorDatabase", "Wait"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-wait.png"))); - appendCursor(Qt::IBeamCursor, QCoreApplication::translate("CursorDatabase", "IBeam"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-ibeam.png"))); - appendCursor(Qt::SizeVerCursor, QCoreApplication::translate("CursorDatabase", "Size Vertical"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizev.png"))); - appendCursor(Qt::SizeHorCursor, QCoreApplication::translate("CursorDatabase", "Size Horizontal"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeh.png"))); - appendCursor(Qt::SizeFDiagCursor, QCoreApplication::translate("CursorDatabase", "Size Backslash"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizef.png"))); - appendCursor(Qt::SizeBDiagCursor, QCoreApplication::translate("CursorDatabase", "Size Slash"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeb.png"))); - appendCursor(Qt::SizeAllCursor, QCoreApplication::translate("CursorDatabase", "Size All"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-sizeall.png"))); - appendCursor(Qt::BlankCursor, QCoreApplication::translate("CursorDatabase", "Blank"), - QIcon()); - appendCursor(Qt::SplitVCursor, QCoreApplication::translate("CursorDatabase", "Split Vertical"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-vsplit.png"))); - appendCursor(Qt::SplitHCursor, QCoreApplication::translate("CursorDatabase", "Split Horizontal"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-hsplit.png"))); - appendCursor(Qt::PointingHandCursor, QCoreApplication::translate("CursorDatabase", "Pointing Hand"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-hand.png"))); - appendCursor(Qt::ForbiddenCursor, QCoreApplication::translate("CursorDatabase", "Forbidden"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-forbidden.png"))); - appendCursor(Qt::OpenHandCursor, QCoreApplication::translate("CursorDatabase", "Open Hand"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-openhand.png"))); - appendCursor(Qt::ClosedHandCursor, QCoreApplication::translate("CursorDatabase", "Closed Hand"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-closedhand.png"))); - appendCursor(Qt::WhatsThisCursor, QCoreApplication::translate("CursorDatabase", "What's This"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-whatsthis.png"))); - appendCursor(Qt::BusyCursor, QCoreApplication::translate("CursorDatabase", "Busy"), - QIcon(QLatin1String(":/qt-project.org/qtpropertybrowser/images/cursor-busy.png"))); -} - -CursorDatabase* CursorDatabase::getInstance() -{ - return cursorDatabase; -} - - -void CursorDatabase::clear() -{ - m_cursorNames.clear(); - m_cursorIcons.clear(); - m_valueToCursorShape.clear(); - m_cursorShapeToValue.clear(); -} - -void CursorDatabase::appendCursor(Qt::CursorShape shape, const QString& name, const QIcon& icon) -{ - if (m_cursorShapeToValue.contains(shape)) - return; - const int value = m_cursorNames.count(); - m_cursorNames.append(name); - m_cursorIcons.insert(value, icon); - m_valueToCursorShape.insert(value, shape); - m_cursorShapeToValue.insert(shape, value); -} - -QStringList CursorDatabase::cursorShapeNames() const -{ - return m_cursorNames; -} - -QMap CursorDatabase::cursorShapeIcons() const -{ - return m_cursorIcons; -} - -QString CursorDatabase::cursorToShapeName(const QCursor& cursor) const -{ - int val = cursorToValue(cursor); - if (val >= 0) - return m_cursorNames.at(val); - return QString(); -} - -QIcon CursorDatabase::cursorToShapeIcon(const QCursor& cursor) const -{ - int val = cursorToValue(cursor); - return m_cursorIcons.value(val); -} - -int CursorDatabase::cursorToValue(const QCursor& cursor) const -{ -#ifndef QT_NO_CURSOR - Qt::CursorShape shape = cursor.shape(); - if (m_cursorShapeToValue.contains(shape)) - return m_cursorShapeToValue[shape]; -#endif - return -1; -} - -#ifndef QT_NO_CURSOR -QCursor CursorDatabase::valueToCursor(int value) const -{ - if (m_valueToCursorShape.contains(value)) - return QCursor(m_valueToCursorShape[value]); - return QCursor(); -} -#endif diff --git a/QtRpa/modules/property/src/cursorpropertymanager.cpp1 b/QtRpa/modules/property/src/cursorpropertymanager.cpp1 deleted file mode 100644 index ecca7f0..0000000 --- a/QtRpa/modules/property/src/cursorpropertymanager.cpp1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/cursorpropertymanager.h" -#include "property/private/cursorpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -CursorPropertyManager::CursorPropertyManager(Object* parent /*= nullptr*/) - :CursorPropertyManager(*new CursorPropertyManagerPrivate, parent) -{ - -} -CursorPropertyManager::CursorPropertyManager(CursorPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/datepropertymanager.cpp1 b/QtRpa/modules/property/src/datepropertymanager.cpp1 deleted file mode 100644 index 6b7b94b..0000000 --- a/QtRpa/modules/property/src/datepropertymanager.cpp1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/datepropertymanager.h" -#include "property/private/datepropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -DatePropertyManager::DatePropertyManager(Object* parent /*= nullptr*/) - :DatePropertyManager(*new DatePropertyManagerPrivate, parent) -{ - -} -DatePropertyManager::DatePropertyManager(DatePropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/datetimepropertymanager.cpp1 b/QtRpa/modules/property/src/datetimepropertymanager.cpp1 deleted file mode 100644 index 941c71c..0000000 --- a/QtRpa/modules/property/src/datetimepropertymanager.cpp1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/datetimepropertymanager.h" -#include "property/private/datetimepropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -DateTimePropertyManager::DateTimePropertyManager(Object* parent /*= nullptr*/) - :DateTimePropertyManager(*new DateTimePropertyManagerPrivate, parent) -{ - -} -DateTimePropertyManager::DateTimePropertyManager(DateTimePropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/doublepropertymanager.cpp1 b/QtRpa/modules/property/src/doublepropertymanager.cpp1 deleted file mode 100644 index b693fac..0000000 --- a/QtRpa/modules/property/src/doublepropertymanager.cpp1 +++ /dev/null @@ -1,259 +0,0 @@ -#include "property/framework.h" -#include "property/abstractpropertymanager.h" -#include "property/doublepropertymanager.h" -#include "private/qobject_p.h" -#include "property/private/abstractpropertymanager_p.h" -#include "property/private/doublepropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -DoublePropertyManager::DoublePropertyManager(Object* parent /*= nullptr*/) - :DoublePropertyManager(*new DoublePropertyManagerPrivate, nullptr, parent) -{ - -} -DoublePropertyManager::DoublePropertyManager(DoublePropertyManagerPrivate& d, QObject* parent, Object* /*parent*/ /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} - - -DoublePropertyManager::DoublePropertyManager(QObject* parent) - : AbstractPropertyManager(*new DoublePropertyManagerPrivate, parent) -{ -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -DoublePropertyManager::~DoublePropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns 0. - - \sa setValue() -*/ -double DoublePropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property, 0.0); -} - -/*! - Returns the given \a property's minimum value. - - \sa maximum(), setRange() -*/ -double DoublePropertyManager::minimum(const PropertySheet* property) const -{ - return getMinimum(d_ptr->m_values, property, 0.0); -} - -/*! - Returns the given \a property's maximum value. - - \sa minimum(), setRange() -*/ -double DoublePropertyManager::maximum(const PropertySheet* property) const -{ - return getMaximum(d_ptr->m_values, property, 0.0); -} - -/*! - Returns the given \a property's step value. - - The step is typically used to increment or decrement a property value while pressing an arrow key. - - \sa setSingleStep() -*/ -double DoublePropertyManager::singleStep(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &DoublePropertyManagerPrivate::Data::singleStep, property, 0); -} - -/*! - Returns the given \a property's precision, in decimals. - - \sa setDecimals() -*/ -int DoublePropertyManager::decimals(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &DoublePropertyManagerPrivate::Data::decimals, property, 0); -} - -/*! - \reimp -*/ -QString DoublePropertyManager::valueText(const PropertySheet* property) const -{ - const DoublePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return QString::number(it.value().val, 'f', it.value().decimals); -} - -/*! - \fn void DoublePropertyManager::setValue(PropertySheet *property, double value) - - Sets the value of the given \a property to \a value. - - If the specified \a value is not valid according to the given - \a property's range, the \a value is adjusted to the nearest valid value - within the range. - - \sa value(), setRange(), valueChanged() -*/ -void DoublePropertyManager::setValue(PropertySheet* property, double val) -{ - void (DoublePropertyManagerPrivate:: * setSubPropertyValue)(PropertySheet*, double) = 0; - setValueInRange(this, d_ptr.data(), - &DoublePropertyManager::propertyChanged, - &DoublePropertyManager::valueChanged, - property, val, setSubPropertyValue); -} - -/*! - Sets the step value for the given \a property to \a step. - - The step is typically used to increment or decrement a property value while pressing an arrow key. - - \sa singleStep() -*/ -void DoublePropertyManager::setSingleStep(PropertySheet* property, double step) -{ - const DoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - DoublePropertyManagerPrivate::Data data = it.value(); - - if (step < 0) - step = 0; - - if (data.singleStep == step) - return; - - data.singleStep = step; - - it.value() = data; - - emit singleStepChanged(property, data.singleStep); -} - -/*! - \fn void DoublePropertyManager::setDecimals(PropertySheet *property, int prec) - - Sets the precision of the given \a property to \a prec. - - The valid decimal range is 0-13. The default is 2. - - \sa decimals() -*/ -void DoublePropertyManager::setDecimals(PropertySheet* property, int prec) -{ - const DoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - DoublePropertyManagerPrivate::Data data = it.value(); - - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; - - if (data.decimals == prec) - return; - - data.decimals = prec; - - it.value() = data; - - emit decimalsChanged(property, data.decimals); -} - -/*! - Sets the minimum value for the given \a property to \a minVal. - - When setting the minimum value, the maximum and current values are - adjusted if necessary (ensuring that the range remains valid and - that the current value is within in the range). - - \sa minimum(), setRange(), rangeChanged() -*/ -void DoublePropertyManager::setMinimum(PropertySheet* property, double minVal) -{ - setMinimumValue(this, d_ptr.data(), - &DoublePropertyManager::propertyChanged, - &DoublePropertyManager::valueChanged, - &DoublePropertyManager::rangeChanged, - property, minVal); -} - -/*! - Sets the maximum value for the given \a property to \a maxVal. - - When setting the maximum value, the minimum and current values are - adjusted if necessary (ensuring that the range remains valid and - that the current value is within in the range). - - \sa maximum(), setRange(), rangeChanged() -*/ -void DoublePropertyManager::setMaximum(PropertySheet* property, double maxVal) -{ - setMaximumValue(this, d_ptr.data(), - &DoublePropertyManager::propertyChanged, - &DoublePropertyManager::valueChanged, - &DoublePropertyManager::rangeChanged, - property, maxVal); -} - -/*! - \fn void DoublePropertyManager::setRange(PropertySheet *property, double minimum, double maximum) - - Sets the range of valid values. - - This is a convenience function defining the range of valid values - in one go; setting the \a minimum and \a maximum values for the - given \a property with a single function call. - - When setting a new range, the current value is adjusted if - necessary (ensuring that the value remains within range). - - \sa setMinimum(), setMaximum(), rangeChanged() -*/ -void DoublePropertyManager::setRange(PropertySheet* property, double minVal, double maxVal) -{ - void (DoublePropertyManagerPrivate:: * setSubPropertyRange)(PropertySheet*, double, double, double) = 0; - setBorderValues(this, d_ptr.data(), - &DoublePropertyManager::propertyChanged, - &DoublePropertyManager::valueChanged, - &DoublePropertyManager::rangeChanged, - property, minVal, maxVal, setSubPropertyRange); -} - -/*! - \reimp -*/ -void DoublePropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = DoublePropertyManagerPrivate::Data(); -} - -/*! - \reimp -*/ -void DoublePropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} diff --git a/QtRpa/modules/property/src/enumpropertymanager.cpp1 b/QtRpa/modules/property/src/enumpropertymanager.cpp1 deleted file mode 100644 index eb76c68..0000000 --- a/QtRpa/modules/property/src/enumpropertymanager.cpp1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/enumpropertymanager.h" -#include "property/private/enumpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -EnumPropertyManager::EnumPropertyManager(Object* parent /*= nullptr*/) - :EnumPropertyManager(*new EnumPropertyManagerPrivate, parent) -{ - -} -EnumPropertyManager::EnumPropertyManager(EnumPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/flagpropertymanager.c1 b/QtRpa/modules/property/src/flagpropertymanager.c1 deleted file mode 100644 index 27a5330..0000000 --- a/QtRpa/modules/property/src/flagpropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/flagpropertymanager.h" -#include "property/private/flagpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -FlagPropertyManager::FlagPropertyManager(Object* parent /*= nullptr*/) - :FlagPropertyManager(*new FlagPropertyManagerPrivate, parent) -{ - -} -FlagPropertyManager::FlagPropertyManager(FlagPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/fontpropertymanager.c1 b/QtRpa/modules/property/src/fontpropertymanager.c1 deleted file mode 100644 index 5d9788b..0000000 --- a/QtRpa/modules/property/src/fontpropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/fontpropertymanager.h" -#include "property/private/fontpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -FontPropertyManager::FontPropertyManager(Object* parent /*= nullptr*/) - :FontPropertyManager(*new FontPropertyManagerPrivate, parent) -{ - -} -FontPropertyManager::FontPropertyManager(FontPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/groupboxpropertybrowser.cpp b/QtRpa/modules/property/src/groupboxpropertybrowser.cpp deleted file mode 100644 index c432e44..0000000 --- a/QtRpa/modules/property/src/groupboxpropertybrowser.cpp +++ /dev/null @@ -1,473 +0,0 @@ -#include "property/framework.h" -#include "qgridlayout.h" -#include "qwidget.h" -#include "qlabel.h" -#include "qtimer.h" -#include "qgroupbox.h" -#include "property/browseritem.h" -#include "property/propertysheet.h" -#include "property/abstractpropertybrowser.h" -#include "property/groupboxpropertybrowser.h" -#include "private/qwidget_p.h" -#include "property/private/abstractpropertybrowser_p.h" -#include "property/private/groupboxpropertybrowser_p.h" - -namespace shelllet { - namespace property { - - } -} -using namespace shelllet::property; -GroupBoxPropertyBrowser::GroupBoxPropertyBrowser(Object* parent /*= nullptr*/) - :GroupBoxPropertyBrowser(*new GroupBoxPropertyBrowserPrivate, nullptr, parent) -{ - -} -GroupBoxPropertyBrowser::GroupBoxPropertyBrowser(GroupBoxPropertyBrowserPrivate& d, QWidget* widget, Object* parent /*= nullptr*/) - : AbstractPropertyBrowser(d, widget) -{ - d.init(this); - -} - - -void GroupBoxPropertyBrowserPrivate::init(QWidget* parent) -{ - m_mainLayout = new QGridLayout(); - parent->setLayout(m_mainLayout); - QLayoutItem* item = new QSpacerItem(0, 0, - QSizePolicy::Fixed, QSizePolicy::Expanding); - m_mainLayout->addItem(item, 0, 0); -} - -void GroupBoxPropertyBrowserPrivate::slotEditorDestroyed() -{ - Q_Q(GroupBoxPropertyBrowser); - QWidget* editor = qobject_cast(q->sender()); - if (!editor) - return; - if (!m_widgetToItem.contains(editor)) - return; - m_widgetToItem[editor]->widget = 0; - m_widgetToItem.remove(editor); -} - -void GroupBoxPropertyBrowserPrivate::slotUpdate() -{ - Q_Q(GroupBoxPropertyBrowser); - for (WidgetItem* item : qAsConst(m_recreateQueue)) { - WidgetItem* par = item->parent; - QWidget* w = 0; - QGridLayout* l = 0; - int oldRow = -1; - if (!par) { - w = q; - l = m_mainLayout; - oldRow = m_children.indexOf(item); - } - else { - w = par->groupBox; - l = par->layout; - oldRow = par->children.indexOf(item); - if (hasHeader(par)) - oldRow += 2; - } - - if (item->widget) { - item->widget->setParent(w); - } - else if (item->widgetLabel) { - item->widgetLabel->setParent(w); - } - else { - item->widgetLabel = new QLabel(w); - } - int span = 1; - if (item->widget) - l->addWidget(item->widget, oldRow, 1, 1, 1); - else if (item->widgetLabel) - l->addWidget(item->widgetLabel, oldRow, 1, 1, 1); - else - span = 2; - item->label = new QLabel(w); - item->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - l->addWidget(item->label, oldRow, 0, 1, span); - - updateItem(item); - } - m_recreateQueue.clear(); -} - -void GroupBoxPropertyBrowserPrivate::updateLater() -{ - Q_Q(GroupBoxPropertyBrowser); - QTimer::singleShot(0, q, SLOT(slotUpdate())); -} - -void GroupBoxPropertyBrowserPrivate::propertyInserted(BrowserItem* index, BrowserItem* afterIndex) -{ - Q_Q(GroupBoxPropertyBrowser); - WidgetItem* afterItem = m_indexToItem.value(afterIndex); - WidgetItem* parentItem = m_indexToItem.value(index->parent()); - - WidgetItem* newItem = new WidgetItem(); - newItem->parent = parentItem; - - QGridLayout* layout = 0; - QWidget* parentWidget = 0; - int row = -1; - if (!afterItem) { - row = 0; - if (parentItem) - parentItem->children.insert(0, newItem); - else - m_children.insert(0, newItem); - } - else { - if (parentItem) { - row = parentItem->children.indexOf(afterItem) + 1; - parentItem->children.insert(row, newItem); - } - else { - row = m_children.indexOf(afterItem) + 1; - m_children.insert(row, newItem); - } - } - if (parentItem && hasHeader(parentItem)) - row += 2; - - if (!parentItem) { - layout = m_mainLayout; - parentWidget = q;; - } - else { - if (!parentItem->groupBox) { - m_recreateQueue.removeAll(parentItem); - WidgetItem* par = parentItem->parent; - QWidget* w = 0; - QGridLayout* l = 0; - int oldRow = -1; - if (!par) { - w = q; - l = m_mainLayout; - oldRow = m_children.indexOf(parentItem); - } - else { - w = par->groupBox; - l = par->layout; - oldRow = par->children.indexOf(parentItem); - if (hasHeader(par)) - oldRow += 2; - } - parentItem->groupBox = new QGroupBox(w); - parentItem->layout = new QGridLayout(); - parentItem->groupBox->setLayout(parentItem->layout); - if (parentItem->label) { - l->removeWidget(parentItem->label); - delete parentItem->label; - parentItem->label = 0; - } - if (parentItem->widget) { - l->removeWidget(parentItem->widget); - parentItem->widget->setParent(parentItem->groupBox); - parentItem->layout->addWidget(parentItem->widget, 0, 0, 1, 2); - parentItem->line = new QFrame(parentItem->groupBox); - } - else if (parentItem->widgetLabel) { - l->removeWidget(parentItem->widgetLabel); - delete parentItem->widgetLabel; - parentItem->widgetLabel = 0; - } - if (parentItem->line) { - parentItem->line->setFrameShape(QFrame::HLine); - parentItem->line->setFrameShadow(QFrame::Sunken); - parentItem->layout->addWidget(parentItem->line, 1, 0, 1, 2); - } - l->addWidget(parentItem->groupBox, oldRow, 0, 1, 2); - updateItem(parentItem); - } - layout = parentItem->layout; - parentWidget = parentItem->groupBox; - } - - newItem->label = new QLabel(parentWidget); - newItem->label->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - newItem->widget = createEditor(index->property(), parentWidget); - if (!newItem->widget) { - newItem->widgetLabel = new QLabel(parentWidget); - } - else { - QObject::connect(newItem->widget, SIGNAL(destroyed()), q, SLOT(slotEditorDestroyed())); - m_widgetToItem[newItem->widget] = newItem; - } - - insertRow(layout, row); - int span = 1; - if (newItem->widget) - layout->addWidget(newItem->widget, row, 1); - else if (newItem->widgetLabel) - layout->addWidget(newItem->widgetLabel, row, 1); - else - span = 2; - layout->addWidget(newItem->label, row, 0, 1, span); - - m_itemToIndex[newItem] = index; - m_indexToItem[index] = newItem; - - updateItem(newItem); -} - -void GroupBoxPropertyBrowserPrivate::propertyRemoved(BrowserItem* index) -{ - WidgetItem* item = m_indexToItem.value(index); - - m_indexToItem.remove(index); - m_itemToIndex.remove(item); - - WidgetItem* parentItem = item->parent; - - int row = -1; - - if (parentItem) { - row = parentItem->children.indexOf(item); - parentItem->children.removeAt(row); - if (hasHeader(parentItem)) - row += 2; - } - else { - row = m_children.indexOf(item); - m_children.removeAt(row); - } - - if (item->widget) - delete item->widget; - if (item->label) - delete item->label; - if (item->widgetLabel) - delete item->widgetLabel; - if (item->groupBox) - delete item->groupBox; - - if (!parentItem) { - removeRow(m_mainLayout, row); - } - else if (parentItem->children.count() != 0) { - removeRow(parentItem->layout, row); - } - else { - WidgetItem* par = parentItem->parent; - QGridLayout* l = 0; - int oldRow = -1; - if (!par) { - l = m_mainLayout; - oldRow = m_children.indexOf(parentItem); - } - else { - l = par->layout; - oldRow = par->children.indexOf(parentItem); - if (hasHeader(par)) - oldRow += 2; - } - - if (parentItem->widget) { - parentItem->widget->hide(); - parentItem->widget->setParent(0); - } - else if (parentItem->widgetLabel) { - parentItem->widgetLabel->hide(); - parentItem->widgetLabel->setParent(0); - } - else { - //parentItem->widgetLabel = new QLabel(w); - } - l->removeWidget(parentItem->groupBox); - delete parentItem->groupBox; - parentItem->groupBox = 0; - parentItem->line = 0; - parentItem->layout = 0; - if (!m_recreateQueue.contains(parentItem)) - m_recreateQueue.append(parentItem); - updateLater(); - } - m_recreateQueue.removeAll(item); - - delete item; -} - -void GroupBoxPropertyBrowserPrivate::insertRow(QGridLayout* layout, int row) const -{ - QMap itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r >= row) { - itemToPos[layout->takeAt(idx)] = QRect(r + 1, c, rs, cs); - } - else { - idx++; - } - } - - const QMap::ConstIterator icend = itemToPos.constEnd(); - for (QMap::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); - } -} - -void GroupBoxPropertyBrowserPrivate::removeRow(QGridLayout* layout, int row) const -{ - QMap itemToPos; - int idx = 0; - while (idx < layout->count()) { - int r, c, rs, cs; - layout->getItemPosition(idx, &r, &c, &rs, &cs); - if (r > row) { - itemToPos[layout->takeAt(idx)] = QRect(r - 1, c, rs, cs); - } - else { - idx++; - } - } - - const QMap::ConstIterator icend = itemToPos.constEnd(); - for (QMap::ConstIterator it = itemToPos.constBegin(); it != icend; ++it) { - const QRect r = it.value(); - layout->addItem(it.key(), r.x(), r.y(), r.width(), r.height()); - } -} - -bool GroupBoxPropertyBrowserPrivate::hasHeader(WidgetItem* item) const -{ - if (item->widget) - return true; - return false; -} - -void GroupBoxPropertyBrowserPrivate::propertyChanged(BrowserItem* index) -{ - WidgetItem* item = m_indexToItem.value(index); - - updateItem(item); -} - -void GroupBoxPropertyBrowserPrivate::updateItem(WidgetItem* item) -{ - PropertySheet* property = m_itemToIndex[item]->property(); - if (item->groupBox) { - QFont font = item->groupBox->font(); - font.setUnderline(property->isModified()); - item->groupBox->setFont(font); - item->groupBox->setTitle(property->propertyName()); - item->groupBox->setToolTip(property->descriptionToolTip()); - item->groupBox->setStatusTip(property->statusTip()); - item->groupBox->setWhatsThis(property->whatsThis()); - item->groupBox->setEnabled(property->isEnabled()); - } - if (item->label) { - QFont font = item->label->font(); - font.setUnderline(property->isModified()); - item->label->setFont(font); - item->label->setText(property->propertyName()); - item->label->setToolTip(property->descriptionToolTip()); - item->label->setStatusTip(property->statusTip()); - item->label->setWhatsThis(property->whatsThis()); - item->label->setEnabled(property->isEnabled()); - } - if (item->widgetLabel) { - QFont font = item->widgetLabel->font(); - font.setUnderline(false); - item->widgetLabel->setFont(font); - item->widgetLabel->setText(*property->valueText().toQString()); - item->widgetLabel->setEnabled(property->isEnabled()); - } - if (item->widget) { - QFont font = item->widget->font(); - font.setUnderline(false); - item->widget->setFont(font); - item->widget->setEnabled(property->isEnabled()); - const QString valueToolTip = property->valueToolTip(); - item->widget->setToolTip(valueToolTip.isEmpty() ? *property->valueText().toQString() : valueToolTip); - } - //item->setIcon(1, property->valueIcon()); -} - -/*! - \class GroupBoxPropertyBrowser - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The GroupBoxPropertyBrowser class provides a QGroupBox - based property browser. - - A property browser is a widget that enables the user to edit a - given set of properties. Each property is represented by a label - specifying the property's name, and an editing widget (e.g. a line - edit or a combobox) holding its value. A property can have zero or - more subproperties. - - GroupBoxPropertyBrowser provides group boxes for all nested - properties, i.e. subproperties are enclosed by a group box with - the parent property's name as its title. For example: - - \image qtgroupboxpropertybrowser.png - - Use the QtAbstractPropertyBrowser API to add, insert and remove - properties from an instance of the GroupBoxPropertyBrowser - class. The properties themselves are created and managed by - implementations of the QtAbstractPropertyManager class. - - \sa QtTreePropertyBrowser, QtAbstractPropertyBrowser -*/ - -/*! - Creates a property browser with the given \a parent. -*/ - - -/*! - Destroys this property browser. - - Note that the properties that were inserted into this browser are - \e not destroyed since they may still be used in other - browsers. The properties are owned by the manager that created - them. - - \sa QtProperty, QtAbstractPropertyManager -*/ -GroupBoxPropertyBrowser::~GroupBoxPropertyBrowser() -{ - Q_D(GroupBoxPropertyBrowser); - const QMap::ConstIterator icend = d->m_itemToIndex.constEnd(); - for (QMap::ConstIterator it = d->m_itemToIndex.constBegin(); it != icend; ++it) - delete it.key(); -} - -/*! - \reimp -*/ -void GroupBoxPropertyBrowser::itemInserted(BrowserItem* item, BrowserItem* afterItem) -{ - Q_D(GroupBoxPropertyBrowser); - d->propertyInserted(item, afterItem); -} - -/*! - \reimp -*/ -void GroupBoxPropertyBrowser::itemRemoved(BrowserItem* item) -{ - Q_D(GroupBoxPropertyBrowser); - d->propertyRemoved(item); -} - -/*! - \reimp -*/ -void GroupBoxPropertyBrowser::itemChanged(BrowserItem* item) -{ - Q_D(GroupBoxPropertyBrowser); - d->propertyChanged(item); -} \ No newline at end of file diff --git a/QtRpa/modules/property/src/grouppropertymanager.cpp b/QtRpa/modules/property/src/grouppropertymanager.cpp deleted file mode 100644 index 8267e22..0000000 --- a/QtRpa/modules/property/src/grouppropertymanager.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "property/framework.h" -#include "property/abstractpropertymanager.h" -#include "property/grouppropertymanager.h" -#include "private/qobject_p.h" -#include "property/private/abstractpropertymanager_p.h" -#include "property/private/grouppropertymanager_p.h" -#include "common/wobjectimpl.h" -namespace shelllet { - namespace property { - - - - } -} -using namespace shelllet::property; - -W_OBJECT_IMPL(GroupPropertyManager) -//GroupPropertyManager::GroupPropertyManager(Object* parent /*= nullptr*/) -// :GroupPropertyManager(*new GroupPropertyManagerPrivate,nullptr, parent) -//{ -// -//} - -GroupPropertyManager::GroupPropertyManager(QObject* parent /*= 0*/) - : GroupPropertyManager(*new GroupPropertyManagerPrivate, parent) -{ - -} -GroupPropertyManager::GroupPropertyManager(GroupPropertyManagerPrivate& d, QObject* parent1, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent1) -{ - -} - - -// QtGroupPropertyManager - -/*! - \class QtGroupPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtGroupPropertyManager provides and manages group properties. - - This class is intended to provide a grouping element without any value. - - \sa AbstractPropertyManager -*/ - -/*! - Creates a manager with the given \a parent. -*/ - -/*! - Destroys this manager, and all the properties it has created. -*/ - -/*! - \reimp -*/ -bool GroupPropertyManager::hasValue(const PropertySheet* property) const -{ - Q_UNUSED(property); - return false; -} - -/*! - \reimp -*/ -void GroupPropertyManager::initializeProperty(PropertySheet* property) -{ - Q_UNUSED(property); -} - -/*! - \reimp -*/ -void GroupPropertyManager::uninitializeProperty(PropertySheet* property) -{ - Q_UNUSED(property); -} \ No newline at end of file diff --git a/QtRpa/modules/property/src/intpropertymanager.c1 b/QtRpa/modules/property/src/intpropertymanager.c1 deleted file mode 100644 index 320d4b3..0000000 --- a/QtRpa/modules/property/src/intpropertymanager.c1 +++ /dev/null @@ -1,225 +0,0 @@ -#include "property/framework.h" -#include "property/abstractpropertymanager.h" -#include "property/intpropertymanager.h" -#include "private/qobject_p.h" -#include "property/private/abstractpropertymanager_p.h" -#include "property/private/intpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -IntPropertyManager::IntPropertyManager(Object* parent /*= nullptr*/) - :IntPropertyManager(*new IntPropertyManagerPrivate, nullptr, parent) -{ - -} -IntPropertyManager::IntPropertyManager(IntPropertyManagerPrivate& d, QObject* parent, Object* /*parent*/ /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} - - -IntPropertyManager::IntPropertyManager(QObject* parent) - : IntPropertyManager(*new IntPropertyManagerPrivate, parent) -{ -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -IntPropertyManager::~IntPropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns 0. - - \sa setValue() -*/ -int IntPropertyManager::value(const PropertySheet* property) const -{ - Q_D(const IntPropertyManager); - return getValue(d->m_values, property, 0); -} - -/*! - Returns the given \a property's minimum value. - - \sa setMinimum(), maximum(), setRange() -*/ -int IntPropertyManager::minimum(const PropertySheet* property) const -{ - Q_D(const IntPropertyManager); - return getMinimum(d->m_values, property, 0); -} - -/*! - Returns the given \a property's maximum value. - - \sa setMaximum(), minimum(), setRange() -*/ -int IntPropertyManager::maximum(const PropertySheet* property) const -{ - Q_D(const IntPropertyManager); - return getMaximum(d->m_values, property, 0); -} - -/*! - Returns the given \a property's step value. - - The step is typically used to increment or decrement a property value while pressing an arrow key. - - \sa setSingleStep() -*/ -int IntPropertyManager::singleStep(const PropertySheet* property) const -{ - Q_D(const IntPropertyManager); - return getData(d->m_values, &IntPropertyManagerPrivate::Data::singleStep, property, 0); -} - -/*! - \reimp -*/ -QString IntPropertyManager::valueText(const PropertySheet* property) const -{ - Q_D(const IntPropertyManager); - const IntPropertyManagerPrivate::PropertyValueMap::const_iterator it = d->m_values.constFind(property); - if (it == d->m_values.constEnd()) - return QString(); - return QString::number(it.value().val); -} - -/*! - \fn void IntPropertyManager::setValue(PropertySheet *property, int value) - - Sets the value of the given \a property to \a value. - - If the specified \a value is not valid according to the given \a - property's range, the \a value is adjusted to the nearest valid - value within the range. - - \sa value(), setRange(), valueChanged() -*/ -void IntPropertyManager::setValue(PropertySheet* property, int val) -{ - Q_D(IntPropertyManager); - void (IntPropertyManagerPrivate:: * setSubPropertyValue)(PropertySheet*, int) = 0; - setValueInRange(this, d_ptr.data(), - &IntPropertyManager::propertyChanged, - &IntPropertyManager::valueChanged, - property, val, setSubPropertyValue); -} - -/*! - Sets the minimum value for the given \a property to \a minVal. - - When setting the minimum value, the maximum and current values are - adjusted if necessary (ensuring that the range remains valid and - that the current value is within the range). - - \sa minimum(), setRange(), rangeChanged() -*/ -void IntPropertyManager::setMinimum(PropertySheet* property, int minVal) -{ - setMinimumValue(this, d_ptr.data(), - &IntPropertyManager::propertyChanged, - &IntPropertyManager::valueChanged, - &IntPropertyManager::rangeChanged, - property, minVal); -} - -/*! - Sets the maximum value for the given \a property to \a maxVal. - - When setting maximum value, the minimum and current values are - adjusted if necessary (ensuring that the range remains valid and - that the current value is within the range). - - \sa maximum(), setRange(), rangeChanged() -*/ -void IntPropertyManager::setMaximum(PropertySheet* property, int maxVal) -{ - setMaximumValue(this, d_ptr.data(), - &IntPropertyManager::propertyChanged, - &IntPropertyManager::valueChanged, - &IntPropertyManager::rangeChanged, - property, maxVal); -} - -/*! - \fn void IntPropertyManager::setRange(PropertySheet *property, int minimum, int maximum) - - Sets the range of valid values. - - This is a convenience function defining the range of valid values - in one go; setting the \a minimum and \a maximum values for the - given \a property with a single function call. - - When setting a new range, the current value is adjusted if - necessary (ensuring that the value remains within range). - - \sa setMinimum(), setMaximum(), rangeChanged() -*/ -void IntPropertyManager::setRange(PropertySheet* property, int minVal, int maxVal) -{ - void (IntPropertyManagerPrivate:: * setSubPropertyRange)(PropertySheet*, int, int, int) = 0; - setBorderValues(this, d_ptr.data(), - &IntPropertyManager::propertyChanged, - &IntPropertyManager::valueChanged, - &IntPropertyManager::rangeChanged, - property, minVal, maxVal, setSubPropertyRange); -} - -/*! - Sets the step value for the given \a property to \a step. - - The step is typically used to increment or decrement a property value while pressing an arrow key. - - \sa singleStep() -*/ -void IntPropertyManager::setSingleStep(PropertySheet* property, int step) -{ - const IntPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - IntPropertyManagerPrivate::Data data = it.value(); - - if (step < 0) - step = 0; - - if (data.singleStep == step) - return; - - data.singleStep = step; - - it.value() = data; - - emit singleStepChanged(property, data.singleStep); -} - -/*! - \reimp -*/ -void IntPropertyManager::initializeProperty(PropertySheet* property) -{ - Q_D(IntPropertyManager); - d->m_values[property] = IntPropertyManagerPrivate::Data(); -} - -/*! - \reimp -*/ -void IntPropertyManager::uninitializeProperty(PropertySheet* property) -{ - Q_D(IntPropertyManager); - d->m_values.remove(property); -} diff --git a/QtRpa/modules/property/src/keysequencepropertymanager.c1 b/QtRpa/modules/property/src/keysequencepropertymanager.c1 deleted file mode 100644 index a2773bc..0000000 --- a/QtRpa/modules/property/src/keysequencepropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/keysequencepropertymanager.h" -#include "property/private/keysequencepropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -KeySequencePropertyManager::KeySequencePropertyManager(Object* parent /*= nullptr*/) - :KeySequencePropertyManager(*new KeySequencePropertyManagerPrivate, parent) -{ - -} -KeySequencePropertyManager::KeySequencePropertyManager(KeySequencePropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/lineeditfactory.cpp b/QtRpa/modules/property/src/lineeditfactory.cpp deleted file mode 100644 index 0fb653e..0000000 --- a/QtRpa/modules/property/src/lineeditfactory.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "property/framework.h" -#include "qlineedit.h" -#include "qvalidator.h" -#include "property/abstracteditorfactorybase.h" -#include "property/abstractpropertymanager.h" -#include "property/stringpropertymanager.h" -#include "property/abstracteditorfactory.h" -#include "property/lineeditfactory.h" -#include "private/qobject_p.h" -#include "property/private/abstracteditorfactorybaseprivate_p.h" -#include "property/private/abstracteditorfactoryprivate_p.h" -#include "property/private/editorfactoryprivate_p.h" -#include "property/private/lineeditfactory_p.h" -namespace shelllet { - namespace property { - - } -} - -using namespace shelllet::property; - - -void LineEditFactoryPrivate::slotPropertyChanged(PropertySheet* property, - const String& value) -{ - Q_Q(LineEditFactory); - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - for (QLineEdit* editor : it.value()) { - if (editor->text() != *value.toQString()) - editor->setText(*value.toQString()); - } -} - - -void LineEditFactoryPrivate::slotRegExpChanged(PropertySheet* property, - const QRegExp& regExp) -{ - Q_Q(LineEditFactory); - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - StringPropertyManager* manager = q->propertyManager(property); - if (!manager) - return; - - for (QLineEdit* editor : it.value()) { - editor->blockSignals(true); - const QValidator* oldValidator = editor->validator(); - QValidator* newValidator = 0; - if (regExp.isValid()) { - newValidator = new QRegExpValidator(regExp, editor); - } - editor->setValidator(newValidator); - if (oldValidator) - delete oldValidator; - editor->blockSignals(false); - } -} - -void LineEditFactoryPrivate::slotSetValue(const QString& value) -{ - Q_Q(LineEditFactory); - QObject* object = q->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - StringPropertyManager* manager = q->propertyManager(property); - if (!manager) - return; - manager->setValue(property, String::fromQString(&value)); - return; - } -} - - -//LineEditFactory::LineEditFactory(Object* parent /*= nullptr*/) -// :LineEditFactory(*new LineEditFactoryPrivate, nullptr, parent) -//{ - -//} -LineEditFactory::LineEditFactory(LineEditFactoryPrivate& d, QObject* parent, Object* /*parent*/ /*= nullptr*/) - : AbstractEditorFactory(d, parent) -{ - -} - - - - -LineEditFactory::LineEditFactory(QObject* parent) - : AbstractEditorFactory(*new LineEditFactoryPrivate(), parent) -{ -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -LineEditFactory::~LineEditFactory() -{ - Q_D(LineEditFactory); - qDeleteAll(d->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void LineEditFactory::connectPropertyManager(StringPropertyManager* manager) -{ - Q_D(LineEditFactory); - connect(manager, &StringPropertyManager::valueChanged, this, [d](auto... args) {d->slotPropertyChanged(std::forward(args)...); }); - connect(manager, &StringPropertyManager::regExpChanged, this, [d](auto... args) { d->slotRegExpChanged(std::forward(args)...); }); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* LineEditFactory::createEditor(StringPropertyManager* manager, - PropertySheet* property, QWidget* parent) -{ - Q_D(LineEditFactory); - QLineEdit* editor = d->createEditor(property, parent); - QRegExp regExp = manager->regExp(property); - if (regExp.isValid()) { - QValidator* validator = new QRegExpValidator(regExp, editor); - editor->setValidator(validator); - } - editor->setText(*manager->value(property).toQString()); - - connect(editor, &QLineEdit::textEdited, this, [d](auto... args) { - d->slotSetValue(std::forward(args)...); }); - connect(editor, &QLineEdit::destroyed, this, [d](auto... args) {d->slotEditorDestroyed(std::forward(args)...); }); - - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void LineEditFactory::disconnectPropertyManager(StringPropertyManager* manager) -{ - manager->disconnect(SIGNAL(valueChanged(PropertySheet*, const String&))); - manager->disconnect(SIGNAL(regExpChanged(PropertySheet*, const QRegExp&))); -} diff --git a/QtRpa/modules/property/src/localepropertymanager.c1 b/QtRpa/modules/property/src/localepropertymanager.c1 deleted file mode 100644 index 9b636c0..0000000 --- a/QtRpa/modules/property/src/localepropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/localepropertymanager.h" -#include "property/private/localepropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -LocalePropertyManager::LocalePropertyManager(Object* parent /*= nullptr*/) - :LocalePropertyManager(*new LocalePropertyManagerPrivate, parent) -{ - -} -LocalePropertyManager::LocalePropertyManager(LocalePropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/pointpropertymanager.c1 b/QtRpa/modules/property/src/pointpropertymanager.c1 deleted file mode 100644 index a6fe6bf..0000000 --- a/QtRpa/modules/property/src/pointpropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/pointpropertymanager.h" -#include "property/private/pointpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -PointPropertyManager::PointPropertyManager(Object* parent /*= nullptr*/) - :PointPropertyManager(*new PointPropertyManagerPrivate, parent) -{ - -} -PointPropertyManager::PointPropertyManager(PointPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/propertybrowser.cpp b/QtRpa/modules/property/src/propertybrowser.cpp deleted file mode 100644 index cb4003b..0000000 --- a/QtRpa/modules/property/src/propertybrowser.cpp +++ /dev/null @@ -1,711 +0,0 @@ -#include "common.hpp" -#include "qwidget.h" -#include "qtreewidget.h" -#include "qlayout.h" -#include "qheaderview.h" -#include "qitemdelegate.h" -#include "property/propertysheet.h" -#include "property/qtpropertybrowser.h" -#include "property/abstractpropertybrowser.h" -#include "property/qtpropertybrowser.h" -#include "property/propertybrowser.h" -#include "property/propertyeditordelegate.h" -#include "property/browseritem.h" -#include "property/propertyeditorview.h" -#include "private/qwidget_p.h" -#include "property/private/abstractpropertybrowser_p.h" -#include "property/private/propertybrowser_p.h" -#include "qstyle.h" -#include "qcoreapplication.h" -#include "qstyleoption.h" -namespace shelllet { - namespace property { - - } -} - -using namespace shelllet::property; - -PropertyBrowser::PropertyBrowser(QWidget* parentWidget, Object* parent /*= nullptr*/) - :PropertyBrowser(*new PropertyBrowserPrivate, parentWidget) -{ - -} -PropertyBrowser::PropertyBrowser(PropertyBrowserPrivate& d, QWidget* parentWidget, Object* parent /*= nullptr*/) - : AbstractPropertyBrowser(d, parentWidget) -{ - d.init(this); - connect(this, SIGNAL(currentItemChanged(BrowserItem*)), this, SLOT(slotCurrentBrowserItemChanged(BrowserItem*))); -} - - - -// -------- PropertyBrowserPrivate implementation -PropertyBrowserPrivate::PropertyBrowserPrivate() : - m_treeWidget(0), - m_headerVisible(true), - m_resizeMode(PropertyBrowser::Stretch), - m_delegate(0), - m_markPropertiesWithoutValue(false), - m_browserChangedBlocked(false) -{ -} - -// Draw an icon indicating opened/closing branches -static QIcon drawIndicatorIcon(const QPalette& palette, QStyle* style) -{ - QPixmap pix(14, 14); - pix.fill(Qt::transparent); - QStyleOption branchOption; - branchOption.rect = QRect(2, 2, 9, 9); // ### hardcoded in qcommonstyle.cpp - branchOption.palette = palette; - branchOption.state = QStyle::State_Children; - - QPainter p; - // Draw closed state - p.begin(&pix); - style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p); - p.end(); - QIcon rc = pix; - rc.addPixmap(pix, QIcon::Selected, QIcon::Off); - // Draw opened state - branchOption.state |= QStyle::State_Open; - pix.fill(Qt::transparent); - p.begin(&pix); - style->drawPrimitive(QStyle::PE_IndicatorBranch, &branchOption, &p); - p.end(); - - rc.addPixmap(pix, QIcon::Normal, QIcon::On); - rc.addPixmap(pix, QIcon::Selected, QIcon::On); - return rc; -} - -void PropertyBrowserPrivate::init(QWidget* parent) -{ - Q_Q(PropertyBrowser); - QHBoxLayout* layout = new QHBoxLayout(parent); - layout->setContentsMargins(QMargins()); - m_treeWidget = new PropertyEditorView(parent); - m_treeWidget->setEditorPrivate(this); - m_treeWidget->setIconSize(QSize(18, 18)); - layout->addWidget(m_treeWidget); - - m_treeWidget->setColumnCount(2); - QStringList labels; - labels.append(QCoreApplication::translate("PropertyBrowser", "Property")); - labels.append(QCoreApplication::translate("PropertyBrowser", "Value")); - m_treeWidget->setHeaderLabels(labels); - m_treeWidget->setAlternatingRowColors(true); - m_treeWidget->setEditTriggers(QAbstractItemView::EditKeyPressed); - m_delegate = new PropertyEditorDelegate(parent); - m_delegate->setEditorPrivate(this); - m_treeWidget->setItemDelegate(m_delegate); - m_treeWidget->header()->setSectionsMovable(false); - m_treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch); - - m_expandIcon = drawIndicatorIcon(q->palette(), q->style()); - - QObject::connect(m_treeWidget, SIGNAL(collapsed(QModelIndex)), q, SLOT(slotCollapsed(QModelIndex))); - QObject::connect(m_treeWidget, SIGNAL(expanded(QModelIndex)), q, SLOT(slotExpanded(QModelIndex))); - QObject::connect(m_treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), q, SLOT(slotCurrentTreeItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); -} - -BrowserItem* PropertyBrowserPrivate::currentItem() const -{ - if (QTreeWidgetItem* treeItem = m_treeWidget->currentItem()) - return m_itemToIndex.value(treeItem); - return 0; -} - -void PropertyBrowserPrivate::setCurrentItem(BrowserItem* browserItem, bool block) -{ - const bool blocked = block ? m_treeWidget->blockSignals(true) : false; - if (browserItem == 0) - m_treeWidget->setCurrentItem(0); - else - m_treeWidget->setCurrentItem(m_indexToItem.value(browserItem)); - if (block) - m_treeWidget->blockSignals(blocked); -} - -PropertySheet* PropertyBrowserPrivate::indexToProperty(const QModelIndex& index) const -{ - QTreeWidgetItem* item = m_treeWidget->indexToItem(index); - BrowserItem* idx = m_itemToIndex.value(item); - if (idx) - return idx->property(); - return 0; -} - -BrowserItem* PropertyBrowserPrivate::indexToBrowserItem(const QModelIndex& index) const -{ - QTreeWidgetItem* item = m_treeWidget->indexToItem(index); - return m_itemToIndex.value(item); -} - -QTreeWidgetItem* PropertyBrowserPrivate::indexToItem(const QModelIndex& index) const -{ - return m_treeWidget->indexToItem(index); -} - -bool PropertyBrowserPrivate::lastColumn(int column) const -{ - return m_treeWidget->header()->visualIndex(column) == m_treeWidget->columnCount() - 1; -} - -void PropertyBrowserPrivate::disableItem(QTreeWidgetItem* item) const -{ - Qt::ItemFlags flags = item->flags(); - if (flags & Qt::ItemIsEnabled) { - flags &= ~Qt::ItemIsEnabled; - item->setFlags(flags); - m_delegate->closeEditor(m_itemToIndex[item]->property()); - const int childCount = item->childCount(); - for (int i = 0; i < childCount; i++) { - QTreeWidgetItem* child = item->child(i); - disableItem(child); - } - } -} - -void PropertyBrowserPrivate::enableItem(QTreeWidgetItem* item) const -{ - Qt::ItemFlags flags = item->flags(); - flags |= Qt::ItemIsEnabled; - item->setFlags(flags); - const int childCount = item->childCount(); - for (int i = 0; i < childCount; i++) { - QTreeWidgetItem* child = item->child(i); - PropertySheet* property = m_itemToIndex[child]->property(); - if (property->isEnabled()) { - enableItem(child); - } - } -} - -bool PropertyBrowserPrivate::hasValue(QTreeWidgetItem* item) const -{ - BrowserItem* browserItem = m_itemToIndex.value(item); - if (browserItem) - return browserItem->property()->hasValue(); - return false; -} - -void PropertyBrowserPrivate::propertyInserted(BrowserItem* index, BrowserItem* afterIndex) -{ - QTreeWidgetItem* afterItem = m_indexToItem.value(afterIndex); - QTreeWidgetItem* parentItem = m_indexToItem.value(index->parent()); - - QTreeWidgetItem* newItem = 0; - if (parentItem) { - newItem = new QTreeWidgetItem(parentItem, afterItem); - } - else { - newItem = new QTreeWidgetItem(m_treeWidget, afterItem); - } - m_itemToIndex[newItem] = index; - m_indexToItem[index] = newItem; - - newItem->setFlags(newItem->flags() | Qt::ItemIsEditable); - newItem->setExpanded(true); - - updateItem(newItem); -} - -void PropertyBrowserPrivate::propertyRemoved(BrowserItem* index) -{ - QTreeWidgetItem* item = m_indexToItem.value(index); - - if (m_treeWidget->currentItem() == item) { - m_treeWidget->setCurrentItem(0); - } - - delete item; - - m_indexToItem.remove(index); - m_itemToIndex.remove(item); - m_indexToBackgroundColor.remove(index); -} - -void PropertyBrowserPrivate::propertyChanged(BrowserItem* index) -{ - QTreeWidgetItem* item = m_indexToItem.value(index); - - updateItem(item); -} - -void PropertyBrowserPrivate::updateItem(QTreeWidgetItem* item) -{ - PropertySheet* property = m_itemToIndex[item]->property(); - QIcon expandIcon; - if (property->hasValue()) { - const QString valueToolTip = property->valueToolTip(); - const String valueText = property->valueText(); - item->setToolTip(1, valueToolTip.isEmpty() ? *valueText.toQString() : valueToolTip); - item->setIcon(1, property->valueIcon()); - item->setText(1, *valueText.toQString()); - } - else if (markPropertiesWithoutValue() && !m_treeWidget->rootIsDecorated()) { - expandIcon = m_expandIcon; - } - item->setIcon(0, expandIcon); - item->setFirstColumnSpanned(!property->hasValue()); - const QString descriptionToolTip = property->descriptionToolTip(); - const QString propertyName = property->propertyName(); - item->setToolTip(0, descriptionToolTip.isEmpty() ? propertyName : descriptionToolTip); - item->setStatusTip(0, property->statusTip()); - item->setWhatsThis(0, property->whatsThis()); - item->setText(0, propertyName); - bool wasEnabled = item->flags() & Qt::ItemIsEnabled; - bool isEnabled = wasEnabled; - if (property->isEnabled()) { - QTreeWidgetItem* parent = item->parent(); - if (!parent || (parent->flags() & Qt::ItemIsEnabled)) - isEnabled = true; - else - isEnabled = false; - } - else { - isEnabled = false; - } - if (wasEnabled != isEnabled) { - if (isEnabled) - enableItem(item); - else - disableItem(item); - } - m_treeWidget->viewport()->update(); -} - -QColor PropertyBrowserPrivate::calculatedBackgroundColor(BrowserItem* item) const -{ - BrowserItem* i = item; - const QMap::const_iterator itEnd = m_indexToBackgroundColor.constEnd(); - while (i) { - QMap::const_iterator it = m_indexToBackgroundColor.constFind(i); - if (it != itEnd) - return it.value(); - i = i->parent(); - } - return QColor(); -} - -void PropertyBrowserPrivate::slotCollapsed(const QModelIndex& index) -{ - Q_Q(PropertyBrowser); - QTreeWidgetItem* item = indexToItem(index); - BrowserItem* idx = m_itemToIndex.value(item); - if (item) - emit q->collapsed(idx); -} - -void PropertyBrowserPrivate::slotExpanded(const QModelIndex& index) -{ - Q_Q(PropertyBrowser); - QTreeWidgetItem* item = indexToItem(index); - BrowserItem* idx = m_itemToIndex.value(item); - if (item) - emit q->expanded(idx); -} - -void PropertyBrowserPrivate::slotCurrentBrowserItemChanged(BrowserItem* item) -{ - if (!m_browserChangedBlocked && item != currentItem()) - setCurrentItem(item, true); -} - -void PropertyBrowserPrivate::slotCurrentTreeItemChanged(QTreeWidgetItem* newItem, QTreeWidgetItem*) -{ - Q_Q(PropertyBrowser); - BrowserItem* browserItem = newItem ? m_itemToIndex.value(newItem) : 0; - m_browserChangedBlocked = true; - q->setCurrentItem(browserItem); - m_browserChangedBlocked = false; -} - -QTreeWidgetItem* PropertyBrowserPrivate::editedItem() const -{ - return m_delegate->editedItem(); -} - -void PropertyBrowserPrivate::editItem(BrowserItem* browserItem) -{ - if (QTreeWidgetItem* treeItem = m_indexToItem.value(browserItem, 0)) { - m_treeWidget->setCurrentItem(treeItem, 1); - m_treeWidget->editItem(treeItem, 1); - } -} - -/*! - \class PropertyBrowser - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The PropertyBrowser class provides QTreeWidget based - property browser. - - A property browser is a widget that enables the user to edit a - given set of properties. Each property is represented by a label - specifying the property's name, and an editing widget (e.g. a line - edit or a combobox) holding its value. A property can have zero or - more subproperties. - - PropertyBrowser provides a tree based view for all nested - properties, i.e. properties that have subproperties can be in an - expanded (subproperties are visible) or collapsed (subproperties - are hidden) state. For example: - - \image qttreepropertybrowser.png - - Use the QtAbstractPropertyBrowser API to add, insert and remove - properties from an instance of the PropertyBrowser class. - The properties themselves are created and managed by - implementations of the QtAbstractPropertyManager class. - - \sa QtGroupBoxPropertyBrowser, QtAbstractPropertyBrowser -*/ - -/*! - \fn void PropertyBrowser::collapsed(BrowserItem *item) - - This signal is emitted when the \a item is collapsed. - - \sa expanded(), setExpanded() -*/ - -/*! - \fn void PropertyBrowser::expanded(BrowserItem *item) - - This signal is emitted when the \a item is expanded. - - \sa collapsed(), setExpanded() -*/ - -/*! - Creates a property browser with the given \a parent. -*/ - -/*! - Destroys this property browser. - - Note that the properties that were inserted into this browser are - \e not destroyed since they may still be used in other - browsers. The properties are owned by the manager that created - them. - - \sa PropertySheet, QtAbstractPropertyManager -*/ -PropertyBrowser::~PropertyBrowser() -{ -} - -/*! - \property PropertyBrowser::indentation - \brief indentation of the items in the tree view. -*/ -int PropertyBrowser::indentation() const -{ - Q_D(const PropertyBrowser); - return d->m_treeWidget->indentation(); -} - -void PropertyBrowser::setIndentation(int i) -{ - Q_D(PropertyBrowser); - d->m_treeWidget->setIndentation(i); -} - -/*! - \property PropertyBrowser::rootIsDecorated - \brief whether to show controls for expanding and collapsing root items. -*/ -bool PropertyBrowser::rootIsDecorated() const -{ - Q_D(const PropertyBrowser); - return d->m_treeWidget->rootIsDecorated(); -} - -void PropertyBrowser::setRootIsDecorated(bool show) -{ - Q_D(PropertyBrowser); - d->m_treeWidget->setRootIsDecorated(show); - for (auto it = d->m_itemToIndex.cbegin(), end = d->m_itemToIndex.cend(); it != end; ++it) { - PropertySheet* property = it.value()->property(); - if (!property->hasValue()) - d->updateItem(it.key()); - } -} - -/*! - \property PropertyBrowser::alternatingRowColors - \brief whether to draw the background using alternating colors. - By default this property is set to true. -*/ -bool PropertyBrowser::alternatingRowColors() const -{ - Q_D(const PropertyBrowser); - return d->m_treeWidget->alternatingRowColors(); -} - -void PropertyBrowser::setAlternatingRowColors(bool enable) -{ - Q_D(const PropertyBrowser); - d->m_treeWidget->setAlternatingRowColors(enable); -} - -/*! - \property PropertyBrowser::headerVisible - \brief whether to show the header. -*/ -bool PropertyBrowser::isHeaderVisible() const -{ - Q_D(const PropertyBrowser); - return d->m_headerVisible; -} - -void PropertyBrowser::setHeaderVisible(bool visible) -{ - Q_D(PropertyBrowser); - if (d->m_headerVisible == visible) - return; - - d->m_headerVisible = visible; - d->m_treeWidget->header()->setVisible(visible); -} - -/*! - \enum PropertyBrowser::ResizeMode - - The resize mode specifies the behavior of the header sections. - - \value Interactive The user can resize the sections. - The sections can also be resized programmatically using setSplitterPosition(). - - \value Fixed The user cannot resize the section. - The section can only be resized programmatically using setSplitterPosition(). - - \value Stretch QHeaderView will automatically resize the section to fill the available space. - The size cannot be changed by the user or programmatically. - - \value ResizeToContents QHeaderView will automatically resize the section to its optimal - size based on the contents of the entire column. - The size cannot be changed by the user or programmatically. - - \sa setResizeMode() -*/ - -/*! - \property PropertyBrowser::resizeMode - \brief the resize mode of setions in the header. -*/ - -PropertyBrowser::ResizeMode PropertyBrowser::resizeMode() const -{ - Q_D(const PropertyBrowser); - return d->m_resizeMode; -} - -void PropertyBrowser::setResizeMode(PropertyBrowser::ResizeMode mode) -{ - Q_D(PropertyBrowser); - if (d->m_resizeMode == mode) - return; - - d->m_resizeMode = mode; - QHeaderView::ResizeMode m = QHeaderView::Stretch; - switch (mode) { - case PropertyBrowser::Interactive: m = QHeaderView::Interactive; break; - case PropertyBrowser::Fixed: m = QHeaderView::Fixed; break; - case PropertyBrowser::ResizeToContents: m = QHeaderView::ResizeToContents; break; - case PropertyBrowser::Stretch: - default: m = QHeaderView::Stretch; break; - } - d->m_treeWidget->header()->setSectionResizeMode(m); -} - -/*! - \property PropertyBrowser::splitterPosition - \brief the position of the splitter between the colunms. -*/ - -int PropertyBrowser::splitterPosition() const -{ - Q_D(const PropertyBrowser); - return d->m_treeWidget->header()->sectionSize(0); -} - -void PropertyBrowser::setSplitterPosition(int position) -{ - Q_D( PropertyBrowser); - d->m_treeWidget->header()->resizeSection(0, position); -} - -/*! - Sets the \a item to either collapse or expanded, depending on the value of \a expanded. - - \sa isExpanded(), expanded(), collapsed() -*/ - -void PropertyBrowser::setExpanded(BrowserItem* item, bool expanded) -{ - Q_D(PropertyBrowser); - QTreeWidgetItem* treeItem = d->m_indexToItem.value(item); - if (treeItem) - treeItem->setExpanded(expanded); -} - -/*! - Returns true if the \a item is expanded; otherwise returns false. - - \sa setExpanded() -*/ - -bool PropertyBrowser::isExpanded(BrowserItem* item) const -{ - Q_D(const PropertyBrowser); - QTreeWidgetItem* treeItem = d->m_indexToItem.value(item); - if (treeItem) - return treeItem->isExpanded(); - return false; -} - -/*! - Returns true if the \a item is visible; otherwise returns false. - - \sa setItemVisible() - \since 4.5 -*/ - -bool PropertyBrowser::isItemVisible(BrowserItem* item) const -{ - Q_D(const PropertyBrowser); - if (const QTreeWidgetItem* treeItem = d->m_indexToItem.value(item)) - return !treeItem->isHidden(); - return false; -} - -/*! - Sets the \a item to be visible, depending on the value of \a visible. - - \sa isItemVisible() - \since 4.5 -*/ - -void PropertyBrowser::setItemVisible(BrowserItem* item, bool visible) -{ - Q_D(const PropertyBrowser); - if (QTreeWidgetItem* treeItem = d->m_indexToItem.value(item)) - treeItem->setHidden(!visible); -} - -/*! - Sets the \a item's background color to \a color. Note that while item's background - is rendered every second row is being drawn with alternate color (which is a bit lighter than items \a color) - - \sa backgroundColor(), calculatedBackgroundColor() -*/ - -void PropertyBrowser::setBackgroundColor(BrowserItem* item, const QColor& color) -{ - Q_D(PropertyBrowser); - if (!d->m_indexToItem.contains(item)) - return; - if (color.isValid()) - d->m_indexToBackgroundColor[item] = color; - else - d->m_indexToBackgroundColor.remove(item); - d->m_treeWidget->viewport()->update(); -} - -/*! - Returns the \a item's color. If there is no color set for item it returns invalid color. - - \sa calculatedBackgroundColor(), setBackgroundColor() -*/ - -QColor PropertyBrowser::backgroundColor(BrowserItem* item) const -{ - Q_D(const PropertyBrowser); - return d->m_indexToBackgroundColor.value(item); -} - -/*! - Returns the \a item's color. If there is no color set for item it returns parent \a item's - color (if there is no color set for parent it returns grandparent's color and so on). In case - the color is not set for \a item and it's top level item it returns invalid color. - - \sa backgroundColor(), setBackgroundColor() -*/ - -QColor PropertyBrowser::calculatedBackgroundColor(BrowserItem* item) const -{ - Q_D(const PropertyBrowser); - return d->calculatedBackgroundColor(item); -} - -/*! - \property PropertyBrowser::propertiesWithoutValueMarked - \brief whether to enable or disable marking properties without value. - - When marking is enabled the item's background is rendered in dark color and item's - foreground is rendered with light color. - - \sa propertiesWithoutValueMarked() -*/ -void PropertyBrowser::setPropertiesWithoutValueMarked(bool mark) -{ - Q_D(PropertyBrowser); - if (d->m_markPropertiesWithoutValue == mark) - return; - - d->m_markPropertiesWithoutValue = mark; - for (auto it = d->m_itemToIndex.cbegin(), end = d->m_itemToIndex.cend(); it != end; ++it) { - PropertySheet* property = it.value()->property(); - if (!property->hasValue()) - d->updateItem(it.key()); - } - d->m_treeWidget->viewport()->update(); -} - -bool PropertyBrowser::propertiesWithoutValueMarked() const -{ - Q_D(const PropertyBrowser); - return d->m_markPropertiesWithoutValue; -} - -/*! - \reimp -*/ -void PropertyBrowser::itemInserted(BrowserItem* item, BrowserItem* afterItem) -{ - Q_D(PropertyBrowser); - d->propertyInserted(item, afterItem); -} - -/*! - \reimp -*/ -void PropertyBrowser::itemRemoved(BrowserItem* item) -{ - Q_D(PropertyBrowser); - d->propertyRemoved(item); -} - -/*! - \reimp -*/ -void PropertyBrowser::itemChanged(BrowserItem* item) -{ - Q_D(PropertyBrowser); - d->propertyChanged(item); -} - -/*! - Sets the current item to \a item and opens the relevant editor for it. -*/ -void PropertyBrowser::editItem(BrowserItem* item) -{ - Q_D(PropertyBrowser); - d->editItem(item); -} diff --git a/QtRpa/modules/property/src/propertyeditordelegate.cpp b/QtRpa/modules/property/src/propertyeditordelegate.cpp deleted file mode 100644 index 690f1ee..0000000 --- a/QtRpa/modules/property/src/propertyeditordelegate.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include "property/framework.h" -#include "qitemdelegate.h" -#include "qtreewidget.h" -#include "qpainter.h" -#include "qapplication.h" -#include "property/propertysheet.h" -#include "property/qtpropertybrowser.h" -#include "property/abstractpropertybrowser.h" -#include "property/propertybrowser.h" -#include "property/browseritem.h" -#include "property/propertyeditorview.h" -#include "private/qwidget_p.h" -#include "property/private/abstractpropertybrowser_p.h" -#include "property/private/propertybrowser_p.h" -#include "property/propertyeditordelegate.h" -#include "property/private/propertyeditordelegate_p.h" -#include "common/wobjectimpl.h" -namespace shelllet { - namespace property { - - - - } -} -using namespace shelllet::property; - -W_OBJECT_IMPL(PropertyEditorDelegate) -PropertyEditorDelegate::PropertyEditorDelegate(Object* parent /*= nullptr*/) - :PropertyEditorDelegate(*new PropertyEditorDelegatePrivate, nullptr, parent) -{ - -} - -PropertyEditorDelegate::PropertyEditorDelegate(QObject* parent /*= 0*/) - : PropertyEditorDelegate(*new PropertyEditorDelegatePrivate, parent) -{ - -} - -PropertyEditorDelegate::PropertyEditorDelegate(PropertyEditorDelegatePrivate& d, QObject* parent1, Object* parent /*= nullptr*/) - : QItemDelegate(parent1) - , m_editorPrivate(0), m_editedItem(0), m_editedWidget(0) -{ - -} - - - - -int PropertyEditorDelegate::indentation(const QModelIndex& index) const -{ - if (!m_editorPrivate) - return 0; - - QTreeWidgetItem* item = m_editorPrivate->indexToItem(index); - int indent = 0; - while (item->parent()) { - item = item->parent(); - ++indent; - } - if (m_editorPrivate->treeWidget()->rootIsDecorated()) - ++indent; - return indent * m_editorPrivate->treeWidget()->indentation(); -} - -void PropertyEditorDelegate::slotEditorDestroyed(QObject* object) -{ - if (QWidget* w = qobject_cast(object)) { - const EditorToPropertyMap::iterator it = m_editorToProperty.find(w); - if (it != m_editorToProperty.end()) { - m_propertyToEditor.remove(it.value()); - m_editorToProperty.erase(it); - } - if (m_editedWidget == w) { - m_editedWidget = 0; - m_editedItem = 0; - } - } -} - -void PropertyEditorDelegate::closeEditor(PropertySheet* property) -{ - if (QWidget* w = m_propertyToEditor.value(property, 0)) - w->deleteLater(); -} - -QWidget* PropertyEditorDelegate::createEditor(QWidget* parent, - const QStyleOptionViewItem&, const QModelIndex& index) const -{ - if (index.column() == 1 && m_editorPrivate) { - PropertySheet* property = m_editorPrivate->indexToProperty(index); - QTreeWidgetItem* item = m_editorPrivate->indexToItem(index); - if (property && item && (item->flags() & Qt::ItemIsEnabled)) { - QWidget* editor = m_editorPrivate->createEditor(property, parent); - if (editor) { - editor->setAutoFillBackground(true); - editor->installEventFilter(const_cast(this)); - connect(editor, &QWidget::destroyed, this, &PropertyEditorDelegate::slotEditorDestroyed); - m_propertyToEditor[property] = editor; - m_editorToProperty[editor] = property; - m_editedItem = item; - m_editedWidget = editor; - } - return editor; - } - } - return 0; -} - -void PropertyEditorDelegate::updateEditorGeometry(QWidget* editor, - const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - Q_UNUSED(index); - editor->setGeometry(option.rect.adjusted(0, 0, 0, -1)); -} - -void PropertyEditorDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ - bool hasValue = true; - if (m_editorPrivate) { - PropertySheet* property = m_editorPrivate->indexToProperty(index); - if (property) - hasValue = property->hasValue(); - } - QStyleOptionViewItem opt = option; - if ((m_editorPrivate && index.column() == 0) || !hasValue) { - PropertySheet* property = m_editorPrivate->indexToProperty(index); - if (property && property->isModified()) { - opt.font.setBold(true); - opt.fontMetrics = QFontMetrics(opt.font); - } - } - QColor c; - if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { - c = opt.palette.color(QPalette::Dark); - opt.palette.setColor(QPalette::Text, opt.palette.color(QPalette::BrightText)); - } - else { - c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index)); - if (c.isValid() && (opt.features & QStyleOptionViewItem::Alternate)) - c = c.lighter(112); - } - if (c.isValid()) - painter->fillRect(option.rect, c); - opt.state &= ~QStyle::State_HasFocus; - QItemDelegate::paint(painter, opt, index); - - opt.palette.setCurrentColorGroup(QPalette::Active); - QColor color = static_cast(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt)); - painter->save(); - painter->setPen(QPen(color)); - if (!m_editorPrivate || (!m_editorPrivate->lastColumn(index.column()) && hasValue)) { - int right = (option.direction == Qt::LeftToRight) ? option.rect.right() : option.rect.left(); - painter->drawLine(right, option.rect.y(), right, option.rect.bottom()); - } - painter->restore(); -} - -QSize PropertyEditorDelegate::sizeHint(const QStyleOptionViewItem& option, - const QModelIndex& index) const -{ - return QItemDelegate::sizeHint(option, index) + QSize(3, 4); -} - -bool PropertyEditorDelegate::eventFilter(QObject* object, QEvent* event) -{ - if (event->type() == QEvent::FocusOut) { - QFocusEvent* fe = static_cast(event); - if (fe->reason() == Qt::ActiveWindowFocusReason) - return false; - } - return QItemDelegate::eventFilter(object, event); -} diff --git a/QtRpa/modules/property/src/propertyeditorview.cpp b/QtRpa/modules/property/src/propertyeditorview.cpp deleted file mode 100644 index 2e390f3..0000000 --- a/QtRpa/modules/property/src/propertyeditorview.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "property/framework.h" -#include "qtreewidget.h" -#include "qpainter.h" -#include "qheaderview.h" -#include "property/propertysheet.h" -#include "property/qtpropertybrowser.h" - -#include "property/abstractpropertybrowser.h" -#include "property/propertybrowser.h" -#include "property/propertyeditorview.h" -#include "private/qwidget_p.h" -#include "property/private/abstractpropertybrowser_p.h" -#include "property/private/propertybrowser_p.h" -#include "property/private/propertyeditorview_p.h" -#include "common/wobjectimpl.h" -namespace shelllet { - namespace property { - - } -} -using namespace shelllet::property; - -W_OBJECT_IMPL(PropertyEditorView) -PropertyEditorView::PropertyEditorView(Object* parent /*= nullptr*/) - :PropertyEditorView(*new PropertyEditorViewPrivate,nullptr, parent) -{ - -} -PropertyEditorView::PropertyEditorView(PropertyEditorViewPrivate& d, QWidget* parent1/* = 0*/, Object* parent /*= nullptr*/) - : QTreeWidget(parent1) - , - m_editorPrivate(0) - //, Object(d, parent) -{ - -} - - -PropertyEditorView::PropertyEditorView(QWidget* parent) : - PropertyEditorView(*new PropertyEditorViewPrivate, parent) -{ - connect(header(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(resizeColumnToContents(int))); -} - -void PropertyEditorView::drawRow(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - QStyleOptionViewItem opt = option; - bool hasValue = true; - if (m_editorPrivate) { - PropertySheet* property = m_editorPrivate->indexToProperty(index); - if (property) - hasValue = property->hasValue(); - } - if (!hasValue && m_editorPrivate->markPropertiesWithoutValue()) { - const QColor c = option.palette.color(QPalette::Dark); - painter->fillRect(option.rect, c); - opt.palette.setColor(QPalette::AlternateBase, c); - } - else { - const QColor c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index)); - if (c.isValid()) { - painter->fillRect(option.rect, c); - opt.palette.setColor(QPalette::AlternateBase, c.lighter(112)); - } - } - QTreeWidget::drawRow(painter, opt, index); - QColor color = static_cast(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt)); - painter->save(); - painter->setPen(QPen(color)); - painter->drawLine(opt.rect.x(), opt.rect.bottom(), opt.rect.right(), opt.rect.bottom()); - painter->restore(); -} - -void PropertyEditorView::keyPressEvent(QKeyEvent* event) -{ - switch (event->key()) { - case Qt::Key_Return: - case Qt::Key_Enter: - case Qt::Key_Space: // Trigger Edit - if (!m_editorPrivate->editedItem()) - if (const QTreeWidgetItem* item = currentItem()) - if (item->columnCount() >= 2 && ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled))) { - event->accept(); - // If the current position is at column 0, move to 1. - QModelIndex index = currentIndex(); - if (index.column() == 0) { - index = index.sibling(index.row(), 1); - setCurrentIndex(index); - } - edit(index); - return; - } - break; - default: - break; - } - QTreeWidget::keyPressEvent(event); -} - -void PropertyEditorView::mousePressEvent(QMouseEvent* event) -{ - QTreeWidget::mousePressEvent(event); - QTreeWidgetItem* item = itemAt(event->pos()); - - if (item) { - if ((item != m_editorPrivate->editedItem()) && (event->button() == Qt::LeftButton) - && (header()->logicalIndexAt(event->pos().x()) == 1) - && ((item->flags() & (Qt::ItemIsEditable | Qt::ItemIsEnabled)) == (Qt::ItemIsEditable | Qt::ItemIsEnabled))) { - editItem(item, 1); - } - else if (!m_editorPrivate->hasValue(item) && m_editorPrivate->markPropertiesWithoutValue() && !rootIsDecorated()) { - if (event->pos().x() + header()->offset() < 20) - item->setExpanded(!item->isExpanded()); - } - } -} \ No newline at end of file diff --git a/QtRpa/modules/property/src/propertysheet.cpp b/QtRpa/modules/property/src/propertysheet.cpp deleted file mode 100644 index 0edf5a6..0000000 --- a/QtRpa/modules/property/src/propertysheet.cpp +++ /dev/null @@ -1,482 +0,0 @@ -#include "common.hpp" -#include "property/propertysheet.h" -#include "property/abstractpropertymanager.h" -#include "private/qobject_p.h" -#include "property/private/propertysheet_p.h" -#include "property/private/abstractpropertymanager_p.h" -#include "property/qtpropertybrowser.h" -using namespace shelllet::property; -namespace shelllet { - namespace property { - - } - -} - -PropertySheet::PropertySheet(PropertySheetPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - - - -/*! - \class PropertySheet - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The PropertySheet class encapsulates an instance of a property. - - Properties are created by objects of QtAbstractPropertyManager - subclasses; a manager can create properties of a given type, and - is used in conjunction with the QtAbstractPropertyBrowser class. A - property is always owned by the manager that created it, which can - be retrieved using the propertyManager() function. - - PropertySheet contains the most common property attributes, and - provides functions for retrieving as well as setting their values: - - \table - \header \li Getter \li Setter - \row - \li propertyName() \li setPropertyName() - \row - \li statusTip() \li setStatusTip() - \row - \li descriptionToolTip() \li setDescriptionToolTip() - \row - \li valueToolTip() \li setValueToolTip() - \row - \li toolTip() \deprecated in 5.6 \li setToolTip() \deprecated in 5.6 - \row - \li whatsThis() \li setWhatsThis() - \row - \li isEnabled() \li setEnabled() - \row - \li isModified() \li setModified() - \row - \li valueText() \li Nop - \row - \li valueIcon() \li Nop - \endtable - - It is also possible to nest properties: PropertySheet provides the - addSubProperty(), insertSubProperty() and removeSubProperty() functions to - manipulate the set of subproperties. Use the subProperties() - function to retrieve a property's current set of subproperties. - Note that nested properties are not owned by the parent property, - i.e. each subproperty is owned by the manager that created it. - - \sa QtAbstractPropertyManager, QtBrowserItem -*/ - -/*! - Creates a property with the given \a manager. - - This constructor is only useful when creating a custom PropertySheet - subclass (e.g. QtVariantProperty). To create a regular PropertySheet - object, use the QtAbstractPropertyManager::addProperty() - function instead. - - \sa QtAbstractPropertyManager::addProperty() -*/ -PropertySheet::PropertySheet(AbstractPropertyManager* manager) - : PropertySheet(*new PropertySheetPrivate(manager), nullptr) -{ -} - -/*! - Destroys this property. - - Note that subproperties are detached but not destroyed, i.e. they - can still be used in another context. - - \sa QtAbstractPropertyManager::clear() - -*/ -PropertySheet::~PropertySheet() -{ - Q_D(PropertySheet); - for (PropertySheet* property : qAsConst(d->m_parentItems)) - d->m_manager->d_func()->propertyRemoved(this, property); - - d->m_manager->d_func()->propertyDestroyed(this); - - for (PropertySheet* property : qAsConst(d->m_subItems)) - property->d_func()->m_parentItems.remove(this); - - for (PropertySheet* property : qAsConst(d->m_parentItems)) - property->d_func()->m_subItems.removeAll(this); -} - -/*! - Returns the set of subproperties. - - Note that subproperties are not owned by \e this property, but by - the manager that created them. - - \sa insertSubProperty(), removeSubProperty() -*/ -QList PropertySheet::subProperties() const -{ - Q_D(const PropertySheet); - return d->m_subItems; -} - -/*! - Returns a pointer to the manager that owns this property. -*/ -AbstractPropertyManager* PropertySheet::propertyManager() const -{ - Q_D(const PropertySheet); - return d->m_manager; -} - -/* Note: As of 17.7.2015 for Qt 5.6, the existing 'toolTip' of the Property - * Browser solution was split into valueToolTip() and descriptionToolTip() - * to be able to implement custom tool tip for QTBUG-45442. This could - * be back-ported to the solution. */ - - /*! - Returns the property value's tool tip. - - This is suitable for tool tips over the value (item delegate). - - \since 5.6 - \sa setValueToolTip() - */ -QString PropertySheet::valueToolTip() const -{ - Q_D(const PropertySheet); - return d->m_valueToolTip; -} - -/*! - Returns the property description's tool tip. - - This is suitable for tool tips over the description (label). - - \since 5.6 - \sa setDescriptionToolTip() -*/ -QString PropertySheet::descriptionToolTip() const -{ - Q_D(const PropertySheet); - return d->m_descriptionToolTip; -} - -/*! - Returns the property's status tip. - - \sa setStatusTip() -*/ -QString PropertySheet::statusTip() const -{ - Q_D(const PropertySheet); - return d->m_statusTip; -} - -/*! - Returns the property's "What's This" help text. - - \sa setWhatsThis() -*/ -QString PropertySheet::whatsThis() const -{ - Q_D(const PropertySheet); - return d->m_whatsThis; -} - -/*! - Returns the property's name. - - \sa setPropertyName() -*/ -QString PropertySheet::propertyName() const -{ - Q_D(const PropertySheet); - return d->m_name; -} - -/*! - Returns whether the property is enabled. - - \sa setEnabled() -*/ -bool PropertySheet::isEnabled() const -{ - Q_D(const PropertySheet); - return d->m_enabled; -} - -/*! - Returns whether the property is modified. - - \sa setModified() -*/ -bool PropertySheet::isModified() const -{ - Q_D(const PropertySheet); - return d->m_modified; -} - -/*! - Returns whether the property has a value. - - \sa QtAbstractPropertyManager::hasValue() -*/ -bool PropertySheet::hasValue() const -{ - Q_D(const PropertySheet); - return d->m_manager->hasValue(this); -} - -/*! - Returns an icon representing the current state of this property. - - If the given property type can not generate such an icon, this - function returns an invalid icon. - - \sa QtAbstractPropertyManager::valueIcon() -*/ -QIcon PropertySheet::valueIcon() const -{ - Q_D(const PropertySheet); - return d->m_manager->valueIcon(this); -} - -/*! - Returns a string representing the current state of this property. - - If the given property type can not generate such a string, this - function returns an empty string. - - \sa QtAbstractPropertyManager::valueText() -*/ -String PropertySheet::valueText() const -{ - Q_D(const PropertySheet); - return d->m_manager->valueText(this); -} - -/*! - Sets the property value's tool tip to the given \a text. - - \since 5.6 - \sa valueToolTip() -*/ -void PropertySheet::setValueToolTip(const QString& text) -{ - Q_D(PropertySheet); - if (d->m_valueToolTip == text) - return; - - d->m_valueToolTip = text; - propertyChanged(); -} - -/*! - Sets the property description's tool tip to the given \a text. - - \since 5.6 - \sa descriptionToolTip() -*/ -void PropertySheet::setDescriptionToolTip(const QString& text) -{ - Q_D( PropertySheet); - if (d->m_descriptionToolTip == text) - return; - - d->m_descriptionToolTip = text; - propertyChanged(); -} - -/*! - Sets the property's status tip to the given \a text. - - \sa statusTip() -*/ -void PropertySheet::setStatusTip(const QString& text) -{ - Q_D(PropertySheet); - if (d->m_statusTip == text) - return; - - d->m_statusTip = text; - propertyChanged(); -} - -/*! - Sets the property's "What's This" help text to the given \a text. - - \sa whatsThis() -*/ -void PropertySheet::setWhatsThis(const QString& text) -{ - Q_D(PropertySheet); - if (d->m_whatsThis == text) - return; - - d->m_whatsThis = text; - propertyChanged(); -} - -/*! - \fn void PropertySheet::setPropertyName(const QString &name) - - Sets the property's name to the given \a name. - - \sa propertyName() -*/ -void PropertySheet::setPropertyName(const QString& text) -{ - Q_D(PropertySheet); - if (d->m_name == text) - return; - - d->m_name = text; - propertyChanged(); -} - -/*! - Enables or disables the property according to the passed \a enable value. - - \sa isEnabled() -*/ -void PropertySheet::setEnabled(bool enable) -{ - Q_D(PropertySheet); - if (d->m_enabled == enable) - return; - - d->m_enabled = enable; - propertyChanged(); -} - -/*! - Sets the property's modified state according to the passed \a modified value. - - \sa isModified() -*/ -void PropertySheet::setModified(bool modified) -{ - Q_D(PropertySheet); - if (d->m_modified == modified) - return; - - d->m_modified = modified; - propertyChanged(); -} - -/*! - Appends the given \a property to this property's subproperties. - - If the given \a property already is added, this function does - nothing. - - \sa insertSubProperty(), removeSubProperty() -*/ -void PropertySheet::addSubProperty(PropertySheet* property) -{ - Q_D(PropertySheet); - PropertySheet* after = 0; - if (d->m_subItems.count() > 0) - after = d->m_subItems.last(); - insertSubProperty(property, after); -} - -/*! - \fn void PropertySheet::insertSubProperty(PropertySheet *property, PropertySheet *precedingProperty) - - Inserts the given \a property after the specified \a - precedingProperty into this property's list of subproperties. If - \a precedingProperty is 0, the specified \a property is inserted - at the beginning of the list. - - If the given \a property already is inserted, this function does - nothing. - - \sa addSubProperty(), removeSubProperty() -*/ -void PropertySheet::insertSubProperty(PropertySheet* property, - PropertySheet* afterProperty) -{ - Q_D(PropertySheet); - if (!property) - return; - - if (property == this) - return; - - // traverse all children of item. if this item is a child of item then cannot add. - QList pendingList = property->subProperties(); - QMap visited; - while (!pendingList.isEmpty()) { - PropertySheet* i = pendingList.first(); - if (i == this) - return; - pendingList.removeFirst(); - if (visited.contains(i)) - continue; - visited[i] = true; - pendingList += i->subProperties(); - } - - pendingList = subProperties(); - int pos = 0; - int newPos = 0; - PropertySheet* properAfterProperty = 0; - while (pos < pendingList.count()) { - PropertySheet* i = pendingList.at(pos); - if (i == property) - return; // if item is already inserted in this item then cannot add. - if (i == afterProperty) { - newPos = pos + 1; - properAfterProperty = afterProperty; - } - pos++; - } - - d->m_subItems.insert(newPos, property); - property->d_func()->m_parentItems.insert(this); - - d->m_manager->d_func()->propertyInserted(property, this, properAfterProperty); -} - -/*! - Removes the given \a property from the list of subproperties - without deleting it. - - \sa addSubProperty(), insertSubProperty() -*/ -void PropertySheet::removeSubProperty(PropertySheet* property) -{ - Q_D(PropertySheet); - if (!property) - return; - - d->m_manager->d_func()->propertyRemoved(property, this); - - QList pendingList = subProperties(); - int pos = 0; - while (pos < pendingList.count()) { - if (pendingList.at(pos) == property) { - d->m_subItems.removeAt(pos); - property->d_func()->m_parentItems.remove(this); - - return; - } - pos++; - } -} - -/*! - \internal -*/ -void PropertySheet::propertyChanged() -{ - Q_D(PropertySheet); - d->m_manager->d_func()->propertyChanged(this); -} diff --git a/QtRpa/modules/property/src/qteditorfactory.cpp1 b/QtRpa/modules/property/src/qteditorfactory.cpp1 deleted file mode 100644 index 59c7473..0000000 --- a/QtRpa/modules/property/src/qteditorfactory.cpp1 +++ /dev/null @@ -1,2338 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "property/framework.h" -#include "qwidget.h" -#include "qcheckbox.h" -#include "property/propertysheet.h" -#include "property/abstracteditorfactorybase.h" -#include "property/abstracteditorfactory.h" -#include "property/abstractpropertymanager.h" -#include "property/abstracteditorfactorybase.h" -#include "property/booledit.h" -#include "property/cursordatabase.h" -#include "property/utils.h" -#include "property/qteditorfactory.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(Q_CC_MSVC) -# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ -#endif - -QT_BEGIN_NAMESPACE - -// Set a hard coded left margin to account for the indentation -// of the tree view icon when switching to an editor - -using namespace shelllet::property; -static inline void setupTreeViewEditorMargin(QLayout* lt) -{ - enum { DecorationMargin = 4 }; - if (QApplication::layoutDirection() == Qt::LeftToRight) - lt->setContentsMargins(DecorationMargin, 0, 0, 0); - else - lt->setContentsMargins(0, 0, DecorationMargin, 0); -} - -// ---------- EditorFactoryPrivate : -// Base class for editor factory private classes. Manages mapping of properties to editors and vice versa. - -// ------------ QtSpinBoxFactory - -class QtSpinBoxFactoryPrivate : public EditorFactoryPrivate -{ - QtSpinBoxFactory* q_ptr; - Q_DECLARE_PUBLIC(QtSpinBoxFactory) -public: - - void slotPropertyChanged(PropertySheet* property, int value); - void slotRangeChanged(PropertySheet* property, int min, int max); - void slotSingleStepChanged(PropertySheet* property, int step); - void slotSetValue(int value); -}; - -void QtSpinBoxFactoryPrivate::slotPropertyChanged(PropertySheet* property, int value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - for (QSpinBox* editor : it.value()) { - if (editor->value() != value) { - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } - } -} - -void QtSpinBoxFactoryPrivate::slotRangeChanged(PropertySheet* property, int min, int max) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - - QtIntPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - for (QSpinBox* editor : it.value()) { - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtSpinBoxFactoryPrivate::slotSingleStepChanged(PropertySheet* property, int step) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - for (QSpinBox* editor : it.value()) { - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); - } -} - -void QtSpinBoxFactoryPrivate::slotSetValue(int value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) { - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtIntPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } - } -} - -/*! - \class QtSpinBoxFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtSpinBoxFactory class provides QSpinBox widgets for - properties created by QtIntPropertyManager objects. - - \sa AbstractEditorFactory, QtIntPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtSpinBoxFactory::QtSpinBoxFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtSpinBoxFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtSpinBoxFactory::~QtSpinBoxFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtSpinBoxFactory::connectPropertyManager(QtIntPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - connect(manager, SIGNAL(rangeChanged(PropertySheet*, int, int)), - this, SLOT(slotRangeChanged(PropertySheet*, int, int))); - connect(manager, SIGNAL(singleStepChanged(PropertySheet*, int)), - this, SLOT(slotSingleStepChanged(PropertySheet*, int))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtSpinBoxFactory::createEditor(QtIntPropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - QSpinBox* editor = d_ptr->createEditor(property, parent); - editor->setSingleStep(manager->singleStep(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); - editor->setKeyboardTracking(false); - - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtSpinBoxFactory::disconnectPropertyManager(QtIntPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - disconnect(manager, SIGNAL(rangeChanged(PropertySheet*, int, int)), - this, SLOT(slotRangeChanged(PropertySheet*, int, int))); - disconnect(manager, SIGNAL(singleStepChanged(PropertySheet*, int)), - this, SLOT(slotSingleStepChanged(PropertySheet*, int))); -} - -// QtSliderFactory - -class QtSliderFactoryPrivate : public EditorFactoryPrivate -{ - QtSliderFactory* q_ptr; - Q_DECLARE_PUBLIC(QtSliderFactory) -public: - void slotPropertyChanged(PropertySheet* property, int value); - void slotRangeChanged(PropertySheet* property, int min, int max); - void slotSingleStepChanged(PropertySheet* property, int step); - void slotSetValue(int value); -}; - -void QtSliderFactoryPrivate::slotPropertyChanged(PropertySheet* property, int value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - for (QSlider* editor : it.value()) { - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } -} - -void QtSliderFactoryPrivate::slotRangeChanged(PropertySheet* property, int min, int max) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - - QtIntPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - for (QSlider* editor : it.value()) { - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtSliderFactoryPrivate::slotSingleStepChanged(PropertySheet* property, int step) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - for (QSlider* editor : it.value()) { - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); - } -} - -void QtSliderFactoryPrivate::slotSetValue(int value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) { - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtIntPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } - } -} - -/*! - \class QtSliderFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtSliderFactory class provides QSlider widgets for - properties created by QtIntPropertyManager objects. - - \sa AbstractEditorFactory, QtIntPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtSliderFactory::QtSliderFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtSliderFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtSliderFactory::~QtSliderFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtSliderFactory::connectPropertyManager(QtIntPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - connect(manager, SIGNAL(rangeChanged(PropertySheet*, int, int)), - this, SLOT(slotRangeChanged(PropertySheet*, int, int))); - connect(manager, SIGNAL(singleStepChanged(PropertySheet*, int)), - this, SLOT(slotSingleStepChanged(PropertySheet*, int))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtSliderFactory::createEditor(QtIntPropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - QSlider* editor = new QSlider(Qt::Horizontal, parent); - d_ptr->initializeEditor(property, editor); - editor->setSingleStep(manager->singleStep(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); - - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtSliderFactory::disconnectPropertyManager(QtIntPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - disconnect(manager, SIGNAL(rangeChanged(PropertySheet*, int, int)), - this, SLOT(slotRangeChanged(PropertySheet*, int, int))); - disconnect(manager, SIGNAL(singleStepChanged(PropertySheet*, int)), - this, SLOT(slotSingleStepChanged(PropertySheet*, int))); -} - -// QtSliderFactory - -class QtScrollBarFactoryPrivate : public EditorFactoryPrivate -{ - QtScrollBarFactory* q_ptr; - Q_DECLARE_PUBLIC(QtScrollBarFactory) -public: - void slotPropertyChanged(PropertySheet* property, int value); - void slotRangeChanged(PropertySheet* property, int min, int max); - void slotSingleStepChanged(PropertySheet* property, int step); - void slotSetValue(int value); -}; - -void QtScrollBarFactoryPrivate::slotPropertyChanged(PropertySheet* property, int value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - - for (QScrollBar* editor : it.value()) { - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } -} - -void QtScrollBarFactoryPrivate::slotRangeChanged(PropertySheet* property, int min, int max) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - - QtIntPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - for (QScrollBar* editor : it.value()) { - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtScrollBarFactoryPrivate::slotSingleStepChanged(PropertySheet* property, int step) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - for (QScrollBar* editor : it.value()) { - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); - } -} - -void QtScrollBarFactoryPrivate::slotSetValue(int value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtIntPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtScrollBarFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtScrollBarFactory class provides QScrollBar widgets for - properties created by QtIntPropertyManager objects. - - \sa AbstractEditorFactory, QtIntPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtScrollBarFactory::QtScrollBarFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtScrollBarFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtScrollBarFactory::~QtScrollBarFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtScrollBarFactory::connectPropertyManager(QtIntPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - connect(manager, SIGNAL(rangeChanged(PropertySheet*, int, int)), - this, SLOT(slotRangeChanged(PropertySheet*, int, int))); - connect(manager, SIGNAL(singleStepChanged(PropertySheet*, int)), - this, SLOT(slotSingleStepChanged(PropertySheet*, int))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtScrollBarFactory::createEditor(QtIntPropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - QScrollBar* editor = new QScrollBar(Qt::Horizontal, parent); - d_ptr->initializeEditor(property, editor); - editor->setSingleStep(manager->singleStep(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtScrollBarFactory::disconnectPropertyManager(QtIntPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - disconnect(manager, SIGNAL(rangeChanged(PropertySheet*, int, int)), - this, SLOT(slotRangeChanged(PropertySheet*, int, int))); - disconnect(manager, SIGNAL(singleStepChanged(PropertySheet*, int)), - this, SLOT(slotSingleStepChanged(PropertySheet*, int))); -} - -// QtCheckBoxFactory - -class QtCheckBoxFactoryPrivate : public EditorFactoryPrivate -{ - QtCheckBoxFactory* q_ptr; - Q_DECLARE_PUBLIC(QtCheckBoxFactory) -public: - void slotPropertyChanged(PropertySheet* property, bool value); - void slotSetValue(bool value); -}; - -void QtCheckBoxFactoryPrivate::slotPropertyChanged(PropertySheet* property, bool value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - - for (BoolEdit* editor : it.value()) { - editor->blockCheckBoxSignals(true); - editor->setChecked(value); - editor->blockCheckBoxSignals(false); - } -} - -void QtCheckBoxFactoryPrivate::slotSetValue(bool value) -{ - QObject* object = q_ptr->sender(); - - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtBoolPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtCheckBoxFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtCheckBoxFactory class provides QCheckBox widgets for - properties created by QtBoolPropertyManager objects. - - \sa AbstractEditorFactory, QtBoolPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtCheckBoxFactory::QtCheckBoxFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtCheckBoxFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtCheckBoxFactory::~QtCheckBoxFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtCheckBoxFactory::connectPropertyManager(QtBoolPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, bool)), - this, SLOT(slotPropertyChanged(PropertySheet*, bool))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtCheckBoxFactory::createEditor(QtBoolPropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - BoolEdit* editor = d_ptr->createEditor(property, parent); - editor->setChecked(manager->value(property)); - - connect(editor, SIGNAL(toggled(bool)), this, SLOT(slotSetValue(bool))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtCheckBoxFactory::disconnectPropertyManager(QtBoolPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, bool)), - this, SLOT(slotPropertyChanged(PropertySheet*, bool))); -} - -// QtDoubleSpinBoxFactory - -class QtDoubleSpinBoxFactoryPrivate : public EditorFactoryPrivate -{ - QtDoubleSpinBoxFactory* q_ptr; - Q_DECLARE_PUBLIC(QtDoubleSpinBoxFactory) -public: - - void slotPropertyChanged(PropertySheet* property, double value); - void slotRangeChanged(PropertySheet* property, double min, double max); - void slotSingleStepChanged(PropertySheet* property, double step); - void slotDecimalsChanged(PropertySheet* property, int prec); - void slotSetValue(double value); -}; - -void QtDoubleSpinBoxFactoryPrivate::slotPropertyChanged(PropertySheet* property, double value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - for (QDoubleSpinBox* editor : it.value()) { - if (editor->value() != value) { - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } - } -} - -void QtDoubleSpinBoxFactoryPrivate::slotRangeChanged(PropertySheet* property, - double min, double max) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - - QtDoublePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - for (QDoubleSpinBox* editor : it.value()) { - editor->blockSignals(true); - editor->setRange(min, max); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtDoubleSpinBoxFactoryPrivate::slotSingleStepChanged(PropertySheet* property, double step) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.cend()) - return; - - QtDoublePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - for (QDoubleSpinBox* editor : it.value()) { - editor->blockSignals(true); - editor->setSingleStep(step); - editor->blockSignals(false); - } -} - -void QtDoubleSpinBoxFactoryPrivate::slotDecimalsChanged(PropertySheet* property, int prec) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - QtDoublePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - for (QDoubleSpinBox* editor : it.value()) { - editor->blockSignals(true); - editor->setDecimals(prec); - editor->setValue(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtDoubleSpinBoxFactoryPrivate::slotSetValue(double value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator itcend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != itcend; ++itEditor) { - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtDoublePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } - } -} - -/*! \class QtDoubleSpinBoxFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtDoubleSpinBoxFactory class provides QDoubleSpinBox - widgets for properties created by QtDoublePropertyManager objects. - - \sa AbstractEditorFactory, QtDoublePropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtDoubleSpinBoxFactory::QtDoubleSpinBoxFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtDoubleSpinBoxFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtDoubleSpinBoxFactory::~QtDoubleSpinBoxFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtDoubleSpinBoxFactory::connectPropertyManager(QtDoublePropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, double)), - this, SLOT(slotPropertyChanged(PropertySheet*, double))); - connect(manager, SIGNAL(rangeChanged(PropertySheet*, double, double)), - this, SLOT(slotRangeChanged(PropertySheet*, double, double))); - connect(manager, SIGNAL(singleStepChanged(PropertySheet*, double)), - this, SLOT(slotSingleStepChanged(PropertySheet*, double))); - connect(manager, SIGNAL(decimalsChanged(PropertySheet*, int)), - this, SLOT(slotDecimalsChanged(PropertySheet*, int))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtDoubleSpinBoxFactory::createEditor(QtDoublePropertyManager* manager, - PropertySheet* property, QWidget* parent) -{ - QDoubleSpinBox* editor = d_ptr->createEditor(property, parent); - editor->setSingleStep(manager->singleStep(property)); - editor->setDecimals(manager->decimals(property)); - editor->setRange(manager->minimum(property), manager->maximum(property)); - editor->setValue(manager->value(property)); - editor->setKeyboardTracking(false); - - connect(editor, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtDoubleSpinBoxFactory::disconnectPropertyManager(QtDoublePropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, double)), - this, SLOT(slotPropertyChanged(PropertySheet*, double))); - disconnect(manager, SIGNAL(rangeChanged(PropertySheet*, double, double)), - this, SLOT(slotRangeChanged(PropertySheet*, double, double))); - disconnect(manager, SIGNAL(singleStepChanged(PropertySheet*, double)), - this, SLOT(slotSingleStepChanged(PropertySheet*, double))); - disconnect(manager, SIGNAL(decimalsChanged(PropertySheet*, int)), - this, SLOT(slotDecimalsChanged(PropertySheet*, int))); -} - -// QtLineEditFactory - - -/*! - \class QtLineEditFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtLineEditFactory class provides QLineEdit widgets for - properties created by QtStringPropertyManager objects. - - \sa AbstractEditorFactory, QtStringPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -// QtDateEditFactory - -class QtDateEditFactoryPrivate : public EditorFactoryPrivate -{ - QtDateEditFactory* q_ptr; - Q_DECLARE_PUBLIC(QtDateEditFactory) -public: - - void slotPropertyChanged(PropertySheet* property, const QDate& value); - void slotRangeChanged(PropertySheet* property, const QDate& min, const QDate& max); - void slotSetValue(const QDate& value); -}; - -void QtDateEditFactoryPrivate::slotPropertyChanged(PropertySheet* property, const QDate& value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - for (QDateEdit* editor : it.value()) { - editor->blockSignals(true); - editor->setDate(value); - editor->blockSignals(false); - } -} - -void QtDateEditFactoryPrivate::slotRangeChanged(PropertySheet* property, - const QDate& min, const QDate& max) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - QtDatePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - for (QDateEdit* editor : it.value()) { - editor->blockSignals(true); - editor->setDateRange(min, max); - editor->setDate(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtDateEditFactoryPrivate::slotSetValue(const QDate& value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtDatePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtDateEditFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtDateEditFactory class provides QDateEdit widgets for - properties created by QtDatePropertyManager objects. - - \sa AbstractEditorFactory, QtDatePropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtDateEditFactory::QtDateEditFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtDateEditFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtDateEditFactory::~QtDateEditFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtDateEditFactory::connectPropertyManager(QtDatePropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QDate)), - this, SLOT(slotPropertyChanged(PropertySheet*, QDate))); - connect(manager, SIGNAL(rangeChanged(PropertySheet*, QDate, QDate)), - this, SLOT(slotRangeChanged(PropertySheet*, QDate, QDate))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtDateEditFactory::createEditor(QtDatePropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - QDateEdit* editor = d_ptr->createEditor(property, parent); - editor->setDisplayFormat(Utils::dateFormat()); - editor->setCalendarPopup(true); - editor->setDateRange(manager->minimum(property), manager->maximum(property)); - editor->setDate(manager->value(property)); - - connect(editor, SIGNAL(dateChanged(QDate)), - this, SLOT(slotSetValue(QDate))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtDateEditFactory::disconnectPropertyManager(QtDatePropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QDate)), - this, SLOT(slotPropertyChanged(PropertySheet*, QDate))); - disconnect(manager, SIGNAL(rangeChanged(PropertySheet*, QDate, QDate)), - this, SLOT(slotRangeChanged(PropertySheet*, QDate, QDate))); -} - -// QtTimeEditFactory - -class QtTimeEditFactoryPrivate : public EditorFactoryPrivate -{ - QtTimeEditFactory* q_ptr; - Q_DECLARE_PUBLIC(QtTimeEditFactory) -public: - - void slotPropertyChanged(PropertySheet* property, const QTime& value); - void slotSetValue(const QTime& value); -}; - -void QtTimeEditFactoryPrivate::slotPropertyChanged(PropertySheet* property, const QTime& value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - for (QTimeEdit* editor : it.value()) { - editor->blockSignals(true); - editor->setTime(value); - editor->blockSignals(false); - } -} - -void QtTimeEditFactoryPrivate::slotSetValue(const QTime& value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtTimePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtTimeEditFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtTimeEditFactory class provides QTimeEdit widgets for - properties created by QtTimePropertyManager objects. - - \sa AbstractEditorFactory, QtTimePropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtTimeEditFactory::QtTimeEditFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtTimeEditFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtTimeEditFactory::~QtTimeEditFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtTimeEditFactory::connectPropertyManager(QtTimePropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QTime)), - this, SLOT(slotPropertyChanged(PropertySheet*, QTime))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtTimeEditFactory::createEditor(QtTimePropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - QTimeEdit* editor = d_ptr->createEditor(property, parent); - editor->setDisplayFormat(Utils::timeFormat()); - editor->setTime(manager->value(property)); - - connect(editor, SIGNAL(timeChanged(QTime)), - this, SLOT(slotSetValue(QTime))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtTimeEditFactory::disconnectPropertyManager(QtTimePropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QTime)), - this, SLOT(slotPropertyChanged(PropertySheet*, QTime))); -} - -// QtDateTimeEditFactory - -class QtDateTimeEditFactoryPrivate : public EditorFactoryPrivate -{ - QtDateTimeEditFactory* q_ptr; - Q_DECLARE_PUBLIC(QtDateTimeEditFactory) -public: - - void slotPropertyChanged(PropertySheet* property, const QDateTime& value); - void slotSetValue(const QDateTime& value); -}; - -void QtDateTimeEditFactoryPrivate::slotPropertyChanged(PropertySheet* property, - const QDateTime& value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - for (QDateTimeEdit* editor : it.value()) { - editor->blockSignals(true); - editor->setDateTime(value); - editor->blockSignals(false); - } -} - -void QtDateTimeEditFactoryPrivate::slotSetValue(const QDateTime& value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtDateTimePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtDateTimeEditFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtDateTimeEditFactory class provides QDateTimeEdit - widgets for properties created by QtDateTimePropertyManager objects. - - \sa AbstractEditorFactory, QtDateTimePropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtDateTimeEditFactory::QtDateTimeEditFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtDateTimeEditFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtDateTimeEditFactory::~QtDateTimeEditFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtDateTimeEditFactory::connectPropertyManager(QtDateTimePropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QDateTime)), - this, SLOT(slotPropertyChanged(PropertySheet*, QDateTime))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtDateTimeEditFactory::createEditor(QtDateTimePropertyManager* manager, - PropertySheet* property, QWidget* parent) -{ - QDateTimeEdit* editor = d_ptr->createEditor(property, parent); - editor->setDisplayFormat(Utils::dateTimeFormat()); - editor->setDateTime(manager->value(property)); - - connect(editor, SIGNAL(dateTimeChanged(QDateTime)), - this, SLOT(slotSetValue(QDateTime))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtDateTimeEditFactory::disconnectPropertyManager(QtDateTimePropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QDateTime)), - this, SLOT(slotPropertyChanged(PropertySheet*, QDateTime))); -} - -// QtKeySequenceEditorFactory - -class QtKeySequenceEditorFactoryPrivate : public EditorFactoryPrivate -{ - QtKeySequenceEditorFactory* q_ptr; - Q_DECLARE_PUBLIC(QtKeySequenceEditorFactory) -public: - - void slotPropertyChanged(PropertySheet* property, const QKeySequence& value); - void slotSetValue(const QKeySequence& value); -}; - -void QtKeySequenceEditorFactoryPrivate::slotPropertyChanged(PropertySheet* property, - const QKeySequence& value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - for (QKeySequenceEdit* editor : it.value()) { - editor->blockSignals(true); - editor->setKeySequence(value); - editor->blockSignals(false); - } -} - -void QtKeySequenceEditorFactoryPrivate::slotSetValue(const QKeySequence& value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtKeySequencePropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtKeySequenceEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtKeySequenceEditorFactory class provides editor - widgets for properties created by QtKeySequencePropertyManager objects. - - \sa AbstractEditorFactory -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtKeySequenceEditorFactory::QtKeySequenceEditorFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtKeySequenceEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtKeySequenceEditorFactory::~QtKeySequenceEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtKeySequenceEditorFactory::connectPropertyManager(QtKeySequencePropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QKeySequence)), - this, SLOT(slotPropertyChanged(PropertySheet*, QKeySequence))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtKeySequenceEditorFactory::createEditor(QtKeySequencePropertyManager* manager, - PropertySheet* property, QWidget* parent) -{ - QKeySequenceEdit* editor = d_ptr->createEditor(property, parent); - editor->setKeySequence(manager->value(property)); - - connect(editor, SIGNAL(keySequenceChanged(QKeySequence)), - this, SLOT(slotSetValue(QKeySequence))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtKeySequenceEditorFactory::disconnectPropertyManager(QtKeySequencePropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QKeySequence)), - this, SLOT(slotPropertyChanged(PropertySheet*, QKeySequence))); -} - -// QtCharEdit - -class QtCharEdit : public QWidget -{ - Q_OBJECT -public: - QtCharEdit(QWidget* parent = 0); - - QChar value() const; - bool eventFilter(QObject* o, QEvent* e); -public Q_SLOTS: - void setValue(const QChar& value); -Q_SIGNALS: - void valueChanged(const QChar& value); -protected: - void focusInEvent(QFocusEvent* e); - void focusOutEvent(QFocusEvent* e); - void keyPressEvent(QKeyEvent* e); - void keyReleaseEvent(QKeyEvent* e); - bool event(QEvent* e); -private slots: - void slotClearChar(); -private: - void handleKeyEvent(QKeyEvent* e); - - QChar m_value; - QLineEdit* m_lineEdit; -}; - -QtCharEdit::QtCharEdit(QWidget* parent) - : QWidget(parent), m_lineEdit(new QLineEdit(this)) -{ - QHBoxLayout* layout = new QHBoxLayout(this); - layout->addWidget(m_lineEdit); - layout->setContentsMargins(QMargins()); - m_lineEdit->installEventFilter(this); - m_lineEdit->setReadOnly(true); - m_lineEdit->setFocusProxy(this); - setFocusPolicy(m_lineEdit->focusPolicy()); - setAttribute(Qt::WA_InputMethodEnabled); -} - -bool QtCharEdit::eventFilter(QObject* o, QEvent* e) -{ - if (o == m_lineEdit && e->type() == QEvent::ContextMenu) { - QContextMenuEvent* c = static_cast(e); - QMenu* menu = m_lineEdit->createStandardContextMenu(); - const QList actions = menu->actions(); - for (QAction* action : actions) { - action->setShortcut(QKeySequence()); - QString actionString = action->text(); - const int pos = actionString.lastIndexOf(QLatin1Char('\t')); - if (pos > 0) - actionString = actionString.remove(pos, actionString.length() - pos); - action->setText(actionString); - } - QAction* actionBefore = 0; - if (actions.count() > 0) - actionBefore = actions[0]; - QAction* clearAction = new QAction(tr("Clear Char"), menu); - menu->insertAction(actionBefore, clearAction); - menu->insertSeparator(actionBefore); - clearAction->setEnabled(!m_value.isNull()); - connect(clearAction, SIGNAL(triggered()), this, SLOT(slotClearChar())); - menu->exec(c->globalPos()); - delete menu; - e->accept(); - return true; - } - - return QWidget::eventFilter(o, e); -} - -void QtCharEdit::slotClearChar() -{ - if (m_value.isNull()) - return; - setValue(QChar()); - emit valueChanged(m_value); -} - -void QtCharEdit::handleKeyEvent(QKeyEvent* e) -{ - const int key = e->key(); - switch (key) { - case Qt::Key_Control: - case Qt::Key_Shift: - case Qt::Key_Meta: - case Qt::Key_Alt: - case Qt::Key_Super_L: - case Qt::Key_Return: - return; - default: - break; - } - - const QString text = e->text(); - if (text.count() != 1) - return; - - const QChar c = text.at(0); - if (!c.isPrint()) - return; - - if (m_value == c) - return; - - m_value = c; - const QString str = m_value.isNull() ? QString() : QString(m_value); - m_lineEdit->setText(str); - e->accept(); - emit valueChanged(m_value); -} - -void QtCharEdit::setValue(const QChar& value) -{ - if (value == m_value) - return; - - m_value = value; - QString str = value.isNull() ? QString() : QString(value); - m_lineEdit->setText(str); -} - -QChar QtCharEdit::value() const -{ - return m_value; -} - -void QtCharEdit::focusInEvent(QFocusEvent* e) -{ - m_lineEdit->event(e); - m_lineEdit->selectAll(); - QWidget::focusInEvent(e); -} - -void QtCharEdit::focusOutEvent(QFocusEvent* e) -{ - m_lineEdit->event(e); - QWidget::focusOutEvent(e); -} - -void QtCharEdit::keyPressEvent(QKeyEvent* e) -{ - handleKeyEvent(e); - e->accept(); -} - -void QtCharEdit::keyReleaseEvent(QKeyEvent* e) -{ - m_lineEdit->event(e); -} - -bool QtCharEdit::event(QEvent* e) -{ - switch (e->type()) { - case QEvent::Shortcut: - case QEvent::ShortcutOverride: - case QEvent::KeyRelease: - e->accept(); - return true; - default: - break; - } - return QWidget::event(e); -} - -// QtCharEditorFactory - -class QtCharEditorFactoryPrivate : public EditorFactoryPrivate -{ - QtCharEditorFactory* q_ptr; - Q_DECLARE_PUBLIC(QtCharEditorFactory) -public: - - void slotPropertyChanged(PropertySheet* property, const QChar& value); - void slotSetValue(const QChar& value); -}; - -void QtCharEditorFactoryPrivate::slotPropertyChanged(PropertySheet* property, - const QChar& value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - for (QtCharEdit* editor : it.value()) { - editor->blockSignals(true); - editor->setValue(value); - editor->blockSignals(false); - } -} - -void QtCharEditorFactoryPrivate::slotSetValue(const QChar& value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtCharPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtCharEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtCharEditorFactory class provides editor - widgets for properties created by QtCharPropertyManager objects. - - \sa AbstractEditorFactory -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtCharEditorFactory::QtCharEditorFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtCharEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtCharEditorFactory::~QtCharEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtCharEditorFactory::connectPropertyManager(QtCharPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QChar)), - this, SLOT(slotPropertyChanged(PropertySheet*, QChar))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtCharEditorFactory::createEditor(QtCharPropertyManager* manager, - PropertySheet* property, QWidget* parent) -{ - QtCharEdit* editor = d_ptr->createEditor(property, parent); - editor->setValue(manager->value(property)); - - connect(editor, SIGNAL(valueChanged(QChar)), - this, SLOT(slotSetValue(QChar))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtCharEditorFactory::disconnectPropertyManager(QtCharPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QChar)), - this, SLOT(slotPropertyChanged(PropertySheet*, QChar))); -} - -// QtEnumEditorFactory - -class QtEnumEditorFactoryPrivate : public EditorFactoryPrivate -{ - QtEnumEditorFactory* q_ptr; - Q_DECLARE_PUBLIC(QtEnumEditorFactory) -public: - - void slotPropertyChanged(PropertySheet* property, int value); - void slotEnumNamesChanged(PropertySheet* property, const QStringList&); - void slotEnumIconsChanged(PropertySheet* property, const QMap&); - void slotSetValue(int value); -}; - -void QtEnumEditorFactoryPrivate::slotPropertyChanged(PropertySheet* property, int value) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - for (QComboBox* editor : it.value()) { - editor->blockSignals(true); - editor->setCurrentIndex(value); - editor->blockSignals(false); - } -} - -void QtEnumEditorFactoryPrivate::slotEnumNamesChanged(PropertySheet* property, - const QStringList& enumNames) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - QtEnumPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - QMap enumIcons = manager->enumIcons(property); - - for (QComboBox* editor : it.value()) { - editor->blockSignals(true); - editor->clear(); - editor->addItems(enumNames); - const int nameCount = enumNames.count(); - for (int i = 0; i < nameCount; i++) - editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtEnumEditorFactoryPrivate::slotEnumIconsChanged(PropertySheet* property, - const QMap& enumIcons) -{ - const auto it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - QtEnumPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - - const QStringList enumNames = manager->enumNames(property); - for (QComboBox* editor : it.value()) { - editor->blockSignals(true); - const int nameCount = enumNames.count(); - for (int i = 0; i < nameCount; i++) - editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); - editor->blockSignals(false); - } -} - -void QtEnumEditorFactoryPrivate::slotSetValue(int value) -{ - QObject* object = q_ptr->sender(); - const QMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtEnumPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtEnumEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtEnumEditorFactory class provides QComboBox widgets for - properties created by QtEnumPropertyManager objects. - - \sa AbstractEditorFactory, QtEnumPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtEnumEditorFactory::QtEnumEditorFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtEnumEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtEnumEditorFactory::~QtEnumEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtEnumEditorFactory::connectPropertyManager(QtEnumPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - connect(manager, SIGNAL(enumNamesChanged(PropertySheet*, QStringList)), - this, SLOT(slotEnumNamesChanged(PropertySheet*, QStringList))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtEnumEditorFactory::createEditor(QtEnumPropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - QComboBox* editor = d_ptr->createEditor(property, parent); - editor->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - editor->view()->setTextElideMode(Qt::ElideRight); - QStringList enumNames = manager->enumNames(property); - editor->addItems(enumNames); - QMap enumIcons = manager->enumIcons(property); - const int enumNamesCount = enumNames.count(); - for (int i = 0; i < enumNamesCount; i++) - editor->setItemIcon(i, enumIcons.value(i)); - editor->setCurrentIndex(manager->value(property)); - - connect(editor, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSetValue(int))); - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtEnumEditorFactory::disconnectPropertyManager(QtEnumPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotPropertyChanged(PropertySheet*, int))); - disconnect(manager, SIGNAL(enumNamesChanged(PropertySheet*, QStringList)), - this, SLOT(slotEnumNamesChanged(PropertySheet*, QStringList))); -} - -// QtCursorEditorFactory - - -class QtCursorEditorFactoryPrivate -{ - QtCursorEditorFactory* q_ptr; - Q_DECLARE_PUBLIC(QtCursorEditorFactory) -public: - QtCursorEditorFactoryPrivate(); - - void slotPropertyChanged(PropertySheet* property, const QCursor& cursor); - void slotEnumChanged(PropertySheet* property, int value); - void slotEditorDestroyed(QObject* object); - - QtEnumEditorFactory* m_enumEditorFactory; - QtEnumPropertyManager* m_enumPropertyManager; - - QMap m_propertyToEnum; - QMap m_enumToProperty; - QMap m_enumToEditors; - QMap m_editorToEnum; - bool m_updatingEnum; -}; - -QtCursorEditorFactoryPrivate::QtCursorEditorFactoryPrivate() - : m_updatingEnum(false) -{ -} - -void QtCursorEditorFactoryPrivate::slotPropertyChanged(PropertySheet* property, const QCursor& cursor) -{ - // update enum property - PropertySheet* enumProp = m_propertyToEnum.value(property); - if (!enumProp) - return; - - m_updatingEnum = true; - m_enumPropertyManager->setValue(enumProp, CursorDatabase::getInstance()->cursorToValue(cursor)); - m_updatingEnum = false; -} - -void QtCursorEditorFactoryPrivate::slotEnumChanged(PropertySheet* property, int value) -{ - if (m_updatingEnum) - return; - // update cursor property - PropertySheet* prop = m_enumToProperty.value(property); - if (!prop) - return; - QtCursorPropertyManager* cursorManager = q_ptr->propertyManager(prop); - if (!cursorManager) - return; -#ifndef QT_NO_CURSOR - cursorManager->setValue(prop, QCursor(CursorDatabase::getInstance()->valueToCursor(value))); -#endif -} - -void QtCursorEditorFactoryPrivate::slotEditorDestroyed(QObject* object) -{ - // remove from m_editorToEnum map; - // remove from m_enumToEditors map; - // if m_enumToEditors doesn't contains more editors delete enum property; - const QMap::ConstIterator ecend = m_editorToEnum.constEnd(); - for (QMap::ConstIterator itEditor = m_editorToEnum.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - QWidget* editor = itEditor.key(); - PropertySheet* enumProp = itEditor.value(); - m_editorToEnum.remove(editor); - m_enumToEditors[enumProp].removeAll(editor); - if (m_enumToEditors[enumProp].isEmpty()) { - m_enumToEditors.remove(enumProp); - PropertySheet* property = m_enumToProperty.value(enumProp); - m_enumToProperty.remove(enumProp); - m_propertyToEnum.remove(property); - delete enumProp; - } - return; - } -} - -/*! - \class QtCursorEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtCursorEditorFactory class provides QComboBox widgets for - properties created by QtCursorPropertyManager objects. - - \sa AbstractEditorFactory, QtCursorPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtCursorEditorFactory::QtCursorEditorFactory(QObject* parent) - : AbstractEditorFactory(parent), d_ptr(new QtCursorEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; - - d_ptr->m_enumEditorFactory = new QtEnumEditorFactory(this); - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotEnumChanged(PropertySheet*, int))); - d_ptr->m_enumEditorFactory->addPropertyManager(d_ptr->m_enumPropertyManager); -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtCursorEditorFactory::~QtCursorEditorFactory() -{ -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtCursorEditorFactory::connectPropertyManager(QtCursorPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QCursor)), - this, SLOT(slotPropertyChanged(PropertySheet*, QCursor))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtCursorEditorFactory::createEditor(QtCursorPropertyManager* manager, PropertySheet* property, - QWidget* parent) -{ - PropertySheet* enumProp = 0; - if (d_ptr->m_propertyToEnum.contains(property)) { - enumProp = d_ptr->m_propertyToEnum[property]; - } - else { - enumProp = d_ptr->m_enumPropertyManager->addProperty(property->propertyName()); - d_ptr->m_enumPropertyManager->setEnumNames(enumProp, CursorDatabase::getInstance()->cursorShapeNames()); - d_ptr->m_enumPropertyManager->setEnumIcons(enumProp, CursorDatabase::getInstance()->cursorShapeIcons()); -#ifndef QT_NO_CURSOR - d_ptr->m_enumPropertyManager->setValue(enumProp, CursorDatabase::getInstance()->cursorToValue(manager->value(property))); -#endif - d_ptr->m_propertyToEnum[property] = enumProp; - d_ptr->m_enumToProperty[enumProp] = property; - } - AbstractEditorFactoryBase* af = d_ptr->m_enumEditorFactory; - QWidget* editor = af->createEditor(enumProp, parent); - d_ptr->m_enumToEditors[enumProp].append(editor); - d_ptr->m_editorToEnum[editor] = enumProp; - connect(editor, SIGNAL(destroyed(QObject*)), - this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtCursorEditorFactory::disconnectPropertyManager(QtCursorPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QCursor)), - this, SLOT(slotPropertyChanged(PropertySheet*, QCursor))); -} - -// QtColorEditWidget - -class QtColorEditWidget : public QWidget { - Q_OBJECT - -public: - QtColorEditWidget(QWidget* parent); - - bool eventFilter(QObject* obj, QEvent* ev); - -public Q_SLOTS: - void setValue(const QColor& value); - -private Q_SLOTS: - void buttonClicked(); - -Q_SIGNALS: - void valueChanged(const QColor& value); - -private: - QColor m_color; - QLabel* m_pixmapLabel; - QLabel* m_label; - QToolButton* m_button; -}; - -QtColorEditWidget::QtColorEditWidget(QWidget* parent) : - QWidget(parent), - m_pixmapLabel(new QLabel), - m_label(new QLabel), - m_button(new QToolButton) -{ - QHBoxLayout* lt = new QHBoxLayout(this); - setupTreeViewEditorMargin(lt); - lt->setSpacing(0); - lt->addWidget(m_pixmapLabel); - lt->addWidget(m_label); - lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); - - m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); - m_button->setFixedWidth(20); - setFocusProxy(m_button); - setFocusPolicy(m_button->focusPolicy()); - m_button->setText(tr("...")); - m_button->installEventFilter(this); - connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); - lt->addWidget(m_button); - m_pixmapLabel->setPixmap(Utils::brushValuePixmap(QBrush(m_color))); - m_label->setText(Utils::colorValueText(m_color)); -} - -void QtColorEditWidget::setValue(const QColor& c) -{ - if (m_color != c) { - m_color = c; - m_pixmapLabel->setPixmap(Utils::brushValuePixmap(QBrush(c))); - m_label->setText(Utils::colorValueText(c)); - } -} - -void QtColorEditWidget::buttonClicked() -{ - const QColor newColor = QColorDialog::getColor(m_color, this, QString(), QColorDialog::ShowAlphaChannel); - if (newColor.isValid() && newColor != m_color) { - setValue(newColor); - emit valueChanged(m_color); - } -} - -bool QtColorEditWidget::eventFilter(QObject* obj, QEvent* ev) -{ - if (obj == m_button) { - switch (ev->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate - switch (static_cast(ev)->key()) { - case Qt::Key_Escape: - case Qt::Key_Enter: - case Qt::Key_Return: - ev->ignore(); - return true; - default: - break; - } - } - break; - default: - break; - } - } - return QWidget::eventFilter(obj, ev); -} - -// QtColorEditorFactoryPrivate - -class QtColorEditorFactoryPrivate : public EditorFactoryPrivate -{ - QtColorEditorFactory* q_ptr; - Q_DECLARE_PUBLIC(QtColorEditorFactory) -public: - - void slotPropertyChanged(PropertySheet* property, const QColor& value); - void slotSetValue(const QColor& value); -}; - -void QtColorEditorFactoryPrivate::slotPropertyChanged(PropertySheet* property, - const QColor& value) -{ - const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - for (QtColorEditWidget* e : it.value()) - e->setValue(value); -} - -void QtColorEditorFactoryPrivate::slotSetValue(const QColor& value) -{ - QObject* object = q_ptr->sender(); - const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtColorPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtColorEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtColorEditorFactory class provides color editing for - properties created by QtColorPropertyManager objects. - - \sa AbstractEditorFactory, QtColorPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtColorEditorFactory::QtColorEditorFactory(QObject* parent) : - AbstractEditorFactory(parent), - d_ptr(new QtColorEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtColorEditorFactory::~QtColorEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtColorEditorFactory::connectPropertyManager(QtColorPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QColor)), - this, SLOT(slotPropertyChanged(PropertySheet*, QColor))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtColorEditorFactory::createEditor(QtColorPropertyManager* manager, - PropertySheet* property, QWidget* parent) -{ - QtColorEditWidget* editor = d_ptr->createEditor(property, parent); - editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(QColor)), this, SLOT(slotSetValue(QColor))); - connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtColorEditorFactory::disconnectPropertyManager(QtColorPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QColor)), this, SLOT(slotPropertyChanged(PropertySheet*, QColor))); -} - -// QtFontEditWidget - -class QtFontEditWidget : public QWidget { - Q_OBJECT - -public: - QtFontEditWidget(QWidget* parent); - - bool eventFilter(QObject* obj, QEvent* ev); - -public Q_SLOTS: - void setValue(const QFont& value); - -private Q_SLOTS: - void buttonClicked(); - -Q_SIGNALS: - void valueChanged(const QFont& value); - -private: - QFont m_font; - QLabel* m_pixmapLabel; - QLabel* m_label; - QToolButton* m_button; -}; - -QtFontEditWidget::QtFontEditWidget(QWidget* parent) : - QWidget(parent), - m_pixmapLabel(new QLabel), - m_label(new QLabel), - m_button(new QToolButton) -{ - QHBoxLayout* lt = new QHBoxLayout(this); - setupTreeViewEditorMargin(lt); - lt->setSpacing(0); - lt->addWidget(m_pixmapLabel); - lt->addWidget(m_label); - lt->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); - - m_button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); - m_button->setFixedWidth(20); - setFocusProxy(m_button); - setFocusPolicy(m_button->focusPolicy()); - m_button->setText(tr("...")); - m_button->installEventFilter(this); - connect(m_button, SIGNAL(clicked()), this, SLOT(buttonClicked())); - lt->addWidget(m_button); - m_pixmapLabel->setPixmap(Utils::fontValuePixmap(m_font)); - m_label->setText(Utils::fontValueText(m_font)); -} - -void QtFontEditWidget::setValue(const QFont& f) -{ - if (m_font != f) { - m_font = f; - m_pixmapLabel->setPixmap(Utils::fontValuePixmap(f)); - m_label->setText(Utils::fontValueText(f)); - } -} - -void QtFontEditWidget::buttonClicked() -{ - bool ok = false; - QFont newFont = QFontDialog::getFont(&ok, m_font, this, tr("Select Font")); - if (ok && newFont != m_font) { - QFont f = m_font; - // prevent mask for unchanged attributes, don't change other attributes (like kerning, etc...) - if (m_font.family() != newFont.family()) - f.setFamily(newFont.family()); - if (m_font.pointSize() != newFont.pointSize()) - f.setPointSize(newFont.pointSize()); - if (m_font.bold() != newFont.bold()) - f.setBold(newFont.bold()); - if (m_font.italic() != newFont.italic()) - f.setItalic(newFont.italic()); - if (m_font.underline() != newFont.underline()) - f.setUnderline(newFont.underline()); - if (m_font.strikeOut() != newFont.strikeOut()) - f.setStrikeOut(newFont.strikeOut()); - setValue(f); - emit valueChanged(m_font); - } -} - -bool QtFontEditWidget::eventFilter(QObject* obj, QEvent* ev) -{ - if (obj == m_button) { - switch (ev->type()) { - case QEvent::KeyPress: - case QEvent::KeyRelease: { // Prevent the QToolButton from handling Enter/Escape meant control the delegate - switch (static_cast(ev)->key()) { - case Qt::Key_Escape: - case Qt::Key_Enter: - case Qt::Key_Return: - ev->ignore(); - return true; - default: - break; - } - } - break; - default: - break; - } - } - return QWidget::eventFilter(obj, ev); -} - -// QtFontEditorFactoryPrivate - -class QtFontEditorFactoryPrivate : public EditorFactoryPrivate -{ - QtFontEditorFactory* q_ptr; - Q_DECLARE_PUBLIC(QtFontEditorFactory) -public: - - void slotPropertyChanged(PropertySheet* property, const QFont& value); - void slotSetValue(const QFont& value); -}; - -void QtFontEditorFactoryPrivate::slotPropertyChanged(PropertySheet* property, - const QFont& value) -{ - const PropertyToEditorListMap::const_iterator it = m_createdEditors.constFind(property); - if (it == m_createdEditors.constEnd()) - return; - - for (QtFontEditWidget* e : it.value()) - e->setValue(value); -} - -void QtFontEditorFactoryPrivate::slotSetValue(const QFont& value) -{ - QObject* object = q_ptr->sender(); - const EditorToPropertyMap::ConstIterator ecend = m_editorToProperty.constEnd(); - for (EditorToPropertyMap::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != ecend; ++itEditor) - if (itEditor.key() == object) { - PropertySheet* property = itEditor.value(); - QtFontPropertyManager* manager = q_ptr->propertyManager(property); - if (!manager) - return; - manager->setValue(property, value); - return; - } -} - -/*! - \class QtFontEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtFontEditorFactory class provides font editing for - properties created by QtFontPropertyManager objects. - - \sa AbstractEditorFactory, QtFontPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtFontEditorFactory::QtFontEditorFactory(QObject* parent) : - AbstractEditorFactory(parent), - d_ptr(new QtFontEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtFontEditorFactory::~QtFontEditorFactory() -{ - qDeleteAll(d_ptr->m_editorToProperty.keys()); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtFontEditorFactory::connectPropertyManager(QtFontPropertyManager* manager) -{ - connect(manager, SIGNAL(valueChanged(PropertySheet*, QFont)), - this, SLOT(slotPropertyChanged(PropertySheet*, QFont))); -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -QWidget* QtFontEditorFactory::createEditor(QtFontPropertyManager* manager, - PropertySheet* property, QWidget* parent) -{ - QtFontEditWidget* editor = d_ptr->createEditor(property, parent); - editor->setValue(manager->value(property)); - connect(editor, SIGNAL(valueChanged(QFont)), this, SLOT(slotSetValue(QFont))); - connect(editor, SIGNAL(destroyed(QObject*)), this, SLOT(slotEditorDestroyed(QObject*))); - return editor; -} - -/*! - \internal - - Reimplemented from the AbstractEditorFactory class. -*/ -void QtFontEditorFactory::disconnectPropertyManager(QtFontPropertyManager* manager) -{ - disconnect(manager, SIGNAL(valueChanged(PropertySheet*, QFont)), this, SLOT(slotPropertyChanged(PropertySheet*, QFont))); -} - -QT_END_NAMESPACE diff --git a/QtRpa/modules/property/src/qtpropertymanager.xxx b/QtRpa/modules/property/src/qtpropertymanager.xxx deleted file mode 100644 index b196d06..0000000 --- a/QtRpa/modules/property/src/qtpropertymanager.xxx +++ /dev/null @@ -1,5691 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "property/framework.h" -#include "property/propertysheet.h" -#include "property/abstractpropertymanager.h" -#include "property/qtpropertymanager.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#if defined(Q_CC_MSVC) -# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ -#endif - -QT_BEGIN_NAMESPACE -using namespace shelllet::property; -template -static void setSimpleMinimumData(PrivateData* data, const Value& minVal) -{ - data->minVal = minVal; - if (data->maxVal < data->minVal) - data->maxVal = data->minVal; - - if (data->val < data->minVal) - data->val = data->minVal; -} - -template -static void setSimpleMaximumData(PrivateData* data, const Value& maxVal) -{ - data->maxVal = maxVal; - if (data->minVal > data->maxVal) - data->minVal = data->maxVal; - - if (data->val > data->maxVal) - data->val = data->maxVal; -} - -template -static void setSizeMinimumData(PrivateData* data, const Value& newMinVal) -{ - data->minVal = newMinVal; - if (data->maxVal.width() < data->minVal.width()) - data->maxVal.setWidth(data->minVal.width()); - if (data->maxVal.height() < data->minVal.height()) - data->maxVal.setHeight(data->minVal.height()); - - if (data->val.width() < data->minVal.width()) - data->val.setWidth(data->minVal.width()); - if (data->val.height() < data->minVal.height()) - data->val.setHeight(data->minVal.height()); -} - -template -static void setSizeMaximumData(PrivateData* data, const Value& newMaxVal) -{ - data->maxVal = newMaxVal; - if (data->minVal.width() > data->maxVal.width()) - data->minVal.setWidth(data->maxVal.width()); - if (data->minVal.height() > data->maxVal.height()) - data->minVal.setHeight(data->maxVal.height()); - - if (data->val.width() > data->maxVal.width()) - data->val.setWidth(data->maxVal.width()); - if (data->val.height() > data->maxVal.height()) - data->val.setHeight(data->maxVal.height()); -} - -template -static SizeValue qBoundSize(const SizeValue& minVal, const SizeValue& val, const SizeValue& maxVal) -{ - SizeValue croppedVal = val; - if (minVal.width() > val.width()) - croppedVal.setWidth(minVal.width()); - else if (maxVal.width() < val.width()) - croppedVal.setWidth(maxVal.width()); - - if (minVal.height() > val.height()) - croppedVal.setHeight(minVal.height()); - else if (maxVal.height() < val.height()) - croppedVal.setHeight(maxVal.height()); - - return croppedVal; -} - -// Match the exact signature of qBound for VS 6. -QSize qBound(QSize minVal, QSize val, QSize maxVal) -{ - return qBoundSize(minVal, val, maxVal); -} - -QSizeF qBound(QSizeF minVal, QSizeF val, QSizeF maxVal) -{ - return qBoundSize(minVal, val, maxVal); -} - -namespace { - namespace { - template - void orderBorders(Value& minVal, Value& maxVal) - { - if (minVal > maxVal) - qSwap(minVal, maxVal); - } - - template - static void orderSizeBorders(Value& minVal, Value& maxVal) - { - Value fromSize = minVal; - Value toSize = maxVal; - if (fromSize.width() > toSize.width()) { - fromSize.setWidth(maxVal.width()); - toSize.setWidth(minVal.width()); - } - if (fromSize.height() > toSize.height()) { - fromSize.setHeight(maxVal.height()); - toSize.setHeight(minVal.height()); - } - minVal = fromSize; - maxVal = toSize; - } - - void orderBorders(QSize& minVal, QSize& maxVal) - { - orderSizeBorders(minVal, maxVal); - } - - void orderBorders(QSizeF& minVal, QSizeF& maxVal) - { - orderSizeBorders(minVal, maxVal); - } - } -} -//////// - -template -static Value getData(const QMap& propertyMap, - Value PrivateData::* data, - const PropertySheet* property, const Value& defaultValue = Value()) -{ - const auto it = propertyMap.constFind(property); - if (it == propertyMap.constEnd()) - return defaultValue; - return it.value().*data; -} - -template -static Value getValue(const QMap& propertyMap, - const PropertySheet* property, const Value& defaultValue = Value()) -{ - return getData(propertyMap, &PrivateData::val, property, defaultValue); -} - -template -static Value getMinimum(const QMap& propertyMap, - const PropertySheet* property, const Value& defaultValue = Value()) -{ - return getData(propertyMap, &PrivateData::minVal, property, defaultValue); -} - -template -static Value getMaximum(const QMap& propertyMap, - const PropertySheet* property, const Value& defaultValue = Value()) -{ - return getData(propertyMap, &PrivateData::maxVal, property, defaultValue); -} - -template -static void setSimpleValue(QMap& propertyMap, - PropertyManager* manager, - void (PropertyManager::* propertyChangedSignal)(PropertySheet*), - void (PropertyManager::* valueChangedSignal)(PropertySheet*, ValueChangeParameter), - PropertySheet* property, const Value& val) -{ - const auto it = propertyMap.find(property); - if (it == propertyMap.end()) - return; - - if (it.value() == val) - return; - - it.value() = val; - - emit(manager->*propertyChangedSignal)(property); - emit(manager->*valueChangedSignal)(property, val); -} - -template -static void setValueInRange(PropertyManager* manager, PropertyManagerPrivate* managerPrivate, - void (PropertyManager::* propertyChangedSignal)(PropertySheet*), - void (PropertyManager::* valueChangedSignal)(PropertySheet*, ValueChangeParameter), - PropertySheet* property, const Value& val, - void (PropertyManagerPrivate::* setSubPropertyValue)(PropertySheet*, ValueChangeParameter)) -{ - const auto it = managerPrivate->m_values.find(property); - if (it == managerPrivate->m_values.end()) - return; - - auto& data = it.value(); - - if (data.val == val) - return; - - const Value oldVal = data.val; - - data.val = qBound(data.minVal, val, data.maxVal); - - if (data.val == oldVal) - return; - - if (setSubPropertyValue) - (managerPrivate->*setSubPropertyValue)(property, data.val); - - emit(manager->*propertyChangedSignal)(property); - emit(manager->*valueChangedSignal)(property, data.val); -} - -template -static void setBorderValues(PropertyManager* manager, PropertyManagerPrivate* managerPrivate, - void (PropertyManager::* propertyChangedSignal)(PropertySheet*), - void (PropertyManager::* valueChangedSignal)(PropertySheet*, ValueChangeParameter), - void (PropertyManager::* rangeChangedSignal)(PropertySheet*, ValueChangeParameter, ValueChangeParameter), - PropertySheet* property, const Value& minVal, const Value& maxVal, - void (PropertyManagerPrivate::* setSubPropertyRange)(PropertySheet*, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter)) -{ - const auto it = managerPrivate->m_values.find(property); - if (it == managerPrivate->m_values.end()) - return; - - Value fromVal = minVal; - Value toVal = maxVal; - orderBorders(fromVal, toVal); - - auto& data = it.value(); - - if (data.minVal == fromVal && data.maxVal == toVal) - return; - - const Value oldVal = data.val; - - data.setMinimumValue(fromVal); - data.setMaximumValue(toVal); - - emit(manager->*rangeChangedSignal)(property, data.minVal, data.maxVal); - - if (setSubPropertyRange) - (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val); - - if (data.val == oldVal) - return; - - emit(manager->*propertyChangedSignal)(property); - emit(manager->*valueChangedSignal)(property, data.val); -} - -template -static void setBorderValue(PropertyManager* manager, PropertyManagerPrivate* managerPrivate, - void (PropertyManager::* propertyChangedSignal)(PropertySheet*), - void (PropertyManager::* valueChangedSignal)(PropertySheet*, ValueChangeParameter), - void (PropertyManager::* rangeChangedSignal)(PropertySheet*, ValueChangeParameter, ValueChangeParameter), - PropertySheet* property, - Value(PrivateData::* getRangeVal)() const, - void (PrivateData::* setRangeVal)(ValueChangeParameter), const Value& borderVal, - void (PropertyManagerPrivate::* setSubPropertyRange)(PropertySheet*, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter)) -{ - const auto it = managerPrivate->m_values.find(property); - if (it == managerPrivate->m_values.end()) - return; - - PrivateData& data = it.value(); - - if ((data.*getRangeVal)() == borderVal) - return; - - const Value oldVal = data.val; - - (data.*setRangeVal)(borderVal); - - emit(manager->*rangeChangedSignal)(property, data.minVal, data.maxVal); - - if (setSubPropertyRange) - (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val); - - if (data.val == oldVal) - return; - - emit(manager->*propertyChangedSignal)(property); - emit(manager->*valueChangedSignal)(property, data.val); -} - -template -static void setMinimumValue(PropertyManager* manager, PropertyManagerPrivate* managerPrivate, - void (PropertyManager::* propertyChangedSignal)(PropertySheet*), - void (PropertyManager::* valueChangedSignal)(PropertySheet*, ValueChangeParameter), - void (PropertyManager::* rangeChangedSignal)(PropertySheet*, ValueChangeParameter, ValueChangeParameter), - PropertySheet* property, const Value& minVal) -{ - void (PropertyManagerPrivate:: * setSubPropertyRange)(PropertySheet*, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0; - setBorderValue(manager, managerPrivate, - propertyChangedSignal, valueChangedSignal, rangeChangedSignal, - property, &PropertyManagerPrivate::Data::minimumValue, &PropertyManagerPrivate::Data::setMinimumValue, minVal, setSubPropertyRange); -} - -template -static void setMaximumValue(PropertyManager* manager, PropertyManagerPrivate* managerPrivate, - void (PropertyManager::* propertyChangedSignal)(PropertySheet*), - void (PropertyManager::* valueChangedSignal)(PropertySheet*, ValueChangeParameter), - void (PropertyManager::* rangeChangedSignal)(PropertySheet*, ValueChangeParameter, ValueChangeParameter), - PropertySheet* property, const Value& maxVal) -{ - void (PropertyManagerPrivate:: * setSubPropertyRange)(PropertySheet*, - ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0; - setBorderValue(manager, managerPrivate, - propertyChangedSignal, valueChangedSignal, rangeChangedSignal, - property, &PropertyManagerPrivate::Data::maximumValue, &PropertyManagerPrivate::Data::setMaximumValue, maxVal, setSubPropertyRange); -} - -class QtMetaEnumWrapper : public QObject -{ - Q_OBJECT - Q_PROPERTY(QSizePolicy::Policy policy READ policy) -public: - QSizePolicy::Policy policy() const { return QSizePolicy::Ignored; } -private: - QtMetaEnumWrapper(QObject* parent) : QObject(parent) {} -}; - -class QtMetaEnumProvider -{ -public: - QtMetaEnumProvider(); - - QStringList policyEnumNames() const { return m_policyEnumNames; } - QStringList languageEnumNames() const { return m_languageEnumNames; } - QStringList countryEnumNames(QLocale::Language language) const { return m_countryEnumNames.value(language); } - - QSizePolicy::Policy indexToSizePolicy(int index) const; - int sizePolicyToIndex(QSizePolicy::Policy policy) const; - - void indexToLocale(int languageIndex, int countryIndex, QLocale::Language* language, QLocale::Country* country) const; - void localeToIndex(QLocale::Language language, QLocale::Country country, int* languageIndex, int* countryIndex) const; - -private: - void initLocale(); - - QStringList m_policyEnumNames; - QStringList m_languageEnumNames; - QMap m_countryEnumNames; - QMap m_indexToLanguage; - QMap m_languageToIndex; - QMap > m_indexToCountry; - QMap > m_countryToIndex; - QMetaEnum m_policyEnum; -}; - -static QList sortCountries(const QList& countries) -{ - QMultiMap nameToCountry; - for (QLocale::Country country : countries) - nameToCountry.insert(QLocale::countryToString(country), country); - return nameToCountry.values(); -} - -void QtMetaEnumProvider::initLocale() -{ - QMultiMap nameToLanguage; - for (int l = QLocale::C, last = QLocale::LastLanguage; l <= last; ++l) { - const QLocale::Language language = static_cast(l); - QLocale locale(language); - if (locale.language() == language) - nameToLanguage.insert(QLocale::languageToString(language), language); - } - - const QLocale system = QLocale::system(); - if (!nameToLanguage.contains(QLocale::languageToString(system.language()))) - nameToLanguage.insert(QLocale::languageToString(system.language()), system.language()); - - const QList languages = nameToLanguage.values(); - for (QLocale::Language language : languages) { - QList countries; - countries = QLocale::countriesForLanguage(language); - if (countries.isEmpty() && language == system.language()) - countries << system.country(); - - if (!countries.isEmpty() && !m_languageToIndex.contains(language)) { - countries = sortCountries(countries); - int langIdx = m_languageEnumNames.count(); - m_indexToLanguage[langIdx] = language; - m_languageToIndex[language] = langIdx; - QStringList countryNames; - int countryIdx = 0; - for (QLocale::Country country : qAsConst(countries)) { - countryNames << QLocale::countryToString(country); - m_indexToCountry[langIdx][countryIdx] = country; - m_countryToIndex[language][country] = countryIdx; - ++countryIdx; - } - m_languageEnumNames << QLocale::languageToString(language); - m_countryEnumNames[language] = countryNames; - } - } -} - -QtMetaEnumProvider::QtMetaEnumProvider() -{ - QMetaProperty p; - - p = QtMetaEnumWrapper::staticMetaObject.property( - QtMetaEnumWrapper::staticMetaObject.propertyOffset() + 0); - m_policyEnum = p.enumerator(); - const int keyCount = m_policyEnum.keyCount(); - for (int i = 0; i < keyCount; i++) - m_policyEnumNames << QLatin1String(m_policyEnum.key(i)); - - initLocale(); -} - -QSizePolicy::Policy QtMetaEnumProvider::indexToSizePolicy(int index) const -{ - return static_cast(m_policyEnum.value(index)); -} - -int QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const -{ - const int keyCount = m_policyEnum.keyCount(); - for (int i = 0; i < keyCount; i++) - if (indexToSizePolicy(i) == policy) - return i; - return -1; -} - -void QtMetaEnumProvider::indexToLocale(int languageIndex, int countryIndex, QLocale::Language* language, QLocale::Country* country) const -{ - QLocale::Language l = QLocale::C; - QLocale::Country c = QLocale::AnyCountry; - if (m_indexToLanguage.contains(languageIndex)) { - l = m_indexToLanguage[languageIndex]; - if (m_indexToCountry.contains(languageIndex) && m_indexToCountry[languageIndex].contains(countryIndex)) - c = m_indexToCountry[languageIndex][countryIndex]; - } - if (language) - *language = l; - if (country) - *country = c; -} - -void QtMetaEnumProvider::localeToIndex(QLocale::Language language, QLocale::Country country, int* languageIndex, int* countryIndex) const -{ - int l = -1; - int c = -1; - if (m_languageToIndex.contains(language)) { - l = m_languageToIndex[language]; - if (m_countryToIndex.contains(language) && m_countryToIndex[language].contains(country)) - c = m_countryToIndex[language][country]; - } - - if (languageIndex) - *languageIndex = l; - if (countryIndex) - *countryIndex = c; -} - -Q_GLOBAL_STATIC(QtMetaEnumProvider, metaEnumProvider) - - -// QtIntPropertyManager - -class QtIntPropertyManagerPrivate -{ - -}; - -/*! - \class QtIntPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtIntPropertyManager provides and manages int properties. - - An int property has a current value, and a range specifying the - valid values. The range is defined by a minimum and a maximum - value. - - The property's value and range can be retrieved using the value(), - minimum() and maximum() functions, and can be set using the - setValue(), setMinimum() and setMaximum() slots. Alternatively, - the range can be defined in one go using the setRange() slot. - - In addition, QtIntPropertyManager provides the valueChanged() signal which - is emitted whenever a property created by this manager changes, - and the rangeChanged() signal which is emitted whenever such a - property changes its range of valid values. - - \sa AbstractPropertyManager, QtSpinBoxFactory, QtSliderFactory, QtScrollBarFactory -*/ - -/*! - \fn void QtIntPropertyManager::valueChanged(PropertySheet *property, int value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtIntPropertyManager::rangeChanged(PropertySheet *property, int minimum, int maximum) - - This signal is emitted whenever a property created by this manager - changes its range of valid values, passing a pointer to the - \a property and the new \a minimum and \a maximum values. - - \sa setRange() -*/ - -/*! - \fn void QtIntPropertyManager::singleStepChanged(PropertySheet *property, int step) - - This signal is emitted whenever a property created by this manager - changes its single step property, passing a pointer to the - \a property and the new \a step value - - \sa setSingleStep() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -// QtDoublePropertyManager - -class QtDoublePropertyManagerPrivate -{ - -}; - -/*! - \class QtDoublePropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtDoublePropertyManager provides and manages double properties. - - A double property has a current value, and a range specifying the - valid values. The range is defined by a minimum and a maximum - value. - - The property's value and range can be retrieved using the value(), - minimum() and maximum() functions, and can be set using the - setValue(), setMinimum() and setMaximum() slots. - Alternatively, the range can be defined in one go using the - setRange() slot. - - In addition, QtDoublePropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the rangeChanged() signal which is emitted whenever - such a property changes its range of valid values. - - \sa AbstractPropertyManager, QtDoubleSpinBoxFactory -*/ - -/*! - \fn void QtDoublePropertyManager::valueChanged(PropertySheet *property, double value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtDoublePropertyManager::rangeChanged(PropertySheet *property, double minimum, double maximum) - - This signal is emitted whenever a property created by this manager - changes its range of valid values, passing a pointer to the - \a property and the new \a minimum and \a maximum values - - \sa setRange() -*/ - -/*! - \fn void QtDoublePropertyManager::decimalsChanged(PropertySheet *property, int prec) - - This signal is emitted whenever a property created by this manager - changes its precision of value, passing a pointer to the - \a property and the new \a prec value - - \sa setDecimals() -*/ - -/*! - \fn void QtDoublePropertyManager::singleStepChanged(PropertySheet *property, double step) - - This signal is emitted whenever a property created by this manager - changes its single step property, passing a pointer to the - \a property and the new \a step value - - \sa setSingleStep() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -// QtStringPropertyManager - -class QtStringPropertyManagerPrivate -{ - -}; - -/*! - \class QtStringPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtStringPropertyManager provides and manages QString properties. - - A string property's value can be retrieved using the value() - function, and set using the setValue() slot. - - The current value can be checked against a regular expression. To - set the regular expression use the setRegExp() slot, use the - regExp() function to retrieve the currently set expression. - - In addition, QtStringPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the regExpChanged() signal which is emitted whenever - such a property changes its currently set regular expression. - - \sa AbstractPropertyManager, QtLineEditFactory -*/ - -/*! - \fn void QtStringPropertyManager::valueChanged(PropertySheet *property, const QString &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtStringPropertyManager::regExpChanged(PropertySheet *property, const QRegExp ®Exp) - - This signal is emitted whenever a property created by this manager - changes its currenlty set regular expression, passing a pointer to - the \a property and the new \a regExp as parameters. - - \sa setRegExp() -*/ - -/*! - Creates a manager with the given \a parent. -*/ - -// QtBoolPropertyManager -// Return an icon containing a check box indicator -static QIcon drawCheckBox(bool value) -{ - QStyleOptionButton opt; - opt.state |= value ? QStyle::State_On : QStyle::State_Off; - opt.state |= QStyle::State_Enabled; - const QStyle* style = QApplication::style(); - // Figure out size of an indicator and make sure it is not scaled down in a list view item - // by making the pixmap as big as a list view icon and centering the indicator in it. - // (if it is smaller, it can't be helped) - const int indicatorWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &opt); - const int indicatorHeight = style->pixelMetric(QStyle::PM_IndicatorHeight, &opt); - const int listViewIconSize = indicatorWidth; - const int pixmapWidth = indicatorWidth; - const int pixmapHeight = qMax(indicatorHeight, listViewIconSize); - - opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight); - QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight); - pixmap.fill(Qt::transparent); - { - // Center? - const int xoff = (pixmapWidth > indicatorWidth) ? (pixmapWidth - indicatorWidth) / 2 : 0; - const int yoff = (pixmapHeight > indicatorHeight) ? (pixmapHeight - indicatorHeight) / 2 : 0; - QPainter painter(&pixmap); - painter.translate(xoff, yoff); - style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter); - } - return QIcon(pixmap); -} - -class QtBoolPropertyManagerPrivate -{ - -}; - - -// QtDatePropertyManager - -class QtDatePropertyManagerPrivate -{ - QtDatePropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtDatePropertyManager) -public: - explicit QtDatePropertyManagerPrivate(QtDatePropertyManager* q); - - struct Data - { - QDate val{ QDate::currentDate() }; - QDate minVal{ QDate(1752, 9, 14) }; - QDate maxVal{ QDate(9999, 12, 31) }; - QDate minimumValue() const { return minVal; } - QDate maximumValue() const { return maxVal; } - void setMinimumValue(const QDate& newMinVal) { setSimpleMinimumData(this, newMinVal); } - void setMaximumValue(const QDate& newMaxVal) { setSimpleMaximumData(this, newMaxVal); } - }; - - QString m_format; - - typedef QMap PropertyValueMap; - QMap m_values; -}; - -QtDatePropertyManagerPrivate::QtDatePropertyManagerPrivate(QtDatePropertyManager* q) : - q_ptr(q), - m_format(QtPropertyBrowserUtils::dateFormat()) -{ -} - -/*! - \class QtDatePropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtDatePropertyManager provides and manages QDate properties. - - A date property has a current value, and a range specifying the - valid dates. The range is defined by a minimum and a maximum - value. - - The property's values can be retrieved using the minimum(), - maximum() and value() functions, and can be set using the - setMinimum(), setMaximum() and setValue() slots. Alternatively, - the range can be defined in one go using the setRange() slot. - - In addition, QtDatePropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the rangeChanged() signal which is emitted whenever - such a property changes its range of valid dates. - - \sa AbstractPropertyManager, QtDateEditFactory, QtDateTimePropertyManager -*/ - -/*! - \fn void QtDatePropertyManager::valueChanged(PropertySheet *property, const QDate &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtDatePropertyManager::rangeChanged(PropertySheet *property, const QDate &minimum, const QDate &maximum) - - This signal is emitted whenever a property created by this manager - changes its range of valid dates, passing a pointer to the \a - property and the new \a minimum and \a maximum dates. - - \sa setRange() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtDatePropertyManager::QtDatePropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtDatePropertyManagerPrivate(this)) -{ -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtDatePropertyManager::~QtDatePropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by \e this manager, this - function returns an invalid date. - - \sa setValue() -*/ -QDate QtDatePropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's minimum date. - - \sa maximum(), setRange() -*/ -QDate QtDatePropertyManager::minimum(const PropertySheet* property) const -{ - return getMinimum(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's maximum date. - - \sa minimum(), setRange() -*/ -QDate QtDatePropertyManager::maximum(const PropertySheet* property) const -{ - return getMaximum(d_ptr->m_values, property); -} - -/*! - \reimp -*/ -QString QtDatePropertyManager::valueText(const PropertySheet* property) const -{ - const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().val.toString(d_ptr->m_format); -} - -/*! - \fn void QtDatePropertyManager::setValue(PropertySheet *property, const QDate &value) - - Sets the value of the given \a property to \a value. - - If the specified \a value is not a valid date according to the - given \a property's range, the value is adjusted to the nearest - valid value within the range. - - \sa value(), setRange(), valueChanged() -*/ -void QtDatePropertyManager::setValue(PropertySheet* property, const QDate& val) -{ - void (QtDatePropertyManagerPrivate:: * setSubPropertyValue)(PropertySheet*, const QDate&) = 0; - setValueInRange(this, d_ptr.data(), - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - property, val, setSubPropertyValue); -} - -/*! - Sets the minimum value for the given \a property to \a minVal. - - When setting the minimum value, the maximum and current values are - adjusted if necessary (ensuring that the range remains valid and - that the current value is within in the range). - - \sa minimum(), setRange() -*/ -void QtDatePropertyManager::setMinimum(PropertySheet* property, const QDate& minVal) -{ - setMinimumValue(this, d_ptr.data(), - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - &QtDatePropertyManager::rangeChanged, - property, minVal); -} - -/*! - Sets the maximum value for the given \a property to \a maxVal. - - When setting the maximum value, the minimum and current - values are adjusted if necessary (ensuring that the range remains - valid and that the current value is within in the range). - - \sa maximum(), setRange() -*/ -void QtDatePropertyManager::setMaximum(PropertySheet* property, const QDate& maxVal) -{ - setMaximumValue(this, d_ptr.data(), - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - &QtDatePropertyManager::rangeChanged, - property, maxVal); -} - -/*! - \fn void QtDatePropertyManager::setRange(PropertySheet *property, const QDate &minimum, const QDate &maximum) - - Sets the range of valid dates. - - This is a convenience function defining the range of valid dates - in one go; setting the \a minimum and \a maximum values for the - given \a property with a single function call. - - When setting a new date range, the current value is adjusted if - necessary (ensuring that the value remains in date range). - - \sa setMinimum(), setMaximum(), rangeChanged() -*/ -void QtDatePropertyManager::setRange(PropertySheet* property, const QDate& minVal, const QDate& maxVal) -{ - void (QtDatePropertyManagerPrivate:: * setSubPropertyRange)(PropertySheet*, const QDate&, - const QDate&, const QDate&) = 0; - setBorderValues(this, d_ptr.data(), - &QtDatePropertyManager::propertyChanged, - &QtDatePropertyManager::valueChanged, - &QtDatePropertyManager::rangeChanged, - property, minVal, maxVal, setSubPropertyRange); -} - -/*! - \reimp -*/ -void QtDatePropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtDatePropertyManagerPrivate::Data(); -} - -/*! - \reimp -*/ -void QtDatePropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} - -// QtTimePropertyManager - -class QtTimePropertyManagerPrivate -{ - QtTimePropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtTimePropertyManager) -public: - explicit QtTimePropertyManagerPrivate(QtTimePropertyManager* q); - - const QString m_format; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; -}; - -QtTimePropertyManagerPrivate::QtTimePropertyManagerPrivate(QtTimePropertyManager* q) : - q_ptr(q), - m_format(QtPropertyBrowserUtils::timeFormat()) -{ -} - -/*! - \class QtTimePropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtTimePropertyManager provides and manages QTime properties. - - A time property's value can be retrieved using the value() - function, and set using the setValue() slot. - - In addition, QtTimePropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes. - - \sa AbstractPropertyManager, QtTimeEditFactory -*/ - -/*! - \fn void QtTimePropertyManager::valueChanged(PropertySheet *property, const QTime &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtTimePropertyManager::QtTimePropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtTimePropertyManagerPrivate(this)) -{ -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtTimePropertyManager::~QtTimePropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns an invalid time object. - - \sa setValue() -*/ -QTime QtTimePropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QTime()); -} - -/*! - \reimp -*/ -QString QtTimePropertyManager::valueText(const PropertySheet* property) const -{ - const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().toString(d_ptr->m_format); -} - -/*! - \fn void QtTimePropertyManager::setValue(PropertySheet *property, const QTime &value) - - Sets the value of the given \a property to \a value. - - \sa value(), valueChanged() -*/ -void QtTimePropertyManager::setValue(PropertySheet* property, const QTime& val) -{ - setSimpleValue(d_ptr->m_values, this, - &QtTimePropertyManager::propertyChanged, - &QtTimePropertyManager::valueChanged, - property, val); -} - -/*! - \reimp -*/ -void QtTimePropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QTime::currentTime(); -} - -/*! - \reimp -*/ -void QtTimePropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} - -// QtDateTimePropertyManager - -class QtDateTimePropertyManagerPrivate -{ - QtDateTimePropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtDateTimePropertyManager) -public: - explicit QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager* q); - - const QString m_format; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; -}; - -QtDateTimePropertyManagerPrivate::QtDateTimePropertyManagerPrivate(QtDateTimePropertyManager* q) : - q_ptr(q), - m_format(QtPropertyBrowserUtils::dateTimeFormat()) -{ -} - -/*! \class QtDateTimePropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtDateTimePropertyManager provides and manages QDateTime properties. - - A date and time property has a current value which can be - retrieved using the value() function, and set using the setValue() - slot. In addition, QtDateTimePropertyManager provides the - valueChanged() signal which is emitted whenever a property created - by this manager changes. - - \sa AbstractPropertyManager, QtDateTimeEditFactory, QtDatePropertyManager -*/ - -/*! - \fn void QtDateTimePropertyManager::valueChanged(PropertySheet *property, const QDateTime &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtDateTimePropertyManager::QtDateTimePropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtDateTimePropertyManagerPrivate(this)) -{ -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtDateTimePropertyManager::~QtDateTimePropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an invalid QDateTime object. - - \sa setValue() -*/ -QDateTime QtDateTimePropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QDateTime()); -} - -/*! - \reimp -*/ -QString QtDateTimePropertyManager::valueText(const PropertySheet* property) const -{ - const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().toString(d_ptr->m_format); -} - -/*! - \fn void QtDateTimePropertyManager::setValue(PropertySheet *property, const QDateTime &value) - - Sets the value of the given \a property to \a value. - - \sa value(), valueChanged() -*/ -void QtDateTimePropertyManager::setValue(PropertySheet* property, const QDateTime& val) -{ - setSimpleValue(d_ptr->m_values, this, - &QtDateTimePropertyManager::propertyChanged, - &QtDateTimePropertyManager::valueChanged, - property, val); -} - -/*! - \reimp -*/ -void QtDateTimePropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QDateTime::currentDateTime(); -} - -/*! - \reimp -*/ -void QtDateTimePropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} - -// QtKeySequencePropertyManager - -class QtKeySequencePropertyManagerPrivate -{ - QtKeySequencePropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtKeySequencePropertyManager) -public: - - QString m_format; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; -}; - -/*! \class QtKeySequencePropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtKeySequencePropertyManager provides and manages QKeySequence properties. - - A key sequence's value can be retrieved using the value() - function, and set using the setValue() slot. - - In addition, QtKeySequencePropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes. - - \sa AbstractPropertyManager -*/ - -/*! - \fn void QtKeySequencePropertyManager::valueChanged(PropertySheet *property, const QKeySequence &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtKeySequencePropertyManager::QtKeySequencePropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtKeySequencePropertyManagerPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtKeySequencePropertyManager::~QtKeySequencePropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an empty QKeySequence object. - - \sa setValue() -*/ -QKeySequence QtKeySequencePropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QKeySequence()); -} - -/*! - \reimp -*/ -QString QtKeySequencePropertyManager::valueText(const PropertySheet* property) const -{ - const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - return it.value().toString(QKeySequence::NativeText); -} - -/*! - \fn void QtKeySequencePropertyManager::setValue(PropertySheet *property, const QKeySequence &value) - - Sets the value of the given \a property to \a value. - - \sa value(), valueChanged() -*/ -void QtKeySequencePropertyManager::setValue(PropertySheet* property, const QKeySequence& val) -{ - setSimpleValue(d_ptr->m_values, this, - &QtKeySequencePropertyManager::propertyChanged, - &QtKeySequencePropertyManager::valueChanged, - property, val); -} - -/*! - \reimp -*/ -void QtKeySequencePropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QKeySequence(); -} - -/*! - \reimp -*/ -void QtKeySequencePropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} - -// QtCharPropertyManager - -class QtCharPropertyManagerPrivate -{ - QtCharPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtCharPropertyManager) -public: - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; -}; - -/*! \class QtCharPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtCharPropertyManager provides and manages QChar properties. - - A char's value can be retrieved using the value() - function, and set using the setValue() slot. - - In addition, QtCharPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes. - - \sa AbstractPropertyManager -*/ - -/*! - \fn void QtCharPropertyManager::valueChanged(PropertySheet *property, const QChar &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtCharPropertyManager::QtCharPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtCharPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtCharPropertyManager::~QtCharPropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an null QChar object. - - \sa setValue() -*/ -QChar QtCharPropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QChar()); -} - -/*! - \reimp -*/ -QString QtCharPropertyManager::valueText(const PropertySheet* property) const -{ - const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QChar c = it.value(); - return c.isNull() ? QString() : QString(c); -} - -/*! - \fn void QtCharPropertyManager::setValue(PropertySheet *property, const QChar &value) - - Sets the value of the given \a property to \a value. - - \sa value(), valueChanged() -*/ -void QtCharPropertyManager::setValue(PropertySheet* property, const QChar& val) -{ - setSimpleValue(d_ptr->m_values, this, - &QtCharPropertyManager::propertyChanged, - &QtCharPropertyManager::valueChanged, - property, val); -} - -/*! - \reimp -*/ -void QtCharPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QChar(); -} - -/*! - \reimp -*/ -void QtCharPropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} - -// QtLocalePropertyManager - -class QtLocalePropertyManagerPrivate -{ - QtLocalePropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtLocalePropertyManager) -public: - - QtLocalePropertyManagerPrivate(); - - void slotEnumChanged(PropertySheet* property, int value); - void slotPropertyDestroyed(PropertySheet* property); - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtEnumPropertyManager* m_enumPropertyManager; - - QMap m_propertyToLanguage; - QMap m_propertyToCountry; - - QMap m_languageToProperty; - QMap m_countryToProperty; -}; - -QtLocalePropertyManagerPrivate::QtLocalePropertyManagerPrivate() -{ -} - -void QtLocalePropertyManagerPrivate::slotEnumChanged(PropertySheet* property, int value) -{ - if (PropertySheet* prop = m_languageToProperty.value(property, 0)) { - const QLocale loc = m_values[prop]; - QLocale::Language newLanguage = loc.language(); - QLocale::Country newCountry = loc.country(); - metaEnumProvider()->indexToLocale(value, 0, &newLanguage, 0); - QLocale newLoc(newLanguage, newCountry); - q_ptr->setValue(prop, newLoc); - } - else if (PropertySheet* prop = m_countryToProperty.value(property, 0)) { - const QLocale loc = m_values[prop]; - QLocale::Language newLanguage = loc.language(); - QLocale::Country newCountry = loc.country(); - metaEnumProvider()->indexToLocale(m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, &newLanguage, &newCountry); - QLocale newLoc(newLanguage, newCountry); - q_ptr->setValue(prop, newLoc); - } -} - -void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* subProp = m_languageToProperty.value(property, 0)) { - m_propertyToLanguage[subProp] = 0; - m_languageToProperty.remove(property); - } - else if (PropertySheet* subProp = m_countryToProperty.value(property, 0)) { - m_propertyToCountry[subProp] = 0; - m_countryToProperty.remove(property); - } -} - -/*! - \class QtLocalePropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtLocalePropertyManager provides and manages QLocale properties. - - A locale property has nested \e language and \e country - subproperties. The top-level property's value can be retrieved - using the value() function, and set using the setValue() slot. - - The subproperties are created by QtEnumPropertyManager object. - These submanager can be retrieved using the subEnumPropertyManager() - function. In order to provide editing widgets for the subproperties - in a property browser widget, this manager must be associated with editor factory. - - In addition, QtLocalePropertyManager provides the valueChanged() - signal which is emitted whenever a property created by this - manager changes. - - \sa AbstractPropertyManager, QtEnumPropertyManager -*/ - -/*! - \fn void QtLocalePropertyManager::valueChanged(PropertySheet *property, const QLocale &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtLocalePropertyManager::QtLocalePropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtLocalePropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotEnumChanged(PropertySheet*, int))); - - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtLocalePropertyManager::~QtLocalePropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e language - and \e country subproperties. - - In order to provide editing widgets for the mentioned subproperties - in a property browser widget, this manager must be associated with - an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtEnumPropertyManager* QtLocalePropertyManager::subEnumPropertyManager() const -{ - return d_ptr->m_enumPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns the default locale. - - \sa setValue() -*/ -QLocale QtLocalePropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QLocale()); -} - -/*! - \reimp -*/ -QString QtLocalePropertyManager::valueText(const PropertySheet* property) const -{ - const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - const QLocale loc = it.value(); - - int langIdx = 0; - int countryIdx = 0; - const QtMetaEnumProvider* me = metaEnumProvider(); - me->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx); - if (langIdx < 0) { - qWarning("QtLocalePropertyManager::valueText: Unknown language %d", loc.language()); - return tr(""); - } - const QString languageName = me->languageEnumNames().at(langIdx); - if (countryIdx < 0) { - qWarning("QtLocalePropertyManager::valueText: Unknown country %d for %s", loc.country(), qPrintable(languageName)); - return languageName; - } - const QString countryName = me->countryEnumNames(loc.language()).at(countryIdx); - return tr("%1, %2").arg(languageName, countryName); -} - -/*! - \fn void QtLocalePropertyManager::setValue(PropertySheet *property, const QLocale &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - \sa value(), valueChanged() -*/ -void QtLocalePropertyManager::setValue(PropertySheet* property, const QLocale& val) -{ - const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - const QLocale loc = it.value(); - if (loc == val) - return; - - it.value() = val; - - int langIdx = 0; - int countryIdx = 0; - metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx); - if (loc.language() != val.language()) { - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToLanguage.value(property), langIdx); - d_ptr->m_enumPropertyManager->setEnumNames(d_ptr->m_propertyToCountry.value(property), - metaEnumProvider()->countryEnumNames(val.language())); - } - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToCountry.value(property), countryIdx); - - emit propertyChanged(property); - emit valueChanged(property, val); -} - -/*! - \reimp -*/ -void QtLocalePropertyManager::initializeProperty(PropertySheet* property) -{ - QLocale val; - d_ptr->m_values[property] = val; - - int langIdx = 0; - int countryIdx = 0; - metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx); - - PropertySheet* languageProp = d_ptr->m_enumPropertyManager->addProperty(); - languageProp->setPropertyName(tr("Language")); - d_ptr->m_enumPropertyManager->setEnumNames(languageProp, metaEnumProvider()->languageEnumNames()); - d_ptr->m_enumPropertyManager->setValue(languageProp, langIdx); - d_ptr->m_propertyToLanguage[property] = languageProp; - d_ptr->m_languageToProperty[languageProp] = property; - property->addSubProperty(languageProp); - - PropertySheet* countryProp = d_ptr->m_enumPropertyManager->addProperty(); - countryProp->setPropertyName(tr("Country")); - d_ptr->m_enumPropertyManager->setEnumNames(countryProp, metaEnumProvider()->countryEnumNames(val.language())); - d_ptr->m_enumPropertyManager->setValue(countryProp, countryIdx); - d_ptr->m_propertyToCountry[property] = countryProp; - d_ptr->m_countryToProperty[countryProp] = property; - property->addSubProperty(countryProp); -} - -/*! - \reimp -*/ -void QtLocalePropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* languageProp = d_ptr->m_propertyToLanguage[property]; - if (languageProp) { - d_ptr->m_languageToProperty.remove(languageProp); - delete languageProp; - } - d_ptr->m_propertyToLanguage.remove(property); - - PropertySheet* countryProp = d_ptr->m_propertyToCountry[property]; - if (countryProp) { - d_ptr->m_countryToProperty.remove(countryProp); - delete countryProp; - } - d_ptr->m_propertyToCountry.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtPointPropertyManager - -class QtPointPropertyManagerPrivate -{ - QtPointPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtPointPropertyManager) -public: - - void slotIntChanged(PropertySheet* property, int value); - void slotPropertyDestroyed(PropertySheet* property); - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager* m_intPropertyManager; - - QMap m_propertyToX; - QMap m_propertyToY; - - QMap m_xToProperty; - QMap m_yToProperty; -}; - -void QtPointPropertyManagerPrivate::slotIntChanged(PropertySheet* property, int value) -{ - if (PropertySheet* xprop = m_xToProperty.value(property, 0)) { - QPoint p = m_values[xprop]; - p.setX(value); - q_ptr->setValue(xprop, p); - } - else if (PropertySheet* yprop = m_yToProperty.value(property, 0)) { - QPoint p = m_values[yprop]; - p.setY(value); - q_ptr->setValue(yprop, p); - } -} - -void QtPointPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } -} - -/*! \class QtPointPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtPointPropertyManager provides and manages QPoint properties. - - A point property has nested \e x and \e y subproperties. The - top-level property's value can be retrieved using the value() - function, and set using the setValue() slot. - - The subproperties are created by a QtIntPropertyManager object. This - manager can be retrieved using the subIntPropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - In addition, QtPointPropertyManager provides the valueChanged() signal which - is emitted whenever a property created by this manager changes. - - \sa AbstractPropertyManager, QtIntPropertyManager, QtPointFPropertyManager -*/ - -/*! - \fn void QtPointPropertyManager::valueChanged(PropertySheet *property, const QPoint &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtPointPropertyManager::QtPointPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtPointPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotIntChanged(PropertySheet*, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtPointPropertyManager::~QtPointPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e x and \e y - subproperties. - - In order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtIntPropertyManager* QtPointPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns a point with coordinates (0, 0). - - \sa setValue() -*/ -QPoint QtPointPropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QPoint()); -} - -/*! - \reimp -*/ -QString QtPointPropertyManager::valueText(const PropertySheet* property) const -{ - const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QPoint v = it.value(); - return tr("(%1, %2)").arg(QString::number(v.x())) - .arg(QString::number(v.y())); -} - -/*! - \fn void QtPointPropertyManager::setValue(PropertySheet *property, const QPoint &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - \sa value(), valueChanged() -*/ -void QtPointPropertyManager::setValue(PropertySheet* property, const QPoint& val) -{ - const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - if (it.value() == val) - return; - - it.value() = val; - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], val.x()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], val.y()); - - emit propertyChanged(property); - emit valueChanged(property, val); -} - -/*! - \reimp -*/ -void QtPointPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QPoint(0, 0); - - PropertySheet* xProp = d_ptr->m_intPropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_intPropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); - - PropertySheet* yProp = d_ptr->m_intPropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_intPropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); -} - -/*! - \reimp -*/ -void QtPointPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); - - PropertySheet* yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtPointFPropertyManager - -class QtPointFPropertyManagerPrivate -{ - QtPointFPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtPointFPropertyManager) -public: - - struct Data - { - QPointF val; - int decimals{ 2 }; - }; - - void slotDoubleChanged(PropertySheet* property, double value); - void slotPropertyDestroyed(PropertySheet* property); - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtDoublePropertyManager* m_doublePropertyManager; - - QMap m_propertyToX; - QMap m_propertyToY; - - QMap m_xToProperty; - QMap m_yToProperty; -}; - -void QtPointFPropertyManagerPrivate::slotDoubleChanged(PropertySheet* property, double value) -{ - if (PropertySheet* prop = m_xToProperty.value(property, 0)) { - QPointF p = m_values[prop].val; - p.setX(value); - q_ptr->setValue(prop, p); - } - else if (PropertySheet* prop = m_yToProperty.value(property, 0)) { - QPointF p = m_values[prop].val; - p.setY(value); - q_ptr->setValue(prop, p); - } -} - -void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } -} - -/*! \class QtPointFPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtPointFPropertyManager provides and manages QPointF properties. - - A point property has nested \e x and \e y subproperties. The - top-level property's value can be retrieved using the value() - function, and set using the setValue() slot. - - The subproperties are created by a QtDoublePropertyManager object. This - manager can be retrieved using the subDoublePropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - In addition, QtPointFPropertyManager provides the valueChanged() signal which - is emitted whenever a property created by this manager changes. - - \sa AbstractPropertyManager, QtDoublePropertyManager, QtPointPropertyManager -*/ - -/*! - \fn void QtPointFPropertyManager::valueChanged(PropertySheet *property, const QPointF &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtPointFPropertyManager::decimalsChanged(PropertySheet *property, int prec) - - This signal is emitted whenever a property created by this manager - changes its precision of value, passing a pointer to the - \a property and the new \a prec value - - \sa setDecimals() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtPointFPropertyManager::QtPointFPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtPointFPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(PropertySheet*, double)), - this, SLOT(slotDoubleChanged(PropertySheet*, double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtPointFPropertyManager::~QtPointFPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e x and \e y - subproperties. - - In order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtDoublePropertyManager* QtPointFPropertyManager::subDoublePropertyManager() const -{ - return d_ptr->m_doublePropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns a point with coordinates (0, 0). - - \sa setValue() -*/ -QPointF QtPointFPropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's precision, in decimals. - - \sa setDecimals() -*/ -int QtPointFPropertyManager::decimals(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &QtPointFPropertyManagerPrivate::Data::decimals, property, 0); -} - -/*! - \reimp -*/ -QString QtPointFPropertyManager::valueText(const PropertySheet* property) const -{ - const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QPointF v = it.value().val; - const int dec = it.value().decimals; - return tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec)) - .arg(QString::number(v.y(), 'f', dec)); -} - -/*! - \fn void QtPointFPropertyManager::setValue(PropertySheet *property, const QPointF &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - \sa value(), valueChanged() -*/ -void QtPointFPropertyManager::setValue(PropertySheet* property, const QPointF& val) -{ - const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - if (it.value().val == val) - return; - - it.value().val = val; - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], val.x()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], val.y()); - - emit propertyChanged(property); - emit valueChanged(property, val); -} - -/*! - \fn void QtPointFPropertyManager::setDecimals(PropertySheet *property, int prec) - - Sets the precision of the given \a property to \a prec. - - The valid decimal range is 0-13. The default is 2. - - \sa decimals() -*/ -void QtPointFPropertyManager::setDecimals(PropertySheet* property, int prec) -{ - const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtPointFPropertyManagerPrivate::Data data = it.value(); - - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; - - if (data.decimals == prec) - return; - - data.decimals = prec; - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec); - - it.value() = data; - - emit decimalsChanged(property, data.decimals); -} - -/*! - \reimp -*/ -void QtPointFPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtPointFPropertyManagerPrivate::Data(); - - PropertySheet* xProp = d_ptr->m_doublePropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); - - PropertySheet* yProp = d_ptr->m_doublePropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); -} - -/*! - \reimp -*/ -void QtPointFPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); - - PropertySheet* yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtSizePropertyManager - -class QtSizePropertyManagerPrivate -{ - QtSizePropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtSizePropertyManager) -public: - - void slotIntChanged(PropertySheet* property, int value); - void slotPropertyDestroyed(PropertySheet* property); - void setValue(PropertySheet* property, const QSize& val); - void setRange(PropertySheet* property, - const QSize& minVal, const QSize& maxVal, const QSize& val); - - struct Data - { - QSize val{ 0, 0 }; - QSize minVal{ 0, 0 }; - QSize maxVal{ INT_MAX, INT_MAX }; - QSize minimumValue() const { return minVal; } - QSize maximumValue() const { return maxVal; } - void setMinimumValue(const QSize& newMinVal) { setSizeMinimumData(this, newMinVal); } - void setMaximumValue(const QSize& newMaxVal) { setSizeMaximumData(this, newMaxVal); } - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager* m_intPropertyManager; - - QMap m_propertyToW; - QMap m_propertyToH; - - QMap m_wToProperty; - QMap m_hToProperty; -}; - -void QtSizePropertyManagerPrivate::slotIntChanged(PropertySheet* property, int value) -{ - if (PropertySheet* prop = m_wToProperty.value(property, 0)) { - QSize s = m_values[prop].val; - s.setWidth(value); - q_ptr->setValue(prop, s); - } - else if (PropertySheet* prop = m_hToProperty.value(property, 0)) { - QSize s = m_values[prop].val; - s.setHeight(value); - q_ptr->setValue(prop, s); - } -} - -void QtSizePropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); - } -} - -void QtSizePropertyManagerPrivate::setValue(PropertySheet* property, const QSize& val) -{ - m_intPropertyManager->setValue(m_propertyToW.value(property), val.width()); - m_intPropertyManager->setValue(m_propertyToH.value(property), val.height()); -} - -void QtSizePropertyManagerPrivate::setRange(PropertySheet* property, - const QSize& minVal, const QSize& maxVal, const QSize& val) -{ - PropertySheet* wProperty = m_propertyToW.value(property); - PropertySheet* hProperty = m_propertyToH.value(property); - m_intPropertyManager->setRange(wProperty, minVal.width(), maxVal.width()); - m_intPropertyManager->setValue(wProperty, val.width()); - m_intPropertyManager->setRange(hProperty, minVal.height(), maxVal.height()); - m_intPropertyManager->setValue(hProperty, val.height()); -} - -/*! - \class QtSizePropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtSizePropertyManager provides and manages QSize properties. - - A size property has nested \e width and \e height - subproperties. The top-level property's value can be retrieved - using the value() function, and set using the setValue() slot. - - The subproperties are created by a QtIntPropertyManager object. This - manager can be retrieved using the subIntPropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - A size property also has a range of valid values defined by a - minimum size and a maximum size. These sizes can be retrieved - using the minimum() and the maximum() functions, and set using the - setMinimum() and setMaximum() slots. Alternatively, the range can - be defined in one go using the setRange() slot. - - In addition, QtSizePropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the rangeChanged() signal which is emitted whenever - such a property changes its range of valid sizes. - - \sa AbstractPropertyManager, QtIntPropertyManager, QtSizeFPropertyManager -*/ - -/*! - \fn void QtSizePropertyManager::valueChanged(PropertySheet *property, const QSize &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtSizePropertyManager::rangeChanged(PropertySheet *property, const QSize &minimum, const QSize &maximum) - - This signal is emitted whenever a property created by this manager - changes its range of valid sizes, passing a pointer to the \a - property and the new \a minimum and \a maximum sizes. - - \sa setRange() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtSizePropertyManager::QtSizePropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtSizePropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotIntChanged(PropertySheet*, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtSizePropertyManager::~QtSizePropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e width and \e height - subproperties. - - In order to provide editing widgets for the \e width and \e height - properties in a property browser widget, this manager must be - associated with an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtIntPropertyManager* QtSizePropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an invalid size - - \sa setValue() -*/ -QSize QtSizePropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's minimum size value. - - \sa setMinimum(), maximum(), setRange() -*/ -QSize QtSizePropertyManager::minimum(const PropertySheet* property) const -{ - return getMinimum(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's maximum size value. - - \sa setMaximum(), minimum(), setRange() -*/ -QSize QtSizePropertyManager::maximum(const PropertySheet* property) const -{ - return getMaximum(d_ptr->m_values, property); -} - -/*! - \reimp -*/ -QString QtSizePropertyManager::valueText(const PropertySheet* property) const -{ - const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QSize v = it.value().val; - return tr("%1 x %2").arg(QString::number(v.width())) - .arg(QString::number(v.height())); -} - -/*! - \fn void QtSizePropertyManager::setValue(PropertySheet *property, const QSize &value) - - Sets the value of the given \a property to \a value. - - If the specified \a value is not valid according to the given \a - property's size range, the \a value is adjusted to the nearest - valid value within the size range. - - \sa value(), setRange(), valueChanged() -*/ -void QtSizePropertyManager::setValue(PropertySheet* property, const QSize& val) -{ - setValueInRange(this, d_ptr.data(), - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - property, val, &QtSizePropertyManagerPrivate::setValue); -} - -/*! - Sets the minimum size value for the given \a property to \a minVal. - - When setting the minimum size value, the maximum and current - values are adjusted if necessary (ensuring that the size range - remains valid and that the current value is within the range). - - \sa minimum(), setRange(), rangeChanged() -*/ -void QtSizePropertyManager::setMinimum(PropertySheet* property, const QSize& minVal) -{ - setBorderValue(this, d_ptr.data(), - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - &QtSizePropertyManager::rangeChanged, - property, - &QtSizePropertyManagerPrivate::Data::minimumValue, - &QtSizePropertyManagerPrivate::Data::setMinimumValue, - minVal, &QtSizePropertyManagerPrivate::setRange); -} - -/*! - Sets the maximum size value for the given \a property to \a maxVal. - - When setting the maximum size value, the minimum and current - values are adjusted if necessary (ensuring that the size range - remains valid and that the current value is within the range). - - \sa maximum(), setRange(), rangeChanged() -*/ -void QtSizePropertyManager::setMaximum(PropertySheet* property, const QSize& maxVal) -{ - setBorderValue(this, d_ptr.data(), - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - &QtSizePropertyManager::rangeChanged, - property, - &QtSizePropertyManagerPrivate::Data::maximumValue, - &QtSizePropertyManagerPrivate::Data::setMaximumValue, - maxVal, &QtSizePropertyManagerPrivate::setRange); -} - -/*! - \fn void QtSizePropertyManager::setRange(PropertySheet *property, const QSize &minimum, const QSize &maximum) - - Sets the range of valid values. - - This is a convenience function defining the range of valid values - in one go; setting the \a minimum and \a maximum values for the - given \a property with a single function call. - - When setting a new range, the current value is adjusted if - necessary (ensuring that the value remains within the range). - - \sa setMinimum(), setMaximum(), rangeChanged() -*/ -void QtSizePropertyManager::setRange(PropertySheet* property, const QSize& minVal, const QSize& maxVal) -{ - setBorderValues(this, d_ptr.data(), - &QtSizePropertyManager::propertyChanged, - &QtSizePropertyManager::valueChanged, - &QtSizePropertyManager::rangeChanged, - property, minVal, maxVal, &QtSizePropertyManagerPrivate::setRange); -} - -/*! - \reimp -*/ -void QtSizePropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtSizePropertyManagerPrivate::Data(); - - PropertySheet* wProp = d_ptr->m_intPropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_intPropertyManager->setValue(wProp, 0); - d_ptr->m_intPropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); - - PropertySheet* hProp = d_ptr->m_intPropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_intPropertyManager->setValue(hProp, 0); - d_ptr->m_intPropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); -} - -/*! - \reimp -*/ -void QtSizePropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); - - PropertySheet* hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtSizeFPropertyManager - -class QtSizeFPropertyManagerPrivate -{ - QtSizeFPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtSizeFPropertyManager) -public: - - void slotDoubleChanged(PropertySheet* property, double value); - void slotPropertyDestroyed(PropertySheet* property); - void setValue(PropertySheet* property, const QSizeF& val); - void setRange(PropertySheet* property, - const QSizeF& minVal, const QSizeF& maxVal, const QSizeF& val); - - struct Data - { - QSizeF val{ 0, 0 }; - QSizeF minVal{ 0, 0 }; - QSizeF maxVal{ std::numeric_limits::max(), std::numeric_limits::max() }; - int decimals{ 2 }; - QSizeF minimumValue() const { return minVal; } - QSizeF maximumValue() const { return maxVal; } - void setMinimumValue(const QSizeF& newMinVal) { setSizeMinimumData(this, newMinVal); } - void setMaximumValue(const QSizeF& newMaxVal) { setSizeMaximumData(this, newMaxVal); } - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtDoublePropertyManager* m_doublePropertyManager; - - QMap m_propertyToW; - QMap m_propertyToH; - - QMap m_wToProperty; - QMap m_hToProperty; -}; - -void QtSizeFPropertyManagerPrivate::slotDoubleChanged(PropertySheet* property, double value) -{ - if (PropertySheet* prop = m_wToProperty.value(property, 0)) { - QSizeF s = m_values[prop].val; - s.setWidth(value); - q_ptr->setValue(prop, s); - } - else if (PropertySheet* prop = m_hToProperty.value(property, 0)) { - QSizeF s = m_values[prop].val; - s.setHeight(value); - q_ptr->setValue(prop, s); - } -} - -void QtSizeFPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); - } -} - -void QtSizeFPropertyManagerPrivate::setValue(PropertySheet* property, const QSizeF& val) -{ - m_doublePropertyManager->setValue(m_propertyToW.value(property), val.width()); - m_doublePropertyManager->setValue(m_propertyToH.value(property), val.height()); -} - -void QtSizeFPropertyManagerPrivate::setRange(PropertySheet* property, - const QSizeF& minVal, const QSizeF& maxVal, const QSizeF& val) -{ - m_doublePropertyManager->setRange(m_propertyToW[property], minVal.width(), maxVal.width()); - m_doublePropertyManager->setValue(m_propertyToW[property], val.width()); - m_doublePropertyManager->setRange(m_propertyToH[property], minVal.height(), maxVal.height()); - m_doublePropertyManager->setValue(m_propertyToH[property], val.height()); -} - -/*! - \class QtSizeFPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtSizeFPropertyManager provides and manages QSizeF properties. - - A size property has nested \e width and \e height - subproperties. The top-level property's value can be retrieved - using the value() function, and set using the setValue() slot. - - The subproperties are created by a QtDoublePropertyManager object. This - manager can be retrieved using the subDoublePropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - A size property also has a range of valid values defined by a - minimum size and a maximum size. These sizes can be retrieved - using the minimum() and the maximum() functions, and set using the - setMinimum() and setMaximum() slots. Alternatively, the range can - be defined in one go using the setRange() slot. - - In addition, QtSizeFPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the rangeChanged() signal which is emitted whenever - such a property changes its range of valid sizes. - - \sa AbstractPropertyManager, QtDoublePropertyManager, QtSizePropertyManager -*/ - -/*! - \fn void QtSizeFPropertyManager::valueChanged(PropertySheet *property, const QSizeF &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtSizeFPropertyManager::rangeChanged(PropertySheet *property, const QSizeF &minimum, const QSizeF &maximum) - - This signal is emitted whenever a property created by this manager - changes its range of valid sizes, passing a pointer to the \a - property and the new \a minimum and \a maximum sizes. - - \sa setRange() -*/ - -/*! - \fn void QtSizeFPropertyManager::decimalsChanged(PropertySheet *property, int prec) - - This signal is emitted whenever a property created by this manager - changes its precision of value, passing a pointer to the - \a property and the new \a prec value - - \sa setDecimals() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtSizeFPropertyManager::QtSizeFPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtSizeFPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(PropertySheet*, double)), - this, SLOT(slotDoubleChanged(PropertySheet*, double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtSizeFPropertyManager::~QtSizeFPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e width and \e height - subproperties. - - In order to provide editing widgets for the \e width and \e height - properties in a property browser widget, this manager must be - associated with an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtDoublePropertyManager* QtSizeFPropertyManager::subDoublePropertyManager() const -{ - return d_ptr->m_doublePropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an invalid size - - \sa setValue() -*/ -QSizeF QtSizeFPropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's precision, in decimals. - - \sa setDecimals() -*/ -int QtSizeFPropertyManager::decimals(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &QtSizeFPropertyManagerPrivate::Data::decimals, property, 0); -} - -/*! - Returns the given \a property's minimum size value. - - \sa setMinimum(), maximum(), setRange() -*/ -QSizeF QtSizeFPropertyManager::minimum(const PropertySheet* property) const -{ - return getMinimum(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's maximum size value. - - \sa setMaximum(), minimum(), setRange() -*/ -QSizeF QtSizeFPropertyManager::maximum(const PropertySheet* property) const -{ - return getMaximum(d_ptr->m_values, property); -} - -/*! - \reimp -*/ -QString QtSizeFPropertyManager::valueText(const PropertySheet* property) const -{ - const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QSizeF v = it.value().val; - const int dec = it.value().decimals; - return tr("%1 x %2").arg(QString::number(v.width(), 'f', dec)) - .arg(QString::number(v.height(), 'f', dec)); -} - -/*! - \fn void QtSizeFPropertyManager::setValue(PropertySheet *property, const QSizeF &value) - - Sets the value of the given \a property to \a value. - - If the specified \a value is not valid according to the given \a - property's size range, the \a value is adjusted to the nearest - valid value within the size range. - - \sa value(), setRange(), valueChanged() -*/ -void QtSizeFPropertyManager::setValue(PropertySheet* property, const QSizeF& val) -{ - setValueInRange(this, d_ptr.data(), - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - property, val, &QtSizeFPropertyManagerPrivate::setValue); -} - -/*! - \fn void QtSizeFPropertyManager::setDecimals(PropertySheet *property, int prec) - - Sets the precision of the given \a property to \a prec. - - The valid decimal range is 0-13. The default is 2. - - \sa decimals() -*/ -void QtSizeFPropertyManager::setDecimals(PropertySheet* property, int prec) -{ - const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtSizeFPropertyManagerPrivate::Data data = it.value(); - - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; - - if (data.decimals == prec) - return; - - data.decimals = prec; - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec); - - it.value() = data; - - emit decimalsChanged(property, data.decimals); -} - -/*! - Sets the minimum size value for the given \a property to \a minVal. - - When setting the minimum size value, the maximum and current - values are adjusted if necessary (ensuring that the size range - remains valid and that the current value is within the range). - - \sa minimum(), setRange(), rangeChanged() -*/ -void QtSizeFPropertyManager::setMinimum(PropertySheet* property, const QSizeF& minVal) -{ - setBorderValue(this, d_ptr.data(), - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - &QtSizeFPropertyManager::rangeChanged, - property, - &QtSizeFPropertyManagerPrivate::Data::minimumValue, - &QtSizeFPropertyManagerPrivate::Data::setMinimumValue, - minVal, &QtSizeFPropertyManagerPrivate::setRange); -} - -/*! - Sets the maximum size value for the given \a property to \a maxVal. - - When setting the maximum size value, the minimum and current - values are adjusted if necessary (ensuring that the size range - remains valid and that the current value is within the range). - - \sa maximum(), setRange(), rangeChanged() -*/ -void QtSizeFPropertyManager::setMaximum(PropertySheet* property, const QSizeF& maxVal) -{ - setBorderValue(this, d_ptr.data(), - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - &QtSizeFPropertyManager::rangeChanged, - property, - &QtSizeFPropertyManagerPrivate::Data::maximumValue, - &QtSizeFPropertyManagerPrivate::Data::setMaximumValue, - maxVal, &QtSizeFPropertyManagerPrivate::setRange); -} - -/*! - \fn void QtSizeFPropertyManager::setRange(PropertySheet *property, const QSizeF &minimum, const QSizeF &maximum) - - Sets the range of valid values. - - This is a convenience function defining the range of valid values - in one go; setting the \a minimum and \a maximum values for the - given \a property with a single function call. - - When setting a new range, the current value is adjusted if - necessary (ensuring that the value remains within the range). - - \sa setMinimum(), setMaximum(), rangeChanged() -*/ -void QtSizeFPropertyManager::setRange(PropertySheet* property, const QSizeF& minVal, const QSizeF& maxVal) -{ - setBorderValues(this, d_ptr.data(), - &QtSizeFPropertyManager::propertyChanged, - &QtSizeFPropertyManager::valueChanged, - &QtSizeFPropertyManager::rangeChanged, - property, minVal, maxVal, &QtSizeFPropertyManagerPrivate::setRange); -} - -/*! - \reimp -*/ -void QtSizeFPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtSizeFPropertyManagerPrivate::Data(); - - PropertySheet* wProp = d_ptr->m_doublePropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(wProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); - - PropertySheet* hProp = d_ptr->m_doublePropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(hProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); -} - -/*! - \reimp -*/ -void QtSizeFPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); - - PropertySheet* hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtRectPropertyManager - -class QtRectPropertyManagerPrivate -{ - QtRectPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtRectPropertyManager) -public: - - void slotIntChanged(PropertySheet* property, int value); - void slotPropertyDestroyed(PropertySheet* property); - void setConstraint(PropertySheet* property, const QRect& constraint, const QRect& val); - - struct Data - { - QRect val{ 0, 0, 0, 0 }; - QRect constraint; - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager* m_intPropertyManager; - - QMap m_propertyToX; - QMap m_propertyToY; - QMap m_propertyToW; - QMap m_propertyToH; - - QMap m_xToProperty; - QMap m_yToProperty; - QMap m_wToProperty; - QMap m_hToProperty; -}; - -void QtRectPropertyManagerPrivate::slotIntChanged(PropertySheet* property, int value) -{ - if (PropertySheet* prop = m_xToProperty.value(property, 0)) { - QRect r = m_values[prop].val; - r.moveLeft(value); - q_ptr->setValue(prop, r); - } - else if (PropertySheet* prop = m_yToProperty.value(property)) { - QRect r = m_values[prop].val; - r.moveTop(value); - q_ptr->setValue(prop, r); - } - else if (PropertySheet* prop = m_wToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRect r = data.val; - r.setWidth(value); - if (!data.constraint.isNull() && data.constraint.x() + data.constraint.width() < r.x() + r.width()) { - r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); - } - q_ptr->setValue(prop, r); - } - else if (PropertySheet* prop = m_hToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRect r = data.val; - r.setHeight(value); - if (!data.constraint.isNull() && data.constraint.y() + data.constraint.height() < r.y() + r.height()) { - r.moveTop(data.constraint.top() + data.constraint.height() - r.height()); - } - q_ptr->setValue(prop, r); - } -} - -void QtRectPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); - } -} - -void QtRectPropertyManagerPrivate::setConstraint(PropertySheet* property, - const QRect& constraint, const QRect& val) -{ - const bool isNull = constraint.isNull(); - const int left = isNull ? INT_MIN : constraint.left(); - const int right = isNull ? INT_MAX : constraint.left() + constraint.width(); - const int top = isNull ? INT_MIN : constraint.top(); - const int bottom = isNull ? INT_MAX : constraint.top() + constraint.height(); - const int width = isNull ? INT_MAX : constraint.width(); - const int height = isNull ? INT_MAX : constraint.height(); - - m_intPropertyManager->setRange(m_propertyToX[property], left, right); - m_intPropertyManager->setRange(m_propertyToY[property], top, bottom); - m_intPropertyManager->setRange(m_propertyToW[property], 0, width); - m_intPropertyManager->setRange(m_propertyToH[property], 0, height); - - m_intPropertyManager->setValue(m_propertyToX[property], val.x()); - m_intPropertyManager->setValue(m_propertyToY[property], val.y()); - m_intPropertyManager->setValue(m_propertyToW[property], val.width()); - m_intPropertyManager->setValue(m_propertyToH[property], val.height()); -} - -/*! - \class QtRectPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtRectPropertyManager provides and manages QRect properties. - - A rectangle property has nested \e x, \e y, \e width and \e height - subproperties. The top-level property's value can be retrieved - using the value() function, and set using the setValue() slot. - - The subproperties are created by a QtIntPropertyManager object. This - manager can be retrieved using the subIntPropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - A rectangle property also has a constraint rectangle which can be - retrieved using the constraint() function, and set using the - setConstraint() slot. - - In addition, QtRectPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the constraintChanged() signal which is emitted - whenever such a property changes its constraint rectangle. - - \sa AbstractPropertyManager, QtIntPropertyManager, QtRectFPropertyManager -*/ - -/*! - \fn void QtRectPropertyManager::valueChanged(PropertySheet *property, const QRect &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtRectPropertyManager::constraintChanged(PropertySheet *property, const QRect &constraint) - - This signal is emitted whenever property changes its constraint - rectangle, passing a pointer to the \a property and the new \a - constraint rectangle as parameters. - - \sa setConstraint() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtRectPropertyManager::QtRectPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtRectPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotIntChanged(PropertySheet*, int))); - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtRectPropertyManager::~QtRectPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e x, \e y, \e width - and \e height subproperties. - - In order to provide editing widgets for the mentioned - subproperties in a property browser widget, this manager must be - associated with an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtIntPropertyManager* QtRectPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an invalid rectangle. - - \sa setValue(), constraint() -*/ -QRect QtRectPropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's constraining rectangle. If returned value is null QRect it means there is no constraint applied. - - \sa value(), setConstraint() -*/ -QRect QtRectPropertyManager::constraint(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &QtRectPropertyManagerPrivate::Data::constraint, property, QRect()); -} - -/*! - \reimp -*/ -QString QtRectPropertyManager::valueText(const PropertySheet* property) const -{ - const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QRect v = it.value().val; - return tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x())) - .arg(QString::number(v.y())) - .arg(QString::number(v.width())) - .arg(QString::number(v.height())); -} - -/*! - \fn void QtRectPropertyManager::setValue(PropertySheet *property, const QRect &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - If the specified \a value is not inside the given \a property's - constraining rectangle, the value is adjusted accordingly to fit - within the constraint. - - \sa value(), setConstraint(), valueChanged() -*/ -void QtRectPropertyManager::setValue(PropertySheet* property, const QRect& val) -{ - const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtRectPropertyManagerPrivate::Data data = it.value(); - - QRect newRect = val.normalized(); - if (!data.constraint.isNull() && !data.constraint.contains(newRect)) { - const QRect r1 = data.constraint; - const QRect r2 = newRect; - newRect.setLeft(qMax(r1.left(), r2.left())); - newRect.setRight(qMin(r1.right(), r2.right())); - newRect.setTop(qMax(r1.top(), r2.top())); - newRect.setBottom(qMin(r1.bottom(), r2.bottom())); - if (newRect.width() < 0 || newRect.height() < 0) - return; - } - - if (data.val == newRect) - return; - - data.val = newRect; - - it.value() = data; - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height()); - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - Sets the given \a property's constraining rectangle to \a - constraint. - - When setting the constraint, the current value is adjusted if - necessary (ensuring that the current rectangle value is inside the - constraint). In order to reset the constraint pass a null QRect value. - - \sa setValue(), constraint(), constraintChanged() -*/ -void QtRectPropertyManager::setConstraint(PropertySheet* property, const QRect& constraint) -{ - const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtRectPropertyManagerPrivate::Data data = it.value(); - - QRect newConstraint = constraint.normalized(); - if (data.constraint == newConstraint) - return; - - const QRect oldVal = data.val; - - data.constraint = newConstraint; - - if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) { - QRect r1 = data.constraint; - QRect r2 = data.val; - - if (r2.width() > r1.width()) - r2.setWidth(r1.width()); - if (r2.height() > r1.height()) - r2.setHeight(r1.height()); - if (r2.left() < r1.left()) - r2.moveLeft(r1.left()); - else if (r2.right() > r1.right()) - r2.moveRight(r1.right()); - if (r2.top() < r1.top()) - r2.moveTop(r1.top()); - else if (r2.bottom() > r1.bottom()) - r2.moveBottom(r1.bottom()); - - data.val = r2; - } - - it.value() = data; - - emit constraintChanged(property, data.constraint); - - d_ptr->setConstraint(property, data.constraint, data.val); - - if (data.val == oldVal) - return; - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - \reimp -*/ -void QtRectPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtRectPropertyManagerPrivate::Data(); - - PropertySheet* xProp = d_ptr->m_intPropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_intPropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); - - PropertySheet* yProp = d_ptr->m_intPropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_intPropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); - - PropertySheet* wProp = d_ptr->m_intPropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_intPropertyManager->setValue(wProp, 0); - d_ptr->m_intPropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); - - PropertySheet* hProp = d_ptr->m_intPropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_intPropertyManager->setValue(hProp, 0); - d_ptr->m_intPropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); -} - -/*! - \reimp -*/ -void QtRectPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); - - PropertySheet* yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); - - PropertySheet* wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); - - PropertySheet* hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtRectFPropertyManager - -class QtRectFPropertyManagerPrivate -{ - QtRectFPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtRectFPropertyManager) -public: - - void slotDoubleChanged(PropertySheet* property, double value); - void slotPropertyDestroyed(PropertySheet* property); - void setConstraint(PropertySheet* property, const QRectF& constraint, const QRectF& val); - - struct Data - { - QRectF val{ 0, 0, 0, 0 }; - QRectF constraint; - int decimals{ 2 }; - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtDoublePropertyManager* m_doublePropertyManager; - - QMap m_propertyToX; - QMap m_propertyToY; - QMap m_propertyToW; - QMap m_propertyToH; - - QMap m_xToProperty; - QMap m_yToProperty; - QMap m_wToProperty; - QMap m_hToProperty; -}; - -void QtRectFPropertyManagerPrivate::slotDoubleChanged(PropertySheet* property, double value) -{ - if (PropertySheet* prop = m_xToProperty.value(property, 0)) { - QRectF r = m_values[prop].val; - r.moveLeft(value); - q_ptr->setValue(prop, r); - } - else if (PropertySheet* prop = m_yToProperty.value(property, 0)) { - QRectF r = m_values[prop].val; - r.moveTop(value); - q_ptr->setValue(prop, r); - } - else if (PropertySheet* prop = m_wToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRectF r = data.val; - r.setWidth(value); - if (!data.constraint.isNull() && data.constraint.x() + data.constraint.width() < r.x() + r.width()) { - r.moveLeft(data.constraint.left() + data.constraint.width() - r.width()); - } - q_ptr->setValue(prop, r); - } - else if (PropertySheet* prop = m_hToProperty.value(property, 0)) { - Data data = m_values[prop]; - QRectF r = data.val; - r.setHeight(value); - if (!data.constraint.isNull() && data.constraint.y() + data.constraint.height() < r.y() + r.height()) { - r.moveTop(data.constraint.top() + data.constraint.height() - r.height()); - } - q_ptr->setValue(prop, r); - } -} - -void QtRectFPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_wToProperty.value(property, 0)) { - m_propertyToW[pointProp] = 0; - m_wToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_hToProperty.value(property, 0)) { - m_propertyToH[pointProp] = 0; - m_hToProperty.remove(property); - } -} - -void QtRectFPropertyManagerPrivate::setConstraint(PropertySheet* property, - const QRectF& constraint, const QRectF& val) -{ - const bool isNull = constraint.isNull(); - const float left = isNull ? FLT_MIN : constraint.left(); - const float right = isNull ? FLT_MAX : constraint.left() + constraint.width(); - const float top = isNull ? FLT_MIN : constraint.top(); - const float bottom = isNull ? FLT_MAX : constraint.top() + constraint.height(); - const float width = isNull ? FLT_MAX : constraint.width(); - const float height = isNull ? FLT_MAX : constraint.height(); - - m_doublePropertyManager->setRange(m_propertyToX[property], left, right); - m_doublePropertyManager->setRange(m_propertyToY[property], top, bottom); - m_doublePropertyManager->setRange(m_propertyToW[property], 0, width); - m_doublePropertyManager->setRange(m_propertyToH[property], 0, height); - - m_doublePropertyManager->setValue(m_propertyToX[property], val.x()); - m_doublePropertyManager->setValue(m_propertyToY[property], val.y()); - m_doublePropertyManager->setValue(m_propertyToW[property], val.width()); - m_doublePropertyManager->setValue(m_propertyToH[property], val.height()); -} - -/*! - \class QtRectFPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtRectFPropertyManager provides and manages QRectF properties. - - A rectangle property has nested \e x, \e y, \e width and \e height - subproperties. The top-level property's value can be retrieved - using the value() function, and set using the setValue() slot. - - The subproperties are created by a QtDoublePropertyManager object. This - manager can be retrieved using the subDoublePropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - A rectangle property also has a constraint rectangle which can be - retrieved using the constraint() function, and set using the - setConstraint() slot. - - In addition, QtRectFPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the constraintChanged() signal which is emitted - whenever such a property changes its constraint rectangle. - - \sa AbstractPropertyManager, QtDoublePropertyManager, QtRectPropertyManager -*/ - -/*! - \fn void QtRectFPropertyManager::valueChanged(PropertySheet *property, const QRectF &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtRectFPropertyManager::constraintChanged(PropertySheet *property, const QRectF &constraint) - - This signal is emitted whenever property changes its constraint - rectangle, passing a pointer to the \a property and the new \a - constraint rectangle as parameters. - - \sa setConstraint() -*/ - -/*! - \fn void QtRectFPropertyManager::decimalsChanged(PropertySheet *property, int prec) - - This signal is emitted whenever a property created by this manager - changes its precision of value, passing a pointer to the - \a property and the new \a prec value - - \sa setDecimals() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtRectFPropertyManager::QtRectFPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtRectFPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(PropertySheet*, double)), - this, SLOT(slotDoubleChanged(PropertySheet*, double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtRectFPropertyManager::~QtRectFPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e x, \e y, \e width - and \e height subproperties. - - In order to provide editing widgets for the mentioned - subproperties in a property browser widget, this manager must be - associated with an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtDoublePropertyManager* QtRectFPropertyManager::subDoublePropertyManager() const -{ - return d_ptr->m_doublePropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an invalid rectangle. - - \sa setValue(), constraint() -*/ -QRectF QtRectFPropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property); -} - -/*! - Returns the given \a property's precision, in decimals. - - \sa setDecimals() -*/ -int QtRectFPropertyManager::decimals(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::decimals, property, 0); -} - -/*! - Returns the given \a property's constraining rectangle. If returned value is null QRectF it means there is no constraint applied. - - \sa value(), setConstraint() -*/ -QRectF QtRectFPropertyManager::constraint(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::constraint, property, QRect()); -} - -/*! - \reimp -*/ -QString QtRectFPropertyManager::valueText(const PropertySheet* property) const -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - const QRectF v = it.value().val; - const int dec = it.value().decimals; - return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x(), 'f', dec)) - .arg(QString::number(v.y(), 'f', dec)) - .arg(QString::number(v.width(), 'f', dec)) - .arg(QString::number(v.height(), 'f', dec))); -} - -/*! - \fn void QtRectFPropertyManager::setValue(PropertySheet *property, const QRectF &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - If the specified \a value is not inside the given \a property's - constraining rectangle, the value is adjusted accordingly to fit - within the constraint. - - \sa value(), setConstraint(), valueChanged() -*/ -void QtRectFPropertyManager::setValue(PropertySheet* property, const QRectF& val) -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtRectFPropertyManagerPrivate::Data data = it.value(); - - QRectF newRect = val.normalized(); - if (!data.constraint.isNull() && !data.constraint.contains(newRect)) { - const QRectF r1 = data.constraint; - const QRectF r2 = newRect; - newRect.setLeft(qMax(r1.left(), r2.left())); - newRect.setRight(qMin(r1.right(), r2.right())); - newRect.setTop(qMax(r1.top(), r2.top())); - newRect.setBottom(qMin(r1.bottom(), r2.bottom())); - if (newRect.width() < 0 || newRect.height() < 0) - return; - } - - if (data.val == newRect) - return; - - data.val = newRect; - - it.value() = data; - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height()); - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - Sets the given \a property's constraining rectangle to \a - constraint. - - When setting the constraint, the current value is adjusted if - necessary (ensuring that the current rectangle value is inside the - constraint). In order to reset the constraint pass a null QRectF value. - - \sa setValue(), constraint(), constraintChanged() -*/ -void QtRectFPropertyManager::setConstraint(PropertySheet* property, const QRectF& constraint) -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtRectFPropertyManagerPrivate::Data data = it.value(); - - QRectF newConstraint = constraint.normalized(); - if (data.constraint == newConstraint) - return; - - const QRectF oldVal = data.val; - - data.constraint = newConstraint; - - if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) { - QRectF r1 = data.constraint; - QRectF r2 = data.val; - - if (r2.width() > r1.width()) - r2.setWidth(r1.width()); - if (r2.height() > r1.height()) - r2.setHeight(r1.height()); - if (r2.left() < r1.left()) - r2.moveLeft(r1.left()); - else if (r2.right() > r1.right()) - r2.moveRight(r1.right()); - if (r2.top() < r1.top()) - r2.moveTop(r1.top()); - else if (r2.bottom() > r1.bottom()) - r2.moveBottom(r1.bottom()); - - data.val = r2; - } - - it.value() = data; - - emit constraintChanged(property, data.constraint); - - d_ptr->setConstraint(property, data.constraint, data.val); - - if (data.val == oldVal) - return; - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - \fn void QtRectFPropertyManager::setDecimals(PropertySheet *property, int prec) - - Sets the precision of the given \a property to \a prec. - - The valid decimal range is 0-13. The default is 2. - - \sa decimals() -*/ -void QtRectFPropertyManager::setDecimals(PropertySheet* property, int prec) -{ - const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtRectFPropertyManagerPrivate::Data data = it.value(); - - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; - - if (data.decimals == prec) - return; - - data.decimals = prec; - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec); - - it.value() = data; - - emit decimalsChanged(property, data.decimals); -} - -/*! - \reimp -*/ -void QtRectFPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtRectFPropertyManagerPrivate::Data(); - - PropertySheet* xProp = d_ptr->m_doublePropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); - - PropertySheet* yProp = d_ptr->m_doublePropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); - - PropertySheet* wProp = d_ptr->m_doublePropertyManager->addProperty(); - wProp->setPropertyName(tr("Width")); - d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(wProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(wProp, 0); - d_ptr->m_propertyToW[property] = wProp; - d_ptr->m_wToProperty[wProp] = property; - property->addSubProperty(wProp); - - PropertySheet* hProp = d_ptr->m_doublePropertyManager->addProperty(); - hProp->setPropertyName(tr("Height")); - d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(hProp, 0); - d_ptr->m_doublePropertyManager->setMinimum(hProp, 0); - d_ptr->m_propertyToH[property] = hProp; - d_ptr->m_hToProperty[hProp] = property; - property->addSubProperty(hProp); -} - -/*! - \reimp -*/ -void QtRectFPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); - - PropertySheet* yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); - - PropertySheet* wProp = d_ptr->m_propertyToW[property]; - if (wProp) { - d_ptr->m_wToProperty.remove(wProp); - delete wProp; - } - d_ptr->m_propertyToW.remove(property); - - PropertySheet* hProp = d_ptr->m_propertyToH[property]; - if (hProp) { - d_ptr->m_hToProperty.remove(hProp); - delete hProp; - } - d_ptr->m_propertyToH.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtEnumPropertyManager - -class QtEnumPropertyManagerPrivate -{ - QtEnumPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtEnumPropertyManager) -public: - - struct Data - { - int val{ -1 }; - QStringList enumNames; - QMap enumIcons; - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; -}; - -/*! - \class QtEnumPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtEnumPropertyManager provides and manages enum properties. - - Each enum property has an associated list of enum names which can - be retrieved using the enumNames() function, and set using the - corresponding setEnumNames() function. An enum property's value is - represented by an index in this list, and can be retrieved and set - using the value() and setValue() slots respectively. - - Each enum value can also have an associated icon. The mapping from - values to icons can be set using the setEnumIcons() function and - queried with the enumIcons() function. - - In addition, QtEnumPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes. The enumNamesChanged() or enumIconsChanged() signal is emitted - whenever the list of enum names or icons is altered. - - \sa AbstractPropertyManager, QtEnumEditorFactory -*/ - -/*! - \fn void QtEnumPropertyManager::valueChanged(PropertySheet *property, int value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtEnumPropertyManager::enumNamesChanged(PropertySheet *property, const QStringList &names) - - This signal is emitted whenever a property created by this manager - changes its enum names, passing a pointer to the \a property and - the new \a names as parameters. - - \sa setEnumNames() -*/ - -/*! - \fn void QtEnumPropertyManager::enumIconsChanged(PropertySheet *property, const QMap &icons) - - This signal is emitted whenever a property created by this manager - changes its enum icons, passing a pointer to the \a property and - the new mapping of values to \a icons as parameters. - - \sa setEnumIcons() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtEnumPropertyManager::QtEnumPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtEnumPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtEnumPropertyManager::~QtEnumPropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value which is an index in the - list returned by enumNames() - - If the given property is not managed by this manager, this - function returns -1. - - \sa enumNames(), setValue() -*/ -int QtEnumPropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property, -1); -} - -/*! - Returns the given \a property's list of enum names. - - \sa value(), setEnumNames() -*/ -QStringList QtEnumPropertyManager::enumNames(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumNames, property, QStringList()); -} - -/*! - Returns the given \a property's map of enum values to their icons. - - \sa value(), setEnumIcons() -*/ -QMap QtEnumPropertyManager::enumIcons(const PropertySheet* property) const -{ - return getData >(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumIcons, property, QMap()); -} - -/*! - \reimp -*/ -QString QtEnumPropertyManager::valueText(const PropertySheet* property) const -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - const QtEnumPropertyManagerPrivate::Data& data = it.value(); - - const int v = data.val; - if (v >= 0 && v < data.enumNames.count()) - return data.enumNames.at(v); - return QString(); -} - -/*! - \reimp -*/ -QIcon QtEnumPropertyManager::valueIcon(const PropertySheet* property) const -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); - - const QtEnumPropertyManagerPrivate::Data& data = it.value(); - - const int v = data.val; - return data.enumIcons.value(v); -} - -/*! - \fn void QtEnumPropertyManager::setValue(PropertySheet *property, int value) - - Sets the value of the given \a property to \a value. - - The specified \a value must be less than the size of the given \a - property's enumNames() list, and larger than (or equal to) 0. - - \sa value(), valueChanged() -*/ -void QtEnumPropertyManager::setValue(PropertySheet* property, int val) -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtEnumPropertyManagerPrivate::Data data = it.value(); - - if (val >= data.enumNames.count()) - return; - - if (val < 0 && data.enumNames.count() > 0) - return; - - if (val < 0) - val = -1; - - if (data.val == val) - return; - - data.val = val; - - it.value() = data; - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - Sets the given \a property's list of enum names to \a - enumNames. The \a property's current value is reset to 0 - indicating the first item of the list. - - If the specified \a enumNames list is empty, the \a property's - current value is set to -1. - - \sa enumNames(), enumNamesChanged() -*/ -void QtEnumPropertyManager::setEnumNames(PropertySheet* property, const QStringList& enumNames) -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtEnumPropertyManagerPrivate::Data data = it.value(); - - if (data.enumNames == enumNames) - return; - - data.enumNames = enumNames; - - data.val = -1; - - if (enumNames.count() > 0) - data.val = 0; - - it.value() = data; - - emit enumNamesChanged(property, data.enumNames); - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - Sets the given \a property's map of enum values to their icons to \a - enumIcons. - - Each enum value can have associated icon. This association is represented with passed \a enumIcons map. - - \sa enumNames(), enumNamesChanged() -*/ -void QtEnumPropertyManager::setEnumIcons(PropertySheet* property, const QMap& enumIcons) -{ - const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - it.value().enumIcons = enumIcons; - - emit enumIconsChanged(property, it.value().enumIcons); - - emit propertyChanged(property); -} - -/*! - \reimp -*/ -void QtEnumPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtEnumPropertyManagerPrivate::Data(); -} - -/*! - \reimp -*/ -void QtEnumPropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} - -// QtFlagPropertyManager - -class QtFlagPropertyManagerPrivate -{ - QtFlagPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtFlagPropertyManager) -public: - - void slotBoolChanged(PropertySheet* property, bool value); - void slotPropertyDestroyed(PropertySheet* property); - - struct Data - { - int val{ -1 }; - QStringList flagNames; - }; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtBoolPropertyManager* m_boolPropertyManager; - - QMap > m_propertyToFlags; - - QMap m_flagToProperty; -}; - -void QtFlagPropertyManagerPrivate::slotBoolChanged(PropertySheet* property, bool value) -{ - PropertySheet* prop = m_flagToProperty.value(property, 0); - if (prop == 0) - return; - - const auto pfit = m_propertyToFlags.constFind(prop); - if (pfit == m_propertyToFlags.constEnd()) - return; - int level = 0; - for (PropertySheet* p : pfit.value()) { - if (p == property) { - int v = m_values[prop].val; - if (value) { - v |= (1 << level); - } - else { - v &= ~(1 << level); - } - q_ptr->setValue(prop, v); - return; - } - level++; - } -} - -void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - PropertySheet* flagProperty = m_flagToProperty.value(property, 0); - if (flagProperty == 0) - return; - - m_propertyToFlags[flagProperty].replace(m_propertyToFlags[flagProperty].indexOf(property), 0); - m_flagToProperty.remove(property); -} - -/*! - \class QtFlagPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtFlagPropertyManager provides and manages flag properties. - - Each flag property has an associated list of flag names which can - be retrieved using the flagNames() function, and set using the - corresponding setFlagNames() function. - - The flag manager provides properties with nested boolean - subproperties representing each flag, i.e. a flag property's value - is the binary combination of the subproperties' values. A - property's value can be retrieved and set using the value() and - setValue() slots respectively. The combination of flags is represented - by single int value - that's why it's possible to store up to - 32 independent flags in one flag property. - - The subproperties are created by a QtBoolPropertyManager object. This - manager can be retrieved using the subBoolPropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - In addition, QtFlagPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes, and the flagNamesChanged() signal which is emitted - whenever the list of flag names is altered. - - \sa AbstractPropertyManager, QtBoolPropertyManager -*/ - -/*! - \fn void QtFlagPropertyManager::valueChanged(PropertySheet *property, int value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtFlagPropertyManager::flagNamesChanged(PropertySheet *property, const QStringList &names) - - This signal is emitted whenever a property created by this manager - changes its flag names, passing a pointer to the \a property and the - new \a names as parameters. - - \sa setFlagNames() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtFlagPropertyManager::QtFlagPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtFlagPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); - connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(PropertySheet*, bool)), - this, SLOT(slotBoolChanged(PropertySheet*, bool))); - connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtFlagPropertyManager::~QtFlagPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that produces the nested boolean subproperties - representing each flag. - - In order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtBoolPropertyManager* QtFlagPropertyManager::subBoolPropertyManager() const -{ - return d_ptr->m_boolPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns 0. - - \sa flagNames(), setValue() -*/ -int QtFlagPropertyManager::value(const PropertySheet* property) const -{ - return getValue(d_ptr->m_values, property, 0); -} - -/*! - Returns the given \a property's list of flag names. - - \sa value(), setFlagNames() -*/ -QStringList QtFlagPropertyManager::flagNames(const PropertySheet* property) const -{ - return getData(d_ptr->m_values, &QtFlagPropertyManagerPrivate::Data::flagNames, property, QStringList()); -} - -/*! - \reimp -*/ -QString QtFlagPropertyManager::valueText(const PropertySheet* property) const -{ - const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - const QtFlagPropertyManagerPrivate::Data& data = it.value(); - - QString str; - int level = 0; - const QChar bar = QLatin1Char('|'); - const QStringList::const_iterator fncend = data.flagNames.constEnd(); - for (QStringList::const_iterator it = data.flagNames.constBegin(); it != fncend; ++it) { - if (data.val & (1 << level)) { - if (!str.isEmpty()) - str += bar; - str += *it; - } - - level++; - } - return str; -} - -/*! - \fn void QtFlagPropertyManager::setValue(PropertySheet *property, int value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - The specified \a value must be less than the binary combination of - the property's flagNames() list size (i.e. less than 2\sup n, - where \c n is the size of the list) and larger than (or equal to) - 0. - - \sa value(), valueChanged() -*/ -void QtFlagPropertyManager::setValue(PropertySheet* property, int val) -{ - const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtFlagPropertyManagerPrivate::Data data = it.value(); - - if (data.val == val) - return; - - if (val > (1 << data.flagNames.count()) - 1) - return; - - if (val < 0) - return; - - data.val = val; - - it.value() = data; - - const auto pfit = d_ptr->m_propertyToFlags.constFind(property); - int level = 0; - if (pfit != d_ptr->m_propertyToFlags.constEnd()) { - for (PropertySheet* prop : pfit.value()) { - if (prop) - d_ptr->m_boolPropertyManager->setValue(prop, val & (1 << level)); - level++; - } - } - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - Sets the given \a property's list of flag names to \a flagNames. The - property's current value is reset to 0 indicating the first item - of the list. - - \sa flagNames(), flagNamesChanged() -*/ -void QtFlagPropertyManager::setFlagNames(PropertySheet* property, const QStringList& flagNames) -{ - const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - QtFlagPropertyManagerPrivate::Data data = it.value(); - - if (data.flagNames == flagNames) - return; - - data.flagNames = flagNames; - data.val = 0; - - it.value() = data; - - const auto pfit = d_ptr->m_propertyToFlags.find(property); - if (pfit != d_ptr->m_propertyToFlags.end()) { - for (PropertySheet* prop : qAsConst(pfit.value())) { - if (prop) { - delete prop; - d_ptr->m_flagToProperty.remove(prop); - } - } - pfit.value().clear(); - } - - for (const QString& flagName : flagNames) { - PropertySheet* prop = d_ptr->m_boolPropertyManager->addProperty(); - prop->setPropertyName(flagName); - property->addSubProperty(prop); - d_ptr->m_propertyToFlags[property].append(prop); - d_ptr->m_flagToProperty[prop] = property; - } - - emit flagNamesChanged(property, data.flagNames); - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} - -/*! - \reimp -*/ -void QtFlagPropertyManager::initializeProperty(PropertySheet* property) -{ - d_ptr->m_values[property] = QtFlagPropertyManagerPrivate::Data(); - - d_ptr->m_propertyToFlags[property] = QList(); -} - -/*! - \reimp -*/ -void QtFlagPropertyManager::uninitializeProperty(PropertySheet* property) -{ - const auto it = d_ptr->m_propertyToFlags.find(property); - if (it != d_ptr->m_propertyToFlags.end()) { - for (PropertySheet* prop : qAsConst(it.value())) { - if (prop) { - d_ptr->m_flagToProperty.remove(prop); - delete prop; - } - } - } - d_ptr->m_propertyToFlags.erase(it); - - d_ptr->m_values.remove(property); -} - -// QtSizePolicyPropertyManager - -class QtSizePolicyPropertyManagerPrivate -{ - QtSizePolicyPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtSizePolicyPropertyManager) -public: - - QtSizePolicyPropertyManagerPrivate(); - - void slotIntChanged(PropertySheet* property, int value); - void slotEnumChanged(PropertySheet* property, int value); - void slotPropertyDestroyed(PropertySheet* property); - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager* m_intPropertyManager; - QtEnumPropertyManager* m_enumPropertyManager; - - QMap m_propertyToHPolicy; - QMap m_propertyToVPolicy; - QMap m_propertyToHStretch; - QMap m_propertyToVStretch; - - QMap m_hPolicyToProperty; - QMap m_vPolicyToProperty; - QMap m_hStretchToProperty; - QMap m_vStretchToProperty; -}; - -QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate() -{ -} - -void QtSizePolicyPropertyManagerPrivate::slotIntChanged(PropertySheet* property, int value) -{ - if (PropertySheet* prop = m_hStretchToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setHorizontalStretch(value); - q_ptr->setValue(prop, sp); - } - else if (PropertySheet* prop = m_vStretchToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setVerticalStretch(value); - q_ptr->setValue(prop, sp); - } -} - -void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(PropertySheet* property, int value) -{ - if (PropertySheet* prop = m_hPolicyToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value)); - q_ptr->setValue(prop, sp); - } - else if (PropertySheet* prop = m_vPolicyToProperty.value(property, 0)) { - QSizePolicy sp = m_values[prop]; - sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value)); - q_ptr->setValue(prop, sp); - } -} - -void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_hStretchToProperty.value(property, 0)) { - m_propertyToHStretch[pointProp] = 0; - m_hStretchToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_vStretchToProperty.value(property, 0)) { - m_propertyToVStretch[pointProp] = 0; - m_vStretchToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_hPolicyToProperty.value(property, 0)) { - m_propertyToHPolicy[pointProp] = 0; - m_hPolicyToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_vPolicyToProperty.value(property, 0)) { - m_propertyToVPolicy[pointProp] = 0; - m_vPolicyToProperty.remove(property); - } -} - -/*! - \class QtSizePolicyPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtSizePolicyPropertyManager provides and manages QSizePolicy properties. - - A size policy property has nested \e horizontalPolicy, \e - verticalPolicy, \e horizontalStretch and \e verticalStretch - subproperties. The top-level property's value can be retrieved - using the value() function, and set using the setValue() slot. - - The subproperties are created by QtIntPropertyManager and QtEnumPropertyManager - objects. These managers can be retrieved using the subIntPropertyManager() - and subEnumPropertyManager() functions respectively. In order to provide - editing widgets for the subproperties in a property browser widget, - these managers must be associated with editor factories. - - In addition, QtSizePolicyPropertyManager provides the valueChanged() - signal which is emitted whenever a property created by this - manager changes. - - \sa AbstractPropertyManager, QtIntPropertyManager, QtEnumPropertyManager -*/ - -/*! - \fn void QtSizePolicyPropertyManager::valueChanged(PropertySheet *property, const QSizePolicy &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtSizePolicyPropertyManager::QtSizePolicyPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtSizePolicyPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotIntChanged(PropertySheet*, int))); - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotEnumChanged(PropertySheet*, int))); - - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtSizePolicyPropertyManager::~QtSizePolicyPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the nested \e horizontalStretch - and \e verticalStretch subproperties. - - In order to provide editing widgets for the mentioned subproperties - in a property browser widget, this manager must be associated with - an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtIntPropertyManager* QtSizePolicyPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; -} - -/*! - Returns the manager that creates the nested \e horizontalPolicy - and \e verticalPolicy subproperties. - - In order to provide editing widgets for the mentioned subproperties - in a property browser widget, this manager must be associated with - an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtEnumPropertyManager* QtSizePolicyPropertyManager::subEnumPropertyManager() const -{ - return d_ptr->m_enumPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns the default size policy. - - \sa setValue() -*/ -QSizePolicy QtSizePolicyPropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QSizePolicy()); -} - -/*! - \reimp -*/ -QString QtSizePolicyPropertyManager::valueText(const PropertySheet* property) const -{ - const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - const QSizePolicy sp = it.value(); - const QtMetaEnumProvider* mep = metaEnumProvider(); - const int hIndex = mep->sizePolicyToIndex(sp.horizontalPolicy()); - const int vIndex = mep->sizePolicyToIndex(sp.verticalPolicy()); - //! Unknown size policy on reading invalid uic3 files - const QString hPolicy = hIndex != -1 ? mep->policyEnumNames().at(hIndex) : tr(""); - const QString vPolicy = vIndex != -1 ? mep->policyEnumNames().at(vIndex) : tr(""); - const QString str = tr("[%1, %2, %3, %4]").arg(hPolicy, vPolicy).arg(sp.horizontalStretch()).arg(sp.verticalStretch()); - return str; -} - -/*! - \fn void QtSizePolicyPropertyManager::setValue(PropertySheet *property, const QSizePolicy &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - \sa value(), valueChanged() -*/ -void QtSizePolicyPropertyManager::setValue(PropertySheet* property, const QSizePolicy& val) -{ - const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - if (it.value() == val) - return; - - it.value() = val; - - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToHPolicy[property], - metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy())); - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToVPolicy[property], - metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy())); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToHStretch[property], - val.horizontalStretch()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToVStretch[property], - val.verticalStretch()); - - emit propertyChanged(property); - emit valueChanged(property, val); -} - -/*! - \reimp -*/ -void QtSizePolicyPropertyManager::initializeProperty(PropertySheet* property) -{ - QSizePolicy val; - d_ptr->m_values[property] = val; - - PropertySheet* hPolicyProp = d_ptr->m_enumPropertyManager->addProperty(); - hPolicyProp->setPropertyName(tr("Horizontal Policy")); - d_ptr->m_enumPropertyManager->setEnumNames(hPolicyProp, metaEnumProvider()->policyEnumNames()); - d_ptr->m_enumPropertyManager->setValue(hPolicyProp, - metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy())); - d_ptr->m_propertyToHPolicy[property] = hPolicyProp; - d_ptr->m_hPolicyToProperty[hPolicyProp] = property; - property->addSubProperty(hPolicyProp); - - PropertySheet* vPolicyProp = d_ptr->m_enumPropertyManager->addProperty(); - vPolicyProp->setPropertyName(tr("Vertical Policy")); - d_ptr->m_enumPropertyManager->setEnumNames(vPolicyProp, metaEnumProvider()->policyEnumNames()); - d_ptr->m_enumPropertyManager->setValue(vPolicyProp, - metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy())); - d_ptr->m_propertyToVPolicy[property] = vPolicyProp; - d_ptr->m_vPolicyToProperty[vPolicyProp] = property; - property->addSubProperty(vPolicyProp); - - PropertySheet* hStretchProp = d_ptr->m_intPropertyManager->addProperty(); - hStretchProp->setPropertyName(tr("Horizontal Stretch")); - d_ptr->m_intPropertyManager->setValue(hStretchProp, val.horizontalStretch()); - d_ptr->m_intPropertyManager->setRange(hStretchProp, 0, 0xff); - d_ptr->m_propertyToHStretch[property] = hStretchProp; - d_ptr->m_hStretchToProperty[hStretchProp] = property; - property->addSubProperty(hStretchProp); - - PropertySheet* vStretchProp = d_ptr->m_intPropertyManager->addProperty(); - vStretchProp->setPropertyName(tr("Vertical Stretch")); - d_ptr->m_intPropertyManager->setValue(vStretchProp, val.verticalStretch()); - d_ptr->m_intPropertyManager->setRange(vStretchProp, 0, 0xff); - d_ptr->m_propertyToVStretch[property] = vStretchProp; - d_ptr->m_vStretchToProperty[vStretchProp] = property; - property->addSubProperty(vStretchProp); -} - -/*! - \reimp -*/ -void QtSizePolicyPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* hPolicyProp = d_ptr->m_propertyToHPolicy[property]; - if (hPolicyProp) { - d_ptr->m_hPolicyToProperty.remove(hPolicyProp); - delete hPolicyProp; - } - d_ptr->m_propertyToHPolicy.remove(property); - - PropertySheet* vPolicyProp = d_ptr->m_propertyToVPolicy[property]; - if (vPolicyProp) { - d_ptr->m_vPolicyToProperty.remove(vPolicyProp); - delete vPolicyProp; - } - d_ptr->m_propertyToVPolicy.remove(property); - - PropertySheet* hStretchProp = d_ptr->m_propertyToHStretch[property]; - if (hStretchProp) { - d_ptr->m_hStretchToProperty.remove(hStretchProp); - delete hStretchProp; - } - d_ptr->m_propertyToHStretch.remove(property); - - PropertySheet* vStretchProp = d_ptr->m_propertyToVStretch[property]; - if (vStretchProp) { - d_ptr->m_vStretchToProperty.remove(vStretchProp); - delete vStretchProp; - } - d_ptr->m_propertyToVStretch.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtFontPropertyManager: -// QtFontPropertyManagerPrivate has a mechanism for reacting -// to QApplication::fontDatabaseChanged() [4.5], which is emitted -// when someone loads an application font. The signals are compressed -// using a timer with interval 0, which then causes the family -// enumeration manager to re-set its strings and index values -// for each property. - -Q_GLOBAL_STATIC(QFontDatabase, fontDatabase) - -class QtFontPropertyManagerPrivate -{ - QtFontPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtFontPropertyManager) -public: - - QtFontPropertyManagerPrivate(); - - void slotIntChanged(PropertySheet* property, int value); - void slotEnumChanged(PropertySheet* property, int value); - void slotBoolChanged(PropertySheet* property, bool value); - void slotPropertyDestroyed(PropertySheet* property); - void slotFontDatabaseChanged(); - void slotFontDatabaseDelayedChange(); - - QStringList m_familyNames; - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager* m_intPropertyManager; - QtEnumPropertyManager* m_enumPropertyManager; - QtBoolPropertyManager* m_boolPropertyManager; - - QMap m_propertyToFamily; - QMap m_propertyToPointSize; - QMap m_propertyToBold; - QMap m_propertyToItalic; - QMap m_propertyToUnderline; - QMap m_propertyToStrikeOut; - QMap m_propertyToKerning; - - QMap m_familyToProperty; - QMap m_pointSizeToProperty; - QMap m_boldToProperty; - QMap m_italicToProperty; - QMap m_underlineToProperty; - QMap m_strikeOutToProperty; - QMap m_kerningToProperty; - - bool m_settingValue; - QTimer* m_fontDatabaseChangeTimer; -}; - -QtFontPropertyManagerPrivate::QtFontPropertyManagerPrivate() : - m_settingValue(false), - m_fontDatabaseChangeTimer(0) -{ -} - -void QtFontPropertyManagerPrivate::slotIntChanged(PropertySheet* property, int value) -{ - if (m_settingValue) - return; - if (PropertySheet* prop = m_pointSizeToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setPointSize(value); - q_ptr->setValue(prop, f); - } -} - -void QtFontPropertyManagerPrivate::slotEnumChanged(PropertySheet* property, int value) -{ - if (m_settingValue) - return; - if (PropertySheet* prop = m_familyToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setFamily(m_familyNames.at(value)); - q_ptr->setValue(prop, f); - } -} - -void QtFontPropertyManagerPrivate::slotBoolChanged(PropertySheet* property, bool value) -{ - if (m_settingValue) - return; - if (PropertySheet* prop = m_boldToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setBold(value); - q_ptr->setValue(prop, f); - } - else if (PropertySheet* prop = m_italicToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setItalic(value); - q_ptr->setValue(prop, f); - } - else if (PropertySheet* prop = m_underlineToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setUnderline(value); - q_ptr->setValue(prop, f); - } - else if (PropertySheet* prop = m_strikeOutToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setStrikeOut(value); - q_ptr->setValue(prop, f); - } - else if (PropertySheet* prop = m_kerningToProperty.value(property, 0)) { - QFont f = m_values[prop]; - f.setKerning(value); - q_ptr->setValue(prop, f); - } -} - -void QtFontPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_pointSizeToProperty.value(property, 0)) { - m_propertyToPointSize[pointProp] = 0; - m_pointSizeToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_familyToProperty.value(property, 0)) { - m_propertyToFamily[pointProp] = 0; - m_familyToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_boldToProperty.value(property, 0)) { - m_propertyToBold[pointProp] = 0; - m_boldToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_italicToProperty.value(property, 0)) { - m_propertyToItalic[pointProp] = 0; - m_italicToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_underlineToProperty.value(property, 0)) { - m_propertyToUnderline[pointProp] = 0; - m_underlineToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_strikeOutToProperty.value(property, 0)) { - m_propertyToStrikeOut[pointProp] = 0; - m_strikeOutToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_kerningToProperty.value(property, 0)) { - m_propertyToKerning[pointProp] = 0; - m_kerningToProperty.remove(property); - } -} - -void QtFontPropertyManagerPrivate::slotFontDatabaseChanged() -{ - if (!m_fontDatabaseChangeTimer) { - m_fontDatabaseChangeTimer = new QTimer(q_ptr); - m_fontDatabaseChangeTimer->setInterval(0); - m_fontDatabaseChangeTimer->setSingleShot(true); - QObject::connect(m_fontDatabaseChangeTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFontDatabaseDelayedChange())); - } - if (!m_fontDatabaseChangeTimer->isActive()) - m_fontDatabaseChangeTimer->start(); -} - -void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange() -{ - typedef QMap PropertyPropertyMap; - // rescan available font names - const QStringList oldFamilies = m_familyNames; - m_familyNames = fontDatabase()->families(); - - // Adapt all existing properties - if (!m_propertyToFamily.empty()) { - PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd(); - for (PropertyPropertyMap::const_iterator it = m_propertyToFamily.constBegin(); it != cend; ++it) { - PropertySheet* familyProp = it.value(); - const int oldIdx = m_enumPropertyManager->value(familyProp); - int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx)); - if (newIdx < 0) - newIdx = 0; - m_enumPropertyManager->setEnumNames(familyProp, m_familyNames); - m_enumPropertyManager->setValue(familyProp, newIdx); - } - } -} - -/*! - \class QtFontPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtFontPropertyManager provides and manages QFont properties. - - A font property has nested \e family, \e pointSize, \e bold, \e - italic, \e underline, \e strikeOut and \e kerning subproperties. The top-level - property's value can be retrieved using the value() function, and - set using the setValue() slot. - - The subproperties are created by QtIntPropertyManager, QtEnumPropertyManager and - QtBoolPropertyManager objects. These managers can be retrieved using the - corresponding subIntPropertyManager(), subEnumPropertyManager() and - subBoolPropertyManager() functions. In order to provide editing widgets - for the subproperties in a property browser widget, these managers - must be associated with editor factories. - - In addition, QtFontPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes. - - \sa AbstractPropertyManager, QtEnumPropertyManager, QtIntPropertyManager, QtBoolPropertyManager -*/ - -/*! - \fn void QtFontPropertyManager::valueChanged(PropertySheet *property, const QFont &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtFontPropertyManager::QtFontPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtFontPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, SLOT(slotFontDatabaseChanged())); - - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotIntChanged(PropertySheet*, int))); - d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this); - connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotEnumChanged(PropertySheet*, int))); - d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this); - connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(PropertySheet*, bool)), - this, SLOT(slotBoolChanged(PropertySheet*, bool))); - - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); - connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); - connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtFontPropertyManager::~QtFontPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that creates the \e pointSize subproperty. - - In order to provide editing widgets for the \e pointSize property - in a property browser widget, this manager must be associated - with an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtIntPropertyManager* QtFontPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; -} - -/*! - Returns the manager that create the \e family subproperty. - - In order to provide editing widgets for the \e family property - in a property browser widget, this manager must be associated - with an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtEnumPropertyManager* QtFontPropertyManager::subEnumPropertyManager() const -{ - return d_ptr->m_enumPropertyManager; -} - -/*! - Returns the manager that creates the \e bold, \e italic, \e underline, - \e strikeOut and \e kerning subproperties. - - In order to provide editing widgets for the mentioned properties - in a property browser widget, this manager must be associated with - an editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtBoolPropertyManager* QtFontPropertyManager::subBoolPropertyManager() const -{ - return d_ptr->m_boolPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns a font object that uses the application's default - font. - - \sa setValue() -*/ -QFont QtFontPropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QFont()); -} - -/*! - \reimp -*/ -QString QtFontPropertyManager::valueText(const PropertySheet* property) const -{ - const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - return QtPropertyBrowserUtils::fontValueText(it.value()); -} - -/*! - \reimp -*/ -QIcon QtFontPropertyManager::valueIcon(const PropertySheet* property) const -{ - const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); - - return QtPropertyBrowserUtils::fontValueIcon(it.value()); -} - -/*! - \fn void QtFontPropertyManager::setValue(PropertySheet *property, const QFont &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - \sa value(), valueChanged() -*/ -void QtFontPropertyManager::setValue(PropertySheet* property, const QFont& val) -{ - const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - const QFont oldVal = it.value(); - if (oldVal == val && oldVal.resolve() == val.resolve()) - return; - - it.value() = val; - - int idx = d_ptr->m_familyNames.indexOf(val.family()); - if (idx == -1) - idx = 0; - bool settingValue = d_ptr->m_settingValue; - d_ptr->m_settingValue = true; - d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToFamily[property], idx); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToPointSize[property], val.pointSize()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToBold[property], val.bold()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToItalic[property], val.italic()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], val.underline()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], val.strikeOut()); - d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], val.kerning()); - d_ptr->m_settingValue = settingValue; - - emit propertyChanged(property); - emit valueChanged(property, val); -} - -/*! - \reimp -*/ -void QtFontPropertyManager::initializeProperty(PropertySheet* property) -{ - QFont val; - d_ptr->m_values[property] = val; - - PropertySheet* familyProp = d_ptr->m_enumPropertyManager->addProperty(); - familyProp->setPropertyName(tr("Family")); - if (d_ptr->m_familyNames.empty()) - d_ptr->m_familyNames = fontDatabase()->families(); - d_ptr->m_enumPropertyManager->setEnumNames(familyProp, d_ptr->m_familyNames); - int idx = d_ptr->m_familyNames.indexOf(val.family()); - if (idx == -1) - idx = 0; - d_ptr->m_enumPropertyManager->setValue(familyProp, idx); - d_ptr->m_propertyToFamily[property] = familyProp; - d_ptr->m_familyToProperty[familyProp] = property; - property->addSubProperty(familyProp); - - PropertySheet* pointSizeProp = d_ptr->m_intPropertyManager->addProperty(); - pointSizeProp->setPropertyName(tr("Point Size")); - d_ptr->m_intPropertyManager->setValue(pointSizeProp, val.pointSize()); - d_ptr->m_intPropertyManager->setMinimum(pointSizeProp, 1); - d_ptr->m_propertyToPointSize[property] = pointSizeProp; - d_ptr->m_pointSizeToProperty[pointSizeProp] = property; - property->addSubProperty(pointSizeProp); - - PropertySheet* boldProp = d_ptr->m_boolPropertyManager->addProperty(); - boldProp->setPropertyName(tr("Bold")); - d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold()); - d_ptr->m_propertyToBold[property] = boldProp; - d_ptr->m_boldToProperty[boldProp] = property; - property->addSubProperty(boldProp); - - PropertySheet* italicProp = d_ptr->m_boolPropertyManager->addProperty(); - italicProp->setPropertyName(tr("Italic")); - d_ptr->m_boolPropertyManager->setValue(italicProp, val.italic()); - d_ptr->m_propertyToItalic[property] = italicProp; - d_ptr->m_italicToProperty[italicProp] = property; - property->addSubProperty(italicProp); - - PropertySheet* underlineProp = d_ptr->m_boolPropertyManager->addProperty(); - underlineProp->setPropertyName(tr("Underline")); - d_ptr->m_boolPropertyManager->setValue(underlineProp, val.underline()); - d_ptr->m_propertyToUnderline[property] = underlineProp; - d_ptr->m_underlineToProperty[underlineProp] = property; - property->addSubProperty(underlineProp); - - PropertySheet* strikeOutProp = d_ptr->m_boolPropertyManager->addProperty(); - strikeOutProp->setPropertyName(tr("Strikeout")); - d_ptr->m_boolPropertyManager->setValue(strikeOutProp, val.strikeOut()); - d_ptr->m_propertyToStrikeOut[property] = strikeOutProp; - d_ptr->m_strikeOutToProperty[strikeOutProp] = property; - property->addSubProperty(strikeOutProp); - - PropertySheet* kerningProp = d_ptr->m_boolPropertyManager->addProperty(); - kerningProp->setPropertyName(tr("Kerning")); - d_ptr->m_boolPropertyManager->setValue(kerningProp, val.kerning()); - d_ptr->m_propertyToKerning[property] = kerningProp; - d_ptr->m_kerningToProperty[kerningProp] = property; - property->addSubProperty(kerningProp); -} - -/*! - \reimp -*/ -void QtFontPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* familyProp = d_ptr->m_propertyToFamily[property]; - if (familyProp) { - d_ptr->m_familyToProperty.remove(familyProp); - delete familyProp; - } - d_ptr->m_propertyToFamily.remove(property); - - PropertySheet* pointSizeProp = d_ptr->m_propertyToPointSize[property]; - if (pointSizeProp) { - d_ptr->m_pointSizeToProperty.remove(pointSizeProp); - delete pointSizeProp; - } - d_ptr->m_propertyToPointSize.remove(property); - - PropertySheet* boldProp = d_ptr->m_propertyToBold[property]; - if (boldProp) { - d_ptr->m_boldToProperty.remove(boldProp); - delete boldProp; - } - d_ptr->m_propertyToBold.remove(property); - - PropertySheet* italicProp = d_ptr->m_propertyToItalic[property]; - if (italicProp) { - d_ptr->m_italicToProperty.remove(italicProp); - delete italicProp; - } - d_ptr->m_propertyToItalic.remove(property); - - PropertySheet* underlineProp = d_ptr->m_propertyToUnderline[property]; - if (underlineProp) { - d_ptr->m_underlineToProperty.remove(underlineProp); - delete underlineProp; - } - d_ptr->m_propertyToUnderline.remove(property); - - PropertySheet* strikeOutProp = d_ptr->m_propertyToStrikeOut[property]; - if (strikeOutProp) { - d_ptr->m_strikeOutToProperty.remove(strikeOutProp); - delete strikeOutProp; - } - d_ptr->m_propertyToStrikeOut.remove(property); - - PropertySheet* kerningProp = d_ptr->m_propertyToKerning[property]; - if (kerningProp) { - d_ptr->m_kerningToProperty.remove(kerningProp); - delete kerningProp; - } - d_ptr->m_propertyToKerning.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtColorPropertyManager - -class QtColorPropertyManagerPrivate -{ - QtColorPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtColorPropertyManager) -public: - - void slotIntChanged(PropertySheet* property, int value); - void slotPropertyDestroyed(PropertySheet* property); - - typedef QMap PropertyValueMap; - PropertyValueMap m_values; - - QtIntPropertyManager* m_intPropertyManager; - - QMap m_propertyToR; - QMap m_propertyToG; - QMap m_propertyToB; - QMap m_propertyToA; - - QMap m_rToProperty; - QMap m_gToProperty; - QMap m_bToProperty; - QMap m_aToProperty; -}; - -void QtColorPropertyManagerPrivate::slotIntChanged(PropertySheet* property, int value) -{ - if (PropertySheet* prop = m_rToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setRed(value); - q_ptr->setValue(prop, c); - } - else if (PropertySheet* prop = m_gToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setGreen(value); - q_ptr->setValue(prop, c); - } - else if (PropertySheet* prop = m_bToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setBlue(value); - q_ptr->setValue(prop, c); - } - else if (PropertySheet* prop = m_aToProperty.value(property, 0)) { - QColor c = m_values[prop]; - c.setAlpha(value); - q_ptr->setValue(prop, c); - } -} - -void QtColorPropertyManagerPrivate::slotPropertyDestroyed(PropertySheet* property) -{ - if (PropertySheet* pointProp = m_rToProperty.value(property, 0)) { - m_propertyToR[pointProp] = 0; - m_rToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_gToProperty.value(property, 0)) { - m_propertyToG[pointProp] = 0; - m_gToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_bToProperty.value(property, 0)) { - m_propertyToB[pointProp] = 0; - m_bToProperty.remove(property); - } - else if (PropertySheet* pointProp = m_aToProperty.value(property, 0)) { - m_propertyToA[pointProp] = 0; - m_aToProperty.remove(property); - } -} - -/*! - \class QtColorPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtColorPropertyManager provides and manages QColor properties. - - A color property has nested \e red, \e green and \e blue - subproperties. The top-level property's value can be retrieved - using the value() function, and set using the setValue() slot. - - The subproperties are created by a QtIntPropertyManager object. This - manager can be retrieved using the subIntPropertyManager() function. In - order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - In addition, QtColorPropertyManager provides the valueChanged() signal - which is emitted whenever a property created by this manager - changes. - - \sa AbstractPropertyManager, QtAbstractPropertyBrowser, QtIntPropertyManager -*/ - -/*! - \fn void QtColorPropertyManager::valueChanged(PropertySheet *property, const QColor &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtColorPropertyManager::QtColorPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtColorPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_intPropertyManager = new QtIntPropertyManager(this); - connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(PropertySheet*, int)), - this, SLOT(slotIntChanged(PropertySheet*, int))); - - connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(PropertySheet*)), - this, SLOT(slotPropertyDestroyed(PropertySheet*))); -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtColorPropertyManager::~QtColorPropertyManager() -{ - clear(); -} - -/*! - Returns the manager that produces the nested \e red, \e green and - \e blue subproperties. - - In order to provide editing widgets for the subproperties in a - property browser widget, this manager must be associated with an - editor factory. - - \sa QtAbstractPropertyBrowser::setFactoryForManager() -*/ -QtIntPropertyManager* QtColorPropertyManager::subIntPropertyManager() const -{ - return d_ptr->m_intPropertyManager; -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by \e this manager, this - function returns an invalid color. - - \sa setValue() -*/ -QColor QtColorPropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QColor()); -} - -/*! - \reimp -*/ - -QString QtColorPropertyManager::valueText(const PropertySheet* property) const -{ - const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - return QtPropertyBrowserUtils::colorValueText(it.value()); -} - -/*! - \reimp -*/ - -QIcon QtColorPropertyManager::valueIcon(const PropertySheet* property) const -{ - const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); - return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value())); -} - -/*! - \fn void QtColorPropertyManager::setValue(PropertySheet *property, const QColor &value) - - Sets the value of the given \a property to \a value. Nested - properties are updated automatically. - - \sa value(), valueChanged() -*/ -void QtColorPropertyManager::setValue(PropertySheet* property, const QColor& val) -{ - const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - if (it.value() == val) - return; - - it.value() = val; - - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToR[property], val.red()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToG[property], val.green()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToB[property], val.blue()); - d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToA[property], val.alpha()); - - emit propertyChanged(property); - emit valueChanged(property, val); -} - -/*! - \reimp -*/ -void QtColorPropertyManager::initializeProperty(PropertySheet* property) -{ - QColor val; - d_ptr->m_values[property] = val; - - PropertySheet* rProp = d_ptr->m_intPropertyManager->addProperty(); - rProp->setPropertyName(tr("Red")); - d_ptr->m_intPropertyManager->setValue(rProp, val.red()); - d_ptr->m_intPropertyManager->setRange(rProp, 0, 0xFF); - d_ptr->m_propertyToR[property] = rProp; - d_ptr->m_rToProperty[rProp] = property; - property->addSubProperty(rProp); - - PropertySheet* gProp = d_ptr->m_intPropertyManager->addProperty(); - gProp->setPropertyName(tr("Green")); - d_ptr->m_intPropertyManager->setValue(gProp, val.green()); - d_ptr->m_intPropertyManager->setRange(gProp, 0, 0xFF); - d_ptr->m_propertyToG[property] = gProp; - d_ptr->m_gToProperty[gProp] = property; - property->addSubProperty(gProp); - - PropertySheet* bProp = d_ptr->m_intPropertyManager->addProperty(); - bProp->setPropertyName(tr("Blue")); - d_ptr->m_intPropertyManager->setValue(bProp, val.blue()); - d_ptr->m_intPropertyManager->setRange(bProp, 0, 0xFF); - d_ptr->m_propertyToB[property] = bProp; - d_ptr->m_bToProperty[bProp] = property; - property->addSubProperty(bProp); - - PropertySheet* aProp = d_ptr->m_intPropertyManager->addProperty(); - aProp->setPropertyName(tr("Alpha")); - d_ptr->m_intPropertyManager->setValue(aProp, val.alpha()); - d_ptr->m_intPropertyManager->setRange(aProp, 0, 0xFF); - d_ptr->m_propertyToA[property] = aProp; - d_ptr->m_aToProperty[aProp] = property; - property->addSubProperty(aProp); -} - -/*! - \reimp -*/ -void QtColorPropertyManager::uninitializeProperty(PropertySheet* property) -{ - PropertySheet* rProp = d_ptr->m_propertyToR[property]; - if (rProp) { - d_ptr->m_rToProperty.remove(rProp); - delete rProp; - } - d_ptr->m_propertyToR.remove(property); - - PropertySheet* gProp = d_ptr->m_propertyToG[property]; - if (gProp) { - d_ptr->m_gToProperty.remove(gProp); - delete gProp; - } - d_ptr->m_propertyToG.remove(property); - - PropertySheet* bProp = d_ptr->m_propertyToB[property]; - if (bProp) { - d_ptr->m_bToProperty.remove(bProp); - delete bProp; - } - d_ptr->m_propertyToB.remove(property); - - PropertySheet* aProp = d_ptr->m_propertyToA[property]; - if (aProp) { - d_ptr->m_aToProperty.remove(aProp); - delete aProp; - } - d_ptr->m_propertyToA.remove(property); - - d_ptr->m_values.remove(property); -} - -// QtCursorPropertyManager - -// Make sure icons are removed as soon as QApplication is destroyed, otherwise, -// handles are leaked on X11. -static void clearCursorDatabase(); -namespace { - struct CursorDatabase : public QtCursorDatabase - { - CursorDatabase() - { - qAddPostRoutine(clearCursorDatabase); - } - }; -} -Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase) - -static void clearCursorDatabase() -{ - cursorDatabase()->clear(); -} - -class QtCursorPropertyManagerPrivate -{ - QtCursorPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtCursorPropertyManager) -public: - typedef QMap PropertyValueMap; - PropertyValueMap m_values; -}; - -/*! - \class QtCursorPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtCursorPropertyManager provides and manages QCursor properties. - - A cursor property has a current value which can be - retrieved using the value() function, and set using the setValue() - slot. In addition, QtCursorPropertyManager provides the - valueChanged() signal which is emitted whenever a property created - by this manager changes. - - \sa AbstractPropertyManager -*/ - -/*! - \fn void QtCursorPropertyManager::valueChanged(PropertySheet *property, const QCursor &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the new - \a value as parameters. - - \sa setValue() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtCursorPropertyManager::QtCursorPropertyManager(QObject* parent) - : AbstractPropertyManager(parent), d_ptr(new QtCursorPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtCursorPropertyManager::~QtCursorPropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns a default QCursor object. - - \sa setValue() -*/ -#ifndef QT_NO_CURSOR -QCursor QtCursorPropertyManager::value(const PropertySheet* property) const -{ - return d_ptr->m_values.value(property, QCursor()); -} -#endif - -/*! - \reimp -*/ -QString QtCursorPropertyManager::valueText(const PropertySheet* property) const -{ - const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); - - return cursorDatabase()->cursorToShapeName(it.value()); -} - -/*! - \reimp -*/ -QIcon QtCursorPropertyManager::valueIcon(const PropertySheet* property) const -{ - const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QIcon(); - - return cursorDatabase()->cursorToShapeIcon(it.value()); -} - -/*! - \fn void QtCursorPropertyManager::setValue(PropertySheet *property, const QCursor &value) - - Sets the value of the given \a property to \a value. - - \sa value(), valueChanged() -*/ -void QtCursorPropertyManager::setValue(PropertySheet* property, const QCursor& value) -{ -#ifndef QT_NO_CURSOR - const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - if (it.value().shape() == value.shape() && value.shape() != Qt::BitmapCursor) - return; - - it.value() = value; - - emit propertyChanged(property); - emit valueChanged(property, value); -#endif -} - -/*! - \reimp -*/ -void QtCursorPropertyManager::initializeProperty(PropertySheet* property) -{ -#ifndef QT_NO_CURSOR - d_ptr->m_values[property] = QCursor(); -#endif -} - -/*! - \reimp -*/ -void QtCursorPropertyManager::uninitializeProperty(PropertySheet* property) -{ - d_ptr->m_values.remove(property); -} - -QT_END_NAMESPACE - -#include "property_browser/moc_qtpropertymanager.cpp" -#include "qtpropertymanager.moc" \ No newline at end of file diff --git a/QtRpa/modules/property/src/qtvariantproperty.cpp1 b/QtRpa/modules/property/src/qtvariantproperty.cpp1 deleted file mode 100644 index 3d97006..0000000 --- a/QtRpa/modules/property/src/qtvariantproperty.cpp1 +++ /dev/null @@ -1,2272 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the tools applications of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "property_browser/qtvariantproperty.h" -#include "property_browser/qtpropertymanager.h" -#include "property_browser/qteditorfactory.h" -#include -#include -#include -#include - -#if defined(Q_CC_MSVC) -# pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */ -#endif - -QT_BEGIN_NAMESPACE - -class QtEnumPropertyType -{ -}; - -class QtFlagPropertyType -{ -}; - -class QtGroupPropertyType -{ -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QtEnumPropertyType) -Q_DECLARE_METATYPE(QtFlagPropertyType) -Q_DECLARE_METATYPE(QtGroupPropertyType) - -QT_BEGIN_NAMESPACE - -/*! - Returns the type id for an enum property. - - Note that the property's value type can be retrieved using the - valueType() function (which is QVariant::Int for the enum property - type). - - \sa propertyType(), valueType() -*/ -int QtVariantPropertyManager::enumTypeId() -{ - return qMetaTypeId(); -} - -/*! - Returns the type id for a flag property. - - Note that the property's value type can be retrieved using the - valueType() function (which is QVariant::Int for the flag property - type). - - \sa propertyType(), valueType() -*/ -int QtVariantPropertyManager::flagTypeId() -{ - return qMetaTypeId(); -} - -/*! - Returns the type id for a group property. - - Note that the property's value type can be retrieved using the - valueType() function (which is QVariant::Invalid for the group - property type, since it doesn't provide any value). - - \sa propertyType(), valueType() -*/ -int QtVariantPropertyManager::groupTypeId() -{ - return qMetaTypeId(); -} - -/*! - Returns the type id for a icon map attribute. - - Note that the property's attribute type can be retrieved using the - attributeType() function. - - \sa attributeType(), QtEnumPropertyManager::enumIcons() -*/ -int QtVariantPropertyManager::iconMapTypeId() -{ - return qMetaTypeId(); -} - -typedef QMap PropertyMap; -Q_GLOBAL_STATIC(PropertyMap, propertyToWrappedProperty) - -static QtProperty* wrappedProperty(QtProperty* property) -{ - return propertyToWrappedProperty()->value(property, 0); -} - -class QtVariantPropertyPrivate -{ -public: - QtVariantPropertyPrivate(QtVariantPropertyManager* m) : manager(m) {} - - QtVariantPropertyManager* manager; -}; - -/*! - \class QtVariantProperty - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtVariantProperty class is a convenience class handling - QVariant based properties. - - QtVariantProperty provides additional API: A property's type, - value type, attribute values and current value can easily be - retrieved using the propertyType(), valueType(), attributeValue() - and value() functions respectively. In addition, the attribute - values and the current value can be set using the corresponding - setValue() and setAttribute() functions. - - For example, instead of writing: - - \snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp 0 - - you can write: - - \snippet doc/src/snippets/code/tools_shared_qtpropertybrowser_qtvariantproperty.cpp 1 - - QtVariantProperty instances can only be created by the - QtVariantPropertyManager class. - - \sa QtProperty, QtVariantPropertyManager, QtVariantEditorFactory -*/ - -/*! - Creates a variant property using the given \a manager. - - Do not use this constructor to create variant property instances; - use the QtVariantPropertyManager::addProperty() function - instead. This constructor is used internally by the - QtVariantPropertyManager::createProperty() function. - - \sa QtVariantPropertyManager -*/ -QtVariantProperty::QtVariantProperty(QtVariantPropertyManager* manager) - : QtProperty(manager), d_ptr(new QtVariantPropertyPrivate(manager)) -{ -} - -/*! - Destroys this property. - - \sa QtProperty::~QtProperty() -*/ -QtVariantProperty::~QtVariantProperty() -{ -} - -/*! - Returns the property's current value. - - \sa valueType(), setValue() -*/ -QVariant QtVariantProperty::value() const -{ - return d_ptr->manager->value(this); -} - -/*! - Returns this property's value for the specified \a attribute. - - QtVariantPropertyManager provides a couple of related functions: - \l{QtVariantPropertyManager::attributes()}{attributes()} and - \l{QtVariantPropertyManager::attributeType()}{attributeType()}. - - \sa setAttribute() -*/ -QVariant QtVariantProperty::attributeValue(const QString& attribute) const -{ - return d_ptr->manager->attributeValue(this, attribute); -} - -/*! - Returns the type of this property's value. - - \sa propertyType() -*/ -int QtVariantProperty::valueType() const -{ - return d_ptr->manager->valueType(this); -} - -/*! - Returns this property's type. - - QtVariantPropertyManager provides several related functions: - \l{QtVariantPropertyManager::enumTypeId()}{enumTypeId()}, - \l{QtVariantPropertyManager::flagTypeId()}{flagTypeId()} and - \l{QtVariantPropertyManager::groupTypeId()}{groupTypeId()}. - - \sa valueType() -*/ -int QtVariantProperty::propertyType() const -{ - return d_ptr->manager->propertyType(this); -} - -/*! - Sets the value of this property to \a value. - - The specified \a value must be of the type returned by - valueType(), or of a type that can be converted to valueType() - using the QVariant::canConvert() function; otherwise this function - does nothing. - - \sa value() -*/ -void QtVariantProperty::setValue(const QVariant& value) -{ - d_ptr->manager->setValue(this, value); -} - -/*! - Sets the \a attribute of property to \a value. - - QtVariantPropertyManager provides the related - \l{QtVariantPropertyManager::setAttribute()}{setAttribute()} - function. - - \sa attributeValue() -*/ -void QtVariantProperty::setAttribute(const QString& attribute, const QVariant& value) -{ - d_ptr->manager->setAttribute(this, attribute, value); -} - -class QtVariantPropertyManagerPrivate -{ - QtVariantPropertyManager* q_ptr; - Q_DECLARE_PUBLIC(QtVariantPropertyManager) -public: - QtVariantPropertyManagerPrivate(); - - bool m_creatingProperty; - bool m_creatingSubProperties; - bool m_destroyingSubProperties; - int m_propertyType; - - void slotValueChanged(QtProperty* property, int val); - void slotRangeChanged(QtProperty* property, int min, int max); - void slotSingleStepChanged(QtProperty* property, int step); - void slotValueChanged(QtProperty* property, double val); - void slotRangeChanged(QtProperty* property, double min, double max); - void slotSingleStepChanged(QtProperty* property, double step); - void slotDecimalsChanged(QtProperty* property, int prec); - void slotValueChanged(QtProperty* property, bool val); - void slotValueChanged(QtProperty* property, const QString& val); - void slotRegExpChanged(QtProperty* property, const QRegExp& regExp); - void slotValueChanged(QtProperty* property, const QDate& val); - void slotRangeChanged(QtProperty* property, const QDate& min, const QDate& max); - void slotValueChanged(QtProperty* property, const QTime& val); - void slotValueChanged(QtProperty* property, const QDateTime& val); - void slotValueChanged(QtProperty* property, const QKeySequence& val); - void slotValueChanged(QtProperty* property, const QChar& val); - void slotValueChanged(QtProperty* property, const QLocale& val); - void slotValueChanged(QtProperty* property, const QPoint& val); - void slotValueChanged(QtProperty* property, const QPointF& val); - void slotValueChanged(QtProperty* property, const QSize& val); - void slotRangeChanged(QtProperty* property, const QSize& min, const QSize& max); - void slotValueChanged(QtProperty* property, const QSizeF& val); - void slotRangeChanged(QtProperty* property, const QSizeF& min, const QSizeF& max); - void slotValueChanged(QtProperty* property, const QRect& val); - void slotConstraintChanged(QtProperty* property, const QRect& val); - void slotValueChanged(QtProperty* property, const QRectF& val); - void slotConstraintChanged(QtProperty* property, const QRectF& val); - void slotValueChanged(QtProperty* property, const QColor& val); - void slotEnumChanged(QtProperty* property, int val); - void slotEnumNamesChanged(QtProperty* property, const QStringList& enumNames); - void slotEnumIconsChanged(QtProperty* property, const QMap& enumIcons); - void slotValueChanged(QtProperty* property, const QSizePolicy& val); - void slotValueChanged(QtProperty* property, const QFont& val); - void slotValueChanged(QtProperty* property, const QCursor& val); - void slotFlagChanged(QtProperty* property, int val); - void slotFlagNamesChanged(QtProperty* property, const QStringList& flagNames); - void slotPropertyInserted(QtProperty* property, QtProperty* parent, QtProperty* after); - void slotPropertyRemoved(QtProperty* property, QtProperty* parent); - - void valueChanged(QtProperty* property, const QVariant& val); - - int internalPropertyToType(QtProperty* property) const; - QtVariantProperty* createSubProperty(QtVariantProperty* parent, QtVariantProperty* after, - QtProperty* internal); - void removeSubProperty(QtVariantProperty* property); - - QMap m_typeToPropertyManager; - QMap > m_typeToAttributeToAttributeType; - - QMap > m_propertyToType; - - QMap m_typeToValueType; - - QMap m_internalToProperty; - - const QString m_constraintAttribute; - const QString m_singleStepAttribute; - const QString m_decimalsAttribute; - const QString m_enumIconsAttribute; - const QString m_enumNamesAttribute; - const QString m_flagNamesAttribute; - const QString m_maximumAttribute; - const QString m_minimumAttribute; - const QString m_regExpAttribute; -}; - -QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() : - m_constraintAttribute(QLatin1String("constraint")), - m_singleStepAttribute(QLatin1String("singleStep")), - m_decimalsAttribute(QLatin1String("decimals")), - m_enumIconsAttribute(QLatin1String("enumIcons")), - m_enumNamesAttribute(QLatin1String("enumNames")), - m_flagNamesAttribute(QLatin1String("flagNames")), - m_maximumAttribute(QLatin1String("maximum")), - m_minimumAttribute(QLatin1String("minimum")), - m_regExpAttribute(QLatin1String("regExp")) -{ -} - -int QtVariantPropertyManagerPrivate::internalPropertyToType(QtProperty* property) const -{ - int type = 0; - QtAbstractPropertyManager* internPropertyManager = property->propertyManager(); - if (qobject_cast(internPropertyManager)) - type = QVariant::Int; - else if (qobject_cast(internPropertyManager)) - type = QtVariantPropertyManager::enumTypeId(); - else if (qobject_cast(internPropertyManager)) - type = QVariant::Bool; - else if (qobject_cast(internPropertyManager)) - type = QVariant::Double; - return type; -} - -QtVariantProperty* QtVariantPropertyManagerPrivate::createSubProperty(QtVariantProperty* parent, - QtVariantProperty* after, QtProperty* internal) -{ - int type = internalPropertyToType(internal); - if (!type) - return 0; - - bool wasCreatingSubProperties = m_creatingSubProperties; - m_creatingSubProperties = true; - - QtVariantProperty* varChild = q_ptr->addProperty(type, internal->propertyName()); - - m_creatingSubProperties = wasCreatingSubProperties; - - varChild->setPropertyName(internal->propertyName()); - varChild->setToolTip(internal->toolTip()); - varChild->setStatusTip(internal->statusTip()); - varChild->setWhatsThis(internal->whatsThis()); - - parent->insertSubProperty(varChild, after); - - m_internalToProperty[internal] = varChild; - propertyToWrappedProperty()->insert(varChild, internal); - return varChild; -} - -void QtVariantPropertyManagerPrivate::removeSubProperty(QtVariantProperty* property) -{ - QtProperty* internChild = wrappedProperty(property); - bool wasDestroyingSubProperties = m_destroyingSubProperties; - m_destroyingSubProperties = true; - delete property; - m_destroyingSubProperties = wasDestroyingSubProperties; - m_internalToProperty.remove(internChild); - propertyToWrappedProperty()->remove(property); -} - -void QtVariantPropertyManagerPrivate::slotPropertyInserted(QtProperty* property, - QtProperty* parent, QtProperty* after) -{ - if (m_creatingProperty) - return; - - QtVariantProperty* varParent = m_internalToProperty.value(parent, 0); - if (!varParent) - return; - - QtVariantProperty* varAfter = 0; - if (after) { - varAfter = m_internalToProperty.value(after, 0); - if (!varAfter) - return; - } - - createSubProperty(varParent, varAfter, property); -} - -void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty* property, QtProperty* parent) -{ - Q_UNUSED(parent); - - QtVariantProperty* varProperty = m_internalToProperty.value(property, 0); - if (!varProperty) - return; - - removeSubProperty(varProperty); -} - -void QtVariantPropertyManagerPrivate::valueChanged(QtProperty* property, const QVariant& val) -{ - QtVariantProperty* varProp = m_internalToProperty.value(property, 0); - if (!varProp) - return; - emit q_ptr->valueChanged(varProp, val); - emit q_ptr->propertyChanged(varProp); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, int val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty* property, int min, int max) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } -} - -void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty* property, int step) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, double val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty* property, double min, double max) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } -} - -void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty* property, double step) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step)); -} - -void QtVariantPropertyManagerPrivate::slotDecimalsChanged(QtProperty* property, int prec) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_decimalsAttribute, QVariant(prec)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, bool val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QString& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotRegExpChanged(QtProperty* property, const QRegExp& regExp) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_regExpAttribute, QVariant(regExp)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QDate& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty* property, const QDate& min, const QDate& max) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QTime& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QDateTime& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QKeySequence& val) -{ - QVariant v; - v.setValue(val); - valueChanged(property, v); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QChar& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QLocale& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QPoint& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QPointF& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QSize& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty* property, const QSize& min, const QSize& max) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QSizeF& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty* property, const QSizeF& min, const QSizeF& max) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) { - emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min)); - emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max)); - } -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QRect& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty* property, const QRect& constraint) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QRectF& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty* property, const QRectF& constraint) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QColor& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotEnumNamesChanged(QtProperty* property, const QStringList& enumNames) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_enumNamesAttribute, QVariant(enumNames)); -} - -void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty* property, const QMap& enumIcons) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) { - QVariant v; - v.setValue(enumIcons); - emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v); - } -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QSizePolicy& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QFont& val) -{ - valueChanged(property, QVariant(val)); -} - -void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty* property, const QCursor& val) -{ -#ifndef QT_NO_CURSOR - valueChanged(property, QVariant(val)); -#endif -} - -void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty* property, const QStringList& flagNames) -{ - if (QtVariantProperty* varProp = m_internalToProperty.value(property, 0)) - emit q_ptr->attributeChanged(varProp, m_flagNamesAttribute, QVariant(flagNames)); -} - -/*! - \class QtVariantPropertyManager - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtVariantPropertyManager class provides and manages QVariant based properties. - - QtVariantPropertyManager provides the addProperty() function which - creates QtVariantProperty objects. The QtVariantProperty class is - a convenience class handling QVariant based properties inheriting - QtProperty. A QtProperty object created by a - QtVariantPropertyManager instance can be converted into a - QtVariantProperty object using the variantProperty() function. - - The property's value can be retrieved using the value(), and set - using the setValue() slot. In addition the property's type, and - the type of its value, can be retrieved using the propertyType() - and valueType() functions respectively. - - A property's type is a QVariant::Type enumerator value, and - usually a property's type is the same as its value type. But for - some properties the types differ, for example for enums, flags and - group types in which case QtVariantPropertyManager provides the - enumTypeId(), flagTypeId() and groupTypeId() functions, - respectively, to identify their property type (the value types are - QVariant::Int for the enum and flag types, and QVariant::Invalid - for the group type). - - Use the isPropertyTypeSupported() function to check if a particular - property type is supported. The currently supported property types - are: - - \table - \header - \li Property Type - \li Property Type Id - \row - \li int - \li QVariant::Int - \row - \li double - \li QVariant::Double - \row - \li bool - \li QVariant::Bool - \row - \li QString - \li QVariant::String - \row - \li QDate - \li QVariant::Date - \row - \li QTime - \li QVariant::Time - \row - \li QDateTime - \li QVariant::DateTime - \row - \li QKeySequence - \li QVariant::KeySequence - \row - \li QChar - \li QVariant::Char - \row - \li QLocale - \li QVariant::Locale - \row - \li QPoint - \li QVariant::Point - \row - \li QPointF - \li QVariant::PointF - \row - \li QSize - \li QVariant::Size - \row - \li QSizeF - \li QVariant::SizeF - \row - \li QRect - \li QVariant::Rect - \row - \li QRectF - \li QVariant::RectF - \row - \li QColor - \li QVariant::Color - \row - \li QSizePolicy - \li QVariant::SizePolicy - \row - \li QFont - \li QVariant::Font - \row - \li QCursor - \li QVariant::Cursor - \row - \li enum - \li enumTypeId() - \row - \li flag - \li flagTypeId() - \row - \li group - \li groupTypeId() - \endtable - - Each property type can provide additional attributes, - e.g. QVariant::Int and QVariant::Double provides minimum and - maximum values. The currently supported attributes are: - - \table - \header - \li Property Type - \li Attribute Name - \li Attribute Type - \row - \li \c int - \li minimum - \li QVariant::Int - \row - \li - \li maximum - \li QVariant::Int - \row - \li - \li singleStep - \li QVariant::Int - \row - \li \c double - \li minimum - \li QVariant::Double - \row - \li - \li maximum - \li QVariant::Double - \row - \li - \li singleStep - \li QVariant::Double - \row - \li - \li decimals - \li QVariant::Int - \row - \li QString - \li regExp - \li QVariant::RegExp - \row - \li QDate - \li minimum - \li QVariant::Date - \row - \li - \li maximum - \li QVariant::Date - \row - \li QPointF - \li decimals - \li QVariant::Int - \row - \li QSize - \li minimum - \li QVariant::Size - \row - \li - \li maximum - \li QVariant::Size - \row - \li QSizeF - \li minimum - \li QVariant::SizeF - \row - \li - \li maximum - \li QVariant::SizeF - \row - \li - \li decimals - \li QVariant::Int - \row - \li QRect - \li constraint - \li QVariant::Rect - \row - \li QRectF - \li constraint - \li QVariant::RectF - \row - \li - \li decimals - \li QVariant::Int - \row - \li \c enum - \li enumNames - \li QVariant::StringList - \row - \li - \li enumIcons - \li iconMapTypeId() - \row - \li \c flag - \li flagNames - \li QVariant::StringList - \endtable - - The attributes for a given property type can be retrieved using - the attributes() function. Each attribute has a value type which - can be retrieved using the attributeType() function, and a value - accessible through the attributeValue() function. In addition, the - value can be set using the setAttribute() slot. - - QtVariantManager also provides the valueChanged() signal which is - emitted whenever a property created by this manager change, and - the attributeChanged() signal which is emitted whenever an - attribute of such a property changes. - - \sa QtVariantProperty, QtVariantEditorFactory -*/ - -/*! - \fn void QtVariantPropertyManager::valueChanged(QtProperty *property, const QVariant &value) - - This signal is emitted whenever a property created by this manager - changes its value, passing a pointer to the \a property and the - new \a value as parameters. - - \sa setValue() -*/ - -/*! - \fn void QtVariantPropertyManager::attributeChanged(QtProperty *property, - const QString &attribute, const QVariant &value) - - This signal is emitted whenever an attribute of a property created - by this manager changes its value, passing a pointer to the \a - property, the \a attribute and the new \a value as parameters. - - \sa setAttribute() -*/ - -/*! - Creates a manager with the given \a parent. -*/ -QtVariantPropertyManager::QtVariantPropertyManager(QObject* parent) - : QtAbstractPropertyManager(parent), d_ptr(new QtVariantPropertyManagerPrivate) -{ - d_ptr->q_ptr = this; - - d_ptr->m_creatingProperty = false; - d_ptr->m_creatingSubProperties = false; - d_ptr->m_destroyingSubProperties = false; - d_ptr->m_propertyType = 0; - - // IntPropertyManager - QtIntPropertyManager* intPropertyManager = new QtIntPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Int] = intPropertyManager; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_minimumAttribute] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_maximumAttribute] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_singleStepAttribute] = QVariant::Int; - d_ptr->m_typeToValueType[QVariant::Int] = QVariant::Int; - connect(intPropertyManager, SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(intPropertyManager, SIGNAL(rangeChanged(QtProperty*, int, int)), - this, SLOT(slotRangeChanged(QtProperty*, int, int))); - connect(intPropertyManager, SIGNAL(singleStepChanged(QtProperty*, int)), - this, SLOT(slotSingleStepChanged(QtProperty*, int))); - // DoublePropertyManager - QtDoublePropertyManager* doublePropertyManager = new QtDoublePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Double] = doublePropertyManager; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_minimumAttribute] = - QVariant::Double; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_maximumAttribute] = - QVariant::Double; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_singleStepAttribute] = - QVariant::Double; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_decimalsAttribute] = - QVariant::Int; - d_ptr->m_typeToValueType[QVariant::Double] = QVariant::Double; - connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty*, double)), - this, SLOT(slotValueChanged(QtProperty*, double))); - connect(doublePropertyManager, SIGNAL(rangeChanged(QtProperty*, double, double)), - this, SLOT(slotRangeChanged(QtProperty*, double, double))); - connect(doublePropertyManager, SIGNAL(singleStepChanged(QtProperty*, double)), - this, SLOT(slotSingleStepChanged(QtProperty*, double))); - connect(doublePropertyManager, SIGNAL(decimalsChanged(QtProperty*, int)), - this, SLOT(slotDecimalsChanged(QtProperty*, int))); - // BoolPropertyManager - QtBoolPropertyManager* boolPropertyManager = new QtBoolPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Bool] = boolPropertyManager; - d_ptr->m_typeToValueType[QVariant::Bool] = QVariant::Bool; - connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty*, bool)), - this, SLOT(slotValueChanged(QtProperty*, bool))); - // StringPropertyManager - QtStringPropertyManager* stringPropertyManager = new QtStringPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::String] = stringPropertyManager; - d_ptr->m_typeToValueType[QVariant::String] = QVariant::String; - d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_regExpAttribute] = - QVariant::RegExp; - connect(stringPropertyManager, SIGNAL(valueChanged(QtProperty*, QString)), - this, SLOT(slotValueChanged(QtProperty*, QString))); - connect(stringPropertyManager, SIGNAL(regExpChanged(QtProperty*, QRegExp)), - this, SLOT(slotRegExpChanged(QtProperty*, QRegExp))); - // DatePropertyManager - QtDatePropertyManager* datePropertyManager = new QtDatePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Date] = datePropertyManager; - d_ptr->m_typeToValueType[QVariant::Date] = QVariant::Date; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_minimumAttribute] = - QVariant::Date; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_maximumAttribute] = - QVariant::Date; - connect(datePropertyManager, SIGNAL(valueChanged(QtProperty*, QDate)), - this, SLOT(slotValueChanged(QtProperty*, QDate))); - connect(datePropertyManager, SIGNAL(rangeChanged(QtProperty*, QDate, QDate)), - this, SLOT(slotRangeChanged(QtProperty*, QDate, QDate))); - // TimePropertyManager - QtTimePropertyManager* timePropertyManager = new QtTimePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Time] = timePropertyManager; - d_ptr->m_typeToValueType[QVariant::Time] = QVariant::Time; - connect(timePropertyManager, SIGNAL(valueChanged(QtProperty*, QTime)), - this, SLOT(slotValueChanged(QtProperty*, QTime))); - // DateTimePropertyManager - QtDateTimePropertyManager* dateTimePropertyManager = new QtDateTimePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::DateTime] = dateTimePropertyManager; - d_ptr->m_typeToValueType[QVariant::DateTime] = QVariant::DateTime; - connect(dateTimePropertyManager, SIGNAL(valueChanged(QtProperty*, QDateTime)), - this, SLOT(slotValueChanged(QtProperty*, QDateTime))); - // KeySequencePropertyManager - QtKeySequencePropertyManager* keySequencePropertyManager = new QtKeySequencePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::KeySequence] = keySequencePropertyManager; - d_ptr->m_typeToValueType[QVariant::KeySequence] = QVariant::KeySequence; - connect(keySequencePropertyManager, SIGNAL(valueChanged(QtProperty*, QKeySequence)), - this, SLOT(slotValueChanged(QtProperty*, QKeySequence))); - // CharPropertyManager - QtCharPropertyManager* charPropertyManager = new QtCharPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Char] = charPropertyManager; - d_ptr->m_typeToValueType[QVariant::Char] = QVariant::Char; - connect(charPropertyManager, SIGNAL(valueChanged(QtProperty*, QChar)), - this, SLOT(slotValueChanged(QtProperty*, QChar))); - // LocalePropertyManager - QtLocalePropertyManager* localePropertyManager = new QtLocalePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Locale] = localePropertyManager; - d_ptr->m_typeToValueType[QVariant::Locale] = QVariant::Locale; - connect(localePropertyManager, SIGNAL(valueChanged(QtProperty*, QLocale)), - this, SLOT(slotValueChanged(QtProperty*, QLocale))); - connect(localePropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(localePropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(localePropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // PointPropertyManager - QtPointPropertyManager* pointPropertyManager = new QtPointPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Point] = pointPropertyManager; - d_ptr->m_typeToValueType[QVariant::Point] = QVariant::Point; - connect(pointPropertyManager, SIGNAL(valueChanged(QtProperty*, QPoint)), - this, SLOT(slotValueChanged(QtProperty*, QPoint))); - connect(pointPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(pointPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(pointPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // PointFPropertyManager - QtPointFPropertyManager* pointFPropertyManager = new QtPointFPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::PointF] = pointFPropertyManager; - d_ptr->m_typeToValueType[QVariant::PointF] = QVariant::PointF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::PointF][d_ptr->m_decimalsAttribute] = - QVariant::Int; - connect(pointFPropertyManager, SIGNAL(valueChanged(QtProperty*, QPointF)), - this, SLOT(slotValueChanged(QtProperty*, QPointF))); - connect(pointFPropertyManager, SIGNAL(decimalsChanged(QtProperty*, int)), - this, SLOT(slotDecimalsChanged(QtProperty*, int))); - connect(pointFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*, double)), - this, SLOT(slotValueChanged(QtProperty*, double))); - connect(pointFPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(pointFPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // SizePropertyManager - QtSizePropertyManager* sizePropertyManager = new QtSizePropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Size] = sizePropertyManager; - d_ptr->m_typeToValueType[QVariant::Size] = QVariant::Size; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_minimumAttribute] = - QVariant::Size; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_maximumAttribute] = - QVariant::Size; - connect(sizePropertyManager, SIGNAL(valueChanged(QtProperty*, QSize)), - this, SLOT(slotValueChanged(QtProperty*, QSize))); - connect(sizePropertyManager, SIGNAL(rangeChanged(QtProperty*, QSize, QSize)), - this, SLOT(slotRangeChanged(QtProperty*, QSize, QSize))); - connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*, int, int)), - this, SLOT(slotRangeChanged(QtProperty*, int, int))); - connect(sizePropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(sizePropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // SizeFPropertyManager - QtSizeFPropertyManager* sizeFPropertyManager = new QtSizeFPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::SizeF] = sizeFPropertyManager; - d_ptr->m_typeToValueType[QVariant::SizeF] = QVariant::SizeF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_minimumAttribute] = - QVariant::SizeF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_maximumAttribute] = - QVariant::SizeF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_decimalsAttribute] = - QVariant::Int; - connect(sizeFPropertyManager, SIGNAL(valueChanged(QtProperty*, QSizeF)), - this, SLOT(slotValueChanged(QtProperty*, QSizeF))); - connect(sizeFPropertyManager, SIGNAL(rangeChanged(QtProperty*, QSizeF, QSizeF)), - this, SLOT(slotRangeChanged(QtProperty*, QSizeF, QSizeF))); - connect(sizeFPropertyManager, SIGNAL(decimalsChanged(QtProperty*, int)), - this, SLOT(slotDecimalsChanged(QtProperty*, int))); - connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*, double)), - this, SLOT(slotValueChanged(QtProperty*, double))); - connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty*, double, double)), - this, SLOT(slotRangeChanged(QtProperty*, double, double))); - connect(sizeFPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(sizeFPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // RectPropertyManager - QtRectPropertyManager* rectPropertyManager = new QtRectPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Rect] = rectPropertyManager; - d_ptr->m_typeToValueType[QVariant::Rect] = QVariant::Rect; - d_ptr->m_typeToAttributeToAttributeType[QVariant::Rect][d_ptr->m_constraintAttribute] = - QVariant::Rect; - connect(rectPropertyManager, SIGNAL(valueChanged(QtProperty*, QRect)), - this, SLOT(slotValueChanged(QtProperty*, QRect))); - connect(rectPropertyManager, SIGNAL(constraintChanged(QtProperty*, QRect)), - this, SLOT(slotConstraintChanged(QtProperty*, QRect))); - connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*, int, int)), - this, SLOT(slotRangeChanged(QtProperty*, int, int))); - connect(rectPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(rectPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // RectFPropertyManager - QtRectFPropertyManager* rectFPropertyManager = new QtRectFPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::RectF] = rectFPropertyManager; - d_ptr->m_typeToValueType[QVariant::RectF] = QVariant::RectF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_constraintAttribute] = - QVariant::RectF; - d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_decimalsAttribute] = - QVariant::Int; - connect(rectFPropertyManager, SIGNAL(valueChanged(QtProperty*, QRectF)), - this, SLOT(slotValueChanged(QtProperty*, QRectF))); - connect(rectFPropertyManager, SIGNAL(constraintChanged(QtProperty*, QRectF)), - this, SLOT(slotConstraintChanged(QtProperty*, QRectF))); - connect(rectFPropertyManager, SIGNAL(decimalsChanged(QtProperty*, int)), - this, SLOT(slotDecimalsChanged(QtProperty*, int))); - connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty*, double)), - this, SLOT(slotValueChanged(QtProperty*, double))); - connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty*, double, double)), - this, SLOT(slotRangeChanged(QtProperty*, double, double))); - connect(rectFPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(rectFPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // ColorPropertyManager - QtColorPropertyManager* colorPropertyManager = new QtColorPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Color] = colorPropertyManager; - d_ptr->m_typeToValueType[QVariant::Color] = QVariant::Color; - connect(colorPropertyManager, SIGNAL(valueChanged(QtProperty*, QColor)), - this, SLOT(slotValueChanged(QtProperty*, QColor))); - connect(colorPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(colorPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(colorPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // EnumPropertyManager - int enumId = enumTypeId(); - QtEnumPropertyManager* enumPropertyManager = new QtEnumPropertyManager(this); - d_ptr->m_typeToPropertyManager[enumId] = enumPropertyManager; - d_ptr->m_typeToValueType[enumId] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumNamesAttribute] = - QVariant::StringList; - d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumIconsAttribute] = - iconMapTypeId(); - connect(enumPropertyManager, SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(enumPropertyManager, SIGNAL(enumNamesChanged(QtProperty*, QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*, QStringList))); - connect(enumPropertyManager, SIGNAL(enumIconsChanged(QtProperty*, QMap)), - this, SLOT(slotEnumIconsChanged(QtProperty*, QMap))); - // SizePolicyPropertyManager - QtSizePolicyPropertyManager* sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::SizePolicy] = sizePolicyPropertyManager; - d_ptr->m_typeToValueType[QVariant::SizePolicy] = QVariant::SizePolicy; - connect(sizePolicyPropertyManager, SIGNAL(valueChanged(QtProperty*, QSizePolicy)), - this, SLOT(slotValueChanged(QtProperty*, QSizePolicy))); - connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*, int, int)), - this, SLOT(slotRangeChanged(QtProperty*, int, int))); - connect(sizePolicyPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(sizePolicyPropertyManager->subEnumPropertyManager(), - SIGNAL(enumNamesChanged(QtProperty*, QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*, QStringList))); - connect(sizePolicyPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(sizePolicyPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // FontPropertyManager - QtFontPropertyManager* fontPropertyManager = new QtFontPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Font] = fontPropertyManager; - d_ptr->m_typeToValueType[QVariant::Font] = QVariant::Font; - connect(fontPropertyManager, SIGNAL(valueChanged(QtProperty*, QFont)), - this, SLOT(slotValueChanged(QtProperty*, QFont))); - connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty*, int, int)), - this, SLOT(slotRangeChanged(QtProperty*, int, int))); - connect(fontPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(fontPropertyManager->subEnumPropertyManager(), - SIGNAL(enumNamesChanged(QtProperty*, QStringList)), - this, SLOT(slotEnumNamesChanged(QtProperty*, QStringList))); - connect(fontPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty*, bool)), - this, SLOT(slotValueChanged(QtProperty*, bool))); - connect(fontPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(fontPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // CursorPropertyManager - QtCursorPropertyManager* cursorPropertyManager = new QtCursorPropertyManager(this); - d_ptr->m_typeToPropertyManager[QVariant::Cursor] = cursorPropertyManager; - d_ptr->m_typeToValueType[QVariant::Cursor] = QVariant::Cursor; - connect(cursorPropertyManager, SIGNAL(valueChanged(QtProperty*, QCursor)), - this, SLOT(slotValueChanged(QtProperty*, QCursor))); - // FlagPropertyManager - int flagId = flagTypeId(); - QtFlagPropertyManager* flagPropertyManager = new QtFlagPropertyManager(this); - d_ptr->m_typeToPropertyManager[flagId] = flagPropertyManager; - d_ptr->m_typeToValueType[flagId] = QVariant::Int; - d_ptr->m_typeToAttributeToAttributeType[flagId][d_ptr->m_flagNamesAttribute] = - QVariant::StringList; - connect(flagPropertyManager, SIGNAL(valueChanged(QtProperty*, int)), - this, SLOT(slotValueChanged(QtProperty*, int))); - connect(flagPropertyManager, SIGNAL(flagNamesChanged(QtProperty*, QStringList)), - this, SLOT(slotFlagNamesChanged(QtProperty*, QStringList))); - connect(flagPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty*, bool)), - this, SLOT(slotValueChanged(QtProperty*, bool))); - connect(flagPropertyManager, SIGNAL(propertyInserted(QtProperty*, QtProperty*, QtProperty*)), - this, SLOT(slotPropertyInserted(QtProperty*, QtProperty*, QtProperty*))); - connect(flagPropertyManager, SIGNAL(propertyRemoved(QtProperty*, QtProperty*)), - this, SLOT(slotPropertyRemoved(QtProperty*, QtProperty*))); - // FlagPropertyManager - int groupId = groupTypeId(); - QtGroupPropertyManager* groupPropertyManager = new QtGroupPropertyManager(this); - d_ptr->m_typeToPropertyManager[groupId] = groupPropertyManager; - d_ptr->m_typeToValueType[groupId] = QVariant::Invalid; -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -QtVariantPropertyManager::~QtVariantPropertyManager() -{ - clear(); -} - -/*! - Returns the given \a property converted into a QtVariantProperty. - - If the \a property was not created by this variant manager, the - function returns 0. - - \sa createProperty() -*/ -QtVariantProperty* QtVariantPropertyManager::variantProperty(const QtProperty* property) const -{ - const QMap >::const_iterator it = d_ptr->m_propertyToType.constFind(property); - if (it == d_ptr->m_propertyToType.constEnd()) - return 0; - return it.value().first; -} - -/*! - Returns true if the given \a propertyType is supported by this - variant manager; otherwise false. - - \sa propertyType() -*/ -bool QtVariantPropertyManager::isPropertyTypeSupported(int propertyType) const -{ - if (d_ptr->m_typeToValueType.contains(propertyType)) - return true; - return false; -} - -/*! - Creates and returns a variant property of the given \a propertyType - with the given \a name. - - If the specified \a propertyType is not supported by this variant - manager, this function returns 0. - - Do not use the inherited - QtAbstractPropertyManager::addProperty() function to create a - variant property (that function will always return 0 since it will - not be clear what type the property should have). - - \sa isPropertyTypeSupported() -*/ -QtVariantProperty* QtVariantPropertyManager::addProperty(int propertyType, const QString& name) -{ - if (!isPropertyTypeSupported(propertyType)) - return 0; - - bool wasCreating = d_ptr->m_creatingProperty; - d_ptr->m_creatingProperty = true; - d_ptr->m_propertyType = propertyType; - QtProperty* property = QtAbstractPropertyManager::addProperty(name); - d_ptr->m_creatingProperty = wasCreating; - d_ptr->m_propertyType = 0; - - if (!property) - return 0; - - return variantProperty(property); -} - -/*! - Returns the given \a property's value. - - If the given \a property is not managed by this manager, this - function returns an invalid variant. - - \sa setValue() -*/ -QVariant QtVariantPropertyManager::value(const QtProperty* property) const -{ - QtProperty* internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return QVariant(); - - QtAbstractPropertyManager* manager = internProp->propertyManager(); - if (QtIntPropertyManager* intManager = qobject_cast(manager)) { - return intManager->value(internProp); - } - else if (QtDoublePropertyManager* doubleManager = qobject_cast(manager)) { - return doubleManager->value(internProp); - } - else if (QtBoolPropertyManager* boolManager = qobject_cast(manager)) { - return boolManager->value(internProp); - } - else if (QtStringPropertyManager* stringManager = qobject_cast(manager)) { - return stringManager->value(internProp); - } - else if (QtDatePropertyManager* dateManager = qobject_cast(manager)) { - return dateManager->value(internProp); - } - else if (QtTimePropertyManager* timeManager = qobject_cast(manager)) { - return timeManager->value(internProp); - } - else if (QtDateTimePropertyManager* dateTimeManager = qobject_cast(manager)) { - return dateTimeManager->value(internProp); - } - else if (QtKeySequencePropertyManager* keySequenceManager = qobject_cast(manager)) { - return QVariant::fromValue(keySequenceManager->value(internProp)); - } - else if (QtCharPropertyManager* charManager = qobject_cast(manager)) { - return charManager->value(internProp); - } - else if (QtLocalePropertyManager* localeManager = qobject_cast(manager)) { - return localeManager->value(internProp); - } - else if (QtPointPropertyManager* pointManager = qobject_cast(manager)) { - return pointManager->value(internProp); - } - else if (QtPointFPropertyManager* pointFManager = qobject_cast(manager)) { - return pointFManager->value(internProp); - } - else if (QtSizePropertyManager* sizeManager = qobject_cast(manager)) { - return sizeManager->value(internProp); - } - else if (QtSizeFPropertyManager* sizeFManager = qobject_cast(manager)) { - return sizeFManager->value(internProp); - } - else if (QtRectPropertyManager* rectManager = qobject_cast(manager)) { - return rectManager->value(internProp); - } - else if (QtRectFPropertyManager* rectFManager = qobject_cast(manager)) { - return rectFManager->value(internProp); - } - else if (QtColorPropertyManager* colorManager = qobject_cast(manager)) { - return colorManager->value(internProp); - } - else if (QtEnumPropertyManager* enumManager = qobject_cast(manager)) { - return enumManager->value(internProp); - } - else if (QtSizePolicyPropertyManager* sizePolicyManager = - qobject_cast(manager)) { - return sizePolicyManager->value(internProp); - } - else if (QtFontPropertyManager* fontManager = qobject_cast(manager)) { - return fontManager->value(internProp); -#ifndef QT_NO_CURSOR - } - else if (QtCursorPropertyManager* cursorManager = qobject_cast(manager)) { - return cursorManager->value(internProp); -#endif - } - else if (QtFlagPropertyManager* flagManager = qobject_cast(manager)) { - return flagManager->value(internProp); - } - return QVariant(); -} - -/*! - Returns the given \a property's value type. - - \sa propertyType() -*/ -int QtVariantPropertyManager::valueType(const QtProperty* property) const -{ - int propType = propertyType(property); - return valueType(propType); -} - -/*! - \overload - - Returns the value type associated with the given \a propertyType. -*/ -int QtVariantPropertyManager::valueType(int propertyType) const -{ - if (d_ptr->m_typeToValueType.contains(propertyType)) - return d_ptr->m_typeToValueType[propertyType]; - return 0; -} - -/*! - Returns the given \a property's type. - - \sa valueType() -*/ -int QtVariantPropertyManager::propertyType(const QtProperty* property) const -{ - const QMap >::const_iterator it = d_ptr->m_propertyToType.constFind(property); - if (it == d_ptr->m_propertyToType.constEnd()) - return 0; - return it.value().second; -} - -/*! - Returns the given \a property's value for the specified \a - attribute - - If the given \a property was not created by \e this manager, or if - the specified \a attribute does not exist, this function returns - an invalid variant. - - \sa attributes(), attributeType(), setAttribute() -*/ -QVariant QtVariantPropertyManager::attributeValue(const QtProperty* property, const QString& attribute) const -{ - int propType = propertyType(property); - if (!propType) - return QVariant(); - - QMap >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propType); - if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return QVariant(); - - QMap attributes = it.value(); - QMap::ConstIterator itAttr = attributes.find(attribute); - if (itAttr == attributes.constEnd()) - return QVariant(); - - QtProperty* internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return QVariant(); - - QtAbstractPropertyManager* manager = internProp->propertyManager(); - if (QtIntPropertyManager* intManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return intManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return intManager->minimum(internProp); - if (attribute == d_ptr->m_singleStepAttribute) - return intManager->singleStep(internProp); - return QVariant(); - } - else if (QtDoublePropertyManager* doubleManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return doubleManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return doubleManager->minimum(internProp); - if (attribute == d_ptr->m_singleStepAttribute) - return doubleManager->singleStep(internProp); - if (attribute == d_ptr->m_decimalsAttribute) - return doubleManager->decimals(internProp); - return QVariant(); - } - else if (QtStringPropertyManager* stringManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_regExpAttribute) - return stringManager->regExp(internProp); - return QVariant(); - } - else if (QtDatePropertyManager* dateManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return dateManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return dateManager->minimum(internProp); - return QVariant(); - } - else if (QtPointFPropertyManager* pointFManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_decimalsAttribute) - return pointFManager->decimals(internProp); - return QVariant(); - } - else if (QtSizePropertyManager* sizeManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return sizeManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return sizeManager->minimum(internProp); - return QVariant(); - } - else if (QtSizeFPropertyManager* sizeFManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - return sizeFManager->maximum(internProp); - if (attribute == d_ptr->m_minimumAttribute) - return sizeFManager->minimum(internProp); - if (attribute == d_ptr->m_decimalsAttribute) - return sizeFManager->decimals(internProp); - return QVariant(); - } - else if (QtRectPropertyManager* rectManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - return rectManager->constraint(internProp); - return QVariant(); - } - else if (QtRectFPropertyManager* rectFManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - return rectFManager->constraint(internProp); - if (attribute == d_ptr->m_decimalsAttribute) - return rectFManager->decimals(internProp); - return QVariant(); - } - else if (QtEnumPropertyManager* enumManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_enumNamesAttribute) - return enumManager->enumNames(internProp); - if (attribute == d_ptr->m_enumIconsAttribute) { - QVariant v; - v.setValue(enumManager->enumIcons(internProp)); - return v; - } - return QVariant(); - } - else if (QtFlagPropertyManager* flagManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_flagNamesAttribute) - return flagManager->flagNames(internProp); - return QVariant(); - } - return QVariant(); -} - -/*! - Returns a list of the given \a propertyType 's attributes. - - \sa attributeValue(), attributeType() -*/ -QStringList QtVariantPropertyManager::attributes(int propertyType) const -{ - QMap >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propertyType); - if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return QStringList(); - return it.value().keys(); -} - -/*! - Returns the type of the specified \a attribute of the given \a - propertyType. - - If the given \a propertyType is not supported by \e this manager, - or if the given \a propertyType does not possess the specified \a - attribute, this function returns QVariant::Invalid. - - \sa attributes(), valueType() -*/ -int QtVariantPropertyManager::attributeType(int propertyType, const QString& attribute) const -{ - QMap >::ConstIterator it = - d_ptr->m_typeToAttributeToAttributeType.find(propertyType); - if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd()) - return 0; - - QMap attributes = it.value(); - QMap::ConstIterator itAttr = attributes.find(attribute); - if (itAttr == attributes.constEnd()) - return 0; - return itAttr.value(); -} - -/*! - \fn void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &value) - - Sets the value of the given \a property to \a value. - - The specified \a value must be of a type returned by valueType(), - or of type that can be converted to valueType() using the - QVariant::canConvert() function, otherwise this function does - nothing. - - \sa value(), QtVariantProperty::setValue(), valueChanged() -*/ -void QtVariantPropertyManager::setValue(QtProperty* property, const QVariant& val) -{ - int propType = val.userType(); - if (!propType) - return; - - int valType = valueType(property); - - if (propType != valType && !val.canConvert(static_cast(valType))) - return; - - QtProperty* internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return; - - QtAbstractPropertyManager* manager = internProp->propertyManager(); - if (QtIntPropertyManager* intManager = qobject_cast(manager)) { - intManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtDoublePropertyManager* doubleManager = qobject_cast(manager)) { - doubleManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtBoolPropertyManager* boolManager = qobject_cast(manager)) { - boolManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtStringPropertyManager* stringManager = qobject_cast(manager)) { - stringManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtDatePropertyManager* dateManager = qobject_cast(manager)) { - dateManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtTimePropertyManager* timeManager = qobject_cast(manager)) { - timeManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtDateTimePropertyManager* dateTimeManager = qobject_cast(manager)) { - dateTimeManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtKeySequencePropertyManager* keySequenceManager = qobject_cast(manager)) { - keySequenceManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtCharPropertyManager* charManager = qobject_cast(manager)) { - charManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtLocalePropertyManager* localeManager = qobject_cast(manager)) { - localeManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtPointPropertyManager* pointManager = qobject_cast(manager)) { - pointManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtPointFPropertyManager* pointFManager = qobject_cast(manager)) { - pointFManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtSizePropertyManager* sizeManager = qobject_cast(manager)) { - sizeManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtSizeFPropertyManager* sizeFManager = qobject_cast(manager)) { - sizeFManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtRectPropertyManager* rectManager = qobject_cast(manager)) { - rectManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtRectFPropertyManager* rectFManager = qobject_cast(manager)) { - rectFManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtColorPropertyManager* colorManager = qobject_cast(manager)) { - colorManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtEnumPropertyManager* enumManager = qobject_cast(manager)) { - enumManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtSizePolicyPropertyManager* sizePolicyManager = - qobject_cast(manager)) { - sizePolicyManager->setValue(internProp, qvariant_cast(val)); - return; - } - else if (QtFontPropertyManager* fontManager = qobject_cast(manager)) { - fontManager->setValue(internProp, qvariant_cast(val)); - return; -#ifndef QT_NO_CURSOR - } - else if (QtCursorPropertyManager* cursorManager = qobject_cast(manager)) { - cursorManager->setValue(internProp, qvariant_cast(val)); - return; -#endif - } - else if (QtFlagPropertyManager* flagManager = qobject_cast(manager)) { - flagManager->setValue(internProp, qvariant_cast(val)); - return; - } -} - -/*! - Sets the value of the specified \a attribute of the given \a - property, to \a value. - - The new \a value's type must be of the type returned by - attributeType(), or of a type that can be converted to - attributeType() using the QVariant::canConvert() function, - otherwise this function does nothing. - - \sa attributeValue(), QtVariantProperty::setAttribute(), attributeChanged() -*/ -void QtVariantPropertyManager::setAttribute(QtProperty* property, - const QString& attribute, const QVariant& value) -{ - QVariant oldAttr = attributeValue(property, attribute); - if (!oldAttr.isValid()) - return; - - int attrType = value.userType(); - if (!attrType) - return; - - if (attrType != attributeType(propertyType(property), attribute) && - !value.canConvert((QVariant::Type)attrType)) - return; - - QtProperty* internProp = propertyToWrappedProperty()->value(property, 0); - if (internProp == 0) - return; - - QtAbstractPropertyManager* manager = internProp->propertyManager(); - if (QtIntPropertyManager* intManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - intManager->setMaximum(internProp, qvariant_cast(value)); - else if (attribute == d_ptr->m_minimumAttribute) - intManager->setMinimum(internProp, qvariant_cast(value)); - else if (attribute == d_ptr->m_singleStepAttribute) - intManager->setSingleStep(internProp, qvariant_cast(value)); - return; - } - else if (QtDoublePropertyManager* doubleManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - doubleManager->setMaximum(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_minimumAttribute) - doubleManager->setMinimum(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_singleStepAttribute) - doubleManager->setSingleStep(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_decimalsAttribute) - doubleManager->setDecimals(internProp, qvariant_cast(value)); - return; - } - else if (QtStringPropertyManager* stringManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_regExpAttribute) - stringManager->setRegExp(internProp, qvariant_cast(value)); - return; - } - else if (QtDatePropertyManager* dateManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - dateManager->setMaximum(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_minimumAttribute) - dateManager->setMinimum(internProp, qvariant_cast(value)); - return; - } - else if (QtPointFPropertyManager* pointFManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_decimalsAttribute) - pointFManager->setDecimals(internProp, qvariant_cast(value)); - return; - } - else if (QtSizePropertyManager* sizeManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - sizeManager->setMaximum(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_minimumAttribute) - sizeManager->setMinimum(internProp, qvariant_cast(value)); - return; - } - else if (QtSizeFPropertyManager* sizeFManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_maximumAttribute) - sizeFManager->setMaximum(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_minimumAttribute) - sizeFManager->setMinimum(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_decimalsAttribute) - sizeFManager->setDecimals(internProp, qvariant_cast(value)); - return; - } - else if (QtRectPropertyManager* rectManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - rectManager->setConstraint(internProp, qvariant_cast(value)); - return; - } - else if (QtRectFPropertyManager* rectFManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_constraintAttribute) - rectFManager->setConstraint(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_decimalsAttribute) - rectFManager->setDecimals(internProp, qvariant_cast(value)); - return; - } - else if (QtEnumPropertyManager* enumManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_enumNamesAttribute) - enumManager->setEnumNames(internProp, qvariant_cast(value)); - if (attribute == d_ptr->m_enumIconsAttribute) - enumManager->setEnumIcons(internProp, qvariant_cast(value)); - return; - } - else if (QtFlagPropertyManager* flagManager = qobject_cast(manager)) { - if (attribute == d_ptr->m_flagNamesAttribute) - flagManager->setFlagNames(internProp, qvariant_cast(value)); - return; - } -} - -/*! - \internal -*/ -bool QtVariantPropertyManager::hasValue(const QtProperty* property) const -{ - if (propertyType(property) == groupTypeId()) - return false; - return true; -} - -/*! - \internal -*/ -QString QtVariantPropertyManager::valueText(const QtProperty* property) const -{ - const QtProperty* internProp = propertyToWrappedProperty()->value(property, 0); - return internProp ? internProp->valueText() : QString(); -} - -/*! - \internal -*/ -QIcon QtVariantPropertyManager::valueIcon(const QtProperty* property) const -{ - const QtProperty* internProp = propertyToWrappedProperty()->value(property, 0); - return internProp ? internProp->valueIcon() : QIcon(); -} - -/*! - \internal -*/ -void QtVariantPropertyManager::initializeProperty(QtProperty* property) -{ - QtVariantProperty* varProp = variantProperty(property); - if (!varProp) - return; - - QMap::ConstIterator it = - d_ptr->m_typeToPropertyManager.find(d_ptr->m_propertyType); - if (it != d_ptr->m_typeToPropertyManager.constEnd()) { - QtProperty* internProp = 0; - if (!d_ptr->m_creatingSubProperties) { - QtAbstractPropertyManager* manager = it.value(); - internProp = manager->addProperty(); - d_ptr->m_internalToProperty[internProp] = varProp; - } - propertyToWrappedProperty()->insert(varProp, internProp); - if (internProp) { - const QList children = internProp->subProperties(); - QtVariantProperty* lastProperty = 0; - for (QtProperty* child : children) { - QtVariantProperty* prop = d_ptr->createSubProperty(varProp, lastProperty, child); - lastProperty = prop ? prop : lastProperty; - } - } - } -} - -/*! - \internal -*/ -void QtVariantPropertyManager::uninitializeProperty(QtProperty* property) -{ - const QMap >::iterator type_it = d_ptr->m_propertyToType.find(property); - if (type_it == d_ptr->m_propertyToType.end()) - return; - - PropertyMap::iterator it = propertyToWrappedProperty()->find(property); - if (it != propertyToWrappedProperty()->end()) { - QtProperty* internProp = it.value(); - if (internProp) { - d_ptr->m_internalToProperty.remove(internProp); - if (!d_ptr->m_destroyingSubProperties) { - delete internProp; - } - } - propertyToWrappedProperty()->erase(it); - } - d_ptr->m_propertyToType.erase(type_it); -} - -/*! - \internal -*/ -QtProperty* QtVariantPropertyManager::createProperty() -{ - if (!d_ptr->m_creatingProperty) - return 0; - - QtVariantProperty* property = new QtVariantProperty(this); - d_ptr->m_propertyToType.insert(property, qMakePair(property, d_ptr->m_propertyType)); - - return property; -} - -///////////////////////////// - -class QtVariantEditorFactoryPrivate -{ - QtVariantEditorFactory* q_ptr; - Q_DECLARE_PUBLIC(QtVariantEditorFactory) -public: - - QtSpinBoxFactory* m_spinBoxFactory; - QtDoubleSpinBoxFactory* m_doubleSpinBoxFactory; - QtCheckBoxFactory* m_checkBoxFactory; - QtLineEditFactory* m_lineEditFactory; - QtDateEditFactory* m_dateEditFactory; - QtTimeEditFactory* m_timeEditFactory; - QtDateTimeEditFactory* m_dateTimeEditFactory; - QtKeySequenceEditorFactory* m_keySequenceEditorFactory; - QtCharEditorFactory* m_charEditorFactory; - QtEnumEditorFactory* m_comboBoxFactory; - QtCursorEditorFactory* m_cursorEditorFactory; - QtColorEditorFactory* m_colorEditorFactory; - QtFontEditorFactory* m_fontEditorFactory; - - QMap m_factoryToType; - QMap m_typeToFactory; -}; - -/*! - \class QtVariantEditorFactory - \internal - \inmodule QtDesigner - \since 4.4 - - \brief The QtVariantEditorFactory class provides widgets for properties - created by QtVariantPropertyManager objects. - - The variant factory provides the following widgets for the - specified property types: - - \table - \header - \li Property Type - \li Widget - \row - \li \c int - \li QSpinBox - \row - \li \c double - \li QDoubleSpinBox - \row - \li \c bool - \li QCheckBox - \row - \li QString - \li QLineEdit - \row - \li QDate - \li QDateEdit - \row - \li QTime - \li QTimeEdit - \row - \li QDateTime - \li QDateTimeEdit - \row - \li QKeySequence - \li customized editor - \row - \li QChar - \li customized editor - \row - \li \c enum - \li QComboBox - \row - \li QCursor - \li QComboBox - \endtable - - Note that QtVariantPropertyManager supports several additional property - types for which the QtVariantEditorFactory class does not provide - editing widgets, e.g. QPoint and QSize. To provide widgets for other - types using the variant approach, derive from the QtVariantEditorFactory - class. - - \sa QtAbstractEditorFactory, QtVariantPropertyManager -*/ - -/*! - Creates a factory with the given \a parent. -*/ -QtVariantEditorFactory::QtVariantEditorFactory(QObject* parent) - : QtAbstractEditorFactory(parent), d_ptr(new QtVariantEditorFactoryPrivate()) -{ - d_ptr->q_ptr = this; - - d_ptr->m_spinBoxFactory = new QtSpinBoxFactory(this); - d_ptr->m_factoryToType[d_ptr->m_spinBoxFactory] = QVariant::Int; - d_ptr->m_typeToFactory[QVariant::Int] = d_ptr->m_spinBoxFactory; - - d_ptr->m_doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this); - d_ptr->m_factoryToType[d_ptr->m_doubleSpinBoxFactory] = QVariant::Double; - d_ptr->m_typeToFactory[QVariant::Double] = d_ptr->m_doubleSpinBoxFactory; - - d_ptr->m_checkBoxFactory = new QtCheckBoxFactory(this); - d_ptr->m_factoryToType[d_ptr->m_checkBoxFactory] = QVariant::Bool; - d_ptr->m_typeToFactory[QVariant::Bool] = d_ptr->m_checkBoxFactory; - - d_ptr->m_lineEditFactory = new QtLineEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_lineEditFactory] = QVariant::String; - d_ptr->m_typeToFactory[QVariant::String] = d_ptr->m_lineEditFactory; - - d_ptr->m_dateEditFactory = new QtDateEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_dateEditFactory] = QVariant::Date; - d_ptr->m_typeToFactory[QVariant::Date] = d_ptr->m_dateEditFactory; - - d_ptr->m_timeEditFactory = new QtTimeEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_timeEditFactory] = QVariant::Time; - d_ptr->m_typeToFactory[QVariant::Time] = d_ptr->m_timeEditFactory; - - d_ptr->m_dateTimeEditFactory = new QtDateTimeEditFactory(this); - d_ptr->m_factoryToType[d_ptr->m_dateTimeEditFactory] = QVariant::DateTime; - d_ptr->m_typeToFactory[QVariant::DateTime] = d_ptr->m_dateTimeEditFactory; - - d_ptr->m_keySequenceEditorFactory = new QtKeySequenceEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_keySequenceEditorFactory] = QVariant::KeySequence; - d_ptr->m_typeToFactory[QVariant::KeySequence] = d_ptr->m_keySequenceEditorFactory; - - d_ptr->m_charEditorFactory = new QtCharEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_charEditorFactory] = QVariant::Char; - d_ptr->m_typeToFactory[QVariant::Char] = d_ptr->m_charEditorFactory; - - d_ptr->m_cursorEditorFactory = new QtCursorEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_cursorEditorFactory] = QVariant::Cursor; - d_ptr->m_typeToFactory[QVariant::Cursor] = d_ptr->m_cursorEditorFactory; - - d_ptr->m_colorEditorFactory = new QtColorEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_colorEditorFactory] = QVariant::Color; - d_ptr->m_typeToFactory[QVariant::Color] = d_ptr->m_colorEditorFactory; - - d_ptr->m_fontEditorFactory = new QtFontEditorFactory(this); - d_ptr->m_factoryToType[d_ptr->m_fontEditorFactory] = QVariant::Font; - d_ptr->m_typeToFactory[QVariant::Font] = d_ptr->m_fontEditorFactory; - - d_ptr->m_comboBoxFactory = new QtEnumEditorFactory(this); - const int enumId = QtVariantPropertyManager::enumTypeId(); - d_ptr->m_factoryToType[d_ptr->m_comboBoxFactory] = enumId; - d_ptr->m_typeToFactory[enumId] = d_ptr->m_comboBoxFactory; -} - -/*! - Destroys this factory, and all the widgets it has created. -*/ -QtVariantEditorFactory::~QtVariantEditorFactory() -{ -} - -/*! - \internal - - Reimplemented from the QtAbstractEditorFactory class. -*/ -void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager* manager) -{ - const QList intPropertyManagers = manager->findChildren(); - for (QtIntPropertyManager* manager : intPropertyManagers) - d_ptr->m_spinBoxFactory->addPropertyManager(manager); - - const QList doublePropertyManagers = manager->findChildren(); - for (QtDoublePropertyManager* manager : doublePropertyManagers) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager); - - const QList boolPropertyManagers = manager->findChildren(); - for (QtBoolPropertyManager* manager : boolPropertyManagers) - d_ptr->m_checkBoxFactory->addPropertyManager(manager); - - const QList stringPropertyManagers = manager->findChildren(); - for (QtStringPropertyManager* manager : stringPropertyManagers) - d_ptr->m_lineEditFactory->addPropertyManager(manager); - - const QList datePropertyManagers = manager->findChildren(); - for (QtDatePropertyManager* manager : datePropertyManagers) - d_ptr->m_dateEditFactory->addPropertyManager(manager); - - const QList timePropertyManagers = manager->findChildren(); - for (QtTimePropertyManager* manager : timePropertyManagers) - d_ptr->m_timeEditFactory->addPropertyManager(manager); - - const QList dateTimePropertyManagers = manager->findChildren(); - for (QtDateTimePropertyManager* manager : dateTimePropertyManagers) - d_ptr->m_dateTimeEditFactory->addPropertyManager(manager); - - const QList keySequencePropertyManagers = manager->findChildren(); - for (QtKeySequencePropertyManager* manager : keySequencePropertyManagers) - d_ptr->m_keySequenceEditorFactory->addPropertyManager(manager); - - const QList charPropertyManagers = manager->findChildren(); - for (QtCharPropertyManager* manager : charPropertyManagers) - d_ptr->m_charEditorFactory->addPropertyManager(manager); - - const QList localePropertyManagers = manager->findChildren(); - for (QtLocalePropertyManager* manager : localePropertyManagers) - d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager()); - - const QList pointPropertyManagers = manager->findChildren(); - for (QtPointPropertyManager* manager : pointPropertyManagers) - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - - const QList pointFPropertyManagers = manager->findChildren(); - for (QtPointFPropertyManager* manager : pointFPropertyManagers) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager->subDoublePropertyManager()); - - const QList sizePropertyManagers = manager->findChildren(); - for (QtSizePropertyManager* manager : sizePropertyManagers) - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - - const QList sizeFPropertyManagers = manager->findChildren(); - for (QtSizeFPropertyManager* manager : sizeFPropertyManagers) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager->subDoublePropertyManager()); - - const QList rectPropertyManagers = manager->findChildren(); - for (QtRectPropertyManager* manager : rectPropertyManagers) - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - - const QList rectFPropertyManagers = manager->findChildren(); - for (QtRectFPropertyManager* manager : rectFPropertyManagers) - d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager->subDoublePropertyManager()); - - const QList colorPropertyManagers = manager->findChildren(); - for (QtColorPropertyManager* manager : colorPropertyManagers) { - d_ptr->m_colorEditorFactory->addPropertyManager(manager); - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - } - - const QList enumPropertyManagers = manager->findChildren(); - for (QtEnumPropertyManager* manager : enumPropertyManagers) - d_ptr->m_comboBoxFactory->addPropertyManager(manager); - - const QList sizePolicyPropertyManagers = manager->findChildren(); - for (QtSizePolicyPropertyManager* manager : sizePolicyPropertyManagers) { - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager()); - } - - const QList fontPropertyManagers = manager->findChildren(); - for (QtFontPropertyManager* manager : fontPropertyManagers) { - d_ptr->m_fontEditorFactory->addPropertyManager(manager); - d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager()); - d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager()); - } - - const QList cursorPropertyManagers = manager->findChildren(); - for (QtCursorPropertyManager* manager : cursorPropertyManagers) - d_ptr->m_cursorEditorFactory->addPropertyManager(manager); - - const QList flagPropertyManagers = manager->findChildren(); - for (QtFlagPropertyManager* manager : flagPropertyManagers) - d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager()); -} - -/*! - \internal - - Reimplemented from the QtAbstractEditorFactory class. -*/ -QWidget* QtVariantEditorFactory::createEditor(QtVariantPropertyManager* manager, QtProperty* property, - QWidget* parent) -{ - const int propType = manager->propertyType(property); - QtAbstractEditorFactoryBase* factory = d_ptr->m_typeToFactory.value(propType, 0); - if (!factory) - return 0; - return factory->createEditor(wrappedProperty(property), parent); -} - -/*! - \internal - - Reimplemented from the QtAbstractEditorFactory class. -*/ -void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager* manager) -{ - const QList intPropertyManagers = manager->findChildren(); - for (QtIntPropertyManager* manager : intPropertyManagers) - d_ptr->m_spinBoxFactory->removePropertyManager(manager); - - const QList doublePropertyManagers = manager->findChildren(); - for (QtDoublePropertyManager* manager : doublePropertyManagers) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager); - - const QList boolPropertyManagers = manager->findChildren(); - for (QtBoolPropertyManager* manager : boolPropertyManagers) - d_ptr->m_checkBoxFactory->removePropertyManager(manager); - - const QList stringPropertyManagers = manager->findChildren(); - for (QtStringPropertyManager* manager : stringPropertyManagers) - d_ptr->m_lineEditFactory->removePropertyManager(manager); - - const QList datePropertyManagers = manager->findChildren(); - for (QtDatePropertyManager* manager : datePropertyManagers) - d_ptr->m_dateEditFactory->removePropertyManager(manager); - - const QList timePropertyManagers = manager->findChildren(); - for (QtTimePropertyManager* manager : timePropertyManagers) - d_ptr->m_timeEditFactory->removePropertyManager(manager); - - const QList dateTimePropertyManagers = manager->findChildren(); - for (QtDateTimePropertyManager* manager : dateTimePropertyManagers) - d_ptr->m_dateTimeEditFactory->removePropertyManager(manager); - - const QList keySequencePropertyManagers = manager->findChildren(); - for (QtKeySequencePropertyManager* manager : keySequencePropertyManagers) - d_ptr->m_keySequenceEditorFactory->removePropertyManager(manager); - - const QList charPropertyManagers = manager->findChildren(); - for (QtCharPropertyManager* manager : charPropertyManagers) - d_ptr->m_charEditorFactory->removePropertyManager(manager); - - const QList localePropertyManagers = manager->findChildren(); - for (QtLocalePropertyManager* manager : localePropertyManagers) - d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager()); - - const QList pointPropertyManagers = manager->findChildren(); - for (QtPointPropertyManager* manager : pointPropertyManagers) - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - - const QList pointFPropertyManagers = manager->findChildren(); - for (QtPointFPropertyManager* manager : pointFPropertyManagers) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager->subDoublePropertyManager()); - - const QList sizePropertyManagers = manager->findChildren(); - for (QtSizePropertyManager* manager : sizePropertyManagers) - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - - const QList sizeFPropertyManagers = manager->findChildren(); - for (QtSizeFPropertyManager* manager : sizeFPropertyManagers) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager->subDoublePropertyManager()); - - const QList rectPropertyManagers = manager->findChildren(); - for (QtRectPropertyManager* manager : rectPropertyManagers) - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - - const QList rectFPropertyManagers = manager->findChildren(); - for (QtRectFPropertyManager* manager : rectFPropertyManagers) - d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager->subDoublePropertyManager()); - - const QList colorPropertyManagers = manager->findChildren(); - for (QtColorPropertyManager* manager : colorPropertyManagers) { - d_ptr->m_colorEditorFactory->removePropertyManager(manager); - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - } - - const QList enumPropertyManagers = manager->findChildren(); - for (QtEnumPropertyManager* manager : enumPropertyManagers) - d_ptr->m_comboBoxFactory->removePropertyManager(manager); - - const QList sizePolicyPropertyManagers = manager->findChildren(); - for (QtSizePolicyPropertyManager* manager : sizePolicyPropertyManagers) { - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager()); - } - - const QList fontPropertyManagers = manager->findChildren(); - for (QtFontPropertyManager* manager : fontPropertyManagers) { - d_ptr->m_fontEditorFactory->removePropertyManager(manager); - d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager()); - d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager()); - d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager()); - } - - const QList cursorPropertyManagers = manager->findChildren(); - for (QtCursorPropertyManager* manager : cursorPropertyManagers) - d_ptr->m_cursorEditorFactory->removePropertyManager(manager); - - const QList flagPropertyManagers = manager->findChildren(); - for (QtFlagPropertyManager* manager : flagPropertyManagers) - d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager()); -} - -QT_END_NAMESPACE - -#include "property_browser/moc_qtvariantproperty.cpp" \ No newline at end of file diff --git a/QtRpa/modules/property/src/rectpropertymanager.c1 b/QtRpa/modules/property/src/rectpropertymanager.c1 deleted file mode 100644 index 076763d..0000000 --- a/QtRpa/modules/property/src/rectpropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/rectpropertymanager.h" -#include "property/private/rectpropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -RectPropertyManager::RectPropertyManager(Object* parent /*= nullptr*/) - :RectPropertyManager(*new RectPropertyManagerPrivate, parent) -{ - -} -RectPropertyManager::RectPropertyManager(RectPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/sizepolicypropertymanager.c1 b/QtRpa/modules/property/src/sizepolicypropertymanager.c1 deleted file mode 100644 index 9618913..0000000 --- a/QtRpa/modules/property/src/sizepolicypropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/sizepolicypropertymanager.h" -#include "property/private/sizepolicypropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -SizePolicyPropertyManager::SizePolicyPropertyManager(Object* parent /*= nullptr*/) - :SizePolicyPropertyManager(*new SizePolicyPropertyManagerPrivate, parent) -{ - -} -SizePolicyPropertyManager::SizePolicyPropertyManager(SizePolicyPropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/sizepropertymanager.c1 b/QtRpa/modules/property/src/sizepropertymanager.c1 deleted file mode 100644 index d2df37b..0000000 --- a/QtRpa/modules/property/src/sizepropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/sizepropertymanager.h" -#include "property/private/sizepropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -SizePropertyManager::SizePropertyManager(Object* parent /*= nullptr*/) - :SizePropertyManager(*new SizePropertyManagerPrivate, parent) -{ - -} -SizePropertyManager::SizePropertyManager(SizePropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/stringpropertymanager.cpp b/QtRpa/modules/property/src/stringpropertymanager.cpp deleted file mode 100644 index 48429d8..0000000 --- a/QtRpa/modules/property/src/stringpropertymanager.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include "property/framework.h" -#include "property/abstractpropertymanager.h" -#include "property/stringpropertymanager.h" -#include "private/qobject_p.h" -#include "property/private/abstractpropertymanager_p.h" -#include "property/private/stringpropertymanager_p.h" -namespace shelllet{ - namespace property{ - template - static Value getData(const QMap& propertyMap, - Value PrivateData::* data, - const PropertySheet* property, const Value& defaultValue = Value()) - { - const auto it = propertyMap.constFind(property); - if (it == propertyMap.constEnd()) - return defaultValue; - return it.value().*data; - } - - template - static Value getValue(const QMap& propertyMap, - const PropertySheet* property, const Value& defaultValue = Value()) - { - return getData(propertyMap, &PrivateData::val, property, defaultValue); - } - } -} -using namespace shelllet::property; - -//StringPropertyManager::StringPropertyManager(Object* parent /*= nullptr*/) -// :StringPropertyManager(*new StringPropertyManagerPrivate, nullptr, parent) -//{ -// -//} -StringPropertyManager::StringPropertyManager(StringPropertyManagerPrivate& d, QObject* parent, Object* /*parent*/ /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} - - -StringPropertyManager::StringPropertyManager(QObject* parent) - : AbstractPropertyManager(*new StringPropertyManagerPrivate, parent) -{ -} - -/*! - Destroys this manager, and all the properties it has created. -*/ -StringPropertyManager::~StringPropertyManager() -{ - clear(); -} - - - -/*! - Returns the given \a property's value. - - If the given property is not managed by this manager, this - function returns an empty string. - - \sa setValue() -*/ -String StringPropertyManager::value(const PropertySheet* property) const -{ - Q_D(const StringPropertyManager); - return getValue(d->m_values, property); -} - -/*! - Returns the given \a property's currently set regular expression. - - If the given \a property is not managed by this manager, this - function returns an empty expression. - - \sa setRegExp() -*/ -QRegExp StringPropertyManager::regExp(const PropertySheet* property) const -{ - Q_D(const StringPropertyManager); - return getData(d->m_values, &StringPropertyManagerPrivate::Data::regExp, property, QRegExp()); -} - -/*! - \reimp -*/ -String StringPropertyManager::valueText(const PropertySheet* property) const -{ - Q_D(const StringPropertyManager); - const StringPropertyManagerPrivate::PropertyValueMap::const_iterator it = d->m_values.constFind(property); - if (it == d->m_values.constEnd()) - return String(); - return it.value().val; -} - -/*! - \fn void StringPropertyManager::setValue(PropertySheet *property, const QString &value) - - Sets the value of the given \a property to \a value. - - If the specified \a value doesn't match the given \a property's - regular expression, this function does nothing. - - \sa value(), setRegExp(), valueChanged() -*/ -void StringPropertyManager::setValue(PropertySheet* property, const String& val) -{ - Q_D(StringPropertyManager); - const StringPropertyManagerPrivate::PropertyValueMap::iterator it = d->m_values.find(property); - if (it == d->m_values.end()) - return; - - StringPropertyManagerPrivate::Data data = it.value(); - - if (data.val == val) - return; - - if (data.regExp.isValid() && !data.regExp.exactMatch(*val.toQString())) - return; - - data.val = val; - - it.value() = data; - - emit propertyChanged(property); - emit valueChanged(property, data.val); -} -/*! - Sets the regular expression of the given \a property to \a regExp. - - \sa regExp(), setValue(), regExpChanged() -*/ -void StringPropertyManager::setRegExp(PropertySheet* property, const QRegExp& regExp) -{ - Q_D(StringPropertyManager); - const StringPropertyManagerPrivate::PropertyValueMap::iterator it = d->m_values.find(property); - if (it == d->m_values.end()) - return; - - StringPropertyManagerPrivate::Data data = it.value(); - - if (data.regExp == regExp) - return; - - data.regExp = regExp; - - it.value() = data; - - emit regExpChanged(property, data.regExp); -} - -/*! - \reimp -*/ -void StringPropertyManager::initializeProperty(PropertySheet* property) -{ - Q_D(StringPropertyManager); - d->m_values[property] = StringPropertyManagerPrivate::Data(); -} - -/*! - \reimp -*/ -void StringPropertyManager::uninitializeProperty(PropertySheet* property) -{ - Q_D(StringPropertyManager); - d->m_values.remove(property); -} \ No newline at end of file diff --git a/QtRpa/modules/property/src/timepropertymanager.c1 b/QtRpa/modules/property/src/timepropertymanager.c1 deleted file mode 100644 index 4c07b3d..0000000 --- a/QtRpa/modules/property/src/timepropertymanager.c1 +++ /dev/null @@ -1,19 +0,0 @@ -#include "property/timepropertymanager.h" -#include "property/private/timepropertymanager_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -TimePropertyManager::TimePropertyManager(Object* parent /*= nullptr*/) - :TimePropertyManager(*new TimePropertyManagerPrivate, parent) -{ - -} -TimePropertyManager::TimePropertyManager(TimePropertyManagerPrivate& d, Object* parent /*= nullptr*/) - : AbstractPropertyManager(d, parent) -{ - -} diff --git a/QtRpa/modules/property/src/utils.cpp b/QtRpa/modules/property/src/utils.cpp deleted file mode 100644 index 1e171f9..0000000 --- a/QtRpa/modules/property/src/utils.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include "property/framework.h" -#include "qpainter.h" -#include "qpixmap.h" -#include "qcoreapplication.h" -#include "property/utils.h" -#include "property/private/utils_p.h" - -namespace shelllet{ - namespace property{ - - } -} -using namespace shelllet::property; -Utils::Utils(Object* parent /*= nullptr*/) - :Utils(*new UtilsPrivate, parent) -{ - -} -Utils::Utils(UtilsPrivate& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{ - -} - - - -QPixmap Utils::brushValuePixmap(const QBrush& b) -{ - QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); - img.fill(0); - - QPainter painter(&img); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(0, 0, img.width(), img.height(), b); - QColor color = b.color(); - if (color.alpha() != 255) { // indicate alpha by an inset - QBrush opaqueBrush = b; - color.setAlpha(255); - opaqueBrush.setColor(color); - painter.fillRect(img.width() / 4, img.height() / 4, - img.width() / 2, img.height() / 2, opaqueBrush); - } - painter.end(); - return QPixmap::fromImage(img); -} - -QIcon Utils::brushValueIcon(const QBrush& b) -{ - return QIcon(brushValuePixmap(b)); -} - -QString Utils::colorValueText(const QColor& c) -{ - return QCoreApplication::translate("Utils", "[%1, %2, %3] (%4)") - .arg(c.red()).arg(c.green()).arg(c.blue()).arg(c.alpha()); -} - -QPixmap Utils::fontValuePixmap(const QFont& font) -{ - QFont f = font; - QImage img(16, 16, QImage::Format_ARGB32_Premultiplied); - img.fill(0); - QPainter p(&img); - p.setRenderHint(QPainter::TextAntialiasing, true); - p.setRenderHint(QPainter::Antialiasing, true); - f.setPointSize(13); - p.setFont(f); - QTextOption t; - t.setAlignment(Qt::AlignCenter); - p.drawText(QRect(0, 0, 16, 16), QString(QLatin1Char('A')), t); - return QPixmap::fromImage(img); -} - -QIcon Utils::fontValueIcon(const QFont& f) -{ - return QIcon(fontValuePixmap(f)); -} - -QString Utils::fontValueText(const QFont& f) -{ - return QCoreApplication::translate("Utils", "[%1, %2]") - .arg(f.family()).arg(f.pointSize()); -} - -QString Utils::dateFormat() -{ - QLocale loc; - QString format = loc.dateFormat(QLocale::ShortFormat); - // Change dd.MM.yy, MM/dd/yy to 4 digit years - if (format.count(QLatin1Char('y')) == 2) - format.insert(format.indexOf(QLatin1Char('y')), QLatin1String("yy")); - return format; -} - -QString Utils::timeFormat() -{ - QLocale loc; - // ShortFormat is missing seconds on UNIX. - return loc.timeFormat(QLocale::LongFormat); -} - -QString Utils::dateTimeFormat() -{ - QString format = dateFormat(); - format += QLatin1Char(' '); - format += timeFormat(); - return format; -} \ No newline at end of file diff --git a/QtRpa/modules/scintilla2/src/page.cpp b/QtRpa/modules/scintilla2/src/page.cpp deleted file mode 100644 index 9182c24..0000000 --- a/QtRpa/modules/scintilla2/src/page.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "scintilla/page.h" -#include "common/code.h" -#include "common/format.h" - - -shelllet::scintilla::ScintillaPage::ScintillaPage( QWidget* parent /*= nullptr*/) - : ScintillaPage("", parent) - -{ - -} - -shelllet::scintilla::ScintillaPage::ScintillaPage(const String& text, QWidget* parent /*= nullptr*/) - : scintilla_component(parent) -{ - setUtf8Encode(); - setStyleJavaScript(); - setSavePoint(); - - setText(text); -} - -shelllet::scintilla::ScintillaPage::~ScintillaPage() -{ -} - - diff --git a/QtRpa/modules/scintilla2/src/scintilla_api_wrapper.cpp b/QtRpa/modules/scintilla2/src/scintilla_api_wrapper.cpp deleted file mode 100644 index 874fa3d..0000000 --- a/QtRpa/modules/scintilla2/src/scintilla_api_wrapper.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include -#include "scintilla/scintilla_api_wrapper.h" -#include "scintilla/scintilla_module_manager.h" -#include "SciLexer.h" -#include -#include - -void shelllet::scintilla::ScintillaApiWrapper::setText(const String& text) -{ - sendMessage(SCI_SETTEXT, 0, (sptr_t)text.data()); -} - -String shelllet::scintilla::ScintillaApiWrapper::text() const -{ - sptr_t n = sendMessage(SCI_GETTEXT); - if (n > 0) { - std::vector block(--n); - - sendMessage(SCI_GETTEXT, n, (sptr_t)&block[0]); - - return std::string(block.begin(), block.end()); - } - return ""; -} - -void shelllet::scintilla::ScintillaApiWrapper::setSavePoint() -{ - sendMessage(SCI_SETSAVEPOINT); -} - -void shelllet::scintilla::ScintillaApiWrapper::setStyleJavaScript() -{ - const char* keywords = "var break require new"; - sendMessage(SCI_SETLEXER, SCLEX_ESCRIPT); - sendMessage(SCI_SETKEYWORDS, 0, (sptr_t)keywords); - - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_DEFAULT, 0x222222); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_COMMENT, 0x00008000); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_COMMENTLINE, 0x007500); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_COMMENTDOC, 0x007500); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_NUMBER, 0x6500D4); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_WORD, 0x222286); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_STRING, 0x4b505d); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_OPERATOR, 0x994500); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_IDENTIFIER, 0xAB0D9E); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_BRACE, 0x222222); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_WORD2, 0x91CDFF); - sendMessage(SCI_STYLESETFORE, SCE_ESCRIPT_WORD3, 0xC9E4FF); - - sendMessage(SCI_SETCARETLINEVISIBLE, true); - sendMessage(SCI_SETCARETLINEBACK, 0xb0ffff); - sendMessage(SCI_SETTABWIDTH, 4); - - sendMessage(SCI_SETMARGINTYPEN, 0, SC_MARGIN_NUMBER); - sendMessage(SCI_SETMARGINWIDTHN, 0, 20); -} - -void shelllet::scintilla::ScintillaApiWrapper::setUtf8Encode() -{ - sendMessage(SCI_SETCODEPAGE, SC_CP_UTF8); -} - -void shelllet::scintilla::ScintillaApiWrapper::disablePopup() -{ - sendMessage(SCI_USEPOPUP, SC_POPUP_NEVER); -} - -int shelllet::scintilla::ScintillaApiWrapper::get_current_pos() const -{ - return sendMessage(SCI_GETCURRENTPOS); -} - -int shelllet::scintilla::ScintillaApiWrapper::get_word_start_pos(int pos) const -{ - return sendMessage(SCI_WORDSTARTPOSITION, pos); -} - -int shelllet::scintilla::ScintillaApiWrapper::get_word_end_pos(int pos) const -{ - return sendMessage(SCI_WORDENDPOSITION, pos); -} - -bool shelllet::scintilla::ScintillaApiWrapper::isModified() const -{ - return sendMessage(SCI_GETMODIFY); -} - -void shelllet::scintilla::ScintillaApiWrapper::showAuto(const char* items, int lengthEntered) -{ - sendMessage(SCI_AUTOCSHOW, lengthEntered, (sptr_t)items); -} - -String shelllet::scintilla::ScintillaApiWrapper::getAutoCurrentText() -{ - int len = sendMessage(SCI_AUTOCGETCURRENTTEXT, 0, 0); - - std::vector text(len + 1); - - sendMessage(SCI_AUTOCGETCURRENTTEXT, 0, (sptr_t)text.data()); - - return text.data(); -} - -String shelllet::scintilla::ScintillaApiWrapper::get_text_range(int cpMin, int cpMax) const -{ - Sci_TextRange textRange; - // including the terminating 0 - std::vector text(cpMax - cpMin + 1); - textRange.chrg.cpMin = cpMin; - textRange.chrg.cpMax = cpMax; - textRange.lpstrText = text.data(); - - sendMessage(SCI_GETTEXTRANGE, 0, (sptr_t)&textRange); - //std::set delim = { ' \0','\t','\r','\n' }; - - boost::trim_if(text, boost::is_any_of("\r\n" + std::string("\0", 1))); - - if (text.empty()) { - return ""; - } - - return text; -} - -void shelllet::scintilla::ScintillaApiWrapper::formatText() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/scintilla2/src/scintilla_component.cpp b/QtRpa/modules/scintilla2/src/scintilla_component.cpp deleted file mode 100644 index 6dde9b5..0000000 --- a/QtRpa/modules/scintilla2/src/scintilla_component.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "creator.hpp" -#include -#include -#include "scintilla/scintilla_component.h" -#include - - -shelllet::scintilla::scintilla_component::scintilla_component(QWidget* parent) - : QWidget(parent) { - setLayout(new QVBoxLayout()); - layout()->addWidget(createWindowContainer(createEditor(this), this)); -} - -shelllet::scintilla::scintilla_component::~scintilla_component() -{ - destroyWndResource(); -} - -bool shelllet::scintilla::scintilla_component::nativeEvent(const QByteArray& eventType, void* message, long* result) -{ - if (eventType == "windows_generic_MSG") { - MSG* msg = static_cast(message); - - switch (msg->message) - { - case WM_NOTIFY: - LOG_INFO("rpa") << "# wm_notify"; - break; - default: - break; - } - } - - return false; -} \ No newline at end of file diff --git a/QtRpa/modules/scintilla2/src/scintilla_module_manager.cpp b/QtRpa/modules/scintilla2/src/scintilla_module_manager.cpp deleted file mode 100644 index fee6299..0000000 --- a/QtRpa/modules/scintilla2/src/scintilla_module_manager.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include -#include "scintilla/scintilla_module_manager.h" -#include -#include "qwidget.h" -extern "C" { - extern sptr_t Scintilla_DirectFunction(sptr_t sci, UINT iMessage, uptr_t wParam, sptr_t lParam); -} -namespace shelllet { - using namespace scintilla; - typedef sptr_t(*F)(sptr_t, unsigned int, uptr_t, sptr_t); - - //F Scintilla_DirectFunction; - - std::vector> ScintillaInOnePeer; -} - -shelllet::scintilla::ScintillaModuleManager::ScintillaModuleManager() -{ - libray.setFileName("SciLexer.dll"); - - //Scintilla_DirectFunction = reinterpret_cast(libray.resolve("Scintilla_DirectFunction")); -} - -shelllet::scintilla::ScintillaModuleManager::~ScintillaModuleManager() -{ - destroyWndResource(); -} -namespace shelllet { - LRESULT CALLBACK HookWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) - { - using namespace scintilla; - - auto iter = std::find_if(ScintillaInOnePeer.begin(), ScintillaInOnePeer.end(), [hwnd](const std::pair& p) - { - return hwnd == p.first; - }); - - BOOST_ASSERT(iter != ScintillaInOnePeer.end()); - - if (message == WM_COMMAND) { - WORD wNotification = HIWORD(wParam); - - if (wNotification == SCEN_CHANGE) - { - } - } - else if (message == WM_NOTIFY) { - SCNotification* notify = (SCNotification*)lParam; - - //(*iter).second->emit2(notify->nmhdr.code); - } - else if (message == WM_DESTROY) { - //LOG_SEV_TRACE << "# WM_DESTROY" << std::endl; - } - - // return CallWindowProc((*iter).second->getPeerWndProc(), hwnd, message, wParam, lParam); - return 0; - } - - LRESULT ScintillaProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - using namespace scintilla; - LONG_PTR lPtr = GetWindowLongPtr(hwnd, GWLP_USERDATA); - ScintillaModuleManager* scintilla = reinterpret_cast(lPtr); - - if (message == WM_ERASEBKGND) { - return TRUE; - } - else if (message == WM_CONTEXTMENU) { - //PopupMenu m; - // m.addItem(1, "format code"); - //const int result = m.show(); - //if (result == 1) - { - // user dismissed the menu without picking anything - //instance->getActionBroadcaster().sendActionMessage(FORMAT_CODE_ACTION_TEXT); - } - } - else if (message == WM_KEYDOWN || message == WM_SYSKEYDOWN) { - //if (KeyPress::isKeyCurrentlyDown('f') - // && ModifierKeys::getCurrentModifiersRealtime().testFlags(ModifierKeys::altModifier - // | ModifierKeys::shiftModifier)) { - // //instance->getActionBroadcaster().sendActionMessage(FORMAT_CODE_ACTION_TEXT); - //} - } - - else if (message == WM_SIZE) { - RedrawWindow(hwnd, - NULL, NULL, - RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_FRAME); - } - - // return CallWindowProc(scintilla->getWndProc(), hwnd, message, wParam, lParam); - } -} -QWindow* shelllet::scintilla::ScintillaModuleManager::createEditor(QWidget* parent) -{ - //if (!::IsWindow(wndProc_.first)) { - //LOG_SEV_ERROR << "the style `WS_CHILD` must have owner window" << std::endl; - // return NULL; - //} - WId wid = parent->winId(); - auto hwnd = CreateWindowExW(0, - L"Scintilla", L"", WS_CHILD | WS_TABSTOP | WS_CLIPCHILDREN, - 0, 0, - 1, 1, reinterpret_cast(wid), NULL, (NULL), NULL); - - int n = GetLastError(); - if (hwnd == NULL || !::IsWindow(hwnd)) { - LOG_WARNING("rpa") << std::system_error(n, std::system_category()).what(); - return nullptr; - } - - sci_ = ::SendMessage(hwnd, SCI_GETDIRECTPOINTER, 0, 0i64); - - SetLastError(0); - if (SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)this) == 0 && GetLastError() != 0) { - //boost::system::system_error err(GetLastError(), boost::system::detail::system_error_category()); - //qCCritical("rpa") << err.what(); - return nullptr; - } - //WNDPROC proc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC); - //SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)ScintillaProc); - //data_ = std::make_tuple(hwnd, proc, sci); - - return QWindow::fromWinId(WId(hwnd)); -} -// -//std::vector>::iterator shelllet::core::ScintillaModuleManager::find(uint32_t sci) -//{ -// return std::find_if(hWndDatas.begin(), hWndDatas.end(), [sci](const std::tuple& p) -// { -// return sci == reinterpret_cast(std::get<0>(p)); -// }); -//} - -//void shelllet::core::ScintillaModuleManager::removeEditor(HWND hWnd) -//{ - //std::remove_if(hWndDatas.begin(), hWndDatas.end(), [this, hWnd](const HwndData& p) - // { - // if (hWnd == p.hWnd) { - // - // return true; - // } - // return false; - // }); - - //destroyWndResource(&p); -//} - -void shelllet::scintilla::ScintillaModuleManager::hookWndProc(HWND hwnd) -{ - // if (!wndProc_.first) { - // wndProc_.first = hWnd; - - auto iter = std::find_if(ScintillaInOnePeer.begin(), ScintillaInOnePeer.end(), [this](const std::pair& p) - { - return this == p.second; - }); - - if (iter != ScintillaInOnePeer.end()) { - return; - } - - ScintillaInOnePeer.push_back(std::make_pair(hwnd, this)); - WNDPROC proc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC); - - if (HookWndProc != proc) { - // peerWndProc = std::make_pair(hwnd, proc); - SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)HookWndProc); - //SetWindowLongPtr(hwnd, DWLP_USER_PEER, (LONG_PTR)&ScintillaInOnePeer); - } - - // } -} - -void shelllet::scintilla::ScintillaModuleManager::destroyWndResource() -{ - // if (::IsWindow(peerWndProc.first)) { - // SetWindowLongPtr(peerWndProc.first, GWLP_WNDPROC, (LONG_PTR)peerWndProc.second); - //} - - //if (::IsWindow(getHwnd())) { - // DestroyWindow(getHwnd()); - // } - static_cast(std::remove_if(ScintillaInOnePeer.begin(), ScintillaInOnePeer.end(), [this](const std::pair& p) { - return this == p.second; - })); -} - -intptr_t shelllet::scintilla::ScintillaModuleManager::sendMessage(unsigned int message, uintptr_t wParam /*= 0*/, intptr_t lParam /*= 0*/) const -{ - if (sci_) - return Scintilla_DirectFunction(sci_, message, wParam, lParam); - - throw std::runtime_error("error@ scintilla"); -} \ No newline at end of file diff --git a/QtRpa/modules/wizard/CMakeLists.txt b/QtRpa/modules/wizard/CMakeLists.txt deleted file mode 100644 index 60472d7..0000000 --- a/QtRpa/modules/wizard/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(wizard) - -set(CMAKE_AUTOMOC ON) - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/${PROJECT_NAME}/*.h) - -add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(Qt5Widgets CONFIG REQUIRED) - - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} -) - -add_definitions(-DBOOST_ALL_DYN_LINK) -add_definitions(-DASSETS_CURRENT_DIR="${CMAKE_SOURCE_DIR}/assets") diff --git a/QtRpa/modules/wizard/src/createpage.cpp b/QtRpa/modules/wizard/src/createpage.cpp deleted file mode 100644 index c883072..0000000 --- a/QtRpa/modules/wizard/src/createpage.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -#include -#include -#include "wizard/createpage.h" -#include "wizard/framework.h" - - -shelllet::wizard::CreatePage::CreatePage(QWidget* parent) - : QWizardPage(parent) -{ - auto* vLayout = new QVBoxLayout; - - vLayout->addWidget(new QLabel(tr("Project Name"))); - - lineEdit_ = new QLineEdit(this); - vLayout->addWidget(lineEdit_); - - vLayout->addWidget(new QLabel(tr("Location"))); - - auto* layout = new QFormLayout; - comboBox_ = new QComboBox(this); - QPushButton* button = new QPushButton(this); - - layout->addRow(comboBox_, button); - - vLayout->addLayout(layout); - - setLayout(vLayout); -} - -shelllet::wizard::CreatePage::~CreatePage() -{ -} diff --git a/QtRpa/modules/wizard/src/gitpage.cpp b/QtRpa/modules/wizard/src/gitpage.cpp deleted file mode 100644 index e6d0c80..0000000 --- a/QtRpa/modules/wizard/src/gitpage.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include -#include -#include -#include -#include -#include "wizard/gitpage.h" -#include "wizard/framework.h" - - -shelllet::wizard::GitPage::GitPage(QWidget* parent) - : QWizardPage(parent) -{ - auto* vLayout = new QVBoxLayout; - - vLayout->addWidget(new QLabel(tr("Project Name"))); - - lineEdit_ = new QLineEdit(this); - vLayout->addWidget(lineEdit_); - - vLayout->addWidget(new QLabel(tr("Location"))); - - auto* layout = new QFormLayout; - comboBox_ = new QComboBox(this); - QPushButton* button = new QPushButton(this); - - layout->addRow(comboBox_, button); - - vLayout->addLayout(layout); - - setLayout(vLayout); -} - -shelllet::wizard::GitPage::~GitPage() -{ -} - diff --git a/QtRpa/modules/wizard/src/recent_component.cpp b/QtRpa/modules/wizard/src/recent_component.cpp deleted file mode 100644 index 9d63635..0000000 --- a/QtRpa/modules/wizard/src/recent_component.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "wizard/recent_component.h" -#include "wizard/framework.h" -#include "private/qwidget_p.h" -#include "qpushbutton.h" -#include "qdebug.h" -namespace shelllet { - namespace wizard { - class Ui_RencentComponent { - public: - QLabel* label; - QListView* listView; - QVBoxLayout* layout; - QPushButton *button; - void setupUi(QWidget* parent) { - layout = new QVBoxLayout(parent); - - label = new QLabel(parent); - label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - layout->addWidget(label); - - listView = new QListView(parent); - listView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - layout->addWidget(listView); - - button = new QPushButton(parent); - - layout->addWidget(button); - - QObject::connect(button, &QPushButton::clicked, [this]() { - qDebug() << listView->minimumHeight(); - qDebug() << listView->sizeHint(); - qDebug() << listView->geometry(); - }); - } - }; - class RencentComponentPrivate : public QWidgetPrivate { - public: - Ui_RencentComponent ui; - }; - } -} -shelllet::wizard::RencentComponent::RencentComponent( QWidget* parent) - : QWidget(*new RencentComponentPrivate, parent, {}) -{ - Q_D(RencentComponent); - - d->ui.setupUi(this); - - d->ui.label->setText(tr("Open Recent")); -} - -shelllet::wizard::RencentComponent::~RencentComponent() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/wizard/src/splash_content.cpp b/QtRpa/modules/wizard/src/splash_content.cpp deleted file mode 100644 index 3fc8d83..0000000 --- a/QtRpa/modules/wizard/src/splash_content.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "wizard/splash_content.h" -#include "wizard/splash_guide.h" - - -shelllet::wizard::SplashContentComponent::SplashContentComponent(ResponseHandler* response, QWidget* parent) - : QWidget(parent) -{ - recent = new RencentComponent(this); - start = new StartedComponent(response, this); - - - auto* h = new QHBoxLayout(this); - h->addWidget(recent); - h->addWidget(start); - -} - -shelllet::wizard::SplashContentComponent::~SplashContentComponent() -{ -} \ No newline at end of file diff --git a/QtRpa/modules/wizard/src/splash_guide.cpp b/QtRpa/modules/wizard/src/splash_guide.cpp deleted file mode 100644 index 419e893..0000000 --- a/QtRpa/modules/wizard/src/splash_guide.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include "wizard/splash_guide.h" -#include "wizard/splash_content.h" -#include "wizard/framework.h" -shelllet::wizard::SplashGuide::SplashGuide(ResponseHandler* response, QWidget* parent) - : QWidget(parent) -{ - auto* layout = new QVBoxLayout(this); - content = new SplashContentComponent(response,this); - layout->addWidget(content); -} - -shelllet::wizard::SplashGuide::~SplashGuide() -{ -} diff --git a/QtRpa/modules/wizard/src/started_component.cpp b/QtRpa/modules/wizard/src/started_component.cpp deleted file mode 100644 index 041c3ad..0000000 --- a/QtRpa/modules/wizard/src/started_component.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include -#include -#include "wizard/started_component.h" -#include "events.hpp" -#include "private/qwidget_p.h" -namespace shelllet { - namespace wizard { - class Ui_StartedComponent { - public: - QLabel* title; - - QCommandLinkButton* git; - QCommandLinkButton* open; - QCommandLinkButton* create; - QVBoxLayout* layout; - void setupUi(StartedComponent* parent) { - git = new QCommandLinkButton(parent); - open = new QCommandLinkButton(parent); - create = new QCommandLinkButton(parent); - title = new QLabel(parent); - - - layout = new QVBoxLayout(parent); - - title->setText(QObject::tr("Start")); - - layout->addWidget(title); - - git->setText("Clone or checkout Code"); - layout->addWidget(git); - - open->setText("Open project file"); - layout->addWidget(open); - - create->setText("Create new project file"); - layout->addWidget(create); - } - }; - class StartedComponentPrivate : public QWidgetPrivate { - public: - Ui_StartedComponent ui; - - ResponseHandler* response; - }; - } -} - -shelllet::wizard::StartedComponent::StartedComponent(ResponseHandler* response, QWidget* parent) - : QWidget(*new StartedComponentPrivate, parent, {}) - -{ - Q_D(StartedComponent); - d->response = response; - d->ui.setupUi(this); - connect(d->ui.create, &QPushButton::clicked, this, &StartedComponent::buttonClicked); - connect(d->ui.git, &QPushButton::clicked, this, &StartedComponent::buttonClicked); - connect(d->ui.open, &QPushButton::clicked, this, &StartedComponent::buttonClicked); -} - -shelllet::wizard::StartedComponent::~StartedComponent() -{ -} - -void shelllet::wizard::StartedComponent::buttonClicked() -{ - Q_D(StartedComponent); - QCommandLinkButton* button = dynamic_cast(sender()); - - if (button == d->ui.create) { - //QCoreApplication::postEvent(EventDispatcher::Dispatcher(), new CreateSelectEvent); - d->response->finshed(ResponseHandler::Exit::Create); - } - else if (button == d->ui.git) { - //QCoreApplication::postEvent(EventDispatcher::Dispatcher(), new GitCloneEvent); - d->response->finshed(ResponseHandler::Exit::FromGit); - } - else if (button == d->ui.open) { - //QCoreApplication::postEvent(EventDispatcher::Dispatcher(), new OpenSelectEvent); - //QCoreApplication::postEvent(this, new CloseEvent(3)); - d->response->finshed(ResponseHandler::Exit::Open); - } - - -} - diff --git a/QtRpa/modules/wizard/src/wizardpage.cpp b/QtRpa/modules/wizard/src/wizardpage.cpp deleted file mode 100644 index 4a20ed0..0000000 --- a/QtRpa/modules/wizard/src/wizardpage.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "qcoreapplication.h" -#include "qcoreapplication.h" -#include "qboxlayout.h" -#include "wizard/wizardpage.h" -#include "private/qwidget_p.h" -#include "common/private/object_p.h" -namespace shelllet { - namespace wizard { - class WizardPagePrivate : public ObjectPrivate { - public: - QStackedWidget* stackedWidget_; - - }; - IMPLEMENT_PRIVATE_CLASS(WizardPage) - } -} -shelllet::wizard::WizardPage::WizardPage(QWidget* parent) - : QWizardPage(parent) -{ - Q_D(WizardPage); - setLayout(new QVBoxLayout); - d->stackedWidget_ = new QStackedWidget(this); - - //d->stackedWidget_->addWidget(new GitPage); - layout()->addWidget(d->stackedWidget_); -} - -shelllet::wizard::WizardPage::~WizardPage() -{ - FREE_PRIVATE_OBJECT -} - diff --git a/QtRpa/modules/wizard/src/wizardwidget.cpp b/QtRpa/modules/wizard/src/wizardwidget.cpp deleted file mode 100644 index e7ed17c..0000000 --- a/QtRpa/modules/wizard/src/wizardwidget.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "wizard/framework.h" -#include "wizard/wizardwidget.h" -#include "wizard/splash_guide.h" -#include "frameless.hpp" -#include "qapplication.h" -#include "qscreen.h" -#include "qstyle.h" -#include "qdesktopwidget.h" -#include "private/qobject_p.h" -#include "events.hpp" -namespace shelllet { - namespace wizard { - class WizardWidgetPrivate : public QObjectPrivate { - public: - //std::unique_ptr framelessWindow; - }; - } -} - -shelllet::wizard::WizardWidget::WizardWidget(ResponseHandler* handler, QWidget* parent /*= nullptr*/) - : MainWindow(parent, WindowType::CloseButtonHint) -{ - //Q_D(WizardWidget); - setWindowTitle("Visual Studio 2020"); - setCentralWidget(new SplashGuide(handler)); - setWindowModality(Qt::ApplicationModal); - - setFixedSize(QApplication::primaryScreen()->availableSize() * 0.5); -} - - - - diff --git a/QtRpa/msi/favicon.ico b/QtRpa/msi/favicon.ico deleted file mode 100644 index f63aec7..0000000 Binary files a/QtRpa/msi/favicon.ico and /dev/null differ diff --git a/QtRpa/msi/favicon.png b/QtRpa/msi/favicon.png deleted file mode 100644 index 6eec87d..0000000 Binary files a/QtRpa/msi/favicon.png and /dev/null differ diff --git a/QtRpa/msi/setup.nsi b/QtRpa/msi/setup.nsi deleted file mode 100644 index d072f7c..0000000 --- a/QtRpa/msi/setup.nsi +++ /dev/null @@ -1,170 +0,0 @@ -;Include Modern UI - - !include "MUI2.nsh" - !include "x64.nsh" - - Unicode true - -;General - !define VERSION "0.2.0" - !define PRODUCT_NAME "shelllet ${VERSION}" - !define APPNAME "shelllet" - !define MUI_FOLDER "shelllet.com" - !define COMPANYNAME "shelllet.com" - !define HELPURL "http://shelllet.com" - !define MUI_FINISHPAGE_NOAUTOCLOSE - !define MUI_FINISHPAGE_RUN "$INSTDIR\${APPNAME}.exe" - !define MUI_FINISHPAGE_RUN_CHECKED - !define MUI_FINISHPAGE_RUN_TEXT "${PRODUCT_NAME}" - !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" - - - Name "${PRODUCT_NAME}" - # Icon "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico" - # UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico" - - OutFile "..\wiki\content\history\_index.files\${APPNAME}-${VERSION}-setup.x64.exe" - - ;Default installation folder - InstallDir "$PROGRAMFILES64\${MUI_FOLDER}" - - ;Request application privileges for Windows Vista - RequestExecutionLevel admin - -;-------------------------------- -;Variables - - Var StartMenuFolder - -;-------------------------------- -;Interface Configuration - !define MUI_ICON "..\favicon.ico" - !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico" - !define MUI_HEADERIMAGE - !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis3-branding.bmp" - !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\nsis3-branding.bmp" - !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\nsis3-branding.bmp" - !define MUI_ABORTWARNING - -;Pages - - !insertmacro MUI_PAGE_COMPONENTS - !insertmacro MUI_PAGE_DIRECTORY - - ;Start Menu Folder Page Configuration - !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" - !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${MUI_FOLDER}" - !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${MUI_FOLDER}" - - !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder - - !insertmacro MUI_PAGE_INSTFILES - !insertmacro MUI_PAGE_FINISH - - !insertmacro MUI_UNPAGE_COMPONENTS - !insertmacro MUI_UNPAGE_WELCOME - !insertmacro MUI_UNPAGE_CONFIRM - - !insertmacro MUI_UNPAGE_INSTFILES - !insertmacro MUI_UNPAGE_FINISH -;-------------------------------- -;Languages - - !insertmacro MUI_LANGUAGE "SimpChinese" - -;-------------------------------- -;Installer Sections - -Section "װļ" MAIN_FILES - - SetOutPath "$INSTDIR\assets" - FILE ..\x64\Release\assets\*.* - - SetOutPath "$INSTDIR\libs" - FILE ..\x64\Release\libs\*.* - - SetOutPath "$INSTDIR\setting" - FILE ..\x64\Release\setting\*.* - - SetOutPath "$INSTDIR\languages" - FILE ..\x64\Release\languages\*.* - - SetOutPath "$INSTDIR" - File /r ..\x64\Release\*.dll - File ..\x64\Release\*.exe - File ..\x64\Release\*.bin - File ..\x64\Release\icudtl.dat - - ;create desktop shortcut - CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${APPNAME}.exe" "" - - !insertmacro MUI_STARTMENU_WRITE_BEGIN Application - - ;create start-menu items - CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" - CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0 - CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${APPNAME}.exe" "" "$INSTDIR\${APPNAME}.exe" 0 - - !insertmacro MUI_STARTMENU_WRITE_END - - ;Store installation folder - WriteRegStr HKCU "Software\${PRODUCT_NAME}" "" $INSTDIR - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${PRODUCT_NAME}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\${APPNAME}.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "$\"${COMPANYNAME}$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\"" - - ;Create uninstaller - WriteUninstaller "$INSTDIR\Uninstall.exe" - -SectionEnd - - - ;Language strings - ;LangString DESC_SecFiles ${LANG_ENGLISH} "basic component" - LangString DESC_MAIN_SECFILES ${LANG_SIMPCHINESE} "" - - ;Assign language strings to sections - !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${MAIN_FILES} $(DESC_MAIN_SECFILES) - !insertmacro MUI_FUNCTION_DESCRIPTION_END - - - -;Uninstaller Section -Section Un. - - ;ADD YOUR OWN FILES HERE... - - Delete "$INSTDIR\Uninstall.exe" - - RMDir /r "$INSTDIR" - - !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder - - Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" - Delete "$DESKTOP\${PRODUCT_NAME}.lnk" - RMDir "$SMPROGRAMS\$StartMenuFolder" - - DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" -SectionEnd - -Section Un.ű - - SetShellVarContext current - - RMDir /r "$PROGRAMFILES64\scripts" - -SectionEnd - -Function LaunchLink - ExecShell "" "$INSTDIR\${APPNAME}.exe" -FunctionEnd - -ShowInstDetails show - -ShowUnInstDetails show \ No newline at end of file diff --git a/QtRpa/scripts/LICENSE b/QtRpa/scripts/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/QtRpa/scripts/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/QtRpa/scripts/README.md b/QtRpa/scripts/README.md deleted file mode 100644 index 7b65fbc..0000000 --- a/QtRpa/scripts/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# wrapqt -wrap qt class diff --git a/QtRpa/scripts/decode.js b/QtRpa/scripts/decode.js deleted file mode 100644 index 18e38b3..0000000 --- a/QtRpa/scripts/decode.js +++ /dev/null @@ -1,306 +0,0 @@ -function propExpression(type, name) { - let exp1, exp2; - switch (type) { - case "bool": - exp1 = `info.GetReturnValue().Set(p->d_func()->${name}());`; - exp2 = `p->d_func()->${name}(value->BooleanValue(context).FromJust());`; - break; - case "int": - exp1 = `info.GetReturnValue().Set(p->d_func()->${name}());`; - exp2 = `p->d_func()->${name}(value->Int32Value(context).FromJust());`; - break; - case "uint": - case "quint16": - exp1 = `info.GetReturnValue().Set(v8::Uint32::New(isolate, self->d_func()->${name}}()));` - exp2 = `p->d_func()->${name}(value->Uint32Value(context).FromJust());`; - break; - case "QString": - exp1 = `info.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, self->d_func()->${name}().toUtf8().constData()));` - exp2 = `p->d_func()->${name}(value->Uint32Value(context).FromJust());`; - break; - default: - } - return { exp1, exp2 } -} - -function wrapArgs(element, name) { - let argGroup = element.match(/\((.+)\)/); - let args = ""; - if (argGroup) { - args = argGroup[1]; - } - let wrapArgs = []; - args.split(", ").forEach(element => { - let types = element.match(/(.+?) /); - if (!types) - return; - let exp1 = ""; - switch (types[1]) { - case "bool": - exp1 = `v8::Boolean::New(isolate, ${name})` - break; - case "int": - exp1 = `v8::Int32::New(isolate, ${name});` - break; - case "uint": - case "quint16": - exp1 = `v8::UInt32::New(isolate, ${name})` - break; - case "QString": - exp1 = `V8_NEW_STRING_VAR(isolate, self->d_func()->${name}().toUtf8().constData())` - break; - default: - } - wrapArgs.push(exp1); - }); - - return wrapArgs.join(","); -} - -function returnExpression(type, name) { - let exp1; - switch (type) { - case "bool": - exp1 = `args.GetReturnValue().Set(self->d_func()->${name}());` - break; - case "int": - exp1 = `args.GetReturnValue().Set(v8::Int32::New(isolate, self->d_func()->${name}()));` - break; - case "uint": - case "quint16": - exp1 = `args.GetReturnValue().Set(v8::Uint32::New(isolate, self->d_func()->${name}()));` - break; - case "QString": - exp1 = `args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, self->d_func()->${name}()->toUtf8()->constData()));` - break; - default: - } - return exp1; -} - -export function declareFuncs(tpl, text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - results.push(`${tpl}->Set(isolate, "${nameGroups[1]}", v8::FunctionTemplate::New(isolate, ${toUpperCase(nameGroups[1], 0)}));`) - } - }); - - return results.join("\n"); -} - -export function implFuncs(text, className) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - let types = element.match(/(.+?) /); - let exp1 = returnExpression(types[1], nameGroups[1]); - - let text = `static void ${toUpperCase(nameGroups[1], 0)}(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap<${className}Wrapper>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - ${exp1} - } - V8_CREATE_LOCAL_CONTEXT_END - } - `; - results.push(text); - } - }); - - return results.join("\n"); -} - -export function declareEnums(className, text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let enumNames = element.match(/\s+(\w+)\s+\{/); // match name - let fixedName = ""; - if (!enumNames) { - return; - } - - fixedName = toLowerCase(enumNames[1], 0); - - let exp1 = `auto ${fixedName} = v8::FunctionTemplate::New(isolate);`; - results.push(exp1); - let values = element.match(/{(.+)}/); - values.split(",").trim().forEach(element => { - let exp2 = `${fixedName}->Set(isolate, "${element}", v8::Int32::New(isolate, ${className}::${element}));`; - results.push(exp2); - }); - - let exp3 = `tpl->Set(isolate, "${enumNames[1]}", ${fixedName});`; - - results.push(exp3); - }); - - return results.join("\n"); -} - - -export function declareProps(text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let groups = element.split(":"); - if (groups) { - let name = groups[0].trim(); - let fixedName = toUpperCase(name, 0); - results.push(`proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "${name}"), Get${fixedName}, Set${fixedName});`) - } - }); - - return results.join("\n"); -} - -export function implProps(text, className) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let groups = element.split(":"); - if (groups) { - let name = groups[0].trim(); - let fixedName = toUpperCase(name, 0); - let type = groups[1]?.trim(); - let exp = propExpression(type, name); - - let text = `static void Get${fixedName}(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap<${className}Wrapper>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - ${exp.exp1} - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Set${fixedName}(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap<${className}Wrapper>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - ${exp.exp2} - } - V8_CREATE_LOCAL_CONTEXT_END - } - `; - results.push(text); - } - }); - - return results.join("\n"); -} - -export function declareSignals(text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - let exp1 = `proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "${nameGroups[1]}"), nullptr, ${toUpperCase(nameGroups[1], 0)});`; - results.push(exp1); - } - }); - - return results.join("\n"); -} - -export function implSignals(text, className) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - let name = nameGroups[1]; - let fixedName = toUpperCase(nameGroups[1], 0); - let argGroup = element.match(/\((.+)\)/); - let args = ""; - if (argGroup) { - args = argGroup[1]; - } - let vargs = wrapArgs(element); - - let text = `static void ${fixedName}(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap<${className}Wrapper>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - std::shared_ptr>weakPersistent = std::make_shared>(isolate, v8::Local::Cast(value)); - QObject::connect(*self, &${className}::${name}, [isolate, weakPersistent](${args}) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { ${vargs} }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(*self, &${className}::${name}, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - `; - results.push(text); - } - }); - - return results.join("\n"); -} - - -export function virtuals(text, parentClassName) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (!nameGroups) { - return; - } - let vargs = wrapArgs(element); - let name = nameGroups[1]; - let text = `${element} - { - if (q_func()->hasOwnProperty(strrchr(__FUNCTION__, ':') + 1)) { - v8::Local argv[] = { ${vargs} }; - v8::Local value = call(__FUNCTION__, std::size(argv), argv); - return value->BooleanValue(v8::Isolate::GetCurrent()); - } - if constexpr (std::is_abstract::value) - throw std::logic_error("The method or operation is not implemented."); - else { - return T::${name}(); - } - }`; - - results.push(text); - }); - - return results.join("\n"); -} diff --git a/QtRpa/scripts/export.py b/QtRpa/scripts/export.py deleted file mode 100644 index 7a61170..0000000 --- a/QtRpa/scripts/export.py +++ /dev/null @@ -1,14 +0,0 @@ -import vcpkgs -import subprocess - -sep = " " - -print(f'vcpkg export {sep.join(vcpkgs.pkgs)} --zip') - -stream = subprocess.Popen( - f'vcpkg export {sep.join(vcpkgs.pkgs)} --zip', stdout=subprocess.PIPE, stderr=subprocess.PIPE) -out, err = stream.communicate() -if err: - print(err.decode("utf-8")) -else: - print(out.decode("utf-8")) diff --git a/QtRpa/scripts/implement.js b/QtRpa/scripts/implement.js deleted file mode 100644 index b83886c..0000000 --- a/QtRpa/scripts/implement.js +++ /dev/null @@ -1,50 +0,0 @@ -import * as dec from "./decode.js" - -export function create(data, filename){ - var declares = dec.declareFuncs("tpl", data.static); - var bodies = dec.implFuncs(data.static, data.className); - - var code = `#pragma once -#include "framework.h" -#include <${data.className.toLowerCase()}.h> -#include "${data.className.toLowerCase().replace("_", "")}_p.h" -#include "${data.className.toLowerCase().replace("_", "")}_wrapper.h" - -namespace shelllet { - namespace ${data.namespace} { - class ${data.name} : public ${data.className}Wrapper<${data.className}, ${data.name}, ${data.canNew}> - { - using ReturnType = ${data.className}Private<${data.className}, true>; - using ReturnType2 = ${data.className}Private<${data.className}, false>; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - ${data.name}(const v8::FunctionCallbackInfo& args) :${data.className}Wrapper(*Param(args), args) - { - } - ${data.name}(${data.className}* p, const v8::FunctionCallbackInfo& args) :${data.className}Wrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ${data.name}(v8::Isolate* isolate, const v8::Local& tpl) : ${data.className}Wrapper(isolate, tpl) - { - ${declares} - } - - ${data.name}(v8::Isolate* isolate, const v8::Local& proto) : ${data.className}Wrapper(isolate, proto) - { - ${declares} - } - - protected: - void toString(std::stringstream& ss) const {} - public: - static const char* Name() { return "${data.name}"; } - protected: - ${bodies} - }; - } -} -` - writeFile(filename, code); -} diff --git a/QtRpa/scripts/install.py b/QtRpa/scripts/install.py deleted file mode 100644 index 9a12a8a..0000000 --- a/QtRpa/scripts/install.py +++ /dev/null @@ -1,13 +0,0 @@ -import vcpkgs -import subprocess - - -for pkg in vcpkgs.pkgs: - print(f"prepare to install {pkg} ......") - stream = subprocess.Popen( - f'vcpkg install {pkg}', stdout=subprocess.PIPE, stderr=subprocess.PIPE) - out, err = stream.communicate() - if err: - print(err.decode("utf-8")) - else: - print(out.decode("utf-8")) diff --git a/QtRpa/scripts/main.js b/QtRpa/scripts/main.js deleted file mode 100644 index fcc54c1..0000000 --- a/QtRpa/scripts/main.js +++ /dev/null @@ -1,37 +0,0 @@ -import * as impl from "./implement.js" -import * as wrp from "./wrapper.js" -import * as pri from "./private.js" - -var data = { - name: "Dir", - className: "QDir", - namespace: "core", - parent: "Object", - parentNamespace: "", - canNew: true, - public: ` - - `, - virtual: ` - `, - - static: ` - - - `, - signals: ` - - - `, - propeties: ` - - `, - enums: ` - Filter { Dirs, AllDirs, Files, Drives, NoSymLinks, NoDotAndDotDot, NoDot, NoDotDot, AllEntries, Readable, Writable, Executable, Modified, Hidden,System,CaseSensitive } - ` -} - - -impl.create(data, data.className.toLowerCase().replace("_", "") + `_implement.h`); -pri.create(data, data.className.toLowerCase().replace("_", "") + `_p.h`); -wrp.create(data, data.className.toLowerCase().replace("_", "") + `_wrapper.h`); diff --git a/QtRpa/scripts/mk_hpp.py b/QtRpa/scripts/mk_hpp.py deleted file mode 100644 index 43824c9..0000000 --- a/QtRpa/scripts/mk_hpp.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys -import os - -ns = sys.argv[1] -module_name = sys.argv[2] -class_name = sys.argv[3] - -print("namespace is: " + ns) -print("module is: " + module_name) -print("class is: " + class_name) - - -# hpp -try: - fhpp = open("./include/" + module_name + "/" + - class_name.lower() + ".h", "x") - - content = f'''#pragma once -namespace {ns} {{ - namespace {module_name}{{ - class {class_name} {{ - public: - {class_name}(Object*parent = nullptr); - protected: - }}; - }} -}} - ''' - fhpp.write(content) - fhpp.close() -except OSError as err: - print(err) diff --git a/QtRpa/scripts/mkclass.py b/QtRpa/scripts/mkclass.py deleted file mode 100644 index ac30f3d..0000000 --- a/QtRpa/scripts/mkclass.py +++ /dev/null @@ -1,96 +0,0 @@ -import sys -import os - -ns = sys.argv[1] -module_name = sys.argv[2] -class_name = sys.argv[3] - -print("namespace is: " + ns) -print("module is: " + module_name) -print("class is: " + class_name) - - -# cpp -try: - fcpp = open("./modules/" + module_name + "/src/" + - class_name.lower() + ".cpp", "x") - - content = f'''#include "{module_name + "/" +class_name.lower() + ".h"}"''' - content += "\n" - content += f'''#include "{module_name + "/private/" +class_name.lower() + "_p.h"}"''' - content += "\n" - content += f''' -namespace {ns}{{ - namespace {module_name}{{ - - }} -}} -using namespace {ns}::{module_name}; -{class_name}::{class_name}(Object* parent /*= nullptr*/) - :{class_name}(*new {class_name}Private, parent) -{{ - -}} -{class_name}::{class_name}({class_name}Private& d, Object* parent /*= nullptr*/) - : Object(d, parent) -{{ - -}} -''' - fcpp.write(content) - - fcpp.close() -except OSError as err: - print(err) - -# hpp -try: - fhpp = open("./include/" + module_name + "/" + - class_name.lower() + ".h", "x") - - content = f'''#pragma once -#include "common.hpp" -namespace {ns} {{ - namespace {module_name}{{ - class {class_name}Private; - class {class_name} : public Object {{ - Q_DECLARE_PRIVATE({class_name}) - public: - {class_name}(Object*parent = nullptr); - protected: - {class_name}({class_name}Private& d, Object*parent = nullptr); - }}; - }} -}} - ''' - fhpp.write(content) - fhpp.close() -except OSError as err: - print(err) - - -try: - os.mkdir("./include/" + module_name + "/private") -except OSError as err: - print(err) - -# private -try: - fprivate = open("./include/" + module_name + "/private/" + - class_name.lower() + "_p.h", "x") - - content = f'''#pragma once -namespace {ns} {{ - namespace {module_name}{{ - class {class_name}Private : public ObjectPrivate {{ - Q_DECLARE_PUBLIC({class_name}) - public: - }}; - }} -}} -''' - - fprivate.write(content) - fprivate.close() -except OSError as err: - print(err) diff --git a/QtRpa/scripts/module.py b/QtRpa/scripts/module.py deleted file mode 100644 index 1db6dd4..0000000 --- a/QtRpa/scripts/module.py +++ /dev/null @@ -1,74 +0,0 @@ -import sys -import os - -ns = sys.argv[1] -module_name = sys.argv[2] - -try: - os.mkdir("./include/" + module_name) -except OSError as err: - print(err) - -# hpp -try: - fhpp = open("./include/" + module_name + ".hpp", "x") - - content = f'''#pragma once -#include "common/framework.h" - - -using namespace {ns}::{module_name}; - ''' - fhpp.write(content) - fhpp.close() - -except OSError as err: - print(err) - - -try: - os.mkdir("./modules/" + module_name) -except OSError as err: - print(err) - -try: - os.mkdir("./modules/" + module_name + "/src") -except OSError as err: - print(err) - - -# cmake -try: - fcmake = open("./modules/" + module_name + "/CMakeLists.txt", "x") - - content = f'''# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project({module_name}) - -set(CMAKE_AUTOMOC ON) - -aux_source_directory(${{CMAKE_CURRENT_SOURCE_DIR}}/src SOURCES) -file(GLOB HEADERS ${{CMAKE_SOURCE_DIR}}/include/${{PROJECT_NAME}}/*.h) - -add_library(${{PROJECT_NAME}} STATIC ${{SOURCES}} ${{HEADERS}}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(Qt5Gui CONFIG REQUIRED) - -target_include_directories(${{PROJECT_NAME}} PRIVATE - ${{CMAKE_SOURCE_DIR}}/include - ${{Boost_INCLUDE_DIRS}} - ${{Qt5Gui_INCLUDE_DIRS}} - ${{Qt5Gui_PRIVATE_INCLUDE_DIRS}} -) - ''' - - fcmake.write(content) - - fcmake.close() -except OSError as err: - print(err) diff --git a/QtRpa/scripts/private.js b/QtRpa/scripts/private.js deleted file mode 100644 index 626f12b..0000000 --- a/QtRpa/scripts/private.js +++ /dev/null @@ -1,20 +0,0 @@ - -export function create(data, filename){ - var code = `#pragma once -namespace shelllet { - namespace ${data.namespace} { - template - class ${data.className}Private : public ${data.parent}Private - { - public: - template - ${data.className}Private(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ${data.parent}Private(isolate, obj, std::forward(args)...) { - } - - }; - } -} -`; - writeFile(filename, code); - -} diff --git a/QtRpa/scripts/vcpkgs.py b/QtRpa/scripts/vcpkgs.py deleted file mode 100644 index a9423ce..0000000 --- a/QtRpa/scripts/vcpkgs.py +++ /dev/null @@ -1,16 +0,0 @@ -import re -import sys -import os - -readme = open("./README.md", "r", encoding='UTF-8') - -data = readme.read() -readme.close() - -pkgs = [] -p = re.compile("vcpkg install (.+:.+)$", re.MULTILINE) - -for m in re.finditer(p, data): - pkgs.append(m.group(1)) - - diff --git a/QtRpa/scripts/wrapper.js b/QtRpa/scripts/wrapper.js deleted file mode 100644 index b264fa2..0000000 --- a/QtRpa/scripts/wrapper.js +++ /dev/null @@ -1,46 +0,0 @@ -import * as dec from "./decode.js" - - -export function create(data, filename) { - var normal = dec.declareFuncs("proto", data.public); - var normalBodies = dec.implFuncs(data.public, data.className); - - var signals = dec.declareSignals(data.signals); - var sginalBodies = dec.implSignals(data.signals, data.className); - - var props = dec.declareProps(data.propeties); - var propsBodies = dec.implProps(data.propeties, data.className); - - var code = `#pragma once -namespace shelllet { - namespace ${data.namespace} { - template - class ${data.className}Wrapper : public ${data.parent}Wrapper - { - public: - template - ${data.className}Wrapper(${data.className}Private& d, const v8::FunctionCallbackInfo& args) - : ${data.parent}Wrapper(d, args) { - } - ${data.className}Wrapper(v8::Isolate* isolate, const v8::Local& tpl) : ${data.parent}Wrapper(isolate, tpl) - { - } - - - ${data.className}Wrapper(v8::Isolate* isolate, const v8::Local& proto) : ${data.parent}Wrapper(isolate, proto) - { - ${props} - ${normal} - ${signals} - } - - protected: - ${propsBodies} - ${normalBodies} - ${sginalBodies} - }; - } -}`; - writeFile(filename, code); - -} diff --git a/QtRpa/test.py b/QtRpa/test.py deleted file mode 100644 index f90aa7f..0000000 --- a/QtRpa/test.py +++ /dev/null @@ -1,16 +0,0 @@ -class Base: - def ss(self): - return 0 - -class __Base(Base): - def ss(self): - return 10 - - - - - - -b = __Base() - -print(b.ss()) \ No newline at end of file diff --git a/QtStarter/.gitignore b/QtStarter/.gitignore deleted file mode 100644 index 36c7898..0000000 --- a/QtStarter/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# compiled output -/dist -/tmp -/out-tsc - -# visual studio 2017 - -# dir -.vs/ -.vscode/ -.cipd/ -.idea/ -x64/ -Debug/ -Release/ -bin/ - -# golang -pkg/ -#src/modules/**/*.h - -# System Files -.DS_Store -Thumbs.db -*.ttf -*.aps -*.vcxproj.user -*.mm -*.txt -*.dll -*.exe -*.rst -*.user -Makefile -test.c -duk_source_meta.json -package-lock.json -.qmake.stash - - -/GeneratedFiles diff --git a/QtStarter/README.md b/QtStarter/README.md deleted file mode 100644 index d02b2e1..0000000 --- a/QtStarter/README.md +++ /dev/null @@ -1,98 +0,0 @@ - -# debug renderer process -1. __debugbreak(); -2. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug set Auto(REG_SZ) = 1 - - - -# wiki - - git submodule add https://github.com/matcornic/hugo-theme-learn.git wiki/themes/hugo-theme-learn - - git submodule init - - git submodule update --recursive --remote - - cp -rv themes/hugo-theme-learn/exampleSite/. . - - - -# .gitconfig - - git config --global core.autocrlf input - git config --global core.safecrlf false - -# submodule - git submodule init - - git submodule update --recursive --remote --no-fetch --depth=1 - - -# boost - - git submodule add https://github.com/boostorg/boost.git src/boost - - git submodule update src/boost --recursive --remote --depth=1 - - .\bootstrap.bat - - .\b2 --with-program_options --with-coroutine --with-context --with-thread --with-filesystem --with-serialization --with-log --with-random --with-locale link=shared threading=multi address-model=64 runtime-link=shared - -# juce - git submodule add https://github.com/WeAreROLI/JUCE.git src/JUCE - - git submodule update src/JUCE --recursive --remote - -# inih - git submodule add https://github.com/benhoyt/inih.git src/inih - - -# opencv - - git submodule add https://github.com/opencv/opencv.git src/opencv - - git submodule update src/opencv --recursive --remote -# opencv_contrib - - git submodule add https://github.com/opencv/opencv_contrib.git src/opencv_contrib - - git submodule update src/opencv_contrib --recursive --remote - -# scintilla - - cd scintilla\win32 - - nmake -f scintilla.mak - - nmake DEBUG=1 -f scintilla.mak - - nmake -f scintilla.mak clean - -# v8 - wget https://storage.googleapis.com/chrome-infra/depot_tools.zip - - gclient - - fetch v8 - - git pull origin - - gclient sync - -# tinyxml2 - - git submodule add https://github.com/leethomason/tinyxml2.git src/tinyxml2 - - git submodule update src/tinyxml2 --recursive --remote - -# json - - git submodule add https://github.com/nlohmann/json.git src/json - - git submodule update src/json --recursive --remote - -# depot_tools - - git submodule add https://chromium.googlesource.com/chromium/tools/depot_tools src/depot_tools - - git submodule update src/depot_tools --recursive --remote \ No newline at end of file diff --git a/QtStarter/assets/scripts/check_process.js b/QtStarter/assets/scripts/check_process.js deleted file mode 100644 index f9e0b2e..0000000 --- a/QtStarter/assets/scripts/check_process.js +++ /dev/null @@ -1,26 +0,0 @@ -let ok = false - -let dwProcessId = 0 -windows.enumProcess((entry) => { - if (entry.exeFile == "shelllet.exe") { - dwProcessId = entry.processID; - return false; - } -}); - -windows.enumWindows((wnd) => { - if (!wnd) { - return true; - } - let processId = wnd.getProcessID(); - - if (processId == dwProcessId && !wnd.getOwner()) { - wnd.show(windows.show.NORMAL); - wnd.foreground(); - ok = true; - return false; - } - -}); - -(()=>{return ok})() \ No newline at end of file diff --git a/QtStarter/dialog.cpp b/QtStarter/dialog.cpp deleted file mode 100644 index 1e3a889..0000000 --- a/QtStarter/dialog.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "dialog.h" -#include "ui_dialog.h" - -Dialog::Dialog(const QString &name, const QString &cmd, const ListEnvironment &env, Mode mode, QWidget *parent) : - QDialog(parent, Qt::WindowCloseButtonHint), - ui(new Ui::Dialog), - mode_(mode) -{ - ui->setupUi(this); - - ui->lineEdit->setText(name); - ui->lineEdit_2->setText(cmd); - for (const auto& e: env) { - ui->tableWidget->insertRow(ui->tableWidget->rowCount()); - ui->tableWidget->setItem(ui->tableWidget->rowCount() - 1, 0, new QTableWidgetItem(e.first)); - ui->tableWidget->setItem(ui->tableWidget->rowCount() - 1, 1, new QTableWidgetItem(e.second)); - } - setWindowTitle(mode == MODE_CREATE ? "Create": "Edit"); -} - -Dialog::~Dialog() -{ - delete ui; -} - -void Dialog::on_buttonBox_accepted() -{ - if (ui->lineEdit->text().trimmed().isEmpty()){ - return; - } - ListEnvironment list; - - for(int i =0; i < ui->tableWidget->rowCount(); i++){ - auto item = ui->tableWidget->item(i, 0); - if (!item) - continue; - - QString name = item->text().trimmed(); - if (name.isEmpty()) - continue; - item = ui->tableWidget->item(i, 1); - if (!item) - continue; - - QString value = item->text().trimmed(); - list.push_back(qMakePair(name, value)); - } - if (mode_ == MODE_EDIT){ - emit edited(ui->lineEdit->text(), ui->lineEdit_2->text(), list); - } else if (mode_ == MODE_CREATE){ - emit created(ui->lineEdit->text(), ui->lineEdit_2->text(), list); - } -} - -void Dialog::on_buttonBox_rejected() -{ - this->close(); -} - -void Dialog::on_toolButton_Add_clicked() -{ - ui->tableWidget->insertRow(ui->tableWidget->rowCount()); -} - -void Dialog::on_toolButton_Del_clicked() -{ - ui->tableWidget->removeRow(ui->tableWidget->currentRow()); -} diff --git a/QtStarter/dialog.h b/QtStarter/dialog.h deleted file mode 100644 index aaa5a0f..0000000 --- a/QtStarter/dialog.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef DIALOG_H -#define DIALOG_H - -#include -#include "workerthread.h" - -namespace Ui { -class Dialog; -} - -enum Mode{ - MODE_EDIT, - MODE_CREATE -}; - - - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(const QString& name, const QString &cmd, const ListEnvironment& env, Mode mode, QWidget *parent = nullptr); - ~Dialog(); -signals: - - void created(const QString& name, const QString& cmd, const ListEnvironment& env); - void edited(const QString& name, const QString& cmd, const ListEnvironment& env); -private slots: - void on_buttonBox_accepted(); - - void on_buttonBox_rejected(); - - void on_toolButton_Add_clicked(); - - void on_toolButton_Del_clicked(); - -private: - Ui::Dialog *ui; - - Mode mode_; -}; - -#endif // DIALOG_H diff --git a/QtStarter/dialog.ui b/QtStarter/dialog.ui deleted file mode 100644 index 99e83f8..0000000 --- a/QtStarter/dialog.ui +++ /dev/null @@ -1,222 +0,0 @@ - - - Dialog - - - - 0 - 0 - 556 - 483 - - - - Qt::NoContextMenu - - - Dialog - - - - :/new/app/favicon.png:/new/app/favicon.png - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 40 - - - - - - - - - - 名称 - - - - - - - - 0 - 36 - - - - - 9 - - - - - - - - 命令 - - - - - - - - 0 - 36 - - - - - 9 - - - - - - - - 参数必须放在`[]`内,用`,`号分隔。 - - - - - - - - - - - 环境 -变量 - - - - - - - - 名称 - - - - - - - - - - - - - - - ... - - - - :/new/tools/images/new.png:/new/tools/images/new.png - - - - - - - ... - - - - :/new/tools/images/del.png:/new/tools/images/del.png - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/QtStarter/example/index.js b/QtStarter/example/index.js deleted file mode 100644 index 0e816ef..0000000 --- a/QtStarter/example/index.js +++ /dev/null @@ -1,155 +0,0 @@ -//import * as Test from "./index.js"; -//import "shelllet/v0.1.0/common.let.dll" - -//let tim = windows.find("TIM"); - -let image = images.read("C:\\Users\\Admin\\Pictures\\login.custom.exp0.png"); -let text = image.text("C:\\Users\\Admin\\source\\repos\\ConsoleApplication2\\ConsoleApplication2\\tessdata", "hz"); - - -console.log(text) -//window.setPos(windows.NOTOPMOST) -//console.log(registry.CURRENT_USER) -// let image = window.capture(); - -//console.log(tim.getWindowRect()) - -// let image = images.captureDesktop() -// -// image.write(dir.Pictures + "\\qq++.jpg"); -// -// let login = image.subImage(tim.getWindowRect()); -// -// login.write(dir.Pictures + "\\login.jpg") -// -// let result = login.matchTemplate(dir.Pictures + "\\2019-09-17_102801.png") -// -// console.log(result.first) -// console.log(result.second) -// console.log(result.second.min) -// -// let screenPoint = tim.mapToGlobal(result.second.min); -// console.log(screenPoint) -// screenPoint.add(images.pt(20, 10)) -// -// mouse.moveAndClick(screenPoint) -//console.log(ioutil.readFile("c:/works/a.txt")) - -//ioutil.writeFile("c:/works/a.txt", "sgsgsg") -// var hook = win.mouseHookStart((msg, r, pt )=>{ -// console.log(r); -// console.log(pt.x); -// console.log(pt.y); - -// if (msg == win.msg.mButtonDown) { -// win.mouseHookStop(hook) -// win.postQuitMessage(); -// } -// }) - -// win.runMessageLoop() - - -//win.simulateInput("CTRL + A") - -//dir.mkAll("C:/Users/Admin/source/repos/gtktest/x64/Debug/share/themes/Windows10/gtk-3.0/") - -//var ini = Ini.load("C:\\Windows\\System32\\wbem\\Performance\\WmiApRpl.ini") - -//console.log(ini.sectionNames()) - -//console.log(win.keyIsDown(win.key.Shift)) - -//console.log(windows.keyName(windows.key.Ctrl)) - - -// var hook = win.keyStartHook((msg, vk, sc) => { -// if (msg == win.msg.KeyUp) { - - -// console.log(vk); -// console.log(sc); - -// console.log(win.keyName(vk)) - -// if (vk == win.key.LCtrl) { -// win.keyStopHook(hook) -// win.postQuitMessage(); -// } -// } -// }) - -// win.runMessageLoop() -// -// let ok = false -// -// let dwProcessId = 0 -// windows.enumProcess((entry) => { -// if (entry.exeFile == "shelllet.exe") { -// dwProcessId = entry.processID; -// return false; -// } -// }) -// -// windows.enumWindows((wnd) => { -// if (!wnd) { -// return true; -// } -// let processId = wnd.getProcessID(); -// -// // console.log(processId, wnd.getTitle()); -// if (processId == dwProcessId && !wnd.getOwner()) { -// -// if (wnd.isTopLevel()) { -// wnd.show(windows.cmdshow.SW_SHOWNORMAL); -// wnd.foreground(); -// ok = true; -// return false; -// } -// -// } -// -// }); -// (()=>{return ok})() - -// var pid = windows.getCurrentProcessID(); - -// windows.adjustPrivilege(pid, windows.pri.debug, true) - -// windows.enumModule(620, (entry)=>{ -// console.log(JSON.stringify(entry)) -// }) - - -//runAs("test", "123", "C:\\Program Files (x86)\\FastStone Capture\\FSCapture.exe") - -//run("C:\\Program Files (x86)\\Internet Download Manager\\IDMan.exe") - -//shell("C:\\Program Files (x86)\\Internet Download Manager\\IDMan.exe") - -// var k = windows.regCreateKey(windows.reg.CURRENT_USER, "Software\\Licenses\\version"); -// k.close(); - - -//windows.regDelKey(windows.reg.CURRENT_USER, "Software\\Classes\\Wow6432Node\\CLSID\\{79873CC5-3951-43ED-BDF9-D8759474B6FD}"); - - -//start("D:\\Program Files (x86)\\Internet Download Manager\\IDMan.exe"); - -// windows.enumThread(0, (entry)=>{ -// console.log(JSON.stringify(entry)) -// }) - -//console.log(Test.add(3, 3)) - -//console.log(Object.keys(FileSystem)) -//console.log(Object.keys(FileSystem.Path)) -//console.log(FileSystem.Path.userDocuments) - -// let id = windows.getCurrentThreadID(); - -// windows.enumDesktopWindow(windows.getThreadDesktop(id), (window) => { - // if (window) { - // console.log(window.getTitle()) - // } -// }) diff --git a/QtStarter/favicon.ico b/QtStarter/favicon.ico deleted file mode 100644 index f63aec7..0000000 Binary files a/QtStarter/favicon.ico and /dev/null differ diff --git a/QtStarter/favicon.png b/QtStarter/favicon.png deleted file mode 100644 index 6eec87d..0000000 Binary files a/QtStarter/favicon.png and /dev/null differ diff --git a/QtStarter/images/del.png b/QtStarter/images/del.png deleted file mode 100644 index f342a60..0000000 Binary files a/QtStarter/images/del.png and /dev/null differ diff --git a/QtStarter/images/edit.png b/QtStarter/images/edit.png deleted file mode 100644 index 3aa8a95..0000000 Binary files a/QtStarter/images/edit.png and /dev/null differ diff --git a/QtStarter/images/new.png b/QtStarter/images/new.png deleted file mode 100644 index 1e60dde..0000000 Binary files a/QtStarter/images/new.png and /dev/null differ diff --git a/QtStarter/images/quit.png b/QtStarter/images/quit.png deleted file mode 100644 index 2b8d8a4..0000000 Binary files a/QtStarter/images/quit.png and /dev/null differ diff --git a/QtStarter/images/set.png b/QtStarter/images/set.png deleted file mode 100644 index ba62ba9..0000000 Binary files a/QtStarter/images/set.png and /dev/null differ diff --git a/QtStarter/main.cpp b/QtStarter/main.cpp deleted file mode 100644 index e2d2386..0000000 --- a/QtStarter/main.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "mainwindow.h" -#include -#include -#include -#include -#include -#include "setting.h" -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QDir::home().mkpath("shelllet.com"); - - QProcess process; - - auto filename = Setting::LetPath(); - auto dir = QFileInfo(filename).absoluteDir().absolutePath(); - process.setWorkingDirectory(dir); - QStringList params; - params << "run"; - params << qApp->applicationDirPath() + QDir::separator() + "assets" + QDir::separator() + "scripts" + QDir::separator() + "check_process.js"; - process.start(filename, params); - - if (process.waitForFinished()) { - QByteArray result = process.readAllStandardError(); - QJSEngine myEngine; - QJSValue three = myEngine.evaluate(QString(result)); - - if (three.isBool() && three.toBool()){ - return 0; - } - } - - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/QtStarter/mainwindow.cpp b/QtStarter/mainwindow.cpp deleted file mode 100644 index 1e0676f..0000000 --- a/QtStarter/mainwindow.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include "dialog.h" -#include "workerthread.h" -#include "setting.h" -#include -#include - -MainWindow::MainWindow(QWidget* parent) : - QMainWindow(parent), - ui(new Ui::MainWindow), - tray_(QIcon(":/new/app/favicon.png")) -{ - ui->setupUi(this); - - connect(&tableModel_, &TableModel::reported, this, &MainWindow::on_Reported); - - ui->tableView->setModel(&tableModel_); - - ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); - ui->tableView->setColumnWidth(Column_Name, 120); - ui->tableView->setColumnWidth(Column_Cmd, 380); - tableModel_.load(); - - connect(&tray_, &QSystemTrayIcon::activated, this, &MainWindow::on_IconActivated); - tray_.show(); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_action_new_triggered() -{ - std::unique_ptr dialog = std::make_unique("", "[]", ListEnvironment(), MODE_CREATE, this); - - connect(dialog.get(), &Dialog::created, this, &MainWindow::on_Created); - dialog->setModal(true); - - dialog->exec(); -} - -void MainWindow::on_action_edit_triggered() -{ - if (ui->tableView->selectionModel()->hasSelection()) { - auto indexes = ui->tableView->selectionModel()->selectedRows(); - - auto model = ui->tableView->selectionModel()->model(); - - auto name = model->data(indexes[0]).toString(); - auto cmd = model->data(model->index(indexes[0].row(), Column_Cmd)).toString(); - auto env = model->data(model->index(indexes[0].row(), Column_Env)).toString(); - - std::unique_ptr dialog = std::make_unique(name, cmd, WorkerThread::StringToListEnvironment(env), MODE_EDIT, this); - - connect(dialog.get(), &Dialog::edited, this, &MainWindow::on_Edited); - dialog->setModal(true); - - dialog->exec(); - } -} - -void MainWindow::on_Created(const QString& name, const QString& cmd, const ListEnvironment& env) -{ - tableModel_.add(name, cmd, WorkerThread::ListEnvironmentToString(env)); -} - -void MainWindow::on_Edited(const QString& name, const QString& cmd, const ListEnvironment& env) -{ - if (ui->tableView->selectionModel()->hasSelection()) { - auto indexes = ui->tableView->selectionModel()->selectedRows(); - tableModel_.editCurrent(indexes[0].row(), name, cmd, WorkerThread::ListEnvironmentToString(env)); - } -} - -void MainWindow::on_Reported(const QString& message) -{ - ui->plainTextEdit->appendPlainText(message); -} - -void MainWindow::on_action_del_triggered() -{ - if (ui->tableView->selectionModel()->hasSelection()) { - auto indexes = ui->tableView->selectionModel()->selectedRows(); - tableModel_.delCurrent(indexes[0].row()); - } -} - -void MainWindow::on_tableView_doubleClicked(const QModelIndex& index) -{ - auto model = ui->tableView->model(); - auto name = model->data(model->index(index.row(), Column_Name)).toString(); - auto cmd = model->data(model->index(index.row(), Column_Cmd)).toString(); - auto env = model->data(model->index(index.row(), Column_Env)).toString(); - - WorkerThread* workerThread = new WorkerThread(name, cmd, WorkerThread::StringToListEnvironment(env)); - - connect(workerThread, SIGNAL(reported(const QString&)), ui->plainTextEdit, SLOT(appendPlainText(const QString&))); - - connect(workerThread, &WorkerThread::finished, workerThread, &WorkerThread::deleteLater); - - workerThread->start(); -} - -void MainWindow::closeEvent(QCloseEvent* event) -{ - hide(); - tray_.showMessage("Tips", "I'm here."); - event->ignore(); -} - -bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, long* result) -{ - if (eventType == "windows_generic_MSG") { - MSG* msg = static_cast(message); - if (msg->message == WM_SHOWWINDOW && msg->wParam == TRUE) { - show(); - } - } - - return QMainWindow::nativeEvent(eventType, message, result); -} - -void MainWindow::on_action_quit_triggered() -{ - qApp->exit(); -} - -void MainWindow::on_IconActivated(QSystemTrayIcon::ActivationReason reason) -{ - switch (reason) { - case QSystemTrayIcon::Trigger: - case QSystemTrayIcon::DoubleClick: - setWindowState(Qt::WindowActive); - showNormal(); - break; - case QSystemTrayIcon::MiddleClick: - case QSystemTrayIcon::Context: - qApp->exit(); - break; - default: - ; - } -} - -void MainWindow::on_action_setting_triggered() -{ - std::unique_ptr dialog = std::make_unique(); - dialog->setModal(true); - dialog->exec(); -} diff --git a/QtStarter/mainwindow.h b/QtStarter/mainwindow.h deleted file mode 100644 index 0bb7512..0000000 --- a/QtStarter/mainwindow.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include "workerthread.h" -#include "tablemodel.h" - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_action_new_triggered(); - - void on_action_edit_triggered(); - - void on_Created(const QString &name, const QString& cmd, const ListEnvironment& env); - void on_Edited(const QString &name, const QString& cmd, const ListEnvironment& env); - void on_Reported(const QString& message); - void on_action_del_triggered(); - - void on_tableView_doubleClicked(const QModelIndex &index); - void on_action_quit_triggered(); - - void on_IconActivated(QSystemTrayIcon::ActivationReason reason); - - void on_action_setting_triggered(); - -protected: - virtual void closeEvent(QCloseEvent *event); - virtual bool nativeEvent(const QByteArray& eventType, void* message, long* result); -private: - Ui::MainWindow *ui; - - TableModel tableModel_; - QSystemTrayIcon tray_; -}; - -#endif // MAINWINDOW_H diff --git a/QtStarter/mainwindow.ui b/QtStarter/mainwindow.ui deleted file mode 100644 index f734a05..0000000 --- a/QtStarter/mainwindow.ui +++ /dev/null @@ -1,141 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 912 - 673 - - - - shelllet 0.4.0 - - - - :/new/app/favicon.png:/new/app/favicon.png - - - - - - - Qt::Vertical - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - true - - - true - - - false - - - - - true - - - #Output message - - - - - - - - - false - - - Qt::ToolButtonTextBesideIcon - - - false - - - TopToolBarArea - - - false - - - - - - - - - - - :/new/tools/images/new.png:/new/tools/images/new.png - - - 新建 - - - 新建命令 - - - - - - :/new/tools/images/edit.png:/new/tools/images/edit.png - - - 编辑 - - - 编辑命令 - - - - - - :/new/tools/images/del.png:/new/tools/images/del.png - - - 删除 - - - - - - :/new/tools/images/quit.png:/new/tools/images/quit.png - - - 退出 - - - - - - :/new/tools/images/set.png:/new/tools/images/set.png - - - 设置 - - - - - - - - - diff --git a/QtStarter/nsi/setup.nsi b/QtStarter/nsi/setup.nsi deleted file mode 100644 index 4a5f6e8..0000000 --- a/QtStarter/nsi/setup.nsi +++ /dev/null @@ -1,235 +0,0 @@ -;Include Modern UI - - !include "MUI2.nsh" - !include "x64.nsh" - - Unicode true - -;General - !define VERSION "0.5.0" - !define PRODUCT_NAME "shelllet ${VERSION}" - !define APPNAME "shelllet" - !define MUI_FOLDER "shelllet.com" - !define COMPANYNAME "shelllet.com" - !define HELPURL "http://shelllet.com" - !define MUI_FINISHPAGE_NOAUTOCLOSE - !define MUI_FINISHPAGE_RUN "$INSTDIR\${APPNAME}.exe" - !define MUI_FINISHPAGE_RUN_CHECKED - !define MUI_FINISHPAGE_RUN_TEXT "${PRODUCT_NAME}" - !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink" - - - Name "${PRODUCT_NAME}" - # Icon "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico" - # UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico" - - OutFile "${APPNAME}-${VERSION}-setup.x64.exe" - - ;Default installation folder - InstallDir "$PROGRAMFILES64\${MUI_FOLDER}" - - ;Request application privileges for Windows Vista - RequestExecutionLevel admin - -;-------------------------------- -;Variables - - Var StartMenuFolder - -;-------------------------------- -;Interface Configuration - !define MUI_ICON "..\favicon.ico" - !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico" - !define MUI_HEADERIMAGE - !define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis3-branding.bmp" - !define MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\nsis3-branding.bmp" - !define MUI_UNWELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\nsis3-branding.bmp" - !define MUI_ABORTWARNING - -;Pages - - !insertmacro MUI_PAGE_COMPONENTS - !insertmacro MUI_PAGE_DIRECTORY - - ;Start Menu Folder Page Configuration - !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" - !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${MUI_FOLDER}" - !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${MUI_FOLDER}" - - !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder - - !insertmacro MUI_PAGE_INSTFILES - !insertmacro MUI_PAGE_FINISH - - !insertmacro MUI_UNPAGE_COMPONENTS - !insertmacro MUI_UNPAGE_WELCOME - !insertmacro MUI_UNPAGE_CONFIRM - - !insertmacro MUI_UNPAGE_INSTFILES - !insertmacro MUI_UNPAGE_FINISH -;-------------------------------- -;Languages - - !insertmacro MUI_LANGUAGE "SimpChinese" - -;-------------------------------- -;Installer Sections - -Section "װļ" MAIN_FILES - SetOutPath "$INSTDIR" - ; Qt - File C:\Qt\5.13.0\msvc2017_64\bin\Qt5Core.dll - File C:\Qt\5.13.0\msvc2017_64\bin\Qt5Gui.dll - File C:\Qt\5.13.0\msvc2017_64\bin\Qt5Widgets.dll - File C:\Qt\5.13.0\msvc2017_64\bin\Qt5Svg.dll - File C:\Qt\5.13.0\msvc2017_64\bin\Qt5Qml.dll - File C:\Qt\5.13.0\msvc2017_64\bin\Qt5Network.dll - File C:\Qt\5.13.0\msvc2017_64\bin\libEGL.dll - File C:\Qt\5.13.0\msvc2017_64\bin\libGLESV2.dll - File C:\Qt\5.13.0\msvc2017_64\bin\opengl32sw.dll - - ; vc runtime - File "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Redist\MSVC\14.23.27820\vcredist_x64.exe" - - ; opencv - File $%VCPKG_ROOT%\installed\x64-windows\bin\opencv_imgcodecs.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\opencv_imgproc.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\opencv_core.dll - - ; v8 - File C:\v8\v8\out.gn\x64.release\v8.dll - File C:\v8\v8\out.gn\x64.release\v8_libbase.dll - File C:\v8\v8\out.gn\x64.release\v8_libplatform.dll - - ; tesseract - File $%VCPKG_ROOT%\installed\x64-windows\bin\zlib1.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\webp.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\tiff.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\lzma.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\libpng16.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\leptonica-1.78.0.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\jpeg62.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\boost_date_time-vc142-mt-x64-1_70.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\boost_random-vc142-mt-x64-1_70.dll - File $%VCPKG_ROOT%\installed\x64-windows\bin\boost_thread-vc142-mt-x64-1_70.dll - - File ..\bin\let.dll - File ..\bin\shelllet.exe - File ..\bin\let.exe - ; assets - SetOutPath "$INSTDIR" - File /r ..\assets - File /r ..\..\let\assets - - SetOutPath "$INSTDIR\styles" - File C:\Qt\5.13.0\msvc2017_64\plugins\styles\qwindowsvistastyle.dll - - SetOutPath "$INSTDIR\bearer" - File C:\Qt\5.13.0\msvc2017_64\plugins\bearer\qgenericbearer.dll - - SetOutPath "$INSTDIR\iconengines" - File C:\Qt\5.13.0\msvc2017_64\plugins\iconengines\qsvgicon.dll - - SetOutPath "$INSTDIR\platforms" - File C:\Qt\5.13.0\msvc2017_64\plugins\platforms\qwindows.dll - - SetOutPath "$INSTDIR\translations" - File C:\Qt\5.13.0\msvc2017_64\translations\qt_zh_TW.qm - File C:\Qt\5.13.0\msvc2017_64\translations\qt_en.qm - - - SetOutPath "$INSTDIR\imageformats" - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qwebp.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qwbmp.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qtiff.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qtga.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qsvg.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qjpeg.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qico.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qicns.dll - File C:\Qt\5.13.0\msvc2017_64\plugins\imageformats\qgif.dll - - ;create desktop shortcut - CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${APPNAME}.exe" "" - - !insertmacro MUI_STARTMENU_WRITE_BEGIN Application - - ;create start-menu items - CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}" - CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\Uninstall.exe" 0 - CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\${PRODUCT_NAME}.lnk" "$INSTDIR\${APPNAME}.exe" "" "$INSTDIR\${APPNAME}.exe" 0 - - !insertmacro MUI_STARTMENU_WRITE_END - - ;Store installation folder - WriteRegStr HKCU "Software\${PRODUCT_NAME}" "" $INSTDIR - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" "${PRODUCT_NAME}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\${APPNAME}.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "$\"${COMPANYNAME}$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\"" - - ;Create uninstaller - WriteUninstaller "$INSTDIR\Uninstall.exe" - - ; Check VC Runtime - ReadRegDWORD $0 HKLM SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64 Installed - ${If} $0 <> 1 - ExecWait '"$INSTDIR\vcredist_x64.exe" /q' - ${EndIf} - -SectionEnd - - -;Language strings -;LangString DESC_SecFiles ${LANG_ENGLISH} "basic component" -LangString DESC_MAIN_SECFILES ${LANG_SIMPCHINESE} "Main" - -;Assign language strings to sections -!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${MAIN_FILES} $(DESC_MAIN_SECFILES) -!insertmacro MUI_FUNCTION_DESCRIPTION_END - - - -;Uninstaller Section -Section Un.Main UnMain - - ;ADD YOUR OWN FILES HERE... - - Delete "$INSTDIR\Uninstall.exe" - - RMDir /r "$INSTDIR" - - !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder - - Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" - Delete "$DESKTOP\${PRODUCT_NAME}.lnk" - RMDir "$SMPROGRAMS\$StartMenuFolder" - - DeleteRegKey /ifempty HKCU "Software\${PRODUCT_NAME}" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" -SectionEnd - -Function LaunchLink - ExecShell "" "$INSTDIR\${APPNAME}.exe" -FunctionEnd - -ShowInstDetails show - -ShowUnInstDetails show - - -Function .onInit - # set section 'test' as selected and read-only - IntOp $0 ${SF_SELECTED} | ${SF_RO} - SectionSetFlags ${MAIN_FILES} $0 -FunctionEnd - -Function un.onInit - # set section 'test' as selected and read-only - IntOp $0 ${SF_SELECTED} | ${SF_RO} - SectionSetFlags ${UnMain} $0 -FunctionEnd \ No newline at end of file diff --git a/QtStarter/setting.cpp b/QtStarter/setting.cpp deleted file mode 100644 index 2aa03d0..0000000 --- a/QtStarter/setting.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "setting.h" -#include "ui_setting.h" -#include -#include -#include - -Setting::Setting(QWidget *parent) : - QDialog(parent, Qt::WindowCloseButtonHint), - ui(new Ui::Setting) -{ - ui->setupUi(this); - - ui->lineEdit->setText(LetPath()); -} - -Setting::~Setting() -{ - delete ui; -} - -QString Setting::LetPath() -{ - QSettings settings("shelllet.com", "shelllet"); - - auto filename = settings.value("let").toString(); - if (filename.isEmpty()){ - filename = QStandardPaths::findExecutable("let.exe", QStringList{ qApp->applicationDirPath() }); - if (filename.isEmpty()){ - filename = QStandardPaths::findExecutable("let.exe"); - } - } - return filename; -} - -void Setting::on_pushButton_clicked() -{ - auto fileName = QFileDialog::getOpenFileName(this, "Select `let.exe` path", ui->lineEdit->text().trimmed(), "*.exe"); - - ui->lineEdit->setText(fileName); - -} - -void Setting::on_buttonBox_accepted() -{ - QSettings settings("shelllet.com", "shelllet"); - - settings.setValue("let", ui->lineEdit->text().trimmed()); -} diff --git a/QtStarter/setting.h b/QtStarter/setting.h deleted file mode 100644 index 074feac..0000000 --- a/QtStarter/setting.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SETTING_H -#define SETTING_H - -#include - -namespace Ui { -class Setting; -} - -class Setting : public QDialog -{ - Q_OBJECT - -public: - explicit Setting(QWidget *parent = nullptr); - ~Setting(); - - static QString LetPath(); -private slots: - void on_pushButton_clicked(); - - void on_buttonBox_accepted(); - -private: - Ui::Setting *ui; -}; - -#endif // SETTING_H diff --git a/QtStarter/setting.ui b/QtStarter/setting.ui deleted file mode 100644 index 75c5e5e..0000000 --- a/QtStarter/setting.ui +++ /dev/null @@ -1,129 +0,0 @@ - - - Setting - - - - 0 - 0 - 431 - 304 - - - - Setting - - - - - - Qt::Vertical - - - - 20 - 99 - - - - - - - - - - let.exe - - - - - - - - - - - 0 - 0 - - - - - 48 - 0 - - - - - 48 - 16777215 - - - - ... - - - - - - - - - Qt::Vertical - - - - 20 - 98 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - Setting - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Setting - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/QtStarter/shelllet.pro b/QtStarter/shelllet.pro deleted file mode 100644 index f7d604e..0000000 --- a/QtStarter/shelllet.pro +++ /dev/null @@ -1,53 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-08-19T10:51:18 -# -#------------------------------------------------- - -QT += core gui qml - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = shelllet -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++14 - -SOURCES += \ - dialog.cpp \ - main.cpp \ - mainwindow.cpp \ - setting.cpp \ - tablemodel.cpp \ - workerthread.cpp - -HEADERS += \ - dialog.h \ - mainwindow.h \ - setting.h \ - tablemodel.h \ - workerthread.h - -FORMS += \ - dialog.ui \ - mainwindow.ui \ - setting.ui - -RESOURCES += \ - shelllet.qrc - -DISTFILES += - -RC_ICONS = favicon.ico - diff --git a/QtStarter/shelllet.qrc b/QtStarter/shelllet.qrc deleted file mode 100644 index 2b82bb8..0000000 --- a/QtStarter/shelllet.qrc +++ /dev/null @@ -1,12 +0,0 @@ - - - images/edit.png - images/new.png - images/del.png - images/quit.png - images/set.png - - - favicon.png - - diff --git a/QtStarter/shelllet.sln b/QtStarter/shelllet.sln deleted file mode 100644 index 0e852c1..0000000 --- a/QtStarter/shelllet.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29209.152 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shelllet", "shelllet.vcxproj", "{3A7FCD5E-ADA0-3397-ACD8-BF52321A0E44}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3A7FCD5E-ADA0-3397-ACD8-BF52321A0E44}.Debug|x64.ActiveCfg = Debug|x64 - {3A7FCD5E-ADA0-3397-ACD8-BF52321A0E44}.Debug|x64.Build.0 = Debug|x64 - {3A7FCD5E-ADA0-3397-ACD8-BF52321A0E44}.Release|x64.ActiveCfg = Release|x64 - {3A7FCD5E-ADA0-3397-ACD8-BF52321A0E44}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {33E43950-8492-4D18-85BB-0C3B2A6B09A8} - EndGlobalSection -EndGlobal diff --git a/QtStarter/shelllet.vcxproj b/QtStarter/shelllet.vcxproj deleted file mode 100644 index 588c4c7..0000000 --- a/QtStarter/shelllet.vcxproj +++ /dev/null @@ -1,269 +0,0 @@ - - - - - Release - x64 - - - Debug - x64 - - - - {3A7FCD5E-ADA0-3397-ACD8-BF52321A0E44} - shelllet - Qt4VSv1.0 - 10.0.18362.0 - 10.0.18362.0 - - - - v142 - release\ - false - NotSet - Application - release\ - shelllet - - - v142 - debug\ - false - NotSet - Application - debug\ - shelllet - - - - $(MSBuildProjectDirectory)\QtMsBuild - - - - - - - - - - - - - - - - - $(SolutionDir)bin - $(Platform)\$(Configuration)\ - shelllet - true - false - $(SolutionDir)bin - $(Platform)\$(Configuration)\ - shelllet - true - - - - .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(QTDIR)\include;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtQml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtCore;release;\include;$(QTDIR)\mkspecs\win32-msvc;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - release\ - false - None - 4577;4467;%(DisableSpecificWarnings) - Sync - stdcpp14 - $(IntDir) - MaxSpeed - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_QML_LIB;QT_NETWORK_LIB;QT_CORE_LIB;NDEBUG;%(PreprocessorDefinitions) - false - $(IntDir)vc$(PlatformToolsetVersion).pdb - MultiThreadedDLL - true - true - Level3 - true - - - $(QTDIR)\lib\Qt5Widgets.lib;$(QTDIR)\lib\Qt5Gui.lib;$(QTDIR)\lib\Qt5Qml.lib;$(QTDIR)\lib\Qt5Network.lib;$(QTDIR)\lib\Qt5Core.lib;$(QTDIR)\lib\qtmain.lib;shell32.lib;%(AdditionalDependencies) - $(QTDIR)\lib;C:\openssl\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories) - "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) - true - false - true - false - $(OutDir)\shelllet.exe - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_QML_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) - - - $(QTDIR) - $(Configuration)\moc_%(Filename).cpp - UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_QML_LIB;QT_NETWORK_LIB;QT_CORE_LIB - msvc - ./$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - %(FullPath) - output - .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;$(QTDIR)\mkspecs/win32-msvc;.;$(QTDIR)\include;$(QTDIR)\include/QtWidgets;$(QTDIR)\include/QtGui;$(QTDIR)\include/QtANGLE;$(QTDIR)\include/QtQml;$(QTDIR)\include/QtNetwork;$(QTDIR)\include/QtCore;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.23.28008\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.23.28008\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt - - - shelllet - $(Configuration)\qrc_%(Filename).cpp - %(FullPath) - $(QTDIR) - default - Rcc'ing %(Identity)... - - - $(QTDIR) - Uic'ing %(Identity)... - %(FullPath) - .\GeneratedFiles\ui_%(Filename).h - - - - - .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;.;$(QTDIR)\include;$(QTDIR)\include\QtWidgets;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtANGLE;$(QTDIR)\include\QtQml;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtCore;debug;\include;$(QTDIR)\mkspecs\win32-msvc;%(AdditionalIncludeDirectories) - -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 %(AdditionalOptions) - debug\ - false - ProgramDatabase - 4577;4467;%(DisableSpecificWarnings) - Sync - stdcpp14 - $(IntDir) - Disabled - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QT_WIDGETS_LIB;QT_GUI_LIB;QT_QML_LIB;QT_NETWORK_LIB;QT_CORE_LIB;%(PreprocessorDefinitions) - false - MultiThreadedDebugDLL - true - true - Level3 - true - $(IntDir)vc$(PlatformToolsetVersion).pdb - - - $(QTDIR)\lib\Qt5Widgetsd.lib;$(QTDIR)\lib\Qt5Guid.lib;$(QTDIR)\lib\Qt5Qmld.lib;$(QTDIR)\lib\Qt5Networkd.lib;$(QTDIR)\lib\Qt5Cored.lib;$(QTDIR)\lib\qtmaind.lib;shell32.lib;%(AdditionalDependencies) - $(QTDIR)\lib;C:\openssl\lib;C:\Utils\postgresql\pgsql\lib;%(AdditionalLibraryDirectories) - "/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'" %(AdditionalOptions) - true - true - true - $(OutDir)\shelllet.exe - true - Windows - true - - - Unsigned - None - 0 - - - _WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QT_WIDGETS_LIB;QT_GUI_LIB;QT_QML_LIB;QT_NETWORK_LIB;QT_CORE_LIB;_DEBUG;%(PreprocessorDefinitions) - - - $(QTDIR) - $(Configuration)\moc_%(Filename).cpp - UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QT_WIDGETS_LIB;QT_GUI_LIB;QT_QML_LIB;QT_NETWORK_LIB;QT_CORE_LIB - msvc - ./$(Configuration)/moc_predefs.h - Moc'ing %(Identity)... - %(FullPath) - output - .\GeneratedFiles\$(ConfigurationName);.\GeneratedFiles;$(QTDIR)\mkspecs/win32-msvc;.;$(QTDIR)\include;$(QTDIR)\include/QtWidgets;$(QTDIR)\include/QtGui;$(QTDIR)\include/QtANGLE;$(QTDIR)\include/QtQml;$(QTDIR)\include/QtNetwork;$(QTDIR)\include/QtCore;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.23.28008\ATLMFC\include;C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.23.28008\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt - - - $(QTDIR) - %(FullPath) - $(Configuration)\qrc_%(Filename).cpp - shelllet - default - Rcc'ing %(Identity)... - - - $(QTDIR) - Uic'ing %(Identity)... - %(FullPath) - .\GeneratedFiles\ui_%(Filename).h - - - - - - - - - - - - - - - - - - - - - - - - - Document - true - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -Zi -MDd -std:c++14 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >debug\moc_predefs.h - Generate moc_predefs.h - debug\moc_predefs.h;%(Outputs) - - - Document - $(QTDIR)\mkspecs\features\data\dummy.cpp;%(AdditionalInputs) - cl -Bx"$(QTDIR)\bin\qmake.exe" -nologo -Zc:wchar_t -FS -Zc:rvalueCast -Zc:inline -Zc:strictStrings -Zc:throwingNew -Zc:referenceBinding -Zc:__cplusplus -O2 -MD -std:c++14 -W3 -w34100 -w34189 -w44996 -w44456 -w44457 -w44458 -wd4577 -wd4467 -E $(QTDIR)\mkspecs\features\data\dummy.cpp 2>NUL >release\moc_predefs.h - Generate moc_predefs.h - release\moc_predefs.h;%(Outputs) - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/QtStarter/shelllet_resource.rc b/QtStarter/shelllet_resource.rc deleted file mode 100644 index aad5b92..0000000 --- a/QtStarter/shelllet_resource.rc +++ /dev/null @@ -1,37 +0,0 @@ -#include - -IDI_ICON1 ICON DISCARDABLE ".\\favicon.ico" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,0,0,0 - PRODUCTVERSION 0,0,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS VS_FF_DEBUG -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE 0x0L - BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "\0" - VALUE "FileVersion", "0.0.0.0\0" - VALUE "LegalCopyright", "\0" - VALUE "OriginalFilename", "shelllet.exe\0" - VALUE "ProductName", "shelllet\0" - VALUE "ProductVersion", "0.0.0.0\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0409, 1200 - END - END -/* End of Version info */ - diff --git a/QtStarter/tablemodel.cpp b/QtStarter/tablemodel.cpp deleted file mode 100644 index 43452ac..0000000 --- a/QtStarter/tablemodel.cpp +++ /dev/null @@ -1,152 +0,0 @@ -#include "tablemodel.h" -#include -#include -#include -#include - -TableModel::TableModel(QObject *parent) - : QAbstractTableModel(parent) -{ -} - - -void TableModel::save() -{ - QFile file(ModelFileName()); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)){ - emit reported(file.errorString()); - return; - } - - file.write(QJsonDocument(array_).toJson()); -} - -void TableModel::load() -{ - QFile file(ModelFileName()); - if (!file.exists()) - return; - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - emit reported(file.errorString()); - return; - } - - QJsonParseError error; - - auto document= QJsonDocument::fromJson(file.readAll(), &error); - - if (error.error != QJsonParseError::NoError){ - emit reported(error.errorString()); - return; - } - if (!document.isArray()){ - emit reported("Model root is not array"); - return; - } - - array_ = document.array(); -} - -void TableModel::add(const QString &name, const QString &cmd, const QString& env) -{ - QJsonObject object = { - {"name", name}, - {"cmd", cmd}, - {"env", env} - }; - int row = array_.size(); - - this->beginInsertRows(QModelIndex(), row, row); - array_.push_back(object); - - this->setData(createIndex(row, Column_Name), name, Qt::DisplayRole); - this->setData(createIndex(row, Column_Cmd), cmd, Qt::DisplayRole); - this->setData(createIndex(row, Column_Env), env, Qt::DisplayRole); - this->endInsertRows(); - this->save(); -} - -void TableModel::editCurrent(int row, const QString &name, const QString &cmd, const QString& env) -{ - array_[row] = QJsonObject { - {"name", name}, - {"cmd", cmd}, - {"env", env} -}; - auto index1 = createIndex(row, Column_Name); - auto index2 = createIndex(row, Column_Cmd); - auto index3 = createIndex(row, Column_Env); - - this->setData(index1, name, Qt::DisplayRole); - this->setData(index2, cmd, Qt::DisplayRole); - this->setData(index3, env, Qt::DisplayRole); - - this->submit(); - this->save(); -} - -void TableModel::delCurrent(int row) -{ - this->beginRemoveRows(QModelIndex(), row, row); - array_.removeAt(row); - this->removeRow(row); - this->endRemoveRows(); - this->save(); -} - -QString TableModel::ModelFileName() -{ - return QDir::cleanPath(QDir::homePath() + QDir::separator() + "shelllet.com" + QDir::separator() +"model.json"); -} - -QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - Q_UNUSED(orientation) - - if (section == 0 && role == Qt::DisplayRole){ - return "Name"; - } - if (section == 1 && role == Qt::DisplayRole){ - return "Cmd"; - } - if (section == 2 && role == Qt::DisplayRole){ - return "Env"; - } - return QVariant(); -} - -int TableModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return array_.size(); -} - -int TableModel::columnCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return 3; -} - -QVariant TableModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || role != Qt::DisplayRole) - return QVariant(); - - int row = index.row(); - if (row >= array_.size()|| row < 0){ - return QVariant(); - } - if (index.column() == Column_Name) { - return array_[row].toObject().value("name").toString(); - } else if (index.column() == Column_Cmd) { - return array_[row].toObject().value("cmd").toString(); - } else if (index.column() == Column_Env) { - return array_[row].toObject().value("env").toString(); - } - return QVariant(); -} diff --git a/QtStarter/tablemodel.h b/QtStarter/tablemodel.h deleted file mode 100644 index 0e2ce63..0000000 --- a/QtStarter/tablemodel.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef TABLEMODEL_H -#define TABLEMODEL_H - -#include -#include - -enum Column_Type { - Column_Name, - Column_Cmd, - Column_Env -}; - -class TableModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - explicit TableModel(QObject *parent = nullptr); - - // Header: - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - - // Basic functionality: - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; -signals: - void reported(const QString& message); - -public: - void save(); - void load(); - void add(const QString& name, const QString&cmd, const QString& env); - void editCurrent(int row, const QString& name, const QString&cmd, const QString& env); - void delCurrent(int row); -protected: - static QString ModelFileName(); -private: - QJsonArray array_; -}; - -#endif // TABLEMODEL_H diff --git a/QtStarter/version.json b/QtStarter/version.json deleted file mode 100644 index 890a318..0000000 --- a/QtStarter/version.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "shelllet", - "version": "0.1.0", - "published": "2019-03-30", - "url": "https://shelllet.com" -} \ No newline at end of file diff --git a/QtStarter/workerthread.cpp b/QtStarter/workerthread.cpp deleted file mode 100644 index 6943345..0000000 --- a/QtStarter/workerthread.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "workerthread.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "setting.h" - -WorkerThread::WorkerThread(const QString &name, const QString &cmd, const ListEnvironment &env) - : name_(name) - , cmd_(cmd) - , env_(env){ - -} - -ListEnvironment WorkerThread::StringToListEnvironment(const QString &text) -{ - ListEnvironment environment; - QStringList list = text.split("\n"); - for (const auto &row: list) { - QStringList keyValue = row.split("="); - if(keyValue.isEmpty()) - continue; - - environment.push_back(qMakePair(keyValue.first(), keyValue.last())); - } - return environment; -} - -QString WorkerThread::ListEnvironmentToString(const ListEnvironment &env) -{ - QStringList list; - for (const auto& e: env){ - list.append(e.first + "=" + e.second); - } - return list.join("\n"); -} - -void WorkerThread::run() { - QProcess process; - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); - for(const auto& e: env_){ - env.insert(e.first, e.second); - } - process.setProcessEnvironment(env); - - connect(&process, &QProcess::readyReadStandardError, [&](){ - QTextCodec *codec = QTextCodec::codecForName("UTF-8"); - emit reported(QString("[%1]: %2").arg(name_).arg( codec->toUnicode( process.readAllStandardError()))); - }); - - connect(&process, &QProcess::readyReadStandardOutput, [&](){ - QTextCodec *codec = QTextCodec::codecForName("UTF-8"); - QString output = codec->toUnicode(process.readAllStandardOutput()); - emit reported(QString("[%1]: %2").arg(name_).arg(output)); - }); - - connect(&process, &QProcess::errorOccurred, [&](QProcess::ProcessError error){ - if (error == QProcess::FailedToStart){ - emit reported(QString("[%1]: %2").arg(name_).arg("failed to start")); - } else if (error == QProcess::Crashed){ - emit reported(QString("[%1]: %2").arg(name_).arg("crash")); - } else if (error == QProcess::Timedout){ - emit reported(QString("[%1]: %2").arg(name_).arg("timeout")); - } else if (error == QProcess::ReadError){ - emit reported(QString("[%1]: %2").arg(name_).arg("read error")); - } else { - emit reported(QString("[%1]: %2").arg(name_).arg("unknown error")); - } - - }); - - connect(&process, QOverload::of(&QProcess::finished), - [&](int, QProcess::ExitStatus exitStatus){ - emit reported(QString("[%1]: %2 %3").arg(name_).arg(" exit with").arg(exitStatus)); - }); - - - QJsonParseError error; - auto document = QJsonDocument::fromJson(cmd_.toUtf8(), &error); - if (error.error != QJsonParseError::NoError){ - emit reported(error.errorString()); - return; - } - QStringList params; - auto array = document.array(); - for (int i= 0; i < array.size(); i++){ - auto p = array[i].toString().trimmed(); - params.push_back(p.replace('\\', "\\\\")); - } - - auto filename = Setting::LetPath(); - auto dir = QFileInfo(filename).absoluteDir().absolutePath(); - process.setWorkingDirectory(dir); - - process.start(filename, params); - process.waitForFinished(-1); -} diff --git a/QtStarter/workerthread.h b/QtStarter/workerthread.h deleted file mode 100644 index d652818..0000000 --- a/QtStarter/workerthread.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef WORKERTHREAD_H -#define WORKERTHREAD_H - -#include -#include - -typedef QList> ListEnvironment; - -class WorkerThread : public QThread { - Q_OBJECT -public: - WorkerThread(const QString& name, const QString& cmd, const ListEnvironment& env); - static ListEnvironment StringToListEnvironment(const QString &text); - static QString ListEnvironmentToString(const ListEnvironment &env); -protected: - void run(); -signals: - void reported(const QString &info); -private: - QString name_; - QString cmd_; - ListEnvironment env_; -}; - - -#endif // WORKERTHREAD_H diff --git a/README.md b/README.md deleted file mode 100644 index 43de9a0..0000000 --- a/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# c++ example -[Youtube](https://www.youtube.com/playlist?list=PLZzwFJOgBE3We8y8WGmW_ahJA8BqmfIcR) - -# qt - -[Youtube](https://www.youtube.com/playlist?list=PLZzwFJOgBE3X-CylW6tD2jgxSYKTl_MrP) diff --git a/_config.yml b/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/advanced/SpliterRubberBand/SpliterRubberBand.sln b/advanced/SpliterRubberBand/SpliterRubberBand.sln deleted file mode 100644 index ba6199f..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpliterRubberBand", "SpliterRubberBand\SpliterRubberBand.vcxproj", "{9ABC49E8-6A56-4287-A81B-8E9886D572C9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9ABC49E8-6A56-4287-A81B-8E9886D572C9}.Debug|x64.ActiveCfg = Debug|x64 - {9ABC49E8-6A56-4287-A81B-8E9886D572C9}.Debug|x64.Build.0 = Debug|x64 - {9ABC49E8-6A56-4287-A81B-8E9886D572C9}.Release|x64.ActiveCfg = Release|x64 - {9ABC49E8-6A56-4287-A81B-8E9886D572C9}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E629984F-2811-49AD-990C-C33DD072E1D3} - EndGlobalSection -EndGlobal diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/MySplitter.cpp b/advanced/SpliterRubberBand/SpliterRubberBand/MySplitter.cpp deleted file mode 100644 index 72c0722..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/MySplitter.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include "MySplitter.h" -#include -#include "QMouseEvent" -MySplitter::MySplitter(QWidget* parent) - : QSplitter(parent) -{ - -}/* - -void MySplitter::mousePressEvent(QMouseEvent* event) -{ - throw std::logic_error("The method or operation is not implemented."); -} - -void MySplitter::mouseReleaseEvent(QMouseEvent* event) -{ - throw std::logic_error("The method or operation is not implemented."); -} - -void MySplitter::mouseMoveEvent(QMouseEvent* event) -{ - throw std::logic_error("The method or operation is not implemented."); -}*/ - -QSplitterHandle* MySplitter::createHandle() -{ - return new MySplitterHandle(this); -} - -MySplitter::MySplitterHandle::MySplitterHandle(QSplitter* parent) - : QSplitterHandle(Qt::Horizontal, parent) -{ - -} - - - -void MySplitter::MySplitterHandle::mouseReleaseEvent(QMouseEvent* event) -{ - splitter()->setRubberBand(-1); - - //auto* p = parentWidget(); - - auto pos =parentWidget()->mapFromGlobal(event->globalPos()); - - moveSplitter(closestLegalPosition( pos.x())); -} - -void MySplitter::MySplitterHandle::mouseMoveEvent(QMouseEvent* event) -{ - auto pos = parentWidget()->mapFromGlobal(event->globalPos()); - - splitter()->setRubberBand(closestLegalPosition(pos.x())); -} - -MySplitter* MySplitter::MySplitterHandle::splitter() -{ - return dynamic_cast(__super::splitter()); -} diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/MySplitter.h b/advanced/SpliterRubberBand/SpliterRubberBand/MySplitter.h deleted file mode 100644 index e72f31e..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/MySplitter.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once -#include "qsplitter.h" - -class MySplitter : - public QSplitter -{ -public: - MySplitter(QWidget* parent); -protected: - /* void mousePressEvent(QMouseEvent* event) override; - - - void mouseReleaseEvent(QMouseEvent* event) override; - - - void mouseMoveEvent(QMouseEvent* event) override;*/ - - - class MySplitterHandle : public QSplitterHandle { - public: - MySplitterHandle(QSplitter* parent); - - - void mouseReleaseEvent(QMouseEvent* event) override; - - - void mouseMoveEvent(QMouseEvent* event) override; - - MySplitter* splitter(); - }; - - QSplitterHandle* createHandle() override; - -}; - diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.cpp b/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.cpp deleted file mode 100644 index 5c07aca..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "SpliterRubberBand.h" - -SpliterRubberBand::SpliterRubberBand(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); -} diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.h b/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.h deleted file mode 100644 index a663480..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_SpliterRubberBand.h" - -class SpliterRubberBand : public QMainWindow -{ - Q_OBJECT - -public: - SpliterRubberBand(QWidget *parent = Q_NULLPTR); - -private: - Ui::SpliterRubberBandClass ui; -}; diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.qrc b/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.qrc deleted file mode 100644 index ce13868..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.ui b/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.ui deleted file mode 100644 index cb06635..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - SpliterRubberBandClass - - - - 0 - 0 - 600 - 400 - - - - SpliterRubberBand - - - - - - - Qt::Horizontal - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - - - 1 - - - - - 新建列 - - - - - 新建列 - - - - - 新建列 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - MySplitter - QSplitter -
mysplitter.h
- 1 -
-
- - - - -
diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.vcxproj b/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.vcxproj deleted file mode 100644 index a01bc12..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/SpliterRubberBand.vcxproj +++ /dev/null @@ -1,105 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {9ABC49E8-6A56-4287-A81B-8E9886D572C9} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/advanced/SpliterRubberBand/SpliterRubberBand/main.cpp b/advanced/SpliterRubberBand/SpliterRubberBand/main.cpp deleted file mode 100644 index 3a8358b..0000000 --- a/advanced/SpliterRubberBand/SpliterRubberBand/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "SpliterRubberBand.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - SpliterRubberBand w; - w.show(); - return a.exec(); -} diff --git a/advanced/thread/Thread/Thread.sln b/advanced/thread/Thread/Thread.sln deleted file mode 100644 index 16f2f28..0000000 --- a/advanced/thread/Thread/Thread.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30128.74 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Thread", "Thread\Thread.vcxproj", "{FE8706C7-C0C3-4D4F-9C41-54C915893BAE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FE8706C7-C0C3-4D4F-9C41-54C915893BAE}.Debug|x64.ActiveCfg = Debug|x64 - {FE8706C7-C0C3-4D4F-9C41-54C915893BAE}.Debug|x64.Build.0 = Debug|x64 - {FE8706C7-C0C3-4D4F-9C41-54C915893BAE}.Release|x64.ActiveCfg = Release|x64 - {FE8706C7-C0C3-4D4F-9C41-54C915893BAE}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BF1C4A6A-99A3-4317-9943-561188D3CC32} - EndGlobalSection -EndGlobal diff --git a/advanced/thread/Thread/Thread/Thread.cpp b/advanced/thread/Thread/Thread/Thread.cpp deleted file mode 100644 index e4c969a..0000000 --- a/advanced/thread/Thread/Thread/Thread.cpp +++ /dev/null @@ -1,99 +0,0 @@ -#include "Thread.h" -#include -#include -#include -#include "WorkerThread.h" - - -Thread::Thread(QWidget* parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.pushButton, &QPushButton::clicked, this, &Thread::save); - connect(ui.pushButton_set, &QPushButton::clicked, this, &Thread::set); - connect(ui.pushButton_test, &QPushButton::clicked, this, &Thread::test); - connect(ui.pushButton_main, &QPushButton::clicked, this, &Thread::mainTest); - connect(ui.pushButton_move, &QPushButton::clicked, this, &Thread::moveToThread); - - file.open(QIODevice::WriteOnly); -} - -void Thread::save() -{ - qDebug() << "Main thread ID: " << QThread::currentThreadId(); - - auto* thread = QThread::create([this]() { - //mutex.lock(); - //QMutexLocker locker(&mutex); - locker.lockForWrite(); - if (file.write(ui.lineEdit->text().toUtf8()) > 0) { - qDebug() << "write ok"; - } - else { - qDebug() << "write failed"; - } - //mutex.unlock(); - locker.unlock(); - qDebug() << "THREAD ID: " << QThread::currentThreadId(); - QThread::sleep(3); - }); - - thread->start(); -} - -void Thread::set() -{ - QThread::create([this](Thread* thread) { - for (;;) - { - save(); - } - - //QFile file("./setting.txt"); - //file.open(QIODevice::ReadOnly); - //thread->ui.lineEdit->setText(file.readAll()); - }, this)->start(); - - - -} - -void Thread::test() -{ - //WorkerThread* thread = new WorkerThread(this, this); - - //thread->start(); - file.close(); -} - -void Thread::mainTest() -{ - WorkerThread* thread = new WorkerThread(this, this); - thread->run(); -} - - -void Thread::moveToThread() -{ - Worker* worker = new Worker(this, nullptr); - - QThread* thread = new QThread(this); - - worker->moveToThread(thread); - - connect(thread, &QThread::started, worker, &Worker::run); - connect(worker, &Worker::finished, thread, &QThread::quit); - connect(thread, &QThread::finished, [=]() { - thread->deleteLater(); - worker->deleteLater(); - }); - - thread->start(); - -} - -QString Thread::text() const -{ - return ui.lineEdit->text(); -} diff --git a/advanced/thread/Thread/Thread/Thread.h b/advanced/thread/Thread/Thread/Thread.h deleted file mode 100644 index 977bc40..0000000 --- a/advanced/thread/Thread/Thread/Thread.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include -#include "ui_Thread.h" -#include -#include -#include -class Thread : public QMainWindow -{ - Q_OBJECT - -public: - Thread(QWidget *parent = Q_NULLPTR); - - -public slots: - void save(); - void set(); - void test(); - void mainTest(); - void moveToThread(); -public: - QString text() const; -private: - Ui::ThreadClass ui; - QFile file = { "./setting.txt" }; - QMutex mutex; - QReadWriteLock locker; -}; diff --git a/advanced/thread/Thread/Thread/Thread.qrc b/advanced/thread/Thread/Thread/Thread.qrc deleted file mode 100644 index b5935c7..0000000 --- a/advanced/thread/Thread/Thread/Thread.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/advanced/thread/Thread/Thread/Thread.ui b/advanced/thread/Thread/Thread/Thread.ui deleted file mode 100644 index 9c51e4f..0000000 --- a/advanced/thread/Thread/Thread/Thread.ui +++ /dev/null @@ -1,121 +0,0 @@ - - - ThreadClass - - - - 0 - 0 - 600 - 400 - - - - Thread - - - - - - 140 - 110 - 113 - 20 - - - - data - - - - - - 30 - 260 - 75 - 23 - - - - save - - - - - - 160 - 260 - 75 - 23 - - - - set - - - - - - 260 - 260 - 75 - 23 - - - - test - - - - - - 360 - 260 - 181 - 23 - - - - main_thread_test - - - - - - 374 - 290 - 161 - 23 - - - - move_to_thread - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/advanced/thread/Thread/Thread/Thread.vcxproj b/advanced/thread/Thread/Thread/Thread.vcxproj deleted file mode 100644 index b3528d6..0000000 --- a/advanced/thread/Thread/Thread/Thread.vcxproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {FE8706C7-C0C3-4D4F-9C41-54C915893BAE} - QtVS_v302 - 10.0.18362.0 - 10.0.18362.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/advanced/thread/Thread/Thread/WorkerThread.cpp b/advanced/thread/Thread/Thread/WorkerThread.cpp deleted file mode 100644 index 549f9b0..0000000 --- a/advanced/thread/Thread/Thread/WorkerThread.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "WorkerThread.h" -#include -WorkerThread::WorkerThread(Thread* thread, QObject *parent) - : QThread(parent) - , thread(thread) -{ - -} - -WorkerThread::~WorkerThread() -{ -} - -void WorkerThread::run() -{ - qDebug() << thread->text(); - - sleep(10); - - qDebug() << "exit..."; -} - -Worker::Worker(Thread* thread, QObject* parent) - : QObject(parent) - , thread(thread) -{ - -} - -Worker::~Worker() -{ - qDebug() << "~ worker deleted.."; -} - -void Worker::run() -{ - qDebug() << thread->text(); - - QThread::sleep(10); - - qDebug() << "exit..."; - emit finished(); -} diff --git a/advanced/thread/Thread/Thread/WorkerThread.h b/advanced/thread/Thread/Thread/WorkerThread.h deleted file mode 100644 index 86bf528..0000000 --- a/advanced/thread/Thread/Thread/WorkerThread.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include -#include "Thread.h" -class WorkerThread : public QThread -{ - Q_OBJECT - -public: - WorkerThread(Thread* thread, QObject *parent); - ~WorkerThread(); -public: - void run() override; - -private: - Thread* thread; -}; - - -class Worker : public QObject -{ - Q_OBJECT - -public: - Worker(Thread* thread, QObject* parent); - ~Worker(); -public: - void run(); -signals: - void finished(); -private: - Thread* thread; -}; - - diff --git a/advanced/thread/Thread/Thread/main.cpp b/advanced/thread/Thread/Thread/main.cpp deleted file mode 100644 index cdd9f18..0000000 --- a/advanced/thread/Thread/Thread/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Thread.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Thread w; - w.show(); - return a.exec(); -} diff --git a/advanced/thread/Thread/Thread/setting.txt b/advanced/thread/Thread/Thread/setting.txt deleted file mode 100644 index e69de29..0000000 diff --git a/advanced/translation/.gitignore b/advanced/translation/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/advanced/translation/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/advanced/translation/main.cpp b/advanced/translation/main.cpp deleted file mode 100644 index 3d772b2..0000000 --- a/advanced/translation/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "mainwindow.h" - -#include -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - - // { - QTranslator trans; - - if( trans.load("qtbase_zh_Cn.qm")){ - a.installTranslator(&trans); - } - // } - - QTranslator trans2; - - if( trans2.load("test.qm")){ - a.installTranslator(&trans2); - } - - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/advanced/translation/mainwindow.cpp b/advanced/translation/mainwindow.cpp deleted file mode 100644 index 2d69035..0000000 --- a/advanced/translation/mainwindow.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - ui->label->setText(tr("label")); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/advanced/translation/mainwindow.h b/advanced/translation/mainwindow.h deleted file mode 100644 index 4643e32..0000000 --- a/advanced/translation/mainwindow.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/advanced/translation/mainwindow.ui b/advanced/translation/mainwindow.ui deleted file mode 100644 index fe2bf93..0000000 --- a/advanced/translation/mainwindow.ui +++ /dev/null @@ -1,58 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 290 - 280 - 156 - 23 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 330 - 140 - 54 - 12 - - - - TextLabel - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/advanced/translation/test.ts b/advanced/translation/test.ts deleted file mode 100644 index 63e6e57..0000000 --- a/advanced/translation/test.ts +++ /dev/null @@ -1,22 +0,0 @@ - - - - - MainWindow - - - MainWindow - 窗口 - - - - TextLabel - 标签 - - - - label - 标签 - - - diff --git a/advanced/translation/translation.pro b/advanced/translation/translation.pro deleted file mode 100644 index 89aa181..0000000 --- a/advanced/translation/translation.pro +++ /dev/null @@ -1,33 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -TRANSLATIONS += test.ts - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/breakpad/MiniDump.cpp b/breakpad/MiniDump.cpp deleted file mode 100644 index 0a07935..0000000 --- a/breakpad/MiniDump.cpp +++ /dev/null @@ -1,101 +0,0 @@ -#include "pch.h" -#include "MiniDump.h" -#include "winrt/Simple.h" -#include "Model/LevelDB.h" -//#include "TaskForground.h" -//#include "App.xaml.h" -using namespace winrt; -using namespace winrt::Simple; - -using namespace google_breakpad; - -namespace net::winui { - - static void Client_ConnectedCallback(void* context, const google_breakpad::ClientInfo* client_info) { - LOG_INFO << "# connected." << std::endl; - } - - static void Client_ExitedCallback(void* context, const google_breakpad::ClientInfo* client_info) { - LOG_INFO << "# exit." << std::endl; - // temp resolve. - //Application::Current().as()->TaskForground()->Stop(); - } - void Client_UploadRequestCallback(void* context, const DWORD crash_id) { - - } - bool FilterCallback(void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion) - { - return true; - } - - bool MinidumpCallback(const wchar_t* dump_path, const wchar_t* minidump_id, void* context, EXCEPTION_POINTERS* exinfo, MDRawAssertionInfo* assertion, bool succeeded) { - MiniDump* p = static_cast(context); - - if (p->exception_handler->IsOutOfProcess()) - return p->exception_handler->RequestUpload(0); - return succeeded; - } - - MiniDump::MiniDump(hstring const& dumpPath, hstring const& name) { - std::filesystem::path p = std::wstring(dumpPath); - - if (!std::filesystem::exists(p /= "dump")) { - std::filesystem::create_directories(p); - } - - } - - MiniDump::~MiniDump() - { - - } - - bool MiniDump::startCrashServer() { - if (crash_server) { - return true; - } - - crash_server = new google_breakpad::CrashGenerationServer(std::wstring(m_info.second), - nullptr, - Client_ConnectedCallback, - nullptr, - [](void* /*context*/, const google_breakpad::ClientInfo* /*client_info*/, const std::wstring* /*dump_path*/) { - - }, - nullptr, - Client_ExitedCallback, - nullptr, - Client_UploadRequestCallback, - this, - false, - nullptr); - - - if (!crash_server->Start()) { - reset(); - return false; - } - return true; - } - - void MiniDump::stopCrashServer() { - reset(); - } - - void MiniDump::reset() - { - delete crash_server; - crash_server = nullptr; - } - - void MiniDump::StartClient() - { - google_breakpad::CustomClientInfo custom_info = { }; - - exception_handler = std::make_unique(std::wstring(m_info.first), - FilterCallback, MinidumpCallback, this, ExceptionHandler::HandlerType::HANDLER_ALL, MiniDumpNormal, m_info.second.c_str(), &custom_info); -#ifdef _DEV - exception_handler->set_handle_debug_exceptions(true); -#endif // _DEBUG - } -} \ No newline at end of file diff --git a/breakpad/MiniDump.h b/breakpad/MiniDump.h deleted file mode 100644 index 347059a..0000000 --- a/breakpad/MiniDump.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once - -namespace net::winui { - struct MiniDump : implements - { - google_breakpad::CrashGenerationServer* crash_server = nullptr; - - std::unique_ptr exception_handler; - - std::pair m_info; - - MiniDump(winrt::hstring const& dumpPath, winrt::hstring const& name); - ~MiniDump(); - - void StartClient(); - bool startCrashServer(); - void stopCrashServer(); - - - void reset(); - - }; - -} \ No newline at end of file diff --git a/c++/Boost_Pool/Boost_Pool.sln b/c++/Boost_Pool/Boost_Pool.sln deleted file mode 100644 index beb989a..0000000 --- a/c++/Boost_Pool/Boost_Pool.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Boost_Pool", "Boost_Pool\Boost_Pool.vcxproj", "{CE16100B-BD4B-47C0-885B-C81277287012}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CE16100B-BD4B-47C0-885B-C81277287012}.Debug|x64.ActiveCfg = Debug|x64 - {CE16100B-BD4B-47C0-885B-C81277287012}.Debug|x64.Build.0 = Debug|x64 - {CE16100B-BD4B-47C0-885B-C81277287012}.Debug|x86.ActiveCfg = Debug|Win32 - {CE16100B-BD4B-47C0-885B-C81277287012}.Debug|x86.Build.0 = Debug|Win32 - {CE16100B-BD4B-47C0-885B-C81277287012}.Release|x64.ActiveCfg = Release|x64 - {CE16100B-BD4B-47C0-885B-C81277287012}.Release|x64.Build.0 = Release|x64 - {CE16100B-BD4B-47C0-885B-C81277287012}.Release|x86.ActiveCfg = Release|Win32 - {CE16100B-BD4B-47C0-885B-C81277287012}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7DB7CD8E-D381-4ADE-8302-9A91C13EEFAE} - EndGlobalSection -EndGlobal diff --git a/c++/Boost_Pool/Boost_Pool/Boost_Pool.cpp b/c++/Boost_Pool/Boost_Pool/Boost_Pool.cpp deleted file mode 100644 index 87f322d..0000000 --- a/c++/Boost_Pool/Boost_Pool/Boost_Pool.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Boost_Pool.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include -#define MAX_COUNT 100000000 -int main() -{ - - { - std::vector v; - auto start = std::chrono::system_clock::now(); - for (int i = 0; i < MAX_COUNT; ++i) - v.push_back(i); - auto end = std::chrono::system_clock::now(); - std::chrono::duration diff = end - start; - std::cout << "# 1.elapse: " << diff.count() << std::endl; - } - - - - - { - - - std::vector> v; - auto start = std::chrono::system_clock::now(); - for (int i = 0; i < MAX_COUNT; ++i) - v.push_back(i); - - auto end = std::chrono::system_clock::now(); - std::chrono::duration diff = end - start; - std::cout << "# 2.elapse: " << diff.count() << std::endl; - - v.clear(); - boost::singleton_pool:: - purge_memory(); - } - -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/Boost_Pool/Boost_Pool/Boost_Pool.vcxproj b/c++/Boost_Pool/Boost_Pool/Boost_Pool.vcxproj deleted file mode 100644 index ce6fd9d..0000000 --- a/c++/Boost_Pool/Boost_Pool/Boost_Pool.vcxproj +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {ce16100b-bd4b-47c0-885b-c81277287012} - BoostPool - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/ConsoleApplication1/ConsoleApplication1.sln b/c++/ConsoleApplication1/ConsoleApplication1.sln deleted file mode 100644 index b3063b4..0000000 --- a/c++/ConsoleApplication1/ConsoleApplication1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.vcxproj", "{23690146-FE74-42F7-BC7A-BEAE2C6024DA}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Debug|x64.ActiveCfg = Debug|x64 - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Debug|x64.Build.0 = Debug|x64 - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Debug|x86.ActiveCfg = Debug|Win32 - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Debug|x86.Build.0 = Debug|Win32 - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Release|x64.ActiveCfg = Release|x64 - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Release|x64.Build.0 = Release|x64 - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Release|x86.ActiveCfg = Release|Win32 - {23690146-FE74-42F7-BC7A-BEAE2C6024DA}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BEE466C6-BB20-469D-BB73-CEFB072C6A1A} - EndGlobalSection -EndGlobal diff --git a/c++/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.cpp b/c++/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.cpp deleted file mode 100644 index 2bfb22c..0000000 --- a/c++/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -int main() -{ - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.vcxproj b/c++/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.vcxproj deleted file mode 100644 index eb622d0..0000000 --- a/c++/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {23690146-fe74-42f7-bc7a-beae2c6024da} - ConsoleApplication1 - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/Construtor/Construtor.sln b/c++/Construtor/Construtor.sln deleted file mode 100644 index f340ed8..0000000 --- a/c++/Construtor/Construtor.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Construtor", "Construtor\Construtor.vcxproj", "{ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Debug|x64.ActiveCfg = Debug|x64 - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Debug|x64.Build.0 = Debug|x64 - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Debug|x86.ActiveCfg = Debug|Win32 - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Debug|x86.Build.0 = Debug|Win32 - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Release|x64.ActiveCfg = Release|x64 - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Release|x64.Build.0 = Release|x64 - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Release|x86.ActiveCfg = Release|Win32 - {ED533CBC-7C84-4C9E-BBC3-E6B4A24C2E8D}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F29E23C6-0644-46AB-AEF3-785013F40FBF} - EndGlobalSection -EndGlobal diff --git a/c++/Construtor/Construtor/Construtor.cpp b/c++/Construtor/Construtor/Construtor.cpp deleted file mode 100644 index 439f9f5..0000000 --- a/c++/Construtor/Construtor/Construtor.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Construtor.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -int init_age() { - std::cout << "init age" << __FUNCTION__ << std::endl; - return 0; -} -int init_color() { - std::cout << "init color" << __FUNCTION__ << std::endl; - return 0; -} - - - -class Animal { -public: - static int test_this(Animal* e) { - return e->extra; - } - Animal() try : color(init_color()), age(init_age()) { - - } - catch (...) { - - } - /*animal(int age) : age(test_this(this)) { - - - }*/ - - Animal(int age, int color) : age(age), color(color) { - - } - Animal(int age) :Animal(age, 0xff) { - - } - -public: - int getAge() { return age; } -private: - int color = 0xfffff; - int age = 0; - - int extra = 0xff; -}; - -class Dog : public Animal { -public: - Dog() { - - } - Dog(int age) : Animal(age) {} -}; -int main() -{ - Dog dog; - - Dog dog2 = 5; - - std::cout << dog.getAge() << std::endl; - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/Construtor/Construtor/Construtor.vcxproj b/c++/Construtor/Construtor/Construtor.vcxproj deleted file mode 100644 index daf63e4..0000000 --- a/c++/Construtor/Construtor/Construtor.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {ed533cbc-7c84-4c9e-bbc3-e6b4a24c2e8d} - Construtor - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/Loop/Loop.sln b/c++/Loop/Loop.sln deleted file mode 100644 index ec990c0..0000000 --- a/c++/Loop/Loop.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Loop", "Loop\Loop.vcxproj", "{0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Debug|x64.ActiveCfg = Debug|x64 - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Debug|x64.Build.0 = Debug|x64 - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Debug|x86.ActiveCfg = Debug|Win32 - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Debug|x86.Build.0 = Debug|Win32 - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Release|x64.ActiveCfg = Release|x64 - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Release|x64.Build.0 = Release|x64 - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Release|x86.ActiveCfg = Release|Win32 - {0D2A8CB8-C071-4307-B7C2-2E2CB6E85649}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {10BE13BB-80BB-41AB-B2CB-D8DABCD8CE73} - EndGlobalSection -EndGlobal diff --git a/c++/Loop/Loop/Loop.cpp b/c++/Loop/Loop/Loop.cpp deleted file mode 100644 index 599f6e7..0000000 --- a/c++/Loop/Loop/Loop.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Loop.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -int main() -{ - // 1 - for (;;) { - break; - } - - // 2 - - while (true) { - break; - } - - int n = 10; - // 3 - do { - n++; - break; - } while ( n > 15); - - // 4 - - -label: - n--; - std::cout << n << std::endl; - - goto label; - - std::cout << "hello world" << std::endl; - -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/Loop/Loop/Loop.vcxproj b/c++/Loop/Loop/Loop.vcxproj deleted file mode 100644 index 6f57269..0000000 --- a/c++/Loop/Loop/Loop.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {0d2a8cb8-c071-4307-b7c2-2e2cb6e85649} - Loop - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/PtrContainer/PtrContainer.sln b/c++/PtrContainer/PtrContainer.sln deleted file mode 100644 index 76b967b..0000000 --- a/c++/PtrContainer/PtrContainer.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PtrContainer", "PtrContainer\PtrContainer.vcxproj", "{D8323534-E73C-4A77-B8DB-1DAA3FE0A664}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Debug|x64.ActiveCfg = Debug|x64 - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Debug|x64.Build.0 = Debug|x64 - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Debug|x86.ActiveCfg = Debug|Win32 - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Debug|x86.Build.0 = Debug|Win32 - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Release|x64.ActiveCfg = Release|x64 - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Release|x64.Build.0 = Release|x64 - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Release|x86.ActiveCfg = Release|Win32 - {D8323534-E73C-4A77-B8DB-1DAA3FE0A664}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {EA1E1FDA-3144-4A60-8AC3-8FEEA6ABD173} - EndGlobalSection -EndGlobal diff --git a/c++/PtrContainer/PtrContainer/PtrContainer.cpp b/c++/PtrContainer/PtrContainer/PtrContainer.cpp deleted file mode 100644 index 32fdae2..0000000 --- a/c++/PtrContainer/PtrContainer/PtrContainer.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// PtrContainer.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include -#include -class animal { -public: - std::string name; - - int legs; - - bool has_tail; - - - std::ostream& operator<< (std::ostream& os) const { - os << "name: " << name << '\n' - << "legs: " << legs << "\n" - << "tail: " << has_tail; - - return os; - } - friend std::ostream& operator<< (std::ostream& os, const animal& a) { - os << "name: " << a.name << '\n' - << "legs: " << a.legs << "\n" - << "tail: " << a.has_tail; - - return os; - } - constexpr bool operator()(const animal& _Left, const animal& _Right) const { - return _Left.legs < _Right.legs; - } -}; - -//std::ostream& operator<< (std::ostream& os, const animal& a) { -// os << "name: " << a.name << '\n' -// << "legs: " << a.legs << "\n" -// << "tail: " << a.has_tail; -// -// return os; -//} - - - -int main() -{ - boost::ptr_set animals; - - animals.insert(new animal{ "dog", 4, true }); - animals.insert(new animal{ "cat", 1, true }); - animals.insert(new animal{ "duck", 2, false }); - - - const animal obj = *animals.begin(); - - //std::ostream myout(std::cout.rdbuf()); - - obj.operator<<(std::cout); - std::cout << obj; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/PtrContainer/PtrContainer/PtrContainer.vcxproj b/c++/PtrContainer/PtrContainer/PtrContainer.vcxproj deleted file mode 100644 index 947d3e1..0000000 --- a/c++/PtrContainer/PtrContainer/PtrContainer.vcxproj +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {d8323534-e73c-4a77-b8db-1daa3fe0a664} - PtrContainer - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/ScopeExit/ScopeExit.sln b/c++/ScopeExit/ScopeExit.sln deleted file mode 100644 index 2ff01a1..0000000 --- a/c++/ScopeExit/ScopeExit.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScopeExit", "ScopeExit\ScopeExit.vcxproj", "{416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Debug|x64.ActiveCfg = Debug|x64 - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Debug|x64.Build.0 = Debug|x64 - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Debug|x86.ActiveCfg = Debug|Win32 - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Debug|x86.Build.0 = Debug|Win32 - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Release|x64.ActiveCfg = Release|x64 - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Release|x64.Build.0 = Release|x64 - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Release|x86.ActiveCfg = Release|Win32 - {416E8FB5-1EA7-4DDE-9C6B-09B9A56BC698}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2322C74F-CF09-4238-B7EE-BEFA34C9534B} - EndGlobalSection -EndGlobal diff --git a/c++/ScopeExit/ScopeExit/ScopeExit.cpp b/c++/ScopeExit/ScopeExit/ScopeExit.cpp deleted file mode 100644 index d683367..0000000 --- a/c++/ScopeExit/ScopeExit/ScopeExit.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// ScopeExit.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -#include -#include - -int* foo() -{ - int* i = new int{ 10 }; - BOOST_SCOPE_EXIT(&i) - { - delete i; - i = 0; - } BOOST_SCOPE_EXIT_END - std::cout << *i << '\n'; - return i; -} - -void test(int*& p) { - delete p; - p = 0; - -} - -int main() -{ - int* j = foo(); - - int* p = new int(10); - - - test(p); - - - - std::cout << j << '\n'; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/ScopeExit/ScopeExit/ScopeExit.vcxproj b/c++/ScopeExit/ScopeExit/ScopeExit.vcxproj deleted file mode 100644 index 9879cfa..0000000 --- a/c++/ScopeExit/ScopeExit/ScopeExit.vcxproj +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {416e8fb5-1ea7-4dde-9c6b-09b9a56bc698} - ScopeExit - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/SharedMemory1/SharedMemory1.sln b/c++/SharedMemory1/SharedMemory1.sln deleted file mode 100644 index 5af2a08..0000000 --- a/c++/SharedMemory1/SharedMemory1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31624.102 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SharedMemory1", "SharedMemory1\SharedMemory1.vcxproj", "{928CC868-6C4D-4639-BA47-2346042E3219}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {928CC868-6C4D-4639-BA47-2346042E3219}.Debug|x64.ActiveCfg = Debug|x64 - {928CC868-6C4D-4639-BA47-2346042E3219}.Debug|x64.Build.0 = Debug|x64 - {928CC868-6C4D-4639-BA47-2346042E3219}.Debug|x86.ActiveCfg = Debug|Win32 - {928CC868-6C4D-4639-BA47-2346042E3219}.Debug|x86.Build.0 = Debug|Win32 - {928CC868-6C4D-4639-BA47-2346042E3219}.Release|x64.ActiveCfg = Release|x64 - {928CC868-6C4D-4639-BA47-2346042E3219}.Release|x64.Build.0 = Release|x64 - {928CC868-6C4D-4639-BA47-2346042E3219}.Release|x86.ActiveCfg = Release|Win32 - {928CC868-6C4D-4639-BA47-2346042E3219}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1D1AE6E6-CA24-41FE-A3B2-507C653A3632} - EndGlobalSection -EndGlobal diff --git a/c++/SharedMemory1/SharedMemory1/SharedMemory1.cpp b/c++/SharedMemory1/SharedMemory1/SharedMemory1.cpp deleted file mode 100644 index 2c47879..0000000 --- a/c++/SharedMemory1/SharedMemory1/SharedMemory1.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// SharedMemory1.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -//#include -#include -#include -//#include -#include -#include -#include -#include - -using namespace boost::interprocess; - -typedef allocator ShmemAllocatorV; -typedef vector MyVector; - - - -typedef allocator CharAllocator; -typedef std::basic_string, CharAllocator> MyString; - - - -typedef MyString KeyType; -typedef MyVector MappedType; -typedef std::pair ValueType; -typedef allocator ShmemAllocatorMap; -typedef map, ShmemAllocatorMap> MyMap; - - - -struct __Named -{ - static inline const char* shared_memory_name = "MySharedMemory"; - static inline const char* image_map_name = "MyMap"; - static inline const char* image_vec_name = "MyVec"; - static inline const char* image_string_name = "MyString"; -}; - - - -int main() -{ - boost::interprocess::named_semaphore sem(open_or_create, "sem", 0); - - struct shm_remove - { - //shm_remove() { shared_memory_object::remove(__Named::shared_memory_name); } - ~shm_remove() { shared_memory_object::remove(__Named::shared_memory_name); } - } remover; - - try - { - std::string id = "abcdefg"; - std::vector image; - - - for (int i = 0; i < 10; ++i) - { - image.push_back(i); - } - - managed_windows_shared_memory segment(create_only, __Named::shared_memory_name, 4096); - - - MyVector* myvector = segment.construct(__Named::image_vec_name)(image.begin(), image.end(), segment.get_segment_manager()); - - - MyString* mystring = segment.construct(__Named::image_string_name)(id, segment.get_segment_manager()); - - MyMap* mymap = segment.construct(__Named::image_map_name)(segment.get_segment_manager()); - mymap->insert(std::make_pair(*mystring, *myvector)); - - sem.post(); - - std::cout << "exit!" << std::endl; - - } - catch (const interprocess_exception& err) - { - std::cout << err.get_error_code() << ", " << err.what() << std::endl; - } -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/SharedMemory1/SharedMemory1/SharedMemory1.vcxproj b/c++/SharedMemory1/SharedMemory1/SharedMemory1.vcxproj deleted file mode 100644 index 8cb1b03..0000000 --- a/c++/SharedMemory1/SharedMemory1/SharedMemory1.vcxproj +++ /dev/null @@ -1,152 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {928cc868-6c4d-4639-ba47-2346042e3219} - SharedMemory1 - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdc17 - stdcpp17 - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/SharedMemory2/SharedMemory2.sln b/c++/SharedMemory2/SharedMemory2.sln deleted file mode 100644 index 21e3080..0000000 --- a/c++/SharedMemory2/SharedMemory2.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31624.102 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SharedMemory2", "SharedMemory2\SharedMemory2.vcxproj", "{C73D77F2-30B0-4BCF-BF88-7E9D96E93053}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Debug|x64.ActiveCfg = Debug|x64 - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Debug|x64.Build.0 = Debug|x64 - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Debug|x86.ActiveCfg = Debug|Win32 - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Debug|x86.Build.0 = Debug|Win32 - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Release|x64.ActiveCfg = Release|x64 - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Release|x64.Build.0 = Release|x64 - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Release|x86.ActiveCfg = Release|Win32 - {C73D77F2-30B0-4BCF-BF88-7E9D96E93053}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {61F4DEB7-EB3E-4DBF-9B66-400B5D0756CA} - EndGlobalSection -EndGlobal diff --git a/c++/SharedMemory2/SharedMemory2/SharedMemory2.cpp b/c++/SharedMemory2/SharedMemory2/SharedMemory2.cpp deleted file mode 100644 index 65789ee..0000000 --- a/c++/SharedMemory2/SharedMemory2/SharedMemory2.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// SharedMemory2.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include -#include -#include -#include -using namespace boost::interprocess; - -typedef allocator ShmemAllocatorV; -typedef vector MyVector; - - - -typedef allocator CharAllocator; -typedef std::basic_string, CharAllocator> MyString; - - - -typedef MyString KeyType; -typedef MyVector MappedType; -typedef std::pair ValueType; -typedef allocator ShmemAllocatorMap; -typedef map, ShmemAllocatorMap> MyMap; - - -struct __Named -{ - static inline const char* shared_memory_name = "MySharedMemory"; - static inline const char* image_map_name = "MyMap"; - static inline const char* image_vec_name = "MyVec"; - static inline const char* image_string_name = "MyString"; -}; -int main() -{ - boost::interprocess::named_semaphore sem(open_or_create, "sem", 0); - struct shm_remove - { - ~shm_remove() { shared_memory_object::remove(__Named::shared_memory_name); } - - } remover; - - try - { - - sem.wait(); - - managed_windows_shared_memory segment(open_only, __Named::shared_memory_name); - - MyVector* myvector = segment.find(__Named::image_vec_name).first; - - - std::vector vec; - std::copy(myvector->begin(), myvector->end(), std::back_inserter(vec)); - - segment.destroy(__Named::image_map_name); - - } - catch (const interprocess_exception& err) - { - std::cout << err.get_error_code() << ", " << err.what() << std::endl; - } -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/SharedMemory2/SharedMemory2/SharedMemory2.vcxproj b/c++/SharedMemory2/SharedMemory2/SharedMemory2.vcxproj deleted file mode 100644 index e8a8a8d..0000000 --- a/c++/SharedMemory2/SharedMemory2/SharedMemory2.vcxproj +++ /dev/null @@ -1,151 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {c73d77f2-30b0-4bcf-bf88-7e9d96e93053} - SharedMemory2 - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/SmartPtr/SmartPtr.sln b/c++/SmartPtr/SmartPtr.sln deleted file mode 100644 index 8e15c4e..0000000 --- a/c++/SmartPtr/SmartPtr.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SmartPtr", "SmartPtr\SmartPtr.vcxproj", "{564EDF2E-2525-458A-96D3-253F1F768AD6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Debug|x64.ActiveCfg = Debug|x64 - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Debug|x64.Build.0 = Debug|x64 - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Debug|x86.ActiveCfg = Debug|Win32 - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Debug|x86.Build.0 = Debug|Win32 - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Release|x64.ActiveCfg = Release|x64 - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Release|x64.Build.0 = Release|x64 - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Release|x86.ActiveCfg = Release|Win32 - {564EDF2E-2525-458A-96D3-253F1F768AD6}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {71549D71-8769-4C52-86A7-164C10C34BFB} - EndGlobalSection -EndGlobal diff --git a/c++/SmartPtr/SmartPtr/SmartPtr.cpp b/c++/SmartPtr/SmartPtr/SmartPtr.cpp deleted file mode 100644 index 277b512..0000000 --- a/c++/SmartPtr/SmartPtr/SmartPtr.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// SmartPtr.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -std::weak_ptr gw; - -void observe() -{ - std::cout << "use_count == " << gw.use_count() << ": "; - if (auto spt = gw.lock()) { // Has to be copied into a shared_ptr before usage - std::cout << *spt << "\n"; - } - else { - std::cout << "gw is expired\n"; - } -} - - -int main() -{ - gw = std::make_shared(42); - - - - observe(); - - { - - std::unique_ptr u = std::make_unique(2); - } - - int* p = new int(6); - { - { - - std::shared_ptr p1( p ); - - } - { - - std::shared_ptr p2(p); - } - - } - - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/SmartPtr/SmartPtr/SmartPtr.vcxproj b/c++/SmartPtr/SmartPtr/SmartPtr.vcxproj deleted file mode 100644 index 0c9089c..0000000 --- a/c++/SmartPtr/SmartPtr/SmartPtr.vcxproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {564edf2e-2525-458a-96d3-253f1f768ad6} - SmartPtr - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp17 - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/StringCompare/StringCompare.sln b/c++/StringCompare/StringCompare.sln deleted file mode 100644 index 293f319..0000000 --- a/c++/StringCompare/StringCompare.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31004.235 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StringCompare", "StringCompare\StringCompare.vcxproj", "{39B4DA63-FCFA-4A46-9642-37BF4484BC00}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Debug|x64.ActiveCfg = Debug|x64 - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Debug|x64.Build.0 = Debug|x64 - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Debug|x86.ActiveCfg = Debug|Win32 - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Debug|x86.Build.0 = Debug|Win32 - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Release|x64.ActiveCfg = Release|x64 - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Release|x64.Build.0 = Release|x64 - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Release|x86.ActiveCfg = Release|Win32 - {39B4DA63-FCFA-4A46-9642-37BF4484BC00}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {39E50123-1203-433F-AECE-4A4FED738E6B} - EndGlobalSection -EndGlobal diff --git a/c++/StringCompare/StringCompare/StringCompare.cpp b/c++/StringCompare/StringCompare/StringCompare.cpp deleted file mode 100644 index dcd874f..0000000 --- a/c++/StringCompare/StringCompare/StringCompare.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// StringCompare.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include -#include -using namespace boost::algorithm; - -int main() -{ - /*std::string s = "Boost"; - std::cout.setf(std::ios::boolalpha); - - std::cout << lexicographical_compare(s, "Boost2") << '\n';*/ - - std::string s = "Boost C++ Libraries"; - boost::iterator_range r = - find_regex(s, boost::regex{ "\\w\\+\\+" }); - std::cout << r << '\n'; -} -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/StringCompare/StringCompare/StringCompare.vcxproj b/c++/StringCompare/StringCompare/StringCompare.vcxproj deleted file mode 100644 index d183763..0000000 --- a/c++/StringCompare/StringCompare/StringCompare.vcxproj +++ /dev/null @@ -1,150 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {39b4da63-fcfa-4a46-9642-37bf4484bc00} - StringCompare - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/Test05/Test05.sln b/c++/Test05/Test05.sln deleted file mode 100644 index 7d633f7..0000000 --- a/c++/Test05/Test05.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test05", "Test05\Test05.vcxproj", "{1501AA19-08A6-4762-A046-6E2B6984B463}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1501AA19-08A6-4762-A046-6E2B6984B463}.Debug|x64.ActiveCfg = Debug|x64 - {1501AA19-08A6-4762-A046-6E2B6984B463}.Debug|x64.Build.0 = Debug|x64 - {1501AA19-08A6-4762-A046-6E2B6984B463}.Debug|x86.ActiveCfg = Debug|Win32 - {1501AA19-08A6-4762-A046-6E2B6984B463}.Debug|x86.Build.0 = Debug|Win32 - {1501AA19-08A6-4762-A046-6E2B6984B463}.Release|x64.ActiveCfg = Release|x64 - {1501AA19-08A6-4762-A046-6E2B6984B463}.Release|x64.Build.0 = Release|x64 - {1501AA19-08A6-4762-A046-6E2B6984B463}.Release|x86.ActiveCfg = Release|Win32 - {1501AA19-08A6-4762-A046-6E2B6984B463}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {70796CC3-F33C-485C-A5D8-0AF114DE26DE} - EndGlobalSection -EndGlobal diff --git a/c++/Test05/Test05/Test05.cpp b/c++/Test05/Test05/Test05.cpp deleted file mode 100644 index 7afeeed..0000000 --- a/c++/Test05/Test05/Test05.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// Test05.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -int main() -{ - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/Test05/Test05/Test05.vcxproj b/c++/Test05/Test05/Test05.vcxproj deleted file mode 100644 index 33d30e5..0000000 --- a/c++/Test05/Test05/Test05.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {1501aa19-08a6-4762-a046-6e2b6984b463} - Test05 - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/Thread/Thread.sln b/c++/Thread/Thread.sln deleted file mode 100644 index 042659d..0000000 --- a/c++/Thread/Thread.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31025.218 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Thread", "Thread\Thread.vcxproj", "{695D89C8-0223-429E-A483-AE085E2F3B36}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {695D89C8-0223-429E-A483-AE085E2F3B36}.Debug|x64.ActiveCfg = Debug|x64 - {695D89C8-0223-429E-A483-AE085E2F3B36}.Debug|x64.Build.0 = Debug|x64 - {695D89C8-0223-429E-A483-AE085E2F3B36}.Debug|x86.ActiveCfg = Debug|Win32 - {695D89C8-0223-429E-A483-AE085E2F3B36}.Debug|x86.Build.0 = Debug|Win32 - {695D89C8-0223-429E-A483-AE085E2F3B36}.Release|x64.ActiveCfg = Release|x64 - {695D89C8-0223-429E-A483-AE085E2F3B36}.Release|x64.Build.0 = Release|x64 - {695D89C8-0223-429E-A483-AE085E2F3B36}.Release|x86.ActiveCfg = Release|Win32 - {695D89C8-0223-429E-A483-AE085E2F3B36}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {96BE3FD6-F369-4203-AD2C-8F50DD50D725} - EndGlobalSection -EndGlobal diff --git a/c++/Thread/Thread/Thread.cpp b/c++/Thread/Thread/Thread.cpp deleted file mode 100644 index 2a7a7f8..0000000 --- a/c++/Thread/Thread/Thread.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Thread.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include - -using namespace std::literals; -void thread() -{ - for (int i = 0; i < 5; ++i) - { - std::this_thread::sleep_for(1s); - - std::cout << i << '\n'; - } -} - -int main() -{ - boost::thread t{ thread }; - t.join(); - -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/Thread/Thread/Thread.vcxproj b/c++/Thread/Thread/Thread.vcxproj deleted file mode 100644 index 04aafa3..0000000 --- a/c++/Thread/Thread/Thread.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {695d89c8-0223-429e-a483-ae085e2f3b36} - Thread - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/Variadic_Template/ConsoleApplication1.sln b/c++/Variadic_Template/ConsoleApplication1.sln deleted file mode 100644 index b82f07a..0000000 --- a/c++/Variadic_Template/ConsoleApplication1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.32014.148 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.vcxproj", "{1017F537-BB53-447F-B7A2-5D59D2C28AE6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Debug|x64.ActiveCfg = Debug|x64 - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Debug|x64.Build.0 = Debug|x64 - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Debug|x86.ActiveCfg = Debug|Win32 - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Debug|x86.Build.0 = Debug|Win32 - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Release|x64.ActiveCfg = Release|x64 - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Release|x64.Build.0 = Release|x64 - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Release|x86.ActiveCfg = Release|Win32 - {1017F537-BB53-447F-B7A2-5D59D2C28AE6}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2976741D-4C08-4452-B939-746CC153BC36} - EndGlobalSection -EndGlobal diff --git a/c++/Variadic_Template/ConsoleApplication1/ConsoleApplication1.cpp b/c++/Variadic_Template/ConsoleApplication1/ConsoleApplication1.cpp deleted file mode 100644 index 66616c8..0000000 --- a/c++/Variadic_Template/ConsoleApplication1/ConsoleApplication1.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - - -class A { -public: - A(A* ptr) { - std::cout << "called 1" << std::endl; - } - - template - A(void *p, TArgs&&... args) { - std::cout << "called 2" << std::endl; - } - template< typename... TArgs, typename = std::enable_if_t>> - A(TArgs&&... args) { - std::cout << "called 3" << std::endl; - } -}; -int main() -{ - int p1 = 5; - int p2 = 6; - auto a = new A(&p1); - - - - new A(a); - new A(p1); - new A(p2); - new A(nullptr,p1, p2); -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/Variadic_Template/ConsoleApplication1/ConsoleApplication1.vcxproj b/c++/Variadic_Template/ConsoleApplication1/ConsoleApplication1.vcxproj deleted file mode 100644 index 6c7bc3a..0000000 --- a/c++/Variadic_Template/ConsoleApplication1/ConsoleApplication1.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {1017f537-bb53-447f-b7a2-5d59d2c28ae6} - ConsoleApplication1 - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/Variadic_Template/ConsoleApplication1/Format.h b/c++/Variadic_Template/ConsoleApplication1/Format.h deleted file mode 100644 index bab958f..0000000 --- a/c++/Variadic_Template/ConsoleApplication1/Format.h +++ /dev/null @@ -1,180 +0,0 @@ -// -// Format.h -// -// Library: Foundation -// Package: Core -// Module: Format -// -// Definition of the format freestanding function. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_Format_INCLUDED -#define Foundation_Format_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Any.h" -#include -#include - - -namespace Poco { - - - std::string Foundation_API format(const std::string& fmt, const Any& value); - /// This function implements sprintf-style formatting in a typesafe way. - /// Various variants of the function are available, supporting a - /// different number of arguments (up to six). - /// - /// The formatting is controlled by the format string in fmt. - /// Format strings are quite similar to those of the std::printf() function, but - /// there are some minor differences. - /// - /// The format string can consist of any sequence of characters; certain - /// characters have a special meaning. Characters without a special meaning - /// are copied verbatim to the result. A percent sign (%) marks the beginning - /// of a format specification. Format specifications have the following syntax: - /// - /// %[][][][.][] - /// - /// Index, flags, width, precision and prefix are optional. The only required part of - /// the format specification, apart from the percent sign, is the type. - /// - /// The optional index argument has the format "[]" and allows to - /// address an argument by its zero-based position (see the example below). - /// - /// Following are valid type specifications and their meaning: - /// - /// * b boolean (true = 1, false = 0) - /// * c character - /// * d signed decimal integer - /// * i signed decimal integer - /// * o unsigned octal integer - /// * u unsigned decimal integer - /// * x unsigned hexadecimal integer (lower case) - /// * X unsigned hexadecimal integer (upper case) - /// * e signed floating-point value in the form [-]d.dddde[]dd[d] - /// * E signed floating-point value in the form [-]d.ddddE[]dd[d] - /// * f signed floating-point value in the form [-]dddd.dddd - /// * s std::string - /// * z std::size_t - /// - /// The following flags are supported: - /// - /// * - left align the result within the given field width - /// * + prefix the output value with a sign (+ or -) if the output value is of a signed type - /// * 0 if width is prefixed with 0, zeros are added until the minimum width is reached - /// * # For o, x, X, the # flag prefixes any nonzero output value with 0, 0x, or 0X, respectively; - /// for e, E, f, the # flag forces the output value to contain a decimal point in all cases. - /// - /// The following modifiers are supported: - /// - /// * (none) argument is char (c), int (d, i), unsigned (o, u, x, X) double (e, E, f, g, G) or string (s) - /// * l argument is long (d, i), unsigned long (o, u, x, X) or long double (e, E, f, g, G) - /// * L argument is long long (d, i), unsigned long long (o, u, x, X) - /// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G) - /// * ? argument is any signed or unsigned int, short, long, or 64-bit integer (d, i, o, x, X) - /// - /// The width argument is a nonnegative decimal integer or '*' with an additional nonnegative integer value - /// preceding the value to be formated, controlling the minimum number of characters printed. - /// If the number of characters in the output value is less than the specified width, blanks or - /// leading zeros are added, according to the specified flags (-, +, 0). - /// - /// Precision is a nonnegative decimal integer or '*' with an additional nonnegative integer value preceding - /// the value to be formated, preceded by a period (.), which specifies the number of characters - /// to be printed, the number of decimal places, or the number of significant digits. - /// - /// Throws an InvalidArgumentException if an argument index is out of range. - /// - /// Starting with release 1.4.3, an argument that does not match the format - /// specifier no longer results in a BadCastException. The string [ERRFMT] is - /// written to the result string instead. - /// - /// If there are more format specifiers than values, the format specifiers without a corresponding value - /// are copied verbatim to output. - /// - /// If there are more values than format specifiers, the superfluous values are ignored. - /// - /// Usage Examples: - /// std::string s1 = format("The answer to life, the universe, and everything is %d", 42); - /// std::string s2 = format("second: %[1]d, first: %[0]d", 1, 2); - - void Foundation_API format(std::string& result, const char* fmt, const std::vector& values); - /// Supports a variable number of arguments and is used by - /// all other variants of format(). - - void Foundation_API format(std::string& result, const std::string& fmt, const std::vector& values); - /// Supports a variable number of arguments and is used by - /// all other variants of format(). - - - template < - typename T, typename std::enable_if_t, std::vector>>, - typename... Args> - void format(std::string& result, const std::string& fmt, T arg1, Args... args) - /// Appends the formatted string to result. - { - std::vector values; - values.reserve(sizeof...(Args) + 1); - values.emplace_back(arg1); - values.insert(values.end(), { args... }); - ::format(result, fmt, values); - } - - - template < - typename T, typename std::enable_if_t, std::vector>>, - typename... Args> - void format(std::string& result, const char* fmt, T arg1, Args... args) - /// Appends the formatted string to result. - { - std::vector values; - values.reserve(sizeof...(Args) + 1); - values.emplace_back(arg1); - values.insert(values.end(), { args... }); - ::format(result, fmt, values); - } - - - template < - typename T, typename std::enable_if_t, std::vector>>, - typename... Args> - std::string format(const std::string& fmt, T arg1, Args... args) - /// Returns the formatted string. - { - std::vector values; - values.reserve(sizeof...(Args) + 1); - values.emplace_back(arg1); - values.insert(values.end(), { args... }); - std::string result; - ::format(result, fmt, values); - return result; - } - - - template < - typename T, typename std::enable_if_t, std::vector>>, - typename... Args> - std::string format(const char* fmt, T arg1, Args... args) - /// Returns the formatted string. - { - std::vector values; - values.reserve(sizeof...(Args) + 1); - values.emplace_back(arg1); - values.insert(values.end(), { args... }); - std::string result; - ::format(result, fmt, values); - return result; - } - - -} // namespace Poco - - -#endif // Foundation_Format_INCLUDED diff --git a/c++/Variadic_function_ recursively_called/ConsoleApplication1.sln b/c++/Variadic_function_ recursively_called/ConsoleApplication1.sln deleted file mode 100644 index 9463563..0000000 --- a/c++/Variadic_function_ recursively_called/ConsoleApplication1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32505.173 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.vcxproj", "{FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Debug|x64.ActiveCfg = Debug|x64 - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Debug|x64.Build.0 = Debug|x64 - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Debug|x86.ActiveCfg = Debug|Win32 - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Debug|x86.Build.0 = Debug|Win32 - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Release|x64.ActiveCfg = Release|x64 - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Release|x64.Build.0 = Release|x64 - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Release|x86.ActiveCfg = Release|Win32 - {FD9ADEAA-3AB1-4BEF-B4AE-C05FCDDF72B9}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5A846EC9-E8EE-487E-8679-D5ECC19B3B4E} - EndGlobalSection -EndGlobal diff --git a/c++/Variadic_function_ recursively_called/ConsoleApplication1/ConsoleApplication1.cpp b/c++/Variadic_function_ recursively_called/ConsoleApplication1/ConsoleApplication1.cpp deleted file mode 100644 index 383b66a..0000000 --- a/c++/Variadic_function_ recursively_called/ConsoleApplication1/ConsoleApplication1.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include - - -void format(std::string& result, const std::string& fmt, const std::vector& values) -{ - std::cout << "invoked." << std::endl; -} - - -template < - typename T, - typename... Args> -void format(std::string& result, const char* fmt, Args... args) -//void format(std::string& result, const char* fmt, T arg1, Args... args) -/// Appends the formatted string to result. -{ - std::vector values; - //values.reserve(sizeof...(Args) + 1); - //values.emplace_back(arg1); - values.reserve(sizeof...(Args)); - values.insert(values.end(), { args... }); - format(result, fmt, values); - -} - - -template < - typename T, - typename... Args> -std::string format(const char* fmt, T arg1, Args... args) -/// Returns the formatted string. -{ - std::vector values; - values.reserve(sizeof...(Args) + 1); - values.emplace_back(arg1); - values.insert(values.end(), { args... }); - std::string result; - ::format(result, fmt, values); - return result; -} - -int main() -{ - std::string connector = "sqlite", connectionString="c:\\sqlite.db"; - - format("%s:///%s", connector, connectionString); -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/Variadic_function_ recursively_called/ConsoleApplication1/ConsoleApplication1.vcxproj b/c++/Variadic_function_ recursively_called/ConsoleApplication1/ConsoleApplication1.vcxproj deleted file mode 100644 index 00c2b51..0000000 --- a/c++/Variadic_function_ recursively_called/ConsoleApplication1/ConsoleApplication1.vcxproj +++ /dev/null @@ -1,136 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {fd9adeaa-3ab1-4bef-b4ae-c05fcddf72b9} - ConsoleApplication1 - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpp20 - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/boost_python/Game.sln b/c++/boost_python/Game.sln deleted file mode 100644 index d5e787a..0000000 --- a/c++/boost_python/Game.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.1.32210.238 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Game", "Game\Game.vcxproj", "{2EEA3C18-08DE-4116-B1F0-C9430ED750C5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Debug|x64.ActiveCfg = Debug|x64 - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Debug|x64.Build.0 = Debug|x64 - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Debug|x86.ActiveCfg = Debug|Win32 - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Debug|x86.Build.0 = Debug|Win32 - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Release|x64.ActiveCfg = Release|x64 - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Release|x64.Build.0 = Release|x64 - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Release|x86.ActiveCfg = Release|Win32 - {2EEA3C18-08DE-4116-B1F0-C9430ED750C5}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {45704C72-3D9B-4813-88DD-3ED1AA1C6AD3} - EndGlobalSection -EndGlobal diff --git a/c++/boost_python/Game/Game.cpp b/c++/boost_python/Game/Game.cpp deleted file mode 100644 index cc268aa..0000000 --- a/c++/boost_python/Game/Game.cpp +++ /dev/null @@ -1,120 +0,0 @@ -// Game.cpp : Defines the entry point for the application. -// - -#include "framework.h" -#include "Game.h" -#include -#include -#include -#include -#include -#define MAX_LOADSTRING 100 - -// Global Variables: - -// Forward declarations of functions included in this code module: - -int APIENTRY wWinMain(_In_ HINSTANCE hInstance, - _In_opt_ HINSTANCE hPrevInstance, - _In_ LPWSTR lpCmdLine, - _In_ int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - - // TODO: Place code here. - using namespace boost::python; - - std::vector ss; - - std::wstring base = _PythonLib; - if (!IsDebuggerPresent()) - { - wchar_t szFileName[MAX_PATH] = { 0 }; - - GetModuleFileName(NULL, szFileName, MAX_PATH); - - std::filesystem::path p = szFileName; - - base = p.parent_path().wstring(); - } - { - //ss.push_back(base.c_str()); - ss.push_back(base + L"\\site-packages"); - ss.push_back(base + L"\\Lib"); - ss.push_back(base + L"\\DLLs"); - - Py_SetProgramName(L"Test"); - Py_SetPath((boost::join(ss, ";")).c_str()); - - Py_SetPythonHome(base.c_str()); - } - Py_Initialize(); - - std::string config = "config.txt"; - std::ifstream fstream(config); - std::string filename((std::istreambuf_iterator(fstream)), std::istreambuf_iterator()); - - try - { - - object main_module = import("__main__"); - - object main_namespace = main_module.attr("__dict__"); - - //object cpp_module((boost::python::handle<>(PyImport_ImportModule("hello_ext")))); - - - exec_file(filename.c_str(), main_namespace, object()); - } - catch (error_already_set const& err) - { - if (PyErr_ExceptionMatches(PyExc_ZeroDivisionError)) - { - // handle ZeroDivisionError specially - } - else - { - // print all other errors to stderr - PyObject* exc, * val, * tb; - - PyErr_Fetch(&exc, &val, &tb); - PyErr_NormalizeException(&exc, &val, &tb); - - boost::python::handle<> hexc(exc), hval(allow_null(val)), htb(allow_null(tb)); - - std::string message; - - if (!hval) - { - message = extract(boost::python::str(hexc)); - } - else - { - object traceback(import("traceback")); - object format_exception(traceback.attr("format_exception")); - object formatted_list(format_exception(hexc, hval, htb)); - object formatted(str("").join(formatted_list)); - message = extract(formatted); - - } - - - if (IsDebuggerPresent()) - { - ::OutputDebugStringA(message.c_str()); - ::OutputDebugStringA("\n"); - } - else { - std::ofstream out("error.txt", std::ios::trunc); - out << message; - out.close(); - } - - } - } - - - return 0; -} - diff --git a/c++/boost_python/Game/Game.h b/c++/boost_python/Game/Game.h deleted file mode 100644 index d00d47e..0000000 --- a/c++/boost_python/Game/Game.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -#include "resource.h" diff --git a/c++/boost_python/Game/Game.ico b/c++/boost_python/Game/Game.ico deleted file mode 100644 index b3ec03b..0000000 Binary files a/c++/boost_python/Game/Game.ico and /dev/null differ diff --git a/c++/boost_python/Game/Game.rc b/c++/boost_python/Game/Game.rc deleted file mode 100644 index 9aeebc6..0000000 Binary files a/c++/boost_python/Game/Game.rc and /dev/null differ diff --git a/c++/boost_python/Game/Game.vcxproj b/c++/boost_python/Game/Game.vcxproj deleted file mode 100644 index c913d64..0000000 --- a/c++/boost_python/Game/Game.vcxproj +++ /dev/null @@ -1,171 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {2eea3c18-08de-4116-b1f0-c9430ed750c5} - Game - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - true - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Windows - true - true - true - - - - - Level3 - true - _DEBUG;_WINDOWS;%(PreprocessorDefinitions) - true - - - Windows - true - - - - - Level3 - true - true - true - NDEBUG;_WINDOWS;BOOST_PYTHON_STATIC_LIB;_PythonLib=LR"($(VcpkgManifestRoot)\vcpkg_installed\x64-windows\x64-windows-mixed\tools\python3)";%(PreprocessorDefinitions) - true - $(VcpkgManifestRoot)\vcpkg_installed\x64-windows\x64-windows-mixed\include\python3.10;%(AdditionalIncludeDirectories) - stdcpp17 - - - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/c++/boost_python/Game/Resource.h b/c++/boost_python/Game/Resource.h deleted file mode 100644 index 3024274..0000000 --- a/c++/boost_python/Game/Resource.h +++ /dev/null @@ -1,30 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Game.rc - -#define IDS_APP_TITLE 103 - -#define IDR_MAINFRAME 128 -#define IDD_GAME_DIALOG 102 -#define IDD_ABOUTBOX 103 -#define IDM_ABOUT 104 -#define IDM_EXIT 105 -#define IDI_GAME 107 -#define IDI_SMALL 108 -#define IDC_GAME 109 -#define IDC_MYICON 2 -#ifndef IDC_STATIC -#define IDC_STATIC -1 -#endif -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS - -#define _APS_NO_MFC 130 -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif diff --git a/c++/boost_python/Game/framework.h b/c++/boost_python/Game/framework.h deleted file mode 100644 index 33a6be6..0000000 --- a/c++/boost_python/Game/framework.h +++ /dev/null @@ -1,15 +0,0 @@ -// header.h : include file for standard system include files, -// or project specific include files -// - -#pragma once - -#include "targetver.h" -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include -// C RunTime Header Files -#include -#include -#include -#include diff --git a/c++/boost_python/Game/small.ico b/c++/boost_python/Game/small.ico deleted file mode 100644 index b3ec03b..0000000 Binary files a/c++/boost_python/Game/small.ico and /dev/null differ diff --git a/c++/boost_python/Game/targetver.h b/c++/boost_python/Game/targetver.h deleted file mode 100644 index bf75e08..0000000 --- a/c++/boost_python/Game/targetver.h +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -// // Including SDKDDKVer.h defines the highest available Windows platform. -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. -#include diff --git a/c++/boost_python/Game/vcpkg.json b/c++/boost_python/Game/vcpkg.json deleted file mode 100644 index 2f0d93c..0000000 --- a/c++/boost_python/Game/vcpkg.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "test", - "version": "1.0.0", - "dependencies": [ - - "boost-python" - - ], - "builtin-baseline": "8dbd66f5a7821ced1ed57696b50375a977006813" -} \ No newline at end of file diff --git a/c++/boost_spirit/boost_spirit.sln b/c++/boost_spirit/boost_spirit.sln deleted file mode 100644 index 26a1d98..0000000 --- a/c++/boost_spirit/boost_spirit.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.2.32630.192 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "boost_spirit", "boost_spirit\boost_spirit.vcxproj", "{9E1D037B-5037-469A-9D62-9402A91B288C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9E1D037B-5037-469A-9D62-9402A91B288C}.Debug|x64.ActiveCfg = Debug|x64 - {9E1D037B-5037-469A-9D62-9402A91B288C}.Debug|x64.Build.0 = Debug|x64 - {9E1D037B-5037-469A-9D62-9402A91B288C}.Debug|x86.ActiveCfg = Debug|Win32 - {9E1D037B-5037-469A-9D62-9402A91B288C}.Debug|x86.Build.0 = Debug|Win32 - {9E1D037B-5037-469A-9D62-9402A91B288C}.Release|x64.ActiveCfg = Release|x64 - {9E1D037B-5037-469A-9D62-9402A91B288C}.Release|x64.Build.0 = Release|x64 - {9E1D037B-5037-469A-9D62-9402A91B288C}.Release|x86.ActiveCfg = Release|Win32 - {9E1D037B-5037-469A-9D62-9402A91B288C}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B3AC8EBF-4FD8-42CE-9EF8-EAC64A880EB9} - EndGlobalSection -EndGlobal diff --git a/c++/boost_spirit/boost_spirit/boost_spirit.cpp b/c++/boost_spirit/boost_spirit/boost_spirit.cpp deleted file mode 100644 index 1fc3644..0000000 --- a/c++/boost_spirit/boost_spirit/boost_spirit.cpp +++ /dev/null @@ -1,46 +0,0 @@ -// boost_spirit.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include -#include -#include -int main() -{ - std::vector outputs; - - std::string input = " 300, 300 "; - - auto it = input.begin(); - - //input.erase(std::remove_if(input.begin(), input.end(), ::isspace), input.end()); - - using namespace boost::spirit; - - //boost::split(input, outputs, boost::is_any_of(",")); - qi::phrase_parse(it, input.end(), qi::float_ % lexeme[lit(',') | lit(' ')], ascii::space | '(' | ')', outputs); - - - //std::transform(outputs.begin(), outputs.end(), std::back_inserter(results), [](auto& _1) { - // - // return static_cast(std::get(_1)); - // return std::get(_1); - // }); - - for (auto& x : outputs) - std::cout << x << std::endl; - return 0; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/boost_spirit/boost_spirit/boost_spirit.vcxproj b/c++/boost_spirit/boost_spirit/boost_spirit.vcxproj deleted file mode 100644 index f4cce34..0000000 --- a/c++/boost_spirit/boost_spirit/boost_spirit.vcxproj +++ /dev/null @@ -1,135 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {9e1d037b-5037-469a-9d62-9402a91b288c} - boostspirit - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/constant/ConsoleApplication1/ConsoleApplication1.sln b/c++/constant/ConsoleApplication1/ConsoleApplication1.sln deleted file mode 100644 index 4a61688..0000000 --- a/c++/constant/ConsoleApplication1/ConsoleApplication1.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30413.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.vcxproj", "{384DD748-C89C-4D03-988D-9A5EA78C2489}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Debug|x64.ActiveCfg = Debug|x64 - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Debug|x64.Build.0 = Debug|x64 - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Debug|x86.ActiveCfg = Debug|Win32 - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Debug|x86.Build.0 = Debug|Win32 - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Release|x64.ActiveCfg = Release|x64 - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Release|x64.Build.0 = Release|x64 - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Release|x86.ActiveCfg = Release|Win32 - {384DD748-C89C-4D03-988D-9A5EA78C2489}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {53603FE5-9F91-41EC-8659-8DFB7707884A} - EndGlobalSection -EndGlobal diff --git a/c++/constant/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.cpp b/c++/constant/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.cpp deleted file mode 100644 index 3fdf29d..0000000 --- a/c++/constant/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include - -#define Max 255 - -int main() -{ - std::cout << "Hello World!\n"; - - 1.0; - 10; - 0x1b; - 15u; - 15ul; - 160ll; - 3.0f; - - std::cout << "\"Hello world\"" << std::endl; - - std::cout << R"("Hello world - - std::cout << "\"Hello world\"" << std::endl; - std::cout << "\"Hello world\"" << std::endl; -")" << std::endl; - - std::string s = ""; - std::u8string ustr = u8""; - // s = ustr; - std::wstring ws = L""; - std::u16string u16; - - // std::wstring_convert> ss; - - int a = Max; - - const int A = 10; - - int array[A]; - - // ::SetWindowText(); - -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/constant/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.vcxproj b/c++/constant/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.vcxproj deleted file mode 100644 index 1a4f814..0000000 --- a/c++/constant/ConsoleApplication1/ConsoleApplication1/ConsoleApplication1.vcxproj +++ /dev/null @@ -1,148 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {384dd748-c89c-4d03-988d-9a5ea78c2489} - ConsoleApplication1 - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - stdcpplatest - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/constant/ConsoleApplication1/ConsoleApplication1/Output-Build.txt b/c++/constant/ConsoleApplication1/ConsoleApplication1/Output-Build.txt deleted file mode 100644 index 164d53f..0000000 --- a/c++/constant/ConsoleApplication1/ConsoleApplication1/Output-Build.txt +++ /dev/null @@ -1,12 +0,0 @@ -1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------ -1>Using triplet "x86-windows" from "D:\vcpkg\installed\x86-windows\" -1>ConsoleApplication1.cpp -1>D:\qt\c++\constant\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,1): warning C4828: The file contains a character starting at offset 0x1e7 that is illegal in the current source character set (codepage 65001). -1>D:\qt\c++\constant\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,1): warning C4828: The file contains a character starting at offset 0x1e9 that is illegal in the current source character set (codepage 65001). -1>D:\qt\c++\constant\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,1): warning C4828: The file contains a character starting at offset 0x225 that is illegal in the current source character set (codepage 65001). -1>D:\qt\c++\constant\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,1): warning C4828: The file contains a character starting at offset 0x227 that is illegal in the current source character set (codepage 65001). -1>D:\qt\c++\constant\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,1): warning C4828: The file contains a character starting at offset 0x251 that is illegal in the current source character set (codepage 65001). -1>D:\qt\c++\constant\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp(1,1): warning C4828: The file contains a character starting at offset 0x253 that is illegal in the current source character set (codepage 65001). -1>ConsoleApplication1.vcxproj -> D:\qt\c++\constant\ConsoleApplication1\Debug\ConsoleApplication1.exe -1>Done building project "ConsoleApplication1.vcxproj". -========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ========== diff --git a/c++/implict_cast/implict_cast.sln b/c++/implict_cast/implict_cast.sln deleted file mode 100644 index 46de6f0..0000000 --- a/c++/implict_cast/implict_cast.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "implict_cast", "implict_cast\implict_cast.vcxproj", "{8D456820-2106-4BE0-948F-F2692E237E76}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8D456820-2106-4BE0-948F-F2692E237E76}.Debug|x64.ActiveCfg = Debug|x64 - {8D456820-2106-4BE0-948F-F2692E237E76}.Debug|x64.Build.0 = Debug|x64 - {8D456820-2106-4BE0-948F-F2692E237E76}.Debug|x86.ActiveCfg = Debug|Win32 - {8D456820-2106-4BE0-948F-F2692E237E76}.Debug|x86.Build.0 = Debug|Win32 - {8D456820-2106-4BE0-948F-F2692E237E76}.Release|x64.ActiveCfg = Release|x64 - {8D456820-2106-4BE0-948F-F2692E237E76}.Release|x64.Build.0 = Release|x64 - {8D456820-2106-4BE0-948F-F2692E237E76}.Release|x86.ActiveCfg = Release|Win32 - {8D456820-2106-4BE0-948F-F2692E237E76}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A6C4BED1-1D77-4F6F-8CBD-E398F7C42251} - EndGlobalSection -EndGlobal diff --git a/c++/implict_cast/implict_cast/implict_cast.cpp b/c++/implict_cast/implict_cast/implict_cast.cpp deleted file mode 100644 index 5ec0117..0000000 --- a/c++/implict_cast/implict_cast/implict_cast.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// implict_cast.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -class Animal { -public: - Animal(int a): age(a){} -private: - int age; -}; - -class Dog : public Animal { -public: - Dog(int a): Animal(a) { - - } - -}; -int main() -{ - Animal a = 10; - - // implicit conversion - - int narrow = 10; - - float wide = narrow; - - Animal* animal = new Dog(10); - - //Dog* dog = animal; - - - // explicit conversion - - - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/implict_cast/implict_cast/implict_cast.vcxproj b/c++/implict_cast/implict_cast/implict_cast.vcxproj deleted file mode 100644 index 1c3af31..0000000 --- a/c++/implict_cast/implict_cast/implict_cast.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {8d456820-2106-4be0-948f-f2692e237e76} - implictcast - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/operators/operators.sln b/c++/operators/operators.sln deleted file mode 100644 index b246211..0000000 --- a/c++/operators/operators.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30503.244 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "operators", "operators\operators.vcxproj", "{9AE7808D-647B-44A3-B846-0451C8858BDE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Debug|x64.ActiveCfg = Debug|x64 - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Debug|x64.Build.0 = Debug|x64 - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Debug|x86.ActiveCfg = Debug|Win32 - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Debug|x86.Build.0 = Debug|Win32 - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Release|x64.ActiveCfg = Release|x64 - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Release|x64.Build.0 = Release|x64 - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Release|x86.ActiveCfg = Release|Win32 - {9AE7808D-647B-44A3-B846-0451C8858BDE}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {CE556415-B252-47D9-937C-2B2E78397802} - EndGlobalSection -EndGlobal diff --git a/c++/operators/operators/operators.cpp b/c++/operators/operators/operators.cpp deleted file mode 100644 index 042693a..0000000 --- a/c++/operators/operators/operators.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// operators.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -int main() -{ - std::cout << "Hello World!\n"; - int x; - std::cin >> x; - - std::cout << "\n" << x; - - int y = 10; - - - std::cout << "\nmodulo" << x % y << std::endl; - - printf("%s\n", "ss"); - - int r = rand() % 10; - - - int z = x > 10 ? 5 : 3; - - std::cout << "z: " << z << std::endl; - - - y -= 5; - y = y - 5; - - y += 50; - - y++; - y--; - - ++y; - --y; - - y = 10; - std::cout << y++ << std::endl; - std::cout << ++y << std::endl; - - std::cout << !true << std::endl; - std::cout << (0 && 1) << std::endl; - std::cout << (0 || 1) << std::endl; - - int a=0, b=0, c=0; - - if (c = a + b, c) { - - } - - x & 5; - x | 5; - - x >> 5; - x << 5; - - c = 0b101; - - std::bitset<5> bc = c >> 1; - std::cout << bc <(c) << 1; - std::cout << bc << std::endl; - - sizeof(int); - class A { - public: - int a; - }; - sizeof(A); - - A* p = 0; - *p; - - p->a = 10; - - -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/operators/operators/operators.vcxproj b/c++/operators/operators/operators.vcxproj deleted file mode 100644 index de97455..0000000 --- a/c++/operators/operators/operators.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {9ae7808d-647b-44a3-b846-0451c8858bde} - operators - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/primitive_types/primitive_types.sln b/c++/primitive_types/primitive_types.sln deleted file mode 100644 index 155cd90..0000000 --- a/c++/primitive_types/primitive_types.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30406.217 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "primitive_types", "primitive_types\primitive_types.vcxproj", "{5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Debug|x64.ActiveCfg = Debug|x64 - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Debug|x64.Build.0 = Debug|x64 - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Debug|x86.ActiveCfg = Debug|Win32 - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Debug|x86.Build.0 = Debug|Win32 - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Release|x64.ActiveCfg = Release|x64 - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Release|x64.Build.0 = Release|x64 - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Release|x86.ActiveCfg = Release|Win32 - {5CFFC357-A72B-44E0-A8D7-6E1F7D622DD9}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BE99F6DA-BBA0-4A8B-8303-08D008292604} - EndGlobalSection -EndGlobal diff --git a/c++/primitive_types/primitive_types/primitive_types.cpp b/c++/primitive_types/primitive_types/primitive_types.cpp deleted file mode 100644 index 9d6023d..0000000 --- a/c++/primitive_types/primitive_types/primitive_types.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// primitive_types.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -int main() -{ - std::cout << "Hello World!\n"; - - - int a = 10; - - bool b = true; - unsigned char c = ''; - std::cout << "c: " << c << std::endl; - float f = 0.5f; - double d = 0.5; - - - // - wchar_t t = ''; - std::cout << "t: " << t << std::endl; - - std::cout << "int: " << sizeof(int) << std::endl; - std::cout << "bool: " << sizeof(bool) << std::endl; - std::cout << "char: " << sizeof(char) << std::endl; - std::cout << "float: " << sizeof(float) << std::endl; - std::cout << "double: " << sizeof(double) << std::endl; - std::cout << "wchar_t: " << sizeof(wchar_t) << std::endl; - - std::cout << "short --------------" << std::endl; - std::cout << "int: " << sizeof(short) << std::endl; - std::cout << "bool: " << sizeof(bool) << std::endl; - std::cout << "char: " << sizeof(char) << std::endl; - std::cout << "float: " << sizeof(float) << std::endl; - std::cout << "double: " << sizeof(double) << std::endl; - std::cout << "wchar_t: " << sizeof(wchar_t) << std::endl; - - - std::cout << "long --------------" << std::endl; - std::cout << "int: " << sizeof(long long) << std::endl; - std::cout << "bool: " << sizeof( bool) << std::endl; - std::cout << "char: " << sizeof(char) << std::endl; - std::cout << "long float: " << sizeof(long float) << std::endl; - std::cout << "long double: " << sizeof(long double) << std::endl; - std::cout << "long double: " << sizeof(long long) << std::endl; - std::cout << "wchar_t: " << sizeof(wchar_t) << std::endl; - class A { - - }; - struct B {}; - // std::cout << "void: " << sizeof(void) << std::endl; - std::cout << "A: " << sizeof(A) << std::endl; - std::cout << "B: " << sizeof(B) << std::endl; - - -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/primitive_types/primitive_types/primitive_types.vcxproj b/c++/primitive_types/primitive_types/primitive_types.vcxproj deleted file mode 100644 index e06ba4f..0000000 --- a/c++/primitive_types/primitive_types/primitive_types.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {5cffc357-a72b-44e0-a8d7-6e1f7d622dd9} - primitivetypes - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/shared_ptr/shared_ptr.sln b/c++/shared_ptr/shared_ptr.sln deleted file mode 100644 index f975d05..0000000 --- a/c++/shared_ptr/shared_ptr.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30717.126 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared_ptr", "shared_ptr\shared_ptr.vcxproj", "{7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Debug|x64.ActiveCfg = Debug|x64 - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Debug|x64.Build.0 = Debug|x64 - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Debug|x86.ActiveCfg = Debug|Win32 - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Debug|x86.Build.0 = Debug|Win32 - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Release|x64.ActiveCfg = Release|x64 - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Release|x64.Build.0 = Release|x64 - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Release|x86.ActiveCfg = Release|Win32 - {7ABED4DD-043C-4F30-82AA-3BFFAF1F0FD1}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {21D0E7B6-42D7-4917-8F4D-714154EE7A47} - EndGlobalSection -EndGlobal diff --git a/c++/shared_ptr/shared_ptr/shared_ptr.cpp b/c++/shared_ptr/shared_ptr/shared_ptr.cpp deleted file mode 100644 index 8cce237..0000000 --- a/c++/shared_ptr/shared_ptr/shared_ptr.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// shared_ptr.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include -#include -#include -class Animal { -public: - void eat() { - std::cout << "eat called." << std::endl; - } - ~Animal() - { - std::cout << "~Animal called." << std::endl; - } -}; - -void test_memory(std::function func) { - func(); -} -int main() -{ - std::thread thread; - // Animal* aninal = new Animal; - { - - std::shared_ptr animal = std::make_shared(); - - thread = std::thread(test_memory, [animal]() { - animal->eat(); - }); - - std::cout << "exit scope." << std::endl; - } - - - thread.join(); - - std::cout << "Hello World!\n"; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/shared_ptr/shared_ptr/shared_ptr.vcxproj b/c++/shared_ptr/shared_ptr/shared_ptr.vcxproj deleted file mode 100644 index 2d380d7..0000000 --- a/c++/shared_ptr/shared_ptr/shared_ptr.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {7abed4dd-043c-4f30-82aa-3bffaf1f0fd1} - sharedptr - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/unique_lock/unique_lock.sln b/c++/unique_lock/unique_lock.sln deleted file mode 100644 index 7aaaa10..0000000 --- a/c++/unique_lock/unique_lock.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31025.218 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unique_lock", "unique_lock\unique_lock.vcxproj", "{3C2CF6C0-BE08-4525-8301-805C80EC5AAF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Debug|x64.ActiveCfg = Debug|x64 - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Debug|x64.Build.0 = Debug|x64 - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Debug|x86.ActiveCfg = Debug|Win32 - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Debug|x86.Build.0 = Debug|Win32 - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Release|x64.ActiveCfg = Release|x64 - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Release|x64.Build.0 = Release|x64 - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Release|x86.ActiveCfg = Release|Win32 - {3C2CF6C0-BE08-4525-8301-805C80EC5AAF}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {39434699-2775-48CF-9A5A-DAE7475304E0} - EndGlobalSection -EndGlobal diff --git a/c++/unique_lock/unique_lock/unique_lock.cpp b/c++/unique_lock/unique_lock/unique_lock.cpp deleted file mode 100644 index 8c4a7ca..0000000 --- a/c++/unique_lock/unique_lock/unique_lock.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include - -void wait(int seconds) -{ - boost::this_thread::sleep_for(boost::chrono::seconds{ seconds }); -} - -boost::timed_mutex mutex; - -void thread1() -{ - using boost::this_thread::get_id; - for (int i = 0; i < 5; ++i) - { - wait(1); - boost::unique_lock lock{ mutex }; - std::cout << "Thread " << get_id() << ": " << i << std::endl; - wait(3); - boost::timed_mutex* m = lock.release(); - m->unlock(); - } -} - -void thread2() -{ - using boost::this_thread::get_id; - for (int i = 0; i < 5; ++i) - { - wait(3); - boost::unique_lock lock{ mutex, - boost::try_to_lock }; - if (lock.owns_lock() || lock.try_lock_for(boost::chrono::seconds{ 1 })) - { - std::cout << "Thread " << get_id() << ": " << i << std::endl; - } - } -} - -int main() -{ - boost::thread t1{ thread1 }; - boost::thread t2{ thread2 }; - t1.join(); - t2.join(); -} \ No newline at end of file diff --git a/c++/unique_lock/unique_lock/unique_lock.vcxproj b/c++/unique_lock/unique_lock/unique_lock.vcxproj deleted file mode 100644 index f6afd97..0000000 --- a/c++/unique_lock/unique_lock/unique_lock.vcxproj +++ /dev/null @@ -1,153 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {3c2cf6c0-be08-4525-8301-805c80ec5aaf} - uniquelock - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows - - - x64-windows - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/c++/vcpkg/vcpkg.sln b/c++/vcpkg/vcpkg.sln deleted file mode 100644 index 8fec41f..0000000 --- a/c++/vcpkg/vcpkg.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30804.86 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkg", "vcpkg\vcpkg.vcxproj", "{6FF51078-58BD-44E9-BE47-35358468A88F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6FF51078-58BD-44E9-BE47-35358468A88F}.Debug|x64.ActiveCfg = Debug|x64 - {6FF51078-58BD-44E9-BE47-35358468A88F}.Debug|x64.Build.0 = Debug|x64 - {6FF51078-58BD-44E9-BE47-35358468A88F}.Debug|x86.ActiveCfg = Debug|Win32 - {6FF51078-58BD-44E9-BE47-35358468A88F}.Debug|x86.Build.0 = Debug|Win32 - {6FF51078-58BD-44E9-BE47-35358468A88F}.Release|x64.ActiveCfg = Release|x64 - {6FF51078-58BD-44E9-BE47-35358468A88F}.Release|x64.Build.0 = Release|x64 - {6FF51078-58BD-44E9-BE47-35358468A88F}.Release|x86.ActiveCfg = Release|Win32 - {6FF51078-58BD-44E9-BE47-35358468A88F}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {85685168-69AD-4B03-940B-5EDE3493EF6B} - EndGlobalSection -EndGlobal diff --git a/c++/vcpkg/vcpkg/vcpkg.cpp b/c++/vcpkg/vcpkg/vcpkg.cpp deleted file mode 100644 index 17437bf..0000000 --- a/c++/vcpkg/vcpkg/vcpkg.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// vcpkg.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include -#include - -struct A { - int value; - - friend std::ostream& operator<< (std::ostream& os, const A& a) { - os << a.value; - return os; - } - - friend std::istream& operator>> (std::istream& is, A& a) { - is >> a.value; - return is; - } - - -}; - - -int main() -{ - std::cout << "Hello World!\n"; - - auto string = boost::lexical_cast(10); - - - - std::cout << string << std::endl; - - std::cout << boost::lexical_cast(string); - - - auto a = boost::lexical_cast(123); - - std::cout << a.value << std::endl; -} - -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu - -// Tips for Getting Started: -// 1. Use the Solution Explorer window to add/manage files -// 2. Use the Team Explorer window to connect to source control -// 3. Use the Output window to see build output and other messages -// 4. Use the Error List window to view errors -// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project -// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file diff --git a/c++/vcpkg/vcpkg/vcpkg.vcxproj b/c++/vcpkg/vcpkg/vcpkg.vcxproj deleted file mode 100644 index 9b9223f..0000000 --- a/c++/vcpkg/vcpkg/vcpkg.vcxproj +++ /dev/null @@ -1,153 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {6ff51078-58bd-44e9-be47-35358468a88f} - vcpkg - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - x64-windows-mixed - - - x64-windows-mixed - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/chrome_inspector/CMakeLists.txt b/chrome_inspector/CMakeLists.txt deleted file mode 100644 index 190a9e6..0000000 --- a/chrome_inspector/CMakeLists.txt +++ /dev/null @@ -1,94 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) - -project(let) - -cmake_policy(SET CMP0091 NEW) -cmake_policy(SET CMP0020 NEW) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - -#add_definitions(-DBOOST_ALL_DYN_LINK -DV8_COMPRESS_POINTERS) -add_definitions(-DV8_COMPRESS_POINTERS) - -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Qt5Websockets CONFIG REQUIRED) -find_package(Qt5SerialBus CONFIG REQUIRED) -find_package(OpenCV CONFIG REQUIRED) -find_package(Boost REQUIRED COMPONENTS log) - -# https://vcpkg.readthedocs.io/en/latest/examples/installing-and-using-packages/ -find_path(BOOST_ASIO_INCLUDE_DIRS "boost/asio.hpp") - find_path(BOOST_BEAST_INCLUDE_DIRS "boost/beast.hpp") - #find_package(v8 CONFIG REQUIRED) -#file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/internal/*.h) -find_path(V8_INCLUDE_DIR "include/v8.h") - -file(GLOB HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h) -#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/include INC) -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES) -#aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/internal INTERNAL_SOURCES) - -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) - -if (MSVC) - #add_compile_options(/FC /bigobj) - add_compile_options(/wd4309 /wd4996 /wd4244 /wd4267) -endif() - -add_executable(let ${HEADERS} ${SOURCES}) - -#set_property(TARGET let PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - -target_include_directories(let PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${CMAKE_CURRENT_SOURCE_DIR}/v8/include - ${Boost_INCLUDE_DIRS} - ${BOOST_ASIO_INCLUDE_DIRS} - ${BOOST_BEAST_INCLUDE_DIRS} - #${V8_SDK}/include - ${V8_INCLUDE_DIR}/include -) - -#${CMAKE_BUILD_TYPE} -if (CMAKE_BUILD_TYPE STREQUAL "Debug") - set(BUILD "debug") -else() - set(BUILD "release") -endif() -target_link_directories(let PRIVATE "${V8_SDK}\\out\\x64.${BUILD}") - -target_compile_definitions(let PRIVATE WIN32_LEAN_AND_MEAN UNICODE NOMINMAX _WIN32_WINNT=0x0601) - -find_library(V8_LIBRARY v8.dll) -find_library(V8_LIBBASE_LIBRARY v8_libbase.dll) -find_library(V8_LIBPLATFORM_LIBRARY v8_libplatform.dll) -target_link_libraries(let PRIVATE ws2_32.lib - #v8.dll.lib - #v8_libbase.dll.lib - #v8_libplatform.dll.lib - ${V8_LIBRARY} - ${V8_LIBBASE_LIBRARY} - ${V8_LIBPLATFORM_LIBRARY} - opencv_world - Qt::Widgets #Qt5::WidgetsPrivate #Qt5::QWindowsVistaStylePlugin - Qt::WebSockets #Qt5::WebsocketsPrivate #Qt5::QWindowsVistaStylePlugin - Qt::SerialBus #Qt5::SerialBusPrivate #Qt5::PeakCanBusPlugin Qt5::TinyCanBusPlugin - ${Boost_LIBRARIES} -) - -find_file(V8_SNAPSHOT_BLOB_BIN snapshot_blob.bin) -message(STATUS ${V8_SNAPSHOT_BLOB_BIN}) -file(COPY E:\\vcpkg\\buildtrees\\v8\\x64-windows-dbg\\snapshot_blob.bin DESTINATION ${CMAKE_BINARY_DIR}) -#file(COPY ${V8_SDK}/out/x64.${BUILD}/v8.dll DESTINATION ${CMAKE_BINARY_DIR}) -#file(COPY ${V8_SDK}/out/x64.${BUILD}/v8_libbase.dll DESTINATION ${CMAKE_BINARY_DIR}) -#file(COPY ${V8_SDK}/out/x64.${BUILD}/v8_libplatform.dll DESTINATION ${CMAKE_BINARY_DIR}) \ No newline at end of file diff --git a/chrome_inspector/CMakeSettings.json b/chrome_inspector/CMakeSettings.json deleted file mode 100644 index 7c0d87e..0000000 --- a/chrome_inspector/CMakeSettings.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "variables": [ - { - "name": "VCPKG_TARGET_TRIPLET", - "value": "x64-windows", - "type": "STRING" - } - ] - }, - { - "name": "x64-Release", - "generator": "Ninja", - "configurationType": "RelWithDebInfo", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "inheritEnvironments": [ "msvc_x64_x64" ], - "variables": [ - { - "name": "VCPKG_TARGET_TRIPLET", - "value": "x64-windows", - "type": "STRING" - } - ] - }, - { - "name": "x64-Debug-static", - "generator": "Ninja", - "configurationType": "Debug", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "inheritEnvironments": [ "msvc_x64_x64" ], - "variables": [ - { - "name": "VCPKG_TARGET_TRIPLET", - "value": "x64-windows-static", - "type": "STRING" - } - ] - } - ] -} \ No newline at end of file diff --git a/chrome_inspector/README.md b/chrome_inspector/README.md deleted file mode 100644 index 03de8e8..0000000 --- a/chrome_inspector/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# pkg - - vcpkg install qt5-base:x64-windows - vcpkg.exe install qt5-serialbus:x64-windows - vcpkg.exe install qt5-websockets:x64-windows - vcpkg.exe install opencv4[world]:x64-windows - vcpkg.exe install boost-asio:x64-windows - vcpkg.exe install boost-log:x64-windows - vcpkg.exe install boost-beast:x64-windows - vcpkg.exe install v8:x64-windows - - -# clang - Using Ninja alongside Visual Studio[https://clang.llvm.org/get_started.html] - - 1. Check out clang and LLVM - `git clone https://github.com/llvm/llvm-project.git` - - 2. Open a developer command prompt with the appropriate environment - - 3. mkdir build_ninja (or build, or use your own organization) - - 4. cd build_ninja - - 5. set CXX=cl - - 6. set CC=cl - - 7. cmake -GNinja -DLLVM_ENABLE_PROJECTS=clang ..\llvm - - 8. ninja clang - -# third-party - - git submodule add https://github.com/qt-labs/qthttpserver.git ./third-party/qthttpserver -# v8 - wiki - how to build v8 \ No newline at end of file diff --git a/chrome_inspector/example/core/point.js b/chrome_inspector/example/core/point.js deleted file mode 100644 index fe31822..0000000 --- a/chrome_inspector/example/core/point.js +++ /dev/null @@ -1,11 +0,0 @@ -var p1 = new Point(100, 100); - -console.log("p1:" , p1); - -var p2 = new Point(p1); - -console.log("p2:" , p2); - -var p3 = new Point({ x: 100, y: 100 }); - -console.log("p3:" , p3); \ No newline at end of file diff --git a/chrome_inspector/example/core/rect.js b/chrome_inspector/example/core/rect.js deleted file mode 100644 index 9db353f..0000000 --- a/chrome_inspector/example/core/rect.js +++ /dev/null @@ -1,6 +0,0 @@ - -console.log(new Rect()); - -console.log(new Rect(100, 100, 200, 200)); -console.log(new Rect(new Point(100, 100), new Size(200, 200))); -console.log(new Rect(new Point(100, 100), new Point(200, 200))); \ No newline at end of file diff --git a/chrome_inspector/example/core/size.js b/chrome_inspector/example/core/size.js deleted file mode 100644 index b787e19..0000000 --- a/chrome_inspector/example/core/size.js +++ /dev/null @@ -1,3 +0,0 @@ -var size = new Size(100, 100); - -console.log(size.toString()); \ No newline at end of file diff --git a/chrome_inspector/example/global/start.js b/chrome_inspector/example/global/start.js deleted file mode 100644 index 91d801f..0000000 --- a/chrome_inspector/example/global/start.js +++ /dev/null @@ -1,3 +0,0 @@ -let dirname = chdir("C:\\Program Files (x86)\\Proxifier") ; -start("C:\\Program Files (x86)\\Proxifier\\Proxifier.exe"); -chdir(dirname); \ No newline at end of file diff --git a/chrome_inspector/example/global/timer.js b/chrome_inspector/example/global/timer.js deleted file mode 100644 index 1ad3f87..0000000 --- a/chrome_inspector/example/global/timer.js +++ /dev/null @@ -1,15 +0,0 @@ - -var id = setTimeout(()=>{ -console.log("timeout."); - -}, 3000); - - -setTimeout(()=>{ - console.log("timeout2."); - clearTimeout(0); - }, 6000); - -run(); - - diff --git a/chrome_inspector/example/main.js b/chrome_inspector/example/main.js deleted file mode 100644 index 7ae2934..0000000 --- a/chrome_inspector/example/main.js +++ /dev/null @@ -1,4 +0,0 @@ -//import "./core/point.js" - -let a = 10; -let b = a; \ No newline at end of file diff --git a/chrome_inspector/example/opencv/qrcode.js b/chrome_inspector/example/opencv/qrcode.js deleted file mode 100644 index 82b98f0..0000000 --- a/chrome_inspector/example/opencv/qrcode.js +++ /dev/null @@ -1,41 +0,0 @@ -let qrCodeDetector = new cv.QRCodeDetector(); - -function getQRCode(image) { - let [decodedText, ..._] = qrCodeDetector.detectAndDecode(image) - - return decodedText; -} - - -function test(file) { - let img = cv.imread(file); - - // let gray = cv.cvtColor(img, cv.COLOR_RGB2GRAY) - - let result = ""; - let num = 0; - result = getQRCode(img); - if (result == "") { - let [t, newImg] = cv.threshold(img, 0, 255, cv.THRESH_OTSU); - - console.log(file); - while (result == "" && t < 255) { - num++ - [t, newImg] = cv.threshold(newImg, t, 255, cv.THRESH_BINARY); - result = getQRCode(newImg); - t += 20; - } - } - console.log("try ", num, " and result: ", result); -} - - -test("./opencv/qrcode/2020-8-14-11-18-43-0.png"); - - -let dir = new Qt.DirIterator("./opencv/qrcode/", Qt.Dir.Filter.NoDotAndDotDot | Qt.Dir.Filter.Files); - -while (dir.hasNext()) { - //test(dir.next()); -} - diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-12-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-12-0.png deleted file mode 100644 index 2bed1bd..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-12-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-13-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-13-0.png deleted file mode 100644 index 52b5abc..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-13-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-14-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-14-0.png deleted file mode 100644 index 25a39f9..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-14-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-15-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-15-0.png deleted file mode 100644 index 367cc88..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-11-11-5-15-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-13-14-34-23-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-13-14-34-23-0.png deleted file mode 100644 index f2ac7d7..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-13-14-34-23-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-18-43-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-14-11-18-43-0.png deleted file mode 100644 index 8badd33..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-18-43-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-28-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-28-0.png deleted file mode 100644 index bbdfd8e..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-28-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-30-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-30-0.png deleted file mode 100644 index 6ca3ce8..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-30-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-31-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-31-0.png deleted file mode 100644 index 4dc580c..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-31-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-33-0.png b/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-33-0.png deleted file mode 100644 index 0a531a9..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-14-11-19-33-0.png and /dev/null differ diff --git a/chrome_inspector/example/opencv/qrcode/2020-8-6-15-53-55-1.png b/chrome_inspector/example/opencv/qrcode/2020-8-6-15-53-55-1.png deleted file mode 100644 index b88fad3..0000000 Binary files a/chrome_inspector/example/opencv/qrcode/2020-8-6-15-53-55-1.png and /dev/null differ diff --git a/chrome_inspector/example/serialbus/client.js b/chrome_inspector/example/serialbus/client.js deleted file mode 100644 index 960130c..0000000 --- a/chrome_inspector/example/serialbus/client.js +++ /dev/null @@ -1,107 +0,0 @@ -var app = new Application(); - -var device = new ModbusTcpClient(); - -device.errorOccurred = () => { - console.log(device.errorString()); -} - -function read1(){ - let unit = new ModbusDataUnit(ModbusDataUnit.RegisterType.HoldingRegisters, 1100, 1); - - let reply = device.sendReadRequest(unit, 1); - if (!reply.isFinished()) { - reply.finished = () => { - const unit = reply.result(); - for (let i = 0; i < unit.valueCount(); ++i){ - console.log("matrix:", unit.value(i)); - } - console.log("matrix read finsihed"); - } - } -} - -function read2(){ - let unit = new ModbusDataUnit(ModbusDataUnit.RegisterType.HoldingRegisters, 1110, 8); - - let reply = device.sendReadRequest(unit, 1); - if (!reply.isFinished()) { - reply.finished = () => { - const unit = reply.result(); - console.log("----------------"); - console.log("x: ", toNumber([unit.value(0), unit.value(1), unit.value(2), unit.value(3)])) - console.log("y:", toNumber([unit.value(4), unit.value(5), unit.value(6), unit.value(7)])) - console.log("[x,y]read finsihed"); - } - } -} -let num = 1; -function write() { - sleep(1000); - let unit = new ModbusDataUnit(ModbusDataUnit.RegisterType.HoldingRegisters, 1000, 8); - - console.log("---------------write num:", num); - unit.setValue(0, num % 2 + 1); - unit.setValue(2, num++); - - let reply = device.sendWriteRequest(unit, 1); - - if (!reply.isFinished()) { - reply.finished = () => { - console.log("write finsihed"); - } - } - else{ - console.log("write finsihed direct"); - } -} - -function connect(){ - if (!device.connectDevice()) { - console.log("error:", device.errorString()); - } -} - -device.stateChanged = (state) => { - console.log("state: " + state); - - if (state == ModbusDevice.State.ConnectedState) { - console.log("connected."); - } -} - -//const url = Url.fromUserInput("127.0.0.1:502"); -const url = Url.fromUserInput("10.0.0.138:1502"); - -device.setConnectionParameter(ModbusDevice.ConnectionParameter.NetworkPortParameter, url.port()); -device.setConnectionParameter(ModbusDevice.ConnectionParameter.NetworkAddressParameter, url.host()); - -device.setTimeout(200); - -connect(); - -let timer = new Timer; - -timer.setInterval(3000); - -timer.timeout = ()=>{ - if (device.state() != ModbusDevice.State.ConnectedState) { - console.log("no connect.") - connect(); - return; - } - write(); - sleep(1000); - read1(); - sleep(300); - read2(); - - if (num %5 == 0){ - console.log("prepare to close."); - device.disconnectDevice(); - connect(); - } -} -timer.start(); - -Application.exec(); diff --git a/chrome_inspector/example/windows/keyboard.js b/chrome_inspector/example/windows/keyboard.js deleted file mode 100644 index 97d5dd9..0000000 --- a/chrome_inspector/example/windows/keyboard.js +++ /dev/null @@ -1,33 +0,0 @@ -console.log(keyboard.keyCode("a")); -console.log(keyboard.keyCode("A")); - - - -var notepad = winapi.findWindow(/.+记事本/); - - -winapi.setForegroundWindow(notepad.winId()); - - -//keyboard.simulate([0x41]); - -//keyboard.sendText("abc"); -//keyboard.sendText("你好,我是机器人"); -//keyboard.sendText("你好,我是机器人123"); - -keyboard.installHook((wParam, lParam) => { - if (wParam == windows.WM_KEYDOWN) - { - - const name = keyboard.keyName( lParam.vkCode); - console.log("you pressed: " + name); - - if (lParam.vkCode ==keyboard.keyCode("x") && keyboard.getAsyncKeyState(windows.VK_CONTROL)) - { - keyboard.removeHook(); - quitApp(); - } - } -}); - -processEvents(); \ No newline at end of file diff --git a/chrome_inspector/example/windows/mouse.js b/chrome_inspector/example/windows/mouse.js deleted file mode 100644 index 71ef552..0000000 --- a/chrome_inspector/example/windows/mouse.js +++ /dev/null @@ -1,19 +0,0 @@ -mouse.move(1669, 231); - -//mouse.mouse(new Point(300, 300)); - -//mouse.click(); - - -var hhk = mouse.installHook((wParam, msll)=>{ - if (wParam == windows.WM_LBUTTONDOWN) { - console.log("click"); - mouse.removeHook(); - quit(); - } - console.log("hooked.."); -}) - - -processEvents(); - diff --git a/chrome_inspector/example/windows/winapi.js b/chrome_inspector/example/windows/winapi.js deleted file mode 100644 index a122d63..0000000 --- a/chrome_inspector/example/windows/winapi.js +++ /dev/null @@ -1,5 +0,0 @@ - var img = winapi.grabDesktop(); - var s = img.size(); - - console.log("size: ", img.size().toString()); - console.log("offset: " , img.offset()); diff --git a/chrome_inspector/example/windows/windows.js b/chrome_inspector/example/windows/windows.js deleted file mode 100644 index 18723b2..0000000 --- a/chrome_inspector/example/windows/windows.js +++ /dev/null @@ -1,22 +0,0 @@ - -var w = winapi.findWindow("Qt5QWindowIcon"); - -console.log("w: " + w.width); -console.log("h: " + w.height); - - -w.width = 1000; -w.height = 500; - - -console.log("w: " + w.width); -console.log("h: " + w.height); -console.log("title: ", w.title); - -winapi.enumWindows((w)=>{ - console.log("title: ", w.title) ; -}); - - -w.close(); -//w.shutdown(); \ No newline at end of file diff --git a/chrome_inspector/example/windows/winreg.js b/chrome_inspector/example/windows/winreg.js deleted file mode 100644 index 8ca318c..0000000 --- a/chrome_inspector/example/windows/winreg.js +++ /dev/null @@ -1,10 +0,0 @@ - -if (!winreg.registerAssoc(".js", "let.exe")) - console.log(getLastError()); - - -console.log(winreg.queryAssoc(".bat")); - -if (!winreg.removeAssoc(".bat")){ - console.log(getLastError()); -} \ No newline at end of file diff --git a/chrome_inspector/include/error.h b/chrome_inspector/include/error.h deleted file mode 100644 index b2d3610..0000000 --- a/chrome_inspector/include/error.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -namespace shelllet { - namespace error { - std::string GetLastErrorMessage(); - void SetLastErrorMessage(const std::variant& err); - } -} \ No newline at end of file diff --git a/chrome_inspector/include/http_session.h b/chrome_inspector/include/http_session.h deleted file mode 100644 index 9544565..0000000 --- a/chrome_inspector/include/http_session.h +++ /dev/null @@ -1,99 +0,0 @@ -#pragma once -#include -#include -#include -#include "inspector.h" -namespace shelllet { - namespace inspect { - class HttpSession : public std::enable_shared_from_this - { - class Queue - { - enum - { - limit = 8 - }; - - struct Work - { - virtual ~Work() = default; - virtual void operator()() = 0; - }; - - HttpSession& self; - std::vector> items; - - public: - explicit Queue(HttpSession& self) - : self(self) - { - static_assert(limit > 0, "queue limit must be positive"); - items.reserve(limit); - } - - bool isFull() const - { - return items.size() >= limit; - } - - bool onWrite() - { - BOOST_ASSERT(!items.empty()); - auto const was_full = isFull(); - items.erase(items.begin()); - if (!items.empty()) - (*items.front())(); - return was_full; - } - - template - void operator()(boost::beast::http::message&& msg) - { - struct WorkImpl : Work - { - HttpSession& self_; - boost::beast::http::message msg_; - - WorkImpl(HttpSession& self, boost::beast::http::message&& msg) - : self_(self) - , msg_(std::move(msg)) - { - } - - void operator()() - { - boost::beast::http::async_write(self_.stream_, msg_, boost::beast::bind_front_handler(&HttpSession::onWrite, self_.shared_from_this(), msg_.need_eof())); - } - }; - - items.push_back(boost::make_unique(self, std::move(msg))); - - if (items.size() == 1) - (*items.front())(); - } - }; - - public: - explicit HttpSession(Receiver* receiver, boost::asio::ip::tcp::socket&& socket); - - public: - void run(); - protected: - void doRead(); - - void onRead(boost::beast::error_code ec, std::size_t bytes_transferred); - - void onWrite(bool close, boost::beast::error_code ec, std::size_t bytes_transferred); - - void doClose(); - - private: - boost::beast::tcp_stream stream_; - - boost::beast::flat_buffer buffer_; - boost::optional> parser_; - Receiver* receiver_; - Queue queue_; - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/inspector.h b/chrome_inspector/include/inspector.h deleted file mode 100644 index 3fa313f..0000000 --- a/chrome_inspector/include/inspector.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once -#include - -namespace shelllet { - namespace inspect { - struct InspectorVersion { - std::string version; - std::string browser; - }; - struct InspectorList { - std::string description; - std::string type; - std::string title; - std::string url; - std::string address; - uint16_t port; - }; - - class Receiver : public QObject { - public: - void dispatchInspectorMessage(const std::string& message) { if (callback) { callback(message); } } - virtual InspectorVersion requestInspectorVersion() = 0; - virtual InspectorList requestInspectorList() = 0; - std::function callback; - }; - - class MessageInEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - MessageInEvent(const std::string& message) : QEvent(Type), message(message) {} - std::string message; - }; - class MessageOutEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - MessageOutEvent(const std::string& message) : QEvent(Type), message(message) {} - std::string message; - }; - class PumpMessageLoopEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - PumpMessageLoopEvent() : QEvent(Type) {} - }; - class ContinueRunEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - ContinueRunEvent() : QEvent(Type) {} - }; - - class DisconnectEvent : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - DisconnectEvent() : QEvent(Type) {} - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/inspector_agent.h b/chrome_inspector/include/inspector_agent.h deleted file mode 100644 index af75c0b..0000000 --- a/chrome_inspector/include/inspector_agent.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include -#include -#include -#include "resource.h" -#include "inspector_client.h" -QT_FORWARD_DECLARE_CLASS(QEvent) - -namespace shelllet { - namespace engine { - class InspectorAgent :public QObject, public QRunnable - { - public: - InspectorAgent(QObject* receiver, v8::Platform* platform, const std::string& filename, const std::string& source, const std::string& dir, bool inspect_brk); - ~InspectorAgent(); - public: - void postInspectorMessage(const QString& message); - void disconnectInspector(); - void pumpMessageLoop(); - - void run() override; - void cleanup(); - void evaluate(); - private: - bool loadModules(v8::Local context); - private: - v8::Platform* platform_; - v8::Isolate* isolate_ = nullptr; - std::unique_ptr inspector_client_; - v8::Isolate::CreateParams create_params_; - std::string name_; - std::string code_; - QObject* receiver_; - std::string dir_; - bool inspect_brk_; - //static std::list> resources; - }; - } -} diff --git a/chrome_inspector/include/inspector_channel.h b/chrome_inspector/include/inspector_channel.h deleted file mode 100644 index 1492693..0000000 --- a/chrome_inspector/include/inspector_channel.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "framework.h" -#include -namespace shelllet { - namespace inspect { - class InspectorClient; - class InspectorChannel final : public v8_inspector::V8Inspector::Channel { - public: - explicit InspectorChannel(v8_inspector::V8Inspector* inspector, InspectorClient* c); - ~InspectorChannel() = default; - public: - void pauseOnNextJavascriptStatement(const std::string& reason); - void dispatchProtocolMessage(const std::string& message); - private: - void sendResponse(int call_id, std::unique_ptr message) override; - void sendNotification(std::unique_ptr message) override; - void flushProtocolNotifications() override {} - private: - InspectorClient* client_; - std::unique_ptr session_; - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/inspector_client.h b/chrome_inspector/include/inspector_client.h deleted file mode 100644 index 2517aac..0000000 --- a/chrome_inspector/include/inspector_client.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include "framework.h" -#include "inspector_channel.h" -#include "inspector.h" - -namespace shelllet { - namespace inspect { - class InspectorClient : public v8_inspector::V8InspectorClient { - public: - InspectorClient(QObject* receiver, const v8::Local& context, v8::Platform* platform); - - protected: - void runMessageLoopOnPause(int contextGroupId) override; - - void quitMessageLoopOnPause() override; - - void pauseOnNextJavascriptStatement(const std::string& reason); - - double currentTimeMS() override; - - void runIfWaitingForDebugger(int contextGroupId) override; - - // std::unique_ptr resourceNameToUrl(const v8_inspector::StringView& resourceName) override; - - void consoleAPIMessage(int contextGroupId, v8::Isolate::MessageErrorLevel level, const v8_inspector::StringView& message, const v8_inspector::StringView& url, unsigned lineNumber, unsigned columnNumber, v8_inspector::V8StackTrace*) override; - - private: - - v8::Local ensureDefaultContextInGroup(int groupId) override; - public: - void postInspectorMessage(const std::string& message); - void sendMessageToFrontend(const v8_inspector::StringView& string); - void dispatchProtocolMessage(const std::string& message); - bool waitForFrontendMessageWhilePaused(); - void disconnectFrontend(); - void pumpMessageLoop(); - - private: - std::unique_ptr inspector_; - std::unique_ptr channel_; - bool is_paused_ = false; - bool is_ready_ = false; - v8::Isolate* isolate_; - v8::Platform* platform_; - QObject* receiver_; - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/logs.h b/chrome_inspector/include/logs.h deleted file mode 100644 index cf2c14e..0000000 --- a/chrome_inspector/include/logs.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qloggingcategory.h" -#include "qglobalstatic.h" -namespace shelllet { - namespace logs { - Q_DECLARE_LOGGING_CATEGORY(shelllet_engine) - class Logger { - public: - void initialize(boost::log::trivial::severity_level level); - - static boost::log::trivial::severity_level LevelFromString(const QString& level); - }; - - Q_GLOBAL_STATIC(Logger, logger) - } -} \ No newline at end of file diff --git a/chrome_inspector/include/native/console.h b/chrome_inspector/include/native/console.h deleted file mode 100644 index e0fc63e..0000000 --- a/chrome_inspector/include/native/console.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -namespace shelllet { - namespace global { - - class MyConsole { - - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/native/console_implement.h b/chrome_inspector/include/native/console_implement.h deleted file mode 100644 index b84d020..0000000 --- a/chrome_inspector/include/native/console_implement.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "console.h" -#include "console_p.h" -#include "console_wrapper.h" - -namespace shelllet { - namespace global { - class Console : public MyConsoleWrapper - { - public: - using ReturnType = MyConsolePrivate; - using ReturnType2 = MyConsolePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - Console(const v8::FunctionCallbackInfo& args) : MyConsoleWrapper(*Private(args), args) - { - } - Console(MyConsole* p, const v8::FunctionCallbackInfo& args) : MyConsoleWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Console(v8::Isolate* isolate, const v8::Local& tpl) : MyConsoleWrapper(isolate, tpl) - {} - - Console(v8::Isolate* isolate, const v8::Local& proto) : MyConsoleWrapper(isolate, proto) - {} - - static const char* Name() { return "console"; } - public: - }; - } -} diff --git a/chrome_inspector/include/native/console_p.h b/chrome_inspector/include/native/console_p.h deleted file mode 100644 index 39ac91f..0000000 --- a/chrome_inspector/include/native/console_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace global { - template - class MyConsolePrivate : public ObjectPrivate - { - public: - template - MyConsolePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/chrome_inspector/include/native/console_wrapper.h b/chrome_inspector/include/native/console_wrapper.h deleted file mode 100644 index 2bbcd04..0000000 --- a/chrome_inspector/include/native/console_wrapper.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once - -namespace shelllet { - namespace global { - template - class MyConsoleWrapper : public ObjectWrapper - { - public: - template - MyConsoleWrapper(MyConsolePrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - MyConsoleWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - tpl->Set(isolate, "log", v8::FunctionTemplate::New(isolate, Print)); - } - MyConsoleWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - static void Print(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - std::vector list; - for (int i = 0; i < args.Length(); i++) { - list.push_back(ToWString({ isolate, args[i] })); - } - std::wcout.imbue(std::locale(std::locale(), "", LC_CTYPE)); - std::wcout << boost::join(list, " ") << std::endl; - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/chrome_inspector/include/native/global.h b/chrome_inspector/include/native/global.h deleted file mode 100644 index d951e66..0000000 --- a/chrome_inspector/include/native/global.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -namespace shelllet { - namespace global { - class MyGlobal { - public: - static QString Version(); - - static std::string dirname(); - - static std::string Chdir(const std::string& tar); - - static bool IEquals(const std::string& s1, const std::string& s2); - - static bool Start(const std::string& file, const std::vector& args); - - static void Sleep(int64_t ms); - - static std::filesystem::path GetExePath(); - static std::filesystem::path GetHomePath(); - - static std::string Now(); - static void WriteFile(const std::string& filename, const std::string& txt, std::ios_base::openmode mode = std::ios_base::trunc); - - static std::string ToUpperCase(const std::string& string, int index = -1); - - static double ToNumber(const std::vector& v, int type = 0) { - const int L = sizeof(double) / sizeof(std::uint16_t); - union Convert - { - std::uint16_t u[L]; - double real; - }; - Convert convert; - for (int i = 0; i < v.size(); ++i) { - convert.u[i] = v[i]; - } - return convert.real; - } - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/native/global_implement.h b/chrome_inspector/include/native/global_implement.h deleted file mode 100644 index 72448c5..0000000 --- a/chrome_inspector/include/native/global_implement.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "error.h" -#include "timer_resource.h" -#include "global.h" -#include "global_p.h" -#include "global_wrapper.h" -#include - -#include -#include - -namespace shelllet { - using namespace resource; - namespace global { - class Global :public MyGlobalWrapper { - public: - using ReturnType = MyGlobalPrivate; - using ReturnType2 = MyGlobalPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - Global(const v8::FunctionCallbackInfo& args) : MyGlobalWrapper(*Private(args), args) { - } - Global(v8::Isolate* isolate, const v8::Local& tpl) : MyGlobalWrapper(isolate, tpl) - {} - Global(v8::Isolate* isolate, const v8::Local& proto) : MyGlobalWrapper(isolate, proto) - {} - - public: - static const char* Name() { return "global"; } - }; - } -} diff --git a/chrome_inspector/include/native/global_p.h b/chrome_inspector/include/native/global_p.h deleted file mode 100644 index 74c0456..0000000 --- a/chrome_inspector/include/native/global_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace shelllet::global { - template - class MyGlobalPrivate : public ObjectPrivate - { - public: - template - MyGlobalPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/chrome_inspector/include/native/global_wrapper.h b/chrome_inspector/include/native/global_wrapper.h deleted file mode 100644 index f46c531..0000000 --- a/chrome_inspector/include/native/global_wrapper.h +++ /dev/null @@ -1,257 +0,0 @@ -#pragma once -namespace shelllet { - namespace global { - template - class MyGlobalWrapper : public ObjectWrapper - { - public: - template - MyGlobalWrapper(MyGlobalPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - MyGlobalWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - } - MyGlobalWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "__dirname"), Dirname); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "__version"), Version); - - proto->Set(isolate, "chdir", v8::FunctionTemplate::New(isolate, Chdir)); - proto->Set(isolate, "sleep", v8::FunctionTemplate::New(isolate, Sleep)); - proto->Set(isolate, "iequals", v8::FunctionTemplate::New(isolate, IEquals)); - proto->Set(isolate, "start", v8::FunctionTemplate::New(isolate, Start)); - proto->Set(isolate, "setTimeout", v8::FunctionTemplate::New(isolate, SetTimeout)); - proto->Set(isolate, "clearTimeout", v8::FunctionTemplate::New(isolate, ClearTimeout)); - proto->Set(isolate, "setInterval", v8::FunctionTemplate::New(isolate, SetInterval)); - proto->Set(isolate, "clearInterval", v8::FunctionTemplate::New(isolate, ClearInterval)); - proto->Set(isolate, "getLastError", v8::FunctionTemplate::New(isolate, GetLastError)); - proto->Set(isolate, "setLastError", v8::FunctionTemplate::New(isolate, SetLastError)); - proto->Set(isolate, "writeFile", v8::FunctionTemplate::New(isolate, WriteFile)); - proto->Set(isolate, "toUpperCase", v8::FunctionTemplate::New(isolate, ToUpperCase)); - proto->Set(isolate, "toNumber", v8::FunctionTemplate::New(isolate, ToNumber)); - proto->Set(isolate, "waitForDebugger", v8::FunctionTemplate::New(isolate, WaitForDebugger)); - } - - protected: - static void Version(v8::Local property, const v8::PropertyCallbackInfo& info) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - info.GetReturnValue().Set(V8_NEW_WSTRING_VAR(isolate, MyGlobal::Version().toStdWString().c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Dirname(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - info.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, MyGlobal::dirname().c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Chdir(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) { - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, MyGlobal::Chdir(ToString({ isolate, args[0] })).c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IEquals(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - v8::String::Utf8Value s1(isolate, args[0]); - v8::String::Utf8Value s2(isolate, args[1]); - - args.GetReturnValue().Set(v8::Boolean::New(isolate, MyGlobal::IEquals(*s1, *s2))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Start(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) { - std::string filename = ToString({ isolate, args[0] }); - std::vector arguments = {}; - for (int i = 1; i < args.Length(); i++) { - arguments.push_back(ToString({ isolate, args[i] })); - } - - MyGlobal::Start(filename, arguments); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Sleep(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - int64_t ms = args[0]->Uint32Value(context).FromJust(); - v8::Unlocker unlocker(isolate); - MyGlobal::Sleep(ms); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetTimeout(const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - int32_t timeout = 0; - timeout = args[1]->Uint32Value(context).FromMaybe(timeout); - if (args[0].IsEmpty() || !args[0]->IsFunction()) { - throw std::invalid_argument("# function required."); - } - - TimerPrivate* p = new TimerPrivate(isolate, args[0].As()); - p->setTimeout([isolate](TimerPrivate* p) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::Local fn = p->fn.Get(isolate); - if (!fn.IsEmpty() && fn->IsFunction()) - fn->CallAsFunction(context, context->Global(), 0, {}); - } - V8_CREATE_LOCAL_CONTEXT_END - }, timeout); - - V8_GL_VALUE(isolate)->push_back(std::unique_ptr(p)); - args.GetReturnValue().Set(v8::External::New(isolate, p)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ClearTimeout(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (!args[0]->IsExternal()) - { - return; - } - if (auto* timer = static_cast(args[0].As()->Value()); timer) - { - timer->clearTimeout(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void SetInterval(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - int32_t repeat = 0; - repeat = args[1]->Uint32Value(context).FromMaybe(repeat); - - if (args[0].IsEmpty() || !args[0]->IsFunction()) { - throw std::invalid_argument("# function required."); - } - TimerPrivate* p = new TimerPrivate(isolate, args[0].As()); - p->setInterval([isolate](TimerPrivate* p) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::Local fn = p->fn.Get(isolate); - if (!fn.IsEmpty() && fn->IsFunction()) - fn->CallAsFunction(context, context->Global(), 0, {}); - } - V8_CREATE_LOCAL_CONTEXT_END - }, repeat); - V8_GL_VALUE(isolate)->push_back(std::unique_ptr(p)); - args.GetReturnValue().Set(v8::External::New(isolate, p)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ClearInterval(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (!args[0]->IsExternal()) - { - return; - } - if (auto* timer = static_cast(args[0].As()->Value()); timer) - { - timer->clearTimeout(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetLastError(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, error::GetLastErrorMessage().c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void SetLastError(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args[0]->IsNumber()) { - error::SetLastErrorMessage(args[0]->Int32Value(context).FromJust()); - } - else if (args[0]->IsString()) { - error::SetLastErrorMessage(ToString({ isolate, args[0] })); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WriteFile(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - std::string filename = ToString({ isolate, args[0] }); - std::string content = ToString({ isolate, args[1] }); - std::ios_base::openmode mode = std::ios_base::trunc; - - if (args.Length() > 2) { - mode = static_cast(args[2]->Int32Value(context).FromJust()); - } - MyGlobal::WriteFile(filename, content, mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ToUpperCase(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - std::string string = ToString({ isolate, args[0] }); - - int index = -1; - if (args.Length() > 1) { - index = args[1]->Int32Value(context).FromJust(); - } - std::string result = MyGlobal::ToUpperCase(string, index); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, result.c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ToNumber(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto v = ToArray(isolate, args[0]); - int type = 0; - if (args.Length() > 1) { - type = args[1]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(v8::Number::New(isolate, MyGlobal::ToNumber(v, type))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void WaitForDebugger(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto v = ToArray(isolate, args[0]); - int type = 0; - if (args.Length() > 1) { - type = args[1]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(v8::Number::New(isolate, MyGlobal::ToNumber(v, type))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/chrome_inspector/include/native_library.h b/chrome_inspector/include/native_library.h deleted file mode 100644 index b604b19..0000000 --- a/chrome_inspector/include/native_library.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include -namespace shelllet { - namespace library { - class NativeLibrary { - public: - NativeLibrary() = default; - ~NativeLibrary(); - bool initialize(v8::Isolate* isolate, const v8::Local& context); - void cleanup(); - private: - std::vector> libraries; - }; - Q_GLOBAL_STATIC(NativeLibrary, global_native_library) - } -} \ No newline at end of file diff --git a/chrome_inspector/include/options_manager.h b/chrome_inspector/include/options_manager.h deleted file mode 100644 index 7d53e48..0000000 --- a/chrome_inspector/include/options_manager.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "resource.h" -#include -#include - -namespace shelllet { - namespace options { - struct options_data { - std::filesystem::path modules_path; - std::string extension; - }; - class options_manager : public boost::serialization::singleton { - public: - options_manager(); - public: - void set_modules_path(const QString& path); - public: - options_data options; - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/tcp_server.h b/chrome_inspector/include/tcp_server.h deleted file mode 100644 index e9e7f8c..0000000 --- a/chrome_inspector/include/tcp_server.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include -#include -#include -#include "inspector.h" -QT_FORWARD_DECLARE_CLASS(QTimerEvent) -namespace shelllet { - namespace inspect { - class TcpServer : public QThread - { - public: - TcpServer(Receiver* receiver, const QHostAddress& address, uint16_t port); - - protected: - void run() override; - private: - Receiver* receiver_; - QHostAddress address_; - uint16_t port_; - boost::asio::io_context io_{ 1 }; - }; - } -} diff --git a/chrome_inspector/include/timer_resource.h b/chrome_inspector/include/timer_resource.h deleted file mode 100644 index ecb4c38..0000000 --- a/chrome_inspector/include/timer_resource.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "framework.h" -#include "resource.h" -#include - -namespace shelllet { - namespace resource { - class TimerPrivate : public Resource { - public: - TimerPrivate(v8::Isolate* isolate, const v8::Local& f); - public: - v8::Global fn; - std::unique_ptr timer; - QMetaObject::Connection connection; - void setTimeout(const std::function& cb, uint64_t timeout); - void clearTimeout(); - void setInterval(const std::function& cb, uint64_t repeat); - void clearInterval(); - protected: - void cleanup() override; - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/v8_util.h b/chrome_inspector/include/v8_util.h deleted file mode 100644 index 9659365..0000000 --- a/chrome_inspector/include/v8_util.h +++ /dev/null @@ -1,191 +0,0 @@ -#include -#include -#include -namespace shelllet { - static inline bool V8_IsBoolean(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsBoolean(); - } - static inline bool V8_IsString(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsString(); - } - static inline bool V8_IsUint8Array(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsUint8Array(); - } - static inline bool V8_IsNumber(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsNumber(); - } - static inline bool V8_IsUint32(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsUint32(); - } - static inline bool V8_IsInt32(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsInt32(); - } - static inline bool V8_IsBigInt(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsBigInt(); - } - static inline bool V8_IsObject(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsObject(); - } - static inline bool V8_IsSymbol(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsSymbol(); - } - static inline bool V8_IsExternal(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsExternal(); - } - static inline bool V8_IsFunction(const v8::FunctionCallbackInfo& args, int index) { - return args.Length() > index && args[index]->IsFunction(); - } - - template - static inline T V8_To_Ptr(const v8::Local& value) { - v8::Local external = v8::Local::Cast(value); - return static_cast(external->Value()); - } - - namespace convert { - class String : public v8::String { - public: - static v8::Local New(v8::Isolate* isolate, const QString& data) { - return v8::String::NewFromUtf8(isolate, data.toUtf8().constData()).ToLocalChecked(); - } - static v8::Local New(v8::Isolate* isolate, const char* data) { - return v8::String::NewFromUtf8(isolate, data).ToLocalChecked(); - } - static v8::Local New(v8::Isolate* isolate, const std::string& data) { - return v8::String::NewFromUtf8(isolate, data.c_str()).ToLocalChecked(); - } - static inline QString To(v8::Isolate* isolate, const v8::Local& value) { - v8::String::Utf8Value s = { isolate, value }; - if (*s) { - return *s; - } - return QString(); - } - }; - - class Object : public v8::Object { - public: - template - static inline T* UnWrap(const v8::Local& obj, int index = 0) { - if (obj->InternalFieldCount() > index) - return dynamic_cast(static_cast(obj->GetAlignedPointerFromInternalField(index))); - return nullptr; - } - static inline v8::Local Wrap(v8::Isolate* isolate, v8::Local context, const char* name, int argc, v8::Local argv[]) - { - v8::EscapableHandleScope scope(isolate); - v8::Local f = context->Global()->Get(context, convert::String::New(isolate, name)).ToLocalChecked(); - if (f->IsFunction()) { - v8::Local ctor = f.As(); - auto r = ctor->CallAsConstructor(context, argc, argv); - if (!r.IsEmpty()) - return scope.Escape(r.ToLocalChecked()); - } - throw std::runtime_error((boost::format("!`%1%` not registered.") % name).str()); - } - }; - class External : public v8::External { - public: - template - static inline T Value(const v8::Local& value) { - v8::Local external = v8::Local::Cast(value); - return static_cast(external->Value()); - } - }; - class Array : public v8::Array { - public: - static inline v8::Local New(v8::Isolate* isolate, const v8::Local& context, const QStringList& c) { - v8::EscapableHandleScope scope(isolate); - v8::Local array = v8::Array::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - array->Set(context, i, convert::String::New(isolate, c[i])); - } - return scope.Escape(array); - } - static inline void To(v8::Isolate* isolate, const v8::Local& context, const v8::Local& value, QStringList& list) { - v8::Local array = v8::Local::Cast(value); - if (!array.IsEmpty()) { - for (std::uint32_t i = 0; i < array->Length(); ++i) { - list.push_back(convert::String::To(isolate, array->Get(context, i).ToLocalChecked())); - } - } - } - }; - class Uint8Array : public v8::Uint8Array { - public: - static inline v8::Local New(v8::Isolate* isolate, const v8::Local& context, const QByteArray& bytes) { - v8::Local buffer = v8::ArrayBuffer::New(isolate, bytes.size()); - std::memcpy(buffer->GetContents().Data(), bytes.constData(), bytes.size()); - return v8::Uint8Array::New(buffer, 0, buffer->ByteLength()); - } - - static inline void To(const v8::Local& value, QByteArray& buffer) { - v8::Local array = v8::Local::Cast(value); - if (!array.IsEmpty()) { - buffer.resize(array->Length()); - array->CopyContents(buffer.data(), array->Length()); - } - } - }; - class Int32Array : public v8::Int32Array { - public: - template - static inline v8::Local New(v8::Isolate* isolate, const v8::Local& context, const T& c) { - v8::Local ar = v8::ArrayBuffer::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - ar->Set(context, i, v8::Int32::New(isolate, c[i])); - } - - return v8::Int32Array::New(ar, 0, ar->ByteLength()); - } - - static inline void ToVector(const v8::Local& value, QVector& buffer) { - v8::Local ar = v8::Local::Cast(value); - if (!ar.IsEmpty()) { - buffer.resize(ar->Length()); - ar->CopyContents(buffer.data(), ar->ByteLength()); - } - } - static inline QVector ToVector(const v8::Local& value) { - v8::Local ar = v8::Local::Cast(value); - QVector buffer; - if (!ar.IsEmpty()) { - buffer.resize(ar->Length()); - ar->CopyContents(buffer.data(), ar->ByteLength()); - } - return buffer; - } - }; - } - template - static inline v8::Local V8_From_Int32Array(v8::Isolate* isolate, const v8::Local& context, const T& c) { - v8::Local ar = v8::ArrayBuffer::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - ar->Set(context, i, v8::Int32::New(isolate, c[i])); - } - - return v8::Int32Array::New(ar, 0, ar->ByteLength()); - } - template - static inline v8::Local V8_From_ObjectArray(v8::Isolate* isolate, const v8::Local& context, const char* name, const T& c) { - v8::Local ar = v8::Array::New(isolate, c.size()); - for (int i = 0; i < c.size(); i++) { - v8::Local argv[] = { v8::External::New(isolate, (void*)&c[i]) }; - ar->Set(context, i, convert::Object::Wrap(isolate, context, name, std::size(argv), argv)); - } - return ar; - } - - static inline v8::Local Call(v8::Isolate* isolate, const v8::Local& context, const char* name, const char* object, int argc, v8::Local argv[]) { - if (object == nullptr) { - auto v = context->Global()->Get(context, convert::String::New(isolate, name)).ToLocalChecked(); - auto f = v8::Local::Cast(v); - return f->CallAsFunction(context, context->Global(), argc, argv).ToLocalChecked(); - } - auto m = context->Global()->Get(context, convert::String::New(isolate, object)).ToLocalChecked(); - auto o = m->ToObject(context).ToLocalChecked(); - auto v = o->Get(context, convert::String::New(isolate, name)).ToLocalChecked(); - auto f = v8::Local::Cast(v); - return f->CallAsFunction(context, o, argc, argv).ToLocalChecked(); - } -} diff --git a/chrome_inspector/include/websocket_listener.h b/chrome_inspector/include/websocket_listener.h deleted file mode 100644 index 40963b1..0000000 --- a/chrome_inspector/include/websocket_listener.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include "inspector.h" - -namespace shelllet { - namespace inspect { - class WebSocketListener : public std::enable_shared_from_this - { - public: - WebSocketListener(Receiver* receiver, boost::asio::io_context& ioc, boost::asio::ip::tcp::endpoint endpoint); - - public: - void run(); - private: - void doAccept(); - - void onAccept(boost::beast::error_code ec, boost::asio::ip::tcp::socket socket); - - private: - boost::asio::io_context& ioc_; - boost::asio::ip::tcp::acceptor acceptor_; - - Receiver* receiver_; - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/websocket_session.h b/chrome_inspector/include/websocket_session.h deleted file mode 100644 index 4615342..0000000 --- a/chrome_inspector/include/websocket_session.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include "inspector.h" - -namespace shelllet { - namespace inspect { - class WebsocketSession : public std::enable_shared_from_this - { - public: - explicit WebsocketSession(shelllet::inspect::Receiver* receiver, boost::asio::ip::tcp::socket&& socket); - - ~WebsocketSession(); - public: - template - void doAccept(boost::beast::http::request> req) - { - ws_.async_accept(req, boost::beast::bind_front_handler(&WebsocketSession::onAccept, shared_from_this())); - } - - void onAccept(boost::beast::error_code ec); - - void doRead(); - - void onRead(boost::beast::error_code ec, std::size_t bytes_transferred); - - void doWrite(const std::string& message); - private: - friend class Runnable; - boost::beast::websocket::stream ws_; - boost::beast::flat_buffer buffer_; - Receiver* receiver_; - bool is_read_ok_ = true; - std::list messages_; - QThread* thread_ = nullptr; - }; - } -} \ No newline at end of file diff --git a/chrome_inspector/include/worker.h b/chrome_inspector/include/worker.h deleted file mode 100644 index e1f562d..0000000 --- a/chrome_inspector/include/worker.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include -#include "inspector.h" -#include "inspector_agent.h" -#include "tcp_server.h" - -QT_FORWARD_DECLARE_CLASS(QEvent) -namespace shelllet { - namespace engine { - class Worker : public inspect::Receiver - { - public: - Worker(); - ~Worker(); - void run(const std::string& filename, bool inspect_brk); - protected: - virtual void customEvent(QEvent* event) override; - protected: - inspect::InspectorVersion requestInspectorVersion() override; - inspect::InspectorList requestInspectorList() override; - void finished(); - private: - std::unique_ptr agent_; - std::unique_ptr platform_; - inspect::TcpServer* worker_thread_ = nullptr; - }; - } // namespace engine -} diff --git a/chrome_inspector/src/error.cpp b/chrome_inspector/src/error.cpp deleted file mode 100644 index 5d5a015..0000000 --- a/chrome_inspector/src/error.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "framework.h" -#include "error.h" - -namespace shelllet { - thread_local std::string glErrorMessage; -} -std::string shelllet::error::GetLastErrorMessage() -{ - return glErrorMessage; -} - -void shelllet::error::SetLastErrorMessage(const std::variant& err) -{ - if (std::holds_alternative(err)) { - glErrorMessage = std::system_category().message(std::get(err)); - } - else if (std::holds_alternative(err)) { - glErrorMessage = std::get(err); - } -} \ No newline at end of file diff --git a/chrome_inspector/src/global.cpp b/chrome_inspector/src/global.cpp deleted file mode 100644 index 3211662..0000000 --- a/chrome_inspector/src/global.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include "framework.h" -#include -#include -#include -#include -#include -#include "native/global.h" - -QString shelllet::global::MyGlobal::Version() -{ - return VERSION; -} - -std::string shelllet::global::MyGlobal::dirname() -{ - return std::filesystem::current_path().string(); -} - -std::string shelllet::global::MyGlobal::Chdir(const std::string& tar) -{ - std::filesystem::path target = { tar }; - std::filesystem::path dir = std::filesystem::current_path().string(); - - if (!target.empty() && std::filesystem::exists(target)) { - std::filesystem::current_path(target); - } - return dir.string(); -} - -bool shelllet::global::MyGlobal::IEquals(const std::string& s1, const std::string& s2) -{ - return std::equal(s1.begin(), s1.end(), s2.begin(), s2.end(), [](char ch1, char ch2) { - return tolower(ch1) == tolower(ch2); - }); -} - -bool shelllet::global::MyGlobal::Start(const std::string& file, const std::vector& args) -{ - const char* quoted = R"(")"; - QString fixed = QString::fromStdString(file); - if (fixed.contains(" ")) { - if (!fixed.startsWith(quoted)) { - fixed = quoted + fixed; - } - - if (!fixed.endsWith(quoted)) { - fixed = fixed + quoted; - } - } - - if (args.empty()) { - return QProcess::startDetached(fixed); - } - QVector arguments(args.size()); - std::for_each(args.begin(), args.end(), [&arguments](const std::string& arg) { - arguments.push_back(QString::fromStdString(arg)); - }); - return QProcess::startDetached(fixed, QStringList::fromVector(arguments)); -} - -void shelllet::global::MyGlobal::Sleep(int64_t ms) -{ - std::this_thread::sleep_for(std::chrono::milliseconds(ms)); -} - -std::filesystem::path shelllet::global::MyGlobal::GetExePath() -{ - return QCoreApplication::applicationDirPath().toStdString(); -} - -std::filesystem::path shelllet::global::MyGlobal::GetHomePath() -{ - return QStandardPaths::writableLocation(QStandardPaths::HomeLocation).toStdString(); -} - -std::string shelllet::global::MyGlobal::Now() -{ - std::time_t t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); - std::vector buf(0xff, '\0'); - if (size_t size = std::strftime(buf.data(), buf.size(), "%F %T", std::localtime(&t))) { - return std::string(buf.begin(), buf.begin() + size); - } - return QDateTime::currentDateTime().toString().toStdString(); -} - -void shelllet::global::MyGlobal::WriteFile(const std::string& filename, const std::string& txt, std::ios_base::openmode mode /*= std::ios_base::trunc*/) -{ - std::ofstream file(filename, std::ofstream::out | mode); - if (file.is_open()) { - file << txt; - } -} - -std::string shelllet::global::MyGlobal::ToUpperCase(const std::string& string, int index /*= -1*/) -{ - std::string result = string; - if (index == -1) { - result = boost::to_upper_copy(string); - } - else if (index < string.length() && index >= 0) { - result[index] = std::toupper(result[index]); - } - return result; -} \ No newline at end of file diff --git a/chrome_inspector/src/http_session.cpp b/chrome_inspector/src/http_session.cpp deleted file mode 100644 index 8e4becd..0000000 --- a/chrome_inspector/src/http_session.cpp +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "framework.h" -#include "http_session.h" -#include "websocket_session.h" - -namespace shelllet { - // https://github.com/boostorg/beast/blob/develop/example/advanced/server/advanced_server.cpp - static std::string id = QUuid::createUuid().toString(QUuid::WithoutBraces).toStdString(); - - std::string FrontendUrl(const std::string& address, uint16_t port) { - std::ostringstream frontendUrl; - frontendUrl << "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws="; - frontendUrl << address << ":" << port << "/" << id; - return frontendUrl.str(); - } - std::string HandleReqVersion(inspect::Receiver* receiver) - { - // https://chromedevtools.github.io/devtools-protocol/ - auto version = receiver->requestInspectorVersion(); - - QJsonObject json = { {"Browser", QString::fromStdString(version.browser)}, {"Protocol-Version", QString::fromStdString(version.version)} }; - QJsonDocument document(json); - return document.toJson(QJsonDocument::Indented).constData(); - } - - std::string HandleReqList(inspect::Receiver* receiver) - { - // https://chromedevtools.github.io/devtools-protocol/ - - auto info = receiver->requestInspectorList(); - - std::ostringstream ws; - ws << "ws://" << info.address << ":" << info.port << "/" << id; - - std::string frontend_url = FrontendUrl(info.address, info.port); - - QJsonObject obj = { {"id", QString::fromStdString(id) }, {"description", QString::fromStdString(info.description)}, - {"type", QString::fromStdString(info.type)}, - {"title", QString::fromStdString(info.title)}, - {"url", QString::fromStdString(info.url)}, - {"webSocketDebuggerUrl", QString::fromStdString(ws.str())}, - {"devtoolsFrontendUrl", QString::fromStdString(frontend_url)}, - }; - QJsonArray array = { obj }; - QJsonDocument document(array); - - return document.toJson(QJsonDocument::Indented).constData(); - } - - template - void HandleRequest(inspect::Receiver* receiver, boost::beast::http::request>&& req, Send&& send) { - static std::map> handlers = { - {"/json/version", HandleReqVersion }, - {"/json", HandleReqList }, - {"/json/list", HandleReqList } - }; - - auto const bad_request = [&req](boost::beast::string_view why) - { - boost::beast::http::response res{ boost::beast::http::status::bad_request, req.version() }; - res.set(boost::beast::http::field::server, BOOST_BEAST_VERSION_STRING); - res.set(boost::beast::http::field::content_type, "text/html"); - res.keep_alive(req.keep_alive()); - res.body() = std::string(why); - res.prepare_payload(); - return res; - }; - - if (!handlers.contains(req.target())) { - LOG_WARN("inspect") << "# target: `" << req.target() << "` not supported." << std::endl; - return send(bad_request("Illegal request-target")); - } - boost::beast::http::dynamic_body::value_type body; - boost::beast::ostream(body) << handlers[req.target()](receiver).c_str(); - auto const size = body.size(); - - boost::beast::http::response res{ - std::piecewise_construct, - std::make_tuple(std::move(body)), - std::make_tuple(boost::beast::http::status::ok, req.version()) }; - res.set(boost::beast::http::field::content_type, "application/json; charset=UTF-8"); - res.set(boost::beast::http::field::cache_control, "no-cache"); - res.content_length(size); - res.keep_alive(req.keep_alive()); - return send(std::move(res)); - } -} -shelllet::inspect::HttpSession::HttpSession(shelllet::inspect::Receiver* receiver, boost::asio::ip::tcp::socket&& socket) - : receiver_(receiver) - , stream_(std::move(socket)) - , queue_(*this) -{ -} - -void shelllet::inspect::HttpSession::run() -{ - boost::asio::dispatch(stream_.get_executor(), boost::beast::bind_front_handler(&HttpSession::doRead, this->shared_from_this())); -} - -void shelllet::inspect::HttpSession::doRead() -{ - parser_.emplace(); - - boost::beast::http::async_read(stream_, buffer_, *parser_, boost::beast::bind_front_handler(&HttpSession::onRead, shared_from_this())); -} - -void shelllet::inspect::HttpSession::onRead(boost::beast::error_code ec, std::size_t bytes_transferred) -{ - boost::ignore_unused(bytes_transferred); - - if (ec == boost::beast::http::error::end_of_stream) - return doClose(); - - if (ec) { - LOG_ERROR("inspect") << "# read error " << ec.message() << std::endl; - return; - } - if (boost::beast::websocket::is_upgrade(parser_->get())) - { - LOG_TRACE("inspect") << "# websocket created." << std::endl; - std::make_shared(receiver_, stream_.release_socket())->doAccept(parser_->release()); - return; - } - - HandleRequest(receiver_, parser_->release(), queue_); - - if (!queue_.isFull()) - doRead(); -} - -void shelllet::inspect::HttpSession::onWrite(bool close, boost::beast::error_code ec, std::size_t bytes_transferred) -{ - boost::ignore_unused(bytes_transferred); - - if (ec) { - LOG_ERROR("inspect") << "# read error " << ec.message() << std::endl; - return; - } - - if (close) - { - return doClose(); - } - if (queue_.onWrite()) - { - doRead(); - } -} - -void shelllet::inspect::HttpSession::doClose() -{ - boost::system::error_code ec; - stream_.socket().shutdown(boost::asio::ip::tcp::socket::shutdown_send, ec); -} \ No newline at end of file diff --git a/chrome_inspector/src/inspector_agent.cpp b/chrome_inspector/src/inspector_agent.cpp deleted file mode 100644 index cc96f57..0000000 --- a/chrome_inspector/src/inspector_agent.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include -#include -#include "framework.h" -#include "inspector_agent.h" -#include "native/global_implement.h" -#include "native/console_implement.h" -#include "qtcore/initialize.h" -#include "qtgui/initialize.h" -#include "opencv/initialize.h" -#include "native_library.h" -namespace shelllet { - static v8::ScriptOrigin NewScriptOrigin(const char* resourceName, v8::Isolate* isolate) { - return { V8_NEW_STRING_VAR(isolate, resourceName), - v8::Integer::New(isolate, 0), - v8::Integer::New(isolate, 0), - v8::False(isolate), - v8::Local(), - v8::Local(), - False(isolate), - False(isolate), - True(isolate) - }; - } - - using namespace global; - using namespace engine; - using namespace inspect; - using namespace library; - v8::Global global_context; -} - -void shelllet::engine::InspectorAgent::disconnectInspector() -{ - if (inspector_client_) - inspector_client_->disconnectFrontend(); -} - -void shelllet::engine::InspectorAgent::postInspectorMessage(const QString& message) -{ - inspector_client_->postInspectorMessage(message.toStdString()); -} - -void shelllet::engine::InspectorAgent::pumpMessageLoop() -{ - if (inspector_client_) - inspector_client_->pumpMessageLoop(); -} - -shelllet::engine::InspectorAgent::InspectorAgent(QObject* receiver, v8::Platform* platform, const std::string& filename, const std::string& source, const std::string& dir, bool inspect_brk) - : receiver_(receiver) - , platform_(platform) - , name_(filename) - , code_(source) - , dir_(dir) - , inspect_brk_(inspect_brk) -{ - create_params_.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); - - isolate_ = v8::Isolate::New(create_params_); - isolate_->SetData(static_cast(IsolateData::GlobalContext), &global_context); - //isolate->SetData(static_cast(IsolateData::GlobalValue), &resources); - isolate_->SetData(static_cast(IsolateData::SetErrorAddress), error::SetLastErrorMessage); -} - -shelllet::InspectorAgent::~InspectorAgent() -{ - { - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - while (v8::platform::PumpMessageLoop(platform_, isolate_)) { - QCoreApplication::processEvents(); - } - inspector_client_.reset(nullptr); - } - isolate_->Dispose(); - - delete create_params_.array_buffer_allocator; -} - -void shelllet::engine::InspectorAgent::evaluate() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - v8::TryCatch try_catch(isolate_); - v8::Local context = v8::Local::New(isolate_, global_context); - v8::Context::Scope context_scope(context); - - v8::ScriptOrigin origin = NewScriptOrigin(name_.c_str(), isolate_); - v8::ScriptCompiler::Source sourceText(V8_NEW_STRING_VAR(isolate_, code_.c_str()), origin); - - v8::Local module; - - if (!v8::ScriptCompiler::CompileModule(isolate_, &sourceText).ToLocal(&module) && try_catch.HasCaught()) { - LOG_ERROR("engine") << GetException(isolate_, try_catch); - return; - } - if (!module->InstantiateModule(context, [](v8::Local context, - v8::Local specifier, - v8::Local referrer)->v8::MaybeLocal { - v8::String::Utf8Value param(context->GetIsolate(), specifier); - std::string filename = std::string(*param); - v8::Isolate* isolate = context->GetIsolate(); - v8::TryCatch tryCatch(isolate); - - v8::String::Utf8Value u8(isolate, context->GetEmbedderData(static_cast(ContextEmbedderData::WorkingDirectory))); - std::filesystem::path path = std::filesystem::path(*u8).append(filename).lexically_normal(); - - std::ifstream ifs(path); - std::string code((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); - - v8::ScriptOrigin origin = NewScriptOrigin(filename.c_str(), context->GetIsolate()); - v8::ScriptCompiler::Source source(V8_NEW_STRING_VAR(isolate, code.c_str()), origin); - v8::MaybeLocal result = v8::ScriptCompiler::CompileModule(context->GetIsolate(), &source); - - if (tryCatch.HasCaught()) { - LOG_WARN("engine") << GetException(isolate, tryCatch); - v8::ScriptCompiler::Source source(V8_NEW_STRING_VAR(isolate, ""), origin); - return v8::ScriptCompiler::CompileModule(context->GetIsolate(), &source); - } - return result; - }).IsNothing()) { - module->Evaluate(context); - } - - if (try_catch.HasCaught()) { - LOG_ERROR("engine") << GetException(isolate_, try_catch); - } -} - -void shelllet::engine::InspectorAgent::run() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - v8::TryCatch try_catch(isolate_); - { - v8::Local objectTemplate = v8::ObjectTemplate::New(isolate_); - { - static_cast(std::make_unique(isolate_, objectTemplate)); - qtcore::initialize(isolate_, objectTemplate); - } - - v8::Local context = v8::Context::New(isolate_, nullptr, objectTemplate); - context->SetEmbedderData(static_cast(ContextEmbedderData::WorkingDirectory), V8_NEW_STRING_VAR(isolate_, dir_.c_str())); - - v8::Context::Scope contextScope(context); - - { - context->Global()->Set(context, V8_NEW_STRING_VAR(isolate_, Console::Name()), Console::WrapClass(isolate_)->GetFunction(context).ToLocalChecked()); - } - - // opencv - { - v8::Local proto = v8::ObjectTemplate::New(isolate_); - opencv::initialize(isolate_, proto); - - auto instance = proto->NewInstance(context); - - if (auto result = context->Global()->Set(context, V8_NEW_STRING_VAR(isolate_, "cv"), instance.ToLocalChecked()); result.IsNothing()) { - LOG_ERROR("v8") << GetException(isolate_, try_catch); - return; - } - } - { - v8::Local args = v8::Array::New(isolate_, __argc); - for (int i = 0; i < __argc; ++i) { - args->Set(context, i, V8_NEW_STRING_VAR(isolate_, __argv[i])); - } - context->Global()->Set(context, V8_NEW_STRING_VAR(isolate_, "arguments"), args); - } - if (!loadModules(context) && try_catch.HasCaught()) { - LOG_ERROR("engine") << GetException(isolate_, try_catch); - return; - } - global_context.Reset(isolate_, context); - } - - if (inspect_brk_) { - inspector_client_.reset(new InspectorClient(receiver_, global_context.Get(isolate_), platform_)); - isolate_->RequestInterrupt([](v8::Isolate* isolate, void* data) { - InspectorAgent* agent = static_cast(data); - agent->pumpMessageLoop(); - }, this); - } - else { - QCoreApplication::postEvent(receiver_, new ContinueRunEvent); - } -} - -void shelllet::engine::InspectorAgent::cleanup() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - if (inspect_brk_) { - disconnectInspector(); - } - - global_native_library->cleanup(); -#ifdef _DEBUG - isolate_->RequestGarbageCollectionForTesting(v8::Isolate::kFullGarbageCollection); -#endif // _DEBUG - - global_context.Reset(); -} \ No newline at end of file diff --git a/chrome_inspector/src/inspector_channel.cpp b/chrome_inspector/src/inspector_channel.cpp deleted file mode 100644 index ad7459d..0000000 --- a/chrome_inspector/src/inspector_channel.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "inspector_channel.h" -#include "inspector_client.h" -void shelllet::inspect::InspectorChannel::sendResponse(int call_id, std::unique_ptr message) -{ - boost::ignore_unused(call_id); - client_->sendMessageToFrontend(message->string()); -} - -void shelllet::inspect::InspectorChannel::sendNotification(std::unique_ptr message) -{ - client_->sendMessageToFrontend(message->string()); -} - -void shelllet::inspect::InspectorChannel::pauseOnNextJavascriptStatement(const std::string& reason) -{ - auto buffer = v8_inspector::StringBuffer::create({ reinterpret_cast(reason.c_str()), reason.length() }); - session_->schedulePauseOnNextStatement(buffer->string(), buffer->string()); -} - -void shelllet::inspect::InspectorChannel::dispatchProtocolMessage(const std::string& message) -{ - session_->dispatchProtocolMessage({ reinterpret_cast(message.c_str()), message.length() }); -} - -shelllet::inspect::InspectorChannel::InspectorChannel(v8_inspector::V8Inspector* inspector, InspectorClient* c) :client_(c) -{ - std::string debugger = "{}"; - session_ = inspector->connect(1, this, v8_inspector::StringView(reinterpret_cast(debugger.c_str()), debugger.length())); -} \ No newline at end of file diff --git a/chrome_inspector/src/inspector_client.cpp b/chrome_inspector/src/inspector_client.cpp deleted file mode 100644 index 448c9c4..0000000 --- a/chrome_inspector/src/inspector_client.cpp +++ /dev/null @@ -1,173 +0,0 @@ -#include -#include -#include -#include - -#include "framework.h" -#include "inspector_client.h" - -namespace shelllet { - const int kContextGroupId = 1; - class DispatchMessagesTask : public v8::Task { - public: - explicit DispatchMessagesTask(inspect::InspectorClient* agent, const std::string& message) - : agent_(agent) - , message_(message) { - } - - void Run() override { - if (agent_ != nullptr) { - agent_->dispatchProtocolMessage(message_); - } - } - - private: - inspect::InspectorClient* agent_; - std::string message_; - }; - - extern v8::Global global_context; -} -shelllet::inspect::InspectorClient::InspectorClient(QObject* receiver, const v8::Local& context, v8::Platform* platform) - : isolate_(context->GetIsolate()) - , platform_(platform) - , receiver_(receiver) -{ - std::string name = "{}"; - inspector_ = v8_inspector::V8Inspector::create(isolate_, this); - inspector_->contextCreated(v8_inspector::V8ContextInfo( - context, kContextGroupId, v8_inspector::StringView(reinterpret_cast(name.c_str()), name.length()))); - - channel_.reset(new InspectorChannel(inspector_.get(), this)); -} - -void shelllet::inspect::InspectorClient::sendMessageToFrontend(const v8_inspector::StringView& string) -{ - int length = static_cast(string.length()); - - v8::Local message = (string.is8Bit() - ? v8::String::NewFromOneByte( - isolate_, - reinterpret_cast(string.characters8())/*, - v8::NewStringType::kNormal, length*/) - : v8::String::NewFromTwoByte( - isolate_, - reinterpret_cast(string.characters16())/*, - v8::NewStringType::kNormal, length*/)) - .ToLocalChecked(); - std::string resp = ToString({ isolate_, message }); - QCoreApplication::postEvent(receiver_, new MessageOutEvent(resp)); -} - -void shelllet::inspect::InspectorClient::runMessageLoopOnPause(int contextGroupId) -{ - is_paused_ = true; - while (is_paused_ && waitForFrontendMessageWhilePaused()) { - pumpMessageLoop(); - } - is_paused_ = false; -} - -void shelllet::inspect::InspectorClient::quitMessageLoopOnPause() -{ - is_paused_ = false; -} - -void shelllet::inspect::InspectorClient::pauseOnNextJavascriptStatement(const std::string& reason) -{ - if (channel_) - channel_->pauseOnNextJavascriptStatement(reason); -} - -double shelllet::inspect::InspectorClient::currentTimeMS() -{ - return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); -} - -void shelllet::inspect::InspectorClient::runIfWaitingForDebugger(int contextGroupId) -{ - pauseOnNextJavascriptStatement("Break at bootstrap"); - QCoreApplication::postEvent(receiver_, new ContinueRunEvent); -} -// -//std::unique_ptr shelllet::inspect::InspectorClient::resourceNameToUrl(const v8_inspector::StringView& resourceName) -//{ -// v8::Locker locker(isolate_); -// v8::HandleScope handle_scope(isolate_); -// int length = static_cast(resourceName.length()); -// //DCHECK_LT(length, v8::String::kMaxLength); -// v8::Local message = -// (resourceName.is8Bit() -// ? v8::String::NewFromOneByte( -// isolate_, -// reinterpret_cast(resourceName.characters8()), -// v8::NewStringType::kNormal, length) -// : v8::String::NewFromTwoByte( -// isolate_, -// reinterpret_cast(resourceName.characters16()), -// v8::NewStringType::kNormal, length)) -// .ToLocalChecked(); -// std::filesystem::path file = shelllet::ToString({ isolate_, message }); -// //file = "E:\\vision\\debug.js"; -// if (!std::filesystem::is_regular_file(file)) -// return nullptr; -// -// std::string url = QUrl::fromLocalFile(QString::fromUtf8(file.string().c_str())).url().toStdString(); -// return v8_inspector::StringBuffer::create({ reinterpret_cast (url.c_str()), url.size() }); -//} - -void shelllet::inspect::InspectorClient::postInspectorMessage(const std::string& message) -{ - //v8::Locker locker(isolate_); - //v8::Isolate::Scope isolate_scope(isolate_); - //v8::HandleScope handle_scope(isolate_); - platform_->GetForegroundTaskRunner(isolate_)->PostTask(std::make_unique(this, message)); - if (is_paused_) - is_ready_ = true; - else { - QCoreApplication::postEvent(receiver_, new PumpMessageLoopEvent); - } -} - -void shelllet::inspect::InspectorClient::consoleAPIMessage(int contextGroupId, v8::Isolate::MessageErrorLevel level, const v8_inspector::StringView& message, const v8_inspector::StringView& url, unsigned lineNumber, unsigned columnNumber, v8_inspector::V8StackTrace*) -{ - throw std::logic_error("The method or operation is not implemented."); -} - -v8::Local shelllet::inspect::InspectorClient::ensureDefaultContextInGroup(int groupId) -{ - return global_context.Get(isolate_); -} - -void shelllet::inspect::InspectorClient::dispatchProtocolMessage(const std::string& message) -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - channel_->dispatchProtocolMessage(message); -} - -bool shelllet::inspect::InspectorClient::waitForFrontendMessageWhilePaused() -{ - while (!is_ready_) { - QCoreApplication::processEvents(); - } - is_ready_ = !is_ready_; - return true; -} - -void shelllet::inspect::InspectorClient::disconnectFrontend() -{ - is_ready_ = true; - quitMessageLoopOnPause(); -} - -void shelllet::inspect::InspectorClient::pumpMessageLoop() -{ - v8::Locker locker(isolate_); - v8::Isolate::Scope isolate_scope(isolate_); - v8::HandleScope handle_scope(isolate_); - while (v8::platform::PumpMessageLoop(platform_, isolate_)) { - QCoreApplication::processEvents(); - } -} \ No newline at end of file diff --git a/chrome_inspector/src/logs.cpp b/chrome_inspector/src/logs.cpp deleted file mode 100644 index e0601eb..0000000 --- a/chrome_inspector/src/logs.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "framework.h" -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "native/global_implement.h" -#include "logs.h" - -namespace shelllet { - typedef boost::log::sinks::synchronous_sink sink_debug_t; - typedef boost::log::sinks::synchronous_sink event_sink_t; - - BOOST_LOG_ATTRIBUTE_KEYWORD(keyword_channel, "Channel", std::string); - - static auto gl_format = (boost::log::expressions::format("[%1%]<%2%> : <%3%> %4%") - % boost::log::expressions::format_date_time("TimeStamp", "%Y-%m-%d %H:%M:%S") - % boost::log::expressions::attr< std::string >("Channel") - % boost::log::trivial::severity - % boost::log::expressions::message); - using namespace global; -} -void shelllet::logs::Logger::initialize(boost::log::trivial::severity_level level) -{ - boost::log::add_common_attributes(); - - boost::log::core::get()->set_filter(boost::log::trivial::severity >= level); - - boost::shared_ptr sink(new sink_debug_t()); - sink->set_formatter(gl_format); - sink->set_filter(boost::log::expressions::is_debugger_present()); - //boost::log::core::get()->set_filter(boost::log::expressions::is_debugger_present()); - boost::log::core::get()->add_sink(sink); - - boost::log::add_console_log(std::clog, boost::log::keywords::format = gl_format); - - std::filesystem::path dir = MyGlobal::GetHomePath() / "shelllet.com/logs"; - std::filesystem::create_directories(dir); - auto location = dir / (boost::erase_all_copy(MyGlobal::Now(), ":") + ".log"); - - boost::log::add_file_log(boost::log::keywords::file_name = location.c_str(), - boost::log::keywords::rotation_size = 1 * 1024 * 1024, - boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0), - boost::log::keywords::format = gl_format - //boost::log::keywords::channel = keyword_channel == channel - ); -} - -boost::log::trivial::severity_level shelllet::logs::Logger::LevelFromString(const QString& level) -{ - static QMap map = { - {"trace", boost::log::trivial::trace} , - {"debug", boost::log::trivial::debug} , - {"info", boost::log::trivial::info} , - {"warning", boost::log::trivial::warning} , - {"error", boost::log::trivial::error} , - {"fatal", boost::log::trivial::fatal} - }; - - if (auto itor = map.constFind(level); itor != map.cend()) { - return itor.value(); - } - return boost::log::trivial::fatal; -} \ No newline at end of file diff --git a/chrome_inspector/src/main.cc b/chrome_inspector/src/main.cc deleted file mode 100644 index 9c3e4b1..0000000 --- a/chrome_inspector/src/main.cc +++ /dev/null @@ -1,89 +0,0 @@ -#include "framework.h" -#include -#include "worker.h" -#include "logs.h" -#include "options_manager.h" -#include "native/global_implement.h" -#include -#include -#include -#include "native/global.h" - -namespace shelllet { - using namespace engine; - using namespace global; - class Application; - class Event : public QEvent { - public: - static inline QEvent::Type Type = static_cast(registerEventType()); - Event(const QString& file, bool inspect_brk) - : QEvent(Type), - file_(file), - inspect_brk_(inspect_brk) {} - private: - QString file_; - bool inspect_brk_; - friend class Application; - }; - class Application : public QApplication { - public: - Application(int& argc, char** argv) : QApplication(argc, argv) { - } - protected: - void customEvent(QEvent* event) override - { - if (auto* e = dynamic_cast(event)) { - worker_->run(e->file_.toStdString(), e->inspect_brk_); - } - } - private: - std::unique_ptr worker_ = std::make_unique(); - }; -} - -int main(int argc, char* argv[]) -{ -#if defined(WIN32) - if (CP_UTF8 != GetConsoleOutputCP()) - SetConsoleOutputCP(CP_UTF8); -#endif - using namespace shelllet; - Application app(argc, argv); - QCoreApplication::setApplicationName("let"); - QCoreApplication::setApplicationVersion(MyGlobal::Version()); - QCoreApplication::setOrganizationName(MyGlobal::Version()); - //v8::V8::SetFlagsFromCommandLine(&argc, argv, true); - - QCommandLineParser parser; - parser.setApplicationDescription(QObject::tr("A JavaScript engine that executes JavaScript (JS) code.")); - parser.addPositionalArgument("source", QObject::tr("Source file.")); - parser.addHelpOption(); - parser.addVersionOption(); - - QCommandLineOption logLevel = { "level", QObject::tr("set logs level."), "error,warning", -#ifdef _DEBUG - "trace" -#else - "warning" -#endif // _DEBUG - }; - QCommandLineOption moduleDir = { "modules-dir", - QObject::tr("set modules dir."), "path", QString::fromStdString(options::options_manager::get_mutable_instance().options.modules_path.string()) }; - - QCommandLineOption inspectBrk = { "inspect-brk", QObject::tr("inspect break at js debug."), "boolean", "false" }; - - parser.addOptions({ logLevel, moduleDir, inspectBrk }); - - parser.process(app); - - const QStringList args = parser.positionalArguments(); - if (args.length() > 0) { - logs::logger->initialize(logs::Logger::LevelFromString(parser.value(logLevel))); - - options::options_manager::get_mutable_instance().set_modules_path(parser.value(moduleDir)); - - QCoreApplication::postEvent(&app, new Event(args[0], QVariant(parser.value(inspectBrk)).toBool())); - return app.exec(); - } - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/chrome_inspector/src/native_library.cpp b/chrome_inspector/src/native_library.cpp deleted file mode 100644 index f3ba537..0000000 --- a/chrome_inspector/src/native_library.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "framework.h" -#include "native_library.h" -#include "options_manager.h" -namespace shelllet { - typedef void (*Initialize)(v8::Isolate*, const v8::Local&); - typedef const char* (*Name)(); -} -bool shelllet::library::NativeLibrary::initialize(v8::Isolate* isolate, const v8::Local& context) -{ - std::filesystem::path exe = options::options_manager::get_const_instance().options.modules_path; - try - { - for (auto& p : std::filesystem::directory_iterator(exe)) - { - if (!p.is_regular_file()) - continue; - auto& path = p.path(); - LOG_DEBUG("engine") << "# modules: " << path; - if (path.extension() != options::options_manager::get_const_instance().options.extension) - continue; - - std::unique_ptr< QLibrary> lib = std::make_unique(QString::fromStdString(path.string())); - v8::Local proto = v8::ObjectTemplate::New(isolate); - - if (!lib->load()) { - // qCDebug(shelllet_engine) << "# initialize " << library->fileName(); - return false; - } - auto initialize = (Initialize)lib->resolve("initialize"); - if (!initialize) { - return false; - } - initialize(isolate, proto); - - auto instance = proto->NewInstance(context); - if (instance.IsEmpty()) { - return false; - } - auto name = (Name)lib->resolve("name"); - - if (auto result = context->Global()->Set(context, V8_NEW_STRING_VAR(isolate, name()), instance.ToLocalChecked()); result.IsNothing()) - return false; - - libraries.push_back(std::move(lib)); - } - } - catch (const std::exception& err) - { - LOG_WARN("engine") << "# modules loaded: " << QString::fromLocal8Bit(err.what()).toStdString() << std::endl; - } - return true; -} - -void shelllet::library::NativeLibrary::cleanup() -{ - for (auto& lib : libraries) - { - typedef void (*CleanupFunction)(); - CleanupFunction cleanup = nullptr; - - if (lib->isLoaded()) { - auto cleanup = (CleanupFunction)lib->resolve("cleanup"); - if (cleanup) { - cleanup(); - } - lib->unload(); - } - } -} - -shelllet::library::NativeLibrary::~NativeLibrary() -{ - cleanup(); -} \ No newline at end of file diff --git a/chrome_inspector/src/options_manager.cpp b/chrome_inspector/src/options_manager.cpp deleted file mode 100644 index dcdd133..0000000 --- a/chrome_inspector/src/options_manager.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "framework.h" -#include "options_manager.h" -#include "native/global_implement.h" - -shelllet::options::options_manager::options_manager() -{ - options.modules_path = std::filesystem::current_path() / "modules"; - options.extension = ".dll"; -} - -void shelllet::options::options_manager::set_modules_path(const QString& path) -{ - options.modules_path = path.toStdString(); -} \ No newline at end of file diff --git a/chrome_inspector/src/plugin_load.cpp b/chrome_inspector/src/plugin_load.cpp deleted file mode 100644 index 32b0871..0000000 --- a/chrome_inspector/src/plugin_load.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "framework.h" -#include "inspector_agent.h" -#include "native_library.h" -namespace shelllet { - using namespace library; - extern v8::Global global_context; -} -bool shelllet::engine::InspectorAgent::loadModules(v8::Local context) -{ - return global_native_library->initialize(isolate_, context); -} \ No newline at end of file diff --git a/chrome_inspector/src/tcp_server.cpp b/chrome_inspector/src/tcp_server.cpp deleted file mode 100644 index cc44b68..0000000 --- a/chrome_inspector/src/tcp_server.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include "framework.h" -#include "tcp_server.h" -#include "websocket_listener.h" -void shelllet::inspect::TcpServer::run() -{ - std::make_shared(receiver_, io_, boost::asio::ip::tcp::endpoint{ boost::asio::ip::make_address(address_.toString().toStdString()), port_ })->run(); - io_.run(); -} - -shelllet::inspect::TcpServer::TcpServer(Receiver* receiver, const QHostAddress& address, uint16_t port) - : receiver_(receiver) - , address_(address) - , port_(port) -{ -} \ No newline at end of file diff --git a/chrome_inspector/src/timer_resource.cpp b/chrome_inspector/src/timer_resource.cpp deleted file mode 100644 index 6a84377..0000000 --- a/chrome_inspector/src/timer_resource.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include -#include "timer_resource.h" -#include "native/global_implement.h" - -namespace shelllet { - using namespace global; -} -shelllet::resource::TimerPrivate::TimerPrivate(v8::Isolate* isolate, const v8::Local& f) - : fn(isolate, f) -{ -} - -void shelllet::resource::TimerPrivate::setTimeout(const std::function& cb, uint64_t timeout) -{ - timer = std::make_unique(); - connection = timer->callOnTimeout([this, cb]() { - cb(this); - }); - timer->setSingleShot(true); - timer->setTimerType(Qt::CoarseTimer); - timer->start(timeout); -} - -void shelllet::resource::TimerPrivate::clearTimeout() -{ - timer->stop(); - timer->disconnect(connection); -} - -void shelllet::resource::TimerPrivate::setInterval(const std::function& cb, uint64_t repeat) -{ - timer = std::make_unique(); - connection = timer->callOnTimeout([this, cb]() { - cb(this); - }); - timer->setSingleShot(false); - timer->setInterval(repeat); - timer->setTimerType(Qt::CoarseTimer); - timer->start(); -} - -void shelllet::resource::TimerPrivate::clearInterval() -{ - timer->stop(); - timer->disconnect(connection); -} - -void shelllet::resource::TimerPrivate::cleanup() -{ - clearTimeout(); - clearInterval(); - fn.Reset(); -} \ No newline at end of file diff --git a/chrome_inspector/src/websocket_listener.cpp b/chrome_inspector/src/websocket_listener.cpp deleted file mode 100644 index 6cee1b7..0000000 --- a/chrome_inspector/src/websocket_listener.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "framework.h" -#include "websocket_listener.h" -#include "http_session.h" - -namespace shelllet { -} - -shelllet::inspect::WebSocketListener::WebSocketListener(shelllet::inspect::Receiver* receiver, boost::asio::io_context& ioc, boost::asio::ip::tcp::endpoint endpoint) - : receiver_(receiver) - , ioc_(ioc) - , acceptor_(ioc) -{ - boost::beast::error_code ec; - acceptor_.open(endpoint.protocol(), ec); - if (ec) - { - LOG_ERROR("inspect") << "# open error: " << ec.message() << std::endl; - return; - } - - acceptor_.set_option(boost::asio::socket_base::reuse_address(true), ec); - if (ec) - { - LOG_ERROR("inspect") << "# set option error: " << ec.message() << std::endl; - return; - } - acceptor_.bind(endpoint, ec); - if (ec) - { - LOG_ERROR("inspect") << "# bind error: " << ec.message() << std::endl; - return; - } - - acceptor_.listen(boost::asio::socket_base::max_listen_connections, ec); - if (ec) - { - LOG_ERROR("inspect") << "# set option error: " << ec.message() << std::endl; - } -} - -void shelllet::inspect::WebSocketListener::run() -{ - boost::asio::dispatch(acceptor_.get_executor(), boost::beast::bind_front_handler(&WebSocketListener::doAccept, this->shared_from_this())); -} - -void shelllet::inspect::WebSocketListener::doAccept() -{ - acceptor_.async_accept(boost::asio::make_strand(ioc_), boost::beast::bind_front_handler(&WebSocketListener::onAccept, shared_from_this())); -} - -void shelllet::inspect::WebSocketListener::onAccept(boost::beast::error_code ec, boost::asio::ip::tcp::socket socket) -{ - if (ec) - { - LOG_ERROR("inspect") << "# accept error: " << ec.message() << std::endl; - } - else - { - std::make_shared(receiver_, std::move(socket))->run(); - } - if (QThread::currentThread()->isInterruptionRequested()) { - ioc_.stop(); - return; - } - doAccept(); -} \ No newline at end of file diff --git a/chrome_inspector/src/websocket_session.cpp b/chrome_inspector/src/websocket_session.cpp deleted file mode 100644 index 83a9f5c..0000000 --- a/chrome_inspector/src/websocket_session.cpp +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "framework.h" -#include "websocket_session.h" -namespace shelllet { - std::mutex mutex; -} -shelllet::inspect::WebsocketSession::WebsocketSession(shelllet::inspect::Receiver* receiver, boost::asio::ip::tcp::socket&& socket) - : receiver_(receiver) - , ws_(std::move(socket)) -{ - receiver_->callback = [this](auto& message) { - std::lock_guard lock_guard(mutex); - messages_.emplace_front(message); - }; -} - -shelllet::inspect::WebsocketSession::~WebsocketSession() -{ - receiver_->callback = {}; - LOG_TRACE("inspect") << "# ~websocket_session." << std::endl; -} - -//void shelllet::inspect::WebsocketSession::customEvent(QEvent* event) -//{ -// if (auto* e = dynamic_cast(event)) { -// doRead(); -// } -// else if (auto* e = dynamic_cast(event)) { -// doWrite(messages_.back()); -// messages_.pop_back(); -// } -//} - -void shelllet::inspect::WebsocketSession::onAccept(boost::beast::error_code ec) -{ - if (ec) { - LOG_ERROR("inspect") << "# accept error: " << ec.message() << std::endl; - return; - } - - class Runnable : public QRunnable { - public: - Runnable(const std::shared_ptr& session) :self_(session) { - } - void run() override { - self_->thread_ = QThread::currentThread(); - while (true) { - if (QThread::currentThread()->isInterruptionRequested()) { - break; - } - if (self_->messages_.empty()) { - self_->doRead(); - } - else { - std::lock_guard lock_guard(mutex); - self_->doWrite(self_->messages_.back()); - self_->messages_.pop_back(); - } - QCoreApplication::processEvents(); - std::this_thread::sleep_for(10ms); - } - QCoreApplication::postEvent(self_->receiver_, new DisconnectEvent); - - LOG_INFO("inspect") << "# message runnable exit." << std::endl; - } - private: - std::shared_ptr self_; - }; - QThreadPool::globalInstance()->start(new Runnable(shared_from_this())); -} - -void shelllet::inspect::WebsocketSession::doRead() -{ - if (is_read_ok_) { - is_read_ok_ = false; - ws_.async_read(buffer_, boost::beast::bind_front_handler(&WebsocketSession::onRead, shared_from_this())); - } -} - -void shelllet::inspect::WebsocketSession::onRead(boost::beast::error_code ec, std::size_t bytes_transferred) -{ - boost::ignore_unused(bytes_transferred); - - if (ec == boost::beast::websocket::error::closed) { - if (thread_) { - thread_->requestInterruption(); - } - return; - } - - if (ec) { - LOG_ERROR("inspect") << "# read error: " << ec.message() << std::endl; - if (thread_) { - thread_->requestInterruption(); - } - return; - } - - std::string message = boost::beast::buffers_to_string(buffer_.cdata()); - QCoreApplication::postEvent(receiver_, new MessageInEvent(message)); - - is_read_ok_ = true; - buffer_.consume(buffer_.size()); - LOG_TRACE("inspct") << "# incoming: " << message << std::endl; -} -void shelllet::inspect::WebsocketSession::doWrite(const std::string& message) -{ - ws_.text(true); - - boost::beast::error_code ec; - - std::size_t size = ws_.write(boost::asio::buffer(message), ec); - - if (ec) { - LOG_ERROR("inspect") << "# write error: " << ec.message() << std::endl; - if (thread_) { - thread_->requestInterruption(); - } - return; - } - assert(size == message.length()); - - LOG_TRACE("inspct") << "# outgoing: " << message << std::endl; -} \ No newline at end of file diff --git a/chrome_inspector/src/worker.cpp b/chrome_inspector/src/worker.cpp deleted file mode 100644 index 930a76a..0000000 --- a/chrome_inspector/src/worker.cpp +++ /dev/null @@ -1,112 +0,0 @@ -#include -#include "framework.h" -#include -#include -#include "worker.h" -namespace shelllet { - using namespace inspect; - extern std::string FrontendUrl(const std::string& address, uint16_t port); -} - -shelllet::inspect::InspectorVersion shelllet::engine::Worker::requestInspectorVersion() -{ - return { "1.2","v8inspector" }; -} - -shelllet::inspect::InspectorList shelllet::engine::Worker::requestInspectorList() -{ - return { - "v8inspector instance", - "node", - "Debug", - "file:///", - "127.0.0.1", - 9229 - }; -} - -shelllet::engine::Worker::Worker() -{ -#ifdef _DEBUG - v8::V8::SetFlagsFromString("--expose-gc"); -#endif // _DEBUG - v8::V8::InitializeICUDefaultLocation(__argv[0]); - v8::V8::InitializeExternalStartupData(__argv[0]); - - platform_ = v8::platform::NewDefaultPlatform(); - v8::V8::InitializePlatform(platform_.get()); - v8::V8::Initialize(); -} - -shelllet::engine::Worker::~Worker() -{ - v8::V8::Dispose(); - v8::V8::ShutdownPlatform(); -} - -void shelllet::engine::Worker::run(const std::string& filename, bool inspect_brk) -{ - if (!std::filesystem::exists(filename)) { - LOG_ERROR("engine") << "# the file not exist: " << filename; - return; - } - - std::filesystem::path src = filename; - std::filesystem::path dir = src.parent_path(); - if (std::filesystem::is_directory(src)) { - dir = src; - src /= "src/index.js"; - } - std::string name = src.filename().string(); - - std::ifstream stream(src); - std::string code = std::string((std::istreambuf_iterator(stream)), std::istreambuf_iterator()); - - if (inspect_brk) { - worker_thread_ = new TcpServer(this, QHostAddress::LocalHost, 9229); - connect(worker_thread_, &TcpServer::finished, worker_thread_, &QObject::deleteLater); - worker_thread_->start(); - auto info = requestInspectorList(); - std::cout << "# debugger connection success; copy URL and open in Chrome browser: " << FrontendUrl(info.address, info.port) << std::endl; - } - - agent_ = std::make_unique(this, platform_.get(), name, code, dir.string(), inspect_brk); - agent_->run(); -} - -void shelllet::engine::Worker::finished() -{ - if (worker_thread_ && worker_thread_->isRunning()) { - worker_thread_->requestInterruption(); - worker_thread_->wait(); - } -} - -void shelllet::engine::Worker::customEvent(QEvent* event) -{ - if (auto* e = dynamic_cast(event)) { - agent_->postInspectorMessage(QString::fromStdString(e->message)); - } - else if (auto* e = dynamic_cast(event)) { - dispatchInspectorMessage(e->message); - } - else if (auto* e = dynamic_cast(event)) { - agent_->evaluate(); - agent_->cleanup(); - finished(); - QCoreApplication::removePostedEvents(this); - QTimer::singleShot(100, qApp, [this]() { - agent_.reset(nullptr); - QCoreApplication::quit(); - }); - QCoreApplication::processEvents(); - LOG_TRACE("inspect") << "# evaluate end." << std::endl; - } - else if (auto* e = dynamic_cast(event)) { - agent_->pumpMessageLoop(); - } - - else if (auto* e = dynamic_cast(event)) { - agent_->disconnectInspector(); - } -} \ No newline at end of file diff --git a/chrome_inspector/tools/LICENSE b/chrome_inspector/tools/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/chrome_inspector/tools/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/chrome_inspector/tools/README.md b/chrome_inspector/tools/README.md deleted file mode 100644 index 7b65fbc..0000000 --- a/chrome_inspector/tools/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# wrapqt -wrap qt class diff --git a/chrome_inspector/tools/decode.js b/chrome_inspector/tools/decode.js deleted file mode 100644 index 18e38b3..0000000 --- a/chrome_inspector/tools/decode.js +++ /dev/null @@ -1,306 +0,0 @@ -function propExpression(type, name) { - let exp1, exp2; - switch (type) { - case "bool": - exp1 = `info.GetReturnValue().Set(p->d_func()->${name}());`; - exp2 = `p->d_func()->${name}(value->BooleanValue(context).FromJust());`; - break; - case "int": - exp1 = `info.GetReturnValue().Set(p->d_func()->${name}());`; - exp2 = `p->d_func()->${name}(value->Int32Value(context).FromJust());`; - break; - case "uint": - case "quint16": - exp1 = `info.GetReturnValue().Set(v8::Uint32::New(isolate, self->d_func()->${name}}()));` - exp2 = `p->d_func()->${name}(value->Uint32Value(context).FromJust());`; - break; - case "QString": - exp1 = `info.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, self->d_func()->${name}().toUtf8().constData()));` - exp2 = `p->d_func()->${name}(value->Uint32Value(context).FromJust());`; - break; - default: - } - return { exp1, exp2 } -} - -function wrapArgs(element, name) { - let argGroup = element.match(/\((.+)\)/); - let args = ""; - if (argGroup) { - args = argGroup[1]; - } - let wrapArgs = []; - args.split(", ").forEach(element => { - let types = element.match(/(.+?) /); - if (!types) - return; - let exp1 = ""; - switch (types[1]) { - case "bool": - exp1 = `v8::Boolean::New(isolate, ${name})` - break; - case "int": - exp1 = `v8::Int32::New(isolate, ${name});` - break; - case "uint": - case "quint16": - exp1 = `v8::UInt32::New(isolate, ${name})` - break; - case "QString": - exp1 = `V8_NEW_STRING_VAR(isolate, self->d_func()->${name}().toUtf8().constData())` - break; - default: - } - wrapArgs.push(exp1); - }); - - return wrapArgs.join(","); -} - -function returnExpression(type, name) { - let exp1; - switch (type) { - case "bool": - exp1 = `args.GetReturnValue().Set(self->d_func()->${name}());` - break; - case "int": - exp1 = `args.GetReturnValue().Set(v8::Int32::New(isolate, self->d_func()->${name}()));` - break; - case "uint": - case "quint16": - exp1 = `args.GetReturnValue().Set(v8::Uint32::New(isolate, self->d_func()->${name}()));` - break; - case "QString": - exp1 = `args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, self->d_func()->${name}()->toUtf8()->constData()));` - break; - default: - } - return exp1; -} - -export function declareFuncs(tpl, text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - results.push(`${tpl}->Set(isolate, "${nameGroups[1]}", v8::FunctionTemplate::New(isolate, ${toUpperCase(nameGroups[1], 0)}));`) - } - }); - - return results.join("\n"); -} - -export function implFuncs(text, className) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - let types = element.match(/(.+?) /); - let exp1 = returnExpression(types[1], nameGroups[1]); - - let text = `static void ${toUpperCase(nameGroups[1], 0)}(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap<${className}Wrapper>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - ${exp1} - } - V8_CREATE_LOCAL_CONTEXT_END - } - `; - results.push(text); - } - }); - - return results.join("\n"); -} - -export function declareEnums(className, text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let enumNames = element.match(/\s+(\w+)\s+\{/); // match name - let fixedName = ""; - if (!enumNames) { - return; - } - - fixedName = toLowerCase(enumNames[1], 0); - - let exp1 = `auto ${fixedName} = v8::FunctionTemplate::New(isolate);`; - results.push(exp1); - let values = element.match(/{(.+)}/); - values.split(",").trim().forEach(element => { - let exp2 = `${fixedName}->Set(isolate, "${element}", v8::Int32::New(isolate, ${className}::${element}));`; - results.push(exp2); - }); - - let exp3 = `tpl->Set(isolate, "${enumNames[1]}", ${fixedName});`; - - results.push(exp3); - }); - - return results.join("\n"); -} - - -export function declareProps(text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let groups = element.split(":"); - if (groups) { - let name = groups[0].trim(); - let fixedName = toUpperCase(name, 0); - results.push(`proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "${name}"), Get${fixedName}, Set${fixedName});`) - } - }); - - return results.join("\n"); -} - -export function implProps(text, className) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let groups = element.split(":"); - if (groups) { - let name = groups[0].trim(); - let fixedName = toUpperCase(name, 0); - let type = groups[1]?.trim(); - let exp = propExpression(type, name); - - let text = `static void Get${fixedName}(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap<${className}Wrapper>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - ${exp.exp1} - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Set${fixedName}(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap<${className}Wrapper>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - ${exp.exp2} - } - V8_CREATE_LOCAL_CONTEXT_END - } - `; - results.push(text); - } - }); - - return results.join("\n"); -} - -export function declareSignals(text) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - let exp1 = `proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "${nameGroups[1]}"), nullptr, ${toUpperCase(nameGroups[1], 0)});`; - results.push(exp1); - } - }); - - return results.join("\n"); -} - -export function implSignals(text, className) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (nameGroups) { - let name = nameGroups[1]; - let fixedName = toUpperCase(nameGroups[1], 0); - let argGroup = element.match(/\((.+)\)/); - let args = ""; - if (argGroup) { - args = argGroup[1]; - } - let vargs = wrapArgs(element); - - let text = `static void ${fixedName}(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap<${className}Wrapper>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - std::shared_ptr>weakPersistent = std::make_shared>(isolate, v8::Local::Cast(value)); - QObject::connect(*self, &${className}::${name}, [isolate, weakPersistent](${args}) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { ${vargs} }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(*self, &${className}::${name}, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - `; - results.push(text); - } - }); - - return results.join("\n"); -} - - -export function virtuals(text, parentClassName) { - let results = []; - var functions = text.trim().split('\n'); - functions.forEach(element => { - let nameGroups = element.match(/(\w+)\(.*?\)/); - if (!nameGroups) { - return; - } - let vargs = wrapArgs(element); - let name = nameGroups[1]; - let text = `${element} - { - if (q_func()->hasOwnProperty(strrchr(__FUNCTION__, ':') + 1)) { - v8::Local argv[] = { ${vargs} }; - v8::Local value = call(__FUNCTION__, std::size(argv), argv); - return value->BooleanValue(v8::Isolate::GetCurrent()); - } - if constexpr (std::is_abstract::value) - throw std::logic_error("The method or operation is not implemented."); - else { - return T::${name}(); - } - }`; - - results.push(text); - }); - - return results.join("\n"); -} diff --git a/chrome_inspector/tools/implement.js b/chrome_inspector/tools/implement.js deleted file mode 100644 index b83886c..0000000 --- a/chrome_inspector/tools/implement.js +++ /dev/null @@ -1,50 +0,0 @@ -import * as dec from "./decode.js" - -export function create(data, filename){ - var declares = dec.declareFuncs("tpl", data.static); - var bodies = dec.implFuncs(data.static, data.className); - - var code = `#pragma once -#include "framework.h" -#include <${data.className.toLowerCase()}.h> -#include "${data.className.toLowerCase().replace("_", "")}_p.h" -#include "${data.className.toLowerCase().replace("_", "")}_wrapper.h" - -namespace shelllet { - namespace ${data.namespace} { - class ${data.name} : public ${data.className}Wrapper<${data.className}, ${data.name}, ${data.canNew}> - { - using ReturnType = ${data.className}Private<${data.className}, true>; - using ReturnType2 = ${data.className}Private<${data.className}, false>; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - ${data.name}(const v8::FunctionCallbackInfo& args) :${data.className}Wrapper(*Param(args), args) - { - } - ${data.name}(${data.className}* p, const v8::FunctionCallbackInfo& args) :${data.className}Wrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ${data.name}(v8::Isolate* isolate, const v8::Local& tpl) : ${data.className}Wrapper(isolate, tpl) - { - ${declares} - } - - ${data.name}(v8::Isolate* isolate, const v8::Local& proto) : ${data.className}Wrapper(isolate, proto) - { - ${declares} - } - - protected: - void toString(std::stringstream& ss) const {} - public: - static const char* Name() { return "${data.name}"; } - protected: - ${bodies} - }; - } -} -` - writeFile(filename, code); -} diff --git a/chrome_inspector/tools/main.js b/chrome_inspector/tools/main.js deleted file mode 100644 index fcc54c1..0000000 --- a/chrome_inspector/tools/main.js +++ /dev/null @@ -1,37 +0,0 @@ -import * as impl from "./implement.js" -import * as wrp from "./wrapper.js" -import * as pri from "./private.js" - -var data = { - name: "Dir", - className: "QDir", - namespace: "core", - parent: "Object", - parentNamespace: "", - canNew: true, - public: ` - - `, - virtual: ` - `, - - static: ` - - - `, - signals: ` - - - `, - propeties: ` - - `, - enums: ` - Filter { Dirs, AllDirs, Files, Drives, NoSymLinks, NoDotAndDotDot, NoDot, NoDotDot, AllEntries, Readable, Writable, Executable, Modified, Hidden,System,CaseSensitive } - ` -} - - -impl.create(data, data.className.toLowerCase().replace("_", "") + `_implement.h`); -pri.create(data, data.className.toLowerCase().replace("_", "") + `_p.h`); -wrp.create(data, data.className.toLowerCase().replace("_", "") + `_wrapper.h`); diff --git a/chrome_inspector/tools/private.js b/chrome_inspector/tools/private.js deleted file mode 100644 index 626f12b..0000000 --- a/chrome_inspector/tools/private.js +++ /dev/null @@ -1,20 +0,0 @@ - -export function create(data, filename){ - var code = `#pragma once -namespace shelllet { - namespace ${data.namespace} { - template - class ${data.className}Private : public ${data.parent}Private - { - public: - template - ${data.className}Private(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ${data.parent}Private(isolate, obj, std::forward(args)...) { - } - - }; - } -} -`; - writeFile(filename, code); - -} diff --git a/chrome_inspector/tools/wrapper.js b/chrome_inspector/tools/wrapper.js deleted file mode 100644 index b264fa2..0000000 --- a/chrome_inspector/tools/wrapper.js +++ /dev/null @@ -1,46 +0,0 @@ -import * as dec from "./decode.js" - - -export function create(data, filename) { - var normal = dec.declareFuncs("proto", data.public); - var normalBodies = dec.implFuncs(data.public, data.className); - - var signals = dec.declareSignals(data.signals); - var sginalBodies = dec.implSignals(data.signals, data.className); - - var props = dec.declareProps(data.propeties); - var propsBodies = dec.implProps(data.propeties, data.className); - - var code = `#pragma once -namespace shelllet { - namespace ${data.namespace} { - template - class ${data.className}Wrapper : public ${data.parent}Wrapper - { - public: - template - ${data.className}Wrapper(${data.className}Private& d, const v8::FunctionCallbackInfo& args) - : ${data.parent}Wrapper(d, args) { - } - ${data.className}Wrapper(v8::Isolate* isolate, const v8::Local& tpl) : ${data.parent}Wrapper(isolate, tpl) - { - } - - - ${data.className}Wrapper(v8::Isolate* isolate, const v8::Local& proto) : ${data.parent}Wrapper(isolate, proto) - { - ${props} - ${normal} - ${signals} - } - - protected: - ${propsBodies} - ${normalBodies} - ${sginalBodies} - }; - } -}`; - writeFile(filename, code); - -} diff --git a/docs/CNAME b/docs/CNAME new file mode 100644 index 0000000..fc60b70 --- /dev/null +++ b/docs/CNAME @@ -0,0 +1 @@ +www.shelllet.com \ No newline at end of file diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..fc24e7a --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-hacker \ No newline at end of file diff --git a/docs/poco/080-Files.pdf b/docs/poco/080-Files.pdf deleted file mode 100644 index 681d01b..0000000 Binary files a/docs/poco/080-Files.pdf and /dev/null differ diff --git a/docs/poco/200-Network.pdf b/docs/poco/200-Network.pdf deleted file mode 100644 index 6d4a0cc..0000000 Binary files a/docs/poco/200-Network.pdf and /dev/null differ diff --git a/framless_window/CMakeLists.txt b/framless_window/CMakeLists.txt deleted file mode 100644 index a53f2d1..0000000 --- a/framless_window/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -# CMakeList.txt : Top-level CMake project file, do global configuration -# and include sub-projects here. -# -cmake_minimum_required (VERSION 3.14) -cmake_policy(SET CMP0091 NEW) - -project(frameless) - -set(CMAKE_AUTOMOC ON) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - - -aux_source_directory(${CMAKE_SOURCE_DIR}/src SOURCES) -file(GLOB HEADERS ${CMAKE_SOURCE_DIR}/include/*.h) - -add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) - -find_package(Boost REQUIRED COMPONENTS serialization log) -find_package(Qt5Widgets CONFIG REQUIRED) -find_package(Qt5Svg CONFIG REQUIRED) -find_package(pugixml CONFIG REQUIRED) - -target_include_directories(${PROJECT_NAME} PRIVATE - ${CMAKE_SOURCE_DIR}/include - ${Boost_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} - ${Qt5Svg_INCLUDE_DIRS} - ${Qt5Widgets_PRIVATE_INCLUDE_DIRS} -) - -add_definitions(-DBOOST_ALL_DYN_LINK) - -target_link_libraries(${PROJECT_NAME} PRIVATE Qt::Svg Dwmapi.lib D2d1.lib - Qt::Widgets - pugixml - ${Boost_LIBRARIES} -) \ No newline at end of file diff --git a/framless_window/CMakeSettings.json b/framless_window/CMakeSettings.json deleted file mode 100644 index df2506a..0000000 --- a/framless_window/CMakeSettings.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "configurations": [ - { - "name": "x64-Debug", - "generator": "Ninja", - "configurationType": "Debug", - "cmakeExecutable": "${env.CMAKE_ROOT}\\cmake.exe", - "inheritEnvironments": [ "msvc_x64_x64" ], - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake", - "variables": [ - { - "name": "VCPKG_TARGET_TRIPLET", - "value": "x64-windows-mixed", - "type": "STRING" - } - ] - }, - { - "name": "x64-Release", - "generator": "Ninja", - "configurationType": "RelWithDebInfo", - "cmakeExecutable": "${env.CMAKE_ROOT}\\cmake.exe", - "buildRoot": "${projectDir}\\out\\build\\${name}", - "installRoot": "${projectDir}\\out\\install\\${name}", - "cmakeCommandArgs": "", - "buildCommandArgs": "", - "ctestCommandArgs": "", - "cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake", - "inheritEnvironments": [ "msvc_x64_x64" ], - "variables": [ - { - "name": "VCPKG_TARGET_TRIPLET", - "value": "x64-windows-mixed", - "type": "STRING" - } - ] - } - ] -} \ No newline at end of file diff --git a/framless_window/README.md b/framless_window/README.md deleted file mode 100644 index 6d97970..0000000 --- a/framless_window/README.md +++ /dev/null @@ -1,29 +0,0 @@ -Qt Frameless Titlebar. No cross-system supported, only support window 7++. - - -# How to use (Method 1) - - auto famelessWindow = std::make_unique(nullptr, WindowType::AllButton); - - framelessWindow->setCentralWidget(new [YourWidget]); - - -# How to use (Method 2) - - class MessageBoxDialog : public MainWindow - { - MessageBoxDialog(){ - // .... - setCentralWidget(contentWidget); - } - } - -# Env - CMAKE_ROOT # define cmake path, e.g. C:\Program Files\CMake\bin - - VCPKG_ROOT # define vcpkg path, e.g. D:\vcpkg-export-20201126-140522 - -# vcpkg - vcpkg install boost:x64-windows-mixed - vcpkg install pugixml:x64-windows-mixed - vcpkg install qt5-svg:x64-windows-mixed diff --git a/framless_window/include/common/custom_output_backend.h b/framless_window/include/common/custom_output_backend.h deleted file mode 100644 index 5eaf1f5..0000000 --- a/framless_window/include/common/custom_output_backend.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -namespace shelllet { - namespace logging { - class custom_output_backend : public boost::log::sinks::basic_formatted_sink_backend - { - public: - virtual void consume(boost::log::record_view const& rec, string_type const& command_line); - }; - } -} \ No newline at end of file diff --git a/framless_window/include/common/logs.h b/framless_window/include/common/logs.h deleted file mode 100644 index 12e6bc9..0000000 --- a/framless_window/include/common/logs.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "filesystem" -#include "boost/log/sinks.hpp" -#include "boost/log/trivial.hpp" -#include "boost/log/sources/global_logger_storage.hpp" -#include "boost/log/expressions.hpp" -#include "boost/log/sources/severity_channel_logger.hpp" -#include "custom_output_backend.h" - -namespace sinks = boost::log::sinks; -BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(__logger, boost::log::sources::severity_channel_logger_mt); - -namespace shelllet { -#define LOG_TRACE(c) BOOST_LOG_CHANNEL_SEV(__logger::get(), c, boost::log::trivial::trace) -#define LOG_DEBUG(c) BOOST_LOG_CHANNEL_SEV(__logger::get(), c, boost::log::trivial::debug) -#define LOG_INFO(c) BOOST_LOG_CHANNEL_SEV(__logger::get(), c,boost::log::trivial::info) -#define LOG_WARN(c) BOOST_LOG_CHANNEL_SEV(__logger::get(), c, boost::log::trivial::warning) -#define LOG_ERROR(c) BOOST_LOG_CHANNEL_SEV(__logger::get(), c,boost::log::trivial::error) -#define LOG_FATAL(c) BOOST_LOG_CHANNEL_SEV(__logger::get(), c,boost::log::trivial::fatal) - -#define THROW_SYSTEM_ERROR(n) throw boost::system::system_error(n, boost::system::detail::system_error_category(), (boost::format("%1% %2%") % __FUNCTION__ % __LINE__).str()) - - typedef boost::log::sinks::synchronous_sink sink_custom_t; - - namespace logging { - BOOST_LOG_ATTRIBUTE_KEYWORD(simple_log_message, "Simple", bool) - - void initialize(boost::log::trivial::severity_level level); - - boost::log::trivial::severity_level level_from_string(const std::string& level); - - void add_custom_sink(const boost::shared_ptr& sink); - - void add_file_sink(const std::filesystem::path& filename); - } -} \ No newline at end of file diff --git a/framless_window/include/common/object.h b/framless_window/include/common/object.h deleted file mode 100644 index e1f31b3..0000000 --- a/framless_window/include/common/object.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "qobject.h" -#include "boost/noncopyable.hpp" - -namespace shelllet { - namespace common { - class Object; - class ObjectData : private boost::noncopyable - { - public: - virtual ~ObjectData() = 0; - public: - Object* q_ptr; - Object* parent; - std::list children; - }; - class ObjectPrivate : public ObjectData { - public: - virtual ~ObjectPrivate(); - }; - class Object { - Q_DECLARE_PRIVATE(Object) - public: - - protected: - Object(ObjectPrivate& dd, Object* parent = nullptr); - protected: - std::unique_ptr d_ptr; - }; - } - - using namespace common; -} \ No newline at end of file diff --git a/framless_window/include/delegatewindow.h b/framless_window/include/delegatewindow.h deleted file mode 100644 index 808167d..0000000 --- a/framless_window/include/delegatewindow.h +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once -#include "common/object.h" -#include "qt_windows.h" -#include "flags.h" -namespace shelllet { - namespace frameless { - class TitleBarWidget; - class DelegateWindowPrivate; - class DelegateWindow : public Object - { - Q_DECLARE_PRIVATE(DelegateWindow) - public: - DelegateWindow(TitleBarWidget* widget); - - long hitNcTest(HWND hWnd, const QPoint& pos, const QRect& geometry, const SizePolicyFlags& fixed); - bool calcNcSize(HWND hWnd, WPARAM wParam, LPARAM lParam); - - void updateWindow(HWND hWnd, bool frameChange, bool redraw); - - int getSystemTitleBarHeight(HWND hWnd); - }; - } -} \ No newline at end of file diff --git a/framless_window/include/flags.h b/framless_window/include/flags.h deleted file mode 100644 index 48b6f70..0000000 --- a/framless_window/include/flags.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -namespace shelllet { - namespace frameless { - - - enum class WindowType - { - None = 1 << 0, - MinimizeButtonHint = 1 << 1, - MaximizeButtonHint = 1 << 2, - MinMaxButtonsHint = MinimizeButtonHint | MaximizeButtonHint, - CloseButtonHint = 1 << 3, - AllButton = CloseButtonHint | MinMaxButtonsHint, - MinCloseButton = MinimizeButtonHint | CloseButtonHint, - CustomButtonHint = 1 << 4 - }; - - //Q_ENUM(WindowType); - Q_DECLARE_FLAGS(WindowTypeFlags, WindowType) - Q_DECLARE_OPERATORS_FOR_FLAGS(WindowTypeFlags) - - - enum class SizePolicy - { - None = 1 << 0, - FixedWidth = 1 << 1, - FixedHeigth = 1 << 2, - FixedAll = FixedWidth | FixedHeigth - }; - - Q_DECLARE_FLAGS(SizePolicyFlags, SizePolicy) - Q_DECLARE_OPERATORS_FOR_FLAGS(SizePolicyFlags) - } -} diff --git a/framless_window/include/framelesswindow.h b/framless_window/include/framelesswindow.h deleted file mode 100644 index 87a69a9..0000000 --- a/framless_window/include/framelesswindow.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "qmainwindow.h" -#include "common/object.h" -#include "flags.h" -namespace shelllet { - namespace frameless { - class FramelessWindowPrivate; - class FramelessWindow : public QMainWindow, public Object { - Q_OBJECT - Q_DECLARE_PRIVATE_D(Object::d_ptr, FramelessWindow) - public: - explicit FramelessWindow(QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - virtual ~FramelessWindow(); - - void setCustomButton(QWidget* c); - void setContextMenu(QMenu* menu); - void setTitleTextBlurRadius(qreal blurRadius); - void disableNativeTitleBar(); - void enableNativeTitleBar(); - - virtual SizePolicyFlags fixedSizeTypes() const = 0; - protected: - virtual void minimizeButtonClicked(); - virtual void restoreButtonClicked(); - virtual void maximizeButtonClicked(); - virtual void closeButtonClicked(); - virtual void iconDoubleClicked(); - - FramelessWindow(FramelessWindowPrivate& d, QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - protected: - void paintEvent(QPaintEvent* event) override; - void changeEvent(QEvent* event) override; - bool nativeEvent(const QByteArray& eventType, void* message, long* result) override; - }; - } -} diff --git a/framless_window/include/mainwindow.h b/framless_window/include/mainwindow.h deleted file mode 100644 index 69827e1..0000000 --- a/framless_window/include/mainwindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once -#include "framelesswindow.h" - -namespace shelllet { - namespace frameless { - class MainWindowPrivate; - class MainWindow : public FramelessWindow { - Q_DECLARE_PRIVATE_D(Object::d_ptr, MainWindow) - public: - MainWindow(QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - - - void moveToCentral(); - - void setFixedHeight(int h); - void setFixedWidth(int w); - void setFixedSize(int w, int h); - void setFixedSize(const QSize& s); - - SizePolicyFlags fixedSizeTypes() const override; - - protected: - MainWindow(MainWindowPrivate&d, QWidget* parent = nullptr, WindowTypeFlags flags = WindowTypeFlags()); - }; - } -} diff --git a/framless_window/include/private/framelesswindow_p.h b/framless_window/include/private/framelesswindow_p.h deleted file mode 100644 index 4910c85..0000000 --- a/framless_window/include/private/framelesswindow_p.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include -namespace QT_NAMESPACE { - class QMenu; -} -namespace shelllet { - namespace frameless { - class DelegateWindow; - class TitleBarWidget; - class FramelessWindowPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(FramelessWindow) - public: - DelegateWindow* delegateWindow = nullptr; - QMenu* menu = nullptr; - TitleBarWidget* titleBar = nullptr; - WindowTypeFlags flags; - LONG currentStyle; - LONG currentExStyle; - }; - } -} \ No newline at end of file diff --git a/framless_window/include/private/mainwindow_p.h b/framless_window/include/private/mainwindow_p.h deleted file mode 100644 index 157bfae..0000000 --- a/framless_window/include/private/mainwindow_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "framelesswindow_p.h" -namespace shelllet { - namespace frameless{ - class MainWindowPrivate : public FramelessWindowPrivate { - Q_DECLARE_PUBLIC(MainWindow) - public: - SizePolicyFlags fixedSize; - }; - } -} - \ No newline at end of file diff --git a/framless_window/include/standardbutton.h b/framless_window/include/standardbutton.h deleted file mode 100644 index 1c14dcb..0000000 --- a/framless_window/include/standardbutton.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "common/object.h" -#include "qsvgwidget.h" -namespace shelllet { - namespace frameless { - enum class ButtonType { - Close, - Minimize, - Maximize, - Restore - }; - class StandardButtonPrivate; - class StandardButton : public QSvgWidget, public Object { - Q_DECLARE_PRIVATE_D(Object::d_ptr, StandardButton) - Q_OBJECT - public: - StandardButton(ButtonType t, QWidget* parent = nullptr); - - - signals: - void clicked(); - protected slots: - void applicationStateChanged(Qt::ApplicationState state); - protected: - void paintEvent(QPaintEvent* event); - - void mousePressEvent(QMouseEvent* event) override; - - void enterEvent(QEvent* event) override; - - void leaveEvent(QEvent* event) override; - - void mouseReleaseEvent(QMouseEvent* event) override; - - QSize sizeHint() const override; - }; - - } -} \ No newline at end of file diff --git a/framless_window/include/titlebarwidget.h b/framless_window/include/titlebarwidget.h deleted file mode 100644 index 77bec7f..0000000 --- a/framless_window/include/titlebarwidget.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "qwidget.h" -#include "qevent.h" -#include "flags.h" -namespace shelllet { - namespace frameless { - class TitleBarWidgetPrivate; - class TitleBarWidget : public QWidget { - Q_OBJECT - Q_DECLARE_PRIVATE(TitleBarWidget) - public: - explicit TitleBarWidget(QWidget* parent = nullptr, WindowTypeFlags f = WindowTypeFlags()); - virtual ~TitleBarWidget() {} - - void applicationStateChanged(Qt::ApplicationState state); - void setWindowTypes(WindowTypeFlags f); - - void setCustomButton(QWidget* c); - - bool underMouse(); - - void switchToMaxButton(); - void switchToRestoreButton(); - void setTitleTextBlurRadius(qreal blurRadius); - signals: - void minimizeButtonClicked(); - void restoreButtonClicked(); - void maximizeButtonClicked(); - void closeButtonClicked(); - void iconDoubleClicked(); - protected: - void paintEvent(QPaintEvent* event); - void resizeEvent(QResizeEvent* event); - }; - - } -} diff --git a/framless_window/src/custom_output_backend.cpp b/framless_window/src/custom_output_backend.cpp deleted file mode 100644 index 7219e31..0000000 --- a/framless_window/src/custom_output_backend.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "common/logs.h" -#include "common/custom_output_backend.h" - -void shelllet::logging::custom_output_backend::consume(boost::log::record_view const& rec, string_type const& command_line) -{ - -} diff --git a/framless_window/src/delegatewindow.cpp b/framless_window/src/delegatewindow.cpp deleted file mode 100644 index 1eb912f..0000000 --- a/framless_window/src/delegatewindow.cpp +++ /dev/null @@ -1,299 +0,0 @@ -#include "qt_windows.h" -#include "delegatewindow.h" -#include "titlebarwidget.h" -#include "qapplication.h" -#include "qlibrary.h" -#include "wrl.h" -#include "d2d1.h" -#include "qoperatingsystemversion.h" -#include "qwindow.h" -#include "qdebug.h" -#include "common/logs.h" -namespace shelllet { - using namespace Microsoft::WRL; - namespace frameless { -#ifdef _DEBUG -#define JWF_RESOLVE_ERROR(funcName) Q_ASSERT(m_lp##funcName); -#else -#define JWF_RESOLVE_ERROR(funcName) \ - if (!m_lp##funcName) { \ - LOG_FATAL("frameless") << "Failed to resolve symbol: " #funcName << std::endl; \ - } -#endif - -#define JWF_GENERATE_WINAPI(funcName, retType, ...) \ - using WINAPI_##funcName = retType(WINAPI *)(__VA_ARGS__); \ - static WINAPI_##funcName m_lp##funcName = nullptr; - -#define JWF_RESOLVE_WINAPI(libName, funcName) \ - if (!m_lp##funcName) { \ - m_lp##funcName = reinterpret_cast( \ - QLibrary::resolve(QString::fromUtf8(#libName), #funcName)); \ - JWF_RESOLVE_ERROR(funcName) \ - } - - JWF_GENERATE_WINAPI(GetSystemMetricsForDpi, int, int, UINT) - JWF_GENERATE_WINAPI(GetDpiForWindow, UINT, HWND) - static ComPtr m_pDirect2dFactory; - - enum AppbarAutohideEdge { - EDGE_TOP = 1 << 0, - EDGE_LEFT = 1 << 1, - EDGE_BOTTOM = 1 << 2, - EDGE_RIGHT = 1 << 3, - }; - - class DelegateWindowPrivate : public ObjectPrivate { - public: - TitleBarWidget* titleBar; - }; - - bool __MonitorHasAutohideTaskbarForEdge(UINT edge, HMONITOR monitor) { - APPBARDATA taskbarData = { sizeof(APPBARDATA), NULL, 0, edge }; - taskbarData.hWnd = ::GetForegroundWindow(); - // MSDN documents an ABM_GETAUTOHIDEBAREX, which supposedly takes a monitor - // rect and returns autohide bars on that monitor. This sounds like a good - // idea for multi-monitor systems. Unfortunately, it appears to not work at - // least some of the time (erroneously returning NULL) and there's almost no - // online documentation or other sample code using it that suggests ways to - // address this problem. We do the following:- - // 1. Use the ABM_GETAUTOHIDEBAR message. If it works, i.e. returns a valid - // window we are done. - // 2. If the ABM_GETAUTOHIDEBAR message does not work we query the auto hide - // state of the taskbar and then retrieve its position. That call returns - // the edge on which the taskbar is present. If it matches the edge we - // are looking for, we are done. - // NOTE: This call spins a nested run loop. - HWND taskbar = reinterpret_cast(SHAppBarMessage(ABM_GETAUTOHIDEBAR, &taskbarData)); - if (!::IsWindow(taskbar)) { - APPBARDATA taskbarData = { sizeof(APPBARDATA), 0, 0, 0 }; - unsigned int taskbar_state = SHAppBarMessage(ABM_GETSTATE, &taskbarData); - if (!(taskbar_state & ABS_AUTOHIDE)) - return false; - taskbarData.hWnd = ::FindWindowW(L"Shell_TrayWnd", NULL); - if (!::IsWindow(taskbarData.hWnd)) - return false; - SHAppBarMessage(ABM_GETTASKBARPOS, &taskbarData); - if (taskbarData.uEdge == edge) - taskbar = taskbarData.hWnd; - } - // There is a potential race condition here: - // 1. A maximized chrome window is fullscreened. - // 2. It is switched back to maximized. - // 3. In the process the window gets a WM_NCCACLSIZE message which calls us to - // get the autohide state. - // 4. The worker thread is invoked. It calls the API to get the autohide - // state. On Windows versions earlier than Windows 7, taskbars could - // easily be always on top or not. - // This meant that we only want to look for taskbars which have the topmost - // bit set. However this causes problems in cases where the window on the - // main thread is still in the process of switching away from fullscreen. - // In this case the taskbar might not yet have the topmost bit set. - // 5. The main thread resumes and does not leave space for the taskbar and - // hence it does not pop when hovered. - // - // To address point 4 above, it is best to not check for the WS_EX_TOPMOST - // window style on the taskbar, as starting from Windows 7, the topmost - // style is always set. We don't support XP and Vista anymore. - if (::IsWindow(taskbar)) { - if (MonitorFromWindow(taskbar, MONITOR_DEFAULTTONEAREST) == monitor) - return true; - // In some cases like when the autohide taskbar is on the left of the - // secondary monitor, the MonitorFromWindow call above fails to return the - // correct monitor the taskbar is on. We fallback to MonitorFromPoint for - // the cursor position in that case, which seems to work well. - POINT cursorPos = { 0 }; - GetCursorPos(&cursorPos); - if (MonitorFromPoint(cursorPos, MONITOR_DEFAULTTONEAREST) == monitor) - return true; - } - return false; - } - int __GetAppbarAutohideEdges(HMONITOR monitor) { - int edges = 0; - if (__MonitorHasAutohideTaskbarForEdge(ABE_LEFT, monitor)) - edges |= EDGE_LEFT; - if (__MonitorHasAutohideTaskbarForEdge(ABE_TOP, monitor)) - edges |= EDGE_TOP; - if (__MonitorHasAutohideTaskbarForEdge(ABE_RIGHT, monitor)) - edges |= EDGE_RIGHT; - if (__MonitorHasAutohideTaskbarForEdge(ABE_BOTTOM, monitor)) - edges |= EDGE_BOTTOM; - return edges; - } - int __GetSystemMetricsForDpi(int nIndex, UINT dpi) { - if (m_lpGetSystemMetricsForDpi) - return m_lpGetSystemMetricsForDpi(nIndex, dpi); - - return GetSystemMetrics(nIndex); - } - UINT __GetDpiForWindow(HWND hWnd) { - if (m_lpGetDpiForWindow) - return m_lpGetDpiForWindow(hWnd); - - FLOAT dpiX = 96.0, dpiY = 96.0; - if (m_pDirect2dFactory) - m_pDirect2dFactory->GetDesktopDpi(&dpiX, &dpiY); - - return qRound(dpiX); - } - - MONITORINFO __GetMonitorInfoForWindow(HWND hWnd) - { - HMONITOR mon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi = { .cbSize = sizeof mi }; - GetMonitorInfoW(mon, &mi); - return mi; - } - - int __GetBorderWidthForWindow(HWND hWnd) { - uint dpi = __GetDpiForWindow(hWnd); - return __GetSystemMetricsForDpi(SM_CXSIZEFRAME, dpi) + __GetSystemMetricsForDpi(SM_CXPADDEDBORDER, dpi); - } - - } -} - - -shelllet::frameless::DelegateWindow::DelegateWindow(TitleBarWidget* widget) - : Object(*new DelegateWindowPrivate, nullptr) -{ - Q_D(DelegateWindow); - - d->titleBar = widget; - - if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows10) { - JWF_RESOLVE_WINAPI(User32, GetSystemMetricsForDpi) - JWF_RESOLVE_WINAPI(User32, GetDpiForWindow) - } - - if (!m_pDirect2dFactory) { - HRESULT hResult = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, m_pDirect2dFactory.GetAddressOf()); - if (FAILED(hResult)) { - LOG_FATAL("frameless") << "Failed to create d2d factory: " << std::system_category().message(hResult) << std::endl; - } - } -} - -bool shelllet::frameless::DelegateWindow::calcNcSize(HWND hWnd, WPARAM wParam, LPARAM lParam) -{ - Q_D(DelegateWindow); - union { - LPARAM lParam; - RECT* rect; - } params = { .lParam = lParam }; - RECT ncclient = *params.rect; - DefWindowProcW(hWnd, WM_NCCALCSIZE, wParam, params.lParam); - RECT client = *params.rect; - if (::IsZoomed(hWnd)) - { - int borderWidth = __GetBorderWidthForWindow(hWnd); - *params.rect = { - .left = client.left, - .top = ncclient.top + static_cast(borderWidth), // Maximized window always have a border around. - .right = client.right, - .bottom = client.bottom, - }; - - HMONITOR mon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); - MONITORINFO mi = __GetMonitorInfoForWindow(hWnd); - - // reduce size when same monitor's rectangle. - if (EqualRect(params.rect, &mi.rcMonitor)) { - if (__GetAppbarAutohideEdges(mon) == EDGE_TOP) { - params.rect->top++; - } - else if (__GetAppbarAutohideEdges(mon) == EDGE_LEFT) { - params.rect->left++; - } - else if (__GetAppbarAutohideEdges(mon) == EDGE_BOTTOM) { - params.rect->bottom--; - } - else if (__GetAppbarAutohideEdges(mon) == EDGE_RIGHT) { - params.rect->right--; - } - } - QWindow* window = QWindow::fromWinId(reinterpret_cast(hWnd)); - d->titleBar->setMaximumWidth(window->size().width()); - } - else { - *params.rect = ncclient; - - d->titleBar->setMaximumWidth(QWIDGETSIZE_MAX); - } - return true; -} - - -void shelllet::frameless::DelegateWindow::updateWindow(HWND hWnd, bool frameChange, bool redraw) -{ - if (frameChange) { - SetWindowPos(hWnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); - } - if (redraw) { - //RedrawWindow(hWnd, nullptr, nullptr, RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); - RedrawWindow(hWnd, NULL, NULL, RDW_UPDATENOW | RDW_ERASENOW | RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_NOCHILDREN); - } -} - -int shelllet::frameless::DelegateWindow::getSystemTitleBarHeight(HWND hWnd) -{ - const UINT dpi = 96; - - if (IsZoomed(hWnd)) { - return qRound(__GetSystemMetricsForDpi(SM_CYCAPTION, dpi) * 0.75) + 5; - } - - return __GetSystemMetricsForDpi(SM_CYCAPTION, dpi) +5; -} - -long shelllet::frameless::DelegateWindow::hitNcTest(HWND hWnd, const QPoint& pos, const QRect& geometry, const SizePolicyFlags& flags) -{ - Q_D(DelegateWindow); - int borderWidth = __GetBorderWidthForWindow(hWnd); - QRect rcMax = geometry; - QRect rcMin = geometry.marginsRemoved({ borderWidth, borderWidth, borderWidth, borderWidth }); - - QRect rcLeft = { QPoint{rcMax.left(), rcMin.top()}, rcMin.bottomLeft() }; - QRect rcTop = { QPoint{rcMin.left(), rcMax.top()}, rcMin.topRight() }; - - QRect rctRight = { rcMin.topRight(),QPoint(rcMax.right(), rcMin.bottom()) }; - QRect rcBottom = { rcMin.bottomLeft(), QPoint(rcMin.right(), rcMax.bottom()) }; - - - QRect rcTopLeft = { rcMax.topLeft(), rcMin.topLeft() }; - QRect rcTopRight = { QPoint{rcMin.right(), rcMax.top()}, QPoint(rcMax.right(), rcMin.top()) }; - - QRect rcBottomLeft = { QPoint(rcMax.left(), rcMin.bottom()),QPoint(rcMin.left(), rcMax.bottom()) }; - QRect rcBottomRight = { rcMin.bottomRight(), rcMax.bottomRight() }; - - if (rcLeft.contains(pos)) { - return flags.testFlag(SizePolicy::FixedWidth) ? HTCLIENT : HTLEFT; - } - else if (rctRight.contains(pos)) { - return flags.testFlag(SizePolicy::FixedWidth) ? HTCLIENT : HTRIGHT; - } - else if (rcBottom.contains(pos)) { - return flags.testFlag(SizePolicy::FixedHeigth) ? HTCLIENT : HTBOTTOM; - } - else if (rcTop.contains(pos)) { - return flags.testFlag(SizePolicy::FixedHeigth) ? HTCLIENT : HTTOP; - } - else if (rcBottomLeft.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTBOTTOMLEFT; - } - else if (rcBottomRight.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTBOTTOMRIGHT; - } - else if (rcTopRight.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTTOPRIGHT; - } - else if (rcTopLeft.contains(pos)) { - return (flags.testFlag(SizePolicy::FixedHeigth) || flags.testFlag(SizePolicy::FixedWidth)) ? HTCLIENT : HTTOPLEFT; - } - else if (d->titleBar->underMouse()) { - return HTCAPTION; - } - - return HTCLIENT; -} diff --git a/framless_window/src/framelesswindow.cpp b/framless_window/src/framelesswindow.cpp deleted file mode 100644 index 3d099d0..0000000 --- a/framless_window/src/framelesswindow.cpp +++ /dev/null @@ -1,250 +0,0 @@ -#include "qmenu.h" -#include "framelesswindow.h" -#include "titlebarwidget.h" -#include "delegatewindow.h" -#include "private/qwidget_p.h" -#include "qapplication.h" -#include "qdesktopwidget.h" -#include "qpainter.h" -#include "qpainterpath.h" -#include "qgraphicseffect.h" -#include "qscreen.h" -#include "qboxlayout.h" -#include "qstyleoption.h" -#include "qt_windows.h" -#include "windowsx.h" -#include "qstackedwidget.h" -#include "dwmapi.h" -#include "private/framelesswindow_p.h" - - - -shelllet::frameless::FramelessWindow::FramelessWindow(QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= {}*/) - : FramelessWindow(*new FramelessWindowPrivate, parent, flags) -{ - Q_D(FramelessWindow); - setObjectName("app-main-window"); -} -shelllet::frameless::FramelessWindow::FramelessWindow(FramelessWindowPrivate& d, QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= WindowFlags()*/) - : QMainWindow(parent, Qt::FramelessWindowHint) - , Object(d, nullptr) -{ - d.flags = flags; - HWND hWnd = reinterpret_cast(winId()); - d.currentStyle = GetWindowLong(hWnd, GWL_STYLE); - d.currentExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); - setContentsMargins(1, 1, 1, 1); - disableNativeTitleBar(); -} - -shelllet::frameless::FramelessWindow::~FramelessWindow() { - Q_D(FramelessWindow); - delete d->delegateWindow; -} - -void shelllet::frameless::FramelessWindow::setCustomButton(QWidget* c) -{ - Q_D(FramelessWindow); - if (d->titleBar) - d->titleBar->setCustomButton(c); -} - - - -void shelllet::frameless::FramelessWindow::setContextMenu(QMenu* menu) -{ - Q_D(FramelessWindow); - d->menu = menu; -} - -void shelllet::frameless::FramelessWindow::setTitleTextBlurRadius(qreal blurRadius) -{ - Q_D(FramelessWindow); - if (d->titleBar) - d->titleBar->setTitleTextBlurRadius(blurRadius); -} - - -void shelllet::frameless::FramelessWindow::enableNativeTitleBar() -{ - Q_D(FramelessWindow); - HWND hWnd = reinterpret_cast(winId()); - { - SetWindowLongW(hWnd, GWL_STYLE, d->currentStyle); - SetWindowLongW(hWnd, GWL_EXSTYLE, d->currentExStyle); - - MARGINS margins = { 0 }; - DwmExtendFrameIntoClientArea(hWnd, &margins); - } - d->delegateWindow->updateWindow(hWnd, true, true); - if (d->titleBar) { - delete d->titleBar; - d->titleBar = nullptr; - } - setMenuWidget(nullptr); - if (d->delegateWindow) { - delete d->delegateWindow; - d->delegateWindow = nullptr; - } - setWindowFlag(Qt::Window, true); - setWindowFlag(Qt::FramelessWindowHint, false); -} - - -void shelllet::frameless::FramelessWindow::disableNativeTitleBar() -{ - Q_D(FramelessWindow); - HWND hWnd = reinterpret_cast(winId()); - { - SetWindowLongW(hWnd, GWL_STYLE, d->currentStyle | WS_OVERLAPPEDWINDOW | WS_SIZEBOX); - //SetWindowLongW(hWnd, GWL_EXSTYLE, d->currentExStyle | WS_EX_LAYERED); - SetLayeredWindowAttributes(hWnd, RGB(255, 0, 0), 0, LWA_COLORKEY); - - DWMNCRENDERINGPOLICY ncrp = DWMNCRP_ENABLED; - DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp)); - MARGINS margins = { 0, 0, 0, 0 }; - DwmExtendFrameIntoClientArea(hWnd, &margins); - } - - d->titleBar = new TitleBarWidget; - d->delegateWindow = new DelegateWindow(d->titleBar); - d->titleBar->setWindowTypes(d->flags); - - d->titleBar->setFixedHeight(d->delegateWindow->getSystemTitleBarHeight(hWnd)); - connect(d->titleBar, &TitleBarWidget::closeButtonClicked, this, &FramelessWindow::closeButtonClicked); - connect(d->titleBar, &TitleBarWidget::minimizeButtonClicked, this, &FramelessWindow::minimizeButtonClicked); - connect(d->titleBar, &TitleBarWidget::maximizeButtonClicked, this, &FramelessWindow::maximizeButtonClicked); - connect(d->titleBar, &TitleBarWidget::restoreButtonClicked, this, &FramelessWindow::restoreButtonClicked); - connect(d->titleBar, &TitleBarWidget::iconDoubleClicked, this, &FramelessWindow::iconDoubleClicked); - - connect(this, &FramelessWindow::windowTitleChanged, d->titleBar, &TitleBarWidget::windowTitleChanged); - connect(this, &FramelessWindow::windowIconChanged, d->titleBar, &TitleBarWidget::windowIconChanged); - - setMenuWidget(d->titleBar); - setWindowFlag(Qt::FramelessWindowHint, true); - setWindowFlag(Qt::Window, false); -} - -void shelllet::frameless::FramelessWindow::minimizeButtonClicked() { - Q_D(FramelessWindow); - showMinimized(); -} - -void shelllet::frameless::FramelessWindow::restoreButtonClicked() { - Q_D(FramelessWindow); - showNormal(); -} - -void shelllet::frameless::FramelessWindow::maximizeButtonClicked() { - Q_D(FramelessWindow); - - showMaximized(); -} - -void shelllet::frameless::FramelessWindow::closeButtonClicked() { close(); } - - -void shelllet::frameless::FramelessWindow::iconDoubleClicked() -{ - close(); -} - -void shelllet::frameless::FramelessWindow::paintEvent(QPaintEvent* event) -{ - Q_D(FramelessWindow); - if (d->titleBar) { - QStyleOption styleOption; - styleOption.initFrom(this); - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - QPen pen; - pen.setColor(QColor(58, 58, 58)); - QBrush brush(QColor(58, 58, 58)); - painter.setPen(pen); - painter.setBrush(brush); - painter.drawRect(rect()); - //QPainterPath path; - //path.addRoundedRect(rect(), 0, 0); - - //painter.drawPath(path); - } - else { - __super::paintEvent(event); - } -} - -void shelllet::frameless::FramelessWindow::changeEvent(QEvent* event) -{ - Q_D(FramelessWindow); - if (event->type() == QEvent::WindowStateChange) - { - QWindowStateChangeEvent* e = dynamic_cast(event); - if (!(e->oldState() & Qt::WindowMaximized) && (windowState() & Qt::WindowMaximized)) - { - if (d->titleBar) { - d->titleBar->setFixedHeight(d->delegateWindow->getSystemTitleBarHeight(reinterpret_cast(winId()))); - d->titleBar->switchToRestoreButton(); - } - } - else if ((e->oldState() & Qt::WindowMaximized) && (windowState() != Qt::WindowMaximized)) - { - if (d->titleBar) { - d->titleBar->setFixedHeight(d->delegateWindow->getSystemTitleBarHeight(reinterpret_cast(winId()))); - if (!isMaximized()) - d->titleBar->switchToMaxButton(); - } - } - } - __super::changeEvent(event); -} - -bool shelllet::frameless::FramelessWindow::nativeEvent(const QByteArray& eventType, void* message, long* result) -{ - Q_D(FramelessWindow); - LPMSG lpMsg = reinterpret_cast(message); - if (!d->titleBar) { - return __super::nativeEvent(eventType, message, result); - } - switch (lpMsg->message) { - case WM_NCCALCSIZE: - if (lpMsg->wParam) { - - d->delegateWindow->calcNcSize(lpMsg->hwnd, lpMsg->wParam, lpMsg->lParam); - *result = WVR_REDRAW; - return true; - } - break; - case WM_NCHITTEST: - { - POINT pt = { GET_X_LPARAM(lpMsg->lParam), GET_Y_LPARAM(lpMsg->lParam) }; - - ScreenToClient(lpMsg->hwnd, &pt); - RECT rc; - GetClientRect(lpMsg->hwnd, &rc); - *result = d->delegateWindow->hitNcTest(lpMsg->hwnd, { pt.x, pt.y }, { rc.left,rc.top, rc.right - rc.left, rc.bottom - rc.top }, fixedSizeTypes()); - return *result != 0; - } - case WM_DPICHANGED: - d->delegateWindow->updateWindow(lpMsg->hwnd, true, true); - break; - case WM_GETMINMAXINFO: - *result = ::DefWindowProc(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, lpMsg->lParam); - return true; - case WM_MOVE: - d->delegateWindow->updateWindow(lpMsg->hwnd, true, true); - break; - case WM_NCACTIVATE: - *result = DefWindowProcW(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, -1); - return true; - case WM_NCLBUTTONDBLCLK: - if (!d->flags.testFlag(WindowType::MaximizeButtonHint)) - return true; - *result = DefWindowProcW(lpMsg->hwnd, lpMsg->message, lpMsg->wParam, -1); - return true; - case WM_NCRBUTTONDOWN: - if (d->menu) - d->menu->exec(QCursor::pos()); - } - return false; -} diff --git a/framless_window/src/logs.cpp b/framless_window/src/logs.cpp deleted file mode 100644 index 7ad8c96..0000000 --- a/framless_window/src/logs.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "common/logs.h" -#include "boost/log/support/date_time.hpp" -#include "boost/log/utility/setup/common_attributes.hpp" -#include "boost/log/expressions/predicates/is_debugger_present.hpp" -#include "boost/log/utility/setup/console.hpp" -#include "boost/log/utility/setup/file.hpp" - -namespace shelllet { - typedef boost::log::sinks::synchronous_sink sink_debug_t; - typedef boost::log::sinks::synchronous_sink sink_broadcast_t; - - namespace logging { - static inline auto LOG_FORMAT_STREAM = (boost::log::expressions::format("[%1%]<%2%> : <%3%> %4%") - % boost::log::expressions::format_date_time("TimeStamp", "%Y-%m-%d %H:%M:%S") - % boost::log::expressions::attr< std::string >("Channel") - % boost::log::trivial::severity - % boost::log::expressions::message); - - - BOOST_LOG_ATTRIBUTE_KEYWORD(keyword_channel, "Channel", std::string); - } -} -void shelllet::logging::add_custom_sink(const boost::shared_ptr& sink) -{ - //sink->set_formatter(boost::log::expressions::stream << boost::log::expressions::if_(boost::log::expressions::has_attr(simple_log_message) && boost::log::expressions::attr("Simple")) - // [ - // boost::log::expressions::stream << boost::log::expressions::message - // ] - //.else_ - // [ - // LOG_FORMAT_STREAM - // ]); - boost::log::formatter formatter = ( - boost::log::expressions::stream - << boost::log::expressions::format_date_time("TimeStamp", "%H:%M:%S") - << " " << boost::log::expressions::smessage); - sink->set_formatter(formatter); - - boost::log::core::get()->add_sink(sink); - // LOG_INFO("") << boost::log::add_value(simple_log_message, true) << "simple message." << std::endl; -} - - -void shelllet::logging::add_file_sink(const std::filesystem::path& filename) -{ - boost::log::add_file_log(boost::log::keywords::file_name = filename.c_str(), - boost::log::keywords::rotation_size = 1 * 1024 * 1024, - boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0), - boost::log::keywords::format = LOG_FORMAT_STREAM - //boost::log::keywords::channel = keyword_channel == channel - ); -} - -void shelllet::logging::initialize(boost::log::trivial::severity_level level) -{ - boost::log::add_common_attributes(); - - { - boost::shared_ptr sink = boost::make_shared(); - sink->set_formatter(LOG_FORMAT_STREAM); - boost::log::core::get()->add_sink(sink); - } - - - boost::log::add_console_log(std::clog, boost::log::keywords::format = LOG_FORMAT_STREAM); - boost::log::core::get()->set_filter(boost::log::trivial::severity >= level); -} - -boost::log::trivial::severity_level shelllet::logging::level_from_string(const std::string& level) -{ - static std::map map = { - {"trace", boost::log::trivial::trace} , - {"debug", boost::log::trivial::debug} , - {"info", boost::log::trivial::info} , - {"warning", boost::log::trivial::warning} , - {"error", boost::log::trivial::error} , - {"fatal", boost::log::trivial::fatal} - }; - - if (auto itor = map.find(level); itor != map.cend()) { - return itor->second; - } - return boost::log::trivial::fatal; -} diff --git a/framless_window/src/mainwindow.cpp b/framless_window/src/mainwindow.cpp deleted file mode 100644 index fb87a11..0000000 --- a/framless_window/src/mainwindow.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "mainwindow.h" -#include "qapplication.h" -#include "qstyle.h" -#include "qdesktopwidget.h" -#include "private/mainwindow_p.h" -namespace shelllet { - - -} - -shelllet::frameless::MainWindow::MainWindow(QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= WindowFlags()*/) - : MainWindow(*new MainWindowPrivate, parent, flags) -{ -} - -void shelllet::frameless::MainWindow::moveToCentral() -{ - // Q_D(FramelessWindow); - //QSize size = QApplication::primaryScreen()->availableSize() * 0.5; - - //LOG_DEBUG(PROJECT_NAME) << "# geometry size: " << geometry() << std::endl; - setGeometry(QStyle::alignedRect( - Qt::LeftToRight, - Qt::AlignCenter, - geometry().size(), - qApp->desktop()->availableGeometry())); ; -} - -void shelllet::frameless::MainWindow::setFixedHeight(int h) -{ - - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedHeigth; - __super::setFixedHeight(h); -} - -void shelllet::frameless::MainWindow::setFixedWidth(int w) -{ - - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedWidth; - __super::setFixedWidth(w); -} - -void shelllet::frameless::MainWindow::setFixedSize(const QSize& s) -{ - - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedAll; - __super::setFixedSize(s); -} - -shelllet::frameless::SizePolicyFlags shelllet::frameless::MainWindow::fixedSizeTypes() const -{ - Q_D(const MainWindow); - - return d->fixedSize; -} - -shelllet::frameless::MainWindow::MainWindow(MainWindowPrivate& d, QWidget* parent /*= nullptr*/, WindowTypeFlags flags /*= WindowFlags()*/) - : FramelessWindow(d, parent, flags) -{ - -} - -void shelllet::frameless::MainWindow::setFixedSize(int w, int h) -{ - Q_D(MainWindow); - d->fixedSize = SizePolicy::FixedAll; - __super::setFixedSize(w, h); -} diff --git a/framless_window/src/object.cpp b/framless_window/src/object.cpp deleted file mode 100644 index 66e39c7..0000000 --- a/framless_window/src/object.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "common/object.h" - -shelllet::common::ObjectData::~ObjectData() -{ - -} - -shelllet::common::ObjectPrivate::~ObjectPrivate() -{ - -} - -shelllet::common::Object::Object(ObjectPrivate& dd, Object* parent /*= nullptr*/) - : d_ptr(&dd) -{ - Q_D(Object); - d_ptr->q_ptr = this; -} \ No newline at end of file diff --git a/framless_window/src/standardbutton.cpp b/framless_window/src/standardbutton.cpp deleted file mode 100644 index 48620ca..0000000 --- a/framless_window/src/standardbutton.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "standardbutton.h" -#include "qstyleoption.h" -#include "qsvgrenderer.h" -#include "qpainter.h" -#include "qguiapplication.h" -#include "pugixml.hpp" -#include -#include "qevent.h" -namespace shelllet { - namespace frameless { - static constexpr std::int32_t kNumTypes = 4; - enum class MouseStatus { - None, - Enter, - Leave, - Pressed, - Release - }; - - class StandardButtonPrivate : public ObjectPrivate { - Q_DECLARE_PUBLIC(StandardButton) - public: - MouseStatus status = {}; - Qt::ApplicationState state = {}; - - std::array xmls; - - ButtonType type = {}; - QByteArray getXmlData(const QColor& c) const { - std::ostringstream stream; - auto& doc = xmls[static_cast(type)]; - doc.document_element().first_child().attribute("fill") = c.name().toUtf8().constData(); - doc.save(stream); - return QByteArray(stream.str().c_str()); - } - const QColor hoverColor = "#686868"; - const QColor pressColor = "#484848"; - const QColor releaseColor = "#3a3a3a"; - const QColor leaveColor = "#3a3a3a"; - const QColor hoverColorForClose = "#E81123"; - const QColor pressColorForClose = "#F1707A"; - void init() { - Q_Q(StandardButton); - xmls[static_cast(ButtonType::Close)].load_string(R"( - - )"); - - xmls[static_cast(ButtonType::Restore)].load_string(R"( - - )"); - - xmls[static_cast(ButtonType::Maximize)].load_string(R"( - - )"); - - xmls[static_cast(ButtonType::Minimize)].load_string(R"( - - )"); - } - }; - } -} -shelllet::frameless::StandardButton::StandardButton(ButtonType t, QWidget* parent /*= nullptr*/) - : QSvgWidget(parent) - , Object(*new StandardButtonPrivate, nullptr) -{ - Q_D(StandardButton); - d->type = t; - d->init(); - load(d->getXmlData(Qt::white)); - QObject::connect(qApp, &QGuiApplication::applicationStateChanged, this, &StandardButton::applicationStateChanged); -} - -QSize shelllet::frameless::StandardButton::sizeHint() const -{ - return { qRound(geometry().height() * 1.36) ,geometry().height() }; -} - -void shelllet::frameless::StandardButton::applicationStateChanged(Qt::ApplicationState state) -{ - Q_D(StandardButton); - d->state = state; - if (state == Qt::ApplicationActive) { - load(d->getXmlData(Qt::white)); - } - else { - load(d->getXmlData(Qt::gray)); - } - update(); -} - -void shelllet::frameless::StandardButton::paintEvent(QPaintEvent* event) -{ - Q_D(StandardButton); - - QStyleOption opt; - opt.initFrom(this); - QPainter painter(this); - - switch (d->status) - { - case MouseStatus::Enter: - painter.fillRect(rect(), d->type == ButtonType::Close ? d->hoverColorForClose : d->hoverColor); - break; - case MouseStatus::Pressed: - painter.fillRect(rect(), d->type == ButtonType::Close ? d->pressColorForClose : d->pressColor); - break; - case MouseStatus::Release: - painter.fillRect(rect(), d->releaseColor); - break; - case MouseStatus::Leave: - painter.fillRect(rect(), d->leaveColor); - break; - default: - //painter.fillRect(rect(), 0x3a3a3a); - break; - } - QRectF rc = QRectF({ .0f, .0f }, renderer()->defaultSize() * 1.0f); - rc.moveCenter(rect().center()); - - renderer()->render(&painter, rc); -} - -void shelllet::frameless::StandardButton::mousePressEvent(QMouseEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Pressed; - update(); -} - -void shelllet::frameless::StandardButton::enterEvent(QEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Enter; - update(); -} - -void shelllet::frameless::StandardButton::leaveEvent(QEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Leave; - update(); -} - -void shelllet::frameless::StandardButton::mouseReleaseEvent(QMouseEvent* event) -{ - Q_D(StandardButton); - d->status = MouseStatus::Release; - update(); - if (event->button() == Qt::LeftButton && underMouse()) - emit clicked(); -} - diff --git a/framless_window/src/titlebarwidget.cpp b/framless_window/src/titlebarwidget.cpp deleted file mode 100644 index c314a20..0000000 --- a/framless_window/src/titlebarwidget.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include "titlebarwidget.h" -#include "qpainter.h" -#include "qstyleoption.h" -#include "private/qwidget_p.h" -#include "qlabel.h" -#include "qtoolbutton.h" -#include "qapplication.h" -#include "qstackedwidget.h" -#include "standardbutton.h" -#include "qboxlayout.h" -#include -namespace shelllet { - namespace frameless { - class IconButton : public QLabel { - public: - IconButton(const std::function& doubleClicked, QWidget* parent) : QLabel(parent), doubleClicked(doubleClicked) { - } - - protected: - void mouseDoubleClickEvent(QMouseEvent* /*event*/) override - { - if (doubleClicked) - doubleClicked(); - } - - private: - std::function doubleClicked; - }; - - class TitleBarWidgetPrivate : public QWidgetPrivate { - public: - IconButton* icon; - QLabel* titleText; - StandardButton* minimizeButton; - StandardButton* restoreButton; - StandardButton* maximizeButton; - StandardButton* closeButton; - QStackedWidget* customButton; - QHBoxLayout* horizontalLayout; - const float factor = 0.8; - void setupUi(TitleBarWidget* parent) { - parent->setObjectName("window-title-bar"); - horizontalLayout = new QHBoxLayout(parent); - horizontalLayout->setSpacing(0); - horizontalLayout->setContentsMargins(0, 0, 0, 0); - horizontalLayout->addSpacing(2); - - icon = new IconButton([parent]() { parent->iconDoubleClicked(); }, parent); - auto extent = static_cast(parent->geometry().height() * factor); - icon->setPixmap(qApp->windowIcon().pixmap(extent)); - icon->setContextMenuPolicy(Qt::NoContextMenu); - - horizontalLayout->addWidget(icon); - horizontalLayout->addSpacing(1); - - titleText = new QLabel(parent); - titleText->setObjectName("window-title-label"); - titleText->setAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter); - titleText->setContextMenuPolicy(Qt::CustomContextMenu); - - - titleText->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - horizontalLayout->addWidget(titleText); - - horizontalLayout->addSpacing(9); - customButton = new QStackedWidget(parent); - horizontalLayout->addWidget(customButton); - - minimizeButton = new StandardButton(ButtonType::Minimize, parent); - minimizeButton->setFixedWidth(45); - horizontalLayout->addWidget(minimizeButton); - - restoreButton = new StandardButton(ButtonType::Restore, parent); - restoreButton->setFixedWidth(45); - horizontalLayout->addWidget(restoreButton); - restoreButton->setStyleSheet("background-color: #3a3a3a"); - - maximizeButton = new StandardButton(ButtonType::Maximize, parent); - maximizeButton->setFixedWidth(45); - horizontalLayout->addWidget(maximizeButton); - maximizeButton->setStyleSheet("background-color: #3a3a3a"); - closeButton = new StandardButton(ButtonType::Close, parent); - closeButton->setFixedWidth(45); - horizontalLayout->addWidget(closeButton); - } - }; - } -} -shelllet::frameless::TitleBarWidget::TitleBarWidget(QWidget* parent /*= nullptr*/, WindowTypeFlags f /*= WindowTypes()*/) - : QWidget(*new TitleBarWidgetPrivate, parent, {}) { - Q_D(TitleBarWidget); - d->setupUi(this); - - - - d->restoreButton->setVisible(false); - connect(this, &TitleBarWidget::windowTitleChanged, [d](const QString& title) {d->titleText->setText(title); }); - connect(this, &TitleBarWidget::windowIconChanged, [this, d](const QIcon& icon) {d->icon->setPixmap(icon.pixmap(static_cast(geometry().height() * d->factor))); }); - - connect(d->closeButton, SIGNAL(clicked()), this, SIGNAL(closeButtonClicked())); - connect(d->minimizeButton, SIGNAL(clicked()), this, SIGNAL(minimizeButtonClicked())); - connect(d->maximizeButton, SIGNAL(clicked()), this, SIGNAL(maximizeButtonClicked())); - connect(d->restoreButton, SIGNAL(clicked()), this, SIGNAL(restoreButtonClicked())); - QObject::connect(qApp, &QGuiApplication::applicationStateChanged, this, &TitleBarWidget::applicationStateChanged); -} - -void shelllet::frameless::TitleBarWidget::applicationStateChanged(Qt::ApplicationState state) -{ - Q_D(TitleBarWidget); - - if (state == Qt::ApplicationActive) { - d->titleText->setStyleSheet("color: rgb(240, 240, 240)"); - } - else { - d->titleText->setStyleSheet("color: rgb(200, 200, 200)"); - } -} - -void shelllet::frameless::TitleBarWidget::setWindowTypes(WindowTypeFlags f) -{ - Q_D(TitleBarWidget); - if (!f.testFlag(WindowType::CloseButtonHint)) { - d->closeButton->hide(); - } - if (!f.testFlag(WindowType::MinimizeButtonHint)) { - d->minimizeButton->hide(); - } - if (!f.testFlag(WindowType::MaximizeButtonHint)) { - d->maximizeButton->hide(); - } -} - -void shelllet::frameless::TitleBarWidget::setCustomButton(QWidget* c) -{ - Q_D(TitleBarWidget); - auto* widget = d->customButton->currentWidget(); - if (widget) { - d->customButton->removeWidget(widget); - widget->deleteLater(); - } - d->customButton->addWidget(c); -} - -bool shelllet::frameless::TitleBarWidget::underMouse() -{ - Q_D(TitleBarWidget); - QWidget* action = QApplication::widgetAt(QCursor::pos()); - if (action == this || action == d->titleText || action == d->customButton) { - return true; - } - return false; -} - -void shelllet::frameless::TitleBarWidget::switchToMaxButton() -{ - Q_D(TitleBarWidget); - d->restoreButton->setVisible(false); - d->maximizeButton->setVisible(true); -} - -void shelllet::frameless::TitleBarWidget::switchToRestoreButton() -{ - Q_D(TitleBarWidget); - d->restoreButton->setVisible(true); - d->maximizeButton->setVisible(false); -} - -void shelllet::frameless::TitleBarWidget::setTitleTextBlurRadius(qreal blurRadius) -{ - Q_D(TitleBarWidget); - QGraphicsDropShadowEffect* textShadow = new QGraphicsDropShadowEffect; - textShadow->setBlurRadius(blurRadius); - textShadow->setColor(QColor(0, 0, 0)); - textShadow->setOffset(.0f); - d->titleText->setGraphicsEffect(textShadow); -} - -void shelllet::frameless::TitleBarWidget::paintEvent(QPaintEvent* event) { - boost::ignore_unused(event); - QStyleOption styleOption; - styleOption.initFrom(this); - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - style()->drawPrimitive(QStyle::PE_Widget, &styleOption, &painter, this); -} - -void shelllet::frameless::TitleBarWidget::resizeEvent(QResizeEvent* event) -{ - //throw std::logic_error("The method or operation is not implemented."); - Q_D(TitleBarWidget); - auto extent = static_cast(event->size().height() * d->factor); - d->icon->setPixmap(qApp->windowIcon().pixmap(extent)); -} - diff --git a/index.md b/index.md new file mode 100644 index 0000000..374ee0a --- /dev/null +++ b/index.md @@ -0,0 +1,37 @@ +## Welcome to GitHub Pages + +You can use the [editor on GitHub](https://github.com/shelllet/cpp-example/edit/gh-pages/index.md) to maintain and preview the content for your website in Markdown files. + +Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. + +### Markdown + +Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for + +```markdown +Syntax highlighted code block + +# Header 1 +## Header 2 +### Header 3 + +- Bulleted +- List + +1. Numbered +2. List + +**Bold** and _Italic_ and `Code` text + +[Link](url) and ![Image](src) +``` + +For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/). + +### Jekyll Themes + +Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/shelllet/cpp-example/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file. + +### Support or Contact + +Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out. diff --git a/ppt/01-Qt introduce.pptx b/ppt/01-Qt introduce.pptx deleted file mode 100644 index 78f51cd..0000000 Binary files a/ppt/01-Qt introduce.pptx and /dev/null differ diff --git a/ppt/02-env-QtCreator.pptx b/ppt/02-env-QtCreator.pptx deleted file mode 100644 index 42f76ab..0000000 Binary files a/ppt/02-env-QtCreator.pptx and /dev/null differ diff --git a/ppt/03-env-Visual studio 2017(Hyper-V).pptx b/ppt/03-env-Visual studio 2017(Hyper-V).pptx deleted file mode 100644 index c578498..0000000 Binary files a/ppt/03-env-Visual studio 2017(Hyper-V).pptx and /dev/null differ diff --git a/ppt/04-layout(Widget).pptx b/ppt/04-layout(Widget).pptx deleted file mode 100644 index 1da5f4d..0000000 Binary files a/ppt/04-layout(Widget).pptx and /dev/null differ diff --git a/ppt/10-Spacer.pptx b/ppt/10-Spacer.pptx deleted file mode 100644 index 5e112bf..0000000 Binary files a/ppt/10-Spacer.pptx and /dev/null differ diff --git a/ppt/11-Buttons.pptx b/ppt/11-Buttons.pptx deleted file mode 100644 index 86f7f0a..0000000 Binary files a/ppt/11-Buttons.pptx and /dev/null differ diff --git a/ppt/17-Views.pptx b/ppt/17-Views.pptx deleted file mode 100644 index 88e8f96..0000000 Binary files a/ppt/17-Views.pptx and /dev/null differ diff --git a/qt/Buttons/CommandLinkButton/1.png b/qt/Buttons/CommandLinkButton/1.png deleted file mode 100644 index de68fd3..0000000 Binary files a/qt/Buttons/CommandLinkButton/1.png and /dev/null differ diff --git a/qt/Buttons/CommandLinkButton/2.png b/qt/Buttons/CommandLinkButton/2.png deleted file mode 100644 index 20edb92..0000000 Binary files a/qt/Buttons/CommandLinkButton/2.png and /dev/null differ diff --git a/qt/Buttons/CommandLinkButton/3.png b/qt/Buttons/CommandLinkButton/3.png deleted file mode 100644 index 2f7cb48..0000000 Binary files a/qt/Buttons/CommandLinkButton/3.png and /dev/null differ diff --git a/qt/Buttons/CommandLinkButton/4.png b/qt/Buttons/CommandLinkButton/4.png deleted file mode 100644 index 1fde370..0000000 Binary files a/qt/Buttons/CommandLinkButton/4.png and /dev/null differ diff --git a/qt/Buttons/CommandLinkButton/CommandLinkButton.pro b/qt/Buttons/CommandLinkButton/CommandLinkButton.pro deleted file mode 100644 index 365c843..0000000 --- a/qt/Buttons/CommandLinkButton/CommandLinkButton.pro +++ /dev/null @@ -1,43 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-10-01T18:10:51 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = CommandLinkButton -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - -RESOURCES += \ - rc.qrc diff --git a/qt/Buttons/CommandLinkButton/main.cpp b/qt/Buttons/CommandLinkButton/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/Buttons/CommandLinkButton/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/Buttons/CommandLinkButton/mainwindow.cpp b/qt/Buttons/CommandLinkButton/mainwindow.cpp deleted file mode 100644 index 75d1060..0000000 --- a/qt/Buttons/CommandLinkButton/mainwindow.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_commandLinkButton_clicked() -{ - -} diff --git a/qt/Buttons/CommandLinkButton/mainwindow.h b/qt/Buttons/CommandLinkButton/mainwindow.h deleted file mode 100644 index a96db2f..0000000 --- a/qt/Buttons/CommandLinkButton/mainwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_commandLinkButton_clicked(); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/Buttons/CommandLinkButton/mainwindow.ui b/qt/Buttons/CommandLinkButton/mainwindow.ui deleted file mode 100644 index c96ce53..0000000 --- a/qt/Buttons/CommandLinkButton/mainwindow.ui +++ /dev/null @@ -1,214 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 357 - 462 - - - - MainWindow - - - - background-color: rgb(37, 37, 38); - - - - - 70 - 41 - 240 - 345 - - - - - - - background-color: rgb(51, 51, 55); - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - false - - - -color: rgb(255, 255, 255); - - - Clone or checkout code - - - - :/new/prefix1/1.png:/new/prefix1/1.png - - - - 80 - 40 - - - - get code form online - - - - - - - - - - background-color: rgb(51, 51, 55); - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - color: rgb(255, 255, 255); - - - Open - - - - :/new/prefix1/2.png:/new/prefix1/2.png - - - - 40 - 40 - - - - Open a local project - - - - - - - - - - background-color: rgb(51, 51, 55); - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - color: rgb(255, 255, 255); - - - Open Local Folder - - - - :/new/prefix1/3.png:/new/prefix1/3.png - - - - 40 - 40 - - - - Navigate and edit code - - - - - - - - - - background-color: rgb(51, 51, 55); - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - color: rgb(255, 255, 255); - - - Create new project - - - - :/new/prefix1/4.png:/new/prefix1/4.png - - - - 40 - 40 - - - - Choost project from template - - - - - - - - - - - - - 0 - 0 - 357 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/Buttons/CommandLinkButton/rc.qrc b/qt/Buttons/CommandLinkButton/rc.qrc deleted file mode 100644 index cdb3268..0000000 --- a/qt/Buttons/CommandLinkButton/rc.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - 1.png - 2.png - 3.png - 4.png - - diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/.gitignore b/qt/Buttons/DialogButtonBox/DialogButtonBox/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/DialogButtonBox.pro b/qt/Buttons/DialogButtonBox/DialogButtonBox/DialogButtonBox.pro deleted file mode 100644 index 45f245c..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/DialogButtonBox.pro +++ /dev/null @@ -1,34 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - dialog.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - dialog.h \ - mainwindow.h - -FORMS += \ - dialog.ui \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.cpp b/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.cpp deleted file mode 100644 index c31861f..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "dialog.h" -#include "ui_dialog.h" -#include - -Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) -{ - ui->setupUi(this); - - QPushButton* btn = ui->buttonBox->button(QDialogButtonBox::Ok); - btn->setText(QStringLiteral("确定")); - - btn = ui->buttonBox->button(QDialogButtonBox::Cancel); - btn->setText(QStringLiteral("取消")); -} - -Dialog::~Dialog() -{ - delete ui; -} - -Dialog::Option Dialog::getOption() const -{ - return option_; -} - -void Dialog::on_buttonBox_accepted() -{ - option_.math = ui->checkBox_math->isChecked(); - option_.chinese = ui->checkBox_chi->isChecked(); - option_.english = ui->checkBox_eng->isChecked(); - - accept(); -} - -void Dialog::on_buttonBox_rejected() -{ - reject(); -} diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.h b/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.h deleted file mode 100644 index 219e372..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef DIALOG_H -#define DIALOG_H - -#include - -namespace Ui { -class Dialog; -} - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = nullptr); - ~Dialog(); - - struct Option{ - bool chinese; - bool english; - bool math; - }; - -public: - Option getOption() const; - -private slots: - void on_buttonBox_accepted(); - - void on_buttonBox_rejected(); - - -private: - Ui::Dialog *ui; - Option option_; -}; - -#endif // DIALOG_H diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.ui b/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.ui deleted file mode 100644 index 88a520a..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/dialog.ui +++ /dev/null @@ -1,74 +0,0 @@ - - - Dialog - - - - 0 - 0 - 450 - 313 - - - - Dialog - - - - - 95 - 270 - 291 - 23 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - true - - - - - - 100 - 60 - 71 - 16 - - - - 英文 - - - - - - 100 - 100 - 71 - 16 - - - - 中文 - - - - - - 100 - 140 - 71 - 16 - - - - 数学 - - - - - - diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/main.cpp b/qt/Buttons/DialogButtonBox/DialogButtonBox/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.cpp b/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.cpp deleted file mode 100644 index b7d4c3a..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include "dialog.h" -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_actionoptional_triggered() -{ - Dialog dlg; - auto result = dlg.exec(); - - if (result == QDialog::Accepted){ - - auto option = dlg.getOption(); - - - qDebug() <<"math: " << option.math << "\n" - << "chinese: " << option.chinese << "\n" - << "english: " << option.english; - } - else{ - qDebug() << "reject."; - } - -} diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.h b/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.h deleted file mode 100644 index fa6e563..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_actionoptional_triggered(); - -private: - Ui::MainWindow *ui; - -}; -#endif // MAINWINDOW_H diff --git a/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.ui b/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.ui deleted file mode 100644 index cfa4ecb..0000000 --- a/qt/Buttons/DialogButtonBox/DialogButtonBox/mainwindow.ui +++ /dev/null @@ -1,43 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 0 - 0 - 800 - 23 - - - - - 设置 - - - - - - - - - 选项 - - - - - - diff --git a/qt/Buttons/Radio/Radio.pro b/qt/Buttons/Radio/Radio.pro deleted file mode 100644 index 19aa5d8..0000000 --- a/qt/Buttons/Radio/Radio.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-09-07T17:15:45 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = Radio -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Buttons/Radio/main.cpp b/qt/Buttons/Radio/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/Buttons/Radio/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/Buttons/Radio/mainwindow.cpp b/qt/Buttons/Radio/mainwindow.cpp deleted file mode 100644 index 33828ea..0000000 --- a/qt/Buttons/Radio/mainwindow.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_radioButton_2_clicked() -{ - static int index = 0; - qDebug() << "clicked: "<< index++ ; -} - - -void MainWindow::on_radioButton_clicked() -{ - - ui->radioButton_2->setChecked(!ui->radioButton_2->isChecked()); - -} diff --git a/qt/Buttons/Radio/mainwindow.h b/qt/Buttons/Radio/mainwindow.h deleted file mode 100644 index be155db..0000000 --- a/qt/Buttons/Radio/mainwindow.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_radioButton_2_clicked(); - - void on_radioButton_clicked(); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/Buttons/Radio/mainwindow.ui b/qt/Buttons/Radio/mainwindow.ui deleted file mode 100644 index cf0377d..0000000 --- a/qt/Buttons/Radio/mainwindow.ui +++ /dev/null @@ -1,107 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 400 - 300 - - - - MainWindow - - - - - - 200 - 30 - 89 - 16 - - - - 英文 - - - true - - - false - - - true - - - true - - - 6000 - - - 1000 - - - - - - 80 - 110 - 120 - 80 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 40 - 30 - 89 - 16 - - - - 中文 - - - false - - - true - - - - - - - - 0 - 0 - 400 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/Buttons/checkbox/checkbox.pro b/qt/Buttons/checkbox/checkbox.pro deleted file mode 100644 index cd8c628..0000000 --- a/qt/Buttons/checkbox/checkbox.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-09-21T10:00:05 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = checkbox -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Buttons/checkbox/main.cpp b/qt/Buttons/checkbox/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/Buttons/checkbox/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/Buttons/checkbox/mainwindow.cpp b/qt/Buttons/checkbox/mainwindow.cpp deleted file mode 100644 index 36ab23d..0000000 --- a/qt/Buttons/checkbox/mainwindow.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_checkBox_co_stateChanged(int arg1) -{ - ui->checkBox_chi->blockSignals(true); - ui->checkBox_eng->blockSignals(true); - ui->checkBox_jp->blockSignals(true); - - ui->checkBox_chi->setChecked(arg1 == Qt::Checked); - ui->checkBox_eng->setChecked(arg1 == Qt::Checked); - ui->checkBox_jp->setChecked(arg1 == Qt::Checked); - - ui->checkBox_chi->blockSignals(false); - ui->checkBox_eng->blockSignals(false); - ui->checkBox_jp->blockSignals(false); -} - -void MainWindow::on_checkBox_chi_stateChanged(int arg1) -{ - Qt::CheckState state; - - if (arg1 == ui->checkBox_eng->checkState() && arg1 == ui->checkBox_jp->checkState()){ - state = (Qt::CheckState)arg1; - } else { - state = Qt::PartiallyChecked; - } - - ui->checkBox_co->blockSignals(true); - ui->checkBox_co->setCheckState( state); - ui->checkBox_co->blockSignals(false); -} - -void MainWindow::on_checkBox_eng_stateChanged(int arg1) -{ - Qt::CheckState state; - - if (arg1 == ui->checkBox_chi->checkState() && arg1 == ui->checkBox_jp->checkState()){ - state = (Qt::CheckState)arg1; - } else { - state = Qt::PartiallyChecked; - } - ui->checkBox_co->blockSignals(true); - ui->checkBox_co->setCheckState( state); - ui->checkBox_co->blockSignals(false); -} - -void MainWindow::on_checkBox_jp_stateChanged(int arg1) -{ - Qt::CheckState state; - - if (arg1 == ui->checkBox_chi->checkState() && arg1 == ui->checkBox_eng->checkState()){ - state = (Qt::CheckState)arg1; - } else { - state = Qt::PartiallyChecked; - } - - ui->checkBox_co->blockSignals(true); - ui->checkBox_co->setCheckState( state); - ui->checkBox_co->blockSignals(false); -} diff --git a/qt/Buttons/checkbox/mainwindow.h b/qt/Buttons/checkbox/mainwindow.h deleted file mode 100644 index 93f7d9f..0000000 --- a/qt/Buttons/checkbox/mainwindow.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_checkBox_co_stateChanged(int arg1); - - void on_checkBox_chi_stateChanged(int arg1); - - void on_checkBox_eng_stateChanged(int arg1); - - void on_checkBox_jp_stateChanged(int arg1); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/Buttons/checkbox/mainwindow.ui b/qt/Buttons/checkbox/mainwindow.ui deleted file mode 100644 index 00fa777..0000000 --- a/qt/Buttons/checkbox/mainwindow.ui +++ /dev/null @@ -1,112 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 400 - 300 - - - - MainWindow - - - - - - 120 - 60 - 71 - 16 - - - - 汉语 - - - false - - - - - - 120 - 100 - 71 - 16 - - - - 英语 - - - - - - 120 - 140 - 71 - 16 - - - - 日语 - - - - - - 50 - 30 - 71 - 16 - - - - 学科 - - - true - - - - - - 250 - 190 - 75 - 23 - - - - 报名 - - - - - - - 0 - 0 - 400 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/Buttons/pushbutton/Buttons.pro b/qt/Buttons/pushbutton/Buttons.pro deleted file mode 100644 index 3fe05f7..0000000 --- a/qt/Buttons/pushbutton/Buttons.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-08-03T17:34:28 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = Buttons -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Buttons/pushbutton/main.cpp b/qt/Buttons/pushbutton/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/Buttons/pushbutton/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/Buttons/pushbutton/mainwindow.cpp b/qt/Buttons/pushbutton/mainwindow.cpp deleted file mode 100644 index 7ad67e0..0000000 --- a/qt/Buttons/pushbutton/mainwindow.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_pushButton_clicked() -{ - QMessageBox::about(this, "about", "this is button click"); -} diff --git a/qt/Buttons/pushbutton/mainwindow.h b/qt/Buttons/pushbutton/mainwindow.h deleted file mode 100644 index 4b203a3..0000000 --- a/qt/Buttons/pushbutton/mainwindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/Buttons/pushbutton/mainwindow.ui b/qt/Buttons/pushbutton/mainwindow.ui deleted file mode 100644 index 08a5592..0000000 --- a/qt/Buttons/pushbutton/mainwindow.ui +++ /dev/null @@ -1,54 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 667 - 412 - - - - MainWindow - - - - - - 160 - 130 - 75 - 23 - - - - PushButton - - - - - - - 0 - 0 - 667 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/Buttons/toolbutton/help.png b/qt/Buttons/toolbutton/help.png deleted file mode 100644 index e9cafa1..0000000 Binary files a/qt/Buttons/toolbutton/help.png and /dev/null differ diff --git a/qt/Buttons/toolbutton/main.cpp b/qt/Buttons/toolbutton/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/Buttons/toolbutton/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/Buttons/toolbutton/mainwindow.cpp b/qt/Buttons/toolbutton/mainwindow.cpp deleted file mode 100644 index 49d64fc..0000000 --- a/qt/Buttons/toolbutton/mainwindow.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} diff --git a/qt/Buttons/toolbutton/mainwindow.h b/qt/Buttons/toolbutton/mainwindow.h deleted file mode 100644 index 9353441..0000000 --- a/qt/Buttons/toolbutton/mainwindow.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/Buttons/toolbutton/mainwindow.ui b/qt/Buttons/toolbutton/mainwindow.ui deleted file mode 100644 index 0a4671c..0000000 --- a/qt/Buttons/toolbutton/mainwindow.ui +++ /dev/null @@ -1,140 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 581 - 345 - - - - MainWindow - - - - - - - - - - - 64 - 48 - - - - 打开 - - - - :/new/toolbutton/open.png:/new/toolbutton/open.png - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 64 - 48 - - - - 保存 - - - - :/new/toolbutton/save.png:/new/toolbutton/save.png - - - Qt::ToolButtonTextUnderIcon - - - - - - - - 64 - 48 - - - - 帮助 - - - - :/new/toolbutton/help.png:/new/toolbutton/help.png - - - Qt::ToolButtonTextUnderIcon - - - Qt::NoArrow - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 0 - 0 - 581 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/Buttons/toolbutton/open.png b/qt/Buttons/toolbutton/open.png deleted file mode 100644 index f5c64f3..0000000 Binary files a/qt/Buttons/toolbutton/open.png and /dev/null differ diff --git a/qt/Buttons/toolbutton/save.png b/qt/Buttons/toolbutton/save.png deleted file mode 100644 index 939c9f7..0000000 Binary files a/qt/Buttons/toolbutton/save.png and /dev/null differ diff --git a/qt/Buttons/toolbutton/toolbutton.pro b/qt/Buttons/toolbutton/toolbutton.pro deleted file mode 100644 index 1ef24b6..0000000 --- a/qt/Buttons/toolbutton/toolbutton.pro +++ /dev/null @@ -1,43 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-08-11T11:29:06 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = toolbutton -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - -RESOURCES += \ - toolbutton.qrc diff --git a/qt/Buttons/toolbutton/toolbutton.qrc b/qt/Buttons/toolbutton/toolbutton.qrc deleted file mode 100644 index f31fe23..0000000 --- a/qt/Buttons/toolbutton/toolbutton.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - help.png - open.png - save.png - - diff --git a/qt/Menu/Menu.sln b/qt/Menu/Menu.sln deleted file mode 100644 index 1c29159..0000000 --- a/qt/Menu/Menu.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30717.126 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Menu", "Menu\Menu.vcxproj", "{A0062BEA-A405-4122-B0A2-5928C251C661}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A0062BEA-A405-4122-B0A2-5928C251C661}.Debug|x64.ActiveCfg = Debug|x64 - {A0062BEA-A405-4122-B0A2-5928C251C661}.Debug|x64.Build.0 = Debug|x64 - {A0062BEA-A405-4122-B0A2-5928C251C661}.Release|x64.ActiveCfg = Release|x64 - {A0062BEA-A405-4122-B0A2-5928C251C661}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B1285409-4CE2-4D5A-A5CB-B272437C83A1} - EndGlobalSection -EndGlobal diff --git a/qt/Menu/Menu/Menu.cpp b/qt/Menu/Menu/Menu.cpp deleted file mode 100644 index 873230a..0000000 --- a/qt/Menu/Menu/Menu.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "Menu.h" -#include -#include "QLineEdit" -#include "QWidgetAction" - -#include "qdebug.h" -Menu::Menu(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - - menu.addSection(QIcon(":/Menu/gamer"), "Widget Menu Section"); - - menu.addAction(QIcon(":/Menu/gamer"), "Options"); - menu.addAction("Exit"); - menu.addSection("Widget Menu Section"); - - QWidgetAction* action = new QWidgetAction(&menu); - - action->setDefaultWidget(new QLineEdit()); - - - menu.addAction(action); - - - qDebug() << menu.isTearOffEnabled(); - - - if (!menu.isTearOffEnabled()) { - - menu.setTearOffEnabled(true); - - - } -} - -void Menu::contextMenuEvent(QContextMenuEvent* event) -{ - //throw std::logic_error("The method or operation is not implemented."); - - - - - - menu.exec(QCursor::pos()); -} diff --git a/qt/Menu/Menu/Menu.h b/qt/Menu/Menu/Menu.h deleted file mode 100644 index dab33d4..0000000 --- a/qt/Menu/Menu/Menu.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include -#include "ui_Menu.h" - -class Menu : public QMainWindow -{ - Q_OBJECT - -public: - Menu(QWidget *parent = Q_NULLPTR); - -private: - Ui::MenuClass ui; - -protected: - void contextMenuEvent(QContextMenuEvent* event) override; - QMenu menu; -}; diff --git a/qt/Menu/Menu/Menu.qrc b/qt/Menu/Menu/Menu.qrc deleted file mode 100644 index 7280a98..0000000 --- a/qt/Menu/Menu/Menu.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - gamer-Sticker-by-Adimanav.jpg - - diff --git a/qt/Menu/Menu/Menu.ui b/qt/Menu/Menu/Menu.ui deleted file mode 100644 index 7ecb557..0000000 --- a/qt/Menu/Menu/Menu.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - MenuClass - - - - 0 - 0 - 600 - 400 - - - - Qt::DefaultContextMenu - - - Menu - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/Menu/Menu/Menu.vcxproj b/qt/Menu/Menu/Menu.vcxproj deleted file mode 100644 index 5060c50..0000000 --- a/qt/Menu/Menu/Menu.vcxproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {A0062BEA-A405-4122-B0A2-5928C251C661} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/Menu/Menu/gamer-Sticker-by-Adimanav.jpg b/qt/Menu/Menu/gamer-Sticker-by-Adimanav.jpg deleted file mode 100644 index fde9076..0000000 Binary files a/qt/Menu/Menu/gamer-Sticker-by-Adimanav.jpg and /dev/null differ diff --git a/qt/Menu/Menu/main.cpp b/qt/Menu/Menu/main.cpp deleted file mode 100644 index cb840d1..0000000 --- a/qt/Menu/Menu/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Menu.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Menu w; - w.show(); - return a.exec(); -} diff --git a/qt/Model/stringlistmodel/.gitignore b/qt/Model/stringlistmodel/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Model/stringlistmodel/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Model/stringlistmodel/custommodel.cpp b/qt/Model/stringlistmodel/custommodel.cpp deleted file mode 100644 index a6ff77a..0000000 --- a/qt/Model/stringlistmodel/custommodel.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "custommodel.h" -#include -CustomModel::CustomModel(QObject *parent) - : QStringListModel(parent) -{ -} - -//QVariant CustomModel::headerData(int section, Qt::Orientation orientation, int role) const -//{ -// // FIXME: Implement me! -//} - -//int CustomModel::rowCount(const QModelIndex &parent) const -//{ -// // For list models only the root node (an invalid parent) should return the list's size. For all -// // other (valid) parents, rowCount() should return 0 so that it does not become a tree model. -// if (parent.isValid()) -// return 0; - -// // FIXME: Implement me! -//} - -QVariant CustomModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - static QStringList list= {":/new/prefix1/image/categories-new-white (1).png", ":/new/prefix1/image/categories-new-white (2).png", ":/new/prefix1/image/categories-new-white3.png"}; - if (role == Qt::DecorationRole){ - - QIcon icon(list[index.row()]); - - assert(!icon.isNull()); - - return icon; - } - - // FIXME: Implement me! - return QStringListModel::data(index, role); -} diff --git a/qt/Model/stringlistmodel/custommodel.h b/qt/Model/stringlistmodel/custommodel.h deleted file mode 100644 index c5fef0c..0000000 --- a/qt/Model/stringlistmodel/custommodel.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef CUSTOMMODEL_H -#define CUSTOMMODEL_H - -#include - -class CustomModel : public QStringListModel -{ - Q_OBJECT - -public: - explicit CustomModel(QObject *parent = nullptr); - - // Header: - // QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - - // Basic functionality: - //int rowCount(const QModelIndex &parent = QModelIndex()) const override; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - -private: -}; - -#endif // CUSTOMMODEL_H diff --git a/qt/Model/stringlistmodel/image.qrc b/qt/Model/stringlistmodel/image.qrc deleted file mode 100644 index 1415f0b..0000000 --- a/qt/Model/stringlistmodel/image.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - image/categories-new-white (1).png - image/categories-new-white (2).png - image/categories-new-white3.png - - diff --git a/qt/Model/stringlistmodel/image/categories-new-white (1).png b/qt/Model/stringlistmodel/image/categories-new-white (1).png deleted file mode 100644 index 74b963e..0000000 Binary files a/qt/Model/stringlistmodel/image/categories-new-white (1).png and /dev/null differ diff --git a/qt/Model/stringlistmodel/image/categories-new-white (2).png b/qt/Model/stringlistmodel/image/categories-new-white (2).png deleted file mode 100644 index bd3c3c4..0000000 Binary files a/qt/Model/stringlistmodel/image/categories-new-white (2).png and /dev/null differ diff --git a/qt/Model/stringlistmodel/image/categories-new-white3.png b/qt/Model/stringlistmodel/image/categories-new-white3.png deleted file mode 100644 index 2009cfa..0000000 Binary files a/qt/Model/stringlistmodel/image/categories-new-white3.png and /dev/null differ diff --git a/qt/Model/stringlistmodel/main.cpp b/qt/Model/stringlistmodel/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Model/stringlistmodel/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Model/stringlistmodel/mainwindow.cpp b/qt/Model/stringlistmodel/mainwindow.cpp deleted file mode 100644 index 218030a..0000000 --- a/qt/Model/stringlistmodel/mainwindow.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - list << "a" << "b" << "c"; - model.setStringList(list); - - ui->listView->setModel(&model); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/Model/stringlistmodel/mainwindow.h b/qt/Model/stringlistmodel/mainwindow.h deleted file mode 100644 index f86e4c9..0000000 --- a/qt/Model/stringlistmodel/mainwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include "custommodel.h" - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - QStringList list; - CustomModel model; -}; -#endif // MAINWINDOW_H diff --git a/qt/Model/stringlistmodel/mainwindow.ui b/qt/Model/stringlistmodel/mainwindow.ui deleted file mode 100644 index 4870603..0000000 --- a/qt/Model/stringlistmodel/mainwindow.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 200 - 250 - 256 - 192 - - - - QListView::IconMode - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/Model/stringlistmodel/stringlistmodel.pro b/qt/Model/stringlistmodel/stringlistmodel.pro deleted file mode 100644 index 23cc59c..0000000 --- a/qt/Model/stringlistmodel/stringlistmodel.pro +++ /dev/null @@ -1,36 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - custommodel.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - custommodel.h \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - -RESOURCES += \ - image.qrc diff --git a/qt/RubberBand/RubberBand.sln b/qt/RubberBand/RubberBand.sln deleted file mode 100644 index 5ff253a..0000000 --- a/qt/RubberBand/RubberBand.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RubberBand", "RubberBand\RubberBand.vcxproj", "{420CE739-47D6-4FB8-80F4-77D507CAA4C7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {420CE739-47D6-4FB8-80F4-77D507CAA4C7}.Debug|x64.ActiveCfg = Debug|x64 - {420CE739-47D6-4FB8-80F4-77D507CAA4C7}.Debug|x64.Build.0 = Debug|x64 - {420CE739-47D6-4FB8-80F4-77D507CAA4C7}.Release|x64.ActiveCfg = Release|x64 - {420CE739-47D6-4FB8-80F4-77D507CAA4C7}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7FD05E98-B153-417F-919A-F330E7D883CD} - EndGlobalSection -EndGlobal diff --git a/qt/RubberBand/RubberBand/RubberBand.cpp b/qt/RubberBand/RubberBand/RubberBand.cpp deleted file mode 100644 index 0a762c2..0000000 --- a/qt/RubberBand/RubberBand/RubberBand.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "RubberBand.h" -#include "QMouseEvent" -RubberBand::RubberBand(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - -} - -void RubberBand::mousePressEvent(QMouseEvent* event) -{ - origin_ = event->pos(); - if (!rubberBand_) - rubberBand_ = new QRubberBand(QRubberBand::Rectangle, this); - rubberBand_->setGeometry(QRect(origin_, QSize())); - rubberBand_->show(); -} - -void RubberBand::mouseReleaseEvent(QMouseEvent* event) -{ - rubberBand_->hide(); -} - -void RubberBand::mouseMoveEvent(QMouseEvent* event) -{ - rubberBand_->setGeometry(QRect(origin_, event->pos()).normalized()); -} diff --git a/qt/RubberBand/RubberBand/RubberBand.h b/qt/RubberBand/RubberBand/RubberBand.h deleted file mode 100644 index 38deae7..0000000 --- a/qt/RubberBand/RubberBand/RubberBand.h +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include -#include "ui_RubberBand.h" -#include "qrubberband.h" -class RubberBand : public QMainWindow -{ - Q_OBJECT - -public: - RubberBand(QWidget *parent = Q_NULLPTR); - -private: - Ui::RubberBandClass ui; -protected: - void mousePressEvent(QMouseEvent* event) override; - - - void mouseReleaseEvent(QMouseEvent* event) override; - - - void mouseMoveEvent(QMouseEvent* event) override; -private: - QRubberBand* rubberBand_ = nullptr; - QPoint origin_; -}; diff --git a/qt/RubberBand/RubberBand/RubberBand.qrc b/qt/RubberBand/RubberBand/RubberBand.qrc deleted file mode 100644 index 4cf07a8..0000000 --- a/qt/RubberBand/RubberBand/RubberBand.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/RubberBand/RubberBand/RubberBand.ui b/qt/RubberBand/RubberBand/RubberBand.ui deleted file mode 100644 index 602589e..0000000 --- a/qt/RubberBand/RubberBand/RubberBand.ui +++ /dev/null @@ -1,28 +0,0 @@ - - RubberBandClass - - - RubberBandClass - - - - 0 - 0 - 600 - 400 - - - - RubberBand - - - - - - - - - - - - diff --git a/qt/RubberBand/RubberBand/RubberBand.vcxproj b/qt/RubberBand/RubberBand/RubberBand.vcxproj deleted file mode 100644 index 68b72f5..0000000 --- a/qt/RubberBand/RubberBand/RubberBand.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {420CE739-47D6-4FB8-80F4-77D507CAA4C7} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/RubberBand/RubberBand/main.cpp b/qt/RubberBand/RubberBand/main.cpp deleted file mode 100644 index 08bd9dd..0000000 --- a/qt/RubberBand/RubberBand/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "RubberBand.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - RubberBand w; - w.show(); - return a.exec(); -} diff --git a/qt/SizeGrip/SizeGrip.sln b/qt/SizeGrip/SizeGrip.sln deleted file mode 100644 index ba814e8..0000000 --- a/qt/SizeGrip/SizeGrip.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SizeGrip", "SizeGrip\SizeGrip.vcxproj", "{B82B7C1E-84B7-45BC-9EAB-11D0F389F1A7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B82B7C1E-84B7-45BC-9EAB-11D0F389F1A7}.Debug|x64.ActiveCfg = Debug|x64 - {B82B7C1E-84B7-45BC-9EAB-11D0F389F1A7}.Debug|x64.Build.0 = Debug|x64 - {B82B7C1E-84B7-45BC-9EAB-11D0F389F1A7}.Release|x64.ActiveCfg = Release|x64 - {B82B7C1E-84B7-45BC-9EAB-11D0F389F1A7}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {272AFA59-8B6B-4282-9ACB-BA2EFF0B9C12} - EndGlobalSection -EndGlobal diff --git a/qt/SizeGrip/SizeGrip/SizeGrip.cpp b/qt/SizeGrip/SizeGrip/SizeGrip.cpp deleted file mode 100644 index d851ec1..0000000 --- a/qt/SizeGrip/SizeGrip/SizeGrip.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "SizeGrip.h" - -SizeGrip::SizeGrip(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); -} diff --git a/qt/SizeGrip/SizeGrip/SizeGrip.h b/qt/SizeGrip/SizeGrip/SizeGrip.h deleted file mode 100644 index b8496cc..0000000 --- a/qt/SizeGrip/SizeGrip/SizeGrip.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_SizeGrip.h" - -class SizeGrip : public QMainWindow -{ - Q_OBJECT - -public: - SizeGrip(QWidget *parent = Q_NULLPTR); - -private: - Ui::SizeGripClass ui; -}; diff --git a/qt/SizeGrip/SizeGrip/SizeGrip.qrc b/qt/SizeGrip/SizeGrip/SizeGrip.qrc deleted file mode 100644 index a9de2c9..0000000 --- a/qt/SizeGrip/SizeGrip/SizeGrip.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/SizeGrip/SizeGrip/SizeGrip.ui b/qt/SizeGrip/SizeGrip/SizeGrip.ui deleted file mode 100644 index f227b0b..0000000 --- a/qt/SizeGrip/SizeGrip/SizeGrip.ui +++ /dev/null @@ -1,28 +0,0 @@ - - SizeGripClass - - - SizeGripClass - - - - 0 - 0 - 600 - 400 - - - - SizeGrip - - - - - - - - - - - - diff --git a/qt/SizeGrip/SizeGrip/SizeGrip.vcxproj b/qt/SizeGrip/SizeGrip/SizeGrip.vcxproj deleted file mode 100644 index 8ee4fe7..0000000 --- a/qt/SizeGrip/SizeGrip/SizeGrip.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {B82B7C1E-84B7-45BC-9EAB-11D0F389F1A7} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/SizeGrip/SizeGrip/main.cpp b/qt/SizeGrip/SizeGrip/main.cpp deleted file mode 100644 index ef8cb5d..0000000 --- a/qt/SizeGrip/SizeGrip/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "SizeGrip.h" -#include -#include "QSizeGrip" -#include "QVBoxLayout" -#include "qevent.h" -class MySizeGrip : public QWidget{ -public: - MySizeGrip():QWidget(nullptr, Qt::FramelessWindowHint){ - - - setLayout(new QVBoxLayout); - sizegrip = new QSizeGrip(this); - - layout()->addWidget(sizegrip); - - } - - QSizeGrip* sizegrip; - - bool isPressed = false; - QPointF orgin; - QPoint windowPos; -protected: - void mousePressEvent(QMouseEvent* event) override - { - isPressed = true; - orgin = event->screenPos(); - windowPos = pos(); - } - - - void mouseMoveEvent(QMouseEvent* event) override - { - if (isPressed) { - // setGeometry(QRect{ QPoint((windowPos + event->screenPos() - orgin).toPoint()), geometry().size() }); - move((windowPos + event->screenPos() - orgin).toPoint()); - } - - } - - - void mouseReleaseEvent(QMouseEvent* event) override - { - isPressed = false; - } - -}; - - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - // SizeGrip w; - // w.show(); - - MySizeGrip sizegrip; - sizegrip.resize(300, 300); - sizegrip.show(); - - return a.exec(); -} diff --git a/qt/TrayIcon/TrayIcon.sln b/qt/TrayIcon/TrayIcon.sln deleted file mode 100644 index a3b2461..0000000 --- a/qt/TrayIcon/TrayIcon.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30717.126 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrayIcon", "TrayIcon\TrayIcon.vcxproj", "{688C51E3-3128-41C8-AE62-762FFCE9903D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {688C51E3-3128-41C8-AE62-762FFCE9903D}.Debug|x64.ActiveCfg = Debug|x64 - {688C51E3-3128-41C8-AE62-762FFCE9903D}.Debug|x64.Build.0 = Debug|x64 - {688C51E3-3128-41C8-AE62-762FFCE9903D}.Release|x64.ActiveCfg = Release|x64 - {688C51E3-3128-41C8-AE62-762FFCE9903D}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {938E6080-E53C-4EC8-A04E-E442AD4C70A6} - EndGlobalSection -EndGlobal diff --git a/qt/TrayIcon/TrayIcon/4804802-gamer-png-download-512512-free-transparent-joystick-png-download-gamer-png-900_520.png b/qt/TrayIcon/TrayIcon/4804802-gamer-png-download-512512-free-transparent-joystick-png-download-gamer-png-900_520.png deleted file mode 100644 index f8a13eb..0000000 Binary files a/qt/TrayIcon/TrayIcon/4804802-gamer-png-download-512512-free-transparent-joystick-png-download-gamer-png-900_520.png and /dev/null differ diff --git a/qt/TrayIcon/TrayIcon/TrayIcon.cpp b/qt/TrayIcon/TrayIcon/TrayIcon.cpp deleted file mode 100644 index d1c3226..0000000 --- a/qt/TrayIcon/TrayIcon/TrayIcon.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "TrayIcon.h" -#include "QApplication" -TrayIcon::TrayIcon(QWidget* parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - trayIcon.setToolTip("this is tray icon demo"); - - trayIcon.setIcon(QIcon(":/TrayIcon/icon")); - - - // trayIcon.setVisible(true); - - menu.addAction("Exit", [](...) { - QApplication::quit(); - }); - - //trayIcon.setContextMenu(&menu); - - connect(&trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) { - - if (reason == QSystemTrayIcon::DoubleClick) - this->showNormal(); - else if (reason == QSystemTrayIcon::Context) { - // TODO: - - menu.popup(QCursor::pos()); - } - }); - - trayIcon.show(); -} diff --git a/qt/TrayIcon/TrayIcon/TrayIcon.h b/qt/TrayIcon/TrayIcon/TrayIcon.h deleted file mode 100644 index 0d7bd87..0000000 --- a/qt/TrayIcon/TrayIcon/TrayIcon.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include "ui_TrayIcon.h" -#include "QSystemTrayIcon" -#include "qmenu.h" -class TrayIcon : public QMainWindow -{ - Q_OBJECT - -public: - TrayIcon(QWidget *parent = Q_NULLPTR); - -private: - Ui::TrayIconClass ui; - - - QSystemTrayIcon trayIcon; - QMenu menu; -}; diff --git a/qt/TrayIcon/TrayIcon/TrayIcon.qrc b/qt/TrayIcon/TrayIcon/TrayIcon.qrc deleted file mode 100644 index 63e365d..0000000 --- a/qt/TrayIcon/TrayIcon/TrayIcon.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - 4804802-gamer-png-download-512512-free-transparent-joystick-png-download-gamer-png-900_520.png - - diff --git a/qt/TrayIcon/TrayIcon/TrayIcon.ui b/qt/TrayIcon/TrayIcon/TrayIcon.ui deleted file mode 100644 index 07c190b..0000000 --- a/qt/TrayIcon/TrayIcon/TrayIcon.ui +++ /dev/null @@ -1,28 +0,0 @@ - - TrayIconClass - - - TrayIconClass - - - - 0 - 0 - 600 - 400 - - - - TrayIcon - - - - - - - - - - - - diff --git a/qt/TrayIcon/TrayIcon/TrayIcon.vcxproj b/qt/TrayIcon/TrayIcon/TrayIcon.vcxproj deleted file mode 100644 index 5f11f76..0000000 --- a/qt/TrayIcon/TrayIcon/TrayIcon.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {688C51E3-3128-41C8-AE62-762FFCE9903D} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/TrayIcon/TrayIcon/main.cpp b/qt/TrayIcon/TrayIcon/main.cpp deleted file mode 100644 index 3d2fe1d..0000000 --- a/qt/TrayIcon/TrayIcon/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "TrayIcon.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - TrayIcon w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/ColumnView/.gitignore b/qt/Views/ColumnView/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/ColumnView/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/ColumnView/Column.pro b/qt/Views/ColumnView/Column.pro deleted file mode 100644 index b057983..0000000 --- a/qt/Views/ColumnView/Column.pro +++ /dev/null @@ -1,33 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - columnview.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - columnview.h \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Views/ColumnView/columnview.cpp b/qt/Views/ColumnView/columnview.cpp deleted file mode 100644 index dd9abc2..0000000 --- a/qt/Views/ColumnView/columnview.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "columnview.h" -#include - -ColumnView::ColumnView(QWidget *parent) : QColumnView(parent) -{ - -} - -QAbstractItemView *ColumnView::createColumn(const QModelIndex &rootIndex) -{ - qDebug() <<"col" << rootIndex.column(); - -// if (rootIndex.column() == 0) -// return nullptr; - - return QColumnView::createColumn(rootIndex); -} diff --git a/qt/Views/ColumnView/columnview.h b/qt/Views/ColumnView/columnview.h deleted file mode 100644 index 55cc8ee..0000000 --- a/qt/Views/ColumnView/columnview.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef COLUMNVIEW_H -#define COLUMNVIEW_H - -#include - -class ColumnView : public QColumnView -{ - Q_OBJECT -public: - explicit ColumnView(QWidget *parent = nullptr); - -signals: - -public slots: - - // QColumnView interface -protected: - QAbstractItemView *createColumn(const QModelIndex &rootIndex); -}; - -#endif // COLUMNVIEW_H diff --git a/qt/Views/ColumnView/main.cpp b/qt/Views/ColumnView/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/ColumnView/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/ColumnView/mainwindow.cpp b/qt/Views/ColumnView/mainwindow.cpp deleted file mode 100644 index c4af3a2..0000000 --- a/qt/Views/ColumnView/mainwindow.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - ui->columnView->setColumnWidths({80, 120, -1}); - for(auto i = 0; i < 5; i++){ - auto group = new QStandardItem(QString("%1").arg(i)); - - for( auto ii = 0; ii < 10; ii++){ - - group->appendRow(new QStandardItem(QString("%1").arg(ii))); - - } - - model_.appendRow(group); - } - - - ui->columnView->setModel(&model_); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/Views/ColumnView/mainwindow.h b/qt/Views/ColumnView/mainwindow.h deleted file mode 100644 index 84df342..0000000 --- a/qt/Views/ColumnView/mainwindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - - - QStandardItemModel model_; -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/ColumnView/mainwindow.ui b/qt/Views/ColumnView/mainwindow.ui deleted file mode 100644 index d407300..0000000 --- a/qt/Views/ColumnView/mainwindow.ui +++ /dev/null @@ -1,48 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 499 - 383 - - - - MainWindow - - - - - - - false - - - - - - - - - 0 - 0 - 499 - 23 - - - - - - - - ColumnView - QColumnView -
columnview.h
-
-
- - -
diff --git a/qt/Views/ListView/.gitignore b/qt/Views/ListView/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/ListView/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/ListView/ListView.pro b/qt/Views/ListView/ListView.pro deleted file mode 100644 index b7b976e..0000000 --- a/qt/Views/ListView/ListView.pro +++ /dev/null @@ -1,36 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - custommodel.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - custommodel.h \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - -DISTFILES += \ - custommodule.qmodel diff --git a/qt/Views/ListView/custommodel.cpp b/qt/Views/ListView/custommodel.cpp deleted file mode 100644 index 1dc2caf..0000000 --- a/qt/Views/ListView/custommodel.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "custommodel.h" -#include - -CustomModel::CustomModel(QObject *parent) - : QAbstractItemModel(parent) -{ - modelData_.push_back(QStringLiteral("湖北省")); - modelData_.push_back(QStringLiteral("浙江省")); - modelData_.push_back(QStringLiteral("河南省")); - modelData_.push_back(QStringLiteral("四川省")); -} - -QVariant CustomModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - qDebug()<< "header"; - return QStringLiteral("省份"); -} - -bool CustomModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) -{ - if (value != headerData(section, orientation, role)) { - // FIXME: Implement me! - emit headerDataChanged(orientation, section, section); - return true; - } - return false; -} - -QModelIndex CustomModel::index(int row, int column, const QModelIndex &parent) const -{ - return createIndex(row, column); -} - -QModelIndex CustomModel::parent(const QModelIndex &index) const -{ - return QModelIndex(); -} - -int CustomModel::rowCount(const QModelIndex &parent) const -{ -// if (!parent.isValid()) -// return 0; - - - qDebug() << "row count:" << modelData_.size(); - return modelData_.size(); -} - -int CustomModel::columnCount(const QModelIndex &parent) const -{ -// if (!parent.isValid()) -// return 0; - - return 1; -} - -QVariant CustomModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role == Qt::DisplayRole || role== Qt::EditRole){ - - return modelData_[index.row()]; - } - return QVariant(); -} - -bool CustomModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (data(index, role) != value) { - if (role == Qt::EditRole){ - qDebug() << "set"; - modelData_[index.row()] = value.toString(); - } - emit dataChanged(index, index, QVector() << role); - return true; - } - return false; -} - -Qt::ItemFlags CustomModel::flags(const QModelIndex &index) const -{ -// if (!index.isValid()) -// return Qt::NoItemFlags; - - return Qt::ItemIsEditable |Qt::ItemIsEnabled; -} diff --git a/qt/Views/ListView/custommodel.h b/qt/Views/ListView/custommodel.h deleted file mode 100644 index 82c8f54..0000000 --- a/qt/Views/ListView/custommodel.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef CUSTOMMODEL_H -#define CUSTOMMODEL_H - -#include - -class CustomModel : public QAbstractItemModel -{ - Q_OBJECT - -public: - explicit CustomModel(QObject *parent = nullptr); - - // Header: - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - - bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole) override; - - // Basic functionality: - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const override; - QModelIndex parent(const QModelIndex &index) const override; - - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - // Editable: - bool setData(const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole) override; - - Qt::ItemFlags flags(const QModelIndex& index) const override; - -private: - QVector modelData_; -}; - -#endif // CUSTOMMODEL_H diff --git a/qt/Views/ListView/custommodule.qmodel b/qt/Views/ListView/custommodule.qmodel deleted file mode 100644 index ffc42a0..0000000 --- a/qt/Views/ListView/custommodule.qmodel +++ /dev/null @@ -1,78 +0,0 @@ - - - - {be942099-ab1e-4143-8469-8d77fe767c94} - - - - - - - - {56adfebd-dd43-41d3-a107-8bcb6a43ca07} - - - CustomModule - - - - - - - {23826a45-dcea-46bb-9f4e-b05ae0c259c7} - - - - - - - - - - {23826a45-dcea-46bb-9f4e-b05ae0c259c7} - - - CustomModule - - - 1573267977189 - Classes - - - - - - - - - - {9c3903ae-137c-4d5c-8621-d1986f05fcce} - - - - - - - - {9c3903ae-137c-4d5c-8621-d1986f05fcce} - - - New Package - - - - - - - - - - - - - - - - - - diff --git a/qt/Views/ListView/main.cpp b/qt/Views/ListView/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/ListView/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/ListView/mainwindow.cpp b/qt/Views/ListView/mainwindow.cpp deleted file mode 100644 index 1cab1ea..0000000 --- a/qt/Views/ListView/mainwindow.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - ui->listView->setModel(&customModel_); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/Views/ListView/mainwindow.h b/qt/Views/ListView/mainwindow.h deleted file mode 100644 index 877063f..0000000 --- a/qt/Views/ListView/mainwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include "custommodel.h" - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - - CustomModel customModel_; - -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/ListView/mainwindow.ui b/qt/Views/ListView/mainwindow.ui deleted file mode 100644 index 73443e5..0000000 --- a/qt/Views/ListView/mainwindow.ui +++ /dev/null @@ -1,42 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 410 - 463 - - - - MainWindow - - - - - - 10 - 10 - 321 - 341 - - - - - - - - 0 - 0 - 410 - 23 - - - - - - - - diff --git a/qt/Views/TableView/.gitignore b/qt/Views/TableView/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/TableView/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/TableView/TableView.pro b/qt/Views/TableView/TableView.pro deleted file mode 100644 index c37cfe6..0000000 --- a/qt/Views/TableView/TableView.pro +++ /dev/null @@ -1,33 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - customtablemodel.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - customtablemodel.h \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Views/TableView/customtablemodel.cpp b/qt/Views/TableView/customtablemodel.cpp deleted file mode 100644 index e90534a..0000000 --- a/qt/Views/TableView/customtablemodel.cpp +++ /dev/null @@ -1,62 +0,0 @@ -#include "customtablemodel.h" - -const int COLUMN_COUNT = 3; -const int ROW_COUNT= 10; - -CustomTableModel::CustomTableModel(QObject *parent) - : QAbstractTableModel(parent) -{ - for(auto i = 0; i < ROW_COUNT; i++) { - QString prifix =QString("%1").arg(i); - int suffix = 1; - - datas.push_back({prifix+ QString("-%1").arg(suffix++), prifix+ QString("-%1").arg(suffix++), prifix+ QString("-%1").arg(suffix++)}); - } - -} - -QVariant CustomTableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - static QList headers = {"first", " second", "third"}; - if (orientation == Qt::Vertical) - { - if (role == Qt::DisplayRole){ - return QVariant(QString("%1").arg(section) ); - } - } else{ - if (role == Qt::DisplayRole){ - return headers[section]; - } - } - return QVariant(); -} - -int CustomTableModel::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return ROW_COUNT; -} - -int CustomTableModel::columnCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return COLUMN_COUNT; -} - -QVariant CustomTableModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (role == Qt::DisplayRole){ - auto row = index.row(); - auto col = index.column(); - - return datas[row][col]; - } - return QVariant(); -} diff --git a/qt/Views/TableView/customtablemodel.h b/qt/Views/TableView/customtablemodel.h deleted file mode 100644 index cdd406b..0000000 --- a/qt/Views/TableView/customtablemodel.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef CUSTOMABSTRACTMODEL_H -#define CUSTOMABSTRACTMODEL_H - -#include - -class CustomTableModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - explicit CustomTableModel(QObject *parent = nullptr); - - // Header: - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - - // Basic functionality: - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - -private: - - QList> datas; -}; - -#endif // CUSTOMABSTRACTMODEL_H diff --git a/qt/Views/TableView/main.cpp b/qt/Views/TableView/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/TableView/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/TableView/mainwindow.cpp b/qt/Views/TableView/mainwindow.cpp deleted file mode 100644 index 64b0bfa..0000000 --- a/qt/Views/TableView/mainwindow.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - ui->tableView->setModel(&model); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/Views/TableView/mainwindow.h b/qt/Views/TableView/mainwindow.h deleted file mode 100644 index dc5896a..0000000 --- a/qt/Views/TableView/mainwindow.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - -CustomTableModel model; -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/TableView/mainwindow.ui b/qt/Views/TableView/mainwindow.ui deleted file mode 100644 index a3ba448..0000000 --- a/qt/Views/TableView/mainwindow.ui +++ /dev/null @@ -1,37 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/Views/TreeView/.gitignore b/qt/Views/TreeView/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/TreeView/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/TreeView/TreeView.pro b/qt/Views/TreeView/TreeView.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/Views/TreeView/TreeView.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Views/TreeView/main.cpp b/qt/Views/TreeView/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/TreeView/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/TreeView/mainwindow.cpp b/qt/Views/TreeView/mainwindow.cpp deleted file mode 100644 index 84f9a9e..0000000 --- a/qt/Views/TreeView/mainwindow.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - QList list; - - auto item = new QStandardItem("浙江省"); - - - auto hz = new QStandardItem("杭州"); - - hz->appendRow(new QStandardItem("西湖区")); - hz->appendRow(new QStandardItem("上城区")); - item->appendRow(hz); - - - - - item->appendRow(new QStandardItem("金华")); - item->appendRow(new QStandardItem("衢州")); - - - list.push_back(item); - - model.appendRow(list); - - - ui->treeView->setModel(&model); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/Views/TreeView/mainwindow.h b/qt/Views/TreeView/mainwindow.h deleted file mode 100644 index 1d4ab53..0000000 --- a/qt/Views/TreeView/mainwindow.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include - - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - - QStandardItemModel model; - -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/TreeView/mainwindow.ui b/qt/Views/TreeView/mainwindow.ui deleted file mode 100644 index 0404bf4..0000000 --- a/qt/Views/TreeView/mainwindow.ui +++ /dev/null @@ -1,45 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 290 - 230 - 256 - 192 - - - - false - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/Views/TreeWidget/.gitignore b/qt/Views/TreeWidget/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/TreeWidget/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/TreeWidget/TreeWidget.pro b/qt/Views/TreeWidget/TreeWidget.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/Views/TreeWidget/TreeWidget.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Views/TreeWidget/main.cpp b/qt/Views/TreeWidget/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/TreeWidget/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/TreeWidget/mainwindow.cpp b/qt/Views/TreeWidget/mainwindow.cpp deleted file mode 100644 index 68b084b..0000000 --- a/qt/Views/TreeWidget/mainwindow.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - auto * p1 = new QTreeWidgetItem({"a", "b", "c"}); - - - p1->addChild(new QTreeWidgetItem({"a"})); - - - ui->treeWidget->addTopLevelItems({ p1, new QTreeWidgetItem({"a", "b", "c"})}); - - auto * item = ui->treeWidget->topLevelItem(ui->treeWidget->topLevelItemCount() - 1); - - auto *child = new QTreeWidgetItem(); - child->setText(0, "child"); - item->addChild(child); - - ui->treeWidget->expandAll(); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/Views/TreeWidget/mainwindow.h b/qt/Views/TreeWidget/mainwindow.h deleted file mode 100644 index 4643e32..0000000 --- a/qt/Views/TreeWidget/mainwindow.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/TreeWidget/mainwindow.ui b/qt/Views/TreeWidget/mainwindow.ui deleted file mode 100644 index d76ef7f..0000000 --- a/qt/Views/TreeWidget/mainwindow.ui +++ /dev/null @@ -1,98 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - - 1 - - - - - 2 - - - - - 3 - - - - - 新建项目 - - - - - - - - - - - a - - - Unchecked - - - aa - - - bbb - - - - - b - - - - - 新建项目 - - - - 新建子项目 - - - - 新建子项目 - - - - - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/Views/UndoView/.gitignore b/qt/Views/UndoView/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/UndoView/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/UndoView/UndoView.pro b/qt/Views/UndoView/UndoView.pro deleted file mode 100644 index daf3d5d..0000000 --- a/qt/Views/UndoView/UndoView.pro +++ /dev/null @@ -1,33 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - appendtext.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - appendtext.h \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Views/UndoView/appendtext.cpp b/qt/Views/UndoView/appendtext.cpp deleted file mode 100644 index a8970cb..0000000 --- a/qt/Views/UndoView/appendtext.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "appendtext.h" - - -AppendText::AppendText(QLabel *doc, QString txt) - : label(doc), text(txt) -{ - - setText("Apend Text"); -} - -void AppendText::undo() -{ - QString s = label->text(); - s.chop(text.length()); - - label->setText(s); -} - -void AppendText::redo() -{ - label->setText(label->text()+ text); -} diff --git a/qt/Views/UndoView/appendtext.h b/qt/Views/UndoView/appendtext.h deleted file mode 100644 index a31b773..0000000 --- a/qt/Views/UndoView/appendtext.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef APPENDTEXT_H -#define APPENDTEXT_H - -#include -#include -class AppendText : public QUndoCommand -{ -public: - AppendText(QLabel *doc, QString txt); - - - -private: - QLabel* label; - QString text; - - // QUndoCommand interface -public: - void undo(); - void redo(); -}; - -#endif // APPENDTEXT_H diff --git a/qt/Views/UndoView/main.cpp b/qt/Views/UndoView/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/UndoView/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/UndoView/mainwindow.cpp b/qt/Views/UndoView/mainwindow.cpp deleted file mode 100644 index bc12abb..0000000 --- a/qt/Views/UndoView/mainwindow.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include "appendtext.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - ui->undoView->setStack(&stack); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_pushButton_clicked() -{ - stack.push(new AppendText(ui->label, ui->lineEdit->text())); -} - -void MainWindow::on_pushButton_2_clicked() -{ - stack.redo(); -} - -void MainWindow::on_pushButton_3_clicked() -{ - stack.undo(); -} diff --git a/qt/Views/UndoView/mainwindow.h b/qt/Views/UndoView/mainwindow.h deleted file mode 100644 index eff3da6..0000000 --- a/qt/Views/UndoView/mainwindow.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - - void on_pushButton_2_clicked(); - - void on_pushButton_3_clicked(); - -private: - Ui::MainWindow *ui; - - QUndoStack stack; - -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/UndoView/mainwindow.ui b/qt/Views/UndoView/mainwindow.ui deleted file mode 100644 index 7166aba..0000000 --- a/qt/Views/UndoView/mainwindow.ui +++ /dev/null @@ -1,104 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 580 - 110 - 151 - 281 - - - - - - - 190 - 190 - 113 - 20 - - - - - - - 110 - 460 - 551 - 21 - - - - TextLabel - - - - - - 330 - 190 - 75 - 23 - - - - add - - - - - - 170 - 70 - 75 - 23 - - - - redo - - - - - - 320 - 70 - 75 - 23 - - - - undo - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/Views/listwidget/.gitignore b/qt/Views/listwidget/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/listwidget/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/listwidget/dialog.cpp b/qt/Views/listwidget/dialog.cpp deleted file mode 100644 index 58c3e72..0000000 --- a/qt/Views/listwidget/dialog.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "dialog.h" -#include "ui_dialog.h" - -Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) -{ - ui->setupUi(this); -} - -Dialog::~Dialog() -{ - delete ui; -} diff --git a/qt/Views/listwidget/dialog.h b/qt/Views/listwidget/dialog.h deleted file mode 100644 index 17537d1..0000000 --- a/qt/Views/listwidget/dialog.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DIALOG_H -#define DIALOG_H - -#include - -namespace Ui { -class Dialog; -} - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = nullptr); - ~Dialog(); - -private: - Ui::Dialog *ui; -}; - -#endif // DIALOG_H diff --git a/qt/Views/listwidget/dialog.ui b/qt/Views/listwidget/dialog.ui deleted file mode 100644 index 685874d..0000000 --- a/qt/Views/listwidget/dialog.ui +++ /dev/null @@ -1,71 +0,0 @@ - - - - - Dialog - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - 30 - 240 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/qt/Views/listwidget/listwidget.pro b/qt/Views/listwidget/listwidget.pro deleted file mode 100644 index 45f245c..0000000 --- a/qt/Views/listwidget/listwidget.pro +++ /dev/null @@ -1,34 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - dialog.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - dialog.h \ - mainwindow.h - -FORMS += \ - dialog.ui \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/Views/listwidget/main.cpp b/qt/Views/listwidget/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/listwidget/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/listwidget/mainwindow.cpp b/qt/Views/listwidget/mainwindow.cpp deleted file mode 100644 index 1a77a4c..0000000 --- a/qt/Views/listwidget/mainwindow.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include "dialog.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - ui->listWidget->addItem(new QListWidgetItem("广东省")); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_listWidget_itemClicked(QListWidgetItem *item) -{ - - Dialog dlg; - dlg.setWindowTitle(item->text()); - dlg.exec(); -} - -void MainWindow::on_pushButton_clicked() -{ - - auto* item = ui->listWidget->currentItem(); - - ui->listWidget->removeItemWidget(item); - delete item; - // delete item; - // auto * item = ui->listWidget->takeItem(ui->listWidget->currentRow()); - - // delete item; -} diff --git a/qt/Views/listwidget/mainwindow.h b/qt/Views/listwidget/mainwindow.h deleted file mode 100644 index a22a9db..0000000 --- a/qt/Views/listwidget/mainwindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_listWidget_itemClicked(QListWidgetItem *item); - - void on_pushButton_clicked(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/listwidget/mainwindow.ui b/qt/Views/listwidget/mainwindow.ui deleted file mode 100644 index ef087be..0000000 --- a/qt/Views/listwidget/mainwindow.ui +++ /dev/null @@ -1,66 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - - 浙江省 - - - - - 河北省 - - - - - 山西省 - - - Checked - - - ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled - - - - - - - - PushButton - - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/Views/tablewidget/.gitignore b/qt/Views/tablewidget/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/Views/tablewidget/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/Views/tablewidget/main.cpp b/qt/Views/tablewidget/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/Views/tablewidget/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/Views/tablewidget/mainwindow.cpp b/qt/Views/tablewidget/mainwindow.cpp deleted file mode 100644 index 1c2ef1b..0000000 --- a/qt/Views/tablewidget/mainwindow.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - ui->tableWidget->item(0, 0)->setText("a"); - - - ui->tableWidget->setCellWidget(0, 1, new QPushButton("button")); - assert(ui->tableWidget->cellWidget(0,1)); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_tableWidget_itemDoubleClicked(QTableWidgetItem *item) -{ - qDebug() << "#" << "this is double clicked"; -} diff --git a/qt/Views/tablewidget/mainwindow.h b/qt/Views/tablewidget/mainwindow.h deleted file mode 100644 index 6035764..0000000 --- a/qt/Views/tablewidget/mainwindow.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_tableWidget_itemDoubleClicked(QTableWidgetItem *item); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/Views/tablewidget/mainwindow.ui b/qt/Views/tablewidget/mainwindow.ui deleted file mode 100644 index 255ccad..0000000 --- a/qt/Views/tablewidget/mainwindow.ui +++ /dev/null @@ -1,93 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 897 - 607 - - - - MainWindow - - - - - - - - 新建行 - - - - - 新建行 - - - - - 新建行 - - - - - 新建列 - - - - - 新建列 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 897 - 23 - - - - - - - - diff --git a/qt/Views/tablewidget/tablewidget.pro b/qt/Views/tablewidget/tablewidget.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/Views/tablewidget/tablewidget.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/activex/.gitignore b/qt/containers/activex/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/containers/activex/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/containers/activex/activex.pro b/qt/containers/activex/activex.pro deleted file mode 100644 index c3cff25..0000000 --- a/qt/containers/activex/activex.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets axcontainer - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/activex/main.cpp b/qt/containers/activex/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/containers/activex/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/containers/activex/mainwindow.cpp b/qt/containers/activex/mainwindow.cpp deleted file mode 100644 index 42eb6af..0000000 --- a/qt/containers/activex/mainwindow.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_pushButton_clicked() -{ - ui->axWidget->dynamicCall(qPrintable( QString("Navigate(\"%1\")").arg(ui->lineEdit->text()))); -} - -void MainWindow::on_pushButton_2_clicked() -{ - ui->axWidget->dynamicCall("GoBack()"); -} diff --git a/qt/containers/activex/mainwindow.h b/qt/containers/activex/mainwindow.h deleted file mode 100644 index 684490b..0000000 --- a/qt/containers/activex/mainwindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - - void on_pushButton_2_clicked(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/containers/activex/mainwindow.ui b/qt/containers/activex/mainwindow.ui deleted file mode 100644 index 47e9e7e..0000000 --- a/qt/containers/activex/mainwindow.ui +++ /dev/null @@ -1,78 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - - - - - - Back - - - - - - - Go - - - - - - - - - {8856f961-340a-11d0-a96b-00c04fd705a2} - - - true - - - - 0 - 0 - - - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - QAxWidget - QWidget -
qaxwidget.h
-
-
- - -
diff --git a/qt/containers/dockwidget/.gitignore b/qt/containers/dockwidget/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/containers/dockwidget/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/containers/dockwidget/dockwidget.pro b/qt/containers/dockwidget/dockwidget.pro deleted file mode 100644 index a341454..0000000 --- a/qt/containers/dockwidget/dockwidget.pro +++ /dev/null @@ -1,34 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - form.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - form.h \ - mainwindow.h - -FORMS += \ - form.ui \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/dockwidget/form.cpp b/qt/containers/dockwidget/form.cpp deleted file mode 100644 index 88e77d2..0000000 --- a/qt/containers/dockwidget/form.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "form.h" -#include "ui_form.h" - -Form::Form(QWidget *parent) : - QWidget(parent), - ui(new Ui::Form) -{ - ui->setupUi(this); -} - -Form::~Form() -{ - delete ui; -} - -void Form::on_pushButton_clicked() -{ - emit closeClicked(); -} diff --git a/qt/containers/dockwidget/form.h b/qt/containers/dockwidget/form.h deleted file mode 100644 index b737371..0000000 --- a/qt/containers/dockwidget/form.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef FORM_H -#define FORM_H - -#include - -namespace Ui { -class Form; -} - -class Form : public QWidget -{ - Q_OBJECT - -public: - explicit Form(QWidget *parent = nullptr); - ~Form(); - -signals: - void closeClicked(); -private slots: - void on_pushButton_clicked(); - -private: - Ui::Form *ui; -}; - -#endif // FORM_H diff --git a/qt/containers/dockwidget/form.ui b/qt/containers/dockwidget/form.ui deleted file mode 100644 index 8781586..0000000 --- a/qt/containers/dockwidget/form.ui +++ /dev/null @@ -1,38 +0,0 @@ - - - Form - - - - 0 - 0 - 400 - 300 - - - - Form - - - - - - search - - - - - - - - - - close - - - - - - - - diff --git a/qt/containers/dockwidget/main.cpp b/qt/containers/dockwidget/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/containers/dockwidget/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/containers/dockwidget/mainwindow.cpp b/qt/containers/dockwidget/mainwindow.cpp deleted file mode 100644 index 9c6b822..0000000 --- a/qt/containers/dockwidget/mainwindow.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include -#include -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - qDebug() <<"text:" << ui->dockWidget->toggleViewAction()->text(); - - auto * form = new Form; - connect(form, &Form::closeClicked, [this](){ - ui->dockWidget->hide(); - }); - ui->dockWidget->setTitleBarWidget(form); - ui->dockWidget_2->toggleViewAction()->setToolTip("tip"); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_pushButton_clicked() - { - ui->dockWidget->toggleViewAction()->setText("abc"); - qDebug() <<"text:" << ui->dockWidget->toggleViewAction()->text(); - - - - ui->dockWidget->setWindowTitle("abc"); - - ui->dockWidget->show(); - - ui->dockWidget_2->toggleViewAction()->trigger(); - - -} diff --git a/qt/containers/dockwidget/mainwindow.h b/qt/containers/dockwidget/mainwindow.h deleted file mode 100644 index 9fb63ce..0000000 --- a/qt/containers/dockwidget/mainwindow.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/containers/dockwidget/mainwindow.ui b/qt/containers/dockwidget/mainwindow.ui deleted file mode 100644 index 16acad6..0000000 --- a/qt/containers/dockwidget/mainwindow.ui +++ /dev/null @@ -1,81 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 120 - 180 - 75 - 23 - - - - PushButton - - - - - - - 0 - 0 - 800 - 23 - - - - - - - false - - - QDockWidget::AllDockWidgetFeatures - - - title - - - 1 - - - - - - - - - - - - QDockWidget::AllDockWidgetFeatures - - - 2 - - - - - - - - - - - - - diff --git a/qt/containers/frame/frame.pro b/qt/containers/frame/frame.pro deleted file mode 100644 index 2206f00..0000000 --- a/qt/containers/frame/frame.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-03-27T19:26:46 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = frame -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/frame/main.cpp b/qt/containers/frame/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/containers/frame/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/containers/frame/mainwindow.cpp b/qt/containers/frame/mainwindow.cpp deleted file mode 100644 index 5f7224b..0000000 --- a/qt/containers/frame/mainwindow.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - ui->frame->setFrameRect({0, 0, 50,50}); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_pushButton_clicked() -{ - qDebug() << ui->frame->frameRect() << " : " << ui->frame->rect(); -} diff --git a/qt/containers/frame/mainwindow.h b/qt/containers/frame/mainwindow.h deleted file mode 100644 index 0699275..0000000 --- a/qt/containers/frame/mainwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/containers/frame/mainwindow.ui b/qt/containers/frame/mainwindow.ui deleted file mode 100644 index ef75ffd..0000000 --- a/qt/containers/frame/mainwindow.ui +++ /dev/null @@ -1,76 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 400 - 300 - - - - MainWindow - - - - - - 203 - 9 - 188 - 225 - - - - QFrame::Panel - - - QFrame::Raised - - - 6 - - - 9 - - - - - - 9 - 110 - 75 - 23 - - - - PushButton - - - - - - - 0 - 0 - 400 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/containers/groupbox/.gitignore b/qt/containers/groupbox/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/containers/groupbox/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/containers/groupbox/groupbox.pro b/qt/containers/groupbox/groupbox.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/containers/groupbox/groupbox.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/groupbox/main.cpp b/qt/containers/groupbox/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/containers/groupbox/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/containers/groupbox/mainwindow.cpp b/qt/containers/groupbox/mainwindow.cpp deleted file mode 100644 index b028d91..0000000 --- a/qt/containers/groupbox/mainwindow.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_groupBox_toggled(bool arg1) -{ - qDebug() << "toggle" << arg1; -} - -void MainWindow::on_groupBox_clicked(bool checked) -{ - qDebug() << "clicked:" << checked; -} diff --git a/qt/containers/groupbox/mainwindow.h b/qt/containers/groupbox/mainwindow.h deleted file mode 100644 index 302db8c..0000000 --- a/qt/containers/groupbox/mainwindow.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_groupBox_toggled(bool arg1); - - void on_groupBox_clicked(bool checked); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/containers/groupbox/mainwindow.ui b/qt/containers/groupbox/mainwindow.ui deleted file mode 100644 index 70aab4c..0000000 --- a/qt/containers/groupbox/mainwindow.ui +++ /dev/null @@ -1,87 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 110 - 40 - 531 - 381 - - - - 设置 - - - Qt::AlignCenter - - - false - - - true - - - false - - - - - 80 - 50 - 256 - 192 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/containers/mdiarea/.gitignore b/qt/containers/mdiarea/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/containers/mdiarea/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/containers/mdiarea/main.cpp b/qt/containers/mdiarea/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/containers/mdiarea/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/containers/mdiarea/mainwindow.cpp b/qt/containers/mdiarea/mainwindow.cpp deleted file mode 100644 index 96d604d..0000000 --- a/qt/containers/mdiarea/mainwindow.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_actiontile_triggered() -{ - - ui->mdiArea->tileSubWindows(); -} - -void MainWindow::on_actioncascade_triggered() -{ - ui->mdiArea->cascadeSubWindows(); - -} - -void MainWindow::on_actionnext_triggered() -{ - - ui->mdiArea->activateNextSubWindow(); -} - -void MainWindow::on_actionprev_triggered() -{ - ui->mdiArea->activatePreviousSubWindow(); -} - -void MainWindow::on_actiondont_max_triggered() -{ - ui->mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true); -} - -void MainWindow::on_actionno_system_menu_triggered() -{ - ui->mdiArea->currentSubWindow()->setSystemMenu(nullptr); -} - -void MainWindow::on_actionshaded_triggered() -{ - ui->mdiArea->currentSubWindow()->showShaded(); -} diff --git a/qt/containers/mdiarea/mainwindow.h b/qt/containers/mdiarea/mainwindow.h deleted file mode 100644 index 88c7c3e..0000000 --- a/qt/containers/mdiarea/mainwindow.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_actiontile_triggered(); - - void on_actioncascade_triggered(); - - void on_actionnext_triggered(); - - void on_actionprev_triggered(); - - void on_actiondont_max_triggered(); - - void on_actionno_system_menu_triggered(); - - void on_actionshaded_triggered(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/containers/mdiarea/mainwindow.ui b/qt/containers/mdiarea/mainwindow.ui deleted file mode 100644 index 711cb39..0000000 --- a/qt/containers/mdiarea/mainwindow.ui +++ /dev/null @@ -1,186 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - QMdiArea::ActivationHistoryOrder - - - QMdiArea::SubWindowView - - - true - - - true - - - - 子窗口1 - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">1</p></body></html> - - - - - - - - 子窗口2 - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">2</p></body></html> - - - - - - - - 子窗口3 - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">3</p></body></html> - - - - - - - - 子窗口 - - - - - - 4 - - - - - - - - 子窗口 - - - - - - 5 - - - - - - - - - - - - - 0 - 0 - 800 - 23 - - - - - Menu - - - - - - - - activite - - - - - - - - - - - - - tile - - - - - cascade - - - - - next - - - - - prev - - - - - dont'max - - - - - no system menu - - - - - shaded - - - - - - diff --git a/qt/containers/mdiarea/mdiarea.pro b/qt/containers/mdiarea/mdiarea.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/containers/mdiarea/mdiarea.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/scrollarea/231102-151931226201f1.jpg b/qt/containers/scrollarea/231102-151931226201f1.jpg deleted file mode 100644 index 42aa8d5..0000000 Binary files a/qt/containers/scrollarea/231102-151931226201f1.jpg and /dev/null differ diff --git a/qt/containers/scrollarea/main.cpp b/qt/containers/scrollarea/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/containers/scrollarea/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/containers/scrollarea/mainwindow.cpp b/qt/containers/scrollarea/mainwindow.cpp deleted file mode 100644 index ac68ac5..0000000 --- a/qt/containers/scrollarea/mainwindow.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - ui->scrollArea->setWidget(ui->label); - // ui->scrollArea->setWidget(ui->pushButton); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_pushButton_2_clicked() -{ - ui->scrollArea->ensureWidgetVisible(ui->label); -} - -void MainWindow::on_spinBox_valueChanged(int arg1) -{ - ui->scrollArea->ensureVisible(arg1, 100); -} diff --git a/qt/containers/scrollarea/mainwindow.h b/qt/containers/scrollarea/mainwindow.h deleted file mode 100644 index 95ceac2..0000000 --- a/qt/containers/scrollarea/mainwindow.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_2_clicked(); - - void on_spinBox_valueChanged(int arg1); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/containers/scrollarea/mainwindow.ui b/qt/containers/scrollarea/mainwindow.ui deleted file mode 100644 index b154ee7..0000000 --- a/qt/containers/scrollarea/mainwindow.ui +++ /dev/null @@ -1,125 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 927 - 454 - - - - MainWindow - - - - - - 20 - 10 - 361 - 371 - - - - true - - - Qt::AlignCenter - - - - - 0 - 0 - 359 - 369 - - - - - - - - 420 - -10 - 1200 - 821 - - - - - - - C:/Users/fan/Pictures/231102-151931226201f1.jpg - - - - - - 400 - 140 - 75 - 23 - - - - PushButton - - - - - - 480 - 290 - 75 - 23 - - - - click - - - - - - 520 - 230 - 131 - 51 - - - - 2000 - - - 10 - - - - - - - 0 - 0 - 927 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/containers/scrollarea/scrollarea.pro b/qt/containers/scrollarea/scrollarea.pro deleted file mode 100644 index 51f6d88..0000000 --- a/qt/containers/scrollarea/scrollarea.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-02-16T14:04:20 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = scrollarea -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/stackwidget/main.cpp b/qt/containers/stackwidget/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/containers/stackwidget/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/containers/stackwidget/mainwindow.cpp b/qt/containers/stackwidget/mainwindow.cpp deleted file mode 100644 index 8ab3bc3..0000000 --- a/qt/containers/stackwidget/mainwindow.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include -#define MAX_PAGE_COUNT 3 - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - ui->stackedWidget->addWidget(new QCheckBox(this)); - -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_pushButton_3_clicked() -{ - static int i = 0; - - if (++i >=MAX_PAGE_COUNT){ i = 0;} - ui->stackedWidget->setCurrentIndex(i %MAX_PAGE_COUNT ); - -} - -void MainWindow::on_stackedWidget_currentChanged(int arg1) -{ - qDebug() << "current changed..."; -} diff --git a/qt/containers/stackwidget/mainwindow.h b/qt/containers/stackwidget/mainwindow.h deleted file mode 100644 index 51c71de..0000000 --- a/qt/containers/stackwidget/mainwindow.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_3_clicked(); - - void on_stackedWidget_currentChanged(int arg1); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/containers/stackwidget/mainwindow.ui b/qt/containers/stackwidget/mainwindow.ui deleted file mode 100644 index 97a8442..0000000 --- a/qt/containers/stackwidget/mainwindow.ui +++ /dev/null @@ -1,87 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 400 - 300 - - - - MainWindow - - - - - - - 0 - - - - - - 90 - 90 - 75 - 23 - - - - page - - - - - - - - 180 - 90 - 75 - 23 - - - - page2 - - - - - - - - - PushButton - - - - - - - - - 0 - 0 - 400 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/containers/stackwidget/stackwidget.pro b/qt/containers/stackwidget/stackwidget.pro deleted file mode 100644 index ce85120..0000000 --- a/qt/containers/stackwidget/stackwidget.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-03-22T09:30:13 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = stackwidget -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/tabwidget/dialog.cpp b/qt/containers/tabwidget/dialog.cpp deleted file mode 100644 index 663050f..0000000 --- a/qt/containers/tabwidget/dialog.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "dialog.h" -#include "ui_dialog.h" - -Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) -{ - ui->setupUi(this); -} - -Dialog::~Dialog() -{ - delete ui; -} - -void Dialog::setText(const QString &text) -{ - ui->lineEdit->setText(text); -} diff --git a/qt/containers/tabwidget/dialog.h b/qt/containers/tabwidget/dialog.h deleted file mode 100644 index 685433b..0000000 --- a/qt/containers/tabwidget/dialog.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef DIALOG_H -#define DIALOG_H - -#include - -namespace Ui { -class Dialog; -} -class AbstractEdit { -public: - virtual void setText(const QString& text) = 0; -}; - -class Dialog : public QDialog, public AbstractEdit -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = nullptr); - ~Dialog(); - -private: - Ui::Dialog *ui; - - // AbstractEdit interface -public: - void setText(const QString &text); -}; - -#endif // DIALOG_H diff --git a/qt/containers/tabwidget/dialog.ui b/qt/containers/tabwidget/dialog.ui deleted file mode 100644 index 25ced47..0000000 --- a/qt/containers/tabwidget/dialog.ui +++ /dev/null @@ -1,78 +0,0 @@ - - - Dialog - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - 290 - 20 - 81 - 241 - - - - Qt::Vertical - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 100 - 130 - 113 - 20 - - - - - - - - buttonBox - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/qt/containers/tabwidget/main.cpp b/qt/containers/tabwidget/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/containers/tabwidget/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/containers/tabwidget/mainwindow.cpp b/qt/containers/tabwidget/mainwindow.cpp deleted file mode 100644 index 303acda..0000000 --- a/qt/containers/tabwidget/mainwindow.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include "dialog.h" -#include -#include - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - ui->tabWidget->addTab(new Dialog, "dialog" ); - - auto * btn = new QPushButton("corner"); - connect(btn, &QPushButton::clicked, [](){ - - qDebug() << "clicked"; - }); - ui->tabWidget->setCornerWidget(btn); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_tabWidget_currentChanged(int index) -{ - auto *w = dynamic_cast(ui->tabWidget->widget(index)); - - if (w){ - w->setText(QString::fromStdString(std::to_string(index))); - } - -} - -void MainWindow::on_tabWidget_tabCloseRequested(int index) -{ - ui->tabWidget->removeTab(index); -} diff --git a/qt/containers/tabwidget/mainwindow.h b/qt/containers/tabwidget/mainwindow.h deleted file mode 100644 index caa34f2..0000000 --- a/qt/containers/tabwidget/mainwindow.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_tabWidget_currentChanged(int index); - - void on_tabWidget_tabCloseRequested(int index); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/containers/tabwidget/mainwindow.ui b/qt/containers/tabwidget/mainwindow.ui deleted file mode 100644 index d0ffd1c..0000000 --- a/qt/containers/tabwidget/mainwindow.ui +++ /dev/null @@ -1,70 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 332 - 269 - - - - MainWindow - - - - - - - 0 - - - Qt::ElideMiddle - - - false - - - true - - - true - - - false - - - - Tab 2 - - - - - - - - - - 0 - 0 - 332 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/containers/tabwidget/tabwidget.pro b/qt/containers/tabwidget/tabwidget.pro deleted file mode 100644 index 97ef14c..0000000 --- a/qt/containers/tabwidget/tabwidget.pro +++ /dev/null @@ -1,43 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-03-14T18:56:03 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = tabwidget -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - dialog.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - dialog.h \ - mainwindow.h - -FORMS += \ - dialog.ui \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/containers/toolbox/main.cpp b/qt/containers/toolbox/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/containers/toolbox/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/containers/toolbox/mainwindow.cpp b/qt/containers/toolbox/mainwindow.cpp deleted file mode 100644 index 9461357..0000000 --- a/qt/containers/toolbox/mainwindow.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include -#include -#include -#include - -static QPixmap extractIcons(const QString &sourceFile, bool large) - { - const QString nativeName = QDir::toNativeSeparators(sourceFile); - const wchar_t *sourceFileC = reinterpret_cast(nativeName.utf16()); - const UINT iconCount = ExtractIconEx(sourceFileC, -1, 0, 0, 0); - if (!iconCount) { - //std::wcerr << sourceFile << " does not appear to contain icons.\n"; - return QPixmap(); - } - - QScopedArrayPointer icons(new HICON[iconCount]); - const UINT extractedIconCount = large ? - ExtractIconEx(sourceFileC, 0, icons.data(), 0, iconCount) : - ExtractIconEx(sourceFileC, 0, 0, icons.data(), iconCount); - if (!extractedIconCount) { - qErrnoWarning("Failed to extract icons from %s", qPrintable(sourceFile)); - return QPixmap(); - } - - QPixmap result; - //result.reserve(int(extractedIconCount)); - - // std::wcout << sourceFile << " contains " << extractedIconCount << " icon(s).\n"; - - for (UINT i = 0; i < extractedIconCount; ++i) { - // PixmapEntry entry; - result = QtWin::fromHICON(icons[i]); - if (result.isNull()) { - // std::wcerr << "Error converting icons.\n"; - return QPixmap(); - } -// entry.name = QString::fromLatin1("%1_%2x%3").arg(i, 3, 10, QLatin1Char('0')) -// .arg(entry.pixmap.width()).arg(entry.pixmap.height()); -// result.append(entry); - } - return result; - } - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - QPixmap map = extractIcons("C:\\Windows\\System32\\notepad.exe", true); - - map.save("note.png"); - - - auto* item = ui->listWidget->item(0); - - item->setIcon(map); - - item->setData(0xff + 1, "C:\\Windows\\System32\\notepad.exe"); - - - ui->toolBox->addItem(new QListWidget(),"third"); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - - - -void MainWindow::on_listWidget_itemDoubleClicked(QListWidgetItem *item) -{ - auto path = item->data(0xff + 1).toString(); - - QProcess::startDetached(path); -} diff --git a/qt/containers/toolbox/mainwindow.h b/qt/containers/toolbox/mainwindow.h deleted file mode 100644 index 9497b18..0000000 --- a/qt/containers/toolbox/mainwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_listWidget_itemDoubleClicked(QListWidgetItem *item); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/containers/toolbox/mainwindow.ui b/qt/containers/toolbox/mainwindow.ui deleted file mode 100644 index 002e1f2..0000000 --- a/qt/containers/toolbox/mainwindow.ui +++ /dev/null @@ -1,135 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 400 - 300 - - - - MainWindow - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 0 - - - - - :/new/prefix1/oil-barrel.png:/new/prefix1/oil-barrel.png - - - - - - 111 - - - - 0 - - - 3 - - - 3 - - - 3 - - - 3 - - - - - - 64 - 64 - - - - QListView::IconMode - - - - 记事本 - - - - - 计算器 - - - - - - - - - - 0 - 0 - 400 - 199 - - - - Page 2 - - - - - - - - - - 0 - 0 - 400 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/containers/toolbox/oil-barrel.png b/qt/containers/toolbox/oil-barrel.png deleted file mode 100644 index 6984572..0000000 Binary files a/qt/containers/toolbox/oil-barrel.png and /dev/null differ diff --git a/qt/containers/toolbox/toolbox.pro b/qt/containers/toolbox/toolbox.pro deleted file mode 100644 index aeba1c7..0000000 --- a/qt/containers/toolbox/toolbox.pro +++ /dev/null @@ -1,43 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-02-22T11:55:57 -# -#------------------------------------------------- - -QT += core gui winextras - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = toolbox -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target - -RESOURCES += \ - toolbox.qrc diff --git a/qt/containers/toolbox/toolbox.qrc b/qt/containers/toolbox/toolbox.qrc deleted file mode 100644 index 75f0e4b..0000000 --- a/qt/containers/toolbox/toolbox.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - oil-barrel.png - - diff --git a/qt/containers/widget/main.cpp b/qt/containers/widget/main.cpp deleted file mode 100644 index 56ad625..0000000 --- a/qt/containers/widget/main.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "mainwindow.h" -#include -#include -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - - - QPalette pal; - - - pal.setColor(QPalette::Window, Qt::red); - - w.setPalette(pal); - w.show(); - - return a.exec(); -} diff --git a/qt/containers/widget/mainwindow.cpp b/qt/containers/widget/mainwindow.cpp deleted file mode 100644 index 1ee6d40..0000000 --- a/qt/containers/widget/mainwindow.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "mainwindow.h" -#include -#include "ui_mainwindow.h" -#include -#include -#include -#include -#include -#include -#include -#include - - -class PushButton : public QPushButton{ -public: - PushButton(QString text): QPushButton(text){ - setMouseTracking(true); - setAcceptDrops(true); - this->setWindowTitle("widget"); - } - void mouseMoveEvent(QMouseEvent*){ - - //qDebug() << "mouse event"; - } - - - -}; - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - ui->lineEdit->addAction(new QAction("menu")); - - - ui->centralWidget->layout()->addWidget(new PushButton("Text")); - - connect(ui->lineEdit, &QLineEdit::customContextMenuRequested, [](){ - - qDebug() << "customContextMenuRequested"; - - }); - - - QPalette pal; - - - pal.setColor(QPalette::Window, Qt::red); - - ui->label->setPalette(pal); - - - // qDebug() << ui->pushButton->geometry(); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_pushButton_clicked() -{ - if (QWhatsThis::inWhatsThisMode()) { - qDebug() << "in"; - QWhatsThis::leaveWhatsThisMode(); - } else{ - qDebug() << "out"; - QWhatsThis::enterWhatsThisMode(); - } -} - -void MainWindow::mouseMoveEvent(QMouseEvent *) -{ - -} - -void MainWindow::dragEnterEvent(QDragEnterEvent *event) -{ - qDebug() << __FUNCTION__; - event->accept(); -} - -void MainWindow::dragLeaveEvent(QDragLeaveEvent *event) -{ - qDebug() << __FUNCTION__; -} - -void MainWindow::dragMoveEvent(QDragMoveEvent *event) -{ - qDebug() << __FUNCTION__; -} - -void MainWindow::dropEvent(QDropEvent *event) -{ - qDebug() << __FUNCTION__; -} diff --git a/qt/containers/widget/mainwindow.h b/qt/containers/widget/mainwindow.h deleted file mode 100644 index 2ed526b..0000000 --- a/qt/containers/widget/mainwindow.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - -protected: - void mouseMoveEvent(QMouseEvent*); - - - virtual void - dragEnterEvent(QDragEnterEvent *event); - virtual void - dragLeaveEvent(QDragLeaveEvent *event); - virtual void - dragMoveEvent(QDragMoveEvent *event); - virtual void - dropEvent(QDropEvent *event); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/qt/containers/widget/mainwindow.ui b/qt/containers/widget/mainwindow.ui deleted file mode 100644 index 3689fd8..0000000 --- a/qt/containers/widget/mainwindow.ui +++ /dev/null @@ -1,120 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 568 - 377 - - - - true - - - Qt::CustomContextMenu - - - true - - - Widget - - - - C:/Users/fan/Pictures/Red_Dead_Redemption_2_1.pngC:/Users/fan/Pictures/Red_Dead_Redemption_2_1.png - - - 1.000000000000000 - - - Qt::RightToLeft - - - false - - - - - - - - - - Qt::ActionsContextMenu - - - this is lineedit. - - - 5000 - - - this status tip - - - this is linedit(what it is this) - - - - - - - false - - - 中文中国 - - - - - - - Qt::WheelFocus - - - Qt::LeftToRight - - - what's this - - - - - - - - - - Qt::ImhLowercaseOnly|Qt::ImhUppercaseOnly - - - - - - - - - 0 - 0 - 568 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/containers/widget/widget.pro b/qt/containers/widget/widget.pro deleted file mode 100644 index fb3a771..0000000 --- a/qt/containers/widget/widget.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2020-03-29T10:22:16 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = widget -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/dialog/ColorDialog/ColorDialog.sln b/qt/dialog/ColorDialog/ColorDialog.sln deleted file mode 100644 index cf67497..0000000 --- a/qt/dialog/ColorDialog/ColorDialog.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30503.244 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dialog", "Dialog\Dialog.vcxproj", "{1860A8DA-9BD5-4860-A480-A00CC4C44914}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1860A8DA-9BD5-4860-A480-A00CC4C44914}.Debug|x64.ActiveCfg = Debug|x64 - {1860A8DA-9BD5-4860-A480-A00CC4C44914}.Debug|x64.Build.0 = Debug|x64 - {1860A8DA-9BD5-4860-A480-A00CC4C44914}.Release|x64.ActiveCfg = Release|x64 - {1860A8DA-9BD5-4860-A480-A00CC4C44914}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {5F42A99A-3DF1-4367-9289-76F033469149} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/ColorDialog/Dialog/Dialog.cpp b/qt/dialog/ColorDialog/Dialog/Dialog.cpp deleted file mode 100644 index 25967e7..0000000 --- a/qt/dialog/ColorDialog/Dialog/Dialog.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "Dialog.h" -#include "qcolordialog.h" -#include "qdebug.h" -Dialog::Dialog(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.pushButton, &QPushButton::clicked, [this]() { - QColorDialog dialog; - - connect(&dialog, &QColorDialog::colorSelected, [](auto& color) { - qDebug() << "# select color: " << color; - }); - dialog.exec(); - - }); -} diff --git a/qt/dialog/ColorDialog/Dialog/Dialog.h b/qt/dialog/ColorDialog/Dialog/Dialog.h deleted file mode 100644 index 2461c84..0000000 --- a/qt/dialog/ColorDialog/Dialog/Dialog.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_Dialog.h" - -class Dialog : public QMainWindow -{ - Q_OBJECT - -public: - Dialog(QWidget *parent = Q_NULLPTR); - -private: - Ui::DialogClass ui; -}; diff --git a/qt/dialog/ColorDialog/Dialog/Dialog.qrc b/qt/dialog/ColorDialog/Dialog/Dialog.qrc deleted file mode 100644 index ee7529b..0000000 --- a/qt/dialog/ColorDialog/Dialog/Dialog.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dialog/ColorDialog/Dialog/Dialog.ui b/qt/dialog/ColorDialog/Dialog/Dialog.ui deleted file mode 100644 index b438aaf..0000000 --- a/qt/dialog/ColorDialog/Dialog/Dialog.ui +++ /dev/null @@ -1,56 +0,0 @@ - - - DialogClass - - - - 0 - 0 - 726 - 592 - - - - Dialog - - - - - - 140 - 220 - 201 - 23 - - - - Show Color dialog - - - - - - - 0 - 0 - 726 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dialog/ColorDialog/Dialog/Dialog.vcxproj b/qt/dialog/ColorDialog/Dialog/Dialog.vcxproj deleted file mode 100644 index c4603bb..0000000 --- a/qt/dialog/ColorDialog/Dialog/Dialog.vcxproj +++ /dev/null @@ -1,102 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {1860A8DA-9BD5-4860-A480-A00CC4C44914} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - ColorDialog - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dialog/ColorDialog/Dialog/main.cpp b/qt/dialog/ColorDialog/Dialog/main.cpp deleted file mode 100644 index f16ca8c..0000000 --- a/qt/dialog/ColorDialog/Dialog/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Dialog.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Dialog w; - w.show(); - return a.exec(); -} diff --git a/qt/dialog/ErrorMessage/ErrorMessage.sln b/qt/dialog/ErrorMessage/ErrorMessage.sln deleted file mode 100644 index bb9b306..0000000 --- a/qt/dialog/ErrorMessage/ErrorMessage.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ErrorMessage", "ErrorMessage\ErrorMessage.vcxproj", "{A4098241-5C77-471D-8A60-E2D398D214F7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A4098241-5C77-471D-8A60-E2D398D214F7}.Debug|x64.ActiveCfg = Debug|x64 - {A4098241-5C77-471D-8A60-E2D398D214F7}.Debug|x64.Build.0 = Debug|x64 - {A4098241-5C77-471D-8A60-E2D398D214F7}.Release|x64.ActiveCfg = Release|x64 - {A4098241-5C77-471D-8A60-E2D398D214F7}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {41CDD0F7-3E73-4C87-BD39-36E6196C7FF7} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.cpp b/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.cpp deleted file mode 100644 index 574f756..0000000 --- a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "ErrorMessage.h" -#include "qerrormessage.h" -#include "qdebug.h" -ErrorMessage::ErrorMessage(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - auto* dialog = QErrorMessage::qtHandler(); - - - connect(ui.pushButton, &QPushButton::clicked, [this]() { - - QErrorMessage dialog; - dialog.showMessage("This is test message."); - dialog.exec(); - }); - - - connect(ui.pushButton_2, &QPushButton::clicked, [this]() { - - qDebug() << "# error message test."; - - }); -} diff --git a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.h b/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.h deleted file mode 100644 index 6c63302..0000000 --- a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_ErrorMessage.h" - -class ErrorMessage : public QMainWindow -{ - Q_OBJECT - -public: - ErrorMessage(QWidget *parent = Q_NULLPTR); - -private: - Ui::ErrorMessageClass ui; -}; diff --git a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.qrc b/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.qrc deleted file mode 100644 index f522c1f..0000000 --- a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.ui b/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.ui deleted file mode 100644 index b599c0a..0000000 --- a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.ui +++ /dev/null @@ -1,69 +0,0 @@ - - - ErrorMessageClass - - - - 0 - 0 - 600 - 400 - - - - ErrorMessage - - - - - - 130 - 180 - 241 - 23 - - - - Show Error Message - - - - - - 130 - 230 - 241 - 23 - - - - Show Error Message 2 - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.vcxproj b/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.vcxproj deleted file mode 100644 index 5728039..0000000 --- a/qt/dialog/ErrorMessage/ErrorMessage/ErrorMessage.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {A4098241-5C77-471D-8A60-E2D398D214F7} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dialog/ErrorMessage/ErrorMessage/main.cpp b/qt/dialog/ErrorMessage/ErrorMessage/main.cpp deleted file mode 100644 index 99e877e..0000000 --- a/qt/dialog/ErrorMessage/ErrorMessage/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "ErrorMessage.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - ErrorMessage w; - w.show(); - return a.exec(); -} diff --git a/qt/dialog/FileDialog/FileDialog.sln b/qt/dialog/FileDialog/FileDialog.sln deleted file mode 100644 index 03ce103..0000000 --- a/qt/dialog/FileDialog/FileDialog.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FileDialog", "FileDialog\FileDialog.vcxproj", "{63DEE855-ECD2-4628-9BC8-83E706DC72C5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {63DEE855-ECD2-4628-9BC8-83E706DC72C5}.Debug|x64.ActiveCfg = Debug|x64 - {63DEE855-ECD2-4628-9BC8-83E706DC72C5}.Debug|x64.Build.0 = Debug|x64 - {63DEE855-ECD2-4628-9BC8-83E706DC72C5}.Release|x64.ActiveCfg = Release|x64 - {63DEE855-ECD2-4628-9BC8-83E706DC72C5}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {E427854A-BF42-4F92-8543-78FD6C3E9498} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/FileDialog/FileDialog/FileDialog.cpp b/qt/dialog/FileDialog/FileDialog/FileDialog.cpp deleted file mode 100644 index 1dc2c6a..0000000 --- a/qt/dialog/FileDialog/FileDialog/FileDialog.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "FileDialog.h" -#include "qfiledialog.h" -#include - -FileDialog::FileDialog(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.pushButton, &QPushButton::clicked, [this]() { - auto picture = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); - - auto file = QFileDialog::getOpenFileName(this, "Open filename", picture, "Png(*.png *.jpg);;All files(*)"); - - - ui.lineEdit->setText(file); - - - }); - - connect(ui.pushButton_2, &QPushButton::clicked, [this]() { - auto picture = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); - - auto file = QFileDialog::getOpenFileUrl(this, "Open filename", QUrl(picture), "Png(*.png *.jpg);;All files(*)"); - - - ui.lineEdit->setText(file.toString()); - - - }); - - - connect(ui.pushButton_3, &QPushButton::clicked, [this]() { - auto picture = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); - - auto file = QFileDialog::getOpenFileUrl(this, "Open filename", QUrl(picture), "Png(*.png *.jpg);;All files(*)", nullptr, - QFileDialog::Option::DontUseNativeDialog); - - - ui.lineEdit->setText(file.toString()); - - - }); -} diff --git a/qt/dialog/FileDialog/FileDialog/FileDialog.h b/qt/dialog/FileDialog/FileDialog/FileDialog.h deleted file mode 100644 index 98a1341..0000000 --- a/qt/dialog/FileDialog/FileDialog/FileDialog.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_FileDialog.h" - -class FileDialog : public QMainWindow -{ - Q_OBJECT - -public: - FileDialog(QWidget *parent = Q_NULLPTR); - -private: - Ui::FileDialogClass ui; -}; diff --git a/qt/dialog/FileDialog/FileDialog/FileDialog.qrc b/qt/dialog/FileDialog/FileDialog/FileDialog.qrc deleted file mode 100644 index b4a006f..0000000 --- a/qt/dialog/FileDialog/FileDialog/FileDialog.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dialog/FileDialog/FileDialog/FileDialog.ui b/qt/dialog/FileDialog/FileDialog/FileDialog.ui deleted file mode 100644 index 97a4a6a..0000000 --- a/qt/dialog/FileDialog/FileDialog/FileDialog.ui +++ /dev/null @@ -1,95 +0,0 @@ - - - FileDialogClass - - - - 0 - 0 - 600 - 400 - - - - FileDialog - - - - - - 80 - 230 - 421 - 20 - - - - - - - 80 - 110 - 261 - 83 - - - - - - - Qt::LeftToRight - - - open file filename - - - - - - - Qt::RightToLeft - - - open by url - - - - - - - Qt::LeftToRight - - - Dot use native - - - - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dialog/FileDialog/FileDialog/FileDialog.vcxproj b/qt/dialog/FileDialog/FileDialog/FileDialog.vcxproj deleted file mode 100644 index 4a10c70..0000000 --- a/qt/dialog/FileDialog/FileDialog/FileDialog.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {63DEE855-ECD2-4628-9BC8-83E706DC72C5} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dialog/FileDialog/FileDialog/main.cpp b/qt/dialog/FileDialog/FileDialog/main.cpp deleted file mode 100644 index 4db61d3..0000000 --- a/qt/dialog/FileDialog/FileDialog/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "FileDialog.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - FileDialog w; - w.show(); - return a.exec(); -} diff --git a/qt/dialog/FontDialog/FontDialog.sln b/qt/dialog/FontDialog/FontDialog.sln deleted file mode 100644 index fbc5a47..0000000 --- a/qt/dialog/FontDialog/FontDialog.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FontDialog", "FontDialog\FontDialog.vcxproj", "{E69E1177-D93E-4906-AE20-8727480A5DF3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E69E1177-D93E-4906-AE20-8727480A5DF3}.Debug|x64.ActiveCfg = Debug|x64 - {E69E1177-D93E-4906-AE20-8727480A5DF3}.Debug|x64.Build.0 = Debug|x64 - {E69E1177-D93E-4906-AE20-8727480A5DF3}.Release|x64.ActiveCfg = Release|x64 - {E69E1177-D93E-4906-AE20-8727480A5DF3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F1F2E6F9-6F4A-41C8-900C-8D20B1C0543A} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/FontDialog/FontDialog/FontDialog.cpp b/qt/dialog/FontDialog/FontDialog/FontDialog.cpp deleted file mode 100644 index a44f8f2..0000000 --- a/qt/dialog/FontDialog/FontDialog/FontDialog.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "FontDialog.h" -#include "qfontdialog.h" -#include "qdebug.h" -FontDialog::FontDialog(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.pushButton, &QPushButton::clicked, [this]() { - - bool ok = false; - auto font= QFontDialog::getFont(&ok, this); - if (ok) - ui.plainTextEdit->setFont(font); - else { - - } - qDebug() << font.family(); - - }); -} diff --git a/qt/dialog/FontDialog/FontDialog/FontDialog.h b/qt/dialog/FontDialog/FontDialog/FontDialog.h deleted file mode 100644 index eeb94d6..0000000 --- a/qt/dialog/FontDialog/FontDialog/FontDialog.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_FontDialog.h" - -class FontDialog : public QMainWindow -{ - Q_OBJECT - -public: - FontDialog(QWidget *parent = Q_NULLPTR); - -private: - Ui::FontDialogClass ui; -}; diff --git a/qt/dialog/FontDialog/FontDialog/FontDialog.qrc b/qt/dialog/FontDialog/FontDialog/FontDialog.qrc deleted file mode 100644 index 3bb301e..0000000 --- a/qt/dialog/FontDialog/FontDialog/FontDialog.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dialog/FontDialog/FontDialog/FontDialog.ui b/qt/dialog/FontDialog/FontDialog/FontDialog.ui deleted file mode 100644 index c544812..0000000 --- a/qt/dialog/FontDialog/FontDialog/FontDialog.ui +++ /dev/null @@ -1,74 +0,0 @@ - - - FontDialogClass - - - - 0 - 0 - 600 - 400 - - - - FontDialog - - - - - - 154 - 170 - 281 - 23 - - - - Open Font Dialog - - - - - - 100 - 220 - 421 - 111 - - - - FontDialog::FontDialog(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); -} - - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dialog/FontDialog/FontDialog/FontDialog.vcxproj b/qt/dialog/FontDialog/FontDialog/FontDialog.vcxproj deleted file mode 100644 index cb3dc90..0000000 --- a/qt/dialog/FontDialog/FontDialog/FontDialog.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {E69E1177-D93E-4906-AE20-8727480A5DF3} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dialog/FontDialog/FontDialog/main.cpp b/qt/dialog/FontDialog/FontDialog/main.cpp deleted file mode 100644 index 89070e6..0000000 --- a/qt/dialog/FontDialog/FontDialog/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "FontDialog.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - FontDialog w; - w.show(); - return a.exec(); -} diff --git a/qt/dialog/InputDialog/.gitattributes b/qt/dialog/InputDialog/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/qt/dialog/InputDialog/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/qt/dialog/InputDialog/.gitignore b/qt/dialog/InputDialog/.gitignore deleted file mode 100644 index 4ce6fdd..0000000 --- a/qt/dialog/InputDialog/.gitignore +++ /dev/null @@ -1,340 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# User-specific files -*.rsuser -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -[Aa][Rr][Mm]/ -[Aa][Rr][Mm]64/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_h.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*_wpftmp.csproj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!?*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser -*- Backup*.rdl - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# CodeRush personal settings -.cr/personal - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ - -# Local History for Visual Studio -.localhistory/ - -# BeatPulse healthcheck temp database -healthchecksdb \ No newline at end of file diff --git a/qt/dialog/InputDialog/InputDialog.sln b/qt/dialog/InputDialog/InputDialog.sln deleted file mode 100644 index 46aca50..0000000 --- a/qt/dialog/InputDialog/InputDialog.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputDialog", "InputDialog\InputDialog.vcxproj", "{EE6F96AC-8CA2-49E2-83B5-FE1EFC3AE7F5}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EE6F96AC-8CA2-49E2-83B5-FE1EFC3AE7F5}.Debug|x64.ActiveCfg = Debug|x64 - {EE6F96AC-8CA2-49E2-83B5-FE1EFC3AE7F5}.Debug|x64.Build.0 = Debug|x64 - {EE6F96AC-8CA2-49E2-83B5-FE1EFC3AE7F5}.Release|x64.ActiveCfg = Release|x64 - {EE6F96AC-8CA2-49E2-83B5-FE1EFC3AE7F5}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {B2FCFF17-B46A-4420-AFE9-6D2A90823EB4} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/InputDialog/InputDialog/InputDialog.cpp b/qt/dialog/InputDialog/InputDialog/InputDialog.cpp deleted file mode 100644 index 1c1f677..0000000 --- a/qt/dialog/InputDialog/InputDialog/InputDialog.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "InputDialog.h" -#include "qinputdialog.h" -#include "qdebug.h" -InputDialog::InputDialog(QWidget* parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.pushButton, &QPushButton::clicked, [this]() { - auto text = QInputDialog::getMultiLineText(this, "test", "description:"); - qDebug() << text; - }); -} diff --git a/qt/dialog/InputDialog/InputDialog/InputDialog.h b/qt/dialog/InputDialog/InputDialog/InputDialog.h deleted file mode 100644 index f505b59..0000000 --- a/qt/dialog/InputDialog/InputDialog/InputDialog.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_InputDialog.h" - -class InputDialog : public QMainWindow -{ - Q_OBJECT - -public: - InputDialog(QWidget *parent = Q_NULLPTR); - -private: - Ui::InputDialogClass ui; -}; diff --git a/qt/dialog/InputDialog/InputDialog/InputDialog.qrc b/qt/dialog/InputDialog/InputDialog/InputDialog.qrc deleted file mode 100644 index 898b068..0000000 --- a/qt/dialog/InputDialog/InputDialog/InputDialog.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dialog/InputDialog/InputDialog/InputDialog.ui b/qt/dialog/InputDialog/InputDialog/InputDialog.ui deleted file mode 100644 index 276975a..0000000 --- a/qt/dialog/InputDialog/InputDialog/InputDialog.ui +++ /dev/null @@ -1,56 +0,0 @@ - - - InputDialogClass - - - - 0 - 0 - 600 - 400 - - - - InputDialog - - - - - - 130 - 150 - 75 - 23 - - - - PushButton - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dialog/InputDialog/InputDialog/InputDialog.vcxproj b/qt/dialog/InputDialog/InputDialog/InputDialog.vcxproj deleted file mode 100644 index 5258606..0000000 --- a/qt/dialog/InputDialog/InputDialog/InputDialog.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {EE6F96AC-8CA2-49E2-83B5-FE1EFC3AE7F5} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dialog/InputDialog/InputDialog/main.cpp b/qt/dialog/InputDialog/InputDialog/main.cpp deleted file mode 100644 index 132e543..0000000 --- a/qt/dialog/InputDialog/InputDialog/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "InputDialog.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - InputDialog w; - w.show(); - return a.exec(); -} diff --git a/qt/dialog/MessageBox/MessageBox.sln b/qt/dialog/MessageBox/MessageBox.sln deleted file mode 100644 index 1e6b39c..0000000 --- a/qt/dialog/MessageBox/MessageBox.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MessageBox", "MessageBox\MessageBox.vcxproj", "{89C19B68-EF58-49E6-9DD1-72112FB808DB}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {89C19B68-EF58-49E6-9DD1-72112FB808DB}.Debug|x64.ActiveCfg = Debug|x64 - {89C19B68-EF58-49E6-9DD1-72112FB808DB}.Debug|x64.Build.0 = Debug|x64 - {89C19B68-EF58-49E6-9DD1-72112FB808DB}.Release|x64.ActiveCfg = Release|x64 - {89C19B68-EF58-49E6-9DD1-72112FB808DB}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {4C4EF72E-C957-4298-8DBA-36DD6A7BF76F} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/MessageBox/MessageBox/MessageBox.cpp b/qt/dialog/MessageBox/MessageBox/MessageBox.cpp deleted file mode 100644 index d6c4c48..0000000 --- a/qt/dialog/MessageBox/MessageBox/MessageBox.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "MessageBox.h" -#include "qmessagebox.h" -#include "qdebug.h" -MessageBox::MessageBox(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.pushButton_about, &QPushButton::clicked, [this]() { - QMessageBox::about(this, "about", "this is a about dialog."); - }); - - connect(ui.pushButton_aboutqt, &QPushButton::clicked, [this]() { - QMessageBox::aboutQt(this, "aboutqt"); - }); - - - connect(ui.pushButton_critical, &QPushButton::clicked, [this]() { - qDebug() << QMessageBox::critical(this, "critical", "this is a critical dialog."); - }); - - connect(ui.pushButton_info, &QPushButton::clicked, [this]() { - qDebug() << QMessageBox::information(this, "information", "this is a information dialog."); - }); - connect(ui.pushButton_quest, &QPushButton::clicked, [this]() { - qDebug() < -#include "ui_MessageBox.h" - -class MessageBox : public QMainWindow -{ - Q_OBJECT - -public: - MessageBox(QWidget *parent = Q_NULLPTR); - -private: - Ui::MessageBoxClass ui; -}; diff --git a/qt/dialog/MessageBox/MessageBox/MessageBox.qrc b/qt/dialog/MessageBox/MessageBox/MessageBox.qrc deleted file mode 100644 index 69dde24..0000000 --- a/qt/dialog/MessageBox/MessageBox/MessageBox.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dialog/MessageBox/MessageBox/MessageBox.ui b/qt/dialog/MessageBox/MessageBox/MessageBox.ui deleted file mode 100644 index b2e383a..0000000 --- a/qt/dialog/MessageBox/MessageBox/MessageBox.ui +++ /dev/null @@ -1,121 +0,0 @@ - - - MessageBoxClass - - - - 0 - 0 - 600 - 400 - - - - MessageBox - - - - - - 60 - 100 - 75 - 23 - - - - about - - - - - - 160 - 100 - 75 - 23 - - - - critical - - - - - - 90 - 180 - 75 - 23 - - - - warning - - - - - - 270 - 110 - 75 - 23 - - - - info - - - - - - 290 - 180 - 75 - 23 - - - - quest - - - - - - 400 - 190 - 75 - 23 - - - - aboutqt - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dialog/MessageBox/MessageBox/MessageBox.vcxproj b/qt/dialog/MessageBox/MessageBox/MessageBox.vcxproj deleted file mode 100644 index e62291c..0000000 --- a/qt/dialog/MessageBox/MessageBox/MessageBox.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {89C19B68-EF58-49E6-9DD1-72112FB808DB} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dialog/MessageBox/MessageBox/main.cpp b/qt/dialog/MessageBox/MessageBox/main.cpp deleted file mode 100644 index 763cf9b..0000000 --- a/qt/dialog/MessageBox/MessageBox/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "MessageBox.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MessageBox w; - w.show(); - return a.exec(); -} diff --git a/qt/dialog/ProgressDialog/ProgressDialog.sln b/qt/dialog/ProgressDialog/ProgressDialog.sln deleted file mode 100644 index 4690915..0000000 --- a/qt/dialog/ProgressDialog/ProgressDialog.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30523.141 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProgressDialog", "ProgressDialog\ProgressDialog.vcxproj", "{B3500A0C-C5FE-4C0F-9EEB-12EBDCD5031D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B3500A0C-C5FE-4C0F-9EEB-12EBDCD5031D}.Debug|x64.ActiveCfg = Debug|x64 - {B3500A0C-C5FE-4C0F-9EEB-12EBDCD5031D}.Debug|x64.Build.0 = Debug|x64 - {B3500A0C-C5FE-4C0F-9EEB-12EBDCD5031D}.Release|x64.ActiveCfg = Release|x64 - {B3500A0C-C5FE-4C0F-9EEB-12EBDCD5031D}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {AF3C8274-2601-41DF-8940-B19FF4CF9D07} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.cpp b/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.cpp deleted file mode 100644 index 7d7ead3..0000000 --- a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.cpp +++ /dev/null @@ -1,69 +0,0 @@ -#include "ProgressDialog.h" -#include "qprogressdialog.h" -#include "qthread.h" -#include "qdebug.h" - -class Thread : public QThread { - Q_OBJECT -public: - Thread(QObject* parent) : QThread(parent) {} - -signals: - - void reportNumberValue(int n); - -protected: - void run() override - { - num = 0; - while (!isInterruptionRequested()) { - num++; - emit reportNumberValue(num); - - if (num == 100) { - break; - } - - QThread::msleep(100); - } - - qDebug() << " thread exit."; - } - -private: - int num = 0; -}; - -ProgressDialog::ProgressDialog(QWidget* parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - Thread* thread = new Thread(this); - - connect(ui.pushButton, &QPushButton::clicked, [this, thread]() { - thread->start(); - QProgressDialog dialog("task", "cancel", 0, 100); - dialog.setAutoClose(true); - - connect(thread, &Thread::reportNumberValue, [&dialog](int num) { - //QMetaObject::invokeMethod(&dialog, "setValue", Q_ARG(int, num)); - QMetaObject::invokeMethod(&dialog, "setValue", Qt::BlockingQueuedConnection, Q_ARG(int, num)); - }); - - connect(&dialog, &QProgressDialog::canceled, [thread]() { - thread->requestInterruption(); - }); - - dialog.exec(); - - qDebug() << "dialog finished"; - }); - - -} - -#include "ProgressDialog.moc" - - -//#include "moc_ProgressDialog.cpp" \ No newline at end of file diff --git a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.h b/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.h deleted file mode 100644 index 211563d..0000000 --- a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include -#include "ui_ProgressDialog.h" - -class ProgressDialog : public QMainWindow -{ - Q_OBJECT - -public: - ProgressDialog(QWidget *parent = Q_NULLPTR); - -//slots: -// void handleReportNumber(int); -private: - Ui::ProgressDialogClass ui; -}; diff --git a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.qrc b/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.qrc deleted file mode 100644 index 77b552d..0000000 --- a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.ui b/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.ui deleted file mode 100644 index ee6cd3e..0000000 --- a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.ui +++ /dev/null @@ -1,56 +0,0 @@ - - - ProgressDialogClass - - - - 0 - 0 - 600 - 400 - - - - ProgressDialog - - - - - - 210 - 180 - 75 - 23 - - - - PushButton - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.vcxproj b/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.vcxproj deleted file mode 100644 index 8a43c92..0000000 --- a/qt/dialog/ProgressDialog/ProgressDialog/ProgressDialog.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {B3500A0C-C5FE-4C0F-9EEB-12EBDCD5031D} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - input - %(Filename).moc - input - %(Filename).moc - - - - - - - - - - \ No newline at end of file diff --git a/qt/dialog/ProgressDialog/ProgressDialog/main.cpp b/qt/dialog/ProgressDialog/ProgressDialog/main.cpp deleted file mode 100644 index 827a0e7..0000000 --- a/qt/dialog/ProgressDialog/ProgressDialog/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "ProgressDialog.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - ProgressDialog w; - w.show(); - return a.exec(); -} diff --git a/qt/dialog/wizarddialog/wizarddialog.sln b/qt/dialog/wizarddialog/wizarddialog.sln deleted file mode 100644 index c659819..0000000 --- a/qt/dialog/wizarddialog/wizarddialog.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30611.23 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wizarddialog", "wizarddialog\wizarddialog.vcxproj", "{D715CD90-829B-4955-BE7D-0A9558BF718F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D715CD90-829B-4955-BE7D-0A9558BF718F}.Debug|x64.ActiveCfg = Debug|x64 - {D715CD90-829B-4955-BE7D-0A9558BF718F}.Debug|x64.Build.0 = Debug|x64 - {D715CD90-829B-4955-BE7D-0A9558BF718F}.Release|x64.ActiveCfg = Release|x64 - {D715CD90-829B-4955-BE7D-0A9558BF718F}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {6931AAAB-5268-4E7E-AD43-AFBB52DC5534} - EndGlobalSection -EndGlobal diff --git a/qt/dialog/wizarddialog/wizarddialog/20200922195737_1.jpg b/qt/dialog/wizarddialog/wizarddialog/20200922195737_1.jpg deleted file mode 100644 index 7fb585c..0000000 Binary files a/qt/dialog/wizarddialog/wizarddialog/20200922195737_1.jpg and /dev/null differ diff --git a/qt/dialog/wizarddialog/wizarddialog/231102-151931226201f1.jpg b/qt/dialog/wizarddialog/wizarddialog/231102-151931226201f1.jpg deleted file mode 100644 index 42aa8d5..0000000 Binary files a/qt/dialog/wizarddialog/wizarddialog/231102-151931226201f1.jpg and /dev/null differ diff --git a/qt/dialog/wizarddialog/wizarddialog/Page1.cpp b/qt/dialog/wizarddialog/wizarddialog/Page1.cpp deleted file mode 100644 index b224d5f..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/Page1.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Page1.h" -#include "QVBoxLayout" -#include "QLineEdit" -Page1::Page1() -{ - setTitle("Page1"); - - setSubTitle("this is page1"); - - setLayout(new QVBoxLayout); - - auto* lineEdit = new QLineEdit(this); - lineEdit->setFixedWidth(200); - layout()->addWidget(lineEdit); - - - registerField("lineEdit*", lineEdit); - -} diff --git a/qt/dialog/wizarddialog/wizarddialog/Page1.h b/qt/dialog/wizarddialog/wizarddialog/Page1.h deleted file mode 100644 index e2e7adb..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/Page1.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include -class Page1 : - public QWizardPage -{ -public: - Page1(); -}; - diff --git a/qt/dialog/wizarddialog/wizarddialog/Page2.cpp b/qt/dialog/wizarddialog/wizarddialog/Page2.cpp deleted file mode 100644 index 5cdc773..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/Page2.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "Page2.h" -#include "QVBoxLayout" - -#include "QPushButton" -#include "QMessageBox" -#include "QVariant" -Page2::Page2() -{ - setTitle("Page2"); - - setSubTitle("this is page2"); - - - setLayout(new QVBoxLayout); - - auto* button = new QPushButton(this); - - layout()->addWidget(button); - - connect(button, &QPushButton::clicked, [this]() { - QMessageBox::information(this, "display linedit value", field("lineEdit").toString()); - }); -} diff --git a/qt/dialog/wizarddialog/wizarddialog/Page2.h b/qt/dialog/wizarddialog/wizarddialog/Page2.h deleted file mode 100644 index 32cbcb9..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/Page2.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include -class Page2 : - public QWizardPage -{ -public: - Page2(); -}; - diff --git a/qt/dialog/wizarddialog/wizarddialog/Page3.cpp b/qt/dialog/wizarddialog/wizarddialog/Page3.cpp deleted file mode 100644 index 0975653..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/Page3.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "Page3.h" - -Page3::Page3() -{ - setTitle("Page3"); - - setSubTitle("this is page3"); -} diff --git a/qt/dialog/wizarddialog/wizarddialog/Page3.h b/qt/dialog/wizarddialog/wizarddialog/Page3.h deleted file mode 100644 index 6a1922a..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/Page3.h +++ /dev/null @@ -1,9 +0,0 @@ -#pragma once -#include -class Page3 : - public QWizardPage -{ -public: - Page3(); -}; - diff --git a/qt/dialog/wizarddialog/wizarddialog/main.cpp b/qt/dialog/wizarddialog/wizarddialog/main.cpp deleted file mode 100644 index 390472e..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "wizarddialog.h" -#include -#include "QWizard" -#include "Page1.h" -#include "Page2.h" -#include "Page3.h" -#include "qdebug.h" -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - // wizarddialog w; - // w.show(); - - QWizard wizard; - QPixmap pixmap = QPixmap(":/wizarddialog/222"); - // QPixmap pixmap = QPixmap(":/wizarddialog/233"); - // pixmap.scaled({ 200, 400 }); - qDebug() << pixmap.size(); - assert(!pixmap.isNull()); - wizard.setWizardStyle(QWizard::ClassicStyle); - wizard.setPixmap(QWizard::WatermarkPixmap, pixmap.scaled({ 200, 400 })); - wizard.addPage(new Page1); - wizard.addPage(new Page2); - wizard.addPage(new Page3); - wizard.show(); - return a.exec(); -} diff --git a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.cpp b/qt/dialog/wizarddialog/wizarddialog/wizarddialog.cpp deleted file mode 100644 index 7c17f40..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "wizarddialog.h" - -wizarddialog::wizarddialog(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); -} diff --git a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.h b/qt/dialog/wizarddialog/wizarddialog/wizarddialog.h deleted file mode 100644 index 1589c98..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_wizarddialog.h" - -class wizarddialog : public QMainWindow -{ - Q_OBJECT - -public: - wizarddialog(QWidget *parent = Q_NULLPTR); - -private: - Ui::wizarddialogClass ui; -}; diff --git a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.qrc b/qt/dialog/wizarddialog/wizarddialog/wizarddialog.qrc deleted file mode 100644 index cbd0ae7..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - 20200922195737_1.jpg - 231102-151931226201f1.jpg - - diff --git a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.ui b/qt/dialog/wizarddialog/wizarddialog/wizarddialog.ui deleted file mode 100644 index 9dfef68..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.ui +++ /dev/null @@ -1,28 +0,0 @@ - - wizarddialogClass - - - wizarddialogClass - - - - 0 - 0 - 600 - 400 - - - - wizarddialog - - - - - - - - - - - - diff --git a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.vcxproj b/qt/dialog/wizarddialog/wizarddialog/wizarddialog.vcxproj deleted file mode 100644 index c8c3641..0000000 --- a/qt/dialog/wizarddialog/wizarddialog/wizarddialog.vcxproj +++ /dev/null @@ -1,109 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {D715CD90-829B-4955-BE7D-0A9558BF718F} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/Calendar/Calendar.sln b/qt/dislpay/Calendar/Calendar.sln deleted file mode 100644 index b3f0511..0000000 --- a/qt/dislpay/Calendar/Calendar.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30406.217 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Calendar", "Calendar\Calendar.vcxproj", "{F72CFB36-6BF7-4B21-B1C2-5467651D4C5D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F72CFB36-6BF7-4B21-B1C2-5467651D4C5D}.Debug|x64.ActiveCfg = Debug|x64 - {F72CFB36-6BF7-4B21-B1C2-5467651D4C5D}.Debug|x64.Build.0 = Debug|x64 - {F72CFB36-6BF7-4B21-B1C2-5467651D4C5D}.Release|x64.ActiveCfg = Release|x64 - {F72CFB36-6BF7-4B21-B1C2-5467651D4C5D}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {15EEFD6A-0562-428D-A1D9-579D4D9C8D20} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/Calendar/Calendar/Calendar.cpp b/qt/dislpay/Calendar/Calendar/Calendar.cpp deleted file mode 100644 index 0195444..0000000 --- a/qt/dislpay/Calendar/Calendar/Calendar.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Calendar.h" - -Calendar::Calendar(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.calendarWidget, &QCalendarWidget::clicked, [this](auto& date) { - ui.lineEdit->setText(date.toString()); - }); -} diff --git a/qt/dislpay/Calendar/Calendar/Calendar.h b/qt/dislpay/Calendar/Calendar/Calendar.h deleted file mode 100644 index def84b2..0000000 --- a/qt/dislpay/Calendar/Calendar/Calendar.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_Calendar.h" - -class Calendar : public QMainWindow -{ - Q_OBJECT - -public: - Calendar(QWidget *parent = Q_NULLPTR); - -private: - Ui::CalendarClass ui; -}; diff --git a/qt/dislpay/Calendar/Calendar/Calendar.qrc b/qt/dislpay/Calendar/Calendar/Calendar.qrc deleted file mode 100644 index 785570f..0000000 --- a/qt/dislpay/Calendar/Calendar/Calendar.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dislpay/Calendar/Calendar/Calendar.ui b/qt/dislpay/Calendar/Calendar/Calendar.ui deleted file mode 100644 index 3a24341..0000000 --- a/qt/dislpay/Calendar/Calendar/Calendar.ui +++ /dev/null @@ -1,88 +0,0 @@ - - - CalendarClass - - - - 0 - 0 - 600 - 400 - - - - Calendar - - - - - - 20 - 0 - 341 - 281 - - - - - 2020 - 8 - 23 - - - - false - - - QCalendarWidget::SingleSelection - - - QCalendarWidget::ShortDayNames - - - QCalendarWidget::ISOWeekNumbers - - - true - - - true - - - - - - 192 - 310 - 331 - 20 - - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dislpay/Calendar/Calendar/Calendar.vcxproj b/qt/dislpay/Calendar/Calendar/Calendar.vcxproj deleted file mode 100644 index 42eb4fc..0000000 --- a/qt/dislpay/Calendar/Calendar/Calendar.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {F72CFB36-6BF7-4B21-B1C2-5467651D4C5D} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/Calendar/Calendar/main.cpp b/qt/dislpay/Calendar/Calendar/main.cpp deleted file mode 100644 index e5ad4f4..0000000 --- a/qt/dislpay/Calendar/Calendar/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Calendar.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Calendar w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/GrapicsView/GrapicsView.sln b/qt/dislpay/GrapicsView/GrapicsView.sln deleted file mode 100644 index a35da15..0000000 --- a/qt/dislpay/GrapicsView/GrapicsView.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30406.217 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GrapicsView", "GrapicsView\GrapicsView.vcxproj", "{1AEC0B9A-F980-431E-A08A-7D260279995B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1AEC0B9A-F980-431E-A08A-7D260279995B}.Debug|x64.ActiveCfg = Debug|x64 - {1AEC0B9A-F980-431E-A08A-7D260279995B}.Debug|x64.Build.0 = Debug|x64 - {1AEC0B9A-F980-431E-A08A-7D260279995B}.Release|x64.ActiveCfg = Release|x64 - {1AEC0B9A-F980-431E-A08A-7D260279995B}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {16BAD0CE-2BC3-4196-A0E2-979961FCB1C8} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/GrapicsView/GrapicsView/231102-151931226201f1.jpg b/qt/dislpay/GrapicsView/GrapicsView/231102-151931226201f1.jpg deleted file mode 100644 index 42aa8d5..0000000 Binary files a/qt/dislpay/GrapicsView/GrapicsView/231102-151931226201f1.jpg and /dev/null differ diff --git a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.cpp b/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.cpp deleted file mode 100644 index d8b342d..0000000 --- a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "GrapicsView.h" -#include -#include -#include -#include -GrapicsView::GrapicsView(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - QGraphicsScene *scene = new QGraphicsScene(this); - - qDebug() << ui.graphicsView->rect(); - - scene->setSceneRect(QRect(0,0, 793,475)); - ui.graphicsView->setSceneRect(QRect(0, 0, 793, 475)); - - QGraphicsPixmapItem* item = new QGraphicsPixmapItem(); - QPixmap pixmap = QPixmap("./231102-151931226201f1.jpg"); - - - assert(!pixmap.isNull()); - - item->setPixmap(pixmap); - scene->addItem(item); - - scene->addItem(new QGraphicsSimpleTextItem("Hello world")); - - - ui.graphicsView->setScene(scene); -} diff --git a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.h b/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.h deleted file mode 100644 index 6766a07..0000000 --- a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_GrapicsView.h" - -class GrapicsView : public QMainWindow -{ - Q_OBJECT - -public: - GrapicsView(QWidget *parent = Q_NULLPTR); - -private: - Ui::GrapicsViewClass ui; -}; diff --git a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.qrc b/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.qrc deleted file mode 100644 index 98e472a..0000000 --- a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.ui b/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.ui deleted file mode 100644 index 288d122..0000000 --- a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.ui +++ /dev/null @@ -1,48 +0,0 @@ - - - GrapicsViewClass - - - - 0 - 0 - 811 - 550 - - - - GrapicsView - - - - - - - - - - - - 0 - 0 - 811 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.vcxproj b/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.vcxproj deleted file mode 100644 index 4121b40..0000000 --- a/qt/dislpay/GrapicsView/GrapicsView/GrapicsView.vcxproj +++ /dev/null @@ -1,104 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {1AEC0B9A-F980-431E-A08A-7D260279995B} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/GrapicsView/GrapicsView/main.cpp b/qt/dislpay/GrapicsView/GrapicsView/main.cpp deleted file mode 100644 index eda5329..0000000 --- a/qt/dislpay/GrapicsView/GrapicsView/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "GrapicsView.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - GrapicsView w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/LCDNumber/LCDNumber.sln b/qt/dislpay/LCDNumber/LCDNumber.sln deleted file mode 100644 index 9f2d13f..0000000 --- a/qt/dislpay/LCDNumber/LCDNumber.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30413.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LCDNumber", "LCDNumber\LCDNumber.vcxproj", "{DA58B081-EAF4-4DE8-BB91-D22B5A5F2553}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DA58B081-EAF4-4DE8-BB91-D22B5A5F2553}.Debug|x64.ActiveCfg = Debug|x64 - {DA58B081-EAF4-4DE8-BB91-D22B5A5F2553}.Debug|x64.Build.0 = Debug|x64 - {DA58B081-EAF4-4DE8-BB91-D22B5A5F2553}.Release|x64.ActiveCfg = Release|x64 - {DA58B081-EAF4-4DE8-BB91-D22B5A5F2553}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {C7ED2695-39D7-44D3-B7EA-4F704A7B2E25} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.cpp b/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.cpp deleted file mode 100644 index 0703b8a..0000000 --- a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "LCDNumber.h" -#include -LCDNumber::LCDNumber(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - connect(ui.lcdNumber, &QLCDNumber::overflow, []() { - - qDebug() << "# overflow."; - }); - - connect(ui.pushButton, &QPushButton::clicked, [this]() { - - auto text = ui.lineEdit->text(); - - ui.lcdNumber->display(text.toInt()); - - - }); -} diff --git a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.h b/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.h deleted file mode 100644 index 2d0b8f8..0000000 --- a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_LCDNumber.h" - -class LCDNumber : public QMainWindow -{ - Q_OBJECT - -public: - LCDNumber(QWidget *parent = Q_NULLPTR); - -private: - Ui::LCDNumberClass ui; -}; diff --git a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.qrc b/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.qrc deleted file mode 100644 index 1550859..0000000 --- a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.ui b/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.ui deleted file mode 100644 index e8c31be..0000000 --- a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.ui +++ /dev/null @@ -1,91 +0,0 @@ - - - LCDNumberClass - - - - 0 - 0 - 679 - 420 - - - - LCDNumber - - - - - - 130 - 180 - 471 - 171 - - - - true - - - 9 - - - QLCDNumber::Dec - - - QLCDNumber::Filled - - - 1112.355499999999893 - - - - - - 330 - 90 - 113 - 20 - - - - - - - 480 - 90 - 75 - 23 - - - - OK - - - - - - - 0 - 0 - 679 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.vcxproj b/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.vcxproj deleted file mode 100644 index 69208cc..0000000 --- a/qt/dislpay/LCDNumber/LCDNumber/LCDNumber.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {DA58B081-EAF4-4DE8-BB91-D22B5A5F2553} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/LCDNumber/LCDNumber/main.cpp b/qt/dislpay/LCDNumber/LCDNumber/main.cpp deleted file mode 100644 index 937183e..0000000 --- a/qt/dislpay/LCDNumber/LCDNumber/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "LCDNumber.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - LCDNumber w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/Line/Line.sln b/qt/dislpay/Line/Line.sln deleted file mode 100644 index 71ccc19..0000000 --- a/qt/dislpay/Line/Line.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30413.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Line", "Line\Line.vcxproj", "{B7699B1D-905B-4EB2-AD28-79FF7EA68607}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B7699B1D-905B-4EB2-AD28-79FF7EA68607}.Debug|x64.ActiveCfg = Debug|x64 - {B7699B1D-905B-4EB2-AD28-79FF7EA68607}.Debug|x64.Build.0 = Debug|x64 - {B7699B1D-905B-4EB2-AD28-79FF7EA68607}.Release|x64.ActiveCfg = Release|x64 - {B7699B1D-905B-4EB2-AD28-79FF7EA68607}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1611AEAA-2623-41EB-917D-C82B96E6CF55} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/Line/Line/Line.cpp b/qt/dislpay/Line/Line/Line.cpp deleted file mode 100644 index cabfe7d..0000000 --- a/qt/dislpay/Line/Line/Line.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "Line.h" -#include -Line::Line(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - ui.line->setStyleSheet(""); - - - QPalette palette; - palette.setColor(QPalette::WindowText, Qt::red); - - ui.line->setPalette(palette); -} diff --git a/qt/dislpay/Line/Line/Line.h b/qt/dislpay/Line/Line/Line.h deleted file mode 100644 index 033f78e..0000000 --- a/qt/dislpay/Line/Line/Line.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_Line.h" - -class Line : public QMainWindow -{ - Q_OBJECT - -public: - Line(QWidget *parent = Q_NULLPTR); - -private: - Ui::LineClass ui; -}; diff --git a/qt/dislpay/Line/Line/Line.qrc b/qt/dislpay/Line/Line/Line.qrc deleted file mode 100644 index 9cc4d8b..0000000 --- a/qt/dislpay/Line/Line/Line.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dislpay/Line/Line/Line.ui b/qt/dislpay/Line/Line/Line.ui deleted file mode 100644 index 4508458..0000000 --- a/qt/dislpay/Line/Line/Line.ui +++ /dev/null @@ -1,111 +0,0 @@ - - - LineClass - - - - 0 - 0 - 875 - 689 - - - - Line - - - - - - 180 - 110 - 461 - 211 - - - - /*10进制 带引号*/ -QFrame[frameShape="4"] { - -color: rgb(170, 85, 255); -} - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - 180 - 290 - 441 - 16 - - - - QFrame { - color: rgb(85, 255, 127); -} - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - 170 - 420 - 491 - 16 - - - - QFrame { - color: rgb(170, 0, 255); -} - - - - QFrame::Plain - - - Qt::Horizontal - - - - - - - 0 - 0 - 875 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dislpay/Line/Line/Line.vcxproj b/qt/dislpay/Line/Line/Line.vcxproj deleted file mode 100644 index ba8ed4a..0000000 --- a/qt/dislpay/Line/Line/Line.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {B7699B1D-905B-4EB2-AD28-79FF7EA68607} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/Line/Line/main.cpp b/qt/dislpay/Line/Line/main.cpp deleted file mode 100644 index ad8b30a..0000000 --- a/qt/dislpay/Line/Line/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Line.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Line w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/OpenGLWidget/OpenGLWidget.sln b/qt/dislpay/OpenGLWidget/OpenGLWidget.sln deleted file mode 100644 index e8a9bc6..0000000 --- a/qt/dislpay/OpenGLWidget/OpenGLWidget.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30503.244 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenGLWidget", "OpenGLWidget\OpenGLWidget.vcxproj", "{F8714FEE-1F14-462B-B049-A868D0CEB01E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F8714FEE-1F14-462B-B049-A868D0CEB01E}.Debug|x64.ActiveCfg = Debug|x64 - {F8714FEE-1F14-462B-B049-A868D0CEB01E}.Debug|x64.Build.0 = Debug|x64 - {F8714FEE-1F14-462B-B049-A868D0CEB01E}.Release|x64.ActiveCfg = Release|x64 - {F8714FEE-1F14-462B-B049-A868D0CEB01E}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F29CFD2F-20BF-491A-90C5-988D4ADE96AA} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.cpp b/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.cpp deleted file mode 100644 index abd937a..0000000 --- a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "OpenGLWidget.h" -#include -#include -class GLWidget : public QOpenGLWidget, public QOpenGLFunctions { -public: - GLWidget(QWidget* parent) : QOpenGLWidget(parent) { - - } -protected: - void initializeGL() override - { - // throw std::logic_error("The method or operation is not implemented."); - initializeOpenGLFunctions(); - } - - - void paintGL() override - { - glClearColor(255, 255, 255, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - QPainter painter; - - painter.begin(this); - - painter.drawRect(QRect{ 10, 10, 50, 50 }); - - painter.end(); - - - glColor3b(0, 0, 0); - glBegin(GL_LINES); - - glVertex2f(0.0, 0.0); - - glVertex2f(0, 0.8); - - glEnd(); - - } - -}; - -OpenGLWidget::OpenGLWidget(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - - ui.verticalLayout->addWidget(new GLWidget(ui.centralWidget)); - -} diff --git a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.h b/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.h deleted file mode 100644 index aa2f489..0000000 --- a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_OpenGLWidget.h" - -class OpenGLWidget : public QMainWindow -{ - Q_OBJECT - -public: - OpenGLWidget(QWidget *parent = Q_NULLPTR); - -private: - Ui::OpenGLWidgetClass ui; -}; diff --git a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.qrc b/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.qrc deleted file mode 100644 index 87a3a3e..0000000 --- a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.ui b/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.ui deleted file mode 100644 index 00bfa16..0000000 --- a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.ui +++ /dev/null @@ -1,64 +0,0 @@ - - - OpenGLWidgetClass - - - - 0 - 0 - 904 - 412 - - - - OpenGLWidget - - - - - - 20 - 50 - 251 - 241 - - - - - - - 370 - 80 - 411 - 241 - - - - - - - - - 0 - 0 - 904 - 26 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.vcxproj b/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.vcxproj deleted file mode 100644 index 34d5aca..0000000 --- a/qt/dislpay/OpenGLWidget/OpenGLWidget/OpenGLWidget.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {F8714FEE-1F14-462B-B049-A868D0CEB01E} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/OpenGLWidget/OpenGLWidget/main.cpp b/qt/dislpay/OpenGLWidget/OpenGLWidget/main.cpp deleted file mode 100644 index e670883..0000000 --- a/qt/dislpay/OpenGLWidget/OpenGLWidget/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "OpenGLWidget.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - OpenGLWidget w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/ProgressBar/ProgressBar.sln b/qt/dislpay/ProgressBar/ProgressBar.sln deleted file mode 100644 index 139d5a5..0000000 --- a/qt/dislpay/ProgressBar/ProgressBar.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30413.136 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ProgressBar", "ProgressBar\ProgressBar.vcxproj", "{0D2F6E16-1E56-4B81-8708-0CAAF861A5D3}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0D2F6E16-1E56-4B81-8708-0CAAF861A5D3}.Debug|x64.ActiveCfg = Debug|x64 - {0D2F6E16-1E56-4B81-8708-0CAAF861A5D3}.Debug|x64.Build.0 = Debug|x64 - {0D2F6E16-1E56-4B81-8708-0CAAF861A5D3}.Release|x64.ActiveCfg = Release|x64 - {0D2F6E16-1E56-4B81-8708-0CAAF861A5D3}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {80C8E027-13F2-4A0B-A875-ADD6FF4172D3} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.cpp b/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.cpp deleted file mode 100644 index 0601a85..0000000 --- a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "ProgressBar.h" - -ProgressBar::ProgressBar(QWidget* parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - connect(ui.pushButton, &QPushButton::clicked, [this]() { - - ui.progressBar->setMaximum(100); - ui.progressBar->setValue(0); - - /// - /// long work. - /// - /// - for (int i = 0; i < 100; i++) { - ui.progressBar->setValue(i); - std::this_thread::sleep_for(std::chrono::milliseconds(200)); - QApplication::processEvents(); - } - - }); -} \ No newline at end of file diff --git a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.h b/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.h deleted file mode 100644 index 19a71f1..0000000 --- a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_ProgressBar.h" - -class ProgressBar : public QMainWindow -{ - Q_OBJECT - -public: - ProgressBar(QWidget *parent = Q_NULLPTR); - -private: - Ui::ProgressBarClass ui; -}; diff --git a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.qrc b/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.qrc deleted file mode 100644 index 2d15c82..0000000 --- a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.ui b/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.ui deleted file mode 100644 index 376b130..0000000 --- a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.ui +++ /dev/null @@ -1,69 +0,0 @@ - - - ProgressBarClass - - - - 0 - 0 - 600 - 400 - - - - ProgressBar - - - - - - 390 - 150 - 75 - 23 - - - - Start - - - - - - 80 - 240 - 471 - 23 - - - - 0 - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.vcxproj b/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.vcxproj deleted file mode 100644 index 2578218..0000000 --- a/qt/dislpay/ProgressBar/ProgressBar/ProgressBar.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {0D2F6E16-1E56-4B81-8708-0CAAF861A5D3} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/ProgressBar/ProgressBar/main.cpp b/qt/dislpay/ProgressBar/ProgressBar/main.cpp deleted file mode 100644 index bd5683c..0000000 --- a/qt/dislpay/ProgressBar/ProgressBar/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "ProgressBar.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - ProgressBar w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/QuickWidget/QuickWidget.sln b/qt/dislpay/QuickWidget/QuickWidget.sln deleted file mode 100644 index a8cc2f0..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30503.244 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QuickWidget", "QuickWidget\QuickWidget.vcxproj", "{3C0D82AA-902C-4271-AF4A-3B55075809F7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3C0D82AA-902C-4271-AF4A-3B55075809F7}.Debug|x64.ActiveCfg = Debug|x64 - {3C0D82AA-902C-4271-AF4A-3B55075809F7}.Debug|x64.Build.0 = Debug|x64 - {3C0D82AA-902C-4271-AF4A-3B55075809F7}.Release|x64.ActiveCfg = Release|x64 - {3C0D82AA-902C-4271-AF4A-3B55075809F7}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {14618D9D-BDA3-4162-BE0F-ACC126CF0665} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.cpp b/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.cpp deleted file mode 100644 index f896a59..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "QuickWidget.h" - -QuickWidget::QuickWidget(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); -} diff --git a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.h b/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.h deleted file mode 100644 index 090d469..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_QuickWidget.h" - -class QuickWidget : public QMainWindow -{ - Q_OBJECT - -public: - QuickWidget(QWidget *parent = Q_NULLPTR); - -private: - Ui::QuickWidgetClass ui; -}; diff --git a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.qrc b/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.qrc deleted file mode 100644 index 790777e..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - hello.qml - - diff --git a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.ui b/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.ui deleted file mode 100644 index 526f64a..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.ui +++ /dev/null @@ -1,68 +0,0 @@ - - - QuickWidgetClass - - - - 0 - 0 - 600 - 400 - - - - QuickWidget - - - - - - 100 - 40 - 191 - 181 - - - - QQuickWidget::SizeRootObjectToView - - - - qrc:/QuickWidget/hello.qml - - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - QQuickWidget - QWidget -
QtQuickWidgets/QQuickWidget
-
-
- - - - -
diff --git a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.vcxproj b/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.vcxproj deleted file mode 100644 index 7d49820..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget/QuickWidget.vcxproj +++ /dev/null @@ -1,107 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {3C0D82AA-902C-4271-AF4A-3B55075809F7} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;quick;quickcontrols2;quickwidgets;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - false - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/QuickWidget/QuickWidget/hello.qml b/qt/dislpay/QuickWidget/QuickWidget/hello.qml deleted file mode 100644 index 5295ff1..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget/hello.qml +++ /dev/null @@ -1,48 +0,0 @@ - import QtQuick 2.0 - import QtQuick.Controls 2.14 -import QtQuick.Layouts 1.14 - - Rectangle { - width: 200 - height: 200 - color: "red" - border.color: "black" - border.width: 5 - radius: 10 - - RowLayout { - - Button { - text: "Ok" - onClicked: { - - rc.color = "blue" - } - } - - Rectangle { - id: "rc" - width: 100 - height: 100 - color: "red" - border.color: "black" - border.width: 1 - radius: 10 - - MouseArea { - anchors.fill: parent - onClicked: { - console.log(parent.color); - - if (parent.color == "#000000"){ - parent.color="red"; - } - else{ - parent.color= "black"; - } - } - } - } - - } - } diff --git a/qt/dislpay/QuickWidget/QuickWidget/main.cpp b/qt/dislpay/QuickWidget/QuickWidget/main.cpp deleted file mode 100644 index 2dd7aed..0000000 --- a/qt/dislpay/QuickWidget/QuickWidget/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "QuickWidget.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - QuickWidget w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/TextBrower/TextBrower.sln b/qt/dislpay/TextBrower/TextBrower.sln deleted file mode 100644 index 7c06e87..0000000 --- a/qt/dislpay/TextBrower/TextBrower.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30320.27 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TextBrower", "TextBrower\TextBrower.vcxproj", "{C6CAC1A7-848C-4E8D-8407-6174F0229991}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C6CAC1A7-848C-4E8D-8407-6174F0229991}.Debug|x64.ActiveCfg = Debug|x64 - {C6CAC1A7-848C-4E8D-8407-6174F0229991}.Debug|x64.Build.0 = Debug|x64 - {C6CAC1A7-848C-4E8D-8407-6174F0229991}.Release|x64.ActiveCfg = Release|x64 - {C6CAC1A7-848C-4E8D-8407-6174F0229991}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BF04EA4B-7FD3-4D79-AB32-15F3554AFB3F} - EndGlobalSection -EndGlobal diff --git a/qt/dislpay/TextBrower/TextBrower/TextBrower.cpp b/qt/dislpay/TextBrower/TextBrower/TextBrower.cpp deleted file mode 100644 index 5e576a1..0000000 --- a/qt/dislpay/TextBrower/TextBrower/TextBrower.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "TextBrower.h" -#include -#include -TextBrower::TextBrower(QWidget* parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - ui.textBrowser->setSearchPaths({"./img"}); - ui.textBrowser->setSource(QUrl::fromLocalFile("./hello.html"), QTextDocument::ResourceType::HtmlResource); - - - qDebug() << "html:" << ui.textBrowser->toHtml(); - - connect(ui.textBrowser, &QTextBrowser::anchorClicked, [](const QUrl& link) { - qDebug() << link; - //QDesktopServices::openUrl(link); - }); - - connect(ui.pushButton, &QPushButton::clicked, [this]() { - - ui.textBrowser->backward(); - }); - connect(ui.pushButton_2, &QPushButton::clicked, [this]() { - ui.textBrowser->forward(); - }); - connect(ui.pushButton_3, &QPushButton::clicked, [this]() { - qDebug() << "html:" << ui.textBrowser->toHtml(); - }); -} diff --git a/qt/dislpay/TextBrower/TextBrower/TextBrower.h b/qt/dislpay/TextBrower/TextBrower/TextBrower.h deleted file mode 100644 index 2d0589c..0000000 --- a/qt/dislpay/TextBrower/TextBrower/TextBrower.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_TextBrower.h" - -class TextBrower : public QMainWindow -{ - Q_OBJECT - -public: - TextBrower(QWidget *parent = Q_NULLPTR); - -private: - Ui::TextBrowerClass ui; -}; diff --git a/qt/dislpay/TextBrower/TextBrower/TextBrower.qrc b/qt/dislpay/TextBrower/TextBrower/TextBrower.qrc deleted file mode 100644 index baaa5d6..0000000 --- a/qt/dislpay/TextBrower/TextBrower/TextBrower.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/dislpay/TextBrower/TextBrower/TextBrower.ui b/qt/dislpay/TextBrower/TextBrower/TextBrower.ui deleted file mode 100644 index 5a5f155..0000000 --- a/qt/dislpay/TextBrower/TextBrower/TextBrower.ui +++ /dev/null @@ -1,82 +0,0 @@ - - - TextBrowerClass - - - - 0 - 0 - 600 - 400 - - - - TextBrower - - - - - - - - - back - - - - - - - forward - - - - - - - - - - http://shelllet.com - - - - true - - - - - - - PushButton - - - - - - - - - 0 - 0 - 600 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/dislpay/TextBrower/TextBrower/TextBrower.vcxproj b/qt/dislpay/TextBrower/TextBrower/TextBrower.vcxproj deleted file mode 100644 index 3b646ff..0000000 --- a/qt/dislpay/TextBrower/TextBrower/TextBrower.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {C6CAC1A7-848C-4E8D-8407-6174F0229991} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/dislpay/TextBrower/TextBrower/hello.html b/qt/dislpay/TextBrower/TextBrower/hello.html deleted file mode 100644 index 35adc05..0000000 --- a/qt/dislpay/TextBrower/TextBrower/hello.html +++ /dev/null @@ -1,8 +0,0 @@ - -this is first. -
shelllet.com -
-当前目录 -hello2 - - diff --git a/qt/dislpay/TextBrower/TextBrower/hello2.html b/qt/dislpay/TextBrower/TextBrower/hello2.html deleted file mode 100644 index 63baf9d..0000000 --- a/qt/dislpay/TextBrower/TextBrower/hello2.html +++ /dev/null @@ -1,6 +0,0 @@ - -shelllet.com -
-当前目录 - -this is second \ No newline at end of file diff --git a/qt/dislpay/TextBrower/TextBrower/img/231102-151931226201f1.jpg b/qt/dislpay/TextBrower/TextBrower/img/231102-151931226201f1.jpg deleted file mode 100644 index 42aa8d5..0000000 Binary files a/qt/dislpay/TextBrower/TextBrower/img/231102-151931226201f1.jpg and /dev/null differ diff --git a/qt/dislpay/TextBrower/TextBrower/main.cpp b/qt/dislpay/TextBrower/TextBrower/main.cpp deleted file mode 100644 index d3ddaf2..0000000 --- a/qt/dislpay/TextBrower/TextBrower/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "TextBrower.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - TextBrower w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/label/.gitignore b/qt/dislpay/label/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/dislpay/label/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/dislpay/label/231102-151931226201f1.jpg b/qt/dislpay/label/231102-151931226201f1.jpg deleted file mode 100644 index 42aa8d5..0000000 Binary files a/qt/dislpay/label/231102-151931226201f1.jpg and /dev/null differ diff --git a/qt/dislpay/label/label.aps b/qt/dislpay/label/label.aps deleted file mode 100644 index c66fc50..0000000 Binary files a/qt/dislpay/label/label.aps and /dev/null differ diff --git a/qt/dislpay/label/label.pro b/qt/dislpay/label/label.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/dislpay/label/label.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/dislpay/label/label.qrc b/qt/dislpay/label/label.qrc deleted file mode 100644 index 434ac7a..0000000 --- a/qt/dislpay/label/label.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - 231102-151931226201f1.jpg - - diff --git a/qt/dislpay/label/main.cpp b/qt/dislpay/label/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/dislpay/label/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/dislpay/label/mainwindow.cpp b/qt/dislpay/label/mainwindow.cpp deleted file mode 100644 index 7c93e84..0000000 --- a/qt/dislpay/label/mainwindow.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include -#include -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - //QMovie* movie = new QMovie(QString::fromStdWString(L"./Screen.mp4")); - QMovie* movie = new QMovie(QString::fromStdWString(L"./timg.gif")); - ui->label_5->setMovie(movie); - movie->start(); - - /// ui->label->setPixmap(QPixmap("./231102-151931226201f1.jpg")); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/dislpay/label/mainwindow.h b/qt/dislpay/label/mainwindow.h deleted file mode 100644 index 4643e32..0000000 --- a/qt/dislpay/label/mainwindow.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/dislpay/label/mainwindow.ui b/qt/dislpay/label/mainwindow.ui deleted file mode 100644 index 28a40ee..0000000 --- a/qt/dislpay/label/mainwindow.ui +++ /dev/null @@ -1,170 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 30 - 290 - 200 - 200 - - - - - 0 - 0 - - - - - 200 - 200 - - - - - 200 - 200 - - - - - - - :/img/231102-151931226201f1.jpg - - - true - - - - - - 420 - 60 - 211 - 41 - - - - <html><head/><body><p><a href="http://www.baidu.com"><span style=" text-decoration: underline; color:#0000ff;">http://www.baidu.com</span></a></p></body></html> - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - 6 - - - 6 - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - 210 - 156 - 191 - 20 - - - - &Name - - - lineEdit - - - - - - 300 - 160 - 113 - 20 - - - - - - - 300 - 200 - 113 - 20 - - - - - - - 200 - 200 - 191 - 16 - - - - &Phone - - - lineEdit_2 - - - - - - 510 - 380 - 191 - 111 - - - - TextLabel - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - - - diff --git a/qt/dislpay/label/release/moc_predefs.h.cbt b/qt/dislpay/label/release/moc_predefs.h.cbt deleted file mode 100644 index 92a8741..0000000 --- a/qt/dislpay/label/release/moc_predefs.h.cbt +++ /dev/null @@ -1 +0,0 @@ -This is a dummy file needed to create release/moc_predefs.h diff --git a/qt/dislpay/label/release/qmake/qtvars_x64_Release.props b/qt/dislpay/label/release/qmake/qtvars_x64_Release.props deleted file mode 100644 index ed1a214..0000000 --- a/qt/dislpay/label/release/qmake/qtvars_x64_Release.props +++ /dev/null @@ -1,57 +0,0 @@ - - -UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;NDEBUG;QT_NO_DEBUG;QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB -D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\include;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\include\QtWidgets;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\include\QtGui;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\include\QtANGLE;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\include\QtCore;/include;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\mkspecs\win32-msvc -D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\lib\Qt5Widgets.lib;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\lib\Qt5Gui.lib;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\lib\Qt5Core.lib;D:\Qt5\Qt5.14.2\5.14.2\msvc2017_64\lib\qtmain.lib;shell32.lib -C:\openssl\lib;C:\Utils\my_sql\mysql-5.7.25-winx64\lib;C:\Utils\postgresql\pgsql\lib - -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64 -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64 -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64 -D:/Qt5/Qt5.14.2/Docs/Qt-5.14.2 -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/include -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/lib -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/bin -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/bin -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/tests -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/plugins -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/imports -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/qml -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/translations - -D:/Qt5/Qt5.14.2/Examples/Qt-5.14.2 -D:/Qt5/Qt5.14.2/Examples/Qt-5.14.2 -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64 -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64 -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/bin -D:/Qt5/Qt5.14.2/5.14.2/msvc2017_64/lib -win32-msvc -win32-msvc -3.1 -5.14.2 -$(Qt_INCLUDEPATH_);Release;D:\qt\A\dislpay\label - msvc2017_64 - core;gui;widgets - bin - bin - - - DEFINES=/-D([^\s=]+(=(\x22(\\\\|\\\x22|[^\x22])*\x22|\S+))?)/$1/;INCLUDEPATH=INCPATH/-I(\x22[^\x22]+\x22|[^\s]+)/$1/;LIBS=/(?:\/LIBPATH:(?:\x22[^\x22]+\x22|[^\s]+))|(\x22[^\x22]+\x22|[^\s]+)/$1/;LIBPATH=LIBS/\/LIBPATH:(\x22[^\x22]+\x22|[^\s]+)/$1/ - - release - 5.14.2 - 5 - 14 - 2 - - diff --git a/qt/dislpay/label/resource.h b/qt/dislpay/label/resource.h deleted file mode 100644 index 282c6a1..0000000 --- a/qt/dislpay/label/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by label.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/qt/dislpay/label/timg.gif b/qt/dislpay/label/timg.gif deleted file mode 100644 index def90bf..0000000 Binary files a/qt/dislpay/label/timg.gif and /dev/null differ diff --git a/qt/formlayout/formlayout.pro b/qt/formlayout/formlayout.pro deleted file mode 100644 index 600a688..0000000 --- a/qt/formlayout/formlayout.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-06-25T21:30:29 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = formlayout -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/formlayout/main.cpp b/qt/formlayout/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/formlayout/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/formlayout/mainwindow.cpp b/qt/formlayout/mainwindow.cpp deleted file mode 100644 index bb43601..0000000 --- a/qt/formlayout/mainwindow.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - labelUser_ = new QLabel(ui->centralWidget); - labelPassword_ = new QLabel(ui->centralWidget); - - labelUser_->setText("userName"); - labelPassword_->setText("password"); - - - fieldUser_ = new QLineEdit(ui->centralWidget); - fieldPassword_ = new QLineEdit(ui->centralWidget); - - - layout_ = new QFormLayout(ui->frame); - - - layout_->addRow(labelUser_, fieldUser_); - - layout_->addRow(labelPassword_, fieldPassword_); - - -} - -MainWindow::~MainWindow() -{ - delete ui; -} diff --git a/qt/formlayout/mainwindow.h b/qt/formlayout/mainwindow.h deleted file mode 100644 index 86941b7..0000000 --- a/qt/formlayout/mainwindow.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - - - QLabel* labelUser_; - QLabel* labelPassword_; - - QLineEdit* fieldUser_; - QLineEdit* fieldPassword_; - - - QFormLayout* layout_; - -}; - -#endif // MAINWINDOW_H diff --git a/qt/formlayout/mainwindow.ui b/qt/formlayout/mainwindow.ui deleted file mode 100644 index 4c1e5ca..0000000 --- a/qt/formlayout/mainwindow.ui +++ /dev/null @@ -1,106 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 627 - 424 - - - - MainWindow - - - - - - 280 - 240 - 75 - 23 - - - - 登录 - - - - - - 70 - 70 - 251 - 141 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - 410 - 170 - 189 - 48 - - - - - - - 用户名: - - - - - - - - - - 密码: - - - - - - - QLineEdit::PasswordEchoOnEdit - - - - - - - - - - 0 - 0 - 627 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/gridlayout/gridlayout.pro b/qt/gridlayout/gridlayout.pro deleted file mode 100644 index 20816ef..0000000 --- a/qt/gridlayout/gridlayout.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-06-09T17:03:31 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = gridlayout -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/gridlayout/main.cpp b/qt/gridlayout/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/gridlayout/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/gridlayout/mainwindow.cpp b/qt/gridlayout/mainwindow.cpp deleted file mode 100644 index 8ef6649..0000000 --- a/qt/gridlayout/mainwindow.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - layout_ = new QGridLayout(ui->centralWidget); - - size_t index = 0; - for (int i = 0; i < 3; ++i) { - - for (int j = 0; j< 3; ++j) { - buttons_[index] = new QPushButton(QString("%1*%2=%3").arg(i).arg(j).arg(i*j), ui->centralWidget); - layout_->addWidget(buttons_[index], i, j); - index++; - } - - } - - layout_->setSpacing(9); -} - -MainWindow::~MainWindow() -{ - delete ui; -} diff --git a/qt/gridlayout/mainwindow.h b/qt/gridlayout/mainwindow.h deleted file mode 100644 index b88db32..0000000 --- a/qt/gridlayout/mainwindow.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - - QGridLayout * layout_ = nullptr; - - std::array buttons_; -}; - -#endif // MAINWINDOW_H diff --git a/qt/gridlayout/mainwindow.ui b/qt/gridlayout/mainwindow.ui deleted file mode 100644 index 2f12a72..0000000 --- a/qt/gridlayout/mainwindow.ui +++ /dev/null @@ -1,40 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 696 - 483 - - - - MainWindow - - - - - - 0 - 0 - 696 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/input/DateTime/DateTime.sln b/qt/input/DateTime/DateTime.sln deleted file mode 100644 index 7ff5bfc..0000000 --- a/qt/input/DateTime/DateTime.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30225.117 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DateTime", "DateTime\DateTime.vcxproj", "{82DC5F83-8E63-409C-8543-CEEF1DED500C}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {82DC5F83-8E63-409C-8543-CEEF1DED500C}.Debug|x64.ActiveCfg = Debug|x64 - {82DC5F83-8E63-409C-8543-CEEF1DED500C}.Debug|x64.Build.0 = Debug|x64 - {82DC5F83-8E63-409C-8543-CEEF1DED500C}.Release|x64.ActiveCfg = Release|x64 - {82DC5F83-8E63-409C-8543-CEEF1DED500C}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {0A432844-C134-4D64-AB7C-1773AB8FC9BA} - EndGlobalSection -EndGlobal diff --git a/qt/input/DateTime/DateTime/DateTime.cpp b/qt/input/DateTime/DateTime/DateTime.cpp deleted file mode 100644 index 3b262cf..0000000 --- a/qt/input/DateTime/DateTime/DateTime.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "DateTime.h" -#include - -//https://bugreports.qt.io/browse/QTBUG-34759 -DateTime::DateTime(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); -} diff --git a/qt/input/DateTime/DateTime/DateTime.h b/qt/input/DateTime/DateTime/DateTime.h deleted file mode 100644 index 6dedcfc..0000000 --- a/qt/input/DateTime/DateTime/DateTime.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_DateTime.h" - -class DateTime : public QMainWindow -{ - Q_OBJECT - -public: - DateTime(QWidget *parent = Q_NULLPTR); - -private: - Ui::DateTimeClass ui; -}; diff --git a/qt/input/DateTime/DateTime/DateTime.qrc b/qt/input/DateTime/DateTime/DateTime.qrc deleted file mode 100644 index 0912b44..0000000 --- a/qt/input/DateTime/DateTime/DateTime.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/input/DateTime/DateTime/DateTime.ui b/qt/input/DateTime/DateTime/DateTime.ui deleted file mode 100644 index 0f265b9..0000000 --- a/qt/input/DateTime/DateTime/DateTime.ui +++ /dev/null @@ -1,91 +0,0 @@ - - - DateTimeClass - - - - 0 - 0 - 600 - 400 - - - - DateTime - - - - - - 190 - 100 - 110 - 22 - - - - QDateTimeEdit::DaySection - - - 2 - - - - - - 180 - 140 - 194 - 22 - - - - QDateTimeEdit::MinuteSection - - - true - - - 5 - - - Qt::LocalTime - - - - - - 180 - 180 - 118 - 22 - - - - - - - - 0 - 0 - 600 - 21 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/input/DateTime/DateTime/DateTime.vcxproj b/qt/input/DateTime/DateTime/DateTime.vcxproj deleted file mode 100644 index 57adbe5..0000000 --- a/qt/input/DateTime/DateTime/DateTime.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {82DC5F83-8E63-409C-8543-CEEF1DED500C} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/input/DateTime/DateTime/main.cpp b/qt/input/DateTime/DateTime/main.cpp deleted file mode 100644 index 4c2cebd..0000000 --- a/qt/input/DateTime/DateTime/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "DateTime.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - DateTime w; - w.show(); - return a.exec(); -} diff --git a/qt/input/KeySequence/KeySequence.sln b/qt/input/KeySequence/KeySequence.sln deleted file mode 100644 index 9d7973a..0000000 --- a/qt/input/KeySequence/KeySequence.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30225.117 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KeySequence", "KeySequence\KeySequence.vcxproj", "{A3534E22-5AC0-4D17-8621-5463A80BDA26}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A3534E22-5AC0-4D17-8621-5463A80BDA26}.Debug|x64.ActiveCfg = Debug|x64 - {A3534E22-5AC0-4D17-8621-5463A80BDA26}.Debug|x64.Build.0 = Debug|x64 - {A3534E22-5AC0-4D17-8621-5463A80BDA26}.Release|x64.ActiveCfg = Release|x64 - {A3534E22-5AC0-4D17-8621-5463A80BDA26}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {86B8806E-1DD0-45C0-B16A-4939E98080B4} - EndGlobalSection -EndGlobal diff --git a/qt/input/KeySequence/KeySequence/KeySequence.cpp b/qt/input/KeySequence/KeySequence/KeySequence.cpp deleted file mode 100644 index 0392a00..0000000 --- a/qt/input/KeySequence/KeySequence/KeySequence.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "KeySequence.h" -#include "QtNewWidgets.h" - -KeySequence::KeySequence(QWidget* parent) - : QMainWindow(parent) - , shortcut(this) -{ - ui.setupUi(this); - - connect(ui.actionopen, &QAction::triggered, [this]() { - options.show(); - }); - - - - shortcut.setKey(options.getSequence()); - - connect(&shortcut, &QShortcut::activated, [this]() { - QtNewWidgets* widget = new QtNewWidgets(); - widget->show(); - - connect(widget, &QtNewWidgets::closed, [widget]() { widget->deleteLater(); }); - }); -} diff --git a/qt/input/KeySequence/KeySequence/KeySequence.h b/qt/input/KeySequence/KeySequence/KeySequence.h deleted file mode 100644 index 49fbf70..0000000 --- a/qt/input/KeySequence/KeySequence/KeySequence.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include -#include "ui_KeySequence.h" -#include -#include "Options.h" -class KeySequence : public QMainWindow -{ - Q_OBJECT - -public: - KeySequence(QWidget *parent = Q_NULLPTR); - -private: - Ui::KeySequenceClass ui; - - QShortcut shortcut; - - Options options; -}; diff --git a/qt/input/KeySequence/KeySequence/KeySequence.qrc b/qt/input/KeySequence/KeySequence/KeySequence.qrc deleted file mode 100644 index 6a74d05..0000000 --- a/qt/input/KeySequence/KeySequence/KeySequence.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/input/KeySequence/KeySequence/KeySequence.ui b/qt/input/KeySequence/KeySequence/KeySequence.ui deleted file mode 100644 index 599ec56..0000000 --- a/qt/input/KeySequence/KeySequence/KeySequence.ui +++ /dev/null @@ -1,54 +0,0 @@ - - - KeySequenceClass - - - - 0 - 0 - 600 - 400 - - - - KeySequence - - - - - - 0 - 0 - 600 - 23 - - - - - File - - - - - - - - TopToolBarArea - - - false - - - - - - setting - - - - - - - - - diff --git a/qt/input/KeySequence/KeySequence/KeySequence.vcxproj b/qt/input/KeySequence/KeySequence/KeySequence.vcxproj deleted file mode 100644 index 8a07d2a..0000000 --- a/qt/input/KeySequence/KeySequence/KeySequence.vcxproj +++ /dev/null @@ -1,111 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {A3534E22-5AC0-4D17-8621-5463A80BDA26} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/input/KeySequence/KeySequence/Options.cpp b/qt/input/KeySequence/KeySequence/Options.cpp deleted file mode 100644 index 34507df..0000000 --- a/qt/input/KeySequence/KeySequence/Options.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "Options.h" - -Options::Options(QWidget *parent) - : QWidget(parent) - , setting("Shelllet") - -{ - ui.setupUi(this); - - connect(ui.keySequenceEdit, &QKeySequenceEdit::keySequenceChanged, [this]() { - setting.setValue("open", ui.keySequenceEdit->keySequence()); - - }); - - if (setting.contains("open")) { - ui.keySequenceEdit->setKeySequence(setting.value("open").value()); - } -} - -Options::~Options() -{ -} - -QKeySequence Options::getSequence() -{ - return ui.keySequenceEdit->keySequence(); -} diff --git a/qt/input/KeySequence/KeySequence/Options.h b/qt/input/KeySequence/KeySequence/Options.h deleted file mode 100644 index 5d9a5ae..0000000 --- a/qt/input/KeySequence/KeySequence/Options.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -#include -#include "ui_Options.h" -#include -#include - -class Options : public QWidget -{ - Q_OBJECT - -public: - Options(QWidget *parent = Q_NULLPTR); - ~Options(); - - QKeySequence getSequence(); -private: - Ui::Options ui; - - QSettings setting; -}; diff --git a/qt/input/KeySequence/KeySequence/Options.ui b/qt/input/KeySequence/KeySequence/Options.ui deleted file mode 100644 index c4a93df..0000000 --- a/qt/input/KeySequence/KeySequence/Options.ui +++ /dev/null @@ -1,46 +0,0 @@ - - - Options - - - - 0 - 0 - 400 - 300 - - - - Options - - - - - 190 - 70 - 113 - 20 - - - - Ctrl+O - - - - - - 130 - 70 - 54 - 12 - - - - 打开窗口 - - - - - - - diff --git a/qt/input/KeySequence/KeySequence/QtNewWidgets.cpp b/qt/input/KeySequence/KeySequence/QtNewWidgets.cpp deleted file mode 100644 index 6c58954..0000000 --- a/qt/input/KeySequence/KeySequence/QtNewWidgets.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "QtNewWidgets.h" - -QtNewWidgets::QtNewWidgets(QWidget *parent) - : QWidget(parent) -{ - ui.setupUi(this); -} - -QtNewWidgets::~QtNewWidgets() -{ -} - -void QtNewWidgets::closeEvent(QCloseEvent* event) -{ - emit closed(); -} \ No newline at end of file diff --git a/qt/input/KeySequence/KeySequence/QtNewWidgets.h b/qt/input/KeySequence/KeySequence/QtNewWidgets.h deleted file mode 100644 index 8c60cc7..0000000 --- a/qt/input/KeySequence/KeySequence/QtNewWidgets.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include -#include "ui_QtNewWidgets.h" - -class QtNewWidgets : public QWidget -{ - Q_OBJECT - -public: - QtNewWidgets(QWidget *parent = Q_NULLPTR); - ~QtNewWidgets(); - -signals: - void closed(); -private: - Ui::QtNewWidgets ui; - -protected: - void closeEvent(QCloseEvent* event) override; - -}; diff --git a/qt/input/KeySequence/KeySequence/QtNewWidgets.ui b/qt/input/KeySequence/KeySequence/QtNewWidgets.ui deleted file mode 100644 index ec35ab4..0000000 --- a/qt/input/KeySequence/KeySequence/QtNewWidgets.ui +++ /dev/null @@ -1,23 +0,0 @@ - - QtNewWidgets - - - QtNewWidgets - - - - 0 - 0 - 400 - 300 - - - - QtNewWidgets - - - - - - - diff --git a/qt/input/KeySequence/KeySequence/main.cpp b/qt/input/KeySequence/KeySequence/main.cpp deleted file mode 100644 index 7f9265e..0000000 --- a/qt/input/KeySequence/KeySequence/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "KeySequence.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - KeySequence w; - w.show(); - return a.exec(); -} diff --git a/qt/input/PlainTextEdit/PlainTextEdit.sln b/qt/input/PlainTextEdit/PlainTextEdit.sln deleted file mode 100644 index 595d5ad..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30114.105 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PlainTextEdit", "PlainTextEdit\PlainTextEdit.vcxproj", "{3632D016-3D3C-46EE-AB48-8F7D30B60890}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3632D016-3D3C-46EE-AB48-8F7D30B60890}.Debug|x64.ActiveCfg = Debug|x64 - {3632D016-3D3C-46EE-AB48-8F7D30B60890}.Debug|x64.Build.0 = Debug|x64 - {3632D016-3D3C-46EE-AB48-8F7D30B60890}.Release|x64.ActiveCfg = Release|x64 - {3632D016-3D3C-46EE-AB48-8F7D30B60890}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1099F6C9-74E5-42C5-AF8E-F2E5B2E7340B} - EndGlobalSection -EndGlobal diff --git a/qt/input/PlainTextEdit/PlainTextEdit/MyHighlighter.cpp b/qt/input/PlainTextEdit/PlainTextEdit/MyHighlighter.cpp deleted file mode 100644 index 37efadc..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/MyHighlighter.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "MyHighlighter.h" -#include -#include -#include - -MyHighlighter::MyHighlighter(QObject *parent) - : QSyntaxHighlighter(parent) -{ -} - -MyHighlighter::~MyHighlighter() -{ -} - - - -void MyHighlighter::highlightBlock(const QString& text) -{ - QTextCharFormat myClassFormat; - myClassFormat.setFontWeight(QFont::Bold); - myClassFormat.setForeground(Qt::darkMagenta); - - QRegularExpression expression("\\bQt\\b"); - QRegularExpressionMatchIterator i = expression.globalMatch(text); - while (i.hasNext()) - { - QRegularExpressionMatch match = i.next(); - setFormat(match.capturedStart(), match.capturedLength(), myClassFormat); - } -} diff --git a/qt/input/PlainTextEdit/PlainTextEdit/MyHighlighter.h b/qt/input/PlainTextEdit/PlainTextEdit/MyHighlighter.h deleted file mode 100644 index a7123f7..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/MyHighlighter.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include - -class MyHighlighter : public QSyntaxHighlighter -{ - Q_OBJECT - -public: - MyHighlighter(QObject *parent); - ~MyHighlighter(); - - -protected: - void highlightBlock(const QString& text) override; - -}; diff --git a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.cpp b/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.cpp deleted file mode 100644 index e740a2b..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "PlainTextEdit.h" -#include "MyHighlighter.h" - -PlainTextEdit::PlainTextEdit(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - MyHighlighter* highlighter = new MyHighlighter(this); - - highlighter->setDocument(ui.plainTextEdit->document()); - - //ui.plainTextEdit->setReadOnly(true); - ui.plainTextEdit->installEventFilter(this); -} -bool PlainTextEdit::eventFilter(QObject* watched, QEvent* event) -{ - if (watched == ui.plainTextEdit && event->type() == QEvent::Wheel) - { - QWheelEvent* wheel = static_cast(event); - if (wheel->modifiers() == Qt::ControlModifier) - if (wheel->delta() > 0) - ui.plainTextEdit->zoomIn(2); - else - ui.plainTextEdit->zoomOut(2); - - } - return false; -} \ No newline at end of file diff --git a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.h b/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.h deleted file mode 100644 index c7c019c..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include -#include "ui_PlainTextEdit.h" - -class PlainTextEdit : public QMainWindow -{ - Q_OBJECT - -public: - PlainTextEdit(QWidget *parent = Q_NULLPTR); - bool eventFilter(QObject* watched, QEvent* event) override; - -private: - Ui::PlainTextEditClass ui; -}; diff --git a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.qrc b/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.qrc deleted file mode 100644 index fc35468..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.ui b/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.ui deleted file mode 100644 index d0ed974..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.ui +++ /dev/null @@ -1,75 +0,0 @@ - - - PlainTextEditClass - - - - 0 - 0 - 840 - 587 - - - - PlainTextEdit - - - - - - - -Qt::UpArrow -Moves one line up. -Qt::DownArrow -Moves one line down. -Qt::LeftArrow -Moves one character to the left. -Qt::RightArrow -Moves one character to the right. -PageUp -Moves one (viewport) page up. -PageDown -Moves one (viewport) page down. -Home -Moves to the beginning of the text. -End -Moves to the end of the text. -Alt+Wheel -Scrolls the page horizontally (the Wheel is the mouse wheel). -Ctrl+Wheel -Zooms the text. -Ctrl+A -Selects all text. - - - - - - - - - - 0 - 0 - 840 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.vcxproj b/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.vcxproj deleted file mode 100644 index fb67ee2..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/PlainTextEdit.vcxproj +++ /dev/null @@ -1,101 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {3632D016-3D3C-46EE-AB48-8F7D30B60890} - QtVS_v302 - 10.0.18362.0 - 10.0.18362.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/input/PlainTextEdit/PlainTextEdit/main.cpp b/qt/input/PlainTextEdit/PlainTextEdit/main.cpp deleted file mode 100644 index e881126..0000000 --- a/qt/input/PlainTextEdit/PlainTextEdit/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "PlainTextEdit.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - PlainTextEdit w; - w.show(); - return a.exec(); -} diff --git a/qt/input/Slider/Slider.sln b/qt/input/Slider/Slider.sln deleted file mode 100644 index 7a9396b..0000000 --- a/qt/input/Slider/Slider.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30225.117 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Slider", "Slider\Slider.vcxproj", "{76B9C0C5-8693-4BE6-A7B3-9500362C870E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {76B9C0C5-8693-4BE6-A7B3-9500362C870E}.Debug|x64.ActiveCfg = Debug|x64 - {76B9C0C5-8693-4BE6-A7B3-9500362C870E}.Debug|x64.Build.0 = Debug|x64 - {76B9C0C5-8693-4BE6-A7B3-9500362C870E}.Release|x64.ActiveCfg = Release|x64 - {76B9C0C5-8693-4BE6-A7B3-9500362C870E}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A65122F5-713E-4038-A5AB-82B5A4FFBBA3} - EndGlobalSection -EndGlobal diff --git a/qt/input/Slider/Slider/Slider.cpp b/qt/input/Slider/Slider/Slider.cpp deleted file mode 100644 index 8062012..0000000 --- a/qt/input/Slider/Slider/Slider.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "Slider.h" - -Slider::Slider(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); - - connect(ui.horizontalSlider, &QSlider::valueChanged, [this](int value) { - - ui.lineEdit->setText(QString("%1").arg(value)); - - }); -} diff --git a/qt/input/Slider/Slider/Slider.h b/qt/input/Slider/Slider/Slider.h deleted file mode 100644 index 28454e0..0000000 --- a/qt/input/Slider/Slider/Slider.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_Slider.h" - -class Slider : public QMainWindow -{ - Q_OBJECT - -public: - Slider(QWidget *parent = Q_NULLPTR); - -private: - Ui::SliderClass ui; -}; diff --git a/qt/input/Slider/Slider/Slider.qrc b/qt/input/Slider/Slider/Slider.qrc deleted file mode 100644 index ac04453..0000000 --- a/qt/input/Slider/Slider/Slider.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/input/Slider/Slider/Slider.ui b/qt/input/Slider/Slider/Slider.ui deleted file mode 100644 index 11d4ccb..0000000 --- a/qt/input/Slider/Slider/Slider.ui +++ /dev/null @@ -1,100 +0,0 @@ - - - SliderClass - - - - 0 - 0 - 626 - 450 - - - - Slider - - - - - - 50 - 50 - 141 - 251 - - - - 50 - - - Qt::Vertical - - - false - - - false - - - true - - - true - - - - - - 100 - 300 - 211 - 22 - - - - false - - - Qt::Horizontal - - - QSlider::TicksAbove - - - - - - 390 - 310 - 113 - 20 - - - - - - - - 0 - 0 - 626 - 21 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/input/Slider/Slider/Slider.vcxproj b/qt/input/Slider/Slider/Slider.vcxproj deleted file mode 100644 index 29939df..0000000 --- a/qt/input/Slider/Slider/Slider.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {76B9C0C5-8693-4BE6-A7B3-9500362C870E} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/input/Slider/Slider/main.cpp b/qt/input/Slider/Slider/main.cpp deleted file mode 100644 index e310dc6..0000000 --- a/qt/input/Slider/Slider/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Slider.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Slider w; - w.show(); - return a.exec(); -} diff --git a/qt/input/Spinbox/Spinbox.sln b/qt/input/Spinbox/Spinbox.sln deleted file mode 100644 index 17d16fd..0000000 --- a/qt/input/Spinbox/Spinbox.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30204.135 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Spinbox", "Spinbox\Spinbox.vcxproj", "{2B34BEE7-3452-4DAD-BC26-81960498C769}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2B34BEE7-3452-4DAD-BC26-81960498C769}.Debug|x64.ActiveCfg = Debug|x64 - {2B34BEE7-3452-4DAD-BC26-81960498C769}.Debug|x64.Build.0 = Debug|x64 - {2B34BEE7-3452-4DAD-BC26-81960498C769}.Release|x64.ActiveCfg = Release|x64 - {2B34BEE7-3452-4DAD-BC26-81960498C769}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2317AB8B-46B6-4FC3-8DC3-1B69DC061743} - EndGlobalSection -EndGlobal diff --git a/qt/input/Spinbox/Spinbox/Spinbox.cpp b/qt/input/Spinbox/Spinbox/Spinbox.cpp deleted file mode 100644 index bd0f40f..0000000 --- a/qt/input/Spinbox/Spinbox/Spinbox.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "Spinbox.h" - -Spinbox::Spinbox(QWidget *parent) - : QMainWindow(parent) -{ - ui.setupUi(this); -} diff --git a/qt/input/Spinbox/Spinbox/Spinbox.h b/qt/input/Spinbox/Spinbox/Spinbox.h deleted file mode 100644 index 32b039f..0000000 --- a/qt/input/Spinbox/Spinbox/Spinbox.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include -#include "ui_Spinbox.h" - -class Spinbox : public QMainWindow -{ - Q_OBJECT - -public: - Spinbox(QWidget *parent = Q_NULLPTR); - -private: - Ui::SpinboxClass ui; -}; diff --git a/qt/input/Spinbox/Spinbox/Spinbox.qrc b/qt/input/Spinbox/Spinbox/Spinbox.qrc deleted file mode 100644 index 4748642..0000000 --- a/qt/input/Spinbox/Spinbox/Spinbox.qrc +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/qt/input/Spinbox/Spinbox/Spinbox.ui b/qt/input/Spinbox/Spinbox/Spinbox.ui deleted file mode 100644 index a9233c8..0000000 --- a/qt/input/Spinbox/Spinbox/Spinbox.ui +++ /dev/null @@ -1,114 +0,0 @@ - - - SpinboxClass - - - - 0 - 0 - 600 - 400 - - - - Spinbox - - - - - - 130 - 110 - 171 - 22 - - - - true - - - QAbstractSpinBox::PlusMinus - - - - - - true - - - QAbstractSpinBox::CorrectToNearestValue - - - true - - - cm - - - - - - 10 - - - 1 - - - QAbstractSpinBox::DefaultStepType - - - 10 - - - - - - 120 - 170 - 341 - 22 - - - - true - - - QAbstractSpinBox::PlusMinus - - - false - - - 3 - - - 9999999.990000000223517 - - - - - - - 0 - 0 - 600 - 21 - - - - - - TopToolBarArea - - - false - - - - - - - - - - diff --git a/qt/input/Spinbox/Spinbox/Spinbox.vcxproj b/qt/input/Spinbox/Spinbox/Spinbox.vcxproj deleted file mode 100644 index 9950c45..0000000 --- a/qt/input/Spinbox/Spinbox/Spinbox.vcxproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - {2B34BEE7-3452-4DAD-BC26-81960498C769} - QtVS_v303 - 10.0.19041.0 - 10.0.19041.0 - $(MSBuildProjectDirectory)\QtMsBuild - - - - Application - v142 - - - Application - v142 - - - - - - - - - - - - - - - - - - - - - - - msvc2017_64 - core;gui;widgets - debug - - - msvc2017_64 - core;gui;widgets - release - - - - - - - true - true - ProgramDatabase - Disabled - MultiThreadedDebugDLL - - - Windows - true - - - - - true - true - None - MaxSpeed - MultiThreadedDLL - - - Windows - false - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/qt/input/Spinbox/Spinbox/main.cpp b/qt/input/Spinbox/Spinbox/main.cpp deleted file mode 100644 index 49b6eca..0000000 --- a/qt/input/Spinbox/Spinbox/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Spinbox.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - Spinbox w; - w.show(); - return a.exec(); -} diff --git a/qt/input/TextEdit/.gitignore b/qt/input/TextEdit/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/input/TextEdit/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/input/TextEdit/TextEdit.pro b/qt/input/TextEdit/TextEdit.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/input/TextEdit/TextEdit.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/input/TextEdit/main.cpp b/qt/input/TextEdit/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/input/TextEdit/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/input/TextEdit/mainwindow.cpp b/qt/input/TextEdit/mainwindow.cpp deleted file mode 100644 index 5341601..0000000 --- a/qt/input/TextEdit/mainwindow.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_pushButton_clicked() -{ - qDebug() << ui->textEdit->toMarkdown(); -} diff --git a/qt/input/TextEdit/mainwindow.h b/qt/input/TextEdit/mainwindow.h deleted file mode 100644 index 9fb63ce..0000000 --- a/qt/input/TextEdit/mainwindow.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/input/TextEdit/mainwindow.ui b/qt/input/TextEdit/mainwindow.ui deleted file mode 100644 index 6225383..0000000 --- a/qt/input/TextEdit/mainwindow.ui +++ /dev/null @@ -1,59 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - - QTextEdit::AutoBulletList - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;"> -<ul style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style="" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Bird</li> -<li style="" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Magic</li></ul></body></html> - - - false - - - - - - - PushButton - - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/input/combobox/.gitignore b/qt/input/combobox/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/input/combobox/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/input/combobox/combobox.pro b/qt/input/combobox/combobox.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/input/combobox/combobox.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/input/combobox/main.cpp b/qt/input/combobox/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/input/combobox/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/input/combobox/mainwindow.cpp b/qt/input/combobox/mainwindow.cpp deleted file mode 100644 index 91bc5fa..0000000 --- a/qt/input/combobox/mainwindow.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" -#include -#include -#include -class ItemDelegate : public QItemDelegate{ - - - // QAbstractItemDelegate interface -public: - - - // QAbstractItemDelegate interface -public: - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const - { - -// auto text = index.data().toString(); - -// QStyleOptionButton buttonOption; -// buttonOption.rect = option.rect; - -// buttonOption.text = text + "%"; - - -// QApplication::style()->drawControl(QStyle::CE_PushButton, -// &buttonOption, painter); - QItemDelegate::paint(painter, option, index); - - } - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const{ - return QSize(100, 20); - } - - // QAbstractItemDelegate interface -public: - bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) - { - return true; - } -}; - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - //ui->comboBox->setModel(ui->treeWidget->model()); - //ui->comboBox->setView(ui->treeWidget); - - ui->comboBox->view()->setEditTriggers(QAbstractItemView::EditTrigger::AllEditTriggers); - - - QStringList wordList; - wordList << "alpha" << "omega" << "omicron" << "zeta"; - - - QCompleter *completer = new QCompleter(wordList, this); - completer->setCaseSensitivity(Qt::CaseInsensitive); - ui->comboBox->setCompleter(completer); - - ui->comboBox->setItemDelegate(new ItemDelegate); - -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - - -void MainWindow::on_pushButton_clicked() -{ - ui->comboBox->showPopup(); -} diff --git a/qt/input/combobox/mainwindow.h b/qt/input/combobox/mainwindow.h deleted file mode 100644 index 8b114cf..0000000 --- a/qt/input/combobox/mainwindow.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - - void on_pushButton_clicked(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/input/combobox/mainwindow.ui b/qt/input/combobox/mainwindow.ui deleted file mode 100644 index a9b1fcb..0000000 --- a/qt/input/combobox/mainwindow.ui +++ /dev/null @@ -1,140 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 140 - 160 - 99 - 20 - - - - true - - - 10 - - - QComboBox::InsertAtTop - - - QComboBox::AdjustToContents - - - 12 - - - - Group box - - - - - Scroll Area - - - - - ToolBox - - - - - Frame - - - - - Widget - - - - - Dock Widget - - - - - - - 520 - 280 - 75 - 23 - - - - PushButton - - - - - - 100 - 300 - 256 - 192 - - - - - 1 - - - - - 新建项目 - - - - 新建子项目 - - - - 新建子项目 - - - - 新建子项目 - - - - - - - - 新建项目 - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/input/fontcombobox/.gitignore b/qt/input/fontcombobox/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/input/fontcombobox/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/input/fontcombobox/fontcombobox.pro b/qt/input/fontcombobox/fontcombobox.pro deleted file mode 100644 index 0086fd6..0000000 --- a/qt/input/fontcombobox/fontcombobox.pro +++ /dev/null @@ -1,31 +0,0 @@ -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -CONFIG += c++11 - -# The following define makes your compiler emit warnings if you use -# any Qt feature that has been marked deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if it uses deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/input/fontcombobox/main.cpp b/qt/input/fontcombobox/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/input/fontcombobox/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/input/fontcombobox/mainwindow.cpp b/qt/input/fontcombobox/mainwindow.cpp deleted file mode 100644 index 41a26bd..0000000 --- a/qt/input/fontcombobox/mainwindow.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - diff --git a/qt/input/fontcombobox/mainwindow.h b/qt/input/fontcombobox/mainwindow.h deleted file mode 100644 index 4643e32..0000000 --- a/qt/input/fontcombobox/mainwindow.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/input/fontcombobox/mainwindow.ui b/qt/input/fontcombobox/mainwindow.ui deleted file mode 100644 index 9f67345..0000000 --- a/qt/input/fontcombobox/mainwindow.ui +++ /dev/null @@ -1,42 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 240 - 230 - 213 - 22 - - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/input/lineEdit/.gitignore b/qt/input/lineEdit/.gitignore deleted file mode 100644 index fab7372..0000000 --- a/qt/input/lineEdit/.gitignore +++ /dev/null @@ -1,73 +0,0 @@ -# This file is used to ignore files which are generated -# ---------------------------------------------------------------------------- - -*~ -*.autosave -*.a -*.core -*.moc -*.o -*.obj -*.orig -*.rej -*.so -*.so.* -*_pch.h.cpp -*_resource.rc -*.qm -.#* -*.*# -core -!core/ -tags -.DS_Store -.directory -*.debug -Makefile* -*.prl -*.app -moc_*.cpp -ui_*.h -qrc_*.cpp -Thumbs.db -*.res -*.rc -/.qmake.cache -/.qmake.stash - -# qtcreator generated files -*.pro.user* - -# xemacs temporary files -*.flc - -# Vim temporary files -.*.swp - -# Visual Studio generated files -*.ib_pdb_index -*.idb -*.ilk -*.pdb -*.sln -*.suo -*.vcproj -*vcproj.*.*.user -*.ncb -*.sdf -*.opensdf -*.vcxproj -*vcxproj.* - -# MinGW generated files -*.Debug -*.Release - -# Python byte code -*.pyc - -# Binaries -# -------- -*.dll -*.exe - diff --git a/qt/input/lineEdit/CMakeLists.txt b/qt/input/lineEdit/CMakeLists.txt deleted file mode 100644 index 31b46d3..0000000 --- a/qt/input/lineEdit/CMakeLists.txt +++ /dev/null @@ -1,45 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project(lineEdit LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOUIC ON) -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# QtCreator supports the following variables for Android, which are identical to qmake Android variables. -# Check http://doc.qt.io/qt-5/deployment-android.html for more information. -# They need to be set before the find_package(Qt5 ...) call. - -#if(ANDROID) -# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") -# if (ANDROID_ABI STREQUAL "armeabi-v7a") -# set(ANDROID_EXTRA_LIBS -# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so -# ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so) -# endif() -#endif() - -find_package(Qt5 COMPONENTS Widgets REQUIRED) - -if(ANDROID) - add_library(lineEdit SHARED - main.cpp - mainwindow.cpp - mainwindow.h - mainwindow.ui - ) -else() - add_executable(lineEdit - main.cpp - mainwindow.cpp - mainwindow.h - mainwindow.ui - ) -endif() - -target_link_libraries(lineEdit PRIVATE Qt5::Widgets) diff --git a/qt/input/lineEdit/gamer-Sticker-by-Adimanav.jpg b/qt/input/lineEdit/gamer-Sticker-by-Adimanav.jpg deleted file mode 100644 index fde9076..0000000 Binary files a/qt/input/lineEdit/gamer-Sticker-by-Adimanav.jpg and /dev/null differ diff --git a/qt/input/lineEdit/lineEdit.qrc b/qt/input/lineEdit/lineEdit.qrc deleted file mode 100644 index 90f4a83..0000000 --- a/qt/input/lineEdit/lineEdit.qrc +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/qt/input/lineEdit/main.cpp b/qt/input/lineEdit/main.cpp deleted file mode 100644 index fd3e533..0000000 --- a/qt/input/lineEdit/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" - -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/qt/input/lineEdit/mainwindow.cpp b/qt/input/lineEdit/mainwindow.cpp deleted file mode 100644 index 6145c4d..0000000 --- a/qt/input/lineEdit/mainwindow.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include "mainwindow.h" -#include "./ui_mainwindow.h" -#include -#include -#include -#include - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - - auto* validator = new QRegularExpressionValidator(QRegularExpression(R"(\w+@\w+\.\w+)")); - - ui->lineEdit->setValidator(validator); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - - -void MainWindow::on_pushButton_clicked() -{ - ui->lineEdit->setCursorPosition(ui->lineEdit_2->text().toInt()); - ui->lineEdit->setFocus(); - qDebug() << "called " << ui->lineEdit->cursorPosition(); -} - -void MainWindow::on_pushButton_2_clicked() -{ - ui->lineEdit->setDragEnabled(!ui->lineEdit->dragEnabled()); -} - -void MainWindow::on_pushButton_3_clicked() -{ - QIcon icon = QIcon("D:\\qt\\A\\input\\lineEdit\\gamer-Sticker-by-Adimanav.jpg"); - - if (icon.isNull()) { - qDebug() << "null icon"; - } - QAction* action = new QAction(icon, "icon"); - - ui->lineEdit->addAction(action, QLineEdit::LeadingPosition); - qDebug() << "action called "; -} - -void MainWindow::on_pushButton_4_clicked() -{ - qDebug()<< ui->lineEdit->hasAcceptableInput(); -} diff --git a/qt/input/lineEdit/mainwindow.h b/qt/input/lineEdit/mainwindow.h deleted file mode 100644 index 4544bcf..0000000 --- a/qt/input/lineEdit/mainwindow.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } -QT_END_NAMESPACE - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - - void on_pushButton_2_clicked(); - - void on_pushButton_3_clicked(); - - void on_pushButton_4_clicked(); - -private: - Ui::MainWindow *ui; -}; -#endif // MAINWINDOW_H diff --git a/qt/input/lineEdit/mainwindow.ui b/qt/input/lineEdit/mainwindow.ui deleted file mode 100644 index 208d5aa..0000000 --- a/qt/input/lineEdit/mainwindow.ui +++ /dev/null @@ -1,134 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 800 - 600 - - - - MainWindow - - - - - - 240 - 190 - 371 - 51 - - - - - - - 333344333 - - - true - - - QLineEdit::Normal - - - 9 - - - false - - - Qt::VisualMoveStyle - - - false - - - - - - 370 - 330 - 113 - 20 - - - - 这里输入位置 - - - Qt::VisualMoveStyle - - - - - - 640 - 340 - 75 - 23 - - - - posiotion - - - - - - 640 - 280 - 75 - 23 - - - - drag - - - - - - 650 - 400 - 75 - 23 - - - - action - - - - - - 650 - 450 - 75 - 23 - - - - validate - - - - - - - 0 - 0 - 800 - 23 - - - - - - - - diff --git a/qt/spacer/main.cpp b/qt/spacer/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/spacer/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/spacer/mainwindow.cpp b/qt/spacer/mainwindow.cpp deleted file mode 100644 index 40e43d4..0000000 --- a/qt/spacer/mainwindow.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - this->layoutCenter_ = new QHBoxLayout(ui->centralWidget); - - this->frame_ = new QFrame(ui->centralWidget); - - layoutCenter_->addWidget(this->frame_); - layout_ = new QHBoxLayout(this->frame_); - - button1_ = new QPushButton(this->frame_); - button1_->setMinimumWidth(175); - button1_->setFixedHeight(36); - button1_->setText("button1"); - - - layout_->addWidget(button1_); - - button2_ = new QPushButton(this->frame_); - - button2_->setMinimumWidth(175); - button2_->setFixedHeight(36); - button2_->setText("button2"); - - layout_->addWidget(button2_); - - spacerItem_ = new QSpacerItem(20, 20, QSizePolicy::Expanding); - - layout_->addItem(spacerItem_); - - - button3_ = new QPushButton(this->frame_); - - button3_->setMinimumWidth(175); - button3_->setFixedHeight(36); - button3_->setText("button3"); - - layout_->addWidget(button3_); - -} - -MainWindow::~MainWindow() -{ - delete ui; -} diff --git a/qt/spacer/mainwindow.h b/qt/spacer/mainwindow.h deleted file mode 100644 index e30ae1a..0000000 --- a/qt/spacer/mainwindow.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include -#include -#include - -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - - QFrame *frame_; - QHBoxLayout* layout_; - QHBoxLayout* layoutCenter_; - - QPushButton *button1_; - QPushButton *button2_; - QPushButton *button3_; - - QSpacerItem *spacerItem_; -}; - -#endif // MAINWINDOW_H diff --git a/qt/spacer/mainwindow.ui b/qt/spacer/mainwindow.ui deleted file mode 100644 index c07bf20..0000000 --- a/qt/spacer/mainwindow.ui +++ /dev/null @@ -1,40 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 655 - 377 - - - - MainWindow - - - - - - 0 - 0 - 655 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/spacer/spacer.pro b/qt/spacer/spacer.pro deleted file mode 100644 index 32aafb3..0000000 --- a/qt/spacer/spacer.pro +++ /dev/null @@ -1,40 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-07-20T22:05:05 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = spacer -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++11 - -SOURCES += \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - mainwindow.h - -FORMS += \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/qt/stackedlayout/dialog1.cpp b/qt/stackedlayout/dialog1.cpp deleted file mode 100644 index 9ad2f3d..0000000 --- a/qt/stackedlayout/dialog1.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "dialog1.h" -#include "ui_dialog1.h" - -Dialog1::Dialog1(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog1) -{ - ui->setupUi(this); -} - -Dialog1::~Dialog1() -{ - delete ui; -} diff --git a/qt/stackedlayout/dialog1.h b/qt/stackedlayout/dialog1.h deleted file mode 100644 index ff19db5..0000000 --- a/qt/stackedlayout/dialog1.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DIALOG1_H -#define DIALOG1_H - -#include - -namespace Ui { -class Dialog1; -} - -class Dialog1 : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog1(QWidget *parent = nullptr); - ~Dialog1(); - -private: - Ui::Dialog1 *ui; -}; - -#endif // DIALOG1_H diff --git a/qt/stackedlayout/dialog1.ui b/qt/stackedlayout/dialog1.ui deleted file mode 100644 index 18fa7b8..0000000 --- a/qt/stackedlayout/dialog1.ui +++ /dev/null @@ -1,108 +0,0 @@ - - - Dialog1 - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - 30 - 240 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 50 - 10 - 256 - 192 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - - - - buttonBox - accepted() - Dialog1 - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog1 - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/qt/stackedlayout/dialog2.cpp b/qt/stackedlayout/dialog2.cpp deleted file mode 100644 index 7f46b8e..0000000 --- a/qt/stackedlayout/dialog2.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "dialog2.h" -#include "ui_dialog2.h" - -Dialog2::Dialog2(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog2) -{ - ui->setupUi(this); -} - -Dialog2::~Dialog2() -{ - delete ui; -} diff --git a/qt/stackedlayout/dialog2.h b/qt/stackedlayout/dialog2.h deleted file mode 100644 index 5155a11..0000000 --- a/qt/stackedlayout/dialog2.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DIALOG2_H -#define DIALOG2_H - -#include - -namespace Ui { -class Dialog2; -} - -class Dialog2 : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog2(QWidget *parent = nullptr); - ~Dialog2(); - -private: - Ui::Dialog2 *ui; -}; - -#endif // DIALOG2_H diff --git a/qt/stackedlayout/dialog2.ui b/qt/stackedlayout/dialog2.ui deleted file mode 100644 index e8ab63a..0000000 --- a/qt/stackedlayout/dialog2.ui +++ /dev/null @@ -1,148 +0,0 @@ - - - Dialog2 - - - - 0 - 0 - 400 - 300 - - - - Dialog - - - - - 30 - 240 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 60 - 40 - 256 - 192 - - - - - 1 - - - - - 新建列 - - - - - 新建列 - - - - - 新建列 - - - - - 新建列 - - - - - 新建列 - - - - - 新建列 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - 新建项目 - - - - - - - - buttonBox - accepted() - Dialog2 - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Dialog2 - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/qt/stackedlayout/main.cpp b/qt/stackedlayout/main.cpp deleted file mode 100644 index b48f94e..0000000 --- a/qt/stackedlayout/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "mainwindow.h" -#include - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/qt/stackedlayout/mainwindow.cpp b/qt/stackedlayout/mainwindow.cpp deleted file mode 100644 index f523a59..0000000 --- a/qt/stackedlayout/mainwindow.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - dialog1_ = std::make_unique(); - dialog2_ = std::make_unique(); - - - - layout_ = new QStackedLayout(ui->frame); - - layout_->addWidget(dialog1_.get()); - layout_->addWidget(dialog2_.get()); -} - - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::on_pushButton_clicked() -{ - layout_->setCurrentWidget(dialog1_.get()); -} - -void MainWindow::on_pushButton_2_clicked() -{ - layout_->setCurrentWidget(dialog2_.get()); -} diff --git a/qt/stackedlayout/mainwindow.h b/qt/stackedlayout/mainwindow.h deleted file mode 100644 index b2c6389..0000000 --- a/qt/stackedlayout/mainwindow.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include -#include -#include "dialog1.h" -#include "dialog2.h" -#include -namespace Ui { -class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); - -private slots: - void on_pushButton_clicked(); - - void on_pushButton_2_clicked(); - -private: - Ui::MainWindow *ui; - - std::unique_ptr dialog1_; - - std::unique_ptr dialog2_; - - QStackedLayout * layout_; -}; - -#endif // MAINWINDOW_H diff --git a/qt/stackedlayout/mainwindow.ui b/qt/stackedlayout/mainwindow.ui deleted file mode 100644 index 08cbc09..0000000 --- a/qt/stackedlayout/mainwindow.ui +++ /dev/null @@ -1,84 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 534 - 519 - - - - MainWindow - - - - - - - - - QLayout::SetFixedSize - - - - - PushButton - - - - - - - PushButton - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - 0 - 0 - 534 - 23 - - - - - - TopToolBarArea - - - false - - - - - - - - diff --git a/qt/stackedlayout/stackedlayout.pro b/qt/stackedlayout/stackedlayout.pro deleted file mode 100644 index 8c67e9b..0000000 --- a/qt/stackedlayout/stackedlayout.pro +++ /dev/null @@ -1,46 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2019-07-06T10:52:18 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = stackedlayout -TEMPLATE = app - -# The following define makes your compiler emit warnings if you use -# any feature of Qt which has been marked as deprecated (the exact warnings -# depend on your compiler). Please consult the documentation of the -# deprecated API in order to know how to port your code away from it. -DEFINES += QT_DEPRECATED_WARNINGS - -# You can also make your code fail to compile if you use deprecated APIs. -# In order to do so, uncomment the following line. -# You can also select to disable deprecated APIs only up to a certain version of Qt. -#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - -CONFIG += c++14 - -SOURCES += \ - dialog1.cpp \ - dialog2.cpp \ - main.cpp \ - mainwindow.cpp - -HEADERS += \ - dialog1.h \ - dialog2.h \ - mainwindow.h - -FORMS += \ - dialog1.ui \ - dialog2.ui \ - mainwindow.ui - -# Default rules for deployment. -qnx: target.path = /tmp/$${TARGET}/bin -else: unix:!android: target.path = /opt/$${TARGET}/bin -!isEmpty(target.path): INSTALLS += target diff --git a/v8/include/framework.h b/v8/include/framework.h deleted file mode 100644 index e5f1e9a..0000000 --- a/v8/include/framework.h +++ /dev/null @@ -1,565 +0,0 @@ -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::chrono_literals; -namespace sinks = boost::log::sinks; -BOOST_LOG_INLINE_GLOBAL_LOGGER_DEFAULT(__LOG__, boost::log::sources::severity_channel_logger_mt); - -namespace shelllet { -#define LOG_TRACE(c) BOOST_LOG_CHANNEL_SEV(__LOG__::get(), c, boost::log::trivial::trace) -#define LOG_DEBUG(c) BOOST_LOG_CHANNEL_SEV(__LOG__::get(), c, boost::log::trivial::debug) -#define LOG_INFO(c) BOOST_LOG_CHANNEL_SEV(__LOG__::get(), c,boost::log::trivial::info) -#define LOG_WARN(c) BOOST_LOG_CHANNEL_SEV(__LOG__::get(), c, boost::log::trivial::warning) -#define LOG_ERROR(c) BOOST_LOG_CHANNEL_SEV(__LOG__::get(), c,boost::log::trivial::error) -#define LOG_FATAL(c) BOOST_LOG_CHANNEL_SEV(__LOG__::get(), c,boost::log::trivial::fatal) - -#define THROW_SYSTEM_ERROR(n) throw boost::system::system_error(n, boost::system::detail::system_error_category(), (boost::format("%1% %2%") % __FUNCTION__ % __LINE__).str()) - -#define STR(str) #str - -#define VERSION "0.5.0" - static inline const char K_CONST_MARK_UNKNOWN[] = "unknown"; - static inline const char K_CONST_ERROR_CALLED[] = "# invalid object."; - static inline const char K_CONST_ERROR_NULL_PTR[] = "# this null."; - static inline const char K_CONST_ERROR_INVLAID_PARAM[] = "# invalid param."; -} - -namespace shelllet { - namespace logs { - typedef boost::log::sinks::synchronous_sink sink_debug_t; - typedef boost::log::sinks::synchronous_sink event_sink_t; - - BOOST_LOG_ATTRIBUTE_KEYWORD(keyword_channel, "Channel", std::string); - - static inline auto global_log_format = (boost::log::expressions::format("[%1%]<%2%> : <%3%> %4%") - % boost::log::expressions::format_date_time("TimeStamp", "%Y-%m-%d %H:%M:%S") - % boost::log::expressions::attr< std::string >("Channel") - % boost::log::trivial::severity - % boost::log::expressions::message); - - static inline void Initialize(const std::filesystem::path& filename, boost::log::trivial::severity_level level) { - boost::log::add_common_attributes(); - - boost::log::core::get()->set_filter(boost::log::trivial::severity >= level); - - boost::shared_ptr sink(new sink_debug_t()); - sink->set_formatter(global_log_format); - sink->set_filter(boost::log::expressions::is_debugger_present()); - //boost::log::core::get()->set_filter(boost::log::expressions::is_debugger_present()); - boost::log::core::get()->add_sink(sink); - - boost::log::add_console_log(std::clog, boost::log::keywords::format = global_log_format); - - boost::log::add_file_log(boost::log::keywords::file_name = filename.c_str(), - boost::log::keywords::rotation_size = 1 * 1024 * 1024, - boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0), - boost::log::keywords::format = global_log_format - //boost::log::keywords::channel = keyword_channel == channel - ); - } - - static inline boost::log::trivial::severity_level LevelFromString(const std::string& level) { - static std::map map = { - {"trace", boost::log::trivial::trace} , - {"debug", boost::log::trivial::debug} , - {"info", boost::log::trivial::info} , - {"warning", boost::log::trivial::warning} , - {"error", boost::log::trivial::error} , - {"fatal", boost::log::trivial::fatal} - }; - - if (auto itor = map.find(level); itor != map.cend()) { - return itor->second; - } - return boost::log::trivial::fatal; - } - } - - enum class IsolateData : uint32_t { - GlobalContext, - GlobalValue, - SetErrorAddress, - }; - enum class ContextEmbedderData : uint32_t { - WorkingDirectory, - }; -#define V8_GL_CONTEXT(isolate) static_cast*>(isolate->GetData(static_cast(IsolateData::GlobalContext))) -#define V8_GL_VALUE(isolate) static_cast>*>(isolate->GetData(static_cast(IsolateData::GlobalValue))) -#define F_SET_LAST_ERROR(isolate, err) static_cast&)>(isolate->GetData(static_cast(IsolateData::SetErrorAddress)))(err) - -#define V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(Args) v8::Isolate* isolate = Args.GetIsolate(); \ - v8::HandleScope handleScope(isolate); \ - v8::Local context = v8::Local::New(isolate, V8_GL_CONTEXT(isolate)->Get(isolate)); \ - v8::Context::Scope contextScope(context); \ - try - -#define V8_CREATE_LOCAL_CONTEXT_END \ - catch (const std::exception& err) { \ - isolate->ThrowException(v8::String::NewFromUtf8(isolate, err.what()).ToLocalChecked()); \ - } - -#define V8_CREATE_LOCAL_CONTEXT_END_WITH_RETURN(ret) \ - catch (const std::exception& err) { \ - isolate->ThrowException(v8::String::NewFromUtf8(isolate, err.what()).ToLocalChecked()); \ - } \ - return ret; - -#define V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) \ - v8::Locker locker(isolate); \ - v8::Isolate::Scope isolateScope(isolate); \ - v8::HandleScope handleScope(isolate); \ - v8::Local context = v8::Local::New(isolate, V8_GL_CONTEXT(isolate)->Get(isolate)); \ - v8::Context::Scope contextScope(context); \ - try - -#define V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) \ - v8::HandleScope handleScope(isolate); \ - v8::Local context = v8::Local::New(isolate, V8_GL_CONTEXT(isolate)->Get(isolate)); \ - v8::Context::Scope contextScope(context); \ - try - -#define V8_NEW_STRING_VAR(isolate, v) v8::String::NewFromUtf8(isolate, v).ToLocalChecked() -#define V8_NEW_WSTRING_VAR(isolate, v) v8::String::NewFromTwoByte(isolate, reinterpret_cast(v)).ToLocalChecked() -} -namespace shelllet { - template - using CopyablePersistent = v8::Persistent>; - - static inline const char* ToString(const v8::String::Utf8Value& value) { - return *value ? *value : ""; - } - static inline const wchar_t* ToWString(const v8::String::Value& value) { - return *value ? reinterpret_cast(*value) : L""; - } - static inline std::string GetConstructorName(v8::Isolate* isolate, const v8::Local& value) { - if (value->IsObject()) - return ToString({ isolate ,value->ToObject(isolate->GetCurrentContext()).ToLocalChecked()->GetConstructorName() }); - return std::string(); - } - static inline std::string GetException(v8::Isolate* isolate, const v8::TryCatch& tryCatch) - { - v8::HandleScope handleScope(isolate); - v8::String::Utf8Value exception(isolate, tryCatch.Exception()); - const char* exceptionString = ToString(exception); - v8::Local message = tryCatch.Message(); - std::ostringstream stream; - if (message.IsEmpty()) { - // V8 didn't provide any extra information about this error; just print the exception. - stream << exceptionString; - } - else { - // Print (filename):(line number): (message). - v8::String::Utf8Value filename(isolate, message->GetScriptOrigin().ResourceName()); - v8::Local context(isolate->GetCurrentContext()); - const char* filenameString = ToString(filename); - int linenum = message->GetLineNumber(context).FromJust(); - - stream << filenameString << ":" << linenum << ": " << exceptionString; - // Print line of source code. - v8::String::Utf8Value sourceline(isolate, message->GetSourceLine(context).ToLocalChecked()); - const char* sourcelineString = ToString(sourceline); - stream << sourcelineString; - // Print wavy underline (GetUnderline is deprecated). - int start = message->GetStartColumn(context).FromJust(); - for (int i = 0; i < start; i++) { - stream << " "; - } - int end = message->GetEndColumn(context).FromJust(); - for (int i = start; i < end; i++) { - stream << "^"; - } - stream << "\n"; - v8::Local stackTrace; - if (tryCatch.StackTrace(context).ToLocal(&stackTrace) && stackTrace->IsString() && v8::Local::Cast(stackTrace)->Length() > 0) { - v8::String::Utf8Value stackTrace(isolate, stackTrace); - stream << ToString(stackTrace); - } - } - - return stream.str(); - } - - template - static void ToArray(v8::Isolate* isolate, const v8::Local& value, std::vector& buffer) { - if constexpr (std::is_same, std::uint32_t>::value) - { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - else if constexpr (std::is_same, std::uint16_t>::value) - { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - else if (std::is_same, std::uint8_t>::value) - { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - else if (std::is_same, std::int8_t>::value) { - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - - if (v8::Local array = v8::Local::Cast(value); !array.IsEmpty()) { - buffer.resize(array->ByteLength()); - array->CopyContents(buffer.data(), array->ByteLength()); - } - } - - template - static void ToArray(v8::Isolate* isolate, const v8::Local& value, std::vector& buffer) { - buffer.resize(value->Length()); - if constexpr (std::is_same::value - || std::is_same, std::uint8_t>::value - || std::is_same, std::uint16_t>::value) - { - for (std::uint32_t i = 0; i < value->Length(); ++i) { - buffer[i] = value->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->Uint32Value(isolate->GetCurrentContext()).FromJust(); - } - } - if constexpr (std::is_same, std::byte>::value) { - for (std::uint32_t i = 0; i < value->Length(); ++i) { - buffer[i] = static_cast(value->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->Uint32Value(isolate->GetCurrentContext()).FromJust()); - } - } - // else { - //for (std::uint32_t i = 0; i < value->Length(); ++i) { - //buffer[i] = value->Get(isolate->GetCurrentContext(), i).ToLocalChecked()->Int32Value(isolate->GetCurrentContext()).FromJust(); - //} - //} - } - template - static auto ToArray(v8::Isolate* isolate, const v8::Local& value) { - std::vector buffer; - if (value->IsArray()) { - ToArray(isolate, v8::Local::Cast(value), buffer); - } - else if (value->IsTypedArray()) { - ToArray(isolate, v8::Local::Cast(value), buffer); - } - - return buffer; - } - - static inline v8::Local NewArray(v8::Isolate* isolate, const std::vector& value) - { - v8::Local array = v8::ArrayBuffer::New(isolate, value.size()); - std::memcpy(array->GetContents().Data(), &value[0], array->ByteLength()); - - return v8::Uint8Array::New(array, 0, array->ByteLength()); - } - template - static inline v8::Local NewArray(v8::Isolate* isolate, const std::vector& v) - { - v8::Local array = v8::Array::New(isolate, v.size()); - for (int i = 0; i < v.size(); ++i) { - if constexpr (std::is_same::value) { - array->Set(isolate->GetCurrentContext(), i, V8_NEW_WSTRING_VAR(isolate, v.at(i).c_str())); - } - else if constexpr (std::is_same::value) { - array->Set(isolate->GetCurrentContext(), i, V8_NEW_STRING_VAR(isolate, v.at(i).c_str())); - } - } - return array; - } - static inline std::filesystem::path FixRelativePath(const std::filesystem::path& path, v8::Isolate* isolate) { - if (path.is_relative()) { - std::filesystem::path root = ToString({ isolate, isolate->GetCurrentContext()->GetEmbedderData(static_cast(ContextEmbedderData::WorkingDirectory)) }); - LOG_DEBUG("v8") << "# rel: " << std::filesystem::relative(path, root); - if (std::filesystem::relative(path, root).empty()) - return (root / path).lexically_normal(); - } - return path.lexically_normal(); - } -} -#define V8_CREATE_ENUM_SYMBOL(T, I, C, N, V) \ -T->Set(I, #V, v8::Symbol::New(I, V8_NEW_STRING_VAR(I, std::to_string(C::N::V).c_str()))) - -namespace shelllet { - class Private - { - public: - Private() = default; - virtual ~Private() { - if (!weak.IsEmpty()) { - weak.ClearWeak(); - weak.Reset(); - } - } - v8::Persistent weak; - }; - - template - class ObjectPrivate :public T, public Private { - public: - template - ObjectPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : T(std::forward(args)...), object(isolate, obj) { - } - - T* operator-> () { - return dynamic_cast(this); - } - const T* operator-> () const { - return dynamic_cast(this); - } - operator T* () { - return dynamic_cast(this); - } - operator const T* () const { - return dynamic_cast(this); - } - - template - v8::Local call(const char* name, Args&&... args) const { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Local local = holder(isolate); - v8::Local proto = local->GetPrototype()->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); - v8::Local value = proto->Get(isolate->GetCurrentContext(), V8_NEW_STRING_VAR(isolate, name)).ToLocalChecked(); - v8::Local func = v8::Local::Cast(value); - if constexpr (sizeof...(Args) == 0) { - return func->CallAsFunction(isolate->GetCurrentContext(), local, 0, {}).ToLocalChecked(); - } - else { - v8::Local argv[] = { std::forward(args)... }; - return func->CallAsFunction(isolate->GetCurrentContext(), local, std::size(argv), argv).ToLocalChecked(); - } - } - - virtual bool hasOwnProperty(const std::string& name) const - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - v8::Local proto = holder(isolate)->GetPrototype()->ToObject(isolate->GetCurrentContext()).ToLocalChecked(); - return proto->HasOwnProperty(isolate->GetCurrentContext(), V8_NEW_STRING_VAR(isolate, name.c_str())).FromJust(); - } - - v8::Local holder(v8::Isolate* isolate) const { return object.Get(isolate); } - private: - v8::Global object; - ObjectPrivate() = delete; - }; - - template - class ObjectPrivate::value>::type> : public Private { - public: - ObjectPrivate(v8::Isolate*, const v8::Local&, T* p) : p(p) { - } - - operator T* () { - return dynamic_cast(p.get()); - } - operator const T* () const { - return dynamic_cast(p.get()); - } - - T* operator-> () { - return dynamic_cast(p.get()); - } - const T* operator-> () const { - return dynamic_cast(p.get()); - } - private: - std::shared_ptr p; - //ObjectPrivate() = delete; - }; -} - -namespace shelllet { - class Empty { - public: - virtual ~Empty() {} - }; - - template // can remove c. - class ObjectWrapper : public Empty - { - public: - template - ObjectWrapper(ObjectPrivate& d, const v8::FunctionCallbackInfo& args) - : d_ptr(std::unique_ptr>(&d)) - { - } - - ObjectWrapper(v8::Isolate* isolate, const v8::Local& tpl) {} - ObjectWrapper(v8::Isolate* isolate, const v8::Local& proto) {} - - virtual ~ObjectWrapper() {} - virtual void toString(std::stringstream& ss) const { ss << "[object" << " " << U::Name() << "]"; } - - template - static v8::Local New(v8::Isolate* isolate, Args&&... args) - { - //std::unique_ptr p = std::make_unique(std::forward(args)...); - v8::Local argv[] = { std::forward(args)... }; - v8::Local name = V8_NEW_STRING_VAR(isolate, U::Name()); - v8::Local value = isolate->GetCurrentContext()->Global()->Get(isolate->GetCurrentContext(), name).ToLocalChecked(); - if (!value->IsFunction()) { - throw std::runtime_error((boost::format("#! `%1%` not registered.") % U::Name()).str()); - } - v8::Local func = value.As(); - auto result = func->CallAsConstructor(isolate->GetCurrentContext(), std::size(argv), argv); - if (!result.IsEmpty()) - return result.ToLocalChecked(); - return v8::Local(); - } - - static v8::Local New2(v8::Isolate* isolate, T* p) - { - auto fn = WrapClass(isolate, p); - auto v = fn->GetFunction(isolate->GetCurrentContext()).ToLocalChecked()->CallAsConstructor(isolate->GetCurrentContext(), 0, {}); - return v.ToLocalChecked(); - } - static U* From(const v8::Local& value, int index = 0) { - if (value->IsObject()) { - v8::Local o = value.As(); - if (o->InternalFieldCount() > index) - return dynamic_cast(static_cast(o->GetAlignedPointerFromInternalField(index))); - } - return nullptr; - } - template - static inline M* UnWrap(const v8::Local& value, int index = 0) { - if (value->InternalFieldCount() > index) - return dynamic_cast(static_cast(value->GetAlignedPointerFromInternalField(index))); - - return nullptr; - } - public: - operator const T* () const { - if (std::holds_alternative>>(d_ptr)) - return *std::get>>(d_ptr); - else { - return *std::get>>(d_ptr); - } - //return *d_ptr; - } - operator T* () { - //return *d_ptr; - if (std::holds_alternative>>(d_ptr)) - return *std::get>>(d_ptr); - else { - return *std::get < std::unique_ptr>>(d_ptr); - } - } - - const T* operator -> () const { - return static_cast(*this); - } - T* operator -> () { - return static_cast(*this); - } - - static v8::Local WrapClass(v8::Isolate* isolate, T* p = nullptr) - { - v8::Local tpl = v8::FunctionTemplate::New(isolate, U::NewCallback, v8::External::New(isolate, p)); - //if constexpr (C) { - static_cast(std::make_unique(isolate, tpl)); - static_cast(std::make_unique(isolate, tpl->PrototypeTemplate())); - //} - tpl->PrototypeTemplate()->Set(isolate, "toString", v8::FunctionTemplate::New(isolate, [](const v8::FunctionCallbackInfo& args) { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (auto* self = UnWrap>(args.This()); self) { - std::stringstream ss; - self->toString(ss); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, ss.str().c_str())); - } - } - V8_CREATE_LOCAL_CONTEXT_END - })); - tpl->InstanceTemplate()->SetInternalFieldCount(1); - return tpl; - } - - protected: - static void NewCallback(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if constexpr (!C) { - throw std::logic_error((boost::format("`%1%` is not a constructor") % U::Name()).str()); - } - - if (!args.IsConstructCall()) { - throw std::logic_error("should use `new` to create instance"); - } - ObjectWrapper* value = nullptr; - if (auto* self = args.Data().As()->Value(); self) { - value = new U(static_cast(self), args); - } - else { - value = new U(args); - } - - args.This()->SetAlignedPointerInInternalField(0, static_cast(value)); - if (std::holds_alternative>>(value->d_ptr)) { - std::get>>(value->d_ptr)->weak.Reset(isolate, args.This()); - std::get>>(value->d_ptr)->weak.SetWeak(dynamic_cast(value), [](const v8::WeakCallbackInfo& data) { - delete data.GetParameter(); - LOG_INFO("v8") << "# free class `" << U::Name() << "`" << std::endl; - }, v8::WeakCallbackType::kParameter); - } - else { - std::get>>(value->d_ptr)->weak.Reset(isolate, args.This()); - std::get>>(value->d_ptr)->weak.SetWeak(dynamic_cast(value), [](const v8::WeakCallbackInfo& data) { - delete data.GetParameter(); - LOG_INFO("v8") << "# free class `" << U::Name() << "`" << std::endl; - }, v8::WeakCallbackType::kParameter); - } - - args.GetReturnValue().Set(args.This()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - protected: - std::variant>, std::unique_ptr>> d_ptr; - }; -} diff --git a/v8/include/modules/core/initialize.h b/v8/include/modules/core/initialize.h deleted file mode 100644 index 0e015d5..0000000 --- a/v8/include/modules/core/initialize.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "framework.h" -#include "randomdevice_implement.h" -#include "uniformintdistribution_implement.h" -#include "qsize_implement.h" -#include "qrect_implement.h" -#include "qpoint_implement.h" -#include "qobject_implement.h" -#include "qurl_implement.h" -#include "qcoreapplication_implement.h" -#include "qtimer_implement.h" -#include "qpointf_implement.h" -#include "qdiriterator_implement.h" -#include "qdir_implement.h" - -namespace shelllet { - namespace qtcore { - void initialize(v8::Isolate* isolate, const v8::Local& proto) { - using namespace shelllet::core; - { - //objectTemplate->Set(isolate, RandomDevice::Name(), RandomDevice::WrapClass(isolate)); - //objectTemplate->Set(isolate, UniformIntDistribution::Name(), UniformIntDistribution::WrapClass(isolate)); - - proto->Set(isolate, Object::Name(), Object::WrapClass(isolate)); - proto->Set(isolate, CoreApplication::Name(), CoreApplication::WrapClass(isolate)); - proto->Set(isolate, Point::Name(), Point::WrapClass(isolate)); - proto->Set(isolate, PointF::Name(), PointF::WrapClass(isolate)); - proto->Set(isolate, Size::Name(), Size::WrapClass(isolate)); - proto->Set(isolate, Rect::Name(), Rect::WrapClass(isolate)); - proto->Set(isolate, Url::Name(), Url::WrapClass(isolate)); - proto->Set(isolate, Timer::Name(), Timer::WrapClass(isolate)); - proto->Set(isolate, DirIterator::Name(), DirIterator::WrapClass(isolate)); - proto->Set(isolate, Dir::Name(), Dir::WrapClass(isolate)); - } - } - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qcoreapplication_implement.h b/v8/include/modules/core/qcoreapplication_implement.h deleted file mode 100644 index 3217a57..0000000 --- a/v8/include/modules/core/qcoreapplication_implement.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qcoreapplication_p.h" -#include "qcoreapplication_wrapper.h" - -namespace shelllet { - namespace core { - class CoreApplication : public QCoreApplicationWrapper - { - public: - using ReturnType = QCoreApplicationPrivate; - using ReturnType2 = QCoreApplicationPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This(), __argc, __argv); - } - - CoreApplication(const v8::FunctionCallbackInfo& args) :QCoreApplicationWrapper(*Private(args), args) - { - } - CoreApplication(QCoreApplication* p, const v8::FunctionCallbackInfo& args) : QCoreApplicationWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - CoreApplication(v8::Isolate* isolate, const v8::Local& tpl) : QCoreApplicationWrapper(isolate, tpl) - { - tpl->Set(isolate, "exec", v8::FunctionTemplate::New(isolate, Exec)); - } - CoreApplication(v8::Isolate* isolate, const v8::Local& proto) : QCoreApplicationWrapper(isolate, proto) - { - } - - static const char* Name() { return "CoreApplication"; } - protected: - virtual void toString(std::stringstream& ss) const {} - - static void Exec(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - v8::Unlocker unlocker(isolate); - QCoreApplication::exec(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/core/qcoreapplication_p.h b/v8/include/modules/core/qcoreapplication_p.h deleted file mode 100644 index ac12b82..0000000 --- a/v8/include/modules/core/qcoreapplication_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template - class QCoreApplicationPrivate : public QObjectPrivate - { - public: - template - QCoreApplicationPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/core/qcoreapplication_wrapper.h b/v8/include/modules/core/qcoreapplication_wrapper.h deleted file mode 100644 index 9dee17b..0000000 --- a/v8/include/modules/core/qcoreapplication_wrapper.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template class QCoreApplicationPrivate; - template - class QCoreApplicationWrapper : public QObjectWrapper - { - public: - - template - QCoreApplicationWrapper(QCoreApplicationPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - QCoreApplicationWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) { - tpl->Set(isolate, "quit", v8::FunctionTemplate::New(isolate, Quit)); - } - QCoreApplicationWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) - { - } - - protected: - static void Quit(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - v8::Unlocker unlocker(isolate); - QCoreApplication::quit(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qdir_implement.h b/v8/include/modules/core/qdir_implement.h deleted file mode 100644 index 4f18e42..0000000 --- a/v8/include/modules/core/qdir_implement.h +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qdir_p.h" -#include "qdir_wrapper.h" - -namespace shelllet { - namespace core { - class Dir : public QDirWrapper - { - using ReturnType = QDirPrivate; - using ReturnType2 = QDirPrivate; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - Dir(const v8::FunctionCallbackInfo& args) :QDirWrapper(*Param(args), args) - { - } - Dir(QDir* p, const v8::FunctionCallbackInfo& args) :QDirWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Dir(v8::Isolate* isolate, const v8::Local& tpl) : QDirWrapper(isolate, tpl) - { - - } - - Dir(v8::Isolate* isolate, const v8::Local& proto) : QDirWrapper(isolate, proto) - { - - } - - protected: - void toString(std::stringstream& ss) const {} - public: - static const char* Name() { return "Dir"; } - protected: - - }; - } -} diff --git a/v8/include/modules/core/qdir_p.h b/v8/include/modules/core/qdir_p.h deleted file mode 100644 index 96e3fd2..0000000 --- a/v8/include/modules/core/qdir_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template - class QDirPrivate : public ObjectPrivate - { - public: - template - QDirPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - }; - } -} diff --git a/v8/include/modules/core/qdir_wrapper.h b/v8/include/modules/core/qdir_wrapper.h deleted file mode 100644 index 101d8c1..0000000 --- a/v8/include/modules/core/qdir_wrapper.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template - class QDirWrapper : public ObjectWrapper - { - public: - template - QDirWrapper(QDirPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QDirWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - auto filter = v8::FunctionTemplate::New(isolate); - filter->Set(isolate, "Dirs", v8::Int32::New(isolate, QDir::Dirs)); - filter->Set(isolate, "Files", v8::Int32::New(isolate, QDir::Files)); - filter->Set(isolate, "AllDirs", v8::Int32::New(isolate, QDir::AllDirs)); - filter->Set(isolate, "NoDotAndDotDot", v8::Int32::New(isolate, QDir::NoDotAndDotDot)); - - tpl->Set(isolate, "Filter", filter); - } - - QDirWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qdiriterator_implement.h b/v8/include/modules/core/qdiriterator_implement.h deleted file mode 100644 index fb61e38..0000000 --- a/v8/include/modules/core/qdiriterator_implement.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qdiriterator_p.h" -#include "qdiriterator_wrapper.h" - -namespace shelllet { - namespace core { - class DirIterator : public QDirIteratorWrapper - { - using ReturnType = QDirIteratorPrivate; - using ReturnType2 = QDirIteratorPrivate; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - if (args[0]->IsString()) { - std::string path = ToString({ args.GetIsolate(), args[0] }); - std::filesystem::path fixed = FixRelativePath(path, args.GetIsolate()); - - QDir::Filters filters = QDir::NoFilter; - QDirIterator::IteratorFlags flags = QDirIterator::NoIteratorFlags; - if (args.Length() > 1) { - filters = static_cast(args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(filters)); - } - if (args.Length() > 2) { - flags = static_cast(args[2]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromMaybe(flags)); - } - - return new ReturnType(args.GetIsolate(), args.This(), QString::fromStdString(fixed.string()), filters, flags); - } - throw std::invalid_argument(K_CONST_ERROR_INVLAID_PARAM); - } - public: - DirIterator(const v8::FunctionCallbackInfo& args) :QDirIteratorWrapper(*Param(args), args) - { - } - DirIterator(QDirIterator* p, const v8::FunctionCallbackInfo& args) :QDirIteratorWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - DirIterator(v8::Isolate* isolate, const v8::Local& tpl) : QDirIteratorWrapper(isolate, tpl) - { - } - - DirIterator(v8::Isolate* isolate, const v8::Local& proto) : QDirIteratorWrapper(isolate, proto) - { - } - - protected: - void toString(std::stringstream& ss) const {} - public: - static const char* Name() { return "DirIterator"; } - protected: - }; - } -} diff --git a/v8/include/modules/core/qdiriterator_p.h b/v8/include/modules/core/qdiriterator_p.h deleted file mode 100644 index ea23f50..0000000 --- a/v8/include/modules/core/qdiriterator_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template - class QDirIteratorPrivate : public ObjectPrivate - { - public: - template - QDirIteratorPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - }; - } -} diff --git a/v8/include/modules/core/qdiriterator_wrapper.h b/v8/include/modules/core/qdiriterator_wrapper.h deleted file mode 100644 index 1ed0d40..0000000 --- a/v8/include/modules/core/qdiriterator_wrapper.h +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template - class QDirIteratorWrapper : public ObjectWrapper - { - public: - template - QDirIteratorWrapper(QDirIteratorPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QDirIteratorWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - } - - QDirIteratorWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "fileInfo", v8::FunctionTemplate::New(isolate, FileInfo)); - proto->Set(isolate, "fileName", v8::FunctionTemplate::New(isolate, FileName)); - proto->Set(isolate, "filePath", v8::FunctionTemplate::New(isolate, FilePath)); - proto->Set(isolate, "hasNext", v8::FunctionTemplate::New(isolate, HasNext)); - proto->Set(isolate, "next", v8::FunctionTemplate::New(isolate, Next)); - proto->Set(isolate, "path", v8::FunctionTemplate::New(isolate, Path)); - } - - protected: - - static void FileInfo(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FileName(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto retval = (*self)->fileName().toUtf8(); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FilePath(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto retval = (*self)->filePath().toUtf8(); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HasNext(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set((*self)->hasNext()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Next(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto retval = (*self)->next().toUtf8(); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Path(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto retval = (*self)->path().toUtf8(); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, retval.constData())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qeventloop_implement.h b/v8/include/modules/core/qeventloop_implement.h deleted file mode 100644 index 6801227..0000000 --- a/v8/include/modules/core/qeventloop_implement.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qeventloop_p.h" -#include "qeventloop_wrapper.h" - -namespace shelllet { - namespace core { - class EventLoop : public virtual QEventLoopWrapper - { - using ReturnType = QEventLoopPrivate; - using ReturnType2 = QEventLoopPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - - EventLoop(const v8::FunctionCallbackInfo& args) : QEventLoopWrapper(*Private(args), args) - { - } - EventLoop(QEventLoop* p, const v8::FunctionCallbackInfo& args) : QEventLoopWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - EventLoop(v8::Isolate* isolate, const v8::Local& tpl) : QEventLoopWrapper(isolate, tpl) - { - } - EventLoop(v8::Isolate* isolate, const v8::Local& proto) : QEventLoopWrapper(isolate, proto) - { - } - - public: - static const char* Name() { - return "QEventLoop"; - } - }; - } -} diff --git a/v8/include/modules/core/qeventloop_p.h b/v8/include/modules/core/qeventloop_p.h deleted file mode 100644 index df71424..0000000 --- a/v8/include/modules/core/qeventloop_p.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "framework.h" -#include "qobject_p.h" - -namespace shelllet { - namespace core { - template - class QEventLoopPrivate : public QObjectPrivate - { - public: - template - QEventLoopPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qeventloop_wrapper.h b/v8/include/modules/core/qeventloop_wrapper.h deleted file mode 100644 index 92edbe9..0000000 --- a/v8/include/modules/core/qeventloop_wrapper.h +++ /dev/null @@ -1,144 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qobject_wrapper.h" - -namespace shelllet { - namespace core { - template class QEventLoopPrivate; - template - class QEventLoopWrapper : public QObjectWrapper - { - public: - - template - QEventLoopWrapper(QEventLoopPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - QEventLoopWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QEventLoopWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "isRunning", v8::FunctionTemplate::New(isolate, IsRunning)); - tpl->PrototypeTemplate()->Set(isolate, "processEvents", v8::FunctionTemplate::New(isolate, ProcessEvents)); - tpl->PrototypeTemplate()->Set(isolate, "exec", v8::FunctionTemplate::New(isolate, Exec)); - tpl->PrototypeTemplate()->Set(isolate, "exit", v8::FunctionTemplate::New(isolate, Exit)); - tpl->PrototypeTemplate()->Set(isolate, "quit", v8::FunctionTemplate::New(isolate, Quit)); - - { - v8::Local process_events_flag = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(process_events_flag, isolate, QEventLoop, ProcessEventsFlag, AllEvents); - V8_CREATE_ENUM_SYMBOL(process_events_flag, isolate, QEventLoop, ProcessEventsFlag, ExcludeUserInputEvents); - V8_CREATE_ENUM_SYMBOL(process_events_flag, isolate, QEventLoop, ProcessEventsFlag, ExcludeSocketNotifiers); - V8_CREATE_ENUM_SYMBOL(process_events_flag, isolate, QEventLoop, ProcessEventsFlag, WaitForMoreEvents); - V8_CREATE_ENUM_SYMBOL(process_events_flag, isolate, QEventLoop, ProcessEventsFlag, X11ExcludeTimers); - V8_CREATE_ENUM_SYMBOL(process_events_flag, isolate, QEventLoop, ProcessEventsFlag, EventLoopExec); - V8_CREATE_ENUM_SYMBOL(process_events_flag, isolate, QEventLoop, ProcessEventsFlag, DialogExec); - - tpl->Set(isolate, "ProcessEventsFlag", process_events_flag); - } - } - - protected: - - static void Exec(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents; - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - flags = static_cast(args[0]->Int32Value(context).FromJust()); - } - v8::Unlocker unlocker(isolate); - p->d_func()->exec(flags); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Exit(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - int return_code = 0; - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - return_code = args[0]->Int32Value(context).FromJust(); - } - p->d_func()->exit(return_code); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsRunning(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - args.GetReturnValue().Set(p->d_func()->isRunning()); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ProcessEvents(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents; - - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - flags = static_cast(args[0]->Int32Value(context).FromJust()); - //p->loop_->processEvents(flags); - } - else if (args.Length() > 2 && args[0]->IsNumber() && args[1]->IsNumber()) { - QEventLoop::ProcessEventsFlags flags = static_cast(args[0]->Int32Value(context).FromJust()); - int max_time = static_cast(args[1]->Int32Value(context).FromJust()); - p->d_func()->processEvents(flags, max_time); - } - else { - p->d_func()->processEvents(flags); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WakeUp(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->wakeUp(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Quit(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->quit(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qfile_implement.h b/v8/include/modules/core/qfile_implement.h deleted file mode 100644 index 6206a3b..0000000 --- a/v8/include/modules/core/qfile_implement.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qfile_p.h" -#include "qfile_wrapper.h" - -namespace QT_NAMESPACE { class QFile; } - -namespace shelllet { - namespace core { - class File : public QFileWrapper - { - using ReturnType = QFilePrivate; - using ReturnType2 = QFilePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - - File::File(const v8::FunctionCallbackInfo& args) : QFileWrapper(*Private(args), args) - { - } - File(QFile* p, const v8::FunctionCallbackInfo& args) : QFileWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - File::File(v8::Isolate* isolate, const v8::Local& tpl, const v8::Local& proto) : QFileWrapper(isolate, tpl) - { - } - - public: - static const char* Name() { return "QFile"; } - }; - } -} diff --git a/v8/include/modules/core/qfile_p.h b/v8/include/modules/core/qfile_p.h deleted file mode 100644 index 6ec2c94..0000000 --- a/v8/include/modules/core/qfile_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include "qfiledevice_p.h" - -namespace shelllet::core { - template - class QFilePrivate : public QFileDevicePrivate - { - public: - template - QFilePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QFileDevicePrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/core/qfile_wrapper.h b/v8/include/modules/core/qfile_wrapper.h deleted file mode 100644 index b8bb7c5..0000000 --- a/v8/include/modules/core/qfile_wrapper.h +++ /dev/null @@ -1,99 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qfiledevice_wrapper.h" -namespace shelllet { - namespace core { - template class QFilePrivate; - template - class QFileWrapper : public QFileDeviceWrapper - { - public: - - template - QFileWrapper(QFilePrivate& d, const v8::FunctionCallbackInfo& args) - : QFileDeviceWrapper(d, args) { - } - QFileWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QFileDeviceWrapper(isolate, tpl) {} - QFileWrapper(v8::Isolate* isolate, const v8::Local& proto) : QFileDeviceWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "remove", v8::FunctionTemplate::New(isolate, Remove)); - tpl->PrototypeTemplate()->Set(isolate, "setFileName", v8::FunctionTemplate::New(isolate, SetFileName)); - tpl->PrototypeTemplate()->Set(isolate, "rename", v8::FunctionTemplate::New(isolate, Rename)); - - { - tpl->Set(isolate, "remove", v8::FunctionTemplate::New(isolate, Remove)); - tpl->Set(isolate, "rename", v8::FunctionTemplate::New(isolate, Rename)); - tpl->Set(isolate, "removeAll", v8::FunctionTemplate::New(isolate, RemoveAll)); - } - } - - protected: - - static void SetFileName(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value name(isolate, args[0]); - p->d_func()->setFileName(*name); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Remove(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() == 0) { - v8::String::Utf8Value target(args.GetIsolate(), args[0]); - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - p->d_func()->remove(); - } - else if (args.Length() > 1 && args[0]->IsString()) - { - v8::String::Utf8Value target(args.GetIsolate(), args[1]); - QFile::remove(*target); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RemoveAll(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value target(args.GetIsolate(), args[0]); - std::filesystem::remove_all(*target); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Rename(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto b = args.This()->IsObject(); - - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value target(args.GetIsolate(), args[0]); - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - args.GetReturnValue().Set(p->d_func()->rename(*target)); - } - else if (args.Length() > 1 && args[0]->IsString() && args[1]->IsString()) - { - v8::String::Utf8Value src(args.GetIsolate(), args[0]); - v8::String::Utf8Value target(args.GetIsolate(), args[1]); - args.GetReturnValue().Set(QFile::rename(*src, *target)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/core/qfiledevice_implement.h b/v8/include/modules/core/qfiledevice_implement.h deleted file mode 100644 index 55f3772..0000000 --- a/v8/include/modules/core/qfiledevice_implement.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qfiledevice_p.h" -#include "qfiledevice_wrapper.h" - -namespace shelllet { - namespace core { - class FileDevice : public QFileDeviceWrapper - { - using ReturnType = QFileDevicePrivate; - using ReturnType2 = QFileDevicePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - FileDevice(const v8::FunctionCallbackInfo& args) :QFileDeviceWrapper(*Private(args), args) { - } - FileDevice(QFileDevice* p, const v8::FunctionCallbackInfo& args) : QFileDeviceWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - FileDevice(v8::Isolate* isolate, const v8::Local& tpl) : QFileDeviceWrapper(isolate, tpl) {} - FileDevice(v8::Isolate* isolate, const v8::Local& proto) : QFileDeviceWrapper(isolate, proto) { - } - - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/core/qfiledevice_p.h b/v8/include/modules/core/qfiledevice_p.h deleted file mode 100644 index 2018b4a..0000000 --- a/v8/include/modules/core/qfiledevice_p.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "qiodevice_p.h" - -namespace shelllet::core { - template - class QFileDevicePrivate : public QIODevicePrivate - { - public: - template - QFileDevicePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QIODevicePrivate(isolate, obj, std::forward(args)...) { - } - QString fileName() const override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->fileName(); - } - return __super::fileName(); - } - }; -} diff --git a/v8/include/modules/core/qfiledevice_wrapper.h b/v8/include/modules/core/qfiledevice_wrapper.h deleted file mode 100644 index c1d9e50..0000000 --- a/v8/include/modules/core/qfiledevice_wrapper.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qiodevice_wrapper.h" - -namespace shelllet { - namespace core { - template class QFileDevicePrivate; - template - class QFileDeviceWrapper : public QIODeviceWrapper - { - template friend class QFileDevicePrivate; - public: - template - QFileDeviceWrapper(QFileDevicePrivate& d, const v8::FunctionCallbackInfo& args) - : QIODeviceWrapper(d, args) { - } - - QFileDeviceWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QIODeviceWrapper(isolate, tpl) {} - QFileDeviceWrapper(v8::Isolate* isolate, const v8::Local& proto) : QIODeviceWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "fileName", v8::FunctionTemplate::New(isolate, FileName)); - } - protected: - QString fileName() const - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local o = d_func()->object_this.Get(isolate); - v8::Local proto = o->GetPrototype()->ToObject(context).ToLocalChecked(); - - v8::Local value = proto->Get(context, V8_NEW_STRING_VAR(isolate, "fileName")).ToLocalChecked(); - - auto f = v8::Local::Cast(value); - auto res = f->CallAsFunction(context, d_func()->object_this.Get(isolate), 0, {}).ToLocalChecked(); - if (!res.IsEmpty() && res->IsString()) { - v8::String::Utf8Value name(isolate, res); - - if (*name) { - return *name; - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - return QString(); - } - - protected: - - static void FileName(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto name = p->d_func()->fileName(); - - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, qPrintable(name))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/core/qiodevice_implement.h b/v8/include/modules/core/qiodevice_implement.h deleted file mode 100644 index 09e262c..0000000 --- a/v8/include/modules/core/qiodevice_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "core_module.h" -#include "qiodevice_p.h" -#include "qiodevice_wrapper.h" - -namespace shelllet { - namespace core { - class IODevice : public QIODeviceWrapper - { - using ReturnType = QIODevicePrivate; - using ReturnType2 = QIODevicePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - - IODevice(const v8::FunctionCallbackInfo& args) : QIODeviceWrapper(*Private(args), args) {} - IODevice(QIODevice* p, const v8::FunctionCallbackInfo& args) : QIODeviceWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - IODevice(v8::Isolate* isolate, const v8::Local& tpl) : QIODeviceWrapper(isolate, tpl) {} - IODevice(v8::Isolate* isolate, const v8::Local& proto) : QIODeviceWrapper(isolate, proto) { - } - - static const char* Name() { return "QIODevice"; } - - public: - }; - } -} diff --git a/v8/include/modules/core/qiodevice_p.h b/v8/include/modules/core/qiodevice_p.h deleted file mode 100644 index eb40bab..0000000 --- a/v8/include/modules/core/qiodevice_p.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "qobject_p.h" - -namespace shelllet::core { - template - class QIODevicePrivate : public QObjectPrivate - { - public: - template - QIODevicePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - qint64 readData(char* data, qint64 maxlen) override - { - throw std::logic_error("The method or operation is not implemented."); - } - - qint64 writeData(const char* data, qint64 len) override - { - throw std::logic_error("The method or operation is not implemented."); - } - - qint64 size() const override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->size(); - } - return __super::size(); - } - }; -} diff --git a/v8/include/modules/core/qiodevice_wrapper.h b/v8/include/modules/core/qiodevice_wrapper.h deleted file mode 100644 index 8502e01..0000000 --- a/v8/include/modules/core/qiodevice_wrapper.h +++ /dev/null @@ -1,752 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qobject_wrapper.h" - -namespace shelllet { - namespace core { - template class QIODevicePrivate; - template - class QIODeviceWrapper : public QObjectWrapper - { - public: - - template - QIODeviceWrapper(QIODevicePrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - - QIODeviceWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QIODeviceWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "atEnd", v8::FunctionTemplate::New(isolate, AtEnd)); - tpl->PrototypeTemplate()->Set(isolate, "bytesAvailable", v8::FunctionTemplate::New(isolate, BytesAvailable)); - tpl->PrototypeTemplate()->Set(isolate, "bytesToWrite", v8::FunctionTemplate::New(isolate, BytesToWrite)); - tpl->PrototypeTemplate()->Set(isolate, "canReadLine", v8::FunctionTemplate::New(isolate, CanReadLine)); - tpl->PrototypeTemplate()->Set(isolate, "close", v8::FunctionTemplate::New(isolate, Close)); - tpl->PrototypeTemplate()->Set(isolate, "commitTransaction", v8::FunctionTemplate::New(isolate, CommitTransaction)); - tpl->PrototypeTemplate()->Set(isolate, "currentReadChannel", v8::FunctionTemplate::New(isolate, CurrentReadChannel)); - tpl->PrototypeTemplate()->Set(isolate, "currentWriteChannel", v8::FunctionTemplate::New(isolate, CurrentWriteChannel)); - tpl->PrototypeTemplate()->Set(isolate, "errorString", v8::FunctionTemplate::New(isolate, ErrorString)); - tpl->PrototypeTemplate()->Set(isolate, "getChar", v8::FunctionTemplate::New(isolate, GetChar)); - tpl->PrototypeTemplate()->Set(isolate, "isOpen", v8::FunctionTemplate::New(isolate, IsOpen)); - tpl->PrototypeTemplate()->Set(isolate, "isReadable", v8::FunctionTemplate::New(isolate, IsReadable)); - tpl->PrototypeTemplate()->Set(isolate, "isSequential", v8::FunctionTemplate::New(isolate, IsSequential)); - tpl->PrototypeTemplate()->Set(isolate, "isTextModeEnabled", v8::FunctionTemplate::New(isolate, IsTextModeEnabled)); - tpl->PrototypeTemplate()->Set(isolate, "isTransactionStarted", v8::FunctionTemplate::New(isolate, IsTransactionStarted)); - tpl->PrototypeTemplate()->Set(isolate, "isWritable", v8::FunctionTemplate::New(isolate, IsWritable)); - tpl->PrototypeTemplate()->Set(isolate, "open", v8::FunctionTemplate::New(isolate, Open)); - tpl->PrototypeTemplate()->Set(isolate, "openMode", v8::FunctionTemplate::New(isolate, OpenMode)); - tpl->PrototypeTemplate()->Set(isolate, "peek", v8::FunctionTemplate::New(isolate, Peek)); - tpl->PrototypeTemplate()->Set(isolate, "putChar", v8::FunctionTemplate::New(isolate, PutChar)); - tpl->PrototypeTemplate()->Set(isolate, "read", v8::FunctionTemplate::New(isolate, Read)); - tpl->PrototypeTemplate()->Set(isolate, "readAll", v8::FunctionTemplate::New(isolate, ReadAll)); - tpl->PrototypeTemplate()->Set(isolate, "readChannelCount", v8::FunctionTemplate::New(isolate, ReadChannelCount)); - tpl->PrototypeTemplate()->Set(isolate, "readLine", v8::FunctionTemplate::New(isolate, ReadLine)); - tpl->PrototypeTemplate()->Set(isolate, "reset", v8::FunctionTemplate::New(isolate, Reset)); - tpl->PrototypeTemplate()->Set(isolate, "rollbackTransaction", v8::FunctionTemplate::New(isolate, RollbackTransaction)); - tpl->PrototypeTemplate()->Set(isolate, "seek", v8::FunctionTemplate::New(isolate, Seek)); - tpl->PrototypeTemplate()->Set(isolate, "setCurrentReadChannel", v8::FunctionTemplate::New(isolate, SetCurrentReadChannel)); - tpl->PrototypeTemplate()->Set(isolate, "setCurrentWriteChannel", v8::FunctionTemplate::New(isolate, SetCurrentWriteChannel)); - tpl->PrototypeTemplate()->Set(isolate, "setTextModeEnabled", v8::FunctionTemplate::New(isolate, SetTextModeEnabled)); - tpl->PrototypeTemplate()->Set(isolate, "size", v8::FunctionTemplate::New(isolate, Size)); - tpl->PrototypeTemplate()->Set(isolate, "skip", v8::FunctionTemplate::New(isolate, Skip)); - tpl->PrototypeTemplate()->Set(isolate, "startTransaction", v8::FunctionTemplate::New(isolate, StartTransaction)); - tpl->PrototypeTemplate()->Set(isolate, "ungetChar", v8::FunctionTemplate::New(isolate, UngetChar)); - tpl->PrototypeTemplate()->Set(isolate, "waitForBytesWritten", v8::FunctionTemplate::New(isolate, WaitForBytesWritten)); - tpl->PrototypeTemplate()->Set(isolate, "waitForReadyRead", v8::FunctionTemplate::New(isolate, WaitForReadyRead)); - tpl->PrototypeTemplate()->Set(isolate, "write", v8::FunctionTemplate::New(isolate, Write)); - tpl->PrototypeTemplate()->Set(isolate, "writeChannelCount", v8::FunctionTemplate::New(isolate, WriteChannelCount)); - - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "readyRead"), nullptr, ReadyRead); - { - v8::Local open_mode_flag = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, NotOpen); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, ReadOnly); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, WriteOnly); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, ReadWrite); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, Append); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, Truncate); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, Text); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, Unbuffered); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, NewOnly); - V8_CREATE_ENUM_SYMBOL(open_mode_flag, isolate, QIODevice, OpenModeFlag, ExistingOnly); - - tpl->Set(isolate, "OpenMode", open_mode_flag); - } - } - protected: - qint64 size() const - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local o = d_func()->object_this.Get(isolate); - v8::Local proto = o->GetPrototype()->ToObject(context).ToLocalChecked(); - - v8::Local value = proto->Get(context, V8_NEW_STRING_VAR(isolate, "size")).ToLocalChecked(); - - auto f = v8::Local::Cast(value); - - auto res = f->CallAsFunction(context, o, 0, {}).ToLocalChecked(); - if (!res.IsEmpty()) { - if (res->IsNumber()) - { - return res->Int32Value(context).FromJust(); - } - else if (res->IsBigInt()) { - auto n = res->ToBigInt(context).ToLocalChecked(); - - if (!n.IsEmpty()) { - return n->Int64Value(); - } - } - } - } - - V8_CREATE_LOCAL_CONTEXT_END - return 0; - } - public: - - static void OpenMode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->openMode(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetTextModeEnabled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsBoolean()) { - p->d_func()->setTextModeEnabled(args[0]->BooleanValue(isolate)); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsTextModeEnabled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isTextModeEnabled(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsOpen(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isOpen(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsReadable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isReadable(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsWritable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isWritable(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsSequential(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isSequential(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadChannelCount(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->readChannelCount(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WriteChannelCount(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->writeChannelCount(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CurrentReadChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->currentReadChannel(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetCurrentReadChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - p->d_func()->setCurrentReadChannel(args[0]->Int32Value(context).FromJust()); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CurrentWriteChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->currentWriteChannel(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetCurrentWriteChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - p->d_func()->setCurrentWriteChannel(args[0]->Int32Value(context).FromJust()); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Open(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - QIODevice::OpenMode mode = static_cast(args[0]->Int32Value(context).FromJust()); - args.GetReturnValue().Set(p->d_func()->open(mode)); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Close(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->close(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Size(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->size(); - - args.GetReturnValue().Set(v8::BigInt::New(isolate, result)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Seek(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - qint64 pos = args[0]->ToBigInt(context).ToLocalChecked()->Int64Value(); - bool result = p->d_func()->seek(pos); - - args.GetReturnValue().Set(result); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void AtEnd(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->atEnd(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Reset(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->reset(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BytesAvailable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->bytesAvailable(); - - args.GetReturnValue().Set(v8::BigInt::New(isolate, result)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BytesToWrite(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->bytesToWrite(); - - args.GetReturnValue().Set(v8::BigInt::New(isolate, result)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Read(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - qint64 maxSize = args[0]->ToBigInt(context).ToLocalChecked()->Int64Value(); - QByteArray bytes = p->d_func()->read(maxSize); - - v8::Local buffer = v8::ArrayBuffer::New(isolate, bytes.data(), bytes.length()); - - v8::Local array = v8::Uint8Array::New(buffer, 0, buffer->ByteLength()); - - args.GetReturnValue().Set(array); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadAll(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->readAll(); - - v8::Local buffer = v8::ArrayBuffer::New(isolate, result.data(), result.length()); - - v8::Local array = v8::Uint8Array::New(buffer, 0, buffer->ByteLength()); - - args.GetReturnValue().Set(array); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadLine(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - qint64 maxSize = 0; - if (args.Length() > 0 && args[0]->IsNumber()) { - maxSize = args[0]->ToBigInt(context).ToLocalChecked()->Int64Value(); - } - QByteArray bytes = p->d_func()->readLine(maxSize); - - v8::Local buffer = v8::ArrayBuffer::New(isolate, bytes.data(), bytes.length()); - - v8::Local array = v8::Uint8Array::New(buffer, 0, buffer->ByteLength()); - - args.GetReturnValue().Set(array); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CanReadLine(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->canReadLine(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StartTransaction(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->startTransaction(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CommitTransaction(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->commitTransaction(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RollbackTransaction(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->rollbackTransaction(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsTransactionStarted(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isTransactionStarted(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Write(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - - if (V8_IsString(args, 0)) { - qint64 bytes = p->d_func()->write(convert::String::To(isolate, args[0]).toUtf8()); - args.GetReturnValue().Set(v8::BigInt::New(isolate, bytes)); - } - else if (V8_IsUint8Array(args, 0)) { - QByteArray data; - convert::Uint8Array::To(args[0], data); - qint64 bytes = p->d_func()->write(data); - args.GetReturnValue().Set(v8::BigInt::New(isolate, bytes)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Peek(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - qint64 maxSize = args[0]->ToBigInt(context).ToLocalChecked()->Int64Value(); - QByteArray bytes = p->d_func()->peek(maxSize); - - v8::Local buffer = v8::ArrayBuffer::New(isolate, bytes.data(), bytes.length()); - - v8::Local array = v8::Uint8Array::New(buffer, 0, buffer->ByteLength()); - - args.GetReturnValue().Set(array); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Skip(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - qint64 maxSize = args[0]->ToBigInt(context).ToLocalChecked()->Int64Value(); - args.GetReturnValue().Set(v8::BigInt::New(isolate, p->d_func()->skip(maxSize))); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForReadyRead(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - int msecs = args[0]->Int32Value(context).FromJust(); - args.GetReturnValue().Set(p->d_func()->waitForReadyRead(msecs)); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForBytesWritten(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - int msecs = args[0]->Int32Value(context).FromJust(); - args.GetReturnValue().Set(p->d_func()->waitForBytesWritten(msecs)); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void UngetChar(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value s(isolate, args[0]); - if (*s) { - p->d_func()->ungetChar((*s)[0]); - } - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PutChar(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value s(isolate, args[0]); - if (*s) { - p->d_func()->putChar((*s)[0]); - } - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetChar(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - char c; - p->d_func()->getChar(&c); - args.GetReturnValue().Set(v8::String::NewFromUtf8(isolate, &c, v8::NewStringType::kNormal, 1).ToLocalChecked()); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ErrorString(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->errorString(); - - args.GetReturnValue().Set(convert::String::New(isolate, qPrintable(result))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadyRead(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weak_persistent = std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QIODevice::readyRead, [weak_persistent]() { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - - weak_persistent->Get(isolate)->CallAsFunction(context, context->Global(), 0, {}); - if (try_catch.HasCaught()) { - qCCritical(shelllet_filesystem) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QIODevice::readyRead, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/core/qobject_implement.h b/v8/include/modules/core/qobject_implement.h deleted file mode 100644 index 81ca7cd..0000000 --- a/v8/include/modules/core/qobject_implement.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "framework.h" -#include "qobject_p.h" -#include "qobject_wrapper.h" - -namespace shelllet { - namespace core { - class Object : public virtual QObjectWrapper - { - using ReturnType = QObjectPrivate; - using ReturnType2 = QObjectPrivate; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - Object(const v8::FunctionCallbackInfo& args) : QObjectWrapper(*Param(args), args) - { - } - Object(QObject* p, const v8::FunctionCallbackInfo& args) : QObjectWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Object(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - Object(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) - { - } - - public: - static const char* Name() { - return "QObject"; - } - }; - } -} diff --git a/v8/include/modules/core/qobject_p.h b/v8/include/modules/core/qobject_p.h deleted file mode 100644 index 617f278..0000000 --- a/v8/include/modules/core/qobject_p.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include "framework.h" -#include - -namespace shelllet { - namespace core { - template - class QObjectPrivate : public ObjectPrivate - { - public: - template - QObjectPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - virtual ~QObjectPrivate() { - if (!weak_objectnamechanged.isNull()) { - weak_objectnamechanged.toStrongRef().reset(); - } - std::for_each(connections.begin(), connections.end(), std::bind([](auto& itor) { itor.second.second.Reset(); }, std::placeholders::_1)); - } - void pushConnection(const std::string& name, QMetaObject::Connection c, CopyablePersistent p) { - connections[name] = std::make_pair(c, p); - } - bool removeConnection(const std::string& name) { - if (connections.contains(name)) { - QObject::disconnect(connections[name].first); - return connections.erase(name) == 1; - } - return false; - } - - QWeakPointer> weak_objectnamechanged; - - std::map>> connections; - protected: - - // - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qobject_wrapper.h b/v8/include/modules/core/qobject_wrapper.h deleted file mode 100644 index 8d267f5..0000000 --- a/v8/include/modules/core/qobject_wrapper.h +++ /dev/null @@ -1,176 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QObjectWrapper : public ObjectWrapper - { - public: - template - QObjectWrapper(QObjectPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) - { - } - QObjectWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QObjectWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) { - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "objectName"), ObjectName, SetObjectName); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "objectNameChanged"), nullptr, SetObjectNameChanged); - - proto->Set(isolate, "timerEvent", v8::FunctionTemplate::New(isolate, TimerEvent)); - //proto->PrototypeTemplate()->Set(isolate, "connect", v8::FunctionTemplate::New(isolate, Connect)); - //proto->PrototypeTemplate()->Set(isolate, "disconnect", v8::FunctionTemplate::New(isolate, Disconnect)); - if constexpr (!std::is_same_v, QTimer>) { - proto->Set(isolate, "startTimer", v8::FunctionTemplate::New(isolate, StartTimer)); - proto->Set(isolate, "killTimer", v8::FunctionTemplate::New(isolate, KillTimer)); - } - } - - virtual ~QObjectWrapper() {} - protected: - - virtual void timerEvent(QTimerEvent* event) - { - //v8::Isolate* isolate = v8::Isolate::GetCurrent(); - - //V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO_2(isolate) { - // if (!d_ptr->global_timer_event.IsEmpty()) { - // v8::Local argv[] = { v8::Int32::New(isolate, event->timerId()) }; - // d_ptr->global_timer_event.Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - // } - //} - } - - /*static void Connect(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() == 2 && args[0]->IsString() && args[1]->IsFunction()) { - auto* p = convert::Object::UnWrap>(args.This()); - v8::String::Utf8Value name(isolate, args[0]); - - QMetaObject::Connection conn = p->connect(*name); - if (conn) { - (*p)->pushConnection(*name, conn, CopyablePersistent(isolate, v8::Local::Cast(args[1]))); - } - args.GetReturnValue().Set(conn); - } - } -V8_CREATE_LOCAL_CONTEXT_END -} - - static void Disconnect(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value name(isolate, args[0]); - auto* p = convert::Object::UnWrap>(args.This()); - args.GetReturnValue().Set(p->disconnect(*name)); - } - } - }*/ - - static void ObjectName(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (p) - { - info.GetReturnValue().Set(V8_NEW_WSTRING_VAR(isolate, (*p)->objectName().toStdWString().c_str())); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetObjectNameChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - if (value->IsFunction()) { - auto* p = UnWrap>(info.This()); - - //if (!(*p)->weak_objectnamechanged) { - v8::Local f = v8::Local::Cast(value); - QSharedPointer>weak_persistent = QSharedPointer>::create(isolate, f); - //(*p)->weak_objectnamechanged = weak_persistent; - - QObject::connect((*p), &QObject::objectNameChanged, [weak_persistent](const QString& objectName) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { V8_NEW_WSTRING_VAR(isolate, objectName.toStdWString().c_str()) }; - weak_persistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - //qCCritical(shelllet_common) << try_catch.Exception(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - //} - } - else { - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetObjectName(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - v8::String::Utf8Value name(isolate, value); - if (*name) { - (*p)->setObjectName(*name); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StartTimer(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - int ms = 0; - Qt::TimerType timerType = Qt::CoarseTimer; - - if (args.Length() > 0 && args[0]->IsNumber()) { - ms = args[0]->Int32Value(context).FromJust(); - } - if (args.Length() > 1 && args[1]->IsNumber()) { - timerType = static_cast(args[1]->Int32Value(context).FromJust()); - } - auto* p = UnWrap>(args.This()); - - if (p) { - int id = (*p)->startTimer(ms, timerType); - args.GetReturnValue().Set(id); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void KillTimer(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() > 0 && args[0]->IsNumber()) { - int id = args[0]->Int32Value(context).FromJust(); - auto* p = UnWrap>(args.This()); - - if (p) { - (*p)->killTimer(id); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void TimerEvent(const v8::FunctionCallbackInfo& args) - { - } - }; - } -} diff --git a/v8/include/modules/core/qpoint_implement.h b/v8/include/modules/core/qpoint_implement.h deleted file mode 100644 index a6c1742..0000000 --- a/v8/include/modules/core/qpoint_implement.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qpoint_p.h" -#include "qpoint_wrapper.h" - -namespace shelllet { - namespace core { - class Point : public QPointWrapper - { - public: - using ReturnType = QPointPrivate; - using ReturnType2 = QPointPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - auto w = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto h = args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - return new ReturnType(args.GetIsolate(), args.This(), w, h); - } - Point(const v8::FunctionCallbackInfo& args) :QPointWrapper(*Private(args), args) - { - } - Point(QPoint* p, const v8::FunctionCallbackInfo& args) : QPointWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Point(v8::Isolate* isolate, const v8::Local& tpl) : QPointWrapper(isolate, tpl) {} - Point(v8::Isolate* isolate, const v8::Local& proto) : QPointWrapper(isolate, proto) - {} - - static const char* Name() { return "Point"; } - protected: - - virtual void toString(std::stringstream& ss) const { - ss << "(" << (*this)->x() << ", " << (*this)->y() << ")"; - } - }; - } -} diff --git a/v8/include/modules/core/qpoint_p.h b/v8/include/modules/core/qpoint_p.h deleted file mode 100644 index 5515a80..0000000 --- a/v8/include/modules/core/qpoint_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QPointPrivate : public ObjectPrivate - { - public: - template - QPointPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/core/qpoint_wrapper.h b/v8/include/modules/core/qpoint_wrapper.h deleted file mode 100644 index 2892ded..0000000 --- a/v8/include/modules/core/qpoint_wrapper.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template class QPointPrivate; - template - class QPointWrapper : public ObjectWrapper - { - public: - template - QPointWrapper(QPointPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QPointWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QPointWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "x"), GetX, SetX); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "y"), GetY, SetY); - } - - protected: - - static void GetX(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - info.GetReturnValue().Set(v8::Int32::New(info.GetIsolate(), (*self)->x())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetX(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - (*self)->setX(value->Int32Value(context).FromJust()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetY(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Int32::New(info.GetIsolate(), (*self)->y())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetY(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - (*self)->setY(value->Int32Value(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qpointf_implement.h b/v8/include/modules/core/qpointf_implement.h deleted file mode 100644 index 063c692..0000000 --- a/v8/include/modules/core/qpointf_implement.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qpointf_p.h" -#include "qpointf_wrapper.h" - -namespace shelllet { - namespace core { - class PointF : public QPointFWrapper - { - public: - using ReturnType = QPointFPrivate; - using ReturnType2 = QPointFPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - auto w = args[0]->NumberValue(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto h = args[1]->NumberValue(args.GetIsolate()->GetCurrentContext()).FromJust(); - return new ReturnType(args.GetIsolate(), args.This(), w, h); - } - PointF(const v8::FunctionCallbackInfo& args) :QPointFWrapper(*Private(args), args) - { - } - PointF(QPointF* p, const v8::FunctionCallbackInfo& args) :QPointFWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - PointF(v8::Isolate* isolate, const v8::Local& tpl) : QPointFWrapper(isolate, tpl) - { - } - PointF(v8::Isolate* isolate, const v8::Local& proto) : QPointFWrapper(isolate, proto) - { - } - - protected: - void toString(std::stringstream& ss) const { ss << "(" << (*this)->x() << ", " << (*this)->y() << ")"; } - public: - static const char* Name() { return "PointF"; } - protected: - }; - } -} diff --git a/v8/include/modules/core/qpointf_p.h b/v8/include/modules/core/qpointf_p.h deleted file mode 100644 index ebac534..0000000 --- a/v8/include/modules/core/qpointf_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QPointFPrivate : public ObjectPrivate - { - public: - template - QPointFPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/core/qpointf_wrapper.h b/v8/include/modules/core/qpointf_wrapper.h deleted file mode 100644 index 153c77c..0000000 --- a/v8/include/modules/core/qpointf_wrapper.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QPointFWrapper : public ObjectWrapper - { - public: - template - QPointFWrapper(QPointFPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QPointFWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - } - QPointFWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "x"), GetX, SetX); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "y"), GetY, SetY); - } - - protected: - static void GetX(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - info.GetReturnValue().Set(v8::Number::New(info.GetIsolate(), (*self)->x())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetX(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - (*self)->setX(value->NumberValue(context).FromJust()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetY(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Number::New(info.GetIsolate(), (*self)->y())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetY(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - (*self)->setY(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qprocess_implement.h b/v8/include/modules/core/qprocess_implement.h deleted file mode 100644 index e8d3555..0000000 --- a/v8/include/modules/core/qprocess_implement.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include -#include "core_module.h" -#include "qprocess_p.h" -#include "qprocess_wrapper.h" -namespace shelllet { - namespace core { - class Process : public QProcessWrapper - { - using ReturnType = QProcessPrivate; - using ReturnType2 = QProcessPrivate; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - - Process(const v8::FunctionCallbackInfo& args) : QProcessWrapper(*Param(args), args) - { - } - Process(v8::Isolate* isolate, const v8::Local& tpl) : QProcessWrapper(isolate, tpl) {} - Process(v8::Isolate* isolate, const v8::Local& proto) : QProcessWrapper(isolate, proto) { - } - - static const char* Name() { - return "QProcess"; - } - public: - }; - } -} diff --git a/v8/include/modules/core/qprocess_p.h b/v8/include/modules/core/qprocess_p.h deleted file mode 100644 index 4659c9d..0000000 --- a/v8/include/modules/core/qprocess_p.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once -#include "qiodevice_p.h" - -namespace shelllet::core { - template - class QProcessPrivate : public QIODevicePrivate - { - public: - template - QProcessPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QIODevicePrivate(isolate, obj, std::forward(args)...) { - } - template - QProcessPrivate(T* d, v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QIODevicePrivate(d, std::forward(args)...) { - } - void setupChildProcess() override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->setupChildProcess(); - } - return __super::setupChildProcess(); - } - }; -} diff --git a/v8/include/modules/core/qprocess_wrapper.h b/v8/include/modules/core/qprocess_wrapper.h deleted file mode 100644 index 1f3ab74..0000000 --- a/v8/include/modules/core/qprocess_wrapper.h +++ /dev/null @@ -1,1139 +0,0 @@ -#pragma once -#include "qiodevice_wrapper.h" -namespace shelllet { - namespace core { - template class QProcessPrivate; - template - class QProcessWrapper : public QIODeviceWrapper - { - public: - - template - QProcessWrapper(QProcessPrivate& d, const v8::FunctionCallbackInfo& args) - : QIODeviceWrapper(d, args) { - } - QProcessWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QIODeviceWrapper(isolate, tpl) {} - QProcessWrapper(v8::Isolate* isolate, const v8::Local& proto) : QIODeviceWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "arguments", v8::FunctionTemplate::New(isolate, Arguments)); - tpl->PrototypeTemplate()->Set(isolate, "closeWriteChannel", v8::FunctionTemplate::New(isolate, CloseWriteChannel)); - tpl->PrototypeTemplate()->Set(isolate, "createProcessArgumentsModifier", v8::FunctionTemplate::New(isolate, CreateProcessArgumentsModifier)); - tpl->PrototypeTemplate()->Set(isolate, "environment", v8::FunctionTemplate::New(isolate, Environment)); - tpl->PrototypeTemplate()->Set(isolate, "error", v8::FunctionTemplate::New(isolate, Error)); - tpl->PrototypeTemplate()->Set(isolate, "exitCode", v8::FunctionTemplate::New(isolate, ExitCode)); - tpl->PrototypeTemplate()->Set(isolate, "exitStatus", v8::FunctionTemplate::New(isolate, ExitStatus)); - tpl->PrototypeTemplate()->Set(isolate, "inputChannelMode", v8::FunctionTemplate::New(isolate, InputChannelMode)); - tpl->PrototypeTemplate()->Set(isolate, "kill", v8::FunctionTemplate::New(isolate, Kill)); - tpl->PrototypeTemplate()->Set(isolate, "nativeArguments", v8::FunctionTemplate::New(isolate, NativeArguments)); - tpl->PrototypeTemplate()->Set(isolate, "pid", v8::FunctionTemplate::New(isolate, Pid)); - tpl->PrototypeTemplate()->Set(isolate, "processChannelMode", v8::FunctionTemplate::New(isolate, ProcessChannelMode)); - tpl->PrototypeTemplate()->Set(isolate, "processEnvironment", v8::FunctionTemplate::New(isolate, ProcessEnvironment)); - tpl->PrototypeTemplate()->Set(isolate, "processId", v8::FunctionTemplate::New(isolate, ProcessId)); - tpl->PrototypeTemplate()->Set(isolate, "program", v8::FunctionTemplate::New(isolate, Program)); - tpl->PrototypeTemplate()->Set(isolate, "readAllStandardError", v8::FunctionTemplate::New(isolate, ReadAllStandardError)); - tpl->PrototypeTemplate()->Set(isolate, "readAllStandardOutput", v8::FunctionTemplate::New(isolate, ReadAllStandardOutput)); - tpl->PrototypeTemplate()->Set(isolate, "readChannel", v8::FunctionTemplate::New(isolate, ReadChannel)); - tpl->PrototypeTemplate()->Set(isolate, "readChannelMode", v8::FunctionTemplate::New(isolate, ReadChannelMode)); - tpl->PrototypeTemplate()->Set(isolate, "setArguments", v8::FunctionTemplate::New(isolate, SetArguments)); - tpl->PrototypeTemplate()->Set(isolate, "setCreateProcessArgumentsModifier", v8::FunctionTemplate::New(isolate, SetCreateProcessArgumentsModifier)); - tpl->PrototypeTemplate()->Set(isolate, "setEnvironment", v8::FunctionTemplate::New(isolate, SetEnvironment)); - tpl->PrototypeTemplate()->Set(isolate, "setInputChannelMode", v8::FunctionTemplate::New(isolate, SetInputChannelMode)); - tpl->PrototypeTemplate()->Set(isolate, "setNativeArguments", v8::FunctionTemplate::New(isolate, SetNativeArguments)); - tpl->PrototypeTemplate()->Set(isolate, "setProcessChannelMode", v8::FunctionTemplate::New(isolate, SetProcessChannelMode)); - tpl->PrototypeTemplate()->Set(isolate, "setProcessEnvironment", v8::FunctionTemplate::New(isolate, SetProcessEnvironment)); - tpl->PrototypeTemplate()->Set(isolate, "setProgram", v8::FunctionTemplate::New(isolate, SetProgram)); - tpl->PrototypeTemplate()->Set(isolate, "setReadChannel", v8::FunctionTemplate::New(isolate, SetReadChannel)); - tpl->PrototypeTemplate()->Set(isolate, "setReadChannelMode", v8::FunctionTemplate::New(isolate, SetReadChannelMode)); - tpl->PrototypeTemplate()->Set(isolate, "setStandardErrorFile", v8::FunctionTemplate::New(isolate, SetStandardErrorFile)); - tpl->PrototypeTemplate()->Set(isolate, "setStandardInputFile", v8::FunctionTemplate::New(isolate, SetStandardInputFile)); - tpl->PrototypeTemplate()->Set(isolate, "setStandardOutputFile", v8::FunctionTemplate::New(isolate, SetStandardOutputFile)); - tpl->PrototypeTemplate()->Set(isolate, "setStandardOutputProcess", v8::FunctionTemplate::New(isolate, SetStandardOutputProcess)); - tpl->PrototypeTemplate()->Set(isolate, "setWorkingDirectory", v8::FunctionTemplate::New(isolate, SetWorkingDirectory)); - tpl->PrototypeTemplate()->Set(isolate, "start", v8::FunctionTemplate::New(isolate, Start)); - tpl->PrototypeTemplate()->Set(isolate, "startDetached", v8::FunctionTemplate::New(isolate, StartDetached)); - tpl->PrototypeTemplate()->Set(isolate, "state", v8::FunctionTemplate::New(isolate, State)); - tpl->PrototypeTemplate()->Set(isolate, "terminate", v8::FunctionTemplate::New(isolate, Terminate)); - tpl->PrototypeTemplate()->Set(isolate, "waitForFinished", v8::FunctionTemplate::New(isolate, WaitForFinished)); - tpl->PrototypeTemplate()->Set(isolate, "waitForStarted", v8::FunctionTemplate::New(isolate, WaitForStarted)); - tpl->PrototypeTemplate()->Set(isolate, "workingDirectory", v8::FunctionTemplate::New(isolate, WorkingDirectory)); - - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "errorOccurred"), nullptr, ErrorOccurred); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "finished"), nullptr, Finished); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "started"), nullptr, Started); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "readyReadStandardError"), nullptr, ReadyReadStandardError); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "readyReadStandardOutput"), nullptr, ReadyReadStandardOutput); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "stateChanged"), nullptr, StateChanged); - { - v8::Local processError = v8::ObjectTemplate::New(isolate); - processError->Set(isolate, "FailedToStart", v8::Int32::New(isolate, QProcess::ProcessError::FailedToStart)); - processError->Set(isolate, "Crashed", v8::Int32::New(isolate, QProcess::ProcessError::Crashed)); - processError->Set(isolate, "Timedout", v8::Int32::New(isolate, QProcess::ProcessError::Timedout)); - processError->Set(isolate, "ReadError", v8::Int32::New(isolate, QProcess::ProcessError::ReadError)); - processError->Set(isolate, "WriteError", v8::Int32::New(isolate, QProcess::ProcessError::WriteError)); - processError->Set(isolate, "UnknownError", v8::Int32::New(isolate, QProcess::ProcessError::UnknownError)); - tpl->Set(isolate, "ProcessError", processError); - - v8::Local processState = v8::ObjectTemplate::New(isolate); - processState->Set(isolate, "NotRunning", v8::Int32::New(isolate, QProcess::ProcessState::NotRunning)); - processState->Set(isolate, "Starting", v8::Int32::New(isolate, QProcess::ProcessState::Starting)); - processState->Set(isolate, "Running", v8::Int32::New(isolate, QProcess::ProcessState::Running)); - tpl->Set(isolate, "ProcessState", processState); - - v8::Local processChannel = v8::ObjectTemplate::New(isolate); - processChannel->Set(isolate, "StandardOutput", v8::Int32::New(isolate, QProcess::ProcessChannel::StandardOutput)); - processChannel->Set(isolate, "StandardError", v8::Int32::New(isolate, QProcess::ProcessChannel::StandardError)); - tpl->Set(isolate, "ProcessChannel", processChannel); - - v8::Local processChannelMode = v8::ObjectTemplate::New(isolate); - processChannelMode->Set(isolate, "SeparateChannels", v8::Int32::New(isolate, QProcess::ProcessChannelMode::SeparateChannels)); - processChannelMode->Set(isolate, "MergedChannels", v8::Int32::New(isolate, QProcess::ProcessChannelMode::MergedChannels)); - processChannelMode->Set(isolate, "ForwardedChannels", v8::Int32::New(isolate, QProcess::ProcessChannelMode::ForwardedChannels)); - processChannelMode->Set(isolate, "ForwardedOutputChannel", v8::Int32::New(isolate, QProcess::ProcessChannelMode::ForwardedOutputChannel)); - processChannelMode->Set(isolate, "ForwardedErrorChannel", v8::Int32::New(isolate, QProcess::ProcessChannelMode::ForwardedErrorChannel)); - tpl->Set(isolate, "ProcessChannelMode", processChannelMode); - - v8::Local inputChannelMode = v8::ObjectTemplate::New(isolate); - inputChannelMode->Set(isolate, "ManagedInputChannel", v8::Int32::New(isolate, QProcess::InputChannelMode::ManagedInputChannel)); - inputChannelMode->Set(isolate, "ForwardedInputChannel", v8::Int32::New(isolate, QProcess::InputChannelMode::ForwardedInputChannel)); - tpl->Set(isolate, "InputChannelMode", inputChannelMode); - - v8::Local exitStatus = v8::ObjectTemplate::New(isolate); - exitStatus->Set(isolate, "NormalExit", v8::Int32::New(isolate, QProcess::ExitStatus::NormalExit)); - exitStatus->Set(isolate, "CrashExit", v8::Int32::New(isolate, QProcess::ExitStatus::CrashExit)); - tpl->Set(isolate, "ExitStatus", exitStatus); - - tpl->Set(isolate, "execute", v8::FunctionTemplate::New(isolate, Execute)); - tpl->Set(isolate, "nullDevice", v8::FunctionTemplate::New(isolate, NullDevice)); - tpl->Set(isolate, "startDetached", v8::FunctionTemplate::New(isolate, StartDetached)); - tpl->Set(isolate, "systemEnvironment", v8::FunctionTemplate::New(isolate, SystemEnvironment)); - } - } - - protected: - void setupChildProcess() - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - call(isolate, context, "setupChildProcess", 0, {}); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - protected: - - static void Arguments(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::Array::New(isolate, context, p->d_func()->invoke<&QProcess::arguments>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CloseReadChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto channel = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QProcess::closeReadChannel>(channel); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CloseWriteChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QProcess::closeWriteChannel>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CreateProcessArgumentsModifier(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - // TODO: - /*auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::createProcessArgumentsModifier>()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Environment(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::Array::New(isolate, context, p->d_func()->invoke<&QProcess::environment>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Error(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke(&QProcess::error)>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ExitCode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::exitCode>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ExitStatus(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::exitStatus>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void InputChannelMode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::inputChannelMode>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsSequential(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QProcess::isSequential>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Kill(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QProcess::kill>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void NativeArguments(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::String::New(isolate, p->d_func()->invoke<&QProcess::nativeArguments>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Pid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - // TODO: - //auto result = v8::BigInt::New(isolate, p->d_func()->invoke<&QProcess::pid>()); - //args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ProcessChannelMode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::processChannelMode>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ProcessEnvironment(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - // TODO: - //auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::processEnvironment>()); - //args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ProcessId(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::BigInt::New(isolate, p->d_func()->invoke<&QProcess::processId>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Program(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::String::New(isolate, p->d_func()->invoke<&QProcess::program>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadAllStandardError(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::Uint8Array::New(isolate, context, p->d_func()->invoke<&QProcess::readAllStandardError>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadAllStandardOutput(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::Uint8Array::New(isolate, context, p->d_func()->invoke<&QProcess::readAllStandardOutput>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::readChannel>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadChannelMode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::readChannelMode>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetArguments(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - - if (!args[0]->IsArray()) - throw std::invalid_argument("!`Array` required at [0]."); - QStringList arguments; - convert::Array::To(isolate, context, args[0], arguments); - - p->d_func()->invoke<&QProcess::setArguments>(arguments); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetCreateProcessArgumentsModifier(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto modifier = std::invoke([&]() { - if (!args[0]->IsFunction()) - throw std::invalid_argument("!`Function` required at [0]."); - return v8::Local::Cast(args[0]); - }); -#ifdef Q_OS_WIN - - p->d_func()->invoke<&QProcess::setCreateProcessArgumentsModifier>([](QProcess::CreateProcessArguments*) { - }); -#endif // Q_OS_WIN - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetEnvironment(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - if (!args[0]->IsArray()) - throw std::invalid_argument("!`Array` required at [0]."); - QStringList environment; - convert::Array::To(isolate, context, args[0], environment); - - p->d_func()->invoke<&QProcess::setEnvironment>(environment); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetInputChannelMode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto mode = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QProcess::setInputChannelMode>(mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetNativeArguments(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto arguments = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - p->d_func()->invoke<&QProcess::setNativeArguments>(arguments); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetProcessChannelMode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto mode = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QProcess::setProcessChannelMode>(mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetProcessEnvironment(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - // TODO: - /* auto environment = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - p->d_func()->invoke<&QProcess::setProcessEnvironment>(environment);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetProgram(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto program = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - p->d_func()->invoke<&QProcess::setProgram>(program); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetReadChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto channel = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QProcess::setReadChannel>(channel); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetReadChannelMode(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto mode = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QProcess::setReadChannelMode>(mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetStandardErrorFile(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto fileName = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - auto mode = std::invoke([&]() { - if (args[1]->IsInt32()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(QIODevice::Truncate); - }); - - p->d_func()->invoke<&QProcess::setStandardErrorFile>(fileName, mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetStandardInputFile(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto fileName = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - p->d_func()->invoke<&QProcess::setStandardInputFile>(fileName); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetStandardOutputFile(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto fileName = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - auto mode = std::invoke([&]() { - if (args[1]->IsInt32()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(QIODevice::Truncate); - }); - - p->d_func()->invoke<&QProcess::setStandardOutputFile>(fileName, mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetStandardOutputProcess(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto* destination = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]->ToObject(context).ToLocalChecked()); - }); - - p->d_func()->invoke<&QProcess::setStandardOutputProcess>(destination); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWorkingDirectory(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto dir = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - p->d_func()->invoke<&QProcess::setWorkingDirectory>(dir); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Start(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto program = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - QStringList arguments; - convert::Array::To(isolate, context, args[1], arguments); - - auto mode = std::invoke([&]() { - if (args[2]->IsInt32()) - return static_cast(args[2]->Int32Value(context).FromJust()); - return static_cast(QIODevice::ReadWrite); - }); - - if (program.isEmpty() && arguments.isEmpty()) { - p->d_func()->invoke(&QProcess::start)>(mode); - } - else if (arguments.isEmpty()) { - p->d_func()->invoke(&QProcess::start)>(program, mode); - } - else { - p->d_func()->invoke(&QProcess::start)>(program, arguments, mode); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void State(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QProcess::state>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Terminate(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QProcess::terminate>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForFinished(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto msecs = std::invoke([&]() { - if (args[0]->IsInt32()) - return args[0]->Int32Value(context).FromJust(); - return 30000; - }); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QProcess::waitForFinished>(msecs)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForStarted(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto msecs = std::invoke([&]() { - if (args[0]->IsInt32()) - return args[0]->Int32Value(context).FromJust(); - return 30000; - }); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QProcess::waitForStarted>(msecs)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WorkingDirectory(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::String::New(isolate, p->d_func()->invoke<&QProcess::workingDirectory>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Execute(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto program = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - QStringList arguments; - convert::Array::To(isolate, context, args[1], arguments); - v8::Localresult; - if (arguments.isEmpty()) { - result = v8::Int32::New(isolate, QProcess::execute(program)); - } - else { - result = v8::Int32::New(isolate, QProcess::execute(program, arguments)); - } - - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void NullDevice(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto result = convert::String::New(isolate, QProcess::nullDevice()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StartDetached(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - bool ok = false; - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - auto program = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - QStringList arguments; - convert::Array::To(isolate, context, args[1], arguments); - - auto workingDirectory = std::invoke([&]() { - if (args[2]->IsString()) - return convert::String::To(isolate, args[2]); - return QString(); - }); - - //auto* pid = std::invoke([&]() { - // if (args[3]->IsBigInt()) - // return args[3]->ToBigInt(context).ToLocalChecked()->Int64Value(); - // return nullptr; - // }); - - if (arguments.isEmpty()) { - ok = QProcess::startDetached(program); - } - else { - ok = QProcess::startDetached(program, arguments, workingDirectory); - } - } - else { - ok = p->d_func()->invoke(&QProcess::startDetached)>(nullptr); - } - args.GetReturnValue().Set(v8::Boolean::New(isolate, ok)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SystemEnvironment(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - args.GetReturnValue().Set(convert::Array::New(isolate, context, QProcess::systemEnvironment())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ErrorOccurred(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QProcess::errorOccurred, [weakPersistent](QProcess::ProcessError error) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, error) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_common) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QProcess::errorOccurred, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Started(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QProcess::started, [weakPersistent]() { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), 0, {}); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_common) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QProcess::started, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Finished(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), qOverload(&QProcess::finished), [weakPersistent](int exitCode, QProcess::ExitStatus exitStatus) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, exitCode), v8::Int32::New(isolate, exitStatus) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_common) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), qOverload(&QProcess::finished), nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadyReadStandardError(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QProcess::readyReadStandardError, [weakPersistent]() { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), 0, {}); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_common) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QProcess::readyReadStandardError, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadyReadStandardOutput(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QProcess::readyReadStandardOutput, [weakPersistent]() { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), 0, {}); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_common) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QProcess::readyReadStandardOutput, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StateChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) - return; - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QProcess::stateChanged, [weakPersistent](QProcess::ProcessState state) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, state) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_common) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QProcess::stateChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/core/qrect_implement.h b/v8/include/modules/core/qrect_implement.h deleted file mode 100644 index 3038d28..0000000 --- a/v8/include/modules/core/qrect_implement.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qrect_p.h" -#include "qrect_wrapper.h" -#include "qpoint_implement.h" -#include "qsize_implement.h" - -namespace shelllet { - namespace core { - class Rect : public QRectWrapper - { - public: - using ReturnType = QRectPrivate; - using ReturnType2 = QRectPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - if (args[0]->IsNumber() && args[1]->IsNumber() && args[2]->IsNumber() && args[3]->IsNumber()) { - auto x1 = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto y1 = args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto w = args[2]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto h = args[3]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - return new ReturnType(args.GetIsolate(), args.This(), x1, y1, w, h); - } - - if (GetConstructorName(args.GetIsolate(), args[0]) == Point::Name() && GetConstructorName(args.GetIsolate(), args[1]) == Size::Name()) { - auto* p = Point::From(args[0]); - auto* s = Size::From(args[1]); - if (p && s) { - return new ReturnType(args.GetIsolate(), args.This(), **p, **s); - } - } - - if (GetConstructorName(args.GetIsolate(), args[0]) == Point::Name() && GetConstructorName(args.GetIsolate(), args[1]) == Point::Name()) { - auto* p1 = Point::From(args[0]); - auto* p2 = Point::From(args[1]); - if (p1 && p2) { - return new ReturnType(args.GetIsolate(), args.This(), **p1, **p2); - } - } - return new ReturnType(args.GetIsolate(), args.This()); - } - Rect(const v8::FunctionCallbackInfo& args) :QRectWrapper(*Private(args), args) - { - } - Rect(QRect* p, const v8::FunctionCallbackInfo& args) : QRectWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Rect(v8::Isolate* isolate, const v8::Local& tpl) : QRectWrapper(isolate, tpl) {} - Rect(v8::Isolate* isolate, const v8::Local& proto) : QRectWrapper(isolate, proto) - {} - - static const char* Name() { return "Rect"; } - protected: - virtual void toString(std::stringstream& ss) const { - } - }; - } -} diff --git a/v8/include/modules/core/qrect_p.h b/v8/include/modules/core/qrect_p.h deleted file mode 100644 index 9f0b84a..0000000 --- a/v8/include/modules/core/qrect_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QRectPrivate : public ObjectPrivate - { - public: - template - QRectPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - }; - } -} diff --git a/v8/include/modules/core/qrect_wrapper.h b/v8/include/modules/core/qrect_wrapper.h deleted file mode 100644 index b73a5ce..0000000 --- a/v8/include/modules/core/qrect_wrapper.h +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template class QRectPrivate; - template - class QRectWrapper : public ObjectWrapper - { - public: - template - QRectWrapper(QRectPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QRectWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QRectWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "x"), GetX, SetX); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "y"), GetY, SetY); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "width"), GetWidth, SetWidth); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "height"), GetHeight, SetHeight); - } - - protected: - static void GetX(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - - info.GetReturnValue().Set(v8::Int32::New(info.GetIsolate(), (*p)->x())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetX(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setX(value->Int32Value(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetY(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Int32::New(isolate, (*p)->y())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetY(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setY(value->Int32Value(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetWidth(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Int32::New(isolate, (*p)->width())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWidth(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setWidth(value->Int32Value(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetHeight(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Int32::New(isolate, (*p)->height())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetHeight(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setHeight(value->Int32Value(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qrectf_implement.h b/v8/include/modules/core/qrectf_implement.h deleted file mode 100644 index a648103..0000000 --- a/v8/include/modules/core/qrectf_implement.h +++ /dev/null @@ -1,58 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qrect_p.h" -#include "qrect_wrapper.h" -#include "qpoint_implement.h" -#include "qsize_implement.h" - -namespace shelllet { - namespace core { - class RectF : public QRectFWrapper - { - public: - using ReturnType = QRectFPrivate; - using ReturnType2 = QRectFPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - if (args[0]->IsNumber() && args[1]->IsNumber() && args[2]->IsNumber() && args[3]->IsNumber()) { - auto x1 = args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto y1 = args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto w = args[2]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto h = args[3]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - return new ReturnType(args.GetIsolate(), args.This(), x1, y1, w, h); - } - - if (GetConstructorName(args.GetIsolate(), args[0]) == Point::Name() && GetConstructorName(args.GetIsolate(), args[1]) == Size::Name()) { - auto* p = Point::From(args[0]); - auto* s = Size::From(args[1]); - if (p && s) { - return new ReturnType(args.GetIsolate(), args.This(), **p, **s); - } - } - - if (GetConstructorName(args.GetIsolate(), args[0]) == Point::Name() && GetConstructorName(args.GetIsolate(), args[1]) == Point::Name()) { - auto* p1 = Point::From(args[0]); - auto* p2 = Point::From(args[1]); - if (p1 && p2) { - return new ReturnType(args.GetIsolate(), args.This(), **p1, **p2); - } - } - return new ReturnType(args.GetIsolate(), args.This()); - } - RectF(const v8::FunctionCallbackInfo& args) :QRectFWrapper(*Private(args), args) - { - } - RectF(QRectF* p, const v8::FunctionCallbackInfo& args) : QRectFWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - RectF(v8::Isolate* isolate, const v8::Local& tpl) : QRectFWrapper(isolate, tpl) {} - RectF(v8::Isolate* isolate, const v8::Local& proto) : QRectFWrapper(isolate, proto) - {} - - static const char* Name() { return "RectF"; } - protected: - virtual void toString(std::stringstream& ss) const { - } - }; - } -} diff --git a/v8/include/modules/core/qrectf_p.h b/v8/include/modules/core/qrectf_p.h deleted file mode 100644 index 790a300..0000000 --- a/v8/include/modules/core/qrectf_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QRectFPrivate : public ObjectPrivate - { - public: - template - QRectFPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - }; - } -} diff --git a/v8/include/modules/core/qrectf_wrapper.h b/v8/include/modules/core/qrectf_wrapper.h deleted file mode 100644 index 3ff1563..0000000 --- a/v8/include/modules/core/qrectf_wrapper.h +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QRectFWrapper : public ObjectWrapper - { - public: - template - QRectFWrapper(QRectFPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QRectFWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QRectFWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "x"), GetX, SetX); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "y"), GetY, SetY); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "width"), GetWidth, SetWidth); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "height"), GetHeight, SetHeight); - } - - protected: - static void GetX(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - - info.GetReturnValue().Set(v8::Number::New(info.GetIsolate(), (*p)->x())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetX(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setX(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetY(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Number::New(isolate, (*p)->y())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetY(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setY(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetWidth(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Number::New(isolate, (*p)->width())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWidth(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setWidth(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetHeight(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set(v8::Number::New(isolate, (*p)->height())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetHeight(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setHeight(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qregularexpression_implement.h b/v8/include/modules/core/qregularexpression_implement.h deleted file mode 100644 index daee413..0000000 --- a/v8/include/modules/core/qregularexpression_implement.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qregularexpression_p.h" -#include "qregularexpression_wrapper.h" - -namespace shelllet { - namespace core { - class RegularExpression : public RegularExpressionWrapper - { - using ReturnType = RegularExpressionPrivate; - using ReturnType2 = RegularExpressionPrivate; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - RegularExpression(const v8::FunctionCallbackInfo& args) : RegularExpressionWrapper(*Param(args), args) {} - RegularExpression(QRegularExpression* p, const v8::FunctionCallbackInfo& args) : RegularExpressionWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - RegularExpression(v8::Isolate* isolate, const v8::Local& tpl) : RegularExpressionWrapper(isolate, tpl) {} - RegularExpression(v8::Isolate* isolate, const v8::Local& proto) : RegularExpressionWrapper(isolate, proto) {} - - static const char* Name() { return "regex"; } - static bool Test(v8::Isolate* isolate, const v8::Local& regex, const std::wstring& str) - { - v8::Local f = v8::Local::Cast(regex->Get(isolate->GetCurrentContext(), V8_NEW_STRING_VAR(isolate, "test")).ToLocalChecked()); - v8::Local argv[] = { V8_NEW_WSTRING_VAR(isolate, str.c_str()) }; - auto result = f->CallAsFunction(isolate->GetCurrentContext(), regex, std::size(argv), argv); - if (result.IsEmpty()) { - return false; - } - return result.ToLocalChecked()->BooleanValue(isolate); - } - public: - }; - } -} diff --git a/v8/include/modules/core/qregularexpression_p.h b/v8/include/modules/core/qregularexpression_p.h deleted file mode 100644 index 53ef038..0000000 --- a/v8/include/modules/core/qregularexpression_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet::core { - template - class RegularExpressionPrivate : public ObjectPrivate - { - public: - template - RegularExpressionPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - - }; -} diff --git a/v8/include/modules/core/qregularexpression_wrapper.h b/v8/include/modules/core/qregularexpression_wrapper.h deleted file mode 100644 index 6b9cea0..0000000 --- a/v8/include/modules/core/qregularexpression_wrapper.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template class RegularExpressionPrivate; - template - class RegularExpressionWrapper : public ObjectWrapper - { - public: - - template - RegularExpressionWrapper(RegularExpressionPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - RegularExpressionWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - RegularExpressionWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) {} - - protected: - }; - } -} diff --git a/v8/include/modules/core/qsize_implement.h b/v8/include/modules/core/qsize_implement.h deleted file mode 100644 index 708fbb9..0000000 --- a/v8/include/modules/core/qsize_implement.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qsize_p.h" -#include "qsize_wrapper.h" - -namespace shelllet { - namespace core { - class Size : public QSizeWrapper - { - public: - using ReturnType = QSizePrivate; - using ReturnType2 = QSizePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - auto w = args[0]->NumberValue(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto h = args[1]->NumberValue(args.GetIsolate()->GetCurrentContext()).FromJust(); - - return new ReturnType(args.GetIsolate(), args.This(), w, h); - } - - Size(const v8::FunctionCallbackInfo& args) :QSizeWrapper(*Private(args), args) - { - } - Size(QSize* p, const v8::FunctionCallbackInfo& args) : QSizeWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Size(v8::Isolate* isolate, const v8::Local& tpl) : QSizeWrapper(isolate, tpl) {} - Size(v8::Isolate* isolate, const v8::Local& proto) : QSizeWrapper(isolate, proto) - {} - - static const char* Name() { return "Size"; } - protected: - virtual void toString(std::stringstream& ss) const { - //ss << "(" << (*this)->x() << ", " << (*this)->y() << ")"; - } - }; - } -} diff --git a/v8/include/modules/core/qsize_p.h b/v8/include/modules/core/qsize_p.h deleted file mode 100644 index a8fa421..0000000 --- a/v8/include/modules/core/qsize_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QSizePrivate : public ObjectPrivate - { - public: - template - QSizePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/core/qsize_wrapper.h b/v8/include/modules/core/qsize_wrapper.h deleted file mode 100644 index c1dfc0f..0000000 --- a/v8/include/modules/core/qsize_wrapper.h +++ /dev/null @@ -1,214 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QSizeWrapper : public ObjectWrapper - { - public: - template - QSizeWrapper(QSizePrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QSizeWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QSizeWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "boundedTo", v8::FunctionTemplate::New(isolate, BoundedTo)); - proto->Set(isolate, "expandedTo", v8::FunctionTemplate::New(isolate, ExpandedTo)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "height"), GetHeight, SetHeight); - proto->Set(isolate, "isEmpty", v8::FunctionTemplate::New(isolate, IsEmpty)); - proto->Set(isolate, "isNull", v8::FunctionTemplate::New(isolate, IsNull)); - proto->Set(isolate, "isValid", v8::FunctionTemplate::New(isolate, IsValid)); - proto->Set(isolate, "scale", v8::FunctionTemplate::New(isolate, Scale)); - proto->Set(isolate, "scaled", v8::FunctionTemplate::New(isolate, Scaled)); - proto->Set(isolate, "transpose", v8::FunctionTemplate::New(isolate, Transpose)); - proto->Set(isolate, "transposed", v8::FunctionTemplate::New(isolate, Transposed)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "width"), GetWidth, SetWidth); - } - - protected: - static void GetWidth(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - info.GetReturnValue().Set((*p)->width()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWidth(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - (*p)->setWidth(value->NumberValue(context).FromJust()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetHeight(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - info.GetReturnValue().Set((*p)->height()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetHeight(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - (*p)->setHeight(value->NumberValue(context).FromJust()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BoundedTo(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto otherSize = Size::From(args[0]); - auto size = (*p)->boundedTo(**otherSize); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ExpandedTo(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto otherSize = Size::From(args[0]); - auto size = (*p)->expandedTo(**otherSize); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsEmpty(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - args.GetReturnValue().Set((*p)->isEmpty()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsNull(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - args.GetReturnValue().Set((*p)->isNull()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsValid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - args.GetReturnValue().Set((*p)->isValid()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Scale(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - int index = 0; - auto s = Size::From(args[0]); - if (!s) { - throw std::invalid_argument("! require `Size` value."); - } - auto mode = static_cast(args[index]->Int32Value(context).FromJust()); - (*p)->scale(**s, mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Scaled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - int index = 0; - auto* s = Size::From(args[0]); - if (!s) { - throw std::invalid_argument("! require `Size` value."); - } - auto mode = static_cast(args[index]->Int32Value(context).FromJust()); - auto size = (*p)->scaled((**s), mode); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Transpose(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - (*p)->transpose(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Transposed(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) { - return; - } - auto size = (*self)->transposed(); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qsizef_implement.h b/v8/include/modules/core/qsizef_implement.h deleted file mode 100644 index cc31f14..0000000 --- a/v8/include/modules/core/qsizef_implement.h +++ /dev/null @@ -1,38 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qsize_p.h" -#include "qsize_wrapper.h" - -namespace shelllet { - namespace core { - class SizeF : public QSizeFWrapper - { - public: - using ReturnType = QSizeFPrivate; - using ReturnType2 = QSizeFPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - auto w = args[0]->NumberValue(args.GetIsolate()->GetCurrentContext()).FromJust(); - auto h = args[1]->NumberValue(args.GetIsolate()->GetCurrentContext()).FromJust(); - - return new ReturnType(args.GetIsolate(), args.This(), w, h); - } - - SizeF(const v8::FunctionCallbackInfo& args) :QSizeFWrapper(*Private(args), args) - { - } - SizeF(QSizeF* p, const v8::FunctionCallbackInfo& args) : QSizeFWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - SizeF(v8::Isolate* isolate, const v8::Local& tpl) : QSizeFWrapper(isolate, tpl) {} - SizeF(v8::Isolate* isolate, const v8::Local& proto) : QSizeFWrapper(isolate, proto) - {} - - static const char* Name() { return "SizeF"; } - protected: - virtual void toString(std::stringstream& ss) const { - //ss << "(" << (*this)->x() << ", " << (*this)->y() << ")"; - } - }; - } -} diff --git a/v8/include/modules/core/qsizef_p.h b/v8/include/modules/core/qsizef_p.h deleted file mode 100644 index 23172db..0000000 --- a/v8/include/modules/core/qsizef_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QSizeFPrivate : public ObjectPrivate - { - public: - template - QSizeFPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/core/qsizef_wrapper.h b/v8/include/modules/core/qsizef_wrapper.h deleted file mode 100644 index 8c5e65e..0000000 --- a/v8/include/modules/core/qsizef_wrapper.h +++ /dev/null @@ -1,214 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QSizeFWrapper : public ObjectWrapper - { - public: - template - QSizeFWrapper(QSizeFPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QSizeFWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QSizeFWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "boundedTo", v8::FunctionTemplate::New(isolate, BoundedTo)); - proto->Set(isolate, "expandedTo", v8::FunctionTemplate::New(isolate, ExpandedTo)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "height"), GetHeight, SetHeight); - proto->Set(isolate, "isEmpty", v8::FunctionTemplate::New(isolate, IsEmpty)); - proto->Set(isolate, "isNull", v8::FunctionTemplate::New(isolate, IsNull)); - proto->Set(isolate, "isValid", v8::FunctionTemplate::New(isolate, IsValid)); - proto->Set(isolate, "scale", v8::FunctionTemplate::New(isolate, Scale)); - proto->Set(isolate, "scaled", v8::FunctionTemplate::New(isolate, Scaled)); - proto->Set(isolate, "transpose", v8::FunctionTemplate::New(isolate, Transpose)); - proto->Set(isolate, "transposed", v8::FunctionTemplate::New(isolate, Transposed)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "width"), GetWidth, SetWidth); - } - - protected: - static void GetWidth(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - info.GetReturnValue().Set((*p)->width()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWidth(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - (*p)->setWidth(value->NumberValue(context).FromJust()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetHeight(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - info.GetReturnValue().Set((*p)->height()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetHeight(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - if (!p) - return; - (*p)->setHeight(value->NumberValue(context).FromJust()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BoundedTo(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto otherSize = Size::From(args[0]); - auto size = (*p)->boundedTo(**otherSize); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ExpandedTo(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto otherSize = Size::From(args[0]); - auto size = (*p)->expandedTo(**otherSize); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsEmpty(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - args.GetReturnValue().Set((*p)->isEmpty()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsNull(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - args.GetReturnValue().Set((*p)->isNull()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsValid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - args.GetReturnValue().Set((*p)->isValid()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Scale(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - int index = 0; - auto s = Size::From(args[0]); - if (!s) { - throw std::invalid_argument("! require `Size` value."); - } - auto mode = static_cast(args[index]->Int32Value(context).FromJust()); - (*p)->scale(**s, mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Scaled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - int index = 0; - auto* s = Size::From(args[0]); - if (!s) { - throw std::invalid_argument("! require `Size` value."); - } - auto mode = static_cast(args[index]->Int32Value(context).FromJust()); - auto size = (*p)->scaled((**s), mode); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Transpose(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - (*p)->transpose(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Transposed(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) { - return; - } - auto size = (*self)->transposed(); - args.GetReturnValue().Set(Size::New(isolate, v8::Number::New(isolate, size.width()), v8::Number::New(isolate, size.height()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qstring_implement.h b/v8/include/modules/core/qstring_implement.h deleted file mode 100644 index 0526e77..0000000 --- a/v8/include/modules/core/qstring_implement.h +++ /dev/null @@ -1,467 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qstring_p.h" -#include "qstring_wrapper.h" - -namespace shelllet { - namespace core { - class String : public QStringWrapper - { - using ReturnType = QRectPrivate; - using ReturnType2 = QRectPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - String(const v8::FunctionCallbackInfo& args) : QStringWrapper(*Private(args), args) {} - String(v8::Isolate* isolate, const v8::Local& tpl) : QRectWrapper(isolate, tpl) {} - String(v8::Isolate* isolate, const v8::Local& proto) : QRectWrapper(isolate, proto) { - tpl->Set(isolate, "chop", v8::FunctionTemplate::New(isolate, Chop)); - tpl->Set(isolate, "chopped", v8::FunctionTemplate::New(isolate, Chopped)); - tpl->Set(isolate, "contains", v8::FunctionTemplate::New(isolate, Contains)); - tpl->Set(isolate, "endsWith", v8::FunctionTemplate::New(isolate, EndsWith)); - tpl->Set(isolate, "isLower", v8::FunctionTemplate::New(isolate, IsLower)); - tpl->Set(isolate, "isSimpleText", v8::FunctionTemplate::New(isolate, IsSimpleText)); - tpl->Set(isolate, "isUpper", v8::FunctionTemplate::New(isolate, IsUpper)); - tpl->Set(isolate, "left", v8::FunctionTemplate::New(isolate, Left)); - tpl->Set(isolate, "mid", v8::FunctionTemplate::New(isolate, Mid)); - tpl->Set(isolate, "repeated", v8::FunctionTemplate::New(isolate, Repeated)); - tpl->Set(isolate, "right", v8::FunctionTemplate::New(isolate, Right)); - tpl->Set(isolate, "section", v8::FunctionTemplate::New(isolate, Section)); - tpl->Set(isolate, "simplified", v8::FunctionTemplate::New(isolate, Simplified)); - tpl->Set(isolate, "simplified", v8::FunctionTemplate::New(isolate, Simplified)); - tpl->Set(isolate, "simplified", v8::FunctionTemplate::New(isolate, Simplified)); - tpl->Set(isolate, "split", v8::FunctionTemplate::New(isolate, Split)); - tpl->Set(isolate, "startsWith", v8::FunctionTemplate::New(isolate, StartsWith)); - tpl->Set(isolate, "toCaseFolded", v8::FunctionTemplate::New(isolate, ToCaseFolded)); - tpl->Set(isolate, "toHtmlEscaped", v8::FunctionTemplate::New(isolate, ToHtmlEscaped)); - tpl->Set(isolate, "toLower", v8::FunctionTemplate::New(isolate, ToLower)); - tpl->Set(isolate, "toUpper", v8::FunctionTemplate::New(isolate, ToUpper)); - tpl->Set(isolate, "trimmed", v8::FunctionTemplate::New(isolate, Trimmed)); - tpl->Set(isolate, "trimmed", v8::FunctionTemplate::New(isolate, Trimmed)); - tpl->Set(isolate, "truncate", v8::FunctionTemplate::New(isolate, Truncate)); - } - - public: - static const char* Name() { return "String"; } - static void Chop(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /* auto n = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - p->d_func()->invoke<&QString::chop>(n);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Chopped(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto n = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::chopped>(n)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Contains(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto s = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return String::To(isolate, args[0]); - }); - - auto cs = std::invoke([&]() { - if (args[1]->IsObject()) - return args[1]->Int32Value(context).FromJust(); - return Qt::CaseSensitive; - }); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QString::contains>(s, cs)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void EndsWith(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto s = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return String::To(isolate, args[0]); - }); - - auto cs = std::invoke([&]() { - if (args[1]->IsObject()) - return args[1]->Int32Value(context).FromJust(); - return Qt::CaseSensitive; - }); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QString::endsWith>(s, cs)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsLower(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QString::isLower>()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsSimpleText(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QString::isSimpleText>()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsUpper(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QString::isUpper>()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Left(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto n = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::left>(n)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Mid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto position = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto n = std::invoke([&]() { - if (args[1]->IsInt32()) - return args[1]->Int32Value(context).FromJust(); - return -1; - }); - - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::mid>(position, n)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Repeated(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto times = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::repeated>(times)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Right(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /* auto n = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::right>(n)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Section(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto sep = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto start = std::invoke([&]() { - if (!args[1]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [1]."); - return args[1]->Int32Value(context).FromJust(); - }); - - auto end = std::invoke([&]() { - if (args[2]->IsInt32()) - return args[2]->Int32Value(context).FromJust(); - return -1; - }); - - auto flags = std::invoke([&]() { - if (args[3]->IsObject()) - return args[3]->Int32Value(context).FromJust(); - return SectionDefault; - }); - - auto result = String::New(isolate, p->d_func()->invoke<&QString::section>(sep, start, end, flags)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Simplified(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::simplified>()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Split(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto sep = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return String::To(isolate, args[0]); - }); - - auto behavior = std::invoke([&]() { - if (args[1]->IsObject()) - return args[1]->Int32Value(context).FromJust(); - return KeepEmptyParts; - }); - - auto cs = std::invoke([&]() { - if (args[2]->IsObject()) - return args[2]->Int32Value(context).FromJust(); - return Qt::CaseSensitive; - }); - - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::split>(sep, behavior, cs)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StartsWith(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto s = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return String::To(isolate, args[0]); - }); - - auto cs = std::invoke([&]() { - if (args[1]->IsObject()) - return args[1]->Int32Value(context).FromJust(); - return Qt::CaseSensitive; - }); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QString::startsWith>(s, cs)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToCaseFolded(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - //auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::toCaseFolded>()); - //args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToHtmlEscaped(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - //auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::toHtmlEscaped>()); - //args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToLower(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - // auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::toLower>()); - //args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToUpper(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - //auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::toUpper>()); - //args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Trimmed(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - ///*auto*/ result = v8::Int32::New(isolate, p->d_func()->invoke<&QString::trimmed>()); - // args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Truncate(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto pos = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - // p->d_func()->invoke<&QString::truncate>(pos); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/core/qstring_p.h b/v8/include/modules/core/qstring_p.h deleted file mode 100644 index 68b063e..0000000 --- a/v8/include/modules/core/qstring_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace shelllet::core { - template - class QStringPrivate : public ObjectPrivate - { - public: - template - QStringPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/core/qstring_wrapper.h b/v8/include/modules/core/qstring_wrapper.h deleted file mode 100644 index 7090fc3..0000000 --- a/v8/include/modules/core/qstring_wrapper.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template class QStringPrivate; - template - class QStringWrapper : public ObjectWrapper - { - public: - template - QStringWrapper(QStringPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - - QStringWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QStringWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) { - } - - protected: - }; - } -} diff --git a/v8/include/modules/core/qtimer_implement.h b/v8/include/modules/core/qtimer_implement.h deleted file mode 100644 index 10c32a3..0000000 --- a/v8/include/modules/core/qtimer_implement.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qtimer_p.h" -#include "qtimer_wrapper.h" - -namespace shelllet { - namespace core { - class Timer : public QTimerWrapper - { - public: - using ReturnType = QTimerPrivate; - using ReturnType2 = QTimerPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - Timer(const v8::FunctionCallbackInfo& args) :QTimerWrapper(*Private(args), args) - { - } - Timer(QTimer* p, const v8::FunctionCallbackInfo& args) :QTimerWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Timer(v8::Isolate* isolate, const v8::Local& tpl) : QTimerWrapper(isolate, tpl) { - tpl->Set(isolate, "singleShot", v8::FunctionTemplate::New(isolate, SingleShot)); - } - Timer(v8::Isolate* isolate, const v8::Local& proto) : QTimerWrapper(isolate, proto) - { - } - public: - static const char* Name() { return "Timer"; } - protected: - void toString(std::stringstream& ss) const {} - protected: - static void SingleShot(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/core/qtimer_p.h b/v8/include/modules/core/qtimer_p.h deleted file mode 100644 index d61596c..0000000 --- a/v8/include/modules/core/qtimer_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template - class QTimerPrivate : public QObjectPrivate - { - public: - template - QTimerPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/core/qtimer_wrapper.h b/v8/include/modules/core/qtimer_wrapper.h deleted file mode 100644 index 2ce1c6e..0000000 --- a/v8/include/modules/core/qtimer_wrapper.h +++ /dev/null @@ -1,226 +0,0 @@ -#pragma once -namespace shelllet { - namespace core { - template - class QTimerWrapper : public QObjectWrapper - { - public: - template - QTimerWrapper(QTimerPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - QTimerWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QTimerWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) - { - proto->Set(isolate, "callOnTimeout", v8::FunctionTemplate::New(isolate, CallOnTimeout)); - proto->Set(isolate, "interval", v8::FunctionTemplate::New(isolate, Interval)); - proto->Set(isolate, "intervalAsDuration", v8::FunctionTemplate::New(isolate, IntervalAsDuration)); - proto->Set(isolate, "isActive", v8::FunctionTemplate::New(isolate, IsActive)); - proto->Set(isolate, "isSingleShot", v8::FunctionTemplate::New(isolate, IsSingleShot)); - proto->Set(isolate, "remainingTime", v8::FunctionTemplate::New(isolate, RemainingTime)); - proto->Set(isolate, "remainingTimeAsDuration", v8::FunctionTemplate::New(isolate, RemainingTimeAsDuration)); - proto->Set(isolate, "setInterval", v8::FunctionTemplate::New(isolate, SetInterval)); - proto->Set(isolate, "setSingleShot", v8::FunctionTemplate::New(isolate, SetSingleShot)); - proto->Set(isolate, "setTimerType", v8::FunctionTemplate::New(isolate, SetTimerType)); - proto->Set(isolate, "start", v8::FunctionTemplate::New(isolate, Start)); - proto->Set(isolate, "timerId", v8::FunctionTemplate::New(isolate, TimerId)); - proto->Set(isolate, "timerType", v8::FunctionTemplate::New(isolate, TimerType)); - proto->Set(isolate, "stop", v8::FunctionTemplate::New(isolate, Stop)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "timeout"), nullptr, Timeout); - } - - protected: - static void CallOnTimeout(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Interval(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IntervalAsDuration(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsActive(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsSingleShot(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RemainingTime(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RemainingTimeAsDuration(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetInterval(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - (*self)->setInterval(args[0]->Uint32Value(context).FromJust()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetSingleShot(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetTimerType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Start(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (args.Length() > 0) { - (*self)->start(args[0]->Uint32Value(context).FromJust()); - } - else { - (*self)->start(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void TimerId(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void TimerType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Stop(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Timeout(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - std::shared_ptr>weakPersistent = std::make_shared>(isolate, v8::Local::Cast(value)); - QObject::connect(*self, &QTimer::timeout, [isolate, weakPersistent]() { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), 0, {}); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(*self, &QTimer::timeout, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/qurl_implement.h b/v8/include/modules/core/qurl_implement.h deleted file mode 100644 index a9fc69e..0000000 --- a/v8/include/modules/core/qurl_implement.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qurl_p.h" -#include "qurl_wrapper.h" - -namespace shelllet { - namespace core { - class Url : public QUrlWrapper - { - public: - using ReturnType = QUrlPrivate; - using ReturnType2 = QUrlPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - if (args[0]->IsExternal()) { - v8::Local wrap = v8::Local::Cast(args[0]); - auto* url = wrap->Value(); - if (url) - return new ReturnType(args.GetIsolate(), args.This(), *static_cast(url)); - } - else if (args[0]->IsString()) { - QUrl::ParsingMode parsingMode = QUrl::TolerantMode; - if (args[1]->IsNumber()) { - parsingMode = static_cast(args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust()); - } - return new ReturnType(args.GetIsolate(), args.This(), ToString({ args.GetIsolate(), args[0] }), parsingMode); - } - - return new ReturnType(args.GetIsolate(), args.This()); - } - - Url(const v8::FunctionCallbackInfo& args) :QUrlWrapper(*Private(args), args) - { - } - Url(QUrl* p, const v8::FunctionCallbackInfo& args) : QUrlWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Url(v8::Isolate* isolate, const v8::Local& tpl) : QUrlWrapper(isolate, tpl) {} - Url(v8::Isolate* isolate, const v8::Local& proto) : QUrlWrapper(isolate, proto) - {} - - static const char* Name() { return "Url"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/core/qurl_p.h b/v8/include/modules/core/qurl_p.h deleted file mode 100644 index 385aec8..0000000 --- a/v8/include/modules/core/qurl_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template - class QUrlPrivate : public ObjectPrivate - { - public: - template - QUrlPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/core/qurl_wrapper.h b/v8/include/modules/core/qurl_wrapper.h deleted file mode 100644 index c731e35..0000000 --- a/v8/include/modules/core/qurl_wrapper.h +++ /dev/null @@ -1,60 +0,0 @@ -#pragma once - -namespace shelllet { - namespace core { - template class QUrlPrivate; - template - class QUrlWrapper : public ObjectWrapper - { - public: - QUrlWrapper(QUrlPrivate& d) : ObjectWrapper(d) { - } - template - QUrlWrapper(QUrlPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QUrlWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) - { - tpl->Set(isolate, "fromUserInput", v8::FunctionTemplate::New(isolate, FromUserInput)); - } - QUrlWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "port", v8::FunctionTemplate::New(isolate, Port)); - proto->Set(isolate, "host", v8::FunctionTemplate::New(isolate, Host)); - } - - protected: - static void Port(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - throw std::domain_error("# invalid object."); - args.GetReturnValue().Set((*p)->port()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Host(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - throw std::domain_error("# invalid object."); - args.GetReturnValue().Set(V8_NEW_WSTRING_VAR(isolate, (*p)->host().toStdWString().c_str())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void FromUserInput(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - QString userInput = ToString({ isolate, args[0] }); - args.GetReturnValue().Set(Url::New(isolate, v8::External::New(isolate, &QUrl::fromUserInput(userInput)))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/core/randomdevice_implement.h b/v8/include/modules/core/randomdevice_implement.h deleted file mode 100644 index 7a8a635..0000000 --- a/v8/include/modules/core/randomdevice_implement.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "randomdevice_p.h" -#include "randomdevice_wrapper.h" -namespace shelllet { - namespace random { - class RandomDevice : public RandomDeviceWrapper - { - public: - using ReturnType = RandomDevicePrivate; - using ReturnType2 = RandomDevicePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - RandomDevice(const v8::FunctionCallbackInfo& args) : RandomDeviceWrapper(*Private(args), args) { - } - RandomDevice(std::random_device* p, const v8::FunctionCallbackInfo& args) : RandomDeviceWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - RandomDevice(v8::Isolate* isolate, const v8::Local& tpl) : RandomDeviceWrapper(isolate, tpl) {} - RandomDevice(v8::Isolate* isolate, const v8::Local& proto) : RandomDeviceWrapper(isolate, proto) - { - } - static const char* Name() { return "RandomDevice"; } - public: - }; - } -} diff --git a/v8/include/modules/core/randomdevice_p.h b/v8/include/modules/core/randomdevice_p.h deleted file mode 100644 index 29e39e4..0000000 --- a/v8/include/modules/core/randomdevice_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -namespace shelllet::random { - template - class RandomDevicePrivate : public ObjectPrivate - { - public: - template - RandomDevicePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - template - RandomDevicePrivate(T* d, v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(d, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/core/randomdevice_wrapper.h b/v8/include/modules/core/randomdevice_wrapper.h deleted file mode 100644 index 2ab972f..0000000 --- a/v8/include/modules/core/randomdevice_wrapper.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -namespace shelllet { - namespace random { - template class RandomDevicePrivate; - template - class RandomDeviceWrapper : public ObjectWrapper - { - public: - template - RandomDeviceWrapper(RandomDevicePrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - RandomDeviceWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - RandomDeviceWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - }; - } -} diff --git a/v8/include/modules/core/uniformintdistribution_implement.h b/v8/include/modules/core/uniformintdistribution_implement.h deleted file mode 100644 index 9ec6679..0000000 --- a/v8/include/modules/core/uniformintdistribution_implement.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "uniformintdistribution_p.h" -#include "uniformintdistribution_wrapper.h" -namespace shelllet { - namespace random { - class UniformIntDistribution : public UniformIntDistributionWrapper, UniformIntDistribution, true> - { - public: - using ReturnType = UniformIntDistributionPrivate, true>; - using ReturnType2 = UniformIntDistributionPrivate, false>; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - UniformIntDistribution(const v8::FunctionCallbackInfo& args) : UniformIntDistributionWrapper(*Private(args), args) { - } - UniformIntDistribution(std::uniform_int_distribution<>* p, const v8::FunctionCallbackInfo& args) : UniformIntDistributionWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - UniformIntDistribution(v8::Isolate* isolate, const v8::Local& tpl) : UniformIntDistributionWrapper(isolate, tpl) {} - UniformIntDistribution(v8::Isolate* isolate, const v8::Local& proto) : UniformIntDistributionWrapper(isolate, proto) - {} - static const char* Name() { return "UniformIntDistribution"; } - public: - }; - } -} diff --git a/v8/include/modules/core/uniformintdistribution_p.h b/v8/include/modules/core/uniformintdistribution_p.h deleted file mode 100644 index 962f688..0000000 --- a/v8/include/modules/core/uniformintdistribution_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -namespace shelllet::random { - template - class UniformIntDistributionPrivate : public ObjectPrivate - { - public: - template - UniformIntDistributionPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - template - UniformIntDistributionPrivate(T* d, v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(d, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/core/uniformintdistribution_wrapper.h b/v8/include/modules/core/uniformintdistribution_wrapper.h deleted file mode 100644 index 0c9f36d..0000000 --- a/v8/include/modules/core/uniformintdistribution_wrapper.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -namespace shelllet { - namespace random { - template class UniformIntDistributionPrivate; - template - class UniformIntDistributionWrapper : public ObjectWrapper - { - public: - template - UniformIntDistributionWrapper(UniformIntDistributionPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - UniformIntDistributionWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - UniformIntDistributionWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - }; - } -} diff --git a/v8/include/modules/gui/initialize.h b/v8/include/modules/gui/initialize.h deleted file mode 100644 index 0df2bb2..0000000 --- a/v8/include/modules/gui/initialize.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include "framework.h" - -namespace shelllet { - namespace qtgui { - void initialize(v8::Isolate* isolate, const v8::Local& proto) { - - } - - } -} \ No newline at end of file diff --git a/v8/include/modules/gui/qcolor_implement.h b/v8/include/modules/gui/qcolor_implement.h deleted file mode 100644 index ded5042..0000000 --- a/v8/include/modules/gui/qcolor_implement.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qcolor_p.h" -#include "qcolor_wrapper.h" -namespace shelllet { - namespace gui { - class Color : public QColorWrapper - { - using ReturnType = QColorPrivate; - using ReturnType2 = QColorPrivate; - ReturnType* Param(const v8::FunctionCallbackInfo& args) { - v8::Isolate* isolate = args.GetIsolate(); - if (args.Length() > 3) { - int r = args[0]->Uint32Value(isolate->GetCurrentContext()).ToChecked(); - int g = args[1]->Uint32Value(isolate->GetCurrentContext()).ToChecked(); - int b = args[2]->Uint32Value(isolate->GetCurrentContext()).ToChecked(); - int a = 255; - if (args.Length() > 3) { - a = args[3]->NumberValue(isolate->GetCurrentContext()).ToChecked(); - } - - return new ReturnType(isolate, args.This(), r, g, b, a); - } - return new ReturnType(isolate, args.This()); - } - public: - - Color(const v8::FunctionCallbackInfo& args) : QColorWrapper(*Param(args), args) - { - } - Color(QColor* p, const v8::FunctionCallbackInfo& args) : QColorWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Color(v8::Isolate* isolate, const v8::Local& tpl) : QColorWrapper(isolate, tpl) {} - Color(v8::Isolate* isolate, const v8::Local& proto) : QColorWrapper(isolate, proto) { - } - - public: - static const char* Name() { return "Color"; } - }; - } -} diff --git a/v8/include/modules/gui/qcolor_p.h b/v8/include/modules/gui/qcolor_p.h deleted file mode 100644 index d992da7..0000000 --- a/v8/include/modules/gui/qcolor_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -namespace shelllet { - namespace gui { - template - class QColorPrivate : public ObjectPrivate - { - public: - template - QColorPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/gui/qcolor_wrapper.h b/v8/include/modules/gui/qcolor_wrapper.h deleted file mode 100644 index 0412265..0000000 --- a/v8/include/modules/gui/qcolor_wrapper.h +++ /dev/null @@ -1,849 +0,0 @@ -#pragma once -namespace shelllet::gui { - template - class QColorWrapper : public ObjectWrapper - { - public: - - template - QColorWrapper(QColorPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) - { - } - QColorWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QColorWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "red"), Red, SetRed); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "green"), Green, SetGreen); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "blue"), Blue, SetBlue); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "alpha"), Alpha, SetAlpha); - - tpl->PrototypeTemplate()->Set(isolate, "black", v8::FunctionTemplate::New(isolate, Black)); - tpl->PrototypeTemplate()->Set(isolate, "convertTo", v8::FunctionTemplate::New(isolate, ConvertTo)); - tpl->PrototypeTemplate()->Set(isolate, "cyan", v8::FunctionTemplate::New(isolate, Cyan)); - tpl->PrototypeTemplate()->Set(isolate, "darker", v8::FunctionTemplate::New(isolate, Darker)); - tpl->PrototypeTemplate()->Set(isolate, "fromCmyk", v8::FunctionTemplate::New(isolate, FromCmyk)); - tpl->PrototypeTemplate()->Set(isolate, "fromHsl", v8::FunctionTemplate::New(isolate, FromHsl)); - tpl->PrototypeTemplate()->Set(isolate, "fromHsv", v8::FunctionTemplate::New(isolate, FromHsv)); - tpl->PrototypeTemplate()->Set(isolate, "fromRgb", v8::FunctionTemplate::New(isolate, FromRgb)); - tpl->PrototypeTemplate()->Set(isolate, "fromRgba", v8::FunctionTemplate::New(isolate, FromRgba)); - tpl->PrototypeTemplate()->Set(isolate, "fromRgba64", v8::FunctionTemplate::New(isolate, FromRgba64)); - - tpl->PrototypeTemplate()->Set(isolate, "hslHue", v8::FunctionTemplate::New(isolate, HslHue)); - tpl->PrototypeTemplate()->Set(isolate, "hslSaturation", v8::FunctionTemplate::New(isolate, HslSaturation)); - tpl->PrototypeTemplate()->Set(isolate, "hsvHue", v8::FunctionTemplate::New(isolate, HsvHue)); - tpl->PrototypeTemplate()->Set(isolate, "hsvSaturation", v8::FunctionTemplate::New(isolate, HsvSaturation)); - tpl->PrototypeTemplate()->Set(isolate, "hue", v8::FunctionTemplate::New(isolate, Hue)); - tpl->PrototypeTemplate()->Set(isolate, "isValid", v8::FunctionTemplate::New(isolate, IsValid)); - tpl->PrototypeTemplate()->Set(isolate, "isValidColor", v8::FunctionTemplate::New(isolate, IsValidColor)); - tpl->PrototypeTemplate()->Set(isolate, "lighter", v8::FunctionTemplate::New(isolate, Lighter)); - tpl->PrototypeTemplate()->Set(isolate, "lightness", v8::FunctionTemplate::New(isolate, Lightness)); - tpl->PrototypeTemplate()->Set(isolate, "magenta", v8::FunctionTemplate::New(isolate, Magenta)); - tpl->PrototypeTemplate()->Set(isolate, "name", v8::FunctionTemplate::New(isolate, Name)); - tpl->PrototypeTemplate()->Set(isolate, "rgb", v8::FunctionTemplate::New(isolate, Rgb)); - tpl->PrototypeTemplate()->Set(isolate, "rgba", v8::FunctionTemplate::New(isolate, Rgba)); - tpl->PrototypeTemplate()->Set(isolate, "rgba64", v8::FunctionTemplate::New(isolate, Rgba64)); - tpl->PrototypeTemplate()->Set(isolate, "saturation", v8::FunctionTemplate::New(isolate, Saturation)); - tpl->PrototypeTemplate()->Set(isolate, "setCmyk", v8::FunctionTemplate::New(isolate, SetCmyk)); - tpl->PrototypeTemplate()->Set(isolate, "setHsl", v8::FunctionTemplate::New(isolate, SetHsl)); - tpl->PrototypeTemplate()->Set(isolate, "setHsv", v8::FunctionTemplate::New(isolate, SetHsv)); - tpl->PrototypeTemplate()->Set(isolate, "setNamedColor", v8::FunctionTemplate::New(isolate, SetNamedColor)); - tpl->PrototypeTemplate()->Set(isolate, "setRgb", v8::FunctionTemplate::New(isolate, SetRgb)); - tpl->PrototypeTemplate()->Set(isolate, "setRgba", v8::FunctionTemplate::New(isolate, SetRgba)); - tpl->PrototypeTemplate()->Set(isolate, "setRgba64", v8::FunctionTemplate::New(isolate, SetRgba64)); - tpl->PrototypeTemplate()->Set(isolate, "spec", v8::FunctionTemplate::New(isolate, Spec)); - tpl->PrototypeTemplate()->Set(isolate, "toCmyk", v8::FunctionTemplate::New(isolate, ToCmyk)); - tpl->PrototypeTemplate()->Set(isolate, "toExtendedRgb", v8::FunctionTemplate::New(isolate, ToExtendedRgb)); - tpl->PrototypeTemplate()->Set(isolate, "toHsl", v8::FunctionTemplate::New(isolate, ToHsl)); - tpl->PrototypeTemplate()->Set(isolate, "toHsv", v8::FunctionTemplate::New(isolate, ToHsv)); - tpl->PrototypeTemplate()->Set(isolate, "toRgb", v8::FunctionTemplate::New(isolate, ToRgb)); - tpl->PrototypeTemplate()->Set(isolate, "value", v8::FunctionTemplate::New(isolate, Value)); - tpl->PrototypeTemplate()->Set(isolate, "yellow", v8::FunctionTemplate::New(isolate, Yellow)); - - { - tpl->Set(isolate, "colorNames", v8::FunctionTemplate::New(isolate, ColorNames)); - tpl->Set(isolate, "fromCmyk", v8::FunctionTemplate::New(isolate, FromCmyk)); - tpl->Set(isolate, "fromHsl", v8::FunctionTemplate::New(isolate, FromHsl)); - tpl->Set(isolate, "fromHsv", v8::FunctionTemplate::New(isolate, FromHsv)); - tpl->Set(isolate, "fromRgb", v8::FunctionTemplate::New(isolate, FromRgb)); - tpl->Set(isolate, "fromRgba64", v8::FunctionTemplate::New(isolate, FromRgba64)); - tpl->Set(isolate, "fromRgba", v8::FunctionTemplate::New(isolate, FromRgba)); - tpl->Set(isolate, "isValidColor", v8::FunctionTemplate::New(isolate, IsValidColor)); - } - } - - public: - qreal red() const noexcept { return d_func()->redF(); } - qreal green() const noexcept { return d_func()->greenF(); } - qreal blue() const noexcept { return d_func()->blueF(); } - qreal alpha() const noexcept { return d_func()->alphaF(); } - void setRed(qreal red) { d_func()->setRedF(red); } - void setGreen(qreal green) { d_func()->setGreenF(green); } - void setBlue(qreal blue) { d_func()->setBlueF(blue); } - void setAlpha(qreal alpha) { d_func()->setAlphaF(alpha); } - - public: - - static void IsValid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->isValid(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Name(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - QString name; - if (args.Length() > 0 && args[0]->IsNumber()) { - QColor::NameFormat format = static_cast(args[0]->Int32Value(context).FromJust()); - name = (*p)->name(format); - } - else { - name = (*p)->name(); - } - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, qPrintable(name))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetNamedColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value name(isolate, args[0]); - (*p)->setNamedColor(*name); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ColorNames(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->colorNames(); - v8::Local array = v8::Array::New(isolate, result.length()); - - for (int i = 0; i < result.length(); ++i) - { - array->Set(context, i, V8_NEW_STRING_VAR(isolate, qPrintable(result[i]))); - } - - args.GetReturnValue().Set(array); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Spec(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->spec(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Alpha(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set((*p)->alpha()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Red(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set((*p)->red()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Green(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set((*p)->green()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Blue(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - info.GetReturnValue().Set((*p)->blue()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetRed(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - - (*p)->setRed(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetGreen(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - - (*p)->setGreen(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetBlue(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setBlue(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetAlpha(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = UnWrap>(info.This()); - (*p)->setAlpha(value->NumberValue(context).ToChecked()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetRgb(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - std::array rgba = { 0, 0, 0, 255 }; - - for (int i = 0; i < args.Length(); ++i) { - if (args[i]->IsNumber()) { - rgba[i] = args[i]->Int32Value(context).FromJust(); - } - } - (*p)->setRgb(rgba[0], rgba[1], rgba[2], rgba[3]); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Rgba64(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->rgba64(); - //args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetRgba64(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Rgba(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->rgba(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetRgba(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Rgb(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->rgb(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Hue(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->hue(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Saturation(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->saturation(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HsvHue(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->hsvHue(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HsvSaturation(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->hsvSaturation(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Value(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->value(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetHsv(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - std::array hsva = { 0, 0, 0, 255 }; - - for (int i = 0; i < args.Length(); ++i) { - if (args[i]->IsNumber()) { - hsva[i] = args[i]->Int32Value(context).FromJust(); - } - } - (*p)->setHsv(hsva[0], hsva[1], hsva[2], hsva[3]); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Cyan(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->cyan(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Magenta(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->magenta(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Yellow(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->yellow(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Black(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->black(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetCmyk(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - std::array rgba = { 0, 0, 0, 0, 255 }; - - for (int i = 0; i < args.Length(); ++i) { - if (args[i]->IsNumber()) { - rgba[i] = args[i]->Int32Value(context).FromJust(); - } - } - (*p)->setCmyk(rgba[0], rgba[1], rgba[2], rgba[3], rgba[4]); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HslHue(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->hslHue(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HslSaturation(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->hslSaturation(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Lightness(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->lightness(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetHsl(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - std::array hsl = { 0, 0, 0, 255 }; - - for (int i = 0; i < args.Length(); ++i) { - if (args[i]->IsNumber()) { - hsl[i] = args[i]->Int32Value(context).FromJust(); - } - } - (*p)->setHsl(hsl[0], hsl[1], hsl[2], hsl[3]); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToRgb(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->toRgb(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToHsv(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->toHsv(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToCmyk(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->toCmyk(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToHsl(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->toHsl(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToExtendedRgb(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - auto result = (*p)->toExtendedRgb(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ConvertTo(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromRgb(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromRgba(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - int r = 0, g = 0, b = 0, a = 255; - if (args.Length() > 0 && args[0]->IsNumber()) { - r = args[0]->Int32Value(context).FromJust(); - } - if (args.Length() > 1 && args[1]->IsNumber()) { - g = args[1]->Int32Value(context).FromJust(); - } - if (args.Length() > 2 && args[2]->IsNumber()) { - b = args[2]->Int32Value(context).FromJust(); - } - if (args.Length() > 3 && args[3]->IsNumber()) { - a = args[3]->Int32Value(context).FromJust(); - } - QColor color = QColor::fromRgb(r, g, b, a); - - args.GetReturnValue().Set(Color::New(isolate, v8::External::New(isolate, &color))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromRgba64(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - short r = 0, g = 0, b = 0, a = USHRT_MAX; - if (args.Length() > 0 && args[0]->IsNumber()) { - r = args[0]->Int32Value(context).FromJust(); - } - if (args.Length() > 1 && args[1]->IsNumber()) { - g = args[1]->Int32Value(context).FromJust(); - } - if (args.Length() > 2 && args[2]->IsNumber()) { - b = args[2]->Int32Value(context).FromJust(); - } - if (args.Length() > 3 && args[3]->IsNumber()) { - a = args[3]->Int32Value(context).FromJust(); - } - QColor color = QColor::fromRgba64(r, g, b, a); - - args.GetReturnValue().Set(Color::New(isolate, v8::External::New(isolate, &color))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromHsv(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - int r = 0, g = 0, b = 0, a = 255; - if (args.Length() > 0 && args[0]->IsNumber()) { - r = args[0]->Int32Value(context).FromJust(); - } - if (args.Length() > 1 && args[1]->IsNumber()) { - g = args[1]->Int32Value(context).FromJust(); - } - if (args.Length() > 2 && args[2]->IsNumber()) { - b = args[2]->Int32Value(context).FromJust(); - } - if (args.Length() > 3 && args[3]->IsNumber()) { - a = args[3]->Int32Value(context).FromJust(); - } - QColor color = QColor::fromHsv(r, g, b, a); - - args.GetReturnValue().Set(Color::New(isolate, v8::External::New(isolate, &color))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromCmyk(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - int c = 0, m = 0, y = 0, k = 0, a = 255; - if (args.Length() > 0 && args[0]->IsNumber()) { - c = args[0]->Int32Value(context).FromJust(); - } - if (args.Length() > 1 && args[1]->IsNumber()) { - m = args[1]->Int32Value(context).FromJust(); - } - if (args.Length() > 2 && args[2]->IsNumber()) { - y = args[2]->Int32Value(context).FromJust(); - } - if (args.Length() > 3 && args[3]->IsNumber()) { - k = args[3]->Int32Value(context).FromJust(); - } - if (args.Length() > 4 && args[4]->IsNumber()) { - a = args[4]->Int32Value(context).FromJust(); - } - QColor color = QColor::fromCmyk(c, m, y, k, a); - - args.GetReturnValue().Set(Color::New(isolate, v8::External::New(isolate, &color))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromHsl(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - int r = 0, g = 0, b = 0, a = 255; - if (args.Length() > 0 && args[0]->IsNumber()) { - r = args[0]->Int32Value(context).FromJust(); - } - if (args.Length() > 1 && args[1]->IsNumber()) { - g = args[1]->Int32Value(context).FromJust(); - } - if (args.Length() > 2 && args[2]->IsNumber()) { - b = args[2]->Int32Value(context).FromJust(); - } - if (args.Length() > 3 && args[3]->IsNumber()) { - a = args[3]->Int32Value(context).FromJust(); - } - QColor color = QColor::fromHsl(r, g, b, a); - args.GetReturnValue().Set(Color::New(isolate, v8::External::New(isolate, &color))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Lighter(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - int factor = 150; - if (args.Length() > 0 && args[0]->IsNumber()) { - factor = args[0]->Int32Value(context).FromJust(); - } - QColor color = (*p)->lighter(factor); - - args.GetReturnValue().Set(Color::New(isolate, v8::External::New(isolate, &color))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Darker(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (p) - { - int factor = 200; - if (args.Length() > 0 && args[0]->IsNumber()) { - factor = args[0]->Int32Value(context).FromJust(); - } - QColor color = (*p)->darker(factor); - - args.GetReturnValue().Set(Color::New(isolate, v8::External::New(isolate, &color))); - }; - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsValidColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value name(isolate, args[0]); - args.GetReturnValue().Set(QColor::isValidColor(*name)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; -} diff --git a/v8/include/modules/gui/qimage_implement.h b/v8/include/modules/gui/qimage_implement.h deleted file mode 100644 index b925f23..0000000 --- a/v8/include/modules/gui/qimage_implement.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "core/qsize_implement.h" -#include "core/qrect_implement.h" -#include "core/qpoint_implement.h" -#include "qimage_p.h" -#include "qimage_wrapper.h" - -namespace shelllet { - namespace gui { - class Image : public QImageWrapper - { - using ReturnType = QImagePrivate; - using ReturnType2 = QImagePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - - Image(const v8::FunctionCallbackInfo& args) : QImageWrapper(*Private(args), args) {} - Image(QImage* p, const v8::FunctionCallbackInfo& args) : QImageWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Image(v8::Isolate* isolate, const v8::Local& tpl) : QImageWrapper(isolate, tpl) {} - Image(v8::Isolate* isolate, const v8::Local& proto) : QImageWrapper(isolate, proto) {} - - static const char* Name() { return "Image"; } - }; - } -} diff --git a/v8/include/modules/gui/qimage_p.h b/v8/include/modules/gui/qimage_p.h deleted file mode 100644 index 94f23c7..0000000 --- a/v8/include/modules/gui/qimage_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "qpaintdevice_p.h" - -namespace shelllet::gui { - template - class QImagePrivate : public QPaintDevicePrivate - { - public: - template - QImagePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QPaintDevicePrivate(isolate, obj, std::forward(args)...) { - } - - }; -} diff --git a/v8/include/modules/gui/qimage_wrapper.h b/v8/include/modules/gui/qimage_wrapper.h deleted file mode 100644 index 62d3297..0000000 --- a/v8/include/modules/gui/qimage_wrapper.h +++ /dev/null @@ -1,1275 +0,0 @@ -#pragma once -#include "qpaintdevice_wrapper.h" -namespace shelllet { - namespace gui { - template - class QImageWrapper : public QPaintDeviceWrapper - { - public: - - template - QImageWrapper(QImagePrivate& d, const v8::FunctionCallbackInfo& args) - : QPaintDeviceWrapper(d, args) { - } - QImageWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QPaintDeviceWrapper(isolate, tpl) {} - QImageWrapper(v8::Isolate* isolate, const v8::Local& proto) : QPaintDeviceWrapper(isolate, proto) { - { - v8::Local invertMode = v8::ObjectTemplate::New(isolate); - invertMode->Set(isolate, "InvertRgb", v8::Int32::New(isolate, QImage::InvertMode::InvertRgb)); - invertMode->Set(isolate, " InvertRgba", v8::Int32::New(isolate, QImage::InvertMode::InvertRgba)); - tpl->Set(isolate, "InvertMode", invertMode); - - v8::Local format = v8::ObjectTemplate::New(isolate); - format->Set(isolate, "Format_Invalid", v8::Int32::New(isolate, QImage::Format::Format_Invalid)); - format->Set(isolate, "Format_Mono", v8::Int32::New(isolate, QImage::Format::Format_Mono)); - format->Set(isolate, "Format_MonoLSB", v8::Int32::New(isolate, QImage::Format::Format_MonoLSB)); - format->Set(isolate, "Format_Indexed8", v8::Int32::New(isolate, QImage::Format::Format_Indexed8)); - format->Set(isolate, "Format_RGB32", v8::Int32::New(isolate, QImage::Format::Format_RGB32)); - format->Set(isolate, "Format_ARGB32", v8::Int32::New(isolate, QImage::Format::Format_ARGB32)); - format->Set(isolate, "Format_ARGB32_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_ARGB32_Premultiplied)); - format->Set(isolate, "Format_RGB16", v8::Int32::New(isolate, QImage::Format::Format_RGB16)); - format->Set(isolate, "Format_ARGB8565_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_ARGB8565_Premultiplied)); - format->Set(isolate, "Format_RGB666", v8::Int32::New(isolate, QImage::Format::Format_RGB666)); - format->Set(isolate, "Format_ARGB6666_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_ARGB6666_Premultiplied)); - format->Set(isolate, "Format_RGB555", v8::Int32::New(isolate, QImage::Format::Format_RGB555)); - format->Set(isolate, "Format_ARGB8555_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_ARGB8555_Premultiplied)); - format->Set(isolate, "Format_RGB888", v8::Int32::New(isolate, QImage::Format::Format_RGB888)); - format->Set(isolate, "Format_RGB444", v8::Int32::New(isolate, QImage::Format::Format_RGB444)); - format->Set(isolate, "Format_ARGB4444_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_ARGB4444_Premultiplied)); - format->Set(isolate, "Format_RGBX8888", v8::Int32::New(isolate, QImage::Format::Format_RGBX8888)); - format->Set(isolate, "Format_RGBA8888", v8::Int32::New(isolate, QImage::Format::Format_RGBA8888)); - format->Set(isolate, "Format_RGBA8888_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_RGBA8888_Premultiplied)); - format->Set(isolate, "Format_BGR30", v8::Int32::New(isolate, QImage::Format::Format_BGR30)); - format->Set(isolate, "Format_A2BGR30_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_A2BGR30_Premultiplied)); - format->Set(isolate, "Format_RGB30", v8::Int32::New(isolate, QImage::Format::Format_RGB30)); - format->Set(isolate, "Format_A2RGB30_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_A2RGB30_Premultiplied)); - format->Set(isolate, "Format_Alpha8", v8::Int32::New(isolate, QImage::Format::Format_Alpha8)); - format->Set(isolate, "Format_Grayscale8", v8::Int32::New(isolate, QImage::Format::Format_Grayscale8)); - format->Set(isolate, "Format_RGBX64", v8::Int32::New(isolate, QImage::Format::Format_RGBX64)); - format->Set(isolate, "Format_RGBA64", v8::Int32::New(isolate, QImage::Format::Format_RGBA64)); - format->Set(isolate, "Format_RGBA64_Premultiplied", v8::Int32::New(isolate, QImage::Format::Format_RGBA64_Premultiplied)); - format->Set(isolate, "Format_Grayscale16", v8::Int32::New(isolate, QImage::Format::Format_Grayscale16)); - format->Set(isolate, "Format_BGR888", v8::Int32::New(isolate, QImage::Format::Format_BGR888)); - format->Set(isolate, "NImageFormats", v8::Int32::New(isolate, QImage::Format::NImageFormats)); - tpl->Set(isolate, "Format", format); - - tpl->Set(isolate, "fromData", v8::FunctionTemplate::New(isolate, FromData)); - tpl->Set(isolate, "toImageFormat", v8::FunctionTemplate::New(isolate, ToImageFormat)); - tpl->Set(isolate, "toPixelFormat", v8::FunctionTemplate::New(isolate, ToPixelFormat)); - tpl->Set(isolate, "trueMatrix", v8::FunctionTemplate::New(isolate, TrueMatrix)); - } - { - tpl->PrototypeTemplate()->Set(isolate, "allGray", v8::FunctionTemplate::New(isolate, AllGray)); - tpl->PrototypeTemplate()->Set(isolate, "alphaChannel", v8::FunctionTemplate::New(isolate, AlphaChannel)); - tpl->PrototypeTemplate()->Set(isolate, "applyColorTransform", v8::FunctionTemplate::New(isolate, ApplyColorTransform)); - tpl->PrototypeTemplate()->Set(isolate, "bitPlaneCount", v8::FunctionTemplate::New(isolate, BitPlaneCount)); - tpl->PrototypeTemplate()->Set(isolate, "bits", v8::FunctionTemplate::New(isolate, Bits)); - tpl->PrototypeTemplate()->Set(isolate, "bytesPerLine", v8::FunctionTemplate::New(isolate, BytesPerLine)); - tpl->PrototypeTemplate()->Set(isolate, "cacheKey", v8::FunctionTemplate::New(isolate, CacheKey)); - tpl->PrototypeTemplate()->Set(isolate, "color", v8::FunctionTemplate::New(isolate, Color)); - tpl->PrototypeTemplate()->Set(isolate, "colorSpace", v8::FunctionTemplate::New(isolate, ColorSpace)); - tpl->PrototypeTemplate()->Set(isolate, "colorTable", v8::FunctionTemplate::New(isolate, ColorTable)); - tpl->PrototypeTemplate()->Set(isolate, "convertedToColorSpace", v8::FunctionTemplate::New(isolate, ConvertedToColorSpace)); - tpl->PrototypeTemplate()->Set(isolate, "convertTo", v8::FunctionTemplate::New(isolate, ConvertTo)); - tpl->PrototypeTemplate()->Set(isolate, "convertToColorSpace", v8::FunctionTemplate::New(isolate, ConvertToColorSpace)); - tpl->PrototypeTemplate()->Set(isolate, "convertToFormat", v8::FunctionTemplate::New(isolate, ConvertToFormat)); - tpl->PrototypeTemplate()->Set(isolate, "copy", v8::FunctionTemplate::New(isolate, Copy)); - tpl->PrototypeTemplate()->Set(isolate, "createAlphaMask", v8::FunctionTemplate::New(isolate, CreateAlphaMask)); - tpl->PrototypeTemplate()->Set(isolate, "createHeuristicMask", v8::FunctionTemplate::New(isolate, CreateHeuristicMask)); - tpl->PrototypeTemplate()->Set(isolate, "createMaskFromColor", v8::FunctionTemplate::New(isolate, CreateMaskFromColor)); - tpl->PrototypeTemplate()->Set(isolate, "detach", v8::FunctionTemplate::New(isolate, Detach)); - tpl->PrototypeTemplate()->Set(isolate, "devType", v8::FunctionTemplate::New(isolate, DevType)); - tpl->PrototypeTemplate()->Set(isolate, "dotsPerMeterX", v8::FunctionTemplate::New(isolate, DotsPerMeterX)); - tpl->PrototypeTemplate()->Set(isolate, "dotsPerMeterY", v8::FunctionTemplate::New(isolate, DotsPerMeterY)); - tpl->PrototypeTemplate()->Set(isolate, "fill", v8::FunctionTemplate::New(isolate, Fill)); - tpl->PrototypeTemplate()->Set(isolate, "format", v8::FunctionTemplate::New(isolate, Format)); - tpl->PrototypeTemplate()->Set(isolate, "fromData", v8::FunctionTemplate::New(isolate, FromData)); - tpl->PrototypeTemplate()->Set(isolate, "hasAlphaChannel", v8::FunctionTemplate::New(isolate, HasAlphaChannel)); - tpl->PrototypeTemplate()->Set(isolate, "invertPixels", v8::FunctionTemplate::New(isolate, InvertPixels)); - tpl->PrototypeTemplate()->Set(isolate, "isDetached", v8::FunctionTemplate::New(isolate, IsDetached)); - tpl->PrototypeTemplate()->Set(isolate, "isGrayscale", v8::FunctionTemplate::New(isolate, IsGrayscale)); - tpl->PrototypeTemplate()->Set(isolate, "isNull", v8::FunctionTemplate::New(isolate, IsNull)); - tpl->PrototypeTemplate()->Set(isolate, "load", v8::FunctionTemplate::New(isolate, Load)); - tpl->PrototypeTemplate()->Set(isolate, "loadFromData", v8::FunctionTemplate::New(isolate, LoadFromData)); - tpl->PrototypeTemplate()->Set(isolate, "mirrored", v8::FunctionTemplate::New(isolate, Mirrored)); - tpl->PrototypeTemplate()->Set(isolate, "offset", v8::FunctionTemplate::New(isolate, Offset)); - tpl->PrototypeTemplate()->Set(isolate, "pixel", v8::FunctionTemplate::New(isolate, Pixel)); - tpl->PrototypeTemplate()->Set(isolate, "pixelColor", v8::FunctionTemplate::New(isolate, PixelColor)); - tpl->PrototypeTemplate()->Set(isolate, "pixelFormat", v8::FunctionTemplate::New(isolate, PixelFormat)); - tpl->PrototypeTemplate()->Set(isolate, "pixelIndex", v8::FunctionTemplate::New(isolate, PixelIndex)); - tpl->PrototypeTemplate()->Set(isolate, "rect", v8::FunctionTemplate::New(isolate, GetRect)); - tpl->PrototypeTemplate()->Set(isolate, "reinterpretAsFormat", v8::FunctionTemplate::New(isolate, ReinterpretAsFormat)); - tpl->PrototypeTemplate()->Set(isolate, "rgbSwapped", v8::FunctionTemplate::New(isolate, RgbSwapped)); - tpl->PrototypeTemplate()->Set(isolate, "save", v8::FunctionTemplate::New(isolate, Save)); - tpl->PrototypeTemplate()->Set(isolate, "scaled", v8::FunctionTemplate::New(isolate, Scaled)); - tpl->PrototypeTemplate()->Set(isolate, "scaledToHeight", v8::FunctionTemplate::New(isolate, ScaledToHeight)); - tpl->PrototypeTemplate()->Set(isolate, "scaledToWidth", v8::FunctionTemplate::New(isolate, ScaledToWidth)); - tpl->PrototypeTemplate()->Set(isolate, "scanLine", v8::FunctionTemplate::New(isolate, ScanLine)); - tpl->PrototypeTemplate()->Set(isolate, "setAlphaChannel", v8::FunctionTemplate::New(isolate, SetAlphaChannel)); - tpl->PrototypeTemplate()->Set(isolate, "setColor", v8::FunctionTemplate::New(isolate, SetColor)); - tpl->PrototypeTemplate()->Set(isolate, "setColorCount", v8::FunctionTemplate::New(isolate, SetColorCount)); - tpl->PrototypeTemplate()->Set(isolate, "setColorSpace", v8::FunctionTemplate::New(isolate, SetColorSpace)); - tpl->PrototypeTemplate()->Set(isolate, "setColorTable", v8::FunctionTemplate::New(isolate, SetColorTable)); - tpl->PrototypeTemplate()->Set(isolate, "setDevicePixelRatio", v8::FunctionTemplate::New(isolate, SetDevicePixelRatio)); - tpl->PrototypeTemplate()->Set(isolate, "setDotsPerMeterX", v8::FunctionTemplate::New(isolate, SetDotsPerMeterX)); - tpl->PrototypeTemplate()->Set(isolate, "setDotsPerMeterY", v8::FunctionTemplate::New(isolate, SetDotsPerMeterY)); - tpl->PrototypeTemplate()->Set(isolate, "setOffset", v8::FunctionTemplate::New(isolate, SetOffset)); - tpl->PrototypeTemplate()->Set(isolate, "setPixel", v8::FunctionTemplate::New(isolate, SetPixel)); - tpl->PrototypeTemplate()->Set(isolate, "setPixelColor", v8::FunctionTemplate::New(isolate, SetPixelColor)); - tpl->PrototypeTemplate()->Set(isolate, "setText", v8::FunctionTemplate::New(isolate, SetText)); - tpl->PrototypeTemplate()->Set(isolate, "size", v8::FunctionTemplate::New(isolate, GetSize)); - tpl->PrototypeTemplate()->Set(isolate, "sizeInBytes", v8::FunctionTemplate::New(isolate, SizeInBytes)); - tpl->PrototypeTemplate()->Set(isolate, "text", v8::FunctionTemplate::New(isolate, Text)); - tpl->PrototypeTemplate()->Set(isolate, "textKeys", v8::FunctionTemplate::New(isolate, TextKeys)); - tpl->PrototypeTemplate()->Set(isolate, "transformed", v8::FunctionTemplate::New(isolate, Transformed)); - tpl->PrototypeTemplate()->Set(isolate, "valid", v8::FunctionTemplate::New(isolate, Valid)); - } - } - - protected: - static void AllGray(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->allGray()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void AlphaChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->alphaChannel())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void ApplyColorTransform(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /*auto transform = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - (*p)->applyColorTransform(transform);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BitPlaneCount(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->bitPlaneCount()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Bits(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Uint32::New(isolate, reinterpret_cast((*p)->bits())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BytesPerLine(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->bytesPerLine()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CacheKey(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::BigInt::New(isolate, (*p)->cacheKey()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Color(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto i = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto result = v8::Uint32::New(isolate, (*p)->color(i)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void ColorSpace(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /*auto result = v8::Int32::New(isolate, (*p)->colorSpace()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ColorTable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto colors = (*p)->colorTable(); - std::vector c(colors.size()); - std::transform(colors.begin(), colors.end(), c.begin(), [](const auto& v) { return v; }); - - args.GetReturnValue().Set(NewArray(c)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void ConvertedToColorSpace(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /* auto QColorSpace = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto result = v8::Int32::New(isolate, (*p)->convertedToColorSpace(QColorSpace)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ConvertTo(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto f = static_cast(args[0]->Int32Value(context).FromJust()); - - auto flags = std::invoke([&]() { - if (args[1]->IsObject()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - - (*p)->convertTo(f, flags); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void ConvertToColorSpace(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /* auto QColorSpace = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - (*p)->convertToColorSpace(QColorSpace);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ConvertToFormat(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto f = static_cast(args[0]->Int32Value(context).FromJust()); - v8::Local result; - - if (args[1]->IsArray()) { - auto colorTable = ToArray(args[1]); - QVector c(colorTable.size()); - std::transform(colorTable.begin(), colorTable.end(), c.begin(), [](const auto& v) { return v; }); - auto flags = std::invoke([&]() { - if (args[1]->IsInt32()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - result = Image::New(isolate, v8::External::New(isolate, &(*p)->convertToFormat(f, c, flags))); - } - else { - auto flags = std::invoke([&]() { - if (args[1]->IsInt32()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - result = Image::New(isolate, v8::External::New(isolate, &(*p)->convertToFormat(f, flags))); - } - - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Copy(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto rect = Rect::From(args[0]); - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->copy(**rect))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CreateAlphaMask(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto flags = std::invoke([&]() { - if (args[0]->IsObject()) - return static_cast(args[0]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->createAlphaMask(flags))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CreateHeuristicMask(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto clipTight = std::invoke([&]() { - if (args[0]->IsBoolean()) - return args[0]->BooleanValue(isolate); - return true; - }); - - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->createHeuristicMask(clipTight))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CreateMaskFromColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto color = static_cast(args[0]->Uint32Value(context).FromJust()); - - auto mode = std::invoke([&]() { - if (args[1]->IsObject()) - return static_cast (args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::MaskInColor); - }); - - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->createMaskFromColor(color, mode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Detach(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - (*p)->detach(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DevType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->devType()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DotsPerMeterX(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->dotsPerMeterX()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DotsPerMeterY(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->dotsPerMeterY()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void Fill(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - if (args[0]->IsNumber()) { - int color = args[0]->Int32Value(context).FromJust(); - - (*p)->fill(color); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Format(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->format()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HasAlphaChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->hasAlphaChannel()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void InvertPixels(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto invertMode = static_cast(args[0]->Int32Value(context).FromJust()); - - (*p)->invertPixels(invertMode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsDetached(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->isDetached()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsGrayscale(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->isGrayscale()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsNull(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->isNull()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Load(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto fileName = ToString({ isolate, args[0] }); - auto format = ToString({ isolate, args[1] }); - - auto result = v8::Boolean::New(isolate, (*p)->load(fileName, format)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void LoadFromData(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto buf = ToArray(args[0]); - auto format = ToString({ isolate, args[1] }); - - auto result = v8::Boolean::New(isolate, (*p)->loadFromData(QByteArray::fromRawData(&buf[0], buf.size()), format)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Mirrored(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto horizontally = std::invoke([&]() { - if (args[0]->IsBoolean()) - return args[0]->BooleanValue(isolate); - return false; - }); - - auto vertically = std::invoke([&]() { - if (args[1]->IsBoolean()) - return args[1]->BooleanValue(isolate); - return true; - }); - - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->mirrored(horizontally, vertically))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Offset(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Point::New(isolate, v8::External::New(isolate, &(*p)->offset())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Pixel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto pt = Point::From(args[0]); - // delete. - auto result = v8::Int32::New(isolate, (*p)->pixel(**pt)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void PixelColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - /* - auto result = v8::Int32::New(isolate, (*p)->pixelColor(x, y)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void PixelFormat(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /*auto result = v8::Int32::New(isolate, (*p)->pixelFormat()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PixelIndex(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - int index = 0; - auto pt = Point::From(args[0]); - auto result = v8::Int32::New(isolate, (*p)->pixelIndex(**pt)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetRect(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Rect::New(isolate, v8::External::New(isolate, &(*p)->rect())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReinterpretAsFormat(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto f = static_cast(args[0]->Int32Value(context).FromJust()); - auto result = v8::Boolean::New(isolate, (*p)->reinterpretAsFormat(f)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RgbSwapped(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->rgbSwapped())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Save(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto fileName = ToString({ isolate, args[0] }); - - auto format = ToString({ isolate, args[0] }); - - auto quality = std::invoke([&]() { - if (args[2]->IsInt32()) - return args[2]->Int32Value(context).FromJust(); - return -1; - }); - - auto result = v8::Boolean::New(isolate, (*p)->save(fileName, format, quality)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Scaled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - int index = 0; - auto s = Size::From(args[0]); - if (!s) { - throw std::invalid_argument("! require `Size` value."); - } - - auto aspectMode = std::invoke([&]() { - if (args[index]->IsObject()) - return static_cast(args[index]->Int32Value(context).FromJust()); - return static_cast(Qt::IgnoreAspectRatio); - }); - - auto mode = std::invoke([&]() { - if (args[index]->IsObject()) - return static_cast(args[index]->Int32Value(context).FromJust()); - return static_cast(Qt::FastTransformation); - }); - - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->scaled(**s, aspectMode, mode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ScaledToHeight(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto h = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto mode = std::invoke([&]() { - if (args[1]->IsObject()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return Qt::FastTransformation; - }); - - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->scaledToHeight(h, mode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ScaledToWidth(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto w = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto mode = std::invoke([&]() { - if (args[1]->IsObject()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return Qt::FastTransformation; - }); - - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->scaledToWidth(w, mode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ScanLine(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto index = args[0]->Int32Value(context).FromJust(); - auto result = v8::Uint32::New(isolate, reinterpret_cast((*p)->scanLine(index))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetAlphaChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto* alphaChannel = Image::From(args[0]); - (*p)->setAlphaChannel(**alphaChannel); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto i = args[0]->Int32Value(context).FromJust(); - - auto c = static_cast(args[1]->Int32Value(context).FromJust()); - (*p)->setColor(i, c); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetColorCount(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto colorCount = args[0]->Int32Value(context).FromJust(); - - (*p)->setColorCount(colorCount); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void SetColorSpace(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /* auto QColorSpace = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - (*p)->setColorSpace(QColorSpace);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetColorTable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto colors = ToArray(args[0]); - QVector c(colors.size()); - std::transform(colors.begin(), colors.end(), c.begin(), [](const auto& v) { return v; }); - (*p)->setColorTable(c); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetDevicePixelRatio(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto scaleFactor = args[0]->NumberValue(context).FromJust(); - (*p)->setDevicePixelRatio(scaleFactor); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetDotsPerMeterX(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto x = args[0]->Int32Value(context).FromJust(); - (*p)->setDotsPerMeterX(x); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetDotsPerMeterY(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto y = args[0]->Int32Value(context).FromJust(); - - (*p)->setDotsPerMeterY(y); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetOffset(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto offset = Point::From(args[0]); - (*p)->setOffset(**offset); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetPixel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto pt = Point::From(args[0]); - auto index_or_rgb = args[1]->Int32Value(context).FromJust(); - (*p)->setPixel(**pt, index_or_rgb); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void SetPixelColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /*auto pt = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto c = std::invoke([&]() { - if (!args[1]->IsObject()) - throw std::invalid_argument("!`Object` required at [1]."); - return args[1]->Int32Value(context).FromJust(); - }); - - (*p)->setPixelColor(pt, c);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetText(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto key = ToString({ isolate, args[0] }); - - auto value = ToString({ isolate, args[1] }); - - (*p)->setText(key, value); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Size::New(isolate, v8::External::New(isolate, &(*p)->size())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SizeInBytes(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->sizeInBytes()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Text(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto key = ToString({ isolate, args[0] }); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, (*p)->text(key).toUtf8().constData())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void TextKeys(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - const auto keys = (*p)->textKeys(); - std::vector c(keys.size()); - std::transform(keys.begin(), keys.end(), c.begin(), [](auto& s) { return s.toStdString(); }); - args.GetReturnValue().Set(NewArray(c)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void Transformed(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /*auto matrix = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto mode = std::invoke([&]() { - if (args[1]->IsObject()) - return args[1]->Int32Value(context).FromJust(); - return Qt::FastTransformation; - }); - - auto result = v8::Int32::New(isolate, (*p)->transformed(matrix, mode)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Valid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto pt = Point::From(args[0]); - auto result = v8::Boolean::New(isolate, (*p)->valid(**pt)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromData(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto data = ToArray(args[0]); - auto format = ToString({ isolate, args[1] }); - - auto result = Image::New(isolate, v8::External::New(isolate, &QImage::fromData(QByteArray::fromRawData(&data[0], data.size()), format))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void ToImageFormat(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - /*auto result = v8::Int32::New(isolate, (*p)->toImageFormat()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO - static void ToPixelFormat(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - /*auto result = v8::Int32::New(isolate, (*p)->toPixelFormat()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void TrueMatrix(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - /*auto QMatrix = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto w = std::invoke([&]() { - if (!args[1]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [1]."); - return args[1]->Int32Value(context).FromJust(); - }); - - auto h = std::invoke([&]() { - if (!args[2]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [2]."); - return args[2]->Int32Value(context).FromJust(); - }); - - auto result = v8::Int32::New(isolate, (*p)->trueMatrix(QMatrix, w, h)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/gui/qpaintdevice_implement.h b/v8/include/modules/gui/qpaintdevice_implement.h deleted file mode 100644 index bd98d1c..0000000 --- a/v8/include/modules/gui/qpaintdevice_implement.h +++ /dev/null @@ -1,30 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "gui_module.h" -#include "qpaintdevice_p.h" -#include "qpaintdevice_wrapper.h" - -namespace shelllet { - namespace gui { - class PaintDevice : public QPaintDeviceWrapper - { - using ReturnType = QPaintDevicePrivate; - using ReturnType2 = QPaintDevicePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - - PaintDevice(const v8::FunctionCallbackInfo& args) : QPaintDeviceWrapper(*Private(args), args) {} - PaintDevice(QPaintDevice* p, const v8::FunctionCallbackInfo& args) : QPaintDeviceWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - PaintDevice(v8::Isolate* isolate, const v8::Local& tpl) :QPaintDeviceWrapper(isolate, tpl) {} - PaintDevice(v8::Isolate* isolate, const v8::Local& proto) :QPaintDeviceWrapper(isolate, proto) {} - - static const char* Name() { return "PaintDevice"; } - public: - }; - } -} diff --git a/v8/include/modules/gui/qpaintdevice_p.h b/v8/include/modules/gui/qpaintdevice_p.h deleted file mode 100644 index c9a1444..0000000 --- a/v8/include/modules/gui/qpaintdevice_p.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -namespace shelllet::gui { - template - class QPaintDevicePrivate : public ObjectPrivate - { - public: - template - QPaintDevicePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - int metric(QPaintDevice::PaintDeviceMetric metric) const { - if (hasOwnProperty(strrchr(__FUNCTION__, ':') + 1)) { - //v8::Local argv[] = { v8::Int32::New(v8::Isolate::GetCurrent(), metric) } - v8::Local v = call(__FUNCTION__, v8::Int32::New(v8::Isolate::GetCurrent(), metric)); - return v->Int32Value(v8::Isolate::GetCurrent()->GetCurrentContext()).FromJust(); - - } - if constexpr (std::is_abstract::value) - throw std::logic_error("The method or operation is not implemented."); - else { - return T::metric(metric); - } - } - QPaintEngine* paintEngine() const { - - if (hasOwnProperty(strrchr(__FUNCTION__, ':') + 1)) { - //v8::Local argv[] = { v8::Int32::New(v8::Isolate::GetCurrent(), metric) } - v8::Local v = call(__FUNCTION__, v8::External::New(v8::Isolate::GetCurrent(), nullptr)); - return static_cast(v.As()->Value()); - - } - if constexpr (std::is_abstract::value) - throw std::logic_error("The method or operation is not implemented."); - - throw std::logic_error("The method or operation is not implemented."); - } - - }; -} diff --git a/v8/include/modules/gui/qpaintdevice_wrapper.h b/v8/include/modules/gui/qpaintdevice_wrapper.h deleted file mode 100644 index 77ac73e..0000000 --- a/v8/include/modules/gui/qpaintdevice_wrapper.h +++ /dev/null @@ -1,232 +0,0 @@ -#pragma once -namespace shelllet { - namespace gui { - template - class QPaintDeviceWrapper : public ObjectWrapper - { - public: - template - QPaintDeviceWrapper(QPaintDevicePrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QPaintDeviceWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QPaintDeviceWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) { - { - v8::Local paintDeviceMetric = v8::ObjectTemplate::New(isolate); - paintDeviceMetric->Set(isolate, "PdmWidth", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmWidth)); - paintDeviceMetric->Set(isolate, "PdmHeight", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmHeight)); - paintDeviceMetric->Set(isolate, "PdmWidthMM", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmWidthMM)); - paintDeviceMetric->Set(isolate, "PdmHeightMM", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmHeightMM)); - paintDeviceMetric->Set(isolate, "PdmNumColors", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmNumColors)); - paintDeviceMetric->Set(isolate, "PdmDepth", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmDepth)); - paintDeviceMetric->Set(isolate, "PdmDpiX", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmDpiX)); - paintDeviceMetric->Set(isolate, "PdmDpiY", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmDpiY)); - paintDeviceMetric->Set(isolate, "PdmPhysicalDpiX", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmPhysicalDpiX)); - paintDeviceMetric->Set(isolate, "PdmPhysicalDpiY", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmPhysicalDpiY)); - paintDeviceMetric->Set(isolate, "PdmDevicePixelRatio", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmDevicePixelRatio)); - paintDeviceMetric->Set(isolate, "PdmDevicePixelRatioScaled", v8::Int32::New(isolate, QPaintDevice::PaintDeviceMetric::PdmDevicePixelRatioScaled)); - tpl->Set(isolate, "PaintDeviceMetric", paintDeviceMetric); - } - { - tpl->PrototypeTemplate()->Set(isolate, "paintingActive", v8::FunctionTemplate::New(isolate, PaintingActive)); - tpl->PrototypeTemplate()->Set(isolate, "width", v8::FunctionTemplate::New(isolate, Width)); - tpl->PrototypeTemplate()->Set(isolate, "height", v8::FunctionTemplate::New(isolate, Height)); - tpl->PrototypeTemplate()->Set(isolate, "widthMM", v8::FunctionTemplate::New(isolate, WidthMM)); - tpl->PrototypeTemplate()->Set(isolate, "heightMM", v8::FunctionTemplate::New(isolate, HeightMM)); - tpl->PrototypeTemplate()->Set(isolate, "logicalDpiX", v8::FunctionTemplate::New(isolate, LogicalDpiX)); - tpl->PrototypeTemplate()->Set(isolate, "logicalDpiY", v8::FunctionTemplate::New(isolate, LogicalDpiY)); - tpl->PrototypeTemplate()->Set(isolate, "physicalDpiX", v8::FunctionTemplate::New(isolate, PhysicalDpiX)); - tpl->PrototypeTemplate()->Set(isolate, "physicalDpiY", v8::FunctionTemplate::New(isolate, PhysicalDpiY)); - tpl->PrototypeTemplate()->Set(isolate, "devicePixelRatio", v8::FunctionTemplate::New(isolate, DevicePixelRatio)); - tpl->PrototypeTemplate()->Set(isolate, "colorCount", v8::FunctionTemplate::New(isolate, ColorCount)); - tpl->PrototypeTemplate()->Set(isolate, "depth", v8::FunctionTemplate::New(isolate, Depth)); - tpl->PrototypeTemplate()->Set(isolate, "metric", v8::FunctionTemplate::New(isolate, Metric)); - } - } - - protected: - static void PaintingActive(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->paintingActive()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Width(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->width()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Height(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->height()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WidthMM(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->widthMM()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HeightMM(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->heightMM()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void LogicalDpiX(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->logicalDpiX()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void LogicalDpiY(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->logicalDpiY()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PhysicalDpiX(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->physicalDpiX()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PhysicalDpiY(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->physicalDpiY()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DevicePixelRatio(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Number::New(isolate, (*p)->devicePixelRatioF()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ColorCount(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->colorCount()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Depth(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->depth()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Metric(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto metric = static_cast(args[0]->Int32Value(context).FromJust()); - //auto result = v8::Int32::New(isolate, dynamic_cast*>(*p)->metric(metric)); - // args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/gui/qpixmap_implement.h b/v8/include/modules/gui/qpixmap_implement.h deleted file mode 100644 index 0b253ee..0000000 --- a/v8/include/modules/gui/qpixmap_implement.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "core/qsize_implement.h" -#include "core/qrect_implement.h" -#include "qcolor_implement.h" -#include "qimage_implement.h" -#include "qpixmap_p.h" -#include "qpixmap_wrapper.h" - -namespace shelllet { - namespace gui { - using namespace core; - class Pixmap : public QPixmapWrapper - { - using ReturnType = QPixmapPrivate; - using ReturnType2 = QPixmapPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - public: - - Pixmap(const v8::FunctionCallbackInfo& args) : QPixmapWrapper(*Private(args), args) {} - Pixmap(QPixmap* p, const v8::FunctionCallbackInfo& args) : QPixmapWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Pixmap(v8::Isolate* isolate, const v8::Local& tpl) :QPixmapWrapper(isolate, tpl) {} - Pixmap(v8::Isolate* isolate, const v8::Local& proto) :QPixmapWrapper(isolate, proto) {} - - static const char* Name() { return "Pixmap"; } - }; - } -} diff --git a/v8/include/modules/gui/qpixmap_p.h b/v8/include/modules/gui/qpixmap_p.h deleted file mode 100644 index 8955e67..0000000 --- a/v8/include/modules/gui/qpixmap_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include "qpaintdevice_p.h" - -namespace shelllet::gui { - template - class QPixmapPrivate : public QPaintDevicePrivate - { - public: - template - QPixmapPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QPaintDevicePrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/gui/qpixmap_wrapper.h b/v8/include/modules/gui/qpixmap_wrapper.h deleted file mode 100644 index 96a2df5..0000000 --- a/v8/include/modules/gui/qpixmap_wrapper.h +++ /dev/null @@ -1,651 +0,0 @@ -#pragma once -#include "qpaintdevice_wrapper.h" -namespace shelllet { - namespace gui { - template - class QPixmapWrapper : public QPaintDeviceWrapper - { - public: - template - QPixmapWrapper(QPixmapPrivate& d, const v8::FunctionCallbackInfo& args) - : QPaintDeviceWrapper(d, args) { - } - QPixmapWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QPaintDeviceWrapper(isolate, tpl) {} - QPixmapWrapper(v8::Isolate* isolate, const v8::Local& proto) : QPaintDeviceWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "cacheKey", v8::FunctionTemplate::New(isolate, CacheKey)); - tpl->PrototypeTemplate()->Set(isolate, "convertFromImage", v8::FunctionTemplate::New(isolate, ConvertFromImage)); - tpl->PrototypeTemplate()->Set(isolate, "copy", v8::FunctionTemplate::New(isolate, Copy)); - tpl->PrototypeTemplate()->Set(isolate, "createHeuristicMask", v8::FunctionTemplate::New(isolate, CreateHeuristicMask)); - tpl->PrototypeTemplate()->Set(isolate, "createMaskFromColor", v8::FunctionTemplate::New(isolate, CreateMaskFromColor)); - tpl->PrototypeTemplate()->Set(isolate, "detach", v8::FunctionTemplate::New(isolate, Detach)); - tpl->PrototypeTemplate()->Set(isolate, "devType", v8::FunctionTemplate::New(isolate, DevType)); - tpl->PrototypeTemplate()->Set(isolate, "fill", v8::FunctionTemplate::New(isolate, Fill)); - tpl->PrototypeTemplate()->Set(isolate, "hasAlpha", v8::FunctionTemplate::New(isolate, HasAlpha)); - tpl->PrototypeTemplate()->Set(isolate, "hasAlphaChannel", v8::FunctionTemplate::New(isolate, HasAlphaChannel)); - tpl->PrototypeTemplate()->Set(isolate, "isDetached", v8::FunctionTemplate::New(isolate, IsDetached)); - tpl->PrototypeTemplate()->Set(isolate, "isNull", v8::FunctionTemplate::New(isolate, IsNull)); - tpl->PrototypeTemplate()->Set(isolate, "isQBitmap", v8::FunctionTemplate::New(isolate, IsQBitmap)); - tpl->PrototypeTemplate()->Set(isolate, "load", v8::FunctionTemplate::New(isolate, Load)); - tpl->PrototypeTemplate()->Set(isolate, "loadFromData", v8::FunctionTemplate::New(isolate, LoadFromData)); - tpl->PrototypeTemplate()->Set(isolate, "mask", v8::FunctionTemplate::New(isolate, Mask)); - tpl->PrototypeTemplate()->Set(isolate, "rect", v8::FunctionTemplate::New(isolate, GetRect)); - tpl->PrototypeTemplate()->Set(isolate, "save", v8::FunctionTemplate::New(isolate, Save)); - tpl->PrototypeTemplate()->Set(isolate, "scaled", v8::FunctionTemplate::New(isolate, Scaled)); - tpl->PrototypeTemplate()->Set(isolate, "scaledToHeight", v8::FunctionTemplate::New(isolate, ScaledToHeight)); - tpl->PrototypeTemplate()->Set(isolate, "scaledToWidth", v8::FunctionTemplate::New(isolate, ScaledToWidth)); - tpl->PrototypeTemplate()->Set(isolate, "scroll", v8::FunctionTemplate::New(isolate, Scroll)); - tpl->PrototypeTemplate()->Set(isolate, "setDevicePixelRatio", v8::FunctionTemplate::New(isolate, SetDevicePixelRatio)); - tpl->PrototypeTemplate()->Set(isolate, "setMask", v8::FunctionTemplate::New(isolate, SetMask)); - tpl->PrototypeTemplate()->Set(isolate, "size", v8::FunctionTemplate::New(isolate, GetSize)); - tpl->PrototypeTemplate()->Set(isolate, "toImage", v8::FunctionTemplate::New(isolate, ToImage)); - tpl->PrototypeTemplate()->Set(isolate, "transformed", v8::FunctionTemplate::New(isolate, Transformed)); - { - tpl->Set(isolate, "defaultDepth", v8::FunctionTemplate::New(isolate, DefaultDepth)); - tpl->Set(isolate, "fromImage", v8::FunctionTemplate::New(isolate, FromImage)); - tpl->Set(isolate, "fromImageReader", v8::FunctionTemplate::New(isolate, FromImageReader)); - tpl->Set(isolate, "trueMatrix", v8::FunctionTemplate::New(isolate, TrueMatrix)); - } - } - - protected: - - static void CacheKey(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::BigInt::New(isolate, (*p)->cacheKey()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ConvertFromImage(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto* img = Image::From(args[0]); - - auto flags = std::invoke([&]() { - if (args[1]->IsInt32()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - - auto result = v8::Boolean::New(isolate, (*p)->convertFromImage(**img, flags)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Copy(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto rect = Rect::From(args[0]); - - auto result = Pixmap::New(isolate, v8::External::New(isolate, &(*p)->copy(**rect))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void CreateHeuristicMask(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - - /*auto clipTight = std::invoke([&]() { - if (args[0]->IsBoolean()) - return args[0]->BooleanValue(isolate); - return true; - }); - - auto result = v8::Int32::New(isolate, (*p)->createHeuristicMask(clipTight)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void CreateMaskFromColor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - v8::Local result; - /*if (args[0]->IsObject()) { - auto maskColor = Color::From(args[0]); - auto mode = std::invoke([&]() { - if (args[1]->IsNumber()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::MaskInColor); - }); - - result = v8::Int32::New(isolate, (*p)->createMaskFromColor(maskColor, mode)); - } - else { - auto color = static_cast(args[0]->Int32Value(context).FromJust()); - auto mode = std::invoke([&]() { - if (args[1]->IsNumber()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::MaskInColor); - }); - result = v8::Int32::New(isolate, (*p)->createMaskFromColor(color, mode)); - }*/ - - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Detach(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - (*p)->detach(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DevType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, (*p)->devType()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Fill(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - if (args[0]->IsNumber()) { - auto fillColor = args[0]->Int32Value(context).FromJust(); - (*p)->fill(fillColor); - } - else if (args[0]->IsObject()) { - auto* fillColor = Color::From(args[0]); - (*p)->fill(**fillColor); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HasAlpha(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->hasAlpha()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HasAlphaChannel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->hasAlphaChannel()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsDetached(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->isDetached()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsNull(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->isNull()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsQBitmap(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, (*p)->isQBitmap()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Load(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - // TODO: - auto fileName = ToString({ isolate, args[0] }); - auto format = ToString({ isolate, args[1] }); - - auto flags = std::invoke([&]() { - if (args[2]->IsObject()) - return static_cast(args[2]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - - auto result = v8::Boolean::New(isolate, (*p)->load(fileName, format, flags)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void LoadFromData(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto data = ToArray(args[0]); - auto format = ToString({ isolate, args[1] }); - - auto flags = std::invoke([&]() { - if (args[2]->IsNumber()) - return static_cast(args[2]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - - auto result = v8::Boolean::New(isolate, (*p)->loadFromData(QByteArray::fromRawData(&data[0], data.size()), format, flags)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void Mask(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /*auto result = v8::Int32::New(isolate, (*p)->mask()); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetRect(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Rect::New(isolate, v8::External::New(isolate, &(*p)->rect())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Save(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - QString fileName; - if (args[0]->IsString()) { - fileName = QString::fromStdWString(ToWString({ isolate, args[0] })); - } - - auto format = ToString({ isolate, args[1] }); - auto quality = std::invoke([&]() { - if (args[2]->IsInt32()) - return args[2]->Int32Value(context).FromJust(); - return -1; - }); - - auto result = v8::Boolean::New(isolate, (*p)->save(fileName, format, quality)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Scaled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - int index = 0; - auto s = Size::From(args[0]); - if (!s) { - throw std::invalid_argument("! require `Size` value."); - } - - auto aspectMode = std::invoke([&]() { - if (args[index]->IsObject()) - return static_cast(args[index]->Int32Value(context).FromJust()); - return static_cast(Qt::IgnoreAspectRatio); - }); - index++; - auto mode = std::invoke([&]() { - if (args[index]->IsObject()) - return static_cast(args[index]->Int32Value(context).FromJust()); - return static_cast(Qt::FastTransformation); - }); - - auto result = Pixmap::New(isolate, v8::External::New(isolate, &(*p)->scaled(**s, aspectMode, mode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ScaledToHeight(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto h = args[0]->Int32Value(context).FromJust(); - - auto mode = std::invoke([&]() { - if (args[1]->IsObject()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::FastTransformation); - }); - - auto result = Pixmap::New(isolate, v8::External::New(isolate, &(*p)->scaledToHeight(h, mode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ScaledToWidth(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto w = args[0]->Int32Value(context).FromJust(); - - auto mode = std::invoke([&]() { - if (args[1]->IsNumber()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::FastTransformation); - }); - - auto result = Pixmap::New(isolate, v8::External::New(isolate, &(*p)->scaledToWidth(w, mode))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Scroll(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto dx = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto dy = std::invoke([&]() { - if (!args[1]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [1]."); - return args[1]->Int32Value(context).FromJust(); - }); - - auto rect = Rect::From(args[2]); - - (*p)->scroll(dx, dy, **rect, nullptr); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetDevicePixelRatio(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto scaleFactor = args[0]->NumberValue(context).FromJust(); - - (*p)->setDevicePixelRatio(scaleFactor); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void SetMask(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - /* auto QBitmap = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - (*p)->setMask(QBitmap);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void GetSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Size::New(isolate, v8::External::New(isolate, &(*p)->size())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToImage(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) { - return; - } - auto result = Image::New(isolate, v8::External::New(isolate, &(*p)->toImage())); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void Transformed(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - return; - /* } - auto QTransform = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto mode = std::invoke([&]() { - if (args[1]->IsObject()) - return args[1]->Int32Value(context).FromJust(); - return Qt::FastTransformation; - }); - - auto result = v8::Int32::New(isolate, (*p)->transformed(QTransform, mode)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DefaultDepth(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto result = v8::Int32::New(isolate, QPixmap::defaultDepth()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromImage(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto image = Image::From(args[0]); - - auto flags = std::invoke([&]() { - if (args[1]->IsObject()) - return static_cast(args[1]->Int32Value(context).FromJust()); - return static_cast(Qt::AutoColor); - }); - - auto result = Pixmap::New(isolate, v8::External::New(isolate, &QPixmap::fromImage(**image, flags))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void FromImageReader(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - /*auto* imageReader = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto flags = std::invoke([&]() { - if (args[1]->IsObject()) - return args[1]->Int32Value(context).FromJust(); - return Qt::AutoColor; - }); - - auto result = v8::Int32::New(isolate, (*p)->fromImageReader(*imageReader, flags)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void TrueMatrix(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - /*auto m = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto w = std::invoke([&]() { - if (!args[1]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [1]."); - return args[1]->Int32Value(context).FromJust(); - }); - - auto h = std::invoke([&]() { - if (!args[2]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [2]."); - return args[2]->Int32Value(context).FromJust(); - }); - - auto result = v8::Int32::New(isolate, (*p)->trueMatrix(m, w, h)); - args.GetReturnValue().Set(result);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/gui/qwindow_p.h b/v8/include/modules/gui/qwindow_p.h deleted file mode 100644 index df73fed..0000000 --- a/v8/include/modules/gui/qwindow_p.h +++ /dev/null @@ -1,137 +0,0 @@ -#pragma once -#include "qobject_p.h" -#include - -namespace shelllet::gui { - template - class QWindowPrivate : public core::QObjectPrivate - { - public: - template - QWindowPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - template - QWindowPrivate(T* d, v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(d, std::forward(args)...) { - } - QObject* focusObject() const override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->focusObject(); - } - return __super::focusObject(); - } - - void exposeEvent(QExposeEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->exposeEvent(e); - } - return __super::exposeEvent(e); - } - - void resizeEvent(QResizeEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->resizeEvent(e); - } - return __super::resizeEvent(e); - } - - void moveEvent(QMoveEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->moveEvent(e); - } - return __super::moveEvent(e); - } - - void focusInEvent(QFocusEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->focusInEvent(e); - } - return __super::focusInEvent(e); - } - - void focusOutEvent(QFocusEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->focusOutEvent(e); - } - return __super::focusOutEvent(e); - } - - void showEvent(QShowEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->showEvent(e); - } - return __super::showEvent(e); - } - - void hideEvent(QHideEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->hideEvent(e); - } - return __super::hideEvent(e); - } - - void keyPressEvent(QKeyEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->keyPressEvent(e); - } - return __super::keyPressEvent(e); - } - - void keyReleaseEvent(QKeyEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->keyReleaseEvent(e); - } - return __super::keyReleaseEvent(e); - } - - void mousePressEvent(QMouseEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->mousePressEvent(e); - } - return __super::mousePressEvent(e); - } - - void mouseReleaseEvent(QMouseEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->mouseReleaseEvent(e); - } - return __super::mouseReleaseEvent(e); - } - - void mouseDoubleClickEvent(QMouseEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->mouseDoubleClickEvent(e); - } - return __super::mouseDoubleClickEvent(e); - } - - void mouseMoveEvent(QMouseEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->mouseMoveEvent(e); - } - return __super::mouseMoveEvent(e); - } - - void wheelEvent(QWheelEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->wheelEvent(e); - } - return __super::wheelEvent(e); - } - - void touchEvent(QTouchEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->touchEvent(e); - } - return __super::touchEvent(e); - } - - void tabletEvent(QTabletEvent* e) override { - if (q_func()->hasOwnProperty(__FUNCTION__)) { - return q_func()->tabletEvent(e); - } - return __super::tabletEvent(e); - } - - - }; -} diff --git a/v8/include/modules/gui/qwindow_wrapper.h b/v8/include/modules/gui/qwindow_wrapper.h deleted file mode 100644 index b7eebdc..0000000 --- a/v8/include/modules/gui/qwindow_wrapper.h +++ /dev/null @@ -1,2490 +0,0 @@ -#pragma once -#include "qobject_wrapper.h" -namespace shelllet { - namespace gui { - template class QWindowPrivate; - template - class QWindowWrapper : public core::QObjectWrapper - { - public: - - template - QWindowWrapper(QWindowPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - QWindowWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QWindowWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "setSurfaceType", v8::FunctionTemplate::New(isolate, SetSurfaceType)); - tpl->PrototypeTemplate()->Set(isolate, "surfaceType", v8::FunctionTemplate::New(isolate, SurfaceType)); - tpl->PrototypeTemplate()->Set(isolate, "create", v8::FunctionTemplate::New(isolate, Create)); - tpl->PrototypeTemplate()->Set(isolate, "winId", v8::FunctionTemplate::New(isolate, WinId)); - tpl->PrototypeTemplate()->Set(isolate, "parent", v8::FunctionTemplate::New(isolate, Parent)); - tpl->PrototypeTemplate()->Set(isolate, "setParent", v8::FunctionTemplate::New(isolate, SetParent)); - tpl->PrototypeTemplate()->Set(isolate, "isTopLevel", v8::FunctionTemplate::New(isolate, IsTopLevel)); - tpl->PrototypeTemplate()->Set(isolate, "isModal", v8::FunctionTemplate::New(isolate, IsModal)); - tpl->PrototypeTemplate()->Set(isolate, "setFormat", v8::FunctionTemplate::New(isolate, SetFormat)); - tpl->PrototypeTemplate()->Set(isolate, "format", v8::FunctionTemplate::New(isolate, Format)); - tpl->PrototypeTemplate()->Set(isolate, "requestedFormat", v8::FunctionTemplate::New(isolate, RequestedFormat)); - tpl->PrototypeTemplate()->Set(isolate, "setFlag", v8::FunctionTemplate::New(isolate, SetFlag)); - tpl->PrototypeTemplate()->Set(isolate, "type", v8::FunctionTemplate::New(isolate, Type)); - tpl->PrototypeTemplate()->Set(isolate, "setMask", v8::FunctionTemplate::New(isolate, SetMask)); - tpl->PrototypeTemplate()->Set(isolate, "mask", v8::FunctionTemplate::New(isolate, Mask)); - tpl->PrototypeTemplate()->Set(isolate, "contentOrientation", v8::FunctionTemplate::New(isolate, ContentOrientation)); - tpl->PrototypeTemplate()->Set(isolate, "devicePixelRatio", v8::FunctionTemplate::New(isolate, DevicePixelRatio)); - tpl->PrototypeTemplate()->Set(isolate, "windowState", v8::FunctionTemplate::New(isolate, WindowState)); - tpl->PrototypeTemplate()->Set(isolate, "windowStates", v8::FunctionTemplate::New(isolate, WindowStates)); - tpl->PrototypeTemplate()->Set(isolate, "setWindowState", v8::FunctionTemplate::New(isolate, SetWindowState)); - tpl->PrototypeTemplate()->Set(isolate, "setWindowStates", v8::FunctionTemplate::New(isolate, SetWindowStates)); - tpl->PrototypeTemplate()->Set(isolate, "setTransientParent", v8::FunctionTemplate::New(isolate, SetTransientParent)); - tpl->PrototypeTemplate()->Set(isolate, "transientParent", v8::FunctionTemplate::New(isolate, TransientParent)); - tpl->PrototypeTemplate()->Set(isolate, "isAncestorOf", v8::FunctionTemplate::New(isolate, IsAncestorOf)); - tpl->PrototypeTemplate()->Set(isolate, "isExposed", v8::FunctionTemplate::New(isolate, IsExposed)); - tpl->PrototypeTemplate()->Set(isolate, "baseSize", v8::FunctionTemplate::New(isolate, BaseSize)); - tpl->PrototypeTemplate()->Set(isolate, "sizeIncrement", v8::FunctionTemplate::New(isolate, SizeIncrement)); - tpl->PrototypeTemplate()->Set(isolate, "setBaseSize", v8::FunctionTemplate::New(isolate, SetBaseSize)); - tpl->PrototypeTemplate()->Set(isolate, "setSizeIncrement", v8::FunctionTemplate::New(isolate, SetSizeIncrement)); - tpl->PrototypeTemplate()->Set(isolate, "geometry", v8::FunctionTemplate::New(isolate, Geometry)); - tpl->PrototypeTemplate()->Set(isolate, "frameMargins", v8::FunctionTemplate::New(isolate, FrameMargins)); - tpl->PrototypeTemplate()->Set(isolate, "frameGeometry", v8::FunctionTemplate::New(isolate, FrameGeometry)); - tpl->PrototypeTemplate()->Set(isolate, "framePosition", v8::FunctionTemplate::New(isolate, FramePosition)); - tpl->PrototypeTemplate()->Set(isolate, "setFramePosition", v8::FunctionTemplate::New(isolate, SetFramePosition)); - tpl->PrototypeTemplate()->Set(isolate, "position", v8::FunctionTemplate::New(isolate, Position)); - tpl->PrototypeTemplate()->Set(isolate, "setPosition", v8::FunctionTemplate::New(isolate, SetPosition)); - tpl->PrototypeTemplate()->Set(isolate, "resize", v8::FunctionTemplate::New(isolate, Resize)); - tpl->PrototypeTemplate()->Set(isolate, "setFilePath", v8::FunctionTemplate::New(isolate, SetFilePath)); - tpl->PrototypeTemplate()->Set(isolate, "filePath", v8::FunctionTemplate::New(isolate, FilePath)); - tpl->PrototypeTemplate()->Set(isolate, "setIcon", v8::FunctionTemplate::New(isolate, SetIcon)); - tpl->PrototypeTemplate()->Set(isolate, "icon", v8::FunctionTemplate::New(isolate, Icon)); - tpl->PrototypeTemplate()->Set(isolate, "destroy", v8::FunctionTemplate::New(isolate, Destroy)); - tpl->PrototypeTemplate()->Set(isolate, "setKeyboardGrabEnabled", v8::FunctionTemplate::New(isolate, SetKeyboardGrabEnabled)); - tpl->PrototypeTemplate()->Set(isolate, "setMouseGrabEnabled", v8::FunctionTemplate::New(isolate, SetMouseGrabEnabled)); - tpl->PrototypeTemplate()->Set(isolate, "screen", v8::FunctionTemplate::New(isolate, Screen)); - tpl->PrototypeTemplate()->Set(isolate, "setScreen", v8::FunctionTemplate::New(isolate, SetScreen)); - tpl->PrototypeTemplate()->Set(isolate, "mapToGlobal", v8::FunctionTemplate::New(isolate, MapToGlobal)); - tpl->PrototypeTemplate()->Set(isolate, "mapFromGlobal", v8::FunctionTemplate::New(isolate, MapFromGlobal)); - tpl->PrototypeTemplate()->Set(isolate, "cursor", v8::FunctionTemplate::New(isolate, Cursor)); - tpl->PrototypeTemplate()->Set(isolate, "setCursor", v8::FunctionTemplate::New(isolate, SetCursor)); - tpl->PrototypeTemplate()->Set(isolate, "unsetCursor", v8::FunctionTemplate::New(isolate, UnsetCursor)); - tpl->PrototypeTemplate()->Set(isolate, "setVulkanInstance", v8::FunctionTemplate::New(isolate, SetVulkanInstance)); - tpl->PrototypeTemplate()->Set(isolate, "vulkanInstance", v8::FunctionTemplate::New(isolate, VulkanInstance)); - tpl->PrototypeTemplate()->Set(isolate, "show", v8::FunctionTemplate::New(isolate, Show)); - tpl->PrototypeTemplate()->Set(isolate, "hide", v8::FunctionTemplate::New(isolate, Hide)); - tpl->PrototypeTemplate()->Set(isolate, "showMinimized", v8::FunctionTemplate::New(isolate, ShowMinimized)); - tpl->PrototypeTemplate()->Set(isolate, "showMaximized", v8::FunctionTemplate::New(isolate, ShowMaximized)); - tpl->PrototypeTemplate()->Set(isolate, "showFullScreen", v8::FunctionTemplate::New(isolate, ShowFullScreen)); - tpl->PrototypeTemplate()->Set(isolate, "showNormal", v8::FunctionTemplate::New(isolate, ShowNormal)); - tpl->PrototypeTemplate()->Set(isolate, "close", v8::FunctionTemplate::New(isolate, Close)); - tpl->PrototypeTemplate()->Set(isolate, "raise", v8::FunctionTemplate::New(isolate, Raise)); - tpl->PrototypeTemplate()->Set(isolate, "lower", v8::FunctionTemplate::New(isolate, Lower)); - tpl->PrototypeTemplate()->Set(isolate, "setGeometry", v8::FunctionTemplate::New(isolate, SetGeometry)); - tpl->PrototypeTemplate()->Set(isolate, "reportContentOrientationChange", v8::FunctionTemplate::New(isolate, ReportContentOrientationChange)); - - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "isVisible"), IsVisible, SetVisible); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "visibility"), Visibility, SetVisibility); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "modality"), Modality, SetModality); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "flags"), Flags, SetFlags); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "title"), Title, SetTitle); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "isActive"), IsActive, SetActive); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "minimumWidth"), MinimumWidth, SetMinimumWidth); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "minimumHeight"), MinimumHeight, SetMinimumHeight); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "maximumWidth"), MaximumWidth, SetMaximumWidth); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "maximumHeight"), MaximumHeight, SetMaximumHeight); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "width"), Width, SetWidth); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "height"), Height, SetHeight); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "x"), X, SetX); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "y"), Y, SetY); - - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "screenChanged"), nullptr, ScreenChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "modalityChanged"), nullptr, ModalityChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "windowStateChanged"), nullptr, WindowStateChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "xChanged"), nullptr, XChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "yChanged"), nullptr, YChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "widthChanged"), nullptr, WidthChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "heightChanged"), nullptr, HeightChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "minimumWidthChanged"), nullptr, MinimumWidthChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "minimumHeightChanged"), nullptr, MinimumHeightChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "maximumWidthChanged"), nullptr, MaximumWidthChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "maximumHeightChanged"), nullptr, MaximumHeightChanged); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "visibleChanged"), nullptr, VisibleChanged); - { - v8::Local visibility = v8::ObjectTemplate::New(isolate); - visibility->Set(isolate, "Hidden", v8::Int32::New(isolate, QWindow::Visibility::Hidden)); - visibility->Set(isolate, "AutomaticVisibility", v8::Int32::New(isolate, QWindow::Visibility::AutomaticVisibility)); - visibility->Set(isolate, "Windowed", v8::Int32::New(isolate, QWindow::Visibility::Windowed)); - visibility->Set(isolate, "Minimized", v8::Int32::New(isolate, QWindow::Visibility::Minimized)); - visibility->Set(isolate, "Maximized", v8::Int32::New(isolate, QWindow::Visibility::Maximized)); - visibility->Set(isolate, "FullScreen", v8::Int32::New(isolate, QWindow::Visibility::FullScreen)); - tpl->Set(isolate, "Visibility", visibility); - - v8::Local ancestorMode = v8::ObjectTemplate::New(isolate); - ancestorMode->Set(isolate, "ExcludeTransients", v8::Int32::New(isolate, QWindow::AncestorMode::ExcludeTransients)); - ancestorMode->Set(isolate, "IncludeTransients", v8::Int32::New(isolate, QWindow::AncestorMode::IncludeTransients)); - tpl->Set(isolate, "AncestorMode", ancestorMode); - tpl->Set(isolate, "fromWinId", v8::FunctionTemplate::New(isolate, FromWinId)); - } - } - protected: - QObject* focusObject() const - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local result = call(isolate, context, "focusObject", 0, {}); - if (!result->IsObject()) { - throw std::logic_error("!return type error."); - } - auto* p = convert::Object::UnWrap(result->ToObject(context).ToLocalChecked()); - if (p) - return **p; - return nullptr; - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void exposeEvent(QExposeEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "ExposeEvent", std::size(argv), argv); - }) }; - call(isolate, context, "exposeEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void resizeEvent(QResizeEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "ResizeEvent", std::size(argv), argv); - }) }; - call(isolate, context, "resizeEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void moveEvent(QMoveEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "MoveEvent", std::size(argv), argv); - }) }; - call(isolate, context, "QMoveEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void focusInEvent(QFocusEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "FocusEvent", std::size(argv), argv); - }) }; - call(isolate, context, "focusInEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void focusOutEvent(QFocusEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "FocusEvent", std::size(argv), argv); - }) }; - call(isolate, context, "focusOutEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void showEvent(QShowEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "ShowEvent", std::size(argv), argv); - }) }; - call(isolate, context, "showEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void hideEvent(QHideEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "HideEvent", std::size(argv), argv); - }) }; - call(isolate, context, "hideEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void keyPressEvent(QKeyEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "KeyEvent", std::size(argv), argv); - }) }; - call(isolate, context, "keyPressEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void keyReleaseEvent(QKeyEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "KeyEvent", std::size(argv), argv); - }) }; - call(isolate, context, "keyReleaseEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void mousePressEvent(QMouseEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "MouseEvent", std::size(argv), argv); - }) }; - call(isolate, context, "mousePressEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void mouseReleaseEvent(QMouseEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "MouseEvent", std::size(argv), argv); - }) }; - call(isolate, context, "mouseReleaseEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void mouseDoubleClickEvent(QMouseEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "MouseEvent", std::size(argv), argv); - }) }; - call(isolate, context, "mouseDoubleClickEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void mouseMoveEvent(QMouseEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "MouseEvent", std::size(argv), argv); - }) }; - call(isolate, context, "mouseMoveEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void wheelEvent(QWheelEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "WheelEvent", std::size(argv), argv); - }) }; - call(isolate, context, "wheelEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void touchEvent(QTouchEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "TouchEvent", std::size(argv), argv); - }) }; - call(isolate, context, "touchEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - void tabletEvent(QTabletEvent* e) - { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - { - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, e) }; - return convert::Object::Wrap(isolate, context, "TabletEvent", std::size(argv), argv); - }) }; - call(isolate, context, "tabletEvent", std::size(argv), argv); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - protected: - static void SetSurfaceType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto surfaceType = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QWindow::setSurfaceType>(std::move(surfaceType)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SurfaceType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::surfaceType>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsVisible(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::isVisible>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetVisible(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto visible = std::invoke([&]() { - if (!value->IsBoolean()) - throw std::invalid_argument("!`Boolean` required."); - return value->BooleanValue(isolate); - }); - p->d_func()->invoke<&QWindow::setVisible>(std::move(visible)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Visibility(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::visibility>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetVisibility(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto visibility = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Object` required."); - return static_cast(value->Int32Value(context).FromJust()); - }); - p->d_func()->invoke<&QWindow::setVisibility>(std::move(visibility)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Create(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::create>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WinId(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::winId>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Parent(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - QWindow* w = nullptr; - - if (args.Length() > 0) { - auto mode = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - w = p->d_func()->invoke(&QWindow::parent)>(std::move(mode)); - } - else { - w = p->d_func()->invoke(&QWindow::parent)>(); - } - - v8::Localargv[] = { v8::External::New(isolate, w) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Window", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetParent(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - - p->d_func()->setParent(**Window::FromValue(isolate, args[0])); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsTopLevel(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::isTopLevel>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsModal(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::isModal>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Modality(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::modality>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetModality(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto modality = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Object` required."); - return static_cast(value->Int32Value(context).FromJust()); - }); - p->d_func()->invoke<&QWindow::setModality>(std::move(modality)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void SetFormat(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto format = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - //p->d_func()->invoke2<&QWindow::setFormat>( format); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void Format(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void RequestedFormat(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Flags(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::flags>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetFlags(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto flags = std::invoke([&]() { - if (!value->IsObject()) - throw std::invalid_argument("!`Object` required."); - return static_cast(value->Int32Value(context).FromJust()); - }); - p->d_func()->invoke<&QWindow::setFlags>(std::move(flags)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Flags(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::flags>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetFlag(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto flag = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Int32` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - auto on = std::invoke([&]() { - if (args[1]->IsBoolean()) - return args[1]->BooleanValue(isolate); - return true; - }); - - p->d_func()->setFlag(flag, on); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Type(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::type>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Title(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = convert::String::New(isolate, p->d_func()->title()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetTitle(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto title = std::invoke([&]() { - if (!value->IsString()) - throw std::invalid_argument("!`String` required."); - return convert::String::To(isolate, value); - }); - p->d_func()->invoke<&QWindow::setTitle>(std::move(title)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetOpacity(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto opacity = std::invoke([&]() { - if (!value->IsNumber()) - throw std::invalid_argument("!`Object` required."); - return value->NumberValue(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setOpacity>(std::move(opacity)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Opacity(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Number::New(isolate, p->d_func()->invoke<&QWindow::opacity>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO: - static void SetMask(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto region = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - p->d_func()->setMask(*region);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void Mask(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - - auto region = p->d_func()->invoke<&QWindow::mask>(); - v8::Local argv[] = { v8::External::New(isolate, ®ion) }; - - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Region", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsActive(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::isActive>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void SetActive(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto title = std::invoke([&]() { - if (!value->IsString()) - throw std::invalid_argument("!`String` required."); - return convert::String::To(isolate, value); - }); - p->d_func()->invoke<&QWindow::setTitle>(std::move(title)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ContentOrientation(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::contentOrientation>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DevicePixelRatio(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Number::New(isolate, p->d_func()->invoke<&QWindow::devicePixelRatio>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WindowState(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::windowState>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WindowStates(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::windowStates>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWindowState(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto state = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QWindow::setWindowState>(std::move(state)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWindowStates(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto states = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QWindow::setWindowStates>(std::move(states)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetTransientParent(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - - p->d_func()->setTransientParent(**Window::FromValue(isolate, args[0])); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void TransientParent(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - QWindow* w = p->d_func()->invoke<&QWindow::transientParent>(); - - v8::Localargv[] = { v8::External::New(isolate, w) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Window", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsAncestorOf(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto child = Window::FromValue(isolate, args[0]); - - auto mode = QWindow::IncludeTransients; - if (args[1]->IsNumber()) - mode = static_cast(args[1]->Int32Value(context).FromJust()); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::isAncestorOf>(**child, mode)); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsExposed(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::isExposed>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MinimumWidth(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::minimumWidth>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetMinimumWidth(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto minimumWidth = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setMinimumWidth>(std::move(minimumWidth)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MinimumHeight(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::minimumHeight>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetMinimumHeight(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto minimumHeight = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setMinimumHeight>(std::move(minimumHeight)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MaximumWidth(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::maximumWidth>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetMaximumWidth(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto maximumWidth = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setMaximumWidth>(std::move(maximumWidth)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MaximumHeight(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::maximumHeight>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetMaximumHeight(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto maximumHeight = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setMaximumHeight>(std::move(maximumHeight)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MinimumSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto size = p->d_func()->invoke<&QWindow::minimumSize>(); - v8::Local argv[] = { v8::External::New(isolate, &size) }; - - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Size", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MaximumSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto size = p->d_func()->invoke<&QWindow::maximumSize>(); - v8::Local argv[] = { v8::External::New(isolate, &size) }; - - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Size", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BaseSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto size = p->d_func()->invoke<&QWindow::baseSize>(); - v8::Local argv[] = { v8::External::New(isolate, &size) }; - - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Size", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SizeIncrement(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto size = p->d_func()->invoke<&QWindow::sizeIncrement>(); - v8::Local argv[] = { v8::External::New(isolate, &size) }; - - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Size", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void SetMinimumSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto size = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->setMinimumSize(*size);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void SetMaximumSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /* auto size = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->setMaximumSize(*size);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void SetBaseSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /* auto size = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->setBaseSize(*size);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO: - static void SetSizeIncrement(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto size = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->setSizeIncrement(*size);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Geometry(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto rect = p->d_func()->invoke<&QWindow::geometry>(); - v8::Local argv[] = { v8::External::New(isolate, &rect) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Rect", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO - static void FrameMargins(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - - auto margins = p->d_func()->invoke<&QWindow::frameMargins>(); - v8::Local argv[] = { v8::External::New(isolate, &margins) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Margins", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FrameGeometry(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto rect = p->d_func()->invoke<&QWindow::frameGeometry>(); - v8::Local argv[] = { v8::External::New(isolate, &rect) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Rect", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FramePosition(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto point = p->d_func()->invoke<&QWindow::framePosition>(); - v8::Local argv[] = { v8::External::New(isolate, &point) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Point", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetFramePosition(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto pt = Point::FromValue(isolate, args[0]); - p->d_func()->setFramePosition((***pt).toPoint()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Width(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::width>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetWidth(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto width = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setWidth>(std::move(width)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Height(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::height>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetHeight(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto height = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setHeight>(std::move(height)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void X(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::x>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetX(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto x = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setX>(std::move(x)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Y(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (!p) { - return; - } - auto result = v8::Int32::New(isolate, p->d_func()->invoke<&QWindow::y>()); - info.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetY(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (!p) { - return; - } - auto y = std::invoke([&]() { - if (!value->IsInt32()) - throw std::invalid_argument("!`Int32` required."); - return value->Int32Value(context).FromJust(); - }); - p->d_func()->invoke<&QWindow::setY>(std::move(y)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Position(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto position = p->d_func()->invoke<&QWindow::position>(); - v8::Local argv[] = { v8::External::New(isolate, &position) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Point", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetPosition(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto pt = Point::FromValue(isolate, args[0]); - p->d_func()->setPosition((***pt).toPoint()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO - static void Resize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto newSize = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->resize(*newSize);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetFilePath(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - QString filePath = std::invoke([&]() { - if (!args[0]->IsString()) - throw std::invalid_argument("!`String` required at [0]."); - return convert::String::To(isolate, args[0]); - }); - - p->d_func()->invoke<&QWindow::setFilePath>(filePath); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FilePath(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = convert::String::New(isolate, p->d_func()->invoke<&QWindow::filePath>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO - static void SetIcon(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto icon = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->setIcon(*icon);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO - static void Icon(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - - auto icon = p->d_func()->invoke<&QWindow::icon>(); - v8::Local argv[] = { v8::External::New(isolate, &icon) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Icon", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Destroy(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::destroy>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetKeyboardGrabEnabled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto grab = std::invoke([&]() { - if (!args[0]->IsBoolean()) - throw std::invalid_argument("!`Boolean` required at [0]."); - return args[0]->BooleanValue(isolate); - }); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::setKeyboardGrabEnabled>(std::move(grab))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetMouseGrabEnabled(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto grab = std::invoke([&]() { - if (!args[0]->IsBoolean()) - throw std::invalid_argument("!`Boolean` required at [0]."); - return args[0]->BooleanValue(isolate); - }); - - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::setMouseGrabEnabled>(std::move(grab))); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // TODO - static void Screen(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto screen = p->d_func()->invoke<&QWindow::screen>(); - v8::Local argv[] = { v8::External::New(isolate, &screen) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Screen", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO - static void SetScreen(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto* screen = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->invoke2<&QWindow::setScreen>( screen);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MapToGlobal(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto pt = Point::FromValue(isolate, args[0]); - auto point = p->d_func()->mapToGlobal((***pt).toPoint()); - v8::Local argv[] = { v8::External::New(isolate, &point) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Point", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MapFromGlobal(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto param = Point::FromValue(isolate, args[0]); - auto point = p->d_func()->mapFromGlobal((***param).toPoint()); - v8::Local argv[] = { v8::External::New(isolate, &point) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Point", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - //TODO - static void Cursor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto cursor = p->d_func()->invoke<&QWindow::cursor>(); - v8::Local argv[] = { v8::External::New(isolate, &cursor) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Cursor", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO - static void SetCursor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto cursor = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->setCursor(*cursor);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void UnsetCursor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::unsetCursor>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetVulkanInstance(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto* instance = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->invoke2<&QWindow::setVulkanInstance>( instance);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void VulkanInstance(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - //auto result = v8::Int32::New(isolate, p->d_func()->invoke2<&QWindow::vulkanInstance>()); - //args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Show(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::show>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Hide(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::hide>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ShowMinimized(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::showMinimized>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ShowMaximized(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::showMaximized>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ShowFullScreen(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::showFullScreen>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ShowNormal(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::showNormal>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Close(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto result = v8::Boolean::New(isolate, p->d_func()->invoke<&QWindow::close>()); - args.GetReturnValue().Set(result); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Raise(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::raise>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Lower(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - p->d_func()->invoke<&QWindow::lower>(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - // TODO - static void SetGeometry(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - /*auto rect = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return convert::Object::UnWrap(args[0]); - }); - - p->d_func()->setGeometry(*rect);*/ - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReportContentOrientationChange(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) { - return; - } - auto orientation = std::invoke([&]() { - if (!args[0]->IsInt32()) - throw std::invalid_argument("!`Object` required at [0]."); - return static_cast(args[0]->Int32Value(context).FromJust()); - }); - - p->d_func()->invoke<&QWindow::reportContentOrientationChange>(std::move(orientation)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FromWinId(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto id = std::invoke([&]() { - if (!args[0]->IsObject()) - throw std::invalid_argument("!`Object` required at [0]."); - return args[0]->Int32Value(context).FromJust(); - }); - - auto* w = QWindow::fromWinId(id); - v8::Local argv[] = { v8::External::New(isolate, w) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Window", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ContentOrientationChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::contentOrientationChanged, [weakPersistent](Qt::ScreenOrientation orientation) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, orientation) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::contentOrientationChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FocusObjectChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::focusObjectChanged, [weakPersistent](QObject* object) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = {v8::External::New(isolate, object) }; - return convert::Object::Wrap(isolate, context, "Object", std::size(argv), argv); - }) - }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::focusObjectChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HeightChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::heightChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::heightChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WidthChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::widthChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::widthChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void XChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::xChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::xChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void YChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::yChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::yChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MaximumHeightChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::maximumHeightChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::maximumHeightChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MaximumWidthChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::maximumWidthChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::maximumWidthChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MinimumHeightChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::minimumHeightChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::minimumHeightChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MinimumWidthChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::minimumWidthChanged, [weakPersistent](int arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::minimumWidthChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ModalityChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::modalityChanged, [weakPersistent](Qt::WindowModality modality) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, modality) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::modalityChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ScreenChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::screenChanged, [weakPersistent](QScreen* screen) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { std::invoke([&]() { - v8::Local argv[] = { v8::External::New(isolate, screen) }; - return convert::Object::Wrap(isolate, context, "Screen", std::size(argv), argv); - }) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::screenChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void VisibleChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::visibleChanged, [weakPersistent](bool arg) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Boolean::New(isolate, arg) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::visibleChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WindowStateChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::windowStateChanged, [weakPersistent](Qt::WindowState windowState) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, windowState) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::windowStateChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WindowTitleChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QWindow::windowTitleChanged, [weakPersistent](const QString& title) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { convert::String::New(isolate, title) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - qCCritical(shelllet_window) << tryCatch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QWindow::windowTitleChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/gui/window_implement.h b/v8/include/modules/gui/window_implement.h deleted file mode 100644 index b0ebb10..0000000 --- a/v8/include/modules/gui/window_implement.h +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once -#include -#include -#include "gui_module.h" -#include "qwindow_p.h" -#include "qwindow_wrapper.h" -#include "qpoint_implement.h" -#include "qobject_implement.h" -namespace shelllet { - namespace gui { - class Window : public QWindowWrapper - { - using ReturnType = QImagePrivate; - using ReturnType2 = QImagePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType; - } - public: - Window(const v8::FunctionCallbackInfo& args) : QWindowWrapper(*Private(args), args) {} - Window(v8::Isolate* isolate, const v8::Local& tpl) :QWindowWrapper(isolate, tpl) {} - Window(v8::Isolate* isolate, const v8::Local& proto) :QWindowWrapper(isolate, proto) {} - - static const char* Name() { return "Window"; } - - public: - }; - } -} diff --git a/v8/include/modules/network/initialize.h b/v8/include/modules/network/initialize.h deleted file mode 100644 index 0aef754..0000000 --- a/v8/include/modules/network/initialize.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once -#include "framework.h" - -namespace shelllet { - namespace qtnetwork { - void initialize(v8::Isolate* isolate, const v8::Local& proto) { - using namespace shelllet::core; - - } - - } -} \ No newline at end of file diff --git a/v8/include/modules/network/qabstractsocket_implement.h b/v8/include/modules/network/qabstractsocket_implement.h deleted file mode 100644 index 81f4df1..0000000 --- a/v8/include/modules/network/qabstractsocket_implement.h +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "network_module.h" -#include "qabstractsocket_p.h" -#include "qabstractsocket_wrapper.h" - -namespace shelllet { - namespace network { - class AbstractSocket : public QAbstractSocketWrapper - { - public: - AbstractSocket(const v8::FunctionCallbackInfo& args); - AbstractSocket(v8::Isolate* isolate, const v8::Local& tpl); - - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qabstractsocket_p.h b/v8/include/modules/network/qabstractsocket_p.h deleted file mode 100644 index dd58801..0000000 --- a/v8/include/modules/network/qabstractsocket_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include "qiodevice_p.h" - -namespace shelllet::network { - template - class QAbstractSocketPrivate : public core::QIODevicePrivate - { - public: - template - QAbstractSocketPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QIODevicePrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/network/qabstractsocket_wrapper.h b/v8/include/modules/network/qabstractsocket_wrapper.h deleted file mode 100644 index 3022a60..0000000 --- a/v8/include/modules/network/qabstractsocket_wrapper.h +++ /dev/null @@ -1,862 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include -#include "qiodevice_wrapper.h" -#include "qhostaddress_implement.h" -namespace shelllet { - namespace network { - template class QAbstractSocketPrivate; - template - class QAbstractSocketWrapper : public core::QIODeviceWrapper { - public: - template - QAbstractSocketWrapper(QAbstractSocketPrivate& d, const v8::FunctionCallbackInfo& args) - : QIODeviceWrapper(d, args) - { - } - QAbstractSocketWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QIODeviceWrapper(isolate, tpl) {} - QAbstractSocketWrapper(v8::Isolate* isolate, const v8::Local& proto) : QIODeviceWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "abort", v8::FunctionTemplate::New(isolate, Abort)); - tpl->PrototypeTemplate()->Set(isolate, "bind", v8::FunctionTemplate::New(isolate, Bind)); - tpl->PrototypeTemplate()->Set(isolate, "connectToHost", v8::FunctionTemplate::New(isolate, ConnectToHost)); - tpl->PrototypeTemplate()->Set(isolate, "disconnectFromHost", v8::FunctionTemplate::New(isolate, DisconnectFromHost)); - tpl->PrototypeTemplate()->Set(isolate, "error", v8::FunctionTemplate::New(isolate, Error)); - tpl->PrototypeTemplate()->Set(isolate, "flush", v8::FunctionTemplate::New(isolate, Flush)); - tpl->PrototypeTemplate()->Set(isolate, "isValid", v8::FunctionTemplate::New(isolate, IsValid)); - tpl->PrototypeTemplate()->Set(isolate, "localAddress", v8::FunctionTemplate::New(isolate, LocalAddress)); - tpl->PrototypeTemplate()->Set(isolate, "localPort", v8::FunctionTemplate::New(isolate, LocalPort)); - tpl->PrototypeTemplate()->Set(isolate, "peerAddress", v8::FunctionTemplate::New(isolate, PeerAddress)); - tpl->PrototypeTemplate()->Set(isolate, "peerName", v8::FunctionTemplate::New(isolate, PeerName)); - tpl->PrototypeTemplate()->Set(isolate, "peerPort", v8::FunctionTemplate::New(isolate, PeerPort)); - tpl->PrototypeTemplate()->Set(isolate, "resume", v8::FunctionTemplate::New(isolate, Resume)); - tpl->PrototypeTemplate()->Set(isolate, "socketType", v8::FunctionTemplate::New(isolate, SocketType)); - tpl->PrototypeTemplate()->Set(isolate, "state", v8::FunctionTemplate::New(isolate, State)); - tpl->PrototypeTemplate()->Set(isolate, "waitForConnected", v8::FunctionTemplate::New(isolate, WaitForConnected)); - tpl->PrototypeTemplate()->Set(isolate, "waitForDisconnected", v8::FunctionTemplate::New(isolate, WaitForDisconnected)); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "connected"), nullptr, SetConnected); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "pauseMode"), PauseMode, SetPauseMode); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "protocolTag"), ProtocolTag, SetProtocolTag); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "proxy"), Proxy, SetProxy); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "readBufferSize"), ReadBufferSize, SetReadBufferSize); - { - v8::Local socket_type = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(socket_type, isolate, QAbstractSocket, SocketType, TcpSocket); - V8_CREATE_ENUM_SYMBOL(socket_type, isolate, QAbstractSocket, SocketType, UdpSocket); - V8_CREATE_ENUM_SYMBOL(socket_type, isolate, QAbstractSocket, SocketType, SctpSocket); - V8_CREATE_ENUM_SYMBOL(socket_type, isolate, QAbstractSocket, SocketType, UnknownSocketType); - - tpl->Set(isolate, "Type", socket_type); - - v8::Local network_layer_protocol = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(network_layer_protocol, isolate, QAbstractSocket, NetworkLayerProtocol, IPv4Protocol); - V8_CREATE_ENUM_SYMBOL(network_layer_protocol, isolate, QAbstractSocket, NetworkLayerProtocol, IPv6Protocol); - V8_CREATE_ENUM_SYMBOL(network_layer_protocol, isolate, QAbstractSocket, NetworkLayerProtocol, AnyIPProtocol); - V8_CREATE_ENUM_SYMBOL(network_layer_protocol, isolate, QAbstractSocket, NetworkLayerProtocol, UnknownNetworkLayerProtocol); - - tpl->Set(isolate, "Protocol", network_layer_protocol); - - v8::Local socket_error = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, ConnectionRefusedError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, RemoteHostClosedError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, HostNotFoundError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, SocketAccessError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, SocketResourceError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, SocketTimeoutError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, DatagramTooLargeError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, NetworkError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, AddressInUseError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, SocketAddressNotAvailableError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, UnsupportedSocketOperationError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, UnfinishedSocketOperationError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, ProxyAuthenticationRequiredError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, SslHandshakeFailedError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, ProxyConnectionRefusedError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, ProxyConnectionClosedError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, ProxyConnectionTimeoutError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, ProxyNotFoundError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, ProxyProtocolError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, OperationError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, SslInternalError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, SslInvalidUserDataError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, TemporaryError); - V8_CREATE_ENUM_SYMBOL(socket_error, isolate, QAbstractSocket, SocketError, UnknownSocketError); - - tpl->Set(isolate, "Error", socket_error); - - v8::Local socket_state = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(socket_state, isolate, QAbstractSocket, SocketState, UnconnectedState); - V8_CREATE_ENUM_SYMBOL(socket_state, isolate, QAbstractSocket, SocketState, HostLookupState); - V8_CREATE_ENUM_SYMBOL(socket_state, isolate, QAbstractSocket, SocketState, ConnectingState); - V8_CREATE_ENUM_SYMBOL(socket_state, isolate, QAbstractSocket, SocketState, ConnectedState); - V8_CREATE_ENUM_SYMBOL(socket_state, isolate, QAbstractSocket, SocketState, BoundState); - V8_CREATE_ENUM_SYMBOL(socket_state, isolate, QAbstractSocket, SocketState, ListeningState); - V8_CREATE_ENUM_SYMBOL(socket_state, isolate, QAbstractSocket, SocketState, ClosingState); - - tpl->Set(isolate, "State", socket_state); - - v8::Local socket_option = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, LowDelayOption); - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, KeepAliveOption); - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, MulticastTtlOption); - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, MulticastLoopbackOption); - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, TypeOfServiceOption); - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, SendBufferSizeSocketOption); - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, ReceiveBufferSizeSocketOption); - V8_CREATE_ENUM_SYMBOL(socket_option, isolate, QAbstractSocket, SocketOption, PathMtuSocketOption); - - tpl->Set(isolate, "Option", socket_option); - - v8::Local bind_flag = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(bind_flag, isolate, QAbstractSocket, BindFlag, DefaultForPlatform); - V8_CREATE_ENUM_SYMBOL(bind_flag, isolate, QAbstractSocket, BindFlag, ShareAddress); - V8_CREATE_ENUM_SYMBOL(bind_flag, isolate, QAbstractSocket, BindFlag, DontShareAddress); - V8_CREATE_ENUM_SYMBOL(bind_flag, isolate, QAbstractSocket, BindFlag, ReuseAddressHint); - - tpl->Set(isolate, "BindFlag", bind_flag); - - v8::Local pause_mode = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(pause_mode, isolate, QAbstractSocket, PauseMode, PauseNever); - V8_CREATE_ENUM_SYMBOL(pause_mode, isolate, QAbstractSocket, PauseMode, PauseOnSslErrors); - - tpl->Set(isolate, "PauseMode", pause_mode); - } - } - - private: - - static void Resume(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->resume(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PauseMode(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - info.GetReturnValue().Set(p->d_func()->pauseMode()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetPauseMode(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - int m = value->Int32Value(context).FromJust(); - - p->d_func()->setPauseMode(static_cast(m)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetConnected(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - v8::Local f = v8::Local::Cast(value); - QSharedPointer>weak_persistent = QSharedPointer>::create(isolate, f); - - QObject::connect(p->d_func(), &T::connected, [weak_persistent]() { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - weak_persistent->Get(isolate)->CallAsFunction(context, context->Global(), 0, {}); - if (try_catch.HasCaught()) { - qCCritical(shelllet_network) << try_catch.Exception(); - } - } - }); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - // - //void shelllet::network::AbstractSocket::Connect(const v8::FunctionCallbackInfo& args) - //{ - // V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - // { - // filesystem::IODevice::Connect(args); - // - // if (args.Length() > 0 && args[0]->IsString()) { - // auto* p = UnWrap(args.This()); - // v8::String::Utf8Value signal(isolate, args[0]); - // - // if (strcmp(*signal, "connected") == 0) { - // if (args.Length() < 2 || !args[1]->IsFunction()) { - // return; - // } - // - // CopyablePersistent function_callback(isolate, v8::Local::Cast(args[1])); - // - // QMetaObject::Connection conn = QObject::connect(dynamic_cast(p), &QAbstractSocket::connected, [isolate, function_callback]() { - // V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO_2(isolate) - // { - // v8::TryCatch try_catch(isolate); - // function_callback.Get(isolate)->Call(context, context->Global(), 0, {}); - // if (try_catch.HasCaught()) { - // qCCritical(shelllet_network) << try_catch.Exception(); - // } - // } - // }); - // - // p->d_func()->push_connection("connected", conn, function_callback); - // } - // - // else if (strcmp(*signal, "disconnected") == 0) { - // if (args.Length() < 2 || !args[1]->IsFunction()) { - // return; - // } - // - // v8::Persistent> function_callback(isolate, v8::Local::Cast(args[1])); - // - // QMetaObject::Connection conn = QObject::connect(dynamic_cast(p), &QAbstractSocket::disconnected, [isolate, function_callback]() { - // V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO_2(isolate) - // { - // function_callback.Get(isolate)->Call(context, context->Global(), 0, {}); - // } - // }); - // - // p->d_func()->push_connection("disconnected", conn, function_callback); - // } - // - // else if (strcmp(*signal, "stateChanged") == 0) { - // if (args.Length() < 2 || !args[1]->IsFunction()) { - // return; - // } - // - // v8::Persistent> function_callback(isolate, v8::Local::Cast(args[1])); - // - // QMetaObject::Connection conn = QObject::connect(dynamic_cast(p), &QAbstractSocket::stateChanged, [isolate, function_callback](QAbstractSocket::SocketState socketState) { - // V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO_2(isolate) - // { - // v8::Local argv[] = { v8::Int32::New(isolate, socketState) }; - // function_callback.Get(isolate)->Call(context, context->Global(), std::size(argv), argv); - // } - // }); - // - // p->d_func()->push_connection("stateChanged", conn, function_callback); - // } - // - // else if (strcmp(*signal, "error") == 0) { - // if (args.Length() < 2 || !args[1]->IsFunction()) { - // return; - // } - // - // v8::Persistent> function_callback(isolate, v8::Local::Cast(args[1])); - // - // QMetaObject::Connection conn = QObject::connect(dynamic_cast(p), qOverload(&QAbstractSocket::error), [isolate, function_callback](QAbstractSocket::SocketError socketError) { - // V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO_2(isolate) - // { - // v8::Local argv[] = { v8::Int32::New(isolate, socketError) }; - // function_callback.Get(isolate)->Call(context, context->Global(), std::size(argv), argv); - // } - // }); - // - // p->d_func()->push_connection("error", conn, function_callback); - // } - // - // else if (strcmp(*signal, "proxyAuthenticationRequired") == 0) { - // if (args.Length() < 2 || !args[1]->IsFunction()) { - // return; - // } - // } - // } - // } - //} - // - //void shelllet::network::AbstractSocket::Disconnect(const v8::FunctionCallbackInfo& args) - //{ - // V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - // { - // common::Object::Disconnect(args); - // } - //} - static void Bind(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This(), 0); - - QAbstractSocket::BindMode mode = QAbstractSocket::DefaultForPlatform; - - if (args.Length() == 0) { - args.GetReturnValue().Set(p->d_func()->bind()); - } - else if (args.Length() > 0) { - if (args[0]->IsSymbol()) { - auto symbol = v8::Local::Cast(args[0]); - v8::String::Utf8Value s = { isolate, symbol->Name() }; - QHostAddress address(static_cast(std::stoi(*s))); - quint16 port = 0; - if (args.Length() > 1 && args[1]->IsNumber()) { - port = args[1]->Int32Value(context).FromJust(); - } - if (args.Length() > 2 && args[2]->IsSymbol()) { - auto symbol = v8::Local::Cast(args[0]); - v8::String::Utf8Value s = { isolate, symbol->Name() }; - mode = static_cast(std::stoi(*s)); - } - - args.GetReturnValue().Set(p->d_func()->bind(address, port, mode)); - } - else if (args[0]->IsObject()) { - auto* address = HostAddress::FromValue(isolate, args[0]); - //QHostAddress address(*(*addr)); - quint16 port = 0; - if (args.Length() > 1 && args[1]->IsNumber()) { - port = args[1]->Int32Value(context).FromJust(); - } - if (args.Length() > 2 && args[2]->IsSymbol()) { - auto symbol = v8::Local::Cast(args[0]); - v8::String::Utf8Value s = { isolate, symbol->Name() }; - mode = static_cast(std::stoi(*s)); - } - - args.GetReturnValue().Set(p->d_func()->bind(***address, port, mode)); - } - else if (args[0]->IsNumber()) { - quint16 port = args[0]->Int32Value(context).FromJust(); - if (args.Length() > 1 && args[1]->IsSymbol()) { - auto symbol = v8::Local::Cast(args[0]); - v8::String::Utf8Value s = { isolate, symbol->Name() }; - mode = static_cast(std::stoi(*s)); - } - args.GetReturnValue().Set(p->d_func()->bind(port, mode)); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ConnectToHost(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - QString host_name; - QHostAddress address; - quint16 port; - if (V8_IsString(args, 0)) { - host_name = convert::String::To(isolate, args[0]); - } - else if (V8_IsObject(args, 0)) { - HostAddress* p = convert::Object::UnWrap(args[0]->ToObject(context).ToLocalChecked()); - address = ***p; - } - else if (V8_IsNumber(args, 0)) { - address = static_cast(isolate, args[0]->Int32Value(context).FromJust()); - } - - if (V8_IsNumber(args, 1)) { - port = args[1]->Int32Value(context).FromJust(); - } - - QIODevice::OpenMode openMode = QAbstractSocket::ReadWrite; - QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::AnyIPProtocol; - - if (V8_IsNumber(args, 2)) { - openMode = static_cast(isolate, args[2]->Int32Value(context).FromJust()); - } - if (V8_IsNumber(args, 3)) { - protocol = static_cast(isolate, args[3]->Int32Value(context).FromJust()); - } - if (!address.isNull()) - p->d_func()->connectToHost(address, port, openMode); - else if (!host_name.trimmed().isEmpty()) { - p->d_func()->connectToHost(host_name, port, openMode, protocol); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DisconnectFromHost(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - // p->d_func()->disconnectFromHost(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsValid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isValid(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BytesAvailable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->bytesAvailable(); - - args.GetReturnValue().Set(v8::BigInt::New(isolate, result)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BytesToWrite(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->bytesToWrite(); - - args.GetReturnValue().Set(v8::BigInt::New(isolate, result)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CanReadLine(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->canReadLine(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void LocalPort(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->localPort(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void LocalAddress(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->localAddress(); - v8::Local argv[] = { v8::External::New(isolate, &result) }; - - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "HostAddress", std::size(argv), argv)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PeerPort(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->peerPort(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PeerAddress(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->peerAddress(); - - v8::Local argv[] = { v8::External::New(isolate, &result) }; - - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "HostAddress", std::size(argv), argv)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PeerName(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->peerName(); - - args.GetReturnValue().Set(convert::String::New(isolate, qPrintable(result))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadBufferSize(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - info.GetReturnValue().Set(v8::BigInt::New(isolate, p->d_func()->readBufferSize())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetReadBufferSize(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - p->d_func()->setReadBufferSize(value->ToBigInt(context).ToLocalChecked()->Int64Value()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Abort(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->abort(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SocketDescriptor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - args.GetReturnValue().Set(std::int32_t(p->d_func()->socketDescriptor())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetSocketDescriptor(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (args.Length() < 1 || !args[0]->IsNumber()) - { - return; - } - QAbstractSocket::SocketState socket_state = QAbstractSocket::ConnectedState; - QIODevice::OpenMode open_mode = QAbstractSocket::ReadWrite; - qintptr socket_descriptor = args[0]->Int32Value(context).FromJust(); - - if (args.Length() > 1 && args[1]->IsNumber()) { - socket_state = static_cast(args[1]->Int32Value(context).FromJust()); - } - if (args.Length() > 2 && args[2]->IsNumber()) { - open_mode = static_cast(args[2]->Int32Value(context).FromJust()); - } - - p->d_func()->setSocketDescriptor(socket_descriptor, socket_state, open_mode); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetSocketOption(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (args.Length() < 2 || !args[0]->IsNumber() || !args[1]->IsObject()) { - return; - } - QAbstractSocket::SocketOption option = static_cast(args[0]->Int32Value(context).FromJust()); - - auto* v = static_cast(args.This()->ToObject(context).ToLocalChecked()->GetAlignedPointerFromInternalField(0)); - p->d_func()->setSocketOption(option, *v); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SocketOption(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (args.Length() < 1 || !args[0]->IsNumber()) { - return; - } - - auto option = p->d_func()->socketOption(static_cast(args[0]->Int32Value(context).FromJust())); - v8::Local argv[] = { v8::External::New(isolate, &option) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "Variant", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SocketType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->socketType(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void State(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->state(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Error(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->error(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Close(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->close(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsSequential(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isSequential(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void AtEnd(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->atEnd(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Flush(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->flush(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForConnected(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - int msec = 30000; - if (args.Length() > 0 && args[0]->IsNumber()) { - msec = args[0]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(p->d_func()->waitForConnected(msec)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForReadyRead(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - int msec = 30000; - if (args.Length() > 0 && args[0]->IsNumber()) { - msec = args[0]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(p->d_func()->waitForReadyRead(msec)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForBytesWritten(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - int msec = 30000; - if (args.Length() > 0 && args[0]->IsNumber()) { - msec = args[0]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(p->d_func()->waitForBytesWritten(msec)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForDisconnected(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - int msec = 30000; - if (args.Length() > 0 && args[0]->IsNumber()) { - msec = args[0]->Int32Value(context).FromJust(); - } - args.GetReturnValue().Set(p->d_func()->waitForDisconnected(msec)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetProxy(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - QNetworkProxy* proxy = static_cast(value->ToObject(context).ToLocalChecked()->GetAlignedPointerFromInternalField(0)); - - p->d_func()->setProxy(*proxy); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Proxy(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - v8::Local argv[] = { v8::External::New(isolate, &p->d_func()->proxy()) }; - info.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "NetworkProxy", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ProtocolTag(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - info.GetReturnValue().Set(convert::String::New(isolate, qPrintable(p->d_func()->protocolTag()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetProtocolTag(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - v8::String::Utf8Value tag(isolate, value); - p->d_func()->setProtocolTag(*tag); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/network/qhostaddress_implement.h b/v8/include/modules/network/qhostaddress_implement.h deleted file mode 100644 index e935bc2..0000000 --- a/v8/include/modules/network/qhostaddress_implement.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "network_module.h" -#include "qhostaddress_p.h" -#include "qhostaddress_wrapper.h" - -namespace shelllet { - namespace network { - class HostAddress : public QHostAddressWrapper - { - public: - HostAddress(const v8::FunctionCallbackInfo& args); - HostAddress(v8::Isolate* isolate, const v8::Local& tpl); - - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qhostaddress_p.h b/v8/include/modules/network/qhostaddress_p.h deleted file mode 100644 index ed04ac7..0000000 --- a/v8/include/modules/network/qhostaddress_p.h +++ /dev/null @@ -1,12 +0,0 @@ -#pragma once - -namespace shelllet::network { - template - class QHostAddressPrivate : public core::ObjectPrivate - { - public: - template - QHostAddressPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/network/qhostaddress_wrapper.h b/v8/include/modules/network/qhostaddress_wrapper.h deleted file mode 100644 index fde746e..0000000 --- a/v8/include/modules/network/qhostaddress_wrapper.h +++ /dev/null @@ -1,321 +0,0 @@ -#pragma once -#include "framework.h" - -namespace shelllet { - namespace network { - template class QHostAddressPrivate; - template - class QHostAddressWrapper : public core::ObjectWrapper - { - public: - template - QHostAddressWrapper(QHostAddressPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) - { - } - - QHostAddressWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QHostAddressWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) { - { - tpl->PrototypeTemplate()->Set(isolate, "clear", v8::FunctionTemplate::New(isolate, Clear)); - tpl->PrototypeTemplate()->Set(isolate, "isBroadcast", v8::FunctionTemplate::New(isolate, IsBroadcast)); - tpl->PrototypeTemplate()->Set(isolate, "isEqual", v8::FunctionTemplate::New(isolate, IsEqual)); - tpl->PrototypeTemplate()->Set(isolate, "isGlobal", v8::FunctionTemplate::New(isolate, IsGlobal)); - tpl->PrototypeTemplate()->Set(isolate, "isInSubnet", v8::FunctionTemplate::New(isolate, IsInSubnet)); - tpl->PrototypeTemplate()->Set(isolate, "isLinkLocal", v8::FunctionTemplate::New(isolate, IsLinkLocal)); - tpl->PrototypeTemplate()->Set(isolate, "isLoopback", v8::FunctionTemplate::New(isolate, IsLoopback)); - tpl->PrototypeTemplate()->Set(isolate, "isMulticast", v8::FunctionTemplate::New(isolate, IsMulticast)); - tpl->PrototypeTemplate()->Set(isolate, "isNull", v8::FunctionTemplate::New(isolate, IsNull)); - tpl->PrototypeTemplate()->Set(isolate, "isSiteLocal", v8::FunctionTemplate::New(isolate, IsSiteLocal)); - tpl->PrototypeTemplate()->Set(isolate, "isUniqueLocalUnicast", v8::FunctionTemplate::New(isolate, IsUniqueLocalUnicast)); - tpl->PrototypeTemplate()->Set(isolate, "setAddress", v8::FunctionTemplate::New(isolate, SetAddress)); - tpl->PrototypeTemplate()->Set(isolate, "swap", v8::FunctionTemplate::New(isolate, Swap)); - tpl->PrototypeTemplate()->Set(isolate, "toIPv4Address", v8::FunctionTemplate::New(isolate, ToIPv4Address)); - tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "scopeId"), ScopeId, SetScopeId); - } - { - v8::Local special_address = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(special_address, isolate, QHostAddress, SpecialAddress, Null); - V8_CREATE_ENUM_SYMBOL(special_address, isolate, QHostAddress, SpecialAddress, Broadcast); - V8_CREATE_ENUM_SYMBOL(special_address, isolate, QHostAddress, SpecialAddress, LocalHost); - V8_CREATE_ENUM_SYMBOL(special_address, isolate, QHostAddress, SpecialAddress, LocalHostIPv6); - V8_CREATE_ENUM_SYMBOL(special_address, isolate, QHostAddress, SpecialAddress, Any); - V8_CREATE_ENUM_SYMBOL(special_address, isolate, QHostAddress, SpecialAddress, AnyIPv6); - V8_CREATE_ENUM_SYMBOL(special_address, isolate, QHostAddress, SpecialAddress, AnyIPv4); - - tpl->Set(isolate, "SpecialAddress", special_address); - - v8::Local conversion_mode_flag = v8::ObjectTemplate::New(isolate); - - V8_CREATE_ENUM_SYMBOL(conversion_mode_flag, isolate, QHostAddress, ConversionModeFlag, ConvertV4MappedToIPv4); - V8_CREATE_ENUM_SYMBOL(conversion_mode_flag, isolate, QHostAddress, ConversionModeFlag, ConvertV4CompatToIPv4); - V8_CREATE_ENUM_SYMBOL(conversion_mode_flag, isolate, QHostAddress, ConversionModeFlag, ConvertUnspecifiedAddress); - V8_CREATE_ENUM_SYMBOL(conversion_mode_flag, isolate, QHostAddress, ConversionModeFlag, ConvertLocalHost); - V8_CREATE_ENUM_SYMBOL(conversion_mode_flag, isolate, QHostAddress, ConversionModeFlag, TolerantConversion); - V8_CREATE_ENUM_SYMBOL(conversion_mode_flag, isolate, QHostAddress, ConversionModeFlag, StrictConversion); - - tpl->Set(isolate, "ConversionModeFlag", conversion_mode_flag); - } - } - - private: - - static void Swap(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) - { - return; - } - auto* address = HostAddress::FromValue(isolate, args[0]); - if (address) { - p->d_func()->swap(***address); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetAddress(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value value(isolate, args[0]); - - p->d_func()->setAddress(QString::fromLocal8Bit(*value)); - } - if (args.Length() > 0 && args[0]->IsNumber()) { - QHostAddress::SpecialAddress address = static_cast(args[0]->Int32Value(context).FromJust()); - - p->d_func()->setAddress(address); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToIPv4Address(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->toIPv4Address(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ScopeId(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - info.GetReturnValue().Set(convert::String::New(isolate, qPrintable(p->d_func()->scopeId()))); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetScopeId(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - v8::String::Utf8Value id(isolate, value); - - p->d_func()->setScopeId(QString::fromLocal8Bit(*id)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsEqual(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() > 0 && args[0]->IsObject()) { - auto address = HostAddress::FromValue(isolate, args[0]); - - QHostAddress::ConversionMode mode = QHostAddress::TolerantConversion; - if (args.Length() > 1 && args[1]->IsNumber()) { - mode = static_cast(args[1]->Int32Value(context).FromJust()); - } - - p->d_func()->isEqual(***address, mode); - } - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsNull(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isNull(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Clear(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - p->d_func()->clear(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsInSubnet(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - if (args.Length() < 2 || !args[0]->IsObject() || !args[1]->IsNumber()) { - return; - } - - auto address = HostAddress::FromValue(isolate, args[0]); - - int netmask = args[1]->Int32Value(context).FromJust(); - - p->d_func()->isInSubnet(***address, netmask); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsLoopback(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isLoopback(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsGlobal(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isGlobal(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsLinkLocal(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isLinkLocal(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsSiteLocal(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isSiteLocal(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsUniqueLocalUnicast(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isUniqueLocalUnicast(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsMulticast(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isMulticast(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsBroadcast(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) - { - auto result = p->d_func()->isBroadcast(); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/network/qnetworkdatagram_implement.h b/v8/include/modules/network/qnetworkdatagram_implement.h deleted file mode 100644 index 68dc0c6..0000000 --- a/v8/include/modules/network/qnetworkdatagram_implement.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -#include "network_module.h" -#include "qnetworkdatagram_p.h" -#include "qnetworkdatagram_wrapper.h" - -namespace shelllet { - namespace network { - class NetworkDatagram : public QNetworkDatagramWrapper - { - public: - NetworkDatagram(const v8::FunctionCallbackInfo& args); - NetworkDatagram(v8::Isolate* isolate, const v8::Local& tpl); - - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qnetworkdatagram_p.h b/v8/include/modules/network/qnetworkdatagram_p.h deleted file mode 100644 index 90199b3..0000000 --- a/v8/include/modules/network/qnetworkdatagram_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include - -namespace shelllet::network { - template - class QNetworkDatagramPrivate : public core::ObjectPrivate - { - public: - template - QNetworkDatagramPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/network/qnetworkdatagram_wrapper.h b/v8/include/modules/network/qnetworkdatagram_wrapper.h deleted file mode 100644 index 8099a44..0000000 --- a/v8/include/modules/network/qnetworkdatagram_wrapper.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once -#include "framework.h" -#include - -namespace shelllet { - namespace network { - template class QNetworkDatagramPrivate; - template - class QNetworkDatagramWrapper :public core::ObjectWrapper { - public: - template - QNetworkDatagramWrapper(QNetworkDatagramPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) - { - } - QNetworkDatagramWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QNetworkDatagramWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "data", v8::FunctionTemplate::New(isolate, Data)); - } - - private: - - static void Data(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - v8::Local array_buffer; - { - QByteArray buffer = p->d_func()->data(); - array_buffer = v8::ArrayBuffer::New(isolate, buffer.size()); - std::memcpy(array_buffer->GetContents().Data(), buffer.constData(), buffer.size()); - } - args.GetReturnValue().Set(v8::Uint8Array::New(array_buffer, 0, array_buffer->ByteLength())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/network/qtcpserver_implement.h b/v8/include/modules/network/qtcpserver_implement.h deleted file mode 100644 index 933ac05..0000000 --- a/v8/include/modules/network/qtcpserver_implement.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -#include "network_module.h" -#include "qtcpserver_p.h" -#include "qtcpserver_wrapper.h" - -namespace shelllet { - namespace network { - class TcpServer : public QTcpServerWrapper - { - public: - TcpServer(const v8::FunctionCallbackInfo& args); - TcpServer(v8::Isolate* isolate, const v8::Local& tpl); - - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qtcpserver_p.h b/v8/include/modules/network/qtcpserver_p.h deleted file mode 100644 index 359cb3c..0000000 --- a/v8/include/modules/network/qtcpserver_p.h +++ /dev/null @@ -1,13 +0,0 @@ -#pragma once -#include -#include "qobject_p.h" - -namespace shelllet::network { - template - class QTcpServerPrivate : public core::QObjectPrivate - { - public: - QTcpServerPrivate() { - } - }; -} diff --git a/v8/include/modules/network/qtcpserver_wrapper.h b/v8/include/modules/network/qtcpserver_wrapper.h deleted file mode 100644 index 79a6343..0000000 --- a/v8/include/modules/network/qtcpserver_wrapper.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qobject_wrapper.h" -namespace shelllet { - namespace network { - template class QTcpServerPrivate; - template - class QTcpServerWrapper : public core::QObjectWrapper { - public: - template - QTcpServerWrapper(QTcpServerPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) - { - } - QTcpServerWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QTcpServerWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "listen", v8::FunctionTemplate::New(isolate, Listen)); - } - - private: - static void Listen(const v8::FunctionCallbackInfo& args) - { - } - }; - } -} diff --git a/v8/include/modules/network/qtcpsocket_implement.h b/v8/include/modules/network/qtcpsocket_implement.h deleted file mode 100644 index 1d01039..0000000 --- a/v8/include/modules/network/qtcpsocket_implement.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -#include "network_module.h" -#include "qtcpsocket_p.h" -#include "qtcpsocket_wrapper.h" - -namespace shelllet { - namespace network { - class TcpSocket : public QTcpSocketWrapper - { - public: - TcpSocket(const v8::FunctionCallbackInfo& args); - TcpSocket(v8::Isolate* isolate, const v8::Local& tpl); - - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qtcpsocket_p.h b/v8/include/modules/network/qtcpsocket_p.h deleted file mode 100644 index c816f13..0000000 --- a/v8/include/modules/network/qtcpsocket_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include "qabstractsocket_p.h" - -namespace shelllet::network { - template - class QTcpSocketPrivate : public QAbstractSocketPrivate - { - public: - template - QTcpSocketPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) :QAbstractSocketPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/network/qtcpsocket_wrapper.h b/v8/include/modules/network/qtcpsocket_wrapper.h deleted file mode 100644 index a4cb39b..0000000 --- a/v8/include/modules/network/qtcpsocket_wrapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qabstractsocket_wrapper.h" - -namespace shelllet { - namespace network { - template class QTcpSocketPrivate; - template - class QTcpSocketWrapper : public QAbstractSocketWrapper { - public: - template - QTcpSocketWrapper(QTcpSocketPrivate& d, const v8::FunctionCallbackInfo& args) - : QAbstractSocketWrapper(d, args) - { - } - - QTcpSocketWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QAbstractSocketWrapper(isolate, tpl) {} - QTcpSocketWrapper(v8::Isolate* isolate, const v8::Local& proto) : QAbstractSocketWrapper(isolate, proto) {} - - private: - }; - } -} diff --git a/v8/include/modules/network/qudpsocket_implement.h b/v8/include/modules/network/qudpsocket_implement.h deleted file mode 100644 index 4452186..0000000 --- a/v8/include/modules/network/qudpsocket_implement.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -#include "network_module.h" -#include "qudpsocket_p.h" -#include "qudpsocket_wrapper.h" - -namespace shelllet { - namespace network { - class UdpSocket : public QUdpSocketWrapper - { - public: - UdpSocket(const v8::FunctionCallbackInfo& args); - UdpSocket(v8::Isolate* isolate, const v8::Local& tpl); - - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qudpsocket_p.h b/v8/include/modules/network/qudpsocket_p.h deleted file mode 100644 index fd73062..0000000 --- a/v8/include/modules/network/qudpsocket_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include "qabstractsocket_p.h" - -namespace shelllet::network { - template - class QUdpSocketPrivate : public QAbstractSocketPrivate - { - public: - template - QUdpSocketPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QAbstractSocketPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/network/qudpsocket_wrapper.h b/v8/include/modules/network/qudpsocket_wrapper.h deleted file mode 100644 index 35e9412..0000000 --- a/v8/include/modules/network/qudpsocket_wrapper.h +++ /dev/null @@ -1,109 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include -#include "qabstractsocket_wrapper.h" -#include "qtcpServer_wrapper.h" -#include "qnetworkdatagram_implement.h" - -namespace shelllet { - namespace network { - template class QUdpSocketPrivate; - template - class QUdpSocketWrapper : public QAbstractSocketWrapper { - public: - template - QUdpSocketWrapper(QUdpSocketPrivate& d, const v8::FunctionCallbackInfo& args) - : QAbstractSocketWrapper(d, args) - { - } - QUdpSocketWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QAbstractSocketWrapper(isolate, tpl) {} - QUdpSocketWrapper(v8::Isolate* isolate, const v8::Local& proto) : QAbstractSocketWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "hasPendingDatagrams", v8::FunctionTemplate::New(isolate, HasPendingDatagrams)); - tpl->PrototypeTemplate()->Set(isolate, "receiveDatagram", v8::FunctionTemplate::New(isolate, ReceiveDatagram)); - tpl->PrototypeTemplate()->Set(isolate, "writeDatagram", v8::FunctionTemplate::New(isolate, WriteDatagram)); - } - virtual ~QUdpSocketWrapper() { - } - - private: - - static void HasPendingDatagrams(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - - args.GetReturnValue().Set(p->d_func()->hasPendingDatagrams()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WriteDatagram(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (args.Length() > 0 && args[0]->IsObject()) { - auto* datagram = NetworkDatagram::FromValue(isolate, args[0]); - p->d_func()->writeDatagram(***datagram); - } - else if (args.Length() > 0 && args[0]->IsUint8Array()) { - v8::Local array = v8::Local::Cast(args[0]); - QByteArray datagram(array->Length(), '\0'); - QHostAddress address; - quint16 port = 0; - array->CopyContents(datagram.data(), datagram.length()); - - if (args.Length() > 1 && args[1]->IsObject()) { - auto* p = HostAddress::FromValue(isolate, args[1]); - address = ***p; - } - if (args.Length() > 2 && args[2]->IsNumber()) { - port = args[2]->NumberValue(context).FromJust(); - } - - if (!address.isNull()) { - p->d_func()->writeDatagram(datagram, address, port); - } - } - else if (args.Length() > 0 && args[0]->IsString()) { - v8::String::Utf8Value datagram = { isolate, args[0] }; - - QHostAddress address; - quint16 port = 0; - if (args.Length() > 1 && args[1]->IsObject()) { - auto* p = HostAddress::FromValue(isolate, args[1]); - address = ***p; - return; - } - else if (args.Length() > 1 && args[1]->IsSymbol()) { - auto symbol = v8::Local::Cast(args[1]); - v8::String::Utf8Value s = { isolate, symbol->Name() }; - address = static_cast(std::stoi(*s)); - } - if (args.Length() > 2 && args[2]->IsNumber()) { - port = args[2]->NumberValue(context).FromJust(); - } - if (!address.isNull()) - p->d_func()->writeDatagram(*datagram, datagram.length(), address, port); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReceiveDatagram(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - - QNetworkDatagram datagram = p->d_func()->receiveDatagram(); - v8::Local argv[] = { v8::External::New(isolate, &datagram) }; - args.GetReturnValue().Set(convert::Object::Wrap(isolate, context, "NetworkDatagram", std::size(argv), argv)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/network/qwebsocket_implement.h b/v8/include/modules/network/qwebsocket_implement.h deleted file mode 100644 index c12b23a..0000000 --- a/v8/include/modules/network/qwebsocket_implement.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -#include "network_module.h" -#include "qwebsocket_p.h" -#include "qwebsocket_wrapper.h" - -namespace shelllet { - namespace network { - class WebSocket : public QWebSocketWrapper - { - public: - WebSocket(const v8::FunctionCallbackInfo& args); - WebSocket(v8::Isolate* isolate, const v8::Local& tpl); - - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qwebsocket_p.h b/v8/include/modules/network/qwebsocket_p.h deleted file mode 100644 index f508311..0000000 --- a/v8/include/modules/network/qwebsocket_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include -#include -#include "qobject_p.h" - -namespace shelllet::network { - template - class QWebSocketPrivate : public core::QObjectPrivate - { - public: - template - QWebSocketPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/network/qwebsocket_wrapper.h b/v8/include/modules/network/qwebsocket_wrapper.h deleted file mode 100644 index 0ad14d5..0000000 --- a/v8/include/modules/network/qwebsocket_wrapper.h +++ /dev/null @@ -1,237 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qobject_wrapper.h" - -namespace shelllet { - namespace network { - template class QWebSocketPrivate; - template - class QWebSocketWrapper : public core::QObjectWrapper { - public: - template - QWebSocketWrapper(QWebSocketPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) - { - } - QWebSocketWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QWebSocketWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "open", v8::FunctionTemplate::New(isolate, Open)); - tpl->PrototypeTemplate()->Set(isolate, "sendTextMessage", v8::FunctionTemplate::New(isolate, SendTextMessage)); - tpl->PrototypeTemplate()->Set(isolate, "close", v8::FunctionTemplate::New(isolate, Close)); - //tpl->PrototypeTemplate()->Set(isolate, "receive", v8::FunctionTemplate::New(isolate, Receive)); - //tpl->PrototypeTemplate()->Set(isolate, "exit", v8::FunctionTemplate::New(isolate, Exit)); - //tpl->PrototypeTemplate()->SetAccessor(convert::String::New(isolate, "connectTimeOut"), nullptr, SetConnectTimeOut); - } - - private: - static void Open(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() == 0 || !args[0]->IsString()) { - qCCritical(shelllet_network) << "#no valid argument for open"; - return; - } - v8::String::Utf8Value address{ isolate, args[0] }; - - auto* p = convert::Object::UnWrap>(args.This()); - p->socket_->open(QUrl(*address)); - } - V8_CREATE_LOCAL_CONTEXT_END - - //if (async) { - // signal = std::make_shared&)>>(); - - // auto resolver = v8::Promise::Resolver::New(isolate->GetCurrentContext()).ToLocalChecked(); - // auto holder = Holder::newHolder(isolate, resolver); - // args.GetReturnValue().Set(resolver->GetPromise()); - // signal->connect([holder](const std::unique_ptr& err) { - // v8::Locker locker(holder->isolate); - // v8::Isolate::Scope scope(holder->isolate); - // v8::HandleScope handle_scope(holder->isolate); - - // if (err) - // { - // //THROW_EXCEPTION_VAR(holder->isolate, err->what()); - // holder->resolver.Get(holder->isolate)->Reject(holder->isolate->GetCurrentContext(), v8::False(holder->isolate)); - // // v8::Isolate::GetCurrent()->RunMicrotasks(); - // return; - // } - // holder->resolver.Get(holder->isolate)->Resolve(holder->isolate->GetCurrentContext(), v8::True(holder->isolate)); - // v8::Isolate::GetCurrent()->RunMicrotasks(); - // }); - //} - - //async ? client->connect(*address, port, target, signal) : client->connect(*address, port, target); - } - static void SendTextMessage(const v8::FunctionCallbackInfo& args) - { - //v8::Isolate* isolate = args.GetIsolate(); - //v8::Locker locker(isolate); - - //if (args.Length() < 1) { - // // THROW_EXCEPTION_VAR(isolate, CONTEXT_CAST(isolate)->getLanguageText("plugin.l1").c_str()); - // return; - //} - - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - if (args.Length() == 0 || !args[0]->IsString()) { - qCCritical(shelllet_network) << "#no valid argument for open"; - return; - } - - v8::String::Utf8Value value{ isolate, args[0] }; - - auto* p = convert::Object::UnWrap>(args.This()); - p->socket_->sendTextMessage(*value); - } - - //LOG_INFO(kMainModuleName) << "boost::this_thread::interruption_enabled: " << boost::this_thread::interruption_enabled() << std::endl; - //boost::this_thread::interruption_point(); - - //WebSocket* client = convert::Object::UnWrap>(args.This()); - ////bool async = convert::Object::UnWrap>(args.This())->async_; - //if (!client) { - // return; - //} - //std::shared_ptr&)>> signal; - - //if (client->async_) { - // auto resolver = v8::Promise::Resolver::New(isolate->GetCurrentContext()).ToLocalChecked(); - // args.GetReturnValue().Set(resolver->GetPromise()); - - // signal = std::make_shared&)>>(); - // auto holder = Holder::newHolder(isolate, resolver); - - // signal->connect([holder](const std::unique_ptr& err) { - // v8::Locker locker(holder->isolate); - - // if (err) - // { - // holder->resolver.Get(holder->isolate)->Reject(holder->isolate->GetCurrentContext(), v8::False(holder->isolate)); - // return; - // } - // else { - // holder->resolver.Get(holder->isolate)->Resolve(holder->isolate->GetCurrentContext(), v8::True(holder->isolate)); - // v8::Isolate::GetCurrent()->RunMicrotasks(); - // } - // }); - //} - - //if (args[0]->IsString()) { - // v8::String::Utf8Value value{ isolate, args[0] }; - // //std::string string = *value; - // client->buffer_ = *value; - // try - // { - // client->async_ ? client->send(boost::asio::buffer(client->buffer_), signal) : client->send(boost::asio::buffer(client->buffer_)); - // } - // catch (const std::exception & err) - // { - // LOG_ERROR(kMainModuleName) << err.what() << std::endl; - // } - //} - //else if (args[0]->IsUint8Array()) { - // v8::Local uint8_array = v8::Local::Cast(args[0]); - - // boost::beast::flat_buffer buffer(uint8_array->Length()); - - // uint8_array->CopyContents(buffer.data().data(), uint8_array->Length()); - - // client->async_ ? client->send(buffer.cdata(), signal) : client->send(buffer.cdata()); - //} - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Close(const v8::FunctionCallbackInfo& args) - { - /*v8::Isolate* isolate = args.GetIsolate(); - v8::Locker locker(isolate); - - bool async = convert::Object::UnWrap>(args.This())->async_; - std::shared_ptr> signal; - - if (async) { - auto resolver = v8::Promise::Resolver::New(isolate->GetCurrentContext()).ToLocalChecked(); - args.GetReturnValue().Set(resolver->GetPromise()); - - signal = std::make_shared>(); - auto holder = Holder::newHolder(isolate, resolver); - - signal->connect([holder] { - v8::Locker locker(holder->isolate); - holder->resolver.Get(holder->isolate)->Resolve(holder->isolate->GetCurrentContext(), v8::True(holder->isolate)); - v8::Isolate::GetCurrent()->RunMicrotasks(); - }); - }*/ - //WebSocketClient* client = convert::Object::UnWrap>(args.This()); - //async ? client->close(signal) : client->close(); - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - p->socket_->close(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Receive(const v8::FunctionCallbackInfo& args) - { - /*v8::Isolate* isolate = args.GetIsolate(); - v8::Locker locker(isolate); - - bool async = convert::Object::UnWrap>(args.This())->async_; - std::shared_ptr&)>> signal; - WebSocketClient* websocket = convert::Object::UnWrap>(args.This()); - if (async) { - auto resolver = v8::Promise::Resolver::New(isolate->GetCurrentContext()).ToLocalChecked(); - args.GetReturnValue().Set(resolver->GetPromise()); - - signal = std::make_shared&)>>(); - auto holder = Holder::newHolder(isolate, resolver); - - signal->connect([holder, websocket](boost::beast::flat_buffer& buffer, const std::unique_ptr& err) { - v8::Locker locker(holder->isolate); - - if (err) - { - holder->resolver.Get(holder->isolate)->Reject(holder->isolate->GetCurrentContext(), v8::False(holder->isolate)); - } - else { - if (websocket->isText()) { - holder->resolver.Get(holder->isolate)->Resolve(holder->isolate->GetCurrentContext(), - v8::convert::String::NewFromUtf8(holder->isolate, static_cast(buffer.data().data()), - v8::NewStringType::kNormal, - static_cast(buffer.size())).ToLocalChecked()); - v8::Isolate::GetCurrent()->RunMicrotasks(); - } - else { - v8::Local array_buffer = v8::ArrayBuffer::New(holder->isolate, buffer.data().data(), buffer.size()); - v8::Local array = v8::Uint8Array::New(array_buffer, 0, buffer.size()); - holder->resolver.Get(holder->isolate)->Resolve(holder->isolate->GetCurrentContext(), array); - v8::Isolate::GetCurrent()->RunMicrotasks(); - } - } - }); - } - boost::beast::flat_buffer buffer; - - async ? websocket->receive(signal) : websocket->receive(buffer); - - if (!async) { - if (websocket->isText()) { - args.GetReturnValue().Set(convert::String::New(isolate, static_cast(buffer.data().data()), v8::NewStringType::kNormal, static_cast(buffer.size()))); - } - else { - v8::Local array_buffer = v8::ArrayBuffer::New(isolate, buffer.data().data(), buffer.size()); - args.GetReturnValue().Set(v8::Uint8Array::New(array_buffer, 0, buffer.size())); - } - }*/ - } - - private: - QWebSocket* socket_; - }; - } -} diff --git a/v8/include/modules/network/qwebsocketserver_implement.h b/v8/include/modules/network/qwebsocketserver_implement.h deleted file mode 100644 index 2ecf6ec..0000000 --- a/v8/include/modules/network/qwebsocketserver_implement.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "framework.h" -#include "network_module.h" -#include "qwebsocketserver_p.h" -#include "qwebsocketserver_wrapper.h" - -namespace shelllet { - namespace network { - class WebSocketServer : public QWebSocketServerWrapper - { - public: - WebSocketServer(const v8::FunctionCallbackInfo& args); - WebSocketServer(v8::Isolate* isolate, const v8::Local& tpl); - public: - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/network/qwebsocketserver_p.h b/v8/include/modules/network/qwebsocketserver_p.h deleted file mode 100644 index 024e09b..0000000 --- a/v8/include/modules/network/qwebsocketserver_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include -#include "qobject_p.h" - -namespace shelllet::network { - template - class QWebSocketServerPrivate : public core::QObjectPrivate - { - public: - template - QWebSocketServerPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; -} diff --git a/v8/include/modules/network/qwebsocketserver_wrapper.h b/v8/include/modules/network/qwebsocketserver_wrapper.h deleted file mode 100644 index 5640dd2..0000000 --- a/v8/include/modules/network/qwebsocketserver_wrapper.h +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qobject_wrapper.h" -#include "qhostaddress_implement.h" - -namespace shelllet { - namespace network { - template class QWebSocketServerPrivate; - template - class QWebSocketServerWrapper : public core::QObjectWrapper { - public: - template - QWebSocketServerWrapper(QWebSocketServerPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) - { - } - QWebSocketServerWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QWebSocketServerWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "close", v8::FunctionTemplate::New(isolate, Close)); - tpl->PrototypeTemplate()->Set(isolate, "listen", v8::FunctionTemplate::New(isolate, Listen)); - tpl->PrototypeTemplate()->Set(isolate, "nextPendingConnection", v8::FunctionTemplate::New(isolate, NextPendingConnection)); - } - - protected: - static void Close(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - p->d_func()->close(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void NextPendingConnection(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - QWebSocket* socket = p->d_func()->nextPendingConnection(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Listen(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) - return; - - auto* address = HostAddress::FromValue(isolate, args[0]); - quint16 port = 0; - if (args[1]->IsNumber()) { - port = args[1]->Int32Value(context).FromJust(); - } - - args.GetReturnValue().Set(p->d_func()->listen(***address, port)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/serialbus/initialize.h b/v8/include/modules/serialbus/initialize.h deleted file mode 100644 index 21d11e7..0000000 --- a/v8/include/modules/serialbus/initialize.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "framework.h" - -#include "serialbus/qmodbusclient_implement.h" -#include "serialbus/qmodbustcpclient_implement.h" -#include "serialbus/qmodbusresponse_implement.h" -#include "serialbus/qmodbusrequest_implement.h" -#include "serialbus/qmodbusreply_implement.h" -#include "serialbus/qmodbuspdu_implement.h" -#include "serialbus/qmodbusdevice_implement.h" -#include "serialbus/qmodbusdataunit_implement.h" - - -namespace shelllet { - namespace qtserialbus { - void initialize(v8::Isolate* isolate, const v8::Local& proto) { - using namespace shelllet::core; - // serialbus - // https://www.ni.com/zh-cn/innovations/white-papers/14/the-modbus-protocol-in-depth.html - { - proto->Set(isolate, ModbusClient::Name(), ModbusClient::WrapClass(isolate)); - proto->Set(isolate, ModbusDataUnit::Name(), ModbusDataUnit::WrapClass(isolate)); - proto->Set(isolate, ModbusDevice::Name(), ModbusDevice::WrapClass(isolate)); - proto->Set(isolate, ModbusPdu::Name(), ModbusPdu::WrapClass(isolate)); - proto->Set(isolate, ModbusReply::Name(), ModbusReply::WrapClass(isolate)); - proto->Set(isolate, ModbusRequest::Name(), ModbusRequest::WrapClass(isolate)); - proto->Set(isolate, ModbusResponse::Name(), ModbusResponse::WrapClass(isolate)); - proto->Set(isolate, ModbusTcpClient::Name(), ModbusTcpClient::WrapClass(isolate)); - } - } - - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbusclient_implement.h b/v8/include/modules/serialbus/qmodbusclient_implement.h deleted file mode 100644 index 8dd09a9..0000000 --- a/v8/include/modules/serialbus/qmodbusclient_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbusclient_p.h" -#include "qmodbusclient_wrapper.h" - -namespace shelllet { - namespace serialbus { - class ModbusClient : public QModbusClientWrapper - { - public: - using ReturnType = QModbusClientPrivate; - using ReturnType2 = QModbusClientPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - ModbusClient(const v8::FunctionCallbackInfo& args) :QModbusClientWrapper(*Private(args), args) - { - } - ModbusClient(QModbusClient* p, const v8::FunctionCallbackInfo& args) : QModbusClientWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusClient(v8::Isolate* isolate, const v8::Local& tpl) : QModbusClientWrapper(isolate, tpl) {} - ModbusClient(v8::Isolate* isolate, const v8::Local& proto) : QModbusClientWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusClient"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusclient_p.h b/v8/include/modules/serialbus/qmodbusclient_p.h deleted file mode 100644 index 6095aff..0000000 --- a/v8/include/modules/serialbus/qmodbusclient_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "qmodbusdevice_p.h" -namespace shelllet { - namespace serialbus { - template - class QModbusClientPrivate : public QModbusDevicePrivate - { - public: - template - QModbusClientPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QModbusDevicePrivate(isolate, obj, std::forward(args)...) { - } - protected: - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusclient_wrapper.h b/v8/include/modules/serialbus/qmodbusclient_wrapper.h deleted file mode 100644 index 101791d..0000000 --- a/v8/include/modules/serialbus/qmodbusclient_wrapper.h +++ /dev/null @@ -1,78 +0,0 @@ -#pragma once -#include "qmodbusdevice_wrapper.h" -namespace shelllet { - namespace serialbus { - template class QModbusClientPrivate; - template - class QModbusClientWrapper : public QModbusDeviceWrapper - { - public: - template - QModbusClientWrapper(QModbusClientPrivate& d, const v8::FunctionCallbackInfo& args) - : QModbusDeviceWrapper(d, args) { - } - QModbusClientWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QModbusDeviceWrapper(isolate, tpl) {} - QModbusClientWrapper(v8::Isolate* isolate, const v8::Local& proto) : QModbusDeviceWrapper(isolate, proto) - { - proto->Set(isolate, "setTimeout", v8::FunctionTemplate::New(isolate, SetTimeout)); - proto->Set(isolate, "sendReadRequest", v8::FunctionTemplate::New(isolate, SendReadRequest)); - proto->Set(isolate, "sendWriteRequest", v8::FunctionTemplate::New(isolate, SendWriteRequest)); - } - - protected: - static void SetTimeout(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - int newTimeout = args[0]->Int32Value(context).FromJust(); - - (*self)->setTimeout(newTimeout); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void SendReadRequest(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto* read = ModbusDataUnit::From(args[0]); - if (!read) { - throw std::invalid_argument(K_CONST_ERROR_INVLAID_PARAM); - } - - int serverAddress = args[1]->Int32Value(context).FromJust(); - auto* reply = (*self)->sendReadRequest(**read, serverAddress); - if (reply) - args.GetReturnValue().Set(ModbusReply::New2(isolate, reply)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void SendWriteRequest(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - auto* write = ModbusDataUnit::From(args[0]); - if (!write) { - throw std::invalid_argument(K_CONST_ERROR_INVLAID_PARAM); - } - - int serverAddress = args[1]->Int32Value(context).FromJust(); - auto* reply = (*self)->sendWriteRequest(**write, serverAddress); - if (reply) - args.GetReturnValue().Set(ModbusReply::New2(isolate, reply)); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbusdataunit_implement.h b/v8/include/modules/serialbus/qmodbusdataunit_implement.h deleted file mode 100644 index 40fdec4..0000000 --- a/v8/include/modules/serialbus/qmodbusdataunit_implement.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbusdataunit_p.h" -#include "qmodbusdataunit_wrapper.h" - -namespace shelllet { - namespace serialbus { - class ModbusDataUnit : public QModbusDataUnitWrapper - { - public: - using ReturnType = QModbusDataUnitPrivate; - using ReturnType2 = QModbusDataUnitPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - v8::Isolate* isolate = args.GetIsolate(); - if (args[0]->IsExternal()) { - void* p = args[0].As()->Value(); - if (p) - return new ReturnType(isolate, args.This(), *static_cast(p)); - } - QModbusDataUnit::RegisterType type = static_cast(args[0]->Int32Value(isolate->GetCurrentContext()).FromJust()); - if (args.Length() == 1) { - return new ReturnType(isolate, args.This(), type); - } - else { - int address = args[1]->Int32Value(isolate->GetCurrentContext()).FromJust(); - if (args[2]->IsInt32Array()) { - std::vector t = ToArray(isolate, args[2]); - return new ReturnType(isolate, args.This(), type, address, QVector::fromStdVector(t)); - } - else { - int size = args[2]->Int32Value(isolate->GetCurrentContext()).FromJust(); - return new ReturnType(isolate, args.This(), type, address, size); - } - } - - return new ReturnType(isolate, args.This()); - } - - ModbusDataUnit(const v8::FunctionCallbackInfo& args) :QModbusDataUnitWrapper(*Private(args), args) - { - } - ModbusDataUnit(QModbusDataUnit* p, const v8::FunctionCallbackInfo& args) : QModbusDataUnitWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusDataUnit(v8::Isolate* isolate, const v8::Local& tpl) : QModbusDataUnitWrapper(isolate, tpl) {} - ModbusDataUnit(v8::Isolate* isolate, const v8::Local& proto) : QModbusDataUnitWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusDataUnit"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusdataunit_p.h b/v8/include/modules/serialbus/qmodbusdataunit_p.h deleted file mode 100644 index 4c94a87..0000000 --- a/v8/include/modules/serialbus/qmodbusdataunit_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace serialbus { - template - class QModbusDataUnitPrivate : public ObjectPrivate - { - public: - template - QModbusDataUnitPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusdataunit_wrapper.h b/v8/include/modules/serialbus/qmodbusdataunit_wrapper.h deleted file mode 100644 index 1ade91d..0000000 --- a/v8/include/modules/serialbus/qmodbusdataunit_wrapper.h +++ /dev/null @@ -1,179 +0,0 @@ -#pragma once - -namespace shelllet { - namespace serialbus { - template class QModbusDataUnitPrivate; - template - class QModbusDataUnitWrapper : public ObjectWrapper - { - public: - template - QModbusDataUnitWrapper(QModbusDataUnitPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QModbusDataUnitWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) { - auto registerType = v8::FunctionTemplate::New(isolate); - registerType->Set(isolate, "Invalid", v8::Int32::New(isolate, QModbusDataUnit::Invalid)); - registerType->Set(isolate, "DiscreteInputs", v8::Int32::New(isolate, QModbusDataUnit::DiscreteInputs)); - registerType->Set(isolate, "Coils", v8::Int32::New(isolate, QModbusDataUnit::Coils)); - registerType->Set(isolate, "InputRegisters", v8::Int32::New(isolate, QModbusDataUnit::InputRegisters)); - registerType->Set(isolate, "HoldingRegisters", v8::Int32::New(isolate, QModbusDataUnit::HoldingRegisters)); - tpl->Set(isolate, "RegisterType", registerType); - } - QModbusDataUnitWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "isValid", v8::FunctionTemplate::New(isolate, IsValid)); - proto->Set(isolate, "registerType", v8::FunctionTemplate::New(isolate, RegisterType)); - proto->Set(isolate, "startAddress", v8::FunctionTemplate::New(isolate, StartAddress)); - proto->Set(isolate, "valueCount", v8::FunctionTemplate::New(isolate, ValueCount)); - proto->Set(isolate, "values", v8::FunctionTemplate::New(isolate, Values)); - proto->Set(isolate, "setRegisterType", v8::FunctionTemplate::New(isolate, SetRegisterType)); - proto->Set(isolate, "setStartAddress", v8::FunctionTemplate::New(isolate, SetStartAddress)); - proto->Set(isolate, "setValue", v8::FunctionTemplate::New(isolate, SetValue)); - proto->Set(isolate, "setValueCount", v8::FunctionTemplate::New(isolate, SetValueCount)); - proto->Set(isolate, "setValues", v8::FunctionTemplate::New(isolate, SetValues)); - proto->Set(isolate, "value", v8::FunctionTemplate::New(isolate, Value)); - } - - protected: - static void IsValid(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set((*self)->isValid()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RegisterType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - args.GetReturnValue().Set(v8::Int32::New(isolate, (*self)->registerType())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StartAddress(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - args.GetReturnValue().Set(v8::Int32::New(isolate, (*self)->startAddress())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ValueCount(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - args.GetReturnValue().Set(v8::Uint32::New(isolate, (*self)->valueCount())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Values(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetRegisterType(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - QModbusDataUnit::RegisterType type = static_cast(args[0]->Int32Value(context).FromJust()); - (*self)->setRegisterType(type); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetStartAddress(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - int address = args[0]->Int32Value(context).FromJust(); - (*self)->setStartAddress(address); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetValue(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - int index = args[0]->Int32Value(context).FromJust(); - quint16 value = args[1]->Uint32Value(context).FromJust(); - (*self)->setValue(index, value); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetValueCount(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - uint newCount = args[0]->Uint32Value(context).FromJust(); - (*self)->setValueCount(newCount); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetValues(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Value(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - int index = args[0]->Int32Value(context).FromJust(); - args.GetReturnValue().Set(v8::Uint32::New(isolate, (*self)->value(index))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbusdevice_implement.h b/v8/include/modules/serialbus/qmodbusdevice_implement.h deleted file mode 100644 index fd43245..0000000 --- a/v8/include/modules/serialbus/qmodbusdevice_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbusdevice_p.h" -#include "qmodbusdevice_wrapper.h" - -namespace shelllet { - namespace serialbus { - class ModbusDevice : public QModbusDeviceWrapper - { - public: - using ReturnType = QModbusDevicePrivate; - using ReturnType2 = QModbusDevicePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - ModbusDevice(const v8::FunctionCallbackInfo& args) :QModbusDeviceWrapper(*Private(args), args) - { - } - ModbusDevice(QModbusDevice* p, const v8::FunctionCallbackInfo& args) : QModbusDeviceWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusDevice(v8::Isolate* isolate, const v8::Local& tpl) : QModbusDeviceWrapper(isolate, tpl) {} - ModbusDevice(v8::Isolate* isolate, const v8::Local& proto) : QModbusDeviceWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusDevice"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusdevice_p.h b/v8/include/modules/serialbus/qmodbusdevice_p.h deleted file mode 100644 index 099dcc6..0000000 --- a/v8/include/modules/serialbus/qmodbusdevice_p.h +++ /dev/null @@ -1,73 +0,0 @@ -#pragma once -#include "core/qobject_p.h" -namespace shelllet { - namespace serialbus { - template - class QModbusDevicePrivate : public QObjectPrivate - { - public: - template - QModbusDevicePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - - protected: - // template::value>::type> - bool open() { - if (hasOwnProperty(strrchr(__FUNCTION__, ':') + 1)) { - //v8::Isolate* isolate = v8::Isolate::GetCurrent(); - - //V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - - /*v8::Local o = object.Get(isolate); - v8::Local proto = o->GetPrototype()->ToObject(context).ToLocalChecked(); - - v8::Local value = proto->Get(context, V8_NEW_STRING_VAR(isolate, __FUNCTION__)).ToLocalChecked(); - - auto f = v8::Local::Cast(value); - - v8::Local res = f->CallAsFunction(context, o, 0, {}).ToLocalChecked();*/ - - v8::Local value = call(__FUNCTION__); - - return value->BooleanValue(v8::Isolate::GetCurrent()); - - //V8_CREATE_LOCAL_CONTEXT_END_WITH_RETURN(false) - } - if constexpr (std::is_abstract::value) - throw std::logic_error("The method or operation is not implemented."); - else { - return T::open(); - } - } - // template::value>::type> - void close() { - const char* name = strrchr(__FUNCTION__, ':') + 1; - if (hasOwnProperty(name)) { - //v8::Isolate* isolate = v8::Isolate::GetCurrent(); - - //V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_ISOLATE(isolate) - - /*v8::Local o = object.Get(isolate); - v8::Local proto = o->GetPrototype()->ToObject(context).ToLocalChecked(); - - v8::Local value = proto->Get(context, V8_NEW_STRING_VAR(isolate, __FUNCTION__)).ToLocalChecked(); - - auto f = v8::Local::Cast(value); - - v8::Local res = f->CallAsFunction(context, o, 0, {}).ToLocalChecked();*/ - - v8::Local value = call(name); - - value->BooleanValue(v8::Isolate::GetCurrent()); - - //V8_CREATE_LOCAL_CONTEXT_END_WITH_RETURN(false) - } - if constexpr (std::is_abstract::value) - throw std::logic_error("The method or operation is not implemented."); - else { - T::close(); - } - } - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusdevice_wrapper.h b/v8/include/modules/serialbus/qmodbusdevice_wrapper.h deleted file mode 100644 index cf76692..0000000 --- a/v8/include/modules/serialbus/qmodbusdevice_wrapper.h +++ /dev/null @@ -1,192 +0,0 @@ -#pragma once -#include "core/qobject_wrapper.h" -namespace shelllet { - namespace serialbus { - template class QModbusDevicePrivate; - template - class QModbusDeviceWrapper : public QObjectWrapper - { - public: - template - QModbusDeviceWrapper(QModbusDevicePrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - QModbusDeviceWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) { - auto connectionParameter = v8::FunctionTemplate::New(isolate); - connectionParameter->Set(isolate, "SerialPortNameParameter", v8::Int32::New(isolate, QModbusDevice::SerialPortNameParameter)); - connectionParameter->Set(isolate, "SerialParityParameter", v8::Int32::New(isolate, QModbusDevice::SerialParityParameter)); - connectionParameter->Set(isolate, "SerialBaudRateParameter", v8::Int32::New(isolate, QModbusDevice::SerialBaudRateParameter)); - connectionParameter->Set(isolate, "SerialDataBitsParameter", v8::Int32::New(isolate, QModbusDevice::SerialDataBitsParameter)); - connectionParameter->Set(isolate, "SerialStopBitsParameter", v8::Int32::New(isolate, QModbusDevice::SerialStopBitsParameter)); - connectionParameter->Set(isolate, "NetworkPortParameter", v8::Int32::New(isolate, QModbusDevice::NetworkPortParameter)); - connectionParameter->Set(isolate, "NetworkAddressParameter", v8::Int32::New(isolate, QModbusDevice::NetworkAddressParameter)); - tpl->Set(isolate, "ConnectionParameter", connectionParameter); - - auto error = v8::FunctionTemplate::New(isolate); - error->Set(isolate, "NoError", v8::Int32::New(isolate, QModbusDevice::NoError)); - error->Set(isolate, "ReadError", v8::Int32::New(isolate, QModbusDevice::ReadError)); - error->Set(isolate, "WriteError", v8::Int32::New(isolate, QModbusDevice::WriteError)); - error->Set(isolate, "ConnectionError", v8::Int32::New(isolate, QModbusDevice::ConnectionError)); - error->Set(isolate, "ConfigurationError", v8::Int32::New(isolate, QModbusDevice::ConfigurationError)); - error->Set(isolate, "TimeoutError", v8::Int32::New(isolate, QModbusDevice::TimeoutError)); - error->Set(isolate, "ProtocolError", v8::Int32::New(isolate, QModbusDevice::ProtocolError)); - error->Set(isolate, "ReplyAbortedError", v8::Int32::New(isolate, QModbusDevice::ReplyAbortedError)); - error->Set(isolate, "UnknownError", v8::Int32::New(isolate, QModbusDevice::UnknownError)); - tpl->Set(isolate, "Error", error); - - auto state = v8::FunctionTemplate::New(isolate); - state->Set(isolate, "UnconnectedState", v8::Int32::New(isolate, QModbusDevice::UnconnectedState)); - state->Set(isolate, "ConnectingState", v8::Int32::New(isolate, QModbusDevice::ConnectingState)); - state->Set(isolate, "ConnectedState", v8::Int32::New(isolate, QModbusDevice::ConnectedState)); - state->Set(isolate, "ClosingState", v8::Int32::New(isolate, QModbusDevice::ClosingState)); - tpl->Set(isolate, "State", state); - } - QModbusDeviceWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) - { - proto->Set(isolate, "setConnectionParameter", v8::FunctionTemplate::New(isolate, SetConnectionParameter)); - proto->Set(isolate, "connectDevice", v8::FunctionTemplate::New(isolate, ConnectDevice)); - proto->Set(isolate, "disconnectDevice", v8::FunctionTemplate::New(isolate, DisconnectDevice)); - proto->Set(isolate, "errorString", v8::FunctionTemplate::New(isolate, ErrorString)); - proto->Set(isolate, "state", v8::FunctionTemplate::New(isolate, State)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "errorOccurred"), nullptr, ErrorOccurred); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "stateChanged"), nullptr, StateChanged); - } - - protected: - static void ErrorString(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - throw std::domain_error(K_CONST_ERROR_CALLED); - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, (*p)->errorString().toUtf8().constData())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void ConnectDevice(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - throw std::domain_error(K_CONST_ERROR_CALLED); - args.GetReturnValue().Set((*p)->connectDevice()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void DisconnectDevice(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - throw std::domain_error(K_CONST_ERROR_CALLED); - (*p)->disconnectDevice(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetConnectionParameter(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - throw std::domain_error(K_CONST_ERROR_CALLED); - int parameter = args[0]->Int32Value(context).FromJust(); - QVariant value; - if (args[1]->IsNumber()) { - value = args[1]->Int32Value(context).FromJust(); - } - else { - value = QString::fromStdString(ToString({ isolate, args[1] })); - } - (*p)->setConnectionParameter(parameter, value); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void State(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set(v8::Int32::New(isolate, (*p)->state())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ErrorOccurred(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weak_persistent = std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(*self, &QModbusDevice::errorOccurred, [isolate, weak_persistent](QModbusDevice::Error error) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, error) }; - weak_persistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(*self, &QModbusDevice::errorOccurred, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void StateChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weak_persistent = std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(*self, &QModbusDevice::stateChanged, [isolate, weak_persistent](QModbusDevice::State state) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, state) }; - weak_persistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(*self, &QModbusDevice::stateChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbuspdu_implement.h b/v8/include/modules/serialbus/qmodbuspdu_implement.h deleted file mode 100644 index f89c68f..0000000 --- a/v8/include/modules/serialbus/qmodbuspdu_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbuspdu_p.h" -#include "qmodbuspdu_wrapper.h" - -namespace shelllet { - namespace serialbus { - class ModbusPdu : public QModbusPduWrapper - { - public: - using ReturnType = QModbusPduPrivate; - using ReturnType2 = QModbusPduPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - ModbusPdu(const v8::FunctionCallbackInfo& args) :QModbusPduWrapper(*Private(args), args) - { - } - ModbusPdu(QModbusPdu* p, const v8::FunctionCallbackInfo& args) : QModbusPduWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusPdu(v8::Isolate* isolate, const v8::Local& tpl) : QModbusPduWrapper(isolate, tpl) {} - ModbusPdu(v8::Isolate* isolate, const v8::Local& proto) : QModbusPduWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusPdu"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbuspdu_p.h b/v8/include/modules/serialbus/qmodbuspdu_p.h deleted file mode 100644 index e91f77e..0000000 --- a/v8/include/modules/serialbus/qmodbuspdu_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace serialbus { - template - class QModbusPduPrivate : public ObjectPrivate - { - public: - template - QModbusPduPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbuspdu_wrapper.h b/v8/include/modules/serialbus/qmodbuspdu_wrapper.h deleted file mode 100644 index 181e2a3..0000000 --- a/v8/include/modules/serialbus/qmodbuspdu_wrapper.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -namespace shelllet { - namespace serialbus { - template class QModbusPduPrivate; - template - class QModbusPduWrapper : public ObjectWrapper - { - public: - - template - QModbusPduWrapper(QModbusPduPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QModbusPduWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) { - tpl->Set(isolate, "log", v8::FunctionTemplate::New(isolate, Print)); - } - QModbusPduWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - } - - protected: - static void Print(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Get(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Set(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbusreply_implement.h b/v8/include/modules/serialbus/qmodbusreply_implement.h deleted file mode 100644 index e6dd013..0000000 --- a/v8/include/modules/serialbus/qmodbusreply_implement.h +++ /dev/null @@ -1,37 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbusreply_p.h" -#include "qmodbusreply_wrapper.h" - -namespace shelllet { - namespace serialbus { - //template - class ModbusReply : public QModbusReplyWrapper - { - using ReturnType = QModbusReplyPrivate; - using ReturnType2 = QModbusReplyPrivate; - public: - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - QModbusReply::ReplyType type = static_cast(args[0]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust()); - int serverAddress = args[1]->Int32Value(args.GetIsolate()->GetCurrentContext()).FromJust(); - return new ReturnType(args.GetIsolate(), args.This(), type, serverAddress); - } - - ModbusReply(const v8::FunctionCallbackInfo& args) :QModbusReplyWrapper(*Private(args), args) - { - } - - ModbusReply(QModbusReply* p, const v8::FunctionCallbackInfo& args) : QModbusReplyWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusReply(v8::Isolate* isolate, const v8::Local& tpl) : QModbusReplyWrapper(isolate, tpl) {} - ModbusReply(v8::Isolate* isolate, const v8::Local& proto) : QModbusReplyWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusReply"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusreply_p.h b/v8/include/modules/serialbus/qmodbusreply_p.h deleted file mode 100644 index e1d8d21..0000000 --- a/v8/include/modules/serialbus/qmodbusreply_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "core/qobject_p.h" -namespace shelllet { - namespace serialbus { - template - class QModbusReplyPrivate : public QObjectPrivate - { - public: - template - QModbusReplyPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args) ...) { - } - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusreply_wrapper.h b/v8/include/modules/serialbus/qmodbusreply_wrapper.h deleted file mode 100644 index 1db6cb1..0000000 --- a/v8/include/modules/serialbus/qmodbusreply_wrapper.h +++ /dev/null @@ -1,179 +0,0 @@ -#pragma once -#include "core/qobject_wrapper.h" -namespace shelllet { - namespace serialbus { - template class QModbusReplyPrivate; - template - class QModbusReplyWrapper : public QObjectWrapper - { - public: - template - QModbusReplyWrapper(QModbusReplyPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - QModbusReplyWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QModbusReplyWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) - { - proto->Set(isolate, "error", v8::FunctionTemplate::New(isolate, Error)); - proto->Set(isolate, "errorString", v8::FunctionTemplate::New(isolate, ErrorString)); - proto->Set(isolate, "isFinished", v8::FunctionTemplate::New(isolate, IsFinished)); - proto->Set(isolate, "rawResult", v8::FunctionTemplate::New(isolate, RawResult)); - proto->Set(isolate, "result", v8::FunctionTemplate::New(isolate, Result)); - proto->Set(isolate, "serverAddress", v8::FunctionTemplate::New(isolate, ServerAddress)); - proto->Set(isolate, "type", v8::FunctionTemplate::New(isolate, Type)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "errorOccurred"), nullptr, ErrorOccurred); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "finished"), nullptr, Finished); - } - - protected: - static void Error(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - args.GetReturnValue().Set(static_cast((*self)->error())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ErrorString(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set(V8_NEW_STRING_VAR(isolate, (*self)->errorString().toUtf8().constData())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsFinished(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set((*self)->isFinished()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RawResult(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - // QModbusResponse t = (*self)->rawResult(); - // args.GetReturnValue().Set(ModbusResponse::New(isolate, )) - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Result(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set(ModbusDataUnit::New(isolate, v8::External::New(isolate, &(*self)->result()))); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ServerAddress(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set(v8::Int32::New(isolate, (*self)->serverAddress())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Type(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set(static_cast((*self)->type())); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ErrorOccurred(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - std::shared_ptr>weakPersistent = std::make_shared>(isolate, v8::Local::Cast(value)); - QObject::connect(*self, &QModbusReply::errorOccurred, [isolate, weakPersistent](QModbusDevice::Error error) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, static_cast(error)) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(*self, &QModbusReply::errorOccurred, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Finished(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - std::shared_ptr>weakPersistent = std::make_shared>(isolate, v8::Local::Cast(value)); - QObject::connect(*self, &QModbusReply::finished, [isolate, weakPersistent]() { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), 0, {}); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(*self, &QModbusReply::finished, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbusrequest_implement.h b/v8/include/modules/serialbus/qmodbusrequest_implement.h deleted file mode 100644 index 08d3e4f..0000000 --- a/v8/include/modules/serialbus/qmodbusrequest_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbusrequest_p.h" -#include "qmodbusrequest_wrapper.h" - -namespace shelllet { - namespace serialbus { - class ModbusRequest : public QModbusRequestWrapper - { - public: - using ReturnType = QModbusRequestPrivate; - using ReturnType2 = QModbusRequestPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - ModbusRequest(const v8::FunctionCallbackInfo& args) :QModbusRequestWrapper(*Private(args), args) - { - } - ModbusRequest(QModbusRequest* p, const v8::FunctionCallbackInfo& args) : QModbusRequestWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusRequest(v8::Isolate* isolate, const v8::Local& tpl) : QModbusRequestWrapper(isolate, tpl) {} - ModbusRequest(v8::Isolate* isolate, const v8::Local& proto) : QModbusRequestWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusRequest"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusrequest_p.h b/v8/include/modules/serialbus/qmodbusrequest_p.h deleted file mode 100644 index efaed04..0000000 --- a/v8/include/modules/serialbus/qmodbusrequest_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "qmodbuspdu_p.h" -namespace shelllet { - namespace serialbus { - template - class QModbusRequestPrivate : public QModbusPduPrivate - { - public: - template - QModbusRequestPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QModbusPduPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusrequest_wrapper.h b/v8/include/modules/serialbus/qmodbusrequest_wrapper.h deleted file mode 100644 index 2e8d5d3..0000000 --- a/v8/include/modules/serialbus/qmodbusrequest_wrapper.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -#include "qmodbuspdu_wrapper.h" -namespace shelllet { - namespace serialbus { - template class QModbusRequestPrivate; - template - class QModbusRequestWrapper : public QModbusPduWrapper - { - public: - - template - QModbusRequestWrapper(QModbusRequestPrivate& d, const v8::FunctionCallbackInfo& args) - : QModbusPduWrapper(d, args) { - } - QModbusRequestWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QModbusPduWrapper(isolate, tpl) {} - QModbusRequestWrapper(v8::Isolate* isolate, const v8::Local& proto) : QModbusPduWrapper(isolate, proto) - { - //tpl->Set(isolate, "log", v8::FunctionTemplate::New(isolate, Print)); - } - - protected: - static void Print(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Get(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Set(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbusresponse_implement.h b/v8/include/modules/serialbus/qmodbusresponse_implement.h deleted file mode 100644 index 3a2383e..0000000 --- a/v8/include/modules/serialbus/qmodbusresponse_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbusresponse_p.h" -#include "qmodbusresponse_wrapper.h" - -namespace shelllet { - namespace serialbus { - class ModbusResponse : public QModbusResponseWrapper - { - public: - using ReturnType = QModbusResponsePrivate; - using ReturnType2 = QModbusResponsePrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - ModbusResponse(const v8::FunctionCallbackInfo& args) :QModbusResponseWrapper(*Private(args), args) - { - } - ModbusResponse(QModbusResponse* p, const v8::FunctionCallbackInfo& args) : QModbusResponseWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusResponse(v8::Isolate* isolate, const v8::Local& tpl) : QModbusResponseWrapper(isolate, tpl) {} - ModbusResponse(v8::Isolate* isolate, const v8::Local& proto) : QModbusResponseWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusResponse"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusresponse_p.h b/v8/include/modules/serialbus/qmodbusresponse_p.h deleted file mode 100644 index c039607..0000000 --- a/v8/include/modules/serialbus/qmodbusresponse_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "qmodbuspdu_p.h" -namespace shelllet { - namespace serialbus { - template - class QModbusResponsePrivate : public QModbusPduPrivate - { - public: - template - QModbusResponsePrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QModbusPduPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbusresponse_wrapper.h b/v8/include/modules/serialbus/qmodbusresponse_wrapper.h deleted file mode 100644 index 413380f..0000000 --- a/v8/include/modules/serialbus/qmodbusresponse_wrapper.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -#include "qmodbuspdu_wrapper.h" -namespace shelllet { - namespace serialbus { - template class QModbusResponsePrivate; - template - class QModbusResponseWrapper : public QModbusPduWrapper - { - public: - - template - QModbusResponseWrapper(QModbusResponsePrivate& d, const v8::FunctionCallbackInfo& args) - : QModbusPduWrapper(d, args) { - } - QModbusResponseWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QModbusPduWrapper(isolate, tpl) {} - QModbusResponseWrapper(v8::Isolate* isolate, const v8::Local& proto) : QModbusPduWrapper(isolate, proto) - { - //tpl->Set(isolate, "log", v8::FunctionTemplate::New(isolate, Print)); - } - - protected: - static void Print(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Get(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Set(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialbus/qmodbustcpclient_implement.h b/v8/include/modules/serialbus/qmodbustcpclient_implement.h deleted file mode 100644 index ae60774..0000000 --- a/v8/include/modules/serialbus/qmodbustcpclient_implement.h +++ /dev/null @@ -1,32 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmodbustcpclient_p.h" -#include "qmodbustcpclient_wrapper.h" - -namespace shelllet { - namespace serialbus { - class ModbusTcpClient : public QModbusTcpClientWrapper - { - public: - using ReturnType = QModbusTcpClientPrivate; - using ReturnType2 = QModbusTcpClientPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - ModbusTcpClient(const v8::FunctionCallbackInfo& args) :QModbusTcpClientWrapper(*Private(args), args) - { - } - ModbusTcpClient(QModbusTcpClient* p, const v8::FunctionCallbackInfo& args) : QModbusTcpClientWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - ModbusTcpClient(v8::Isolate* isolate, const v8::Local& tpl) : QModbusTcpClientWrapper(isolate, tpl) {} - ModbusTcpClient(v8::Isolate* isolate, const v8::Local& proto) : QModbusTcpClientWrapper(isolate, proto) - {} - - static const char* Name() { return "ModbusTcpClient"; } - protected: - virtual void toString(std::stringstream& ss) const {} - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbustcpclient_p.h b/v8/include/modules/serialbus/qmodbustcpclient_p.h deleted file mode 100644 index 53f7f3b..0000000 --- a/v8/include/modules/serialbus/qmodbustcpclient_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "qmodbusclient_p.h" -namespace shelllet { - namespace serialbus { - template - class QModbusTcpClientPrivate : public QModbusClientPrivate - { - public: - template - QModbusTcpClientPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QModbusClientPrivate(isolate, obj, std::forward(args)...) { - } - protected: - }; - } -} diff --git a/v8/include/modules/serialbus/qmodbustcpclient_wrapper.h b/v8/include/modules/serialbus/qmodbustcpclient_wrapper.h deleted file mode 100644 index 1109da7..0000000 --- a/v8/include/modules/serialbus/qmodbustcpclient_wrapper.h +++ /dev/null @@ -1,46 +0,0 @@ -#pragma once -#include "qmodbusclient_wrapper.h" -namespace shelllet { - namespace serialbus { - template class QModbusTcpClientPrivate; - template - class QModbusTcpClientWrapper : public QModbusClientWrapper - { - public: - - template - QModbusTcpClientWrapper(QModbusTcpClientPrivate& d, const v8::FunctionCallbackInfo& args) - : QModbusClientWrapper(d, args) { - } - QModbusTcpClientWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QModbusClientWrapper(isolate, tpl) {} - QModbusTcpClientWrapper(v8::Isolate* isolate, const v8::Local& proto) : QModbusClientWrapper(isolate, proto) - { - //tpl->Set(isolate, "log", v8::FunctionTemplate::New(isolate, Print)); - } - - protected: - static void Print(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Get(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Set(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/serialport/initialize.h b/v8/include/modules/serialport/initialize.h deleted file mode 100644 index b79811e..0000000 --- a/v8/include/modules/serialport/initialize.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "framework.h" - - -namespace shelllet { - namespace qtserialport { - void initialize(v8::Isolate* isolate, const v8::Local& proto) { - using namespace shelllet::core; - - - } - - } -} \ No newline at end of file diff --git a/v8/include/modules/serialport/qserialport_implement.h b/v8/include/modules/serialport/qserialport_implement.h deleted file mode 100644 index ad058df..0000000 --- a/v8/include/modules/serialport/qserialport_implement.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "device_module.h" -#include "qserialport_p.h" -#include "qserialport_wrapper.h" - -namespace shelllet { - namespace device { - class SerialPort : public QSerialPortWrapper - { - public: - SerialPort(const v8::FunctionCallbackInfo& args); - SerialPort(v8::Isolate* isolate, const v8::Local& tpl); - - static const char* Name(); - - public: - }; - } -} diff --git a/v8/include/modules/serialport/qserialport_p.h b/v8/include/modules/serialport/qserialport_p.h deleted file mode 100644 index 86fd40f..0000000 --- a/v8/include/modules/serialport/qserialport_p.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once -#include "qiodevice_p.h" - -namespace shelllet::device { - template - class QSerialPortPrivate : public core::QIODevicePrivate - { - public: - template - QSerialPortPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QIODevicePrivate(isolate, obj, std::forward(args)...) { - } - - - }; -} diff --git a/v8/include/modules/serialport/qserialport_wrapper.h b/v8/include/modules/serialport/qserialport_wrapper.h deleted file mode 100644 index 794440c..0000000 --- a/v8/include/modules/serialport/qserialport_wrapper.h +++ /dev/null @@ -1,1006 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qiodevice_wrapper.h" -#include "qserialportinfo_implement.h" -namespace shelllet { - namespace device { - template class QSerialPortPrivate; - template - class QSerialPortWrapper : public core::QIODeviceWrapper - { - public: - template - QSerialPortWrapper(QSerialPortPrivate& d, const v8::FunctionCallbackInfo& args) - : QIODeviceWrapper(d, args) { - } - QSerialPortWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QIODeviceWrapper(isolate, tpl) {} - QSerialPortWrapper(v8::Isolate* isolate, const v8::Local& proto) : QIODeviceWrapper(isolate, proto) { - { - /*tpl->Set(isolate, "atEnd", v8::FunctionTemplate::New(isolate, AtEnd)); - tpl->PrototypeTemplate()->Set(isolate, "bytesAvailable", v8::FunctionTemplate::New(isolate, BytesAvailable)); - tpl->PrototypeTemplate()->Set(isolate, "bytesToWrite", v8::FunctionTemplate::New(isolate, BytesToWrite)); - tpl->PrototypeTemplate()->Set(isolate, "canReadLine", v8::FunctionTemplate::New(isolate, CanReadLine));*/ - tpl->PrototypeTemplate()->Set(isolate, "clear", v8::FunctionTemplate::New(isolate, Clear)); - tpl->PrototypeTemplate()->Set(isolate, "clearError", v8::FunctionTemplate::New(isolate, ClearError)); - //tpl->PrototypeTemplate()->Set(isolate, "close", v8::FunctionTemplate::New(isolate, Close)); - tpl->PrototypeTemplate()->Set(isolate, "flush", v8::FunctionTemplate::New(isolate, Flush)); - tpl->PrototypeTemplate()->Set(isolate, "handle", v8::FunctionTemplate::New(isolate, Handle)); - //tpl->PrototypeTemplate()->Set(isolate, "isSequential", v8::FunctionTemplate::New(isolate, IsSequential)); - //tpl->PrototypeTemplate()->Set(isolate, "open", v8::FunctionTemplate::New(isolate, Open)); - tpl->PrototypeTemplate()->Set(isolate, "pinoutSignals", v8::FunctionTemplate::New(isolate, PinoutSignals)); - tpl->PrototypeTemplate()->Set(isolate, "readBufferSize", v8::FunctionTemplate::New(isolate, ReadBufferSize)); - tpl->PrototypeTemplate()->Set(isolate, "setPort", v8::FunctionTemplate::New(isolate, SetPort)); - tpl->PrototypeTemplate()->Set(isolate, "setReadBufferSize", v8::FunctionTemplate::New(isolate, SetReadBufferSize)); - //tpl->PrototypeTemplate()->Set(isolate, "waitForBytesWritten", v8::FunctionTemplate::New(isolate, WaitForBytesWritten)); - //tpl->PrototypeTemplate()->Set(isolate, "waitForReadyRead", v8::FunctionTemplate::New(isolate, WaitForReadyRead)); - tpl->PrototypeTemplate()->Set(isolate, "baudRate", v8::FunctionTemplate::New(isolate, BaudRate)); - tpl->PrototypeTemplate()->Set(isolate, "setBaudRate", v8::FunctionTemplate::New(isolate, SetBaudRate)); - - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "portName"), PortName, SetPortName); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "dataBits"), DataBits, SetDataBits); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "parity"), Parity, SetParity); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "stopBits"), StopBits, SetStopBits); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "flowControl"), FlowControl, SetFlowControl); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "dataTerminalReady"), IsDataTerminalReady, SetDataTerminalReady); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "requestToSend"), IsRequestToSend, SetRequestToSend); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "breakEnabled"), IsBreakEnabled, SetBreakEnabled); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "error"), Error, nullptr); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "baudRateChanged"), nullptr, BaudRateChanged); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "breakEnabledChanged"), nullptr, BreakEnabledChanged); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "dataBitsChanged"), nullptr, DataBitsChanged); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "dataTerminalReadyChanged"), nullptr, DataTerminalReadyChanged); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "errorOccurred"), nullptr, ErrorOccurred); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "flowControlChanged"), nullptr, FlowControlChanged); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "parityChanged"), nullptr, ParityChanged); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "requestToSendChanged"), nullptr, RequestToSendChanged); - tpl->PrototypeTemplate()->SetAccessor(V8_NEW_STRING_VAR(isolate, "stopBitsChanged"), nullptr, StopBitsChanged); - } - { - v8::Local direction = v8::ObjectTemplate::New(isolate); - direction->Set(isolate, "Input", v8::Int32::New(isolate, QSerialPort::Direction::Input)); - direction->Set(isolate, "Output", v8::Int32::New(isolate, QSerialPort::Direction::Output)); - direction->Set(isolate, "AllDirections", v8::Int32::New(isolate, QSerialPort::Direction::AllDirections)); - tpl->Set(isolate, "Direction", direction); - - v8::Local baudRate = v8::ObjectTemplate::New(isolate); - baudRate->Set(isolate, "Baud1200", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud1200)); - baudRate->Set(isolate, "Baud2400", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud2400)); - baudRate->Set(isolate, "Baud4800", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud4800)); - baudRate->Set(isolate, "Baud9600", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud9600)); - baudRate->Set(isolate, "Baud19200", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud19200)); - baudRate->Set(isolate, "Baud38400", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud38400)); - baudRate->Set(isolate, "Baud57600", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud57600)); - baudRate->Set(isolate, "Baud115200", v8::Int32::New(isolate, QSerialPort::BaudRate::Baud115200)); - tpl->Set(isolate, "BaudRate", baudRate); - - v8::Local dataBits = v8::ObjectTemplate::New(isolate); - dataBits->Set(isolate, "Data5", v8::Int32::New(isolate, QSerialPort::DataBits::Data5)); - dataBits->Set(isolate, "Data6", v8::Int32::New(isolate, QSerialPort::DataBits::Data6)); - dataBits->Set(isolate, "Data7", v8::Int32::New(isolate, QSerialPort::DataBits::Data7)); - dataBits->Set(isolate, "Data8", v8::Int32::New(isolate, QSerialPort::DataBits::Data8)); - tpl->Set(isolate, "DataBits", dataBits); - - v8::Local parity = v8::ObjectTemplate::New(isolate); - parity->Set(isolate, "NoParity", v8::Int32::New(isolate, QSerialPort::Parity::NoParity)); - parity->Set(isolate, "EvenParity", v8::Int32::New(isolate, QSerialPort::Parity::EvenParity)); - parity->Set(isolate, "OddParity", v8::Int32::New(isolate, QSerialPort::Parity::OddParity)); - parity->Set(isolate, "SpaceParity", v8::Int32::New(isolate, QSerialPort::Parity::SpaceParity)); - parity->Set(isolate, "MarkParity", v8::Int32::New(isolate, QSerialPort::Parity::MarkParity)); - tpl->Set(isolate, "Parity", parity); - - v8::Local stopBits = v8::ObjectTemplate::New(isolate); - stopBits->Set(isolate, "OneStop", v8::Int32::New(isolate, QSerialPort::StopBits::OneStop)); - stopBits->Set(isolate, "OneAndHalfStop", v8::Int32::New(isolate, QSerialPort::StopBits::OneAndHalfStop)); - stopBits->Set(isolate, "TwoStop", v8::Int32::New(isolate, QSerialPort::StopBits::TwoStop)); - tpl->Set(isolate, "StopBits", stopBits); - - v8::Local flowControl = v8::ObjectTemplate::New(isolate); - flowControl->Set(isolate, "NoFlowControl", v8::Int32::New(isolate, QSerialPort::FlowControl::NoFlowControl)); - flowControl->Set(isolate, "HardwareControl", v8::Int32::New(isolate, QSerialPort::FlowControl::HardwareControl)); - flowControl->Set(isolate, "SoftwareControl", v8::Int32::New(isolate, QSerialPort::FlowControl::SoftwareControl)); - tpl->Set(isolate, "FlowControl", flowControl); - - v8::Local pinoutSignal = v8::ObjectTemplate::New(isolate); - pinoutSignal->Set(isolate, "NoSignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::NoSignal)); - pinoutSignal->Set(isolate, "DataTerminalReadySignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::DataTerminalReadySignal)); - pinoutSignal->Set(isolate, "DataCarrierDetectSignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::DataCarrierDetectSignal)); - pinoutSignal->Set(isolate, "DataSetReadySignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::DataSetReadySignal)); - pinoutSignal->Set(isolate, "RingIndicatorSignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::RingIndicatorSignal)); - pinoutSignal->Set(isolate, "RequestToSendSignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::RequestToSendSignal)); - pinoutSignal->Set(isolate, "ClearToSendSignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::ClearToSendSignal)); - pinoutSignal->Set(isolate, "SecondaryTransmittedDataSignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::SecondaryTransmittedDataSignal)); - pinoutSignal->Set(isolate, "SecondaryReceivedDataSignal", v8::Int32::New(isolate, QSerialPort::PinoutSignal::SecondaryReceivedDataSignal)); - tpl->Set(isolate, "PinoutSignal", pinoutSignal); - - v8::Local serialPortError = v8::ObjectTemplate::New(isolate); - serialPortError->Set(isolate, "NoError", v8::Int32::New(isolate, QSerialPort::SerialPortError::NoError)); - serialPortError->Set(isolate, "DeviceNotFoundError", v8::Int32::New(isolate, QSerialPort::SerialPortError::DeviceNotFoundError)); - serialPortError->Set(isolate, "PermissionError", v8::Int32::New(isolate, QSerialPort::SerialPortError::PermissionError)); - serialPortError->Set(isolate, "OpenError", v8::Int32::New(isolate, QSerialPort::SerialPortError::OpenError)); - serialPortError->Set(isolate, "WriteError", v8::Int32::New(isolate, QSerialPort::SerialPortError::WriteError)); - serialPortError->Set(isolate, "ReadError", v8::Int32::New(isolate, QSerialPort::SerialPortError::ReadError)); - serialPortError->Set(isolate, "ResourceError", v8::Int32::New(isolate, QSerialPort::SerialPortError::ResourceError)); - serialPortError->Set(isolate, "UnsupportedOperationError", v8::Int32::New(isolate, QSerialPort::SerialPortError::UnsupportedOperationError)); - serialPortError->Set(isolate, "UnknownError", v8::Int32::New(isolate, QSerialPort::SerialPortError::UnknownError)); - serialPortError->Set(isolate, "TimeoutError", v8::Int32::New(isolate, QSerialPort::SerialPortError::TimeoutError)); - serialPortError->Set(isolate, "NotOpenError", v8::Int32::New(isolate, QSerialPort::SerialPortError::NotOpenError)); - tpl->Set(isolate, "SerialPortError", serialPortError); - } - } - - protected: - - static void AtEnd(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = p->d_func()->atEnd(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BytesAvailable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::BigInt::New(isolate, p->d_func()->bytesAvailable()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BytesToWrite(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::BigInt::New(isolate, p->d_func()->bytesToWrite()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void CanReadLine(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = p->d_func()->canReadLine(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Clear(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto directions = std::invoke([&]() { - if (V8_IsNumber(args, 0)) { - return static_cast(args[0]->Int32Value(context).FromJust()); - } - else { - return static_cast(QSerialPort::AllDirections); - } - }); - - auto result = p->d_func()->clear(directions); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ClearError(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - p->d_func()->clearError(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Close(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - p->d_func()->close(); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Flush(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = p->d_func()->flush(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Handle(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::External::New(isolate, p->d_func()->handle()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsSequential(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = p->d_func()->isSequential(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Open(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto mode = std::invoke([&]() { - if (V8_IsNumber(args, 0)) { - return static_cast(args[0]->Int32Value(context).FromJust()); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[mode] error.")); - }); - - auto result = p->d_func()->open(mode); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PinoutSignals(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = p->d_func()->pinoutSignals(); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PortName(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = V8_NEW_STRING_VAR(isolate, qPrintable(p->d_func()->portName())); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ReadBufferSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::BigInt::New(isolate, p->d_func()->readBufferSize()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetPort(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) - return; - - p->d_func()->setPort(***SerialPortInfo::FromValue(isolate, args[0])); - } - - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetPortName(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto name = std::invoke([&]() { - return convert::String::To(isolate, value); - }); - - p->d_func()->setPortName(name); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetReadBufferSize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto size = std::invoke([&]() { - if (V8_IsBigInt(args, 0)) { - return args[0]->ToBigInt(context).ToLocalChecked()->Int64Value(); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[size] error.")); - }); - - p->d_func()->setReadBufferSize(size); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForBytesWritten(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto msecs = std::invoke([&]() { - if (V8_IsInt32(args, 0)) { - return args[0]->Int32Value(context).FromJust(); - } - else { - return 30000; - } - }); - - auto result = p->d_func()->waitForBytesWritten(msecs); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void WaitForReadyRead(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto msecs = std::invoke([&]() { - if (V8_IsInt32(args, 0)) { - return args[0]->Int32Value(context).FromJust(); - } - else { - return 30000; - } - }); - - auto result = p->d_func()->waitForReadyRead(msecs); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BaudRate(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto directions = std::invoke([&]() { - if (V8_IsNumber(args, 0)) { - return static_cast(args[0]->Int32Value(context).FromJust()); - } - return static_cast(QSerialPort::AllDirections); - }); - - auto result = p->d_func()->baudRate(directions); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetBaudRate(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - - if (p) { - auto baudRate = std::invoke([&]() { - if (V8_IsNumber(args, 0)) { - return args[0]->Int32Value(context).FromJust(); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[baudRate] error.")); - }); - auto directions = std::invoke([&]() { - if (V8_IsNumber(args, 1)) { - return static_cast(args[1]->Int32Value(context).FromJust()); - } - return static_cast(QSerialPort::AllDirections); - }); - p->d_func()->setBaudRate(baudRate, directions); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DataBits(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->dataBits(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetDataBits(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (p) { - auto dataBits = std::invoke([&]() { - if (value->IsNumber()) { - return static_cast(value->Int32Value(context).FromJust()); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[dataBits] error.")); - }); - p->d_func()->setDataBits(dataBits); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Parity(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->parity(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetParity(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (p) { - auto parity = std::invoke([&]() { - if (value->IsNumber()) { - return static_cast(value->Int32Value(context).FromJust()); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[parity] error.")); - }); - p->d_func()->setParity(parity); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StopBits(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->stopBits(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetStopBits(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (p) { - auto stopBits = std::invoke([&]() { - if (value->IsNumber()) { - return static_cast(value->Int32Value(context).FromJust()); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[stopBits] error.")); - }); - p->d_func()->setStopBits(stopBits); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FlowControl(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->flowControl(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetFlowControl(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (p) { - auto flowControl = std::invoke([&]() { - if (value->IsNumber()) { - return static_cast(value->Int32Value(context).FromJust()); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[flowControl] error.")); - }); - p->d_func()->setFlowControl(flowControl); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsDataTerminalReady(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->isDataTerminalReady(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetDataTerminalReady(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (p) { - auto dataTerminalReady = std::invoke([&]() { - if (value->IsBoolean()) { - return value->BooleanValue(isolate); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[dataTerminalReady] error.")); - }); - - p->d_func()->setDataTerminalReady(dataTerminalReady); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsRequestToSend(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->isRequestToSend(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetRequestToSend(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (p) { - auto requestToSend = std::invoke([&]() { - if (value->IsBoolean()) { - return value->BooleanValue(isolate); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[requestToSend] error.")); - }); - - p->d_func()->setRequestToSend(requestToSend); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsBreakEnabled(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->isBreakEnabled(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetBreakEnabled(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - - if (p) { - auto breakEnabled = std::invoke([&]() { - if (value->IsBoolean()) { - return value->BooleanValue(isolate); - } - isolate->ThrowException(V8_NEW_STRING_VAR(isolate, "#[breakEnabled] error.")); - }); - - p->d_func()->setBreakEnabled(breakEnabled); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Error(v8::Local property, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (p) { - auto result = p->d_func()->error(); - info.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BaudRateChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::baudRateChanged, [weakPersistent](qint32 baudRate, QSerialPort::Directions directions) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, baudRate) , v8::Int32::New(isolate,directions) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::baudRateChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void BreakEnabledChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::breakEnabledChanged, [weakPersistent](bool set) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Boolean::New(isolate, set) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::breakEnabledChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DataBitsChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::dataBitsChanged, [weakPersistent](QSerialPort::DataBits dataBits) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, dataBits) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::dataBitsChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void DataTerminalReadyChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::dataTerminalReadyChanged, [weakPersistent](bool set) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Boolean::New(isolate, set) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::dataTerminalReadyChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ErrorOccurred(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::errorOccurred, [weakPersistent](QSerialPort::SerialPortError error) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, error) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::errorOccurred, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void FlowControlChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::flowControlChanged, [weakPersistent](QSerialPort::FlowControl flowControl) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, flowControl) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::flowControlChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ParityChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::parityChanged, [weakPersistent](QSerialPort::Parity parity) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, parity) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::parityChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void RequestToSendChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::requestToSendChanged, [weakPersistent](bool set) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Boolean::New(isolate, set) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::requestToSendChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StopBitsChanged(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* p = convert::Object::UnWrap>(info.This()); - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weakPersistent = - std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(p->d_func(), &QSerialPort::stopBitsChanged, [weakPersistent](QSerialPort::StopBits stopBits) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch try_catch(isolate); - v8::Local argv[] = { v8::Int32::New(isolate, stopBits) }; - weakPersistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (try_catch.HasCaught()) { - qCCritical(shelllet_device) << try_catch.Exception(); - } - } - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(p->d_func(), &QSerialPort::stopBitsChanged, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/serialport/qserialportinfo_implement.h b/v8/include/modules/serialport/qserialportinfo_implement.h deleted file mode 100644 index 57b1492..0000000 --- a/v8/include/modules/serialport/qserialportinfo_implement.h +++ /dev/null @@ -1,21 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "device_module.h" -#include "qstring_implement.h" -#include "qhostaddress_implement.h" -#include "qserialportinfo_p.h" -#include "qserialportinfo_wrapper.h" - -namespace shelllet { - namespace device { - class SerialPortInfo : public QSerialPortInfoWrapper - { - public: - SerialPortInfo(const v8::FunctionCallbackInfo& args); - SerialPortInfo(v8::Isolate* isolate, const v8::Local& tpl); - - static const char* Name(); - }; - } -} diff --git a/v8/include/modules/serialport/qserialportinfo_p.h b/v8/include/modules/serialport/qserialportinfo_p.h deleted file mode 100644 index b8f247c..0000000 --- a/v8/include/modules/serialport/qserialportinfo_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet::device { - template - class QSerialPortInfoPrivate : public core::ObjectPrivate - { - public: - template - QSerialPortInfoPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - - - }; -} diff --git a/v8/include/modules/serialport/qserialportinfo_wrapper.h b/v8/include/modules/serialport/qserialportinfo_wrapper.h deleted file mode 100644 index b322a30..0000000 --- a/v8/include/modules/serialport/qserialportinfo_wrapper.h +++ /dev/null @@ -1,208 +0,0 @@ -#pragma once -#include "framework.h" -#include - -namespace shelllet { - namespace device { - class SerialPortInfo; - template class QSerialPortInfoPrivate; - template - class QSerialPortInfoWrapper : public core::ObjectWrapper - { - public: - template - QSerialPortInfoWrapper(QSerialPortInfoPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - QSerialPortInfoWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - QSerialPortInfoWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) { - tpl->PrototypeTemplate()->Set(isolate, "description", v8::FunctionTemplate::New(isolate, Description)); - tpl->PrototypeTemplate()->Set(isolate, "hasProductIdentifier", v8::FunctionTemplate::New(isolate, HasProductIdentifier)); - tpl->PrototypeTemplate()->Set(isolate, "hasVendorIdentifier", v8::FunctionTemplate::New(isolate, HasVendorIdentifier)); - tpl->PrototypeTemplate()->Set(isolate, "isNull", v8::FunctionTemplate::New(isolate, IsNull)); - tpl->PrototypeTemplate()->Set(isolate, "manufacturer", v8::FunctionTemplate::New(isolate, Manufacturer)); - tpl->PrototypeTemplate()->Set(isolate, "portName", v8::FunctionTemplate::New(isolate, PortName)); - tpl->PrototypeTemplate()->Set(isolate, "productIdentifier", v8::FunctionTemplate::New(isolate, ProductIdentifier)); - tpl->PrototypeTemplate()->Set(isolate, "serialNumber", v8::FunctionTemplate::New(isolate, SerialNumber)); - tpl->PrototypeTemplate()->Set(isolate, "swap", v8::FunctionTemplate::New(isolate, Swap)); - tpl->PrototypeTemplate()->Set(isolate, "systemLocation", v8::FunctionTemplate::New(isolate, SystemLocation)); - tpl->PrototypeTemplate()->Set(isolate, "vendorIdentifier", v8::FunctionTemplate::New(isolate, VendorIdentifier)); - { - tpl->Set(isolate, "availablePorts", v8::FunctionTemplate::New(isolate, AvailablePorts)); - tpl->Set(isolate, "standardBaudRates", v8::FunctionTemplate::New(isolate, StandardBaudRates)); - } - } - - protected: - - static void Description(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = V8_NEW_STRING_VAR(isolate, qPrintable(p->d_func()->description())); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HasProductIdentifier(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::Boolean::New(isolate, p->d_func()->hasProductIdentifier()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void HasVendorIdentifier(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::Boolean::New(isolate, p->d_func()->hasVendorIdentifier()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsNull(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::Boolean::New(isolate, p->d_func()->isNull()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Manufacturer(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = V8_NEW_STRING_VAR(isolate, qPrintable(p->d_func()->manufacturer())); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void PortName(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = V8_NEW_STRING_VAR(isolate, qPrintable(p->d_func()->portName())); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ProductIdentifier(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::Int32::New(isolate, p->d_func()->productIdentifier()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SerialNumber(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = V8_NEW_STRING_VAR(isolate, qPrintable(p->d_func()->serialNumber())); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Swap(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (!p) - return; - p->d_func()->swap(***SerialPortInfo::FromValue(isolate, args[0])); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SystemLocation(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = V8_NEW_STRING_VAR(isolate, qPrintable(p->d_func()->systemLocation())); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void VendorIdentifier(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = v8::Int32::New(isolate, p->d_func()->vendorIdentifier()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void AvailablePorts(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = V8_From_ObjectArray(isolate, context, "SerialPortInfo", p->d_func()->availablePorts()); - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void StandardBaudRates(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = convert::Object::UnWrap>(args.This()); - if (p) { - auto result = V8_From_Int32Array(isolate, context, p->d_func()->standardBaudRates()); - - args.GetReturnValue().Set(result); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/widgets/initialize.h b/v8/include/modules/widgets/initialize.h deleted file mode 100644 index c7c54ee..0000000 --- a/v8/include/modules/widgets/initialize.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "framework.h" -#include "widgets/qapplication_implement.h" -#include "widgets/qwidget_implement.h" -#include "widgets/qmainwindow_implement.h" - -namespace shelllet { - namespace qtcore { - void initialize(v8::Isolate* isolate, const v8::Local& proto) { - using namespace shelllet::core; - { - proto->Set(isolate, Application::Name(), Application::WrapClass(isolate)); - proto->Set(isolate, MainWindow::Name(), MainWindow::WrapClass(isolate)); - proto->Set(isolate, Widget::Name(), Widget::WrapClass(isolate)); - } - - } - } -} \ No newline at end of file diff --git a/v8/include/modules/widgets/qapplication_implement.h b/v8/include/modules/widgets/qapplication_implement.h deleted file mode 100644 index f1e0187..0000000 --- a/v8/include/modules/widgets/qapplication_implement.h +++ /dev/null @@ -1,43 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qapplication_p.h" -#include "qapplication_wrapper.h" - -namespace shelllet { - namespace widgets { - class Application : public QApplicationWrapper - { - public: - using ReturnType = QApplicationPrivate; - using ReturnType2 = QApplicationPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This(), __argc, __argv); - } - Application(const v8::FunctionCallbackInfo& args) :QApplicationWrapper(*Private(args), args) - { - } - Application(QApplication* p, const v8::FunctionCallbackInfo& args) : QApplicationWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Application(v8::Isolate* isolate, const v8::Local& tpl) : QApplicationWrapper(isolate, tpl) { - tpl->Set(isolate, "exec", v8::FunctionTemplate::New(isolate, Exec)); - } - Application(v8::Isolate* isolate, const v8::Local& proto) : QApplicationWrapper(isolate, proto) - { - } - - static const char* Name() { return "Application"; } - protected: - static void Exec(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - v8::Unlocker unlocker(isolate); - QApplication::exec(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/widgets/qapplication_p.h b/v8/include/modules/widgets/qapplication_p.h deleted file mode 100644 index 424efcf..0000000 --- a/v8/include/modules/widgets/qapplication_p.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -#include "core/qcoreapplication_p.h" -namespace shelllet { - namespace widgets { - using namespace core; - - template - class QApplicationPrivate : public QCoreApplicationPrivate - { - public: - template - QApplicationPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QCoreApplicationPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/widgets/qapplication_wrapper.h b/v8/include/modules/widgets/qapplication_wrapper.h deleted file mode 100644 index b7d7930..0000000 --- a/v8/include/modules/widgets/qapplication_wrapper.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include "core/qcoreapplication_wrapper.h" -namespace shelllet { - namespace widgets { - using namespace core; - template class QApplicationPrivate; - template - class QApplicationWrapper : public QCoreApplicationWrapper - { - public: - - template - QApplicationWrapper(QApplicationPrivate& d, const v8::FunctionCallbackInfo& args) - : QCoreApplicationWrapper(d, args) { - } - QApplicationWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QCoreApplicationWrapper(isolate, tpl) {} - QApplicationWrapper(v8::Isolate* isolate, const v8::Local& proto) : QCoreApplicationWrapper(isolate, proto) - { - } - - protected: - }; - } -} diff --git a/v8/include/modules/widgets/qmainwindow_implement.h b/v8/include/modules/widgets/qmainwindow_implement.h deleted file mode 100644 index dcff216..0000000 --- a/v8/include/modules/widgets/qmainwindow_implement.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qmainwindow_p.h" -#include "qmainwindow_wrapper.h" - -namespace shelllet { - namespace widgets { - class MainWindow : public MainWindowWrapper - { - public: - using ReturnType = MainWindowPrivate; - using ReturnType2 = MainWindowPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - MainWindow(const v8::FunctionCallbackInfo& args) :MainWindowWrapper(*Private(args), args) - { - } - MainWindow(QMainWindow* p, const v8::FunctionCallbackInfo& args) : MainWindowWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - MainWindow(v8::Isolate* isolate, const v8::Local& tpl) : MainWindowWrapper(isolate, tpl) {} - MainWindow(v8::Isolate* isolate, const v8::Local& proto) : MainWindowWrapper(isolate, proto) - {} - - static const char* Name() { return "MainWindow"; } - public: - }; - } -} diff --git a/v8/include/modules/widgets/qmainwindow_p.h b/v8/include/modules/widgets/qmainwindow_p.h deleted file mode 100644 index ed10b40..0000000 --- a/v8/include/modules/widgets/qmainwindow_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "qwidget_p.h" -namespace shelllet { - namespace widgets { - template - class MainWindowPrivate : public WidgetPrivate - { - public: - template - MainWindowPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : WidgetPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/widgets/qmainwindow_wrapper.h b/v8/include/modules/widgets/qmainwindow_wrapper.h deleted file mode 100644 index 31ec056..0000000 --- a/v8/include/modules/widgets/qmainwindow_wrapper.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "qwidget_wrapper.h" -namespace shelllet { - namespace widgets { - template class MainWindowPrivate; - template - class MainWindowWrapper : public WidgetWrapper - { - public: - template - MainWindowWrapper(MainWindowPrivate& d, const v8::FunctionCallbackInfo& args) - : WidgetWrapper(d, args) { - } - MainWindowWrapper(v8::Isolate* isolate, const v8::Local& tpl) : WidgetWrapper(isolate, tpl) { - tpl->Set(isolate, "log", v8::FunctionTemplate::New(isolate, Print)); - } - MainWindowWrapper(v8::Isolate* isolate, const v8::Local& proto) : WidgetWrapper(isolate, proto) - { - } - - protected: - static void Print(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/widgets/qsystemtrayicon_implement.h b/v8/include/modules/widgets/qsystemtrayicon_implement.h deleted file mode 100644 index bdfe368..0000000 --- a/v8/include/modules/widgets/qsystemtrayicon_implement.h +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qsystemtrayicon_p.h" -#include "qsystemtrayicon_wrapper.h" - -namespace shelllet { - namespace widgets { - class SystemTrayIcon : public QSystemTrayIconWrapper - { - public: - using ReturnType = QSystemTrayIconPrivate; - using ReturnType2 = QSystemTrayIconPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - SystemTrayIcon(const v8::FunctionCallbackInfo& args) :QSystemTrayIconWrapper(*Private(args), args) - { - } - SystemTrayIcon(QSystemTrayIcon* p, const v8::FunctionCallbackInfo& args) : QSystemTrayIconWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - SystemTrayIcon(v8::Isolate* isolate, const v8::Local& tpl) : QSystemTrayIconWrapper(isolate, tpl) {} - SystemTrayIcon(v8::Isolate* isolate, const v8::Local& proto) : QSystemTrayIconWrapper(isolate, proto) - { - tpl->Set(isolate, "isSystemTrayAvailable", v8::FunctionTemplate::New(isolate, IsSystemTrayAvailable)); - tpl->Set(isolate, "supportsMessages", v8::FunctionTemplate::New(isolate, SupportsMessages)); - } - - protected: - void toString(std::stringstream& ss) const {} - protected: - static const char* Name() { return "SystemTrayIcon"; } - static void IsSystemTrayAvailable(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set(self->d_func()->isSystemTrayAvailable()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SupportsMessages(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - args.GetReturnValue().Set(self->d_func()->supportsMessages()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} diff --git a/v8/include/modules/widgets/qsystemtrayicon_p.h b/v8/include/modules/widgets/qsystemtrayicon_p.h deleted file mode 100644 index 5211935..0000000 --- a/v8/include/modules/widgets/qsystemtrayicon_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once -#include "core/qobject_p.h" -namespace shelllet { - namespace widgets { - template - class QSystemTrayIconPrivate : public QObjectPrivate - { - public: - template - QSystemTrayIconPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : QObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/widgets/qsystemtrayicon_wrapper.h b/v8/include/modules/widgets/qsystemtrayicon_wrapper.h deleted file mode 100644 index 104e347..0000000 --- a/v8/include/modules/widgets/qsystemtrayicon_wrapper.h +++ /dev/null @@ -1,250 +0,0 @@ -#pragma once -#include "core/qobject_wrapper.h" -namespace shelllet { - namespace widgets { - template class QSystemTrayIconPrivate; - template - class QSystemTrayIconWrapper : public QObjectWrapper - { - public: - - template - QSystemTrayIconWrapper(QSystemTrayIconPrivate& d, const v8::FunctionCallbackInfo& args) - : QObjectWrapper(d, args) { - } - QSystemTrayIconWrapper(v8::Isolate* isolate, const v8::Local& tpl) : QObjectWrapper(isolate, tpl) {} - QSystemTrayIconWrapper(v8::Isolate* isolate, const v8::Local& proto) : QObjectWrapper(isolate, proto) - { - proto->Set(isolate, "contextMenu", v8::FunctionTemplate::New(isolate, ContextMenu)); - proto->Set(isolate, "geometry", v8::FunctionTemplate::New(isolate, Geometry)); - proto->Set(isolate, "icon", v8::FunctionTemplate::New(isolate, Icon)); - proto->Set(isolate, "isVisible", v8::FunctionTemplate::New(isolate, IsVisible)); - proto->Set(isolate, "setContextMenu", v8::FunctionTemplate::New(isolate, SetContextMenu)); - proto->Set(isolate, "setIcon", v8::FunctionTemplate::New(isolate, SetIcon)); - proto->Set(isolate, "setToolTip", v8::FunctionTemplate::New(isolate, SetToolTip)); - proto->Set(isolate, "toolTip", v8::FunctionTemplate::New(isolate, ToolTip)); - proto->Set(isolate, "hide", v8::FunctionTemplate::New(isolate, Hide)); - proto->Set(isolate, "setVisible", v8::FunctionTemplate::New(isolate, SetVisible)); - proto->Set(isolate, "show", v8::FunctionTemplate::New(isolate, Show)); - proto->Set(isolate, "showMessage", v8::FunctionTemplate::New(isolate, ShowMessage)); - proto->Set(isolate, "showMessage", v8::FunctionTemplate::New(isolate, ShowMessage)); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "activated"), nullptr, Activated); - proto->SetAccessor(V8_NEW_STRING_VAR(isolate, "messageClicked"), nullptr, MessageClicked); - } - - protected: - static void ContextMenu(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Geometry(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Icon(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void IsVisible(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetContextMenu(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetIcon(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetToolTip(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ToolTip(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Hide(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void SetVisible(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Show(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ShowMessage(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void ShowMessage(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* self = UnWrap>(args.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void Activated(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weak_persistent = std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(self->d_func(), &QSystemTrayIcon::activated, [isolate, weak_persistent](QSystemTrayIcon::ActivationReason reason) { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { }; - weak_persistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(self->d_func(), &QSystemTrayIcon::activated, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - - static void MessageClicked(v8::Local property, v8::Local value, const v8::PropertyCallbackInfo& info) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(info) - { - auto* self = UnWrap>(info.This()); - if (!self) - throw std::domain_error(K_CONST_ERROR_CALLED); - - if (value->IsFunction()) { - v8::Local f = v8::Local::Cast(value); - std::shared_ptr>weak_persistent = std::shared_ptr>(new v8::Global(isolate, f), [](v8::Global* p) { - p->Reset(); - delete p; - }); - - QObject::connect(self->d_func(), &QSystemTrayIcon::messageClicked, [isolate, weak_persistent]() { - V8_CREATE_LOCAL_LOCKER_CONTEXT_BY_ISOLATE(isolate) - { - v8::TryCatch tryCatch(isolate); - v8::Local argv[] = { }; - weak_persistent->Get(isolate)->CallAsFunction(context, context->Global(), std::size(argv), argv); - if (tryCatch.HasCaught()) { - throw std::runtime_error(GetException(isolate, tryCatch)); - } - } - V8_CREATE_LOCAL_CONTEXT_END - }); - } - else if (value->IsNullOrUndefined()) { - QObject::disconnect(self->d_func(), &QSystemTrayIcon::messageClicked, nullptr, nullptr); - } - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/modules/widgets/qwidget_implement.h b/v8/include/modules/widgets/qwidget_implement.h deleted file mode 100644 index facf907..0000000 --- a/v8/include/modules/widgets/qwidget_implement.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once -#include "framework.h" -#include -#include "qwidget_p.h" -#include "qwidget_wrapper.h" - -namespace shelllet { - namespace widgets { - class Widget : public WidgetWrapper - { - public: - using ReturnType = WidgetPrivate; - using ReturnType2 = WidgetPrivate; - ReturnType* Private(const v8::FunctionCallbackInfo& args) { - return new ReturnType(args.GetIsolate(), args.This()); - } - Widget(const v8::FunctionCallbackInfo& args) :WidgetWrapper(*Private(args), args) - { - } - Widget(QWidget* p, const v8::FunctionCallbackInfo& args) : WidgetWrapper(*new ReturnType2(args.GetIsolate(), args.This(), p), args) - { - } - Widget(v8::Isolate* isolate, const v8::Local& tpl) : WidgetWrapper(isolate, tpl) {} - Widget(v8::Isolate* isolate, const v8::Local& proto) : WidgetWrapper(isolate, proto) - {} - - static const char* Name() { return "Widget"; } - public: - }; - } -} diff --git a/v8/include/modules/widgets/qwidget_p.h b/v8/include/modules/widgets/qwidget_p.h deleted file mode 100644 index 797539b..0000000 --- a/v8/include/modules/widgets/qwidget_p.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -namespace shelllet { - namespace widgets { - template - class WidgetPrivate : public ObjectPrivate - { - public: - template - WidgetPrivate(v8::Isolate* isolate, const v8::Local& obj, Args&&... args) : ObjectPrivate(isolate, obj, std::forward(args)...) { - } - }; - } -} diff --git a/v8/include/modules/widgets/qwidget_wrapper.h b/v8/include/modules/widgets/qwidget_wrapper.h deleted file mode 100644 index 16ed0c2..0000000 --- a/v8/include/modules/widgets/qwidget_wrapper.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once -#include "core/qsize_implement.h" - -namespace shelllet { - using namespace core; - namespace widgets { - template class WidgetPrivate; - template - class WidgetWrapper : public ObjectWrapper - { - public: - template - WidgetWrapper(WidgetPrivate& d, const v8::FunctionCallbackInfo& args) - : ObjectWrapper(d, args) { - } - WidgetWrapper(v8::Isolate* isolate, const v8::Local& tpl) : ObjectWrapper(isolate, tpl) {} - WidgetWrapper(v8::Isolate* isolate, const v8::Local& proto) : ObjectWrapper(isolate, proto) - { - proto->Set(isolate, "show", v8::FunctionTemplate::New(isolate, Show)); - proto->Set(isolate, "resize", v8::FunctionTemplate::New(isolate, Resize)); - } - - protected: - static void Show(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - return; - (*p)->show(); - } - V8_CREATE_LOCAL_CONTEXT_END - } - static void Resize(const v8::FunctionCallbackInfo& args) - { - V8_CREATE_LOCAL_CONTEXT_WITHOUT_LOCKER_BY_CALLBACK_INFO(args) - { - auto* p = UnWrap>(args.This()); - if (!p) - return; - auto* value = Size::From(args[0]); - if (!value) { - throw std::invalid_argument("#! require `size` object."); - } - (*p)->resize((*value)->width(), (*value)->height()); - } - V8_CREATE_LOCAL_CONTEXT_END - } - }; - } -} \ No newline at end of file diff --git a/v8/include/resource.h b/v8/include/resource.h deleted file mode 100644 index 13c2d7e..0000000 --- a/v8/include/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -namespace shelllet { - class Resource { - public: - virtual ~Resource() {}; - virtual void cleanup() = 0; - class Deleter { - public: - void operator()(Resource* res) { - res->cleanup(); - delete res; - LOG_DEBUG("resource") << "# free." << std::endl; - } - }; - }; -} \ No newline at end of file diff --git a/visual studio installer/vs_2017_Community.exe b/visual studio installer/vs_2017_Community.exe deleted file mode 100644 index 065ce05..0000000 Binary files a/visual studio installer/vs_2017_Community.exe and /dev/null differ diff --git a/visual studio installer/vs_professional__1569707295.1553307401.exe b/visual studio installer/vs_professional__1569707295.1553307401.exe deleted file mode 100644 index ae930c9..0000000 Binary files a/visual studio installer/vs_professional__1569707295.1553307401.exe and /dev/null differ