mirror of
https://gitlab.com/Syping/luaengineapp.git
synced 2024-12-22 11:55:29 +01:00
load script as resource
This commit is contained in:
parent
98fb0529cf
commit
92e9d25879
11 changed files with 54 additions and 437 deletions
|
@ -1,94 +1,23 @@
|
||||||
--[[
|
--[[
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* luaEngine Lua Engine for Qt
|
* luaEngine Lua Engine for Qt
|
||||||
* Copyright (C) 2018 Syping
|
* Copyright (C) 2019 Syping
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
local mainWindow
|
function main()
|
||||||
local dialogLineEdit
|
showMessageBox(InfoMessageBox, "Lua Engine is working!", "Lua Engine")
|
||||||
|
return 0
|
||||||
function main()
|
end
|
||||||
mainWindow = createMainWindow()
|
|
||||||
local mainLayout = createLayout(VerticalLayout, mainWindow)
|
|
||||||
|
|
||||||
local menuBar = createMenuBar(mainWindow)
|
|
||||||
local menuFile = createMenu("File", menuBar)
|
|
||||||
local menuEntryExit = createMenuEntry("Exit", menuFile, "Alt+F4")
|
|
||||||
connect(menuEntryExit, "triggered()", "closeWindow")
|
|
||||||
local menuHelp = createMenu("Help", menuBar)
|
|
||||||
local menuEntryAbout = createMenuEntry("About LuaEngine", menuHelp, "Ctrl+P")
|
|
||||||
connect(menuEntryAbout, "triggered()", "showAboutBox")
|
|
||||||
|
|
||||||
local labelLayout = createLayout(HorizontalLayout, mainLayout)
|
|
||||||
local appLabel1 = createLabel("LuaEngine greets!", mainWindow)
|
|
||||||
layoutAddWidget(labelLayout, appLabel1)
|
|
||||||
local appLabel2 = createLabel("..and not only one time!", mainWindow)
|
|
||||||
layoutAddWidget(labelLayout, appLabel2)
|
|
||||||
|
|
||||||
local checkBox1 = createCheckBox("Want to check me?", mainWindow)
|
|
||||||
layoutAddWidget(mainLayout, checkBox1)
|
|
||||||
|
|
||||||
local pushButton1 = createPushButton("Press me hard please!", mainWindow)
|
|
||||||
layoutAddWidget(mainLayout, pushButton1)
|
|
||||||
connect(pushButton1, "clicked()", "showDialog")
|
|
||||||
|
|
||||||
setWidgetFixed(mainWindow)
|
|
||||||
showWidget(mainWindow, ShowNormal)
|
|
||||||
return GuiExecuted
|
|
||||||
end
|
|
||||||
|
|
||||||
function closeWindow()
|
|
||||||
closeWidget(mainWindow)
|
|
||||||
end
|
|
||||||
|
|
||||||
function showAboutBox(menuEntry)
|
|
||||||
showMessageBox(InfoMessageBox, "You triggered the About Box!", "LuaEngine", mainWindow)
|
|
||||||
end
|
|
||||||
|
|
||||||
function showDialog(pushButton)
|
|
||||||
local dialog = createDialog("LuaEngine", mainWindow)
|
|
||||||
local dialogLayout = createLayout(VerticalLayout, dialog)
|
|
||||||
local dialogLabel = createLabel("Yes, you have open a Dialog!", dialog)
|
|
||||||
layoutAddWidget(dialogLayout, dialogLabel)
|
|
||||||
dialogLineEdit = createLineEdit("", dialog)
|
|
||||||
layoutAddWidget(dialogLayout, dialogLineEdit)
|
|
||||||
local buttonLayout = createLayout(HorizontalLayout, dialogLayout)
|
|
||||||
createSpacerItem(SizePolicyExpanding, SizePolicyMinimum, buttonLayout)
|
|
||||||
local dialogButton = createPushButton("Close", dialog)
|
|
||||||
layoutAddWidget(buttonLayout, dialogButton)
|
|
||||||
connect(dialogButton, "clicked()", "closeDialog")
|
|
||||||
setWidgetFixed(dialog)
|
|
||||||
executeWidget(dialog)
|
|
||||||
delete(dialog, DeleteInstant)
|
|
||||||
end
|
|
||||||
|
|
||||||
function closeDialog(pushButton)
|
|
||||||
disconnect(pushButton, "clicked()")
|
|
||||||
if not (getWidgetText(dialogLineEdit) == "") then
|
|
||||||
showMessageBox(InfoMessageBox, "You typed: " .. getWidgetText(dialogLineEdit), "LuaEngine", getParent(pushButton))
|
|
||||||
end
|
|
||||||
closeWidget(getParent(pushButton))
|
|
||||||
end
|
|
||||||
|
|
||||||
function testMessageBoxes()
|
|
||||||
showMessageBox(InfoMessageBox, "LuaEngine Test")
|
|
||||||
local returnCode = showMessageBox(QuestionMessageBox, "Do you press Yes or No?")
|
|
||||||
if (returnCode == true) then
|
|
||||||
showMessageBox(InfoMessageBox, "You have pressed Yes!")
|
|
||||||
else
|
|
||||||
showMessageBox(InfoMessageBox, "You have pressed No!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,127 +0,0 @@
|
||||||
--[[
|
|
||||||
******************************************************************************
|
|
||||||
* luaEngine Lua Engine for Qt
|
|
||||||
* Copyright (C) 2018 Syping
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
******************************************************************************
|
|
||||||
--]]
|
|
||||||
|
|
||||||
local currentFile
|
|
||||||
local mainWindow
|
|
||||||
local textEditor
|
|
||||||
|
|
||||||
function main()
|
|
||||||
mainWindow = createMainWindow("LE Text Editor")
|
|
||||||
local mainLayout = createLayout(VerticalLayout, mainWindow)
|
|
||||||
setLayoutMargins(mainLayout, 0, 0, 0, 0)
|
|
||||||
|
|
||||||
local menuBar = createMenuBar(mainWindow)
|
|
||||||
local menuFile = createMenu("&File", menuBar)
|
|
||||||
local menuEntryNew = createMenuEntry("&New", menuFile, "Ctrl+N")
|
|
||||||
connect(menuEntryNew, "triggered()", "editorNew")
|
|
||||||
local menuEntryOpen = createMenuEntry("&Open...", menuFile, "Ctrl+O")
|
|
||||||
connect(menuEntryOpen, "triggered()", "editorOpen")
|
|
||||||
local menuEntrySave = createMenuEntry("&Save...", menuFile, "Ctrl+S")
|
|
||||||
connect(menuEntrySave, "triggered()", "editorSave")
|
|
||||||
local menuEntrySaveAs = createMenuEntry("Save &as...", menuFile)
|
|
||||||
connect(menuEntrySaveAs, "triggered()", "editorSaveAs")
|
|
||||||
createMenuSeparator(menuFile)
|
|
||||||
local menuEntryExit = createMenuEntry("&Exit", menuFile, "Alt+F4")
|
|
||||||
connect(menuEntryExit, "triggered()", "editorClose")
|
|
||||||
local menuHelp = createMenu("&Help", menuBar)
|
|
||||||
local menuEntryAbout = createMenuEntry("&About LE Text Editor", menuHelp, "Ctrl+P")
|
|
||||||
connect(menuEntryAbout, "triggered()", "editorAboutBox")
|
|
||||||
|
|
||||||
textEditor = createPlainTextEdit("", mainWindow)
|
|
||||||
layoutAddWidget(mainLayout, textEditor)
|
|
||||||
|
|
||||||
setWidgetSize(mainWindow, 650, 450)
|
|
||||||
showWidget(mainWindow, ShowDefault)
|
|
||||||
return GuiExecuted
|
|
||||||
end
|
|
||||||
|
|
||||||
function editorNew()
|
|
||||||
setWidgetText(textEditor, "")
|
|
||||||
currentFile = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function editorOpen()
|
|
||||||
local selectedFile = showFileDialog(OpenFileDialog, "Open...", "All files (*)", mainWindow)
|
|
||||||
if not (selectedFile == nil) then
|
|
||||||
local file = io.open(selectedFile, "r")
|
|
||||||
if not (file == nil) then
|
|
||||||
local content = file:read("*a")
|
|
||||||
setWidgetText(textEditor, content)
|
|
||||||
file:close()
|
|
||||||
currentFile = selectedFile
|
|
||||||
else
|
|
||||||
showMessageBox(WarningMessageBox, "Failed to open file " .. selectedFile .. "!", "Open...", mainWindow)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function editorSave()
|
|
||||||
if not (currentFile == nil) then
|
|
||||||
local file = io.open(currentFile, "w")
|
|
||||||
if not (file == nil) then
|
|
||||||
editorSaveFile(file)
|
|
||||||
else
|
|
||||||
showMessageBox(WarningMessageBox, "Failed to save file " .. currentFile .. "!", "Save...", mainWindow)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
editorSaveAs()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function editorSaveAs()
|
|
||||||
local selectedFile = showFileDialog(SaveFileDialog, "Save as...", "All files (*)", mainWindow)
|
|
||||||
if not (selectedFile == nil) then
|
|
||||||
local file = io.open(selectedFile, "w")
|
|
||||||
if not (file == nil) then
|
|
||||||
editorSaveFile(file)
|
|
||||||
currentFile = selectedFile
|
|
||||||
else
|
|
||||||
showMessageBox(WarningMessageBox, "Failed to save file " .. selectedFile .. "!", "Save as...", mainWindow)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function editorSaveFile(file)
|
|
||||||
file:write(getWidgetText(textEditor))
|
|
||||||
file:close()
|
|
||||||
end
|
|
||||||
|
|
||||||
function editorAboutBox()
|
|
||||||
local dialog = createDialog("About LE Text Editor", mainWindow)
|
|
||||||
local dialogLayout = createLayout(VerticalLayout, dialog)
|
|
||||||
local dialogLabel = createLabel("<h4>LE Text Editor</h4>A simple Text Editor made in Lua Engine", dialog)
|
|
||||||
layoutAddWidget(dialogLayout, dialogLabel)
|
|
||||||
local buttonLayout = createLayout(HorizontalLayout, dialogLayout)
|
|
||||||
createSpacerItem(SizePolicyExpanding, SizePolicyMinimum, buttonLayout)
|
|
||||||
local dialogButton = createPushButton("&OK", dialog)
|
|
||||||
layoutAddWidget(buttonLayout, dialogButton)
|
|
||||||
connect(dialogButton, "clicked()", "closeDialog")
|
|
||||||
setWidgetFixed(dialog)
|
|
||||||
executeWidget(dialog)
|
|
||||||
delete(dialog, DeleteInstant)
|
|
||||||
end
|
|
||||||
|
|
||||||
function editorClose()
|
|
||||||
closeWidget(mainWindow)
|
|
||||||
end
|
|
||||||
|
|
||||||
function closeDialog(pushButton)
|
|
||||||
disconnect(pushButton, "clicked()")
|
|
||||||
closeWidget(getWindow(pushButton))
|
|
||||||
end
|
|
|
@ -1,6 +1,6 @@
|
||||||
#/*****************************************************************************
|
#/*****************************************************************************
|
||||||
#* luaEngine Lua Engine for Qt
|
#* luaEngine Lua Engine for Qt
|
||||||
#* Copyright (C) 2018 Syping
|
#* Copyright (C) 2018-2019 Syping
|
||||||
#*
|
#*
|
||||||
#* Licensed under the Apache License, Version 2.0 (the "License");
|
#* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
#* you may not use this file except in compliance with the License.
|
#* you may not use this file except in compliance with the License.
|
||||||
|
@ -27,7 +27,6 @@ unix: LIBS += -L$$OUT_PWD/../luaengine -lluaengine -L$$OUT_PWD/../luaenginegui -
|
||||||
win32: LIBS += -luser32
|
win32: LIBS += -luser32
|
||||||
|
|
||||||
INCLUDEPATH += \
|
INCLUDEPATH += \
|
||||||
./luaenginestyle \
|
|
||||||
../luaengine/lua \
|
../luaengine/lua \
|
||||||
../luaengine/luaengine \
|
../luaengine/luaengine \
|
||||||
../luaenginegui/luaengine
|
../luaenginegui/luaengine
|
||||||
|
@ -35,11 +34,8 @@ INCLUDEPATH += \
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
main.cpp
|
main.cpp
|
||||||
|
|
||||||
HEADERS += \
|
win32: HEADERS += \
|
||||||
luaenginestyle/LuaEngineStyle.h
|
resource.h
|
||||||
|
|
||||||
RESOURCES += \
|
|
||||||
luaengineapp.qrc
|
|
||||||
|
|
||||||
DISTFILES += \
|
DISTFILES += \
|
||||||
android/AndroidManifest.xml \
|
android/AndroidManifest.xml \
|
||||||
|
@ -57,5 +53,10 @@ DISTFILES += \
|
||||||
android/gradle/wrapper/gradle-wrapper.properties \
|
android/gradle/wrapper/gradle-wrapper.properties \
|
||||||
android/gradlew.bat
|
android/gradlew.bat
|
||||||
|
|
||||||
|
OTHER_FILES += \
|
||||||
|
app.lua
|
||||||
|
|
||||||
|
win32: RC_FILE = app.rc
|
||||||
|
|
||||||
ANDROID_EXTRA_LIBS += $$OUT_PWD/../luaengine/libluaengine.so $$OUT_PWD/../luaenginegui/libluaenginegui.so
|
ANDROID_EXTRA_LIBS += $$OUT_PWD/../luaengine/libluaengine.so $$OUT_PWD/../luaenginegui/libluaenginegui.so
|
||||||
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
|
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
<RCC>
|
|
||||||
<qresource prefix="/lua">
|
|
||||||
<file>app.lua</file>
|
|
||||||
<file>edit.lua</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*****************************************************************************
|
|
||||||
* luaEngine Lua Engine for Qt
|
|
||||||
* Copyright (C) 2015-2019 Syping
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef LUAENGINESTYLE
|
|
||||||
#define LUAENGINESTYLE
|
|
||||||
|
|
||||||
#include <QProxyStyle>
|
|
||||||
#include <QStyle>
|
|
||||||
|
|
||||||
class LuaEngineStyle : public QProxyStyle
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit LuaEngineStyle(QStyle *style = nullptr)
|
|
||||||
{
|
|
||||||
setBaseStyle(style);
|
|
||||||
}
|
|
||||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
|
|
||||||
{
|
|
||||||
if (element == QStyle::PE_FrameFocusRect)
|
|
||||||
return;
|
|
||||||
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // LUAENGINESTYLE
|
|
Binary file not shown.
Before Width: | Height: | Size: 173 B |
Binary file not shown.
Before Width: | Height: | Size: 169 B |
|
@ -1,7 +0,0 @@
|
||||||
<RCC>
|
|
||||||
<qresource prefix="/luaenginestyle">
|
|
||||||
<file>luaenginestyle.qss</file>
|
|
||||||
<file>down-arrow.png</file>
|
|
||||||
<file>down-arrow_o.png</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
|
@ -1,148 +0,0 @@
|
||||||
QDialog {
|
|
||||||
background-color: rgb(215, 90, 0);
|
|
||||||
}
|
|
||||||
QMainWindow {
|
|
||||||
background-color: rgb(215, 90, 0);
|
|
||||||
}
|
|
||||||
QMessageBox {
|
|
||||||
background-color: rgb(215, 90, 0);
|
|
||||||
}
|
|
||||||
QCheckBox {
|
|
||||||
background-color: rgb(215, 90, 0);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
border: 0px;
|
|
||||||
}
|
|
||||||
QComboBox {
|
|
||||||
font-size: 10pt;
|
|
||||||
background-color: rgb(215, 120, 50);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
border: 1px solid white;
|
|
||||||
}
|
|
||||||
QComboBox::drop-down {
|
|
||||||
subcontrol-origin: padding;
|
|
||||||
subcontrol-position: top right;
|
|
||||||
width: 15px;
|
|
||||||
background-color: rgb(215, 70, 25);
|
|
||||||
border-left-width: 1px;
|
|
||||||
border-left-color: white;
|
|
||||||
border-left-style: solid;
|
|
||||||
}
|
|
||||||
QComboBox::drop-down:hover {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
}
|
|
||||||
QComboBox::drop-down:on {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
}
|
|
||||||
QComboBox::down-arrow {
|
|
||||||
image: url(:/luaenginestyle/down-arrow.png);
|
|
||||||
}
|
|
||||||
QComboBox::down-arrow:hover {
|
|
||||||
image: url(:/luaenginestyle/down-arrow_o.png);
|
|
||||||
}
|
|
||||||
QComboBox::down-arrow:on {
|
|
||||||
image: url(:/luaenginestyle/down-arrow_o.png);
|
|
||||||
top: 1px;
|
|
||||||
left: 1px;
|
|
||||||
}
|
|
||||||
QComboBox QAbstractItemView {
|
|
||||||
background-color: rgb(215, 120, 50);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
QFrame {
|
|
||||||
background-color: rgb(215, 90, 0);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
}
|
|
||||||
QInputBox {
|
|
||||||
background-color: rgb(215, 90, 0);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
}
|
|
||||||
QLabel {
|
|
||||||
background-color: rgb(215, 90, 0);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
border: 0px;
|
|
||||||
}
|
|
||||||
QLineEdit {
|
|
||||||
background-color: rgb(215, 120, 50);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
border: 1px solid white;
|
|
||||||
}
|
|
||||||
QListWidget {
|
|
||||||
background-color: rgb(215, 120, 50);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
border-color: rgb(166, 92, 38);
|
|
||||||
border-style: solid;
|
|
||||||
border-width: 1px;
|
|
||||||
}
|
|
||||||
QListWidget::item {
|
|
||||||
background-color: rgb(215, 120, 50);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
}
|
|
||||||
QListWidget::item:hover {
|
|
||||||
background-color: rgb(234, 187, 152);
|
|
||||||
}
|
|
||||||
QListWidget::item:selected {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
color: rgb(215, 90, 0);
|
|
||||||
}
|
|
||||||
QPlainTextEdit {
|
|
||||||
background-color: rgb(215, 120, 50);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
border: 1px solid white;
|
|
||||||
}
|
|
||||||
QPushButton {
|
|
||||||
border-style: ridge;
|
|
||||||
background-color: rgb(215, 70, 25);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
border-width: 1px;
|
|
||||||
border-radius: 0px;
|
|
||||||
border-color: rgb(215, 120, 50);
|
|
||||||
min-width: 5em;
|
|
||||||
padding: 4px;
|
|
||||||
}
|
|
||||||
QPushButton:pressed {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
color: rgb(215, 70, 25);
|
|
||||||
border-style: inset;
|
|
||||||
}
|
|
||||||
QPushButton:hover {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
color: rgb(215, 70, 25);
|
|
||||||
}
|
|
||||||
QPushButton:focus {
|
|
||||||
background-color: rgb(218, 86, 45);
|
|
||||||
}
|
|
||||||
QPushButton:focus:hover {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
color: rgb(215, 70, 25);
|
|
||||||
}
|
|
||||||
QPushButton:focus:pressed {
|
|
||||||
background-color: rgb(255, 255, 255);
|
|
||||||
color: rgb(215, 70, 25);
|
|
||||||
border-style: inset;
|
|
||||||
}
|
|
||||||
QTextEdit {
|
|
||||||
background-color: rgb(215, 120, 50);
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
selection-background-color: rgb(255, 255, 255);
|
|
||||||
selection-color: rgb(215, 90, 0);
|
|
||||||
border: 1px solid white;
|
|
||||||
}
|
|
|
@ -15,22 +15,22 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "LuaEngineStyle.h"
|
|
||||||
#include "LuaEngineGui.h"
|
#include "LuaEngineGui.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include "windows.h"
|
||||||
|
#include "resource.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
QApplication::setStyle(new LuaEngineStyle());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#if QT_VERSION >= 0x050400
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
||||||
if (QSysInfo::windowsVersion() >= 0x0080)
|
if (QSysInfo::windowsVersion() >= 0x0080)
|
||||||
{
|
{
|
||||||
a.setFont(QApplication::font("QMenu"));
|
a.setFont(QApplication::font("QMenu"));
|
||||||
|
@ -38,10 +38,23 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QFile luaScript(":/lua/edit.lua");
|
QByteArray luaScript;
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
{
|
||||||
|
HMODULE handle = GetModuleHandle(NULL);
|
||||||
|
HRSRC resource = FindResource(handle, MAKEINTRESOURCE(IDR_RC_TEXT1), MAKEINTRESOURCE(RC_TEXT));
|
||||||
|
HGLOBAL resourceData = LoadResource(handle, resource);
|
||||||
|
DWORD size = SizeofResource(handle, resource);
|
||||||
|
const char *data = static_cast<const char*>(LockResource(resourceData));
|
||||||
|
char* buffer = new char[size + 1];
|
||||||
|
memcpy(buffer, data, size);
|
||||||
|
buffer[size] = 0;
|
||||||
|
luaScript = QByteArray(buffer);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LuaEngineGui luaEngineGui;
|
LuaEngineGui luaEngineGui;
|
||||||
luaEngineGui.executeLuaScript(&luaScript);
|
luaEngineGui.executeLuaScript(luaScript);
|
||||||
|
|
||||||
QVariantList arguments;
|
QVariantList arguments;
|
||||||
for (const QString &argument : a.arguments()) {
|
for (const QString &argument : a.arguments()) {
|
||||||
|
@ -50,7 +63,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (luaEngineGui.executeLuaFunction("main", arguments, true)) {
|
if (luaEngineGui.executeLuaFunction("main", arguments, true)) {
|
||||||
QVariant variant = luaEngineGui.returnVariant();
|
QVariant variant = luaEngineGui.returnVariant();
|
||||||
if (variant.type() == QVariant::Int) {
|
if (variant.type() == QVariant::Int || variant.type() == QVariant::LongLong) {
|
||||||
return variant.toInt();
|
return variant.toInt();
|
||||||
}
|
}
|
||||||
else if (variant.type() == QVariant::String) {
|
else if (variant.type() == QVariant::String) {
|
||||||
|
|
2
src/luaengineapp/resource.h
Normal file
2
src/luaengineapp/resource.h
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#define IDR_RC_TEXT1 201
|
||||||
|
#define RC_TEXT 256
|
Loading…
Reference in a new issue