Compare commits
13
Commits
master
..
212169ab4b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
212169ab4b | ||
|
|
9ac32a481b | ||
|
|
16f4087901 | ||
|
|
adc34dcfbc | ||
|
|
90b5b3f3aa | ||
|
|
18d435e0ea | ||
|
|
50b0ef9fe0 | ||
|
|
e729da21d8 | ||
|
|
05423ec531 | ||
|
|
d7e161362f | ||
|
|
8662e5a06f | ||
|
|
ddaa1d5028 | ||
|
|
f04936f5df |
No files matched your search
@@ -1,5 +0,0 @@
|
|||||||
# Common build folder
|
|
||||||
[Bb]uild/
|
|
||||||
|
|
||||||
# IDE stuff
|
|
||||||
CMakeLists.txt.user*
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
# SPDX-FileCopyrightText: 2024 Gary Wang <git@blumia.net>
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.9.5)
|
|
||||||
|
|
||||||
project(pineapple-notepad)
|
|
||||||
|
|
||||||
find_package(ECM ${KF_MIN_VERSION} REQUIRED NO_MODULE)
|
|
||||||
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
|
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_AUTORCC ON)
|
|
||||||
set(CMAKE_AUTOUIC ON)
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON) # kconfig generated header file is in binary dir
|
|
||||||
|
|
||||||
find_package(Qt6 6.4 REQUIRED
|
|
||||||
COMPONENTS Widgets
|
|
||||||
)
|
|
||||||
|
|
||||||
find_package(KF6 6.3 REQUIRED
|
|
||||||
COMPONENTS XmlGui ConfigWidgets CoreAddons I18n IconThemes
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(pineapple-notepad
|
|
||||||
generalsettings.ui)
|
|
||||||
|
|
||||||
target_sources(pineapple-notepad
|
|
||||||
PRIVATE
|
|
||||||
main.cpp
|
|
||||||
mainwindow.cpp mainwindow.h
|
|
||||||
editorviewhelper.cpp editorviewhelper.h
|
|
||||||
generalsettings.ui
|
|
||||||
|
|
||||||
appsettings.kcfg
|
|
||||||
)
|
|
||||||
|
|
||||||
qt_add_resources(pineapple-notepad xmlgui.qrc
|
|
||||||
PREFIX "/kxmlgui5/pineapple-notepad"
|
|
||||||
FILES pineapple-notepadui.rc
|
|
||||||
)
|
|
||||||
|
|
||||||
kconfig_add_kcfg_files(pineapple-notepad GENERATE_MOC appsettings.kcfgc)
|
|
||||||
|
|
||||||
target_link_libraries(pineapple-notepad
|
|
||||||
PRIVATE
|
|
||||||
Qt6::Widgets
|
|
||||||
KF6::XmlGui
|
|
||||||
KF6::CoreAddons
|
|
||||||
KF6::I18n
|
|
||||||
KF6::ConfigWidgets
|
|
||||||
KF6::IconThemes
|
|
||||||
qscintilla2_qt6
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
Pineapple Notepad - End User License Agreement
|
||||||
|
|
||||||
|
LICENSE GRANT
|
||||||
|
|
||||||
|
Gary "BLumia" Wang ("Licensor") grants you ("Licensee") a non-exclusive, non-transferable,
|
||||||
|
royalty-free license to install and use Pineapple Notepad ("Software") for both personal
|
||||||
|
and commercial purposes. You may use this software within your business, for-profit projects,
|
||||||
|
or professional services.
|
||||||
|
|
||||||
|
RESTRICTIONSs
|
||||||
|
|
||||||
|
* No Resale: You may not sell, rent, lease, sublicense, or distribute the Software for money,
|
||||||
|
nor may you bundle the Software with other products or services for sale.
|
||||||
|
* No Modification: You may not modify, reverse engineer, decompile, or disassemble the Software.
|
||||||
|
* No Rebranding: You may not remove any copyright notices, branding, or logos from the Software.
|
||||||
|
|
||||||
|
OWNERSHIP
|
||||||
|
|
||||||
|
The Software is licensed, not sold. The Licensor retains all title, copyright, and other
|
||||||
|
intellectual property rights in the Software.
|
||||||
|
|
||||||
|
DISCLAIMER OF WARRANTY
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||||
|
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
||||||
|
NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||||
|
DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
|
||||||
|
This license is effective until terminated. Your rights under this license will terminate
|
||||||
|
automatically without notice from the Licensor if you fail to comply with any term(s) of
|
||||||
|
this license.
|
||||||
@@ -1,16 +1,107 @@
|
|||||||
# Pineapple Notepad?
|
# Pineapple Notepad
|
||||||
|
|
||||||
## 说明
|
Pineapple Notepad aims to be a simple, lightweight, and easy to use notepad application that can be a cross-platform alternative to Notepad++. It's based on [Scintilla](https://www.scintilla.org/), [Qt](https://www.qt.io/) and [KDE Framework](https://develop.kde.org/products/frameworks/), available on Windows, Linux[^7] and macOS[^8].
|
||||||
|
|
||||||
这是一个用来实验 KDE Framework 的项目(主要是 Widgets 相关的组件),此项目本身(至少目前)不是一个能用的文本编辑器,甚至可以说实际上什么功能都没有。
|
[^7]: Before reaching the Open Source sponsor goal, it will only available on Debian 13, Ubuntu 26.04 and deepin 25 amd64 version. Please consider become a sponsor to make me be able to reach the Open Source goal so it will be available on more distros and make porting possible.
|
||||||
|
[^8]: Available since `0.2.0`. Bundle will not be signed.
|
||||||
|
|
||||||
现阶段,MSYS2 仓库的 KF6 组件已足以构建基本的应用程序,并包括一些优点。
|
## Pricing
|
||||||
|
|
||||||
- KXmlGui: 提供了一个便于创建与管理 QAction 的框架,可以便于将 Action 注册到菜单栏、工具栏,甚至还有一个命令搜索条。工具栏中的项目可由用户自由调整。`xxxxui.rc`
|
Pineapple Notepad itself is free of charge, even for commercial purposes. Please review `LICENSE` file for details.
|
||||||
- KConfig: 提供了一个基于 XML 文件生成配置管理工具类的解决方案。`xxx.kcfg`(配置文件结构本体)与 `xxx.kcfgc`(如何生成工具类的配置)
|
|
||||||
- KConfigWidgets: 一系列配套组件,包括:
|
Note that it's *currently* closed source. See the "Open Source Goal" section if you want to support Pineapple Notepad and make it open source. Please consider donate!
|
||||||
- KConfigDialog: 提供一个包括多个页的配置对话框,将若干页面加入此对话框,且根据 KConfig 生成的工具类自动更新每个页面的控件(页面内的控件需使用 `kcfg_配置名称` 作为对象名称)。
|
|
||||||
- KHamburgerMenu: 汉堡菜单
|
## Feature Comparation Table
|
||||||
- KStyleManager: 用于初始化 breeze 主题(和配置似乎没啥关系..)
|
|
||||||
- KColorSchemeMenu: 提供切换主题的菜单项(MSYS2 下,KColorSchemeMenu 实际列出的可用主题只有默认和暗色两个?)
|
| Feature | `Pineapple Notepad` | `Notepad++` | `Notepad Next` | `Notepad--` | `Kate` |
|
||||||
- KIconTheme: 初始化图标主题,需要在 QApplication 构造之前调用初始化,并且看上去需要配合什么别的东西才能做到颜色正确...
|
| ------- | ------------------- | ----------- | -------------- | ----------- | ------ |
|
||||||
|
| Open Source | ❔[^1] | ✅ | ✅ | ❌ | ✅ |
|
||||||
|
| Cross Platform | ✅ | ❌ (Win-only) | ✅ | ✅ | ✅ |
|
||||||
|
| Text Encoding | ✅ | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| Show All Characters | ✅ | ✅ | ⚠️[^2] | ⚠️[^2] | ⚠️[^4] |
|
||||||
|
| Session Restore | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| Hi-DPI Support | ✅ | ⚠️[^3] | ✅ | ⚠️[^3] | ✅ |
|
||||||
|
| Dark Theme Support | ✅ | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| Side-by-Side View | ℹ️[^5] | ✅ | ✅ | ❌ | ✅ |
|
||||||
|
| Customizable Toolbar | ✅ | ❌ | ❌ | ❌ | ✅ |
|
||||||
|
| Macro Recording | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||||
|
| Change History | ✅ | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| Smart Highlight [^6] | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| `tail -f` Mode | ✅ | ✅ | ❌ | ✅ | ℹ️[^9] |
|
||||||
|
| Search Result Pane | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| Folder Pane | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| Document Map | ✅ | ✅ | ❌ | ❌ | ✅ |
|
||||||
|
| "Run..." Dialog | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||||
|
| Interval Backup | 🚧[^10] | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| Editor Engine | Scintilla | Scintilla | Scintilla | QScintilla | KTextEdit |
|
||||||
|
| Regex Engine | RESearch [^11] | Boost.Regex | QRegularExpression | Boost.Regex [^12] | QRegularExpression |
|
||||||
|
|
||||||
|
[^1]: Currently not open-sourced. Planned to be Open Source once Open Source Sponsor Goal is reached (please consider donate!). Tier 2 sponsors can also get the full source code for building and auditing purpose before the goal is reached.
|
||||||
|
[^2]: Some non-printable characters are not able to be shown.
|
||||||
|
[^3]: Some components have known issues with Hi-DPI support.
|
||||||
|
[^4]: I created an add-on for this feature, but currently showing line ending is not possible to implement.
|
||||||
|
[^5]: Currently only available as an experimental version in sponsor tier, will be available in future releases once Open Source Sponsor Goal is reached.
|
||||||
|
[^6]: Highlight selected word in the editor.
|
||||||
|
[^9]: Enable "Read-only" mode and also enable "Auto-reload" mode to get similar experience.
|
||||||
|
[^10]: Currently WIP, planned to be available in 0.8.0 releases (or 0.7.z for sponsor early access).
|
||||||
|
[^11]: RESearch is Scintilla's built-in regex engine. I do plan to replace it with a QRegularExpression-based solution in 0.8.0 release.
|
||||||
|
[^12]: According to their pre-existing legacy code and their current dynamic library, they are reusing the same implementation that Notepad++ is using (BoostRegExSearch).
|
||||||
|
|
||||||
|
## Open Source Goal
|
||||||
|
|
||||||
|
Pineapple Notepad is currently not an open source project, but the goal is to make Pineapple Notepad open source. I've set-up a $150 Ko-fi goal that Pineapple Notepad will be released as an Open-Source project if the goal is reached. Please read [this post](https://ko-fi.com/post/Pineapple-Notepad-A-Cross-platform-Notepad--Alte-G2G71V8JPX) for details. If you're interested, please use the following links to support this project.
|
||||||
|
|
||||||
|
### Sponsor Benefits
|
||||||
|
|
||||||
|
Before the goal is reached, if you support Pineapple Notepad for equial or more than $10, you can be credited within the application's About dialog as a kickstart supporter.
|
||||||
|
|
||||||
|
Please read the following details for sponsor benefits and possible restrictions.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
All listed benefits below only apply to sponsors who donate **before** we reach the Open Source goal.
|
||||||
|
|
||||||
|
#### Tier 1: 10 USD
|
||||||
|
|
||||||
|
- Get pre-released builds of Pineapple Notepad.
|
||||||
|
- Get experimental builds of Pineapple Notepad.
|
||||||
|
- You (individual) will be credited within the application's About dialog as a kickstart supporter.
|
||||||
|
- The name will be kept for at least 10 releases, after that, the name might be moved a standalone `THANKS` file in the source repository.
|
||||||
|
- Optional email and/or home page could be provided.
|
||||||
|
- Restriction applies (Please reach out if you have any questions or not sure if it applies to you):
|
||||||
|
- The name, email and/or link to your home page should not contain political content, any emoji or other contents might cause me trouble.
|
||||||
|
|
||||||
|
#### Tier 2: 35 USD
|
||||||
|
|
||||||
|
- All benefits of Tier 1
|
||||||
|
- Get full source code of Pineapple Notepad that allows you build it from source or audit it.
|
||||||
|
- You (company/organization) will be credited within the application's About dialog as a sponsor.
|
||||||
|
- The name will be kept for at least 10 releases, after that, the name might be moved a standalone `THANKS` file in the source repository.
|
||||||
|
- Optional email and/or home page could be provided.
|
||||||
|
- Restriction applies (Please reach out if you have any questions or not sure if it applies to you):
|
||||||
|
- The name, email and/or link to your home page should not contain political content, any emoji or other contents might cause me trouble.
|
||||||
|
- Gambling, blockchain, adult content and/or other similar contents are not allowed.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
*If you have questions about sponsor benefits, please reach out to me by creating an issue or drop me a message on Ko-fi or any other form that can be reached.*
|
||||||
|
|
||||||
|
### Funding
|
||||||
|
|
||||||
|
[](https://ko-fi.com/blumia)
|
||||||
|
|
||||||
|
[Afdian](https://afdian.com/a/BLumia)
|
||||||
|
|
||||||
|
### Related Open-Sourced Projects
|
||||||
|
|
||||||
|
Some associated projects are already open-sourced:
|
||||||
|
|
||||||
|
- [kf6redist](https://github.com/BLumia/kf6redist): KDE Framework redistribution building scripts and patches.
|
||||||
|
- [libintl](https://github.com/BLumia/libintl): Patched libintl for easier build with CMake.
|
||||||
|
- [icoutils-rs](https://github.com/BLumia/icoutils-rs): drop-in, portable replacement for icoutils's `icotool`.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Pineapple Notepad is released under Pineapple Notepad End User License Agreement.
|
||||||
|
|
||||||
|
This section will be updated once the Open Source goal is reached.
|
||||||
+106
@@ -0,0 +1,106 @@
|
|||||||
|
# 菠萝记事本
|
||||||
|
|
||||||
|
菠萝记事本致力于成为一个简单、轻量且易于使用的记事本应用程序,可以作为 Notepad++ 的跨平台替代品。它基于 [Scintilla](https://www.scintilla.org/)、[Qt](https://www.qt.io/) 和 [KDE Framework](https://develop.kde.org/products/frameworks/),可在 Windows、Linux[^7] 和 macOS[^8] 上使用。
|
||||||
|
|
||||||
|
[^7]: 在达到开源赞助目标之前,它将仅在 Debian 13,Ubuntu 26.04 与 deepin 25 的 amd64 版本上可用。请考虑成为赞助者,使我能够达到开源目标,这样它将在更多发行版上可用,并使移植成为可能。
|
||||||
|
[^8]: 从 `0.2.0` 版本开始可用。捆绑包将不会被签名。
|
||||||
|
|
||||||
|
## 定价
|
||||||
|
|
||||||
|
菠萝记事本本身是免费的,包括商业用途在内。请查看 `LICENSE` 文件了解详情。
|
||||||
|
|
||||||
|
请注意,此项目*目前*是闭源的。如果您想支持菠萝记事本并使其开源,请参阅"开源目标"部分。请考虑捐赠!
|
||||||
|
|
||||||
|
## 功能比较表
|
||||||
|
|
||||||
|
| 功能 | `菠萝记事本` | `Notepad++` | `Notepad Next` | `Notepad--` | `Kate` |
|
||||||
|
| --------- | ----------- | ----------- | -------------- | ----------- | ------ |
|
||||||
|
| 开源 | ❔[^1] | ✅ | ✅ | ❌ | ✅ |
|
||||||
|
| 跨平台 | ✅ | ❌ (仅 Windows) | ✅ | ✅ | ✅ |
|
||||||
|
| 文本编码 | ✅ | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| 显示所有字符 | ✅ | ✅ | ⚠️[^2] | ⚠️[^2] | ⚠️[^4] |
|
||||||
|
| 会话恢复 | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| 高分屏支持 | ✅ | ⚠️[^3] | ✅ | ⚠️[^3] | ✅ |
|
||||||
|
| 深色主题支持 | ✅ | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| 并排视图 | ℹ️[^5] | ✅ | ✅ | ❌ | ✅ |
|
||||||
|
| 可自定义工具栏 | ✅ | ❌ | ❌ | ❌ | ✅ |
|
||||||
|
| 宏录制 | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||||
|
| 更改历史 | ✅ | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| 智能高亮 [^6] | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| `tail -f` 模式 | ✅ | ✅ | ❌ | ✅ | ℹ️[^9] |
|
||||||
|
| 搜索结果面板 | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| 文件夹面板 | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| 文档结构图 | ✅ | ✅ | ❌ | ❌ | ✅ |
|
||||||
|
| 运行对话框 | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||||
|
| 定时周期备份 | 🚧[^10] | ✅ | ❌ | ✅ | ✅ |
|
||||||
|
| 编辑器引擎 | Scintilla | Scintilla | Scintilla | QScintilla | KTextEdit |
|
||||||
|
| 正则引擎 | RESearch [^11] | Boost.Regex | QRegularExpression | Boost.Regex [^12] | QRegularExpression |
|
||||||
|
|
||||||
|
[^1]: 目前未开源。计划在达到开源赞助目标后开源(请考虑捐赠!)。第二档位的赞助者也可在开源目标达成前提前获取完整源码以供自行构建和代码审查。
|
||||||
|
[^2]: 某些不可打印字符无法显示。
|
||||||
|
[^3]: 某些组件在高分辨率支持方面存在已知问题。
|
||||||
|
[^4]: 我为此功能创建了一个插件,但目前无法实现显示行尾符。
|
||||||
|
[^5]: 当前仅作为实验性版本提供给赞助者,若开源目标达成后则会在未来版本中可用。
|
||||||
|
[^6]: 在编辑器中高亮选中的单词。
|
||||||
|
[^9]: 需启用只读模式并启用自动重载来获得近似体验。
|
||||||
|
[^10]: 当前施工中,计划在 0.8.0 版本(或者面向赞助者的 0.7.z 版本)中提供。
|
||||||
|
[^11]: RESearch 是 Scintilla 的内置正则引擎。我计划在 0.8.0 版本将其替换为基于 QRegularExpression 的解决方案。
|
||||||
|
[^12]: 根据其原有旧代码和当前的动态库的情况,其目前实现复用了来自 Notepad++ 的正则引擎实现(BoostRegExSearch)。
|
||||||
|
|
||||||
|
## 开源目标
|
||||||
|
|
||||||
|
菠萝记事本目前不是一个开源项目,但目标是使菠萝记事本成为开源软件。我已设定了一个 1000 元的开源目标,如果达到该目标,Pineapple Notepad 将作为开源项目发布。请阅读[这篇文章](https://ko-fi.com/post/Pineapple-Notepad-A-Cross-platform-Notepad--Alte-G2G71V8JPX)了解详情。如果您有兴趣,请使用以下链接支持此项目。
|
||||||
|
|
||||||
|
### 赞助权益
|
||||||
|
|
||||||
|
在达到目标之前,如果您支持菠萝记事本达到或超过 50 元,您可以让您的名字出现在应用程序的"关于"对话框的特别致谢中。
|
||||||
|
|
||||||
|
请阅读以下详情了解赞助权益和可能的限制。
|
||||||
|
|
||||||
|
<details>
|
||||||
|
|
||||||
|
下面列出的所有权益仅适用于在达到开源目标**之前**捐赠的赞助者。
|
||||||
|
|
||||||
|
#### 第 1 档:50 元
|
||||||
|
|
||||||
|
- 获取菠萝记事本的预发布版本。
|
||||||
|
- 您(个人)将在应用程序的"关于"对话框中被列为启动支持者。
|
||||||
|
- 该名称将保留至少 10 个版本,之后可能会移动到源代码仓库中的独立 `THANKS` 文件。
|
||||||
|
- 可以提供可选的电子邮件和/或主页。
|
||||||
|
- 适用限制(如果您有任何疑问或不确定是否适用于您,请联系我):
|
||||||
|
- 您的名称、电子邮件和/或主页链接不应包含政治内容、任何表情符号或其他可能给我带来麻烦的内容。
|
||||||
|
|
||||||
|
#### 第 2 档:200 元
|
||||||
|
|
||||||
|
- 第 1 档的所有权益
|
||||||
|
- 获取菠萝记事本的完整源代码,允许您从源代码构建或进行审计。
|
||||||
|
- 您(公司/组织)将在应用程序的"关于"对话框中被列为赞助者。
|
||||||
|
- 该名称将保留至少 10 个版本,之后可能会移动到源代码仓库中的独立 `THANKS` 文件。
|
||||||
|
- 可以提供可选的电子邮件和/或主页。
|
||||||
|
- 适用限制(如果您有任何疑问或不确定是否适用于您,请联系我):
|
||||||
|
- 您的名称、电子邮件和/或主页链接不应包含政治内容、任何表情符号或其他可能给我带来麻烦的内容。
|
||||||
|
- 恕不接受赌博、区块链、成人内容和/或其他类似内容。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
*如果您对赞助权益有任何疑问,请通过创建 Issue 或在 Ko-fi 上给我留言或其他任何可以联系到我的方式与我取得联系。*
|
||||||
|
|
||||||
|
### 资助
|
||||||
|
|
||||||
|
[](https://ko-fi.com/blumia)
|
||||||
|
|
||||||
|
[爱发电](https://afdian.com/a/BLumia)
|
||||||
|
|
||||||
|
### 相关的开源项目
|
||||||
|
|
||||||
|
一些与此项目关联的项目已开源:
|
||||||
|
|
||||||
|
- [kf6redist](https://github.com/BLumia/kf6redist): KDE Framework 再分发版本的构建脚本和相关补丁。
|
||||||
|
- [libintl](https://github.com/BLumia/libintl): 可供 CMake 构建的 libintl 版本。
|
||||||
|
- [icoutils-rs](https://github.com/BLumia/icoutils-rs): icoutils 的 `icotool` 工具的单可执行文件便携替代实现。
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
菠萝记事本根据《菠萝记事本最终用户许可协议》发布。
|
||||||
|
|
||||||
|
达到开源目标后,此部分将更新。
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
|
||||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
|
||||||
<kcfgfile name="pineapple-notepadrc" />
|
|
||||||
<include>QFontDatabase</include>
|
|
||||||
<group name="Editor">
|
|
||||||
<entry name="tabWidth" type="int">
|
|
||||||
<default>4</default>
|
|
||||||
</entry>
|
|
||||||
<entry name="editorFont" type="Font" key="editor-font">
|
|
||||||
<default code="true">QFontDatabase::systemFont(QFontDatabase::FixedFont)</default>
|
|
||||||
</entry>
|
|
||||||
</group>
|
|
||||||
</kcfg>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
File=appsettings.kcfg
|
|
||||||
ClassName=AppSettings
|
|
||||||
Mutators=true
|
|
||||||
DefaultValueGetters=true
|
|
||||||
GenerateProperties=true
|
|
||||||
ParentInConstructor=true
|
|
||||||
Notifiers=true
|
|
||||||
Singleton=true
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
#include "editorviewhelper.h"
|
|
||||||
|
|
||||||
#include <QActionGroup>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
#include <KActionMenu>
|
|
||||||
|
|
||||||
#include <Qsci/qsciscintilla.h>
|
|
||||||
#include <Qsci/qscilexer.h>
|
|
||||||
#include <Qsci/qscilexerbash.h>
|
|
||||||
#include <Qsci/qscilexerbatch.h>
|
|
||||||
#include <Qsci/qscilexercpp.h>
|
|
||||||
#include <Qsci/qscilexercmake.h>
|
|
||||||
#include <Qsci/qscilexercsharp.h>
|
|
||||||
#include <Qsci/qscilexercss.h>
|
|
||||||
#include <Qsci/qscilexerd.h>
|
|
||||||
#include <Qsci/qscilexerdiff.h>
|
|
||||||
#include <Qsci/qscilexerhtml.h>
|
|
||||||
#include <Qsci/qscilexerjava.h>
|
|
||||||
#include <Qsci/qscilexerjavascript.h>
|
|
||||||
#include <Qsci/qscilexerjson.h>
|
|
||||||
#include <Qsci/qscilexerlua.h>
|
|
||||||
#include <Qsci/qscilexermakefile.h>
|
|
||||||
#include <Qsci/qscilexermarkdown.h>
|
|
||||||
#include <Qsci/qscilexerpascal.h>
|
|
||||||
#include <Qsci/qscilexerperl.h>
|
|
||||||
#include <Qsci/qscilexerpo.h>
|
|
||||||
#include <Qsci/qscilexerpython.h>
|
|
||||||
#include <Qsci/qscilexerruby.h>
|
|
||||||
#include <Qsci/qscilexerxml.h>
|
|
||||||
#include <Qsci/qscilexeryaml.h>
|
|
||||||
|
|
||||||
const QStringList languages_group[] = {
|
|
||||||
QStringList{
|
|
||||||
"Bash", "Batch"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"C", "C++", "C#", "CMake", "CSS"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"D", "Diff"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"HTML"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"Java", "JavaScript", "JSON"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"Lua"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"Makefile", "Markdown"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"Pascal", "Perl", "PO", "Python"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"Ruby"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"XML"
|
|
||||||
},
|
|
||||||
QStringList{
|
|
||||||
"YAML"
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
QString LexerGroupActionMenu::groupName(LanguageGroup grp)
|
|
||||||
{
|
|
||||||
switch (grp) {
|
|
||||||
case LANG_GRP_B:
|
|
||||||
return QLatin1String("B");
|
|
||||||
case LANG_GRP_C:
|
|
||||||
return QLatin1String("C");
|
|
||||||
case LANG_GRP_D:
|
|
||||||
return QLatin1String("D");
|
|
||||||
case LANG_GRP_H:
|
|
||||||
return QLatin1String("H");
|
|
||||||
case LANG_GRP_J:
|
|
||||||
return QLatin1String("J");
|
|
||||||
case LANG_GRP_L:
|
|
||||||
return QLatin1String("L");
|
|
||||||
case LANG_GRP_M:
|
|
||||||
return QLatin1String("M");
|
|
||||||
case LANG_GRP_P:
|
|
||||||
return QLatin1String("P");
|
|
||||||
case LANG_GRP_R:
|
|
||||||
return QLatin1String("R");
|
|
||||||
case LANG_GRP_X:
|
|
||||||
return QLatin1String("X");
|
|
||||||
case LANG_GRP_Y:
|
|
||||||
return QLatin1String("Y");
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_UNREACHABLE_RETURN("");
|
|
||||||
}
|
|
||||||
|
|
||||||
QsciLexer * LexerGroupActionMenu::createLexerByLanguage(const QString &languageName)
|
|
||||||
{
|
|
||||||
QsciLexer * ret = nullptr;
|
|
||||||
if (languageName == "Bash") {
|
|
||||||
ret = new QsciLexerBash();
|
|
||||||
} else if (languageName == "Batch") {
|
|
||||||
ret = new QsciLexerBatch();
|
|
||||||
} else if (languageName == "C" || languageName == "C++") {
|
|
||||||
ret = new QsciLexerCPP();
|
|
||||||
} else if (languageName == "C#") {
|
|
||||||
ret = new QsciLexerCSharp();
|
|
||||||
} else if (languageName == "CMake") {
|
|
||||||
ret = new QsciLexerCMake();
|
|
||||||
} else if (languageName == "CSS") {
|
|
||||||
ret = new QsciLexerCSS();
|
|
||||||
} else if (languageName == "D") {
|
|
||||||
ret = new QsciLexerD();
|
|
||||||
} else if (languageName == "Diff") {
|
|
||||||
ret = new QsciLexerDiff();
|
|
||||||
} else if (languageName == "HTML") {
|
|
||||||
ret = new QsciLexerHTML();
|
|
||||||
} else if (languageName == "Java") {
|
|
||||||
ret = new QsciLexerJava();
|
|
||||||
} else if (languageName == "JavaScript") {
|
|
||||||
ret = new QsciLexerJavaScript();
|
|
||||||
} else if (languageName == "JSON") {
|
|
||||||
ret = new QsciLexerJSON();
|
|
||||||
} else if (languageName == "Lua") {
|
|
||||||
ret = new QsciLexerLua();
|
|
||||||
} else if (languageName == "Makefile") {
|
|
||||||
ret = new QsciLexerMakefile();
|
|
||||||
} else if (languageName == "Markdown") {
|
|
||||||
ret = new QsciLexerMarkdown();
|
|
||||||
} else if (languageName == "Pascal") {
|
|
||||||
ret = new QsciLexerPascal();
|
|
||||||
} else if (languageName == "Perl") {
|
|
||||||
ret = new QsciLexerPerl();
|
|
||||||
} else if (languageName == "PO") {
|
|
||||||
ret = new QsciLexerPO();
|
|
||||||
} else if (languageName == "Python") {
|
|
||||||
ret = new QsciLexerPython();
|
|
||||||
} else if (languageName == "Ruby") {
|
|
||||||
ret = new QsciLexerRuby();
|
|
||||||
} else if (languageName == "XML") {
|
|
||||||
ret = new QsciLexerXML();
|
|
||||||
} else if (languageName == "YAML") {
|
|
||||||
ret = new QsciLexerYAML();
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LexerGroupActionMenu::slotAboutToShow()
|
|
||||||
{
|
|
||||||
if (!m_group) {
|
|
||||||
m_group = new QActionGroup(menu());
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const QString & name : languages_group[m_languageGroup]) {
|
|
||||||
QAction *a = menu()->addAction(name, this, [this, name](){
|
|
||||||
emit lexerSelected(name);
|
|
||||||
});
|
|
||||||
a->setActionGroup(m_group);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <KActionMenu>
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
class QsciLexer;
|
|
||||||
class LexerGroupActionMenu : public KActionMenu
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
enum LanguageGroup {
|
|
||||||
LANG_GRP_B,
|
|
||||||
LANG_GRP_C,
|
|
||||||
LANG_GRP_D,
|
|
||||||
LANG_GRP_H,
|
|
||||||
LANG_GRP_J,
|
|
||||||
LANG_GRP_L,
|
|
||||||
LANG_GRP_M,
|
|
||||||
LANG_GRP_P,
|
|
||||||
LANG_GRP_R,
|
|
||||||
LANG_GRP_X,
|
|
||||||
LANG_GRP_Y,
|
|
||||||
LANG_GRP_LAST = LANG_GRP_Y
|
|
||||||
};
|
|
||||||
LexerGroupActionMenu(const QString &text, enum LanguageGroup grp, QObject *parent)
|
|
||||||
: KActionMenu(text, parent)
|
|
||||||
{
|
|
||||||
m_group = nullptr;
|
|
||||||
m_languageGroup = grp;
|
|
||||||
connect(menu(), &QMenu::aboutToShow, this, &LexerGroupActionMenu::slotAboutToShow);
|
|
||||||
setPopupMode(QToolButton::InstantPopup);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QString groupName(enum LanguageGroup grp);
|
|
||||||
static QsciLexer * createLexerByLanguage(const QString & languageName);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void lexerSelected(const QString lexerName);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QActionGroup *m_group;
|
|
||||||
enum LanguageGroup m_languageGroup;
|
|
||||||
|
|
||||||
public:
|
|
||||||
void slotAboutToShow();
|
|
||||||
};
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>GeneralSettings</class>
|
|
||||||
<widget class="QWidget" name="GeneralSettings">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>406</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QFormLayout" name="formLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>tAB wIDTH</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QSpinBox" name="kcfg_tabWidth">
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>eDITOR fONT</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="KFontRequester" name="kcfg_editorFont"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>KFontRequester</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>kfontrequester.h</header>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#include <QApplication>
|
|
||||||
|
|
||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
#include <KAboutData>
|
|
||||||
#include <KLocalizedString>
|
|
||||||
#include <KIconTheme>
|
|
||||||
#include <KStyleManager>
|
|
||||||
#include <QSci/qsciglobal.h>
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
KIconTheme::initTheme();
|
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
|
||||||
|
|
||||||
KStyleManager::initStyle();
|
|
||||||
|
|
||||||
KLocalizedString::setApplicationDomain(QByteArrayLiteral("pineapple-notepad"));
|
|
||||||
|
|
||||||
KAboutData aboutData(QStringLiteral("pineapple-notepad"),
|
|
||||||
"Pineapple Notepad(迫真)",
|
|
||||||
QStringLiteral("0.1"),
|
|
||||||
"A Scintilla-based Text Editor",
|
|
||||||
KAboutLicense::Unknown,
|
|
||||||
QString(),
|
|
||||||
QString(),
|
|
||||||
QStringLiteral("https://blumia.net"));
|
|
||||||
aboutData.addComponent("QsciScintilla", "A port to Qt6 of Neil Hodgson's Scintilla C++ editor class",
|
|
||||||
QSCINTILLA_VERSION_STR, "https://www.riverbankcomputing.com/software/qscintilla/intro");
|
|
||||||
KAboutData::setApplicationData(aboutData);
|
|
||||||
a.setWindowIcon(QIcon::fromTheme(QStringLiteral("accessories-text-editor")));
|
|
||||||
|
|
||||||
MainWindow mw;
|
|
||||||
mw.show();
|
|
||||||
|
|
||||||
return a.exec();
|
|
||||||
}
|
|
||||||
-181
@@ -1,181 +0,0 @@
|
|||||||
#include "mainwindow.h"
|
|
||||||
|
|
||||||
#include "appsettings.h"
|
|
||||||
#include "editorviewhelper.h"
|
|
||||||
|
|
||||||
#include <QActionGroup>
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QStringBuilder>
|
|
||||||
#include <QStatusBar>
|
|
||||||
|
|
||||||
#include <KActionCollection>
|
|
||||||
#include <KStandardAction>
|
|
||||||
#include <KActionMenu>
|
|
||||||
#include <KConfigDialog>
|
|
||||||
#include <KColorSchemeManager>
|
|
||||||
#include <KColorSchemeMenu>
|
|
||||||
#include <QSpinBox>
|
|
||||||
|
|
||||||
#include <Qsci/qsciscintilla.h>
|
|
||||||
#include <Qsci/qscilexer.h>
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
|
||||||
: KXmlGuiWindow(parent)
|
|
||||||
, m_editor(new QsciScintilla(this))
|
|
||||||
, m_cursorPosStatusLabel(new QLabel(QString("Ln: ? Col: ?")))
|
|
||||||
{
|
|
||||||
setCentralWidget(m_editor);
|
|
||||||
|
|
||||||
statusBar()->addPermanentWidget(m_cursorPosStatusLabel);
|
|
||||||
|
|
||||||
QFont font(AppSettings::self()->editorFont());
|
|
||||||
m_editor->setFont(font);
|
|
||||||
m_editor->setMarginsFont(font);
|
|
||||||
|
|
||||||
m_editor->setMarginLineNumbers(1, true);
|
|
||||||
m_editor->setMarginWidth(1, 40);
|
|
||||||
m_editor->setFolding(QsciScintilla::BoxedTreeFoldStyle);
|
|
||||||
m_editor->setBraceMatching(QsciScintilla::SloppyBraceMatch);
|
|
||||||
|
|
||||||
m_editor->setTabWidth(AppSettings::self()->tabWidth());
|
|
||||||
m_editor->setEolMode(QsciScintilla::EolUnix);
|
|
||||||
|
|
||||||
connect(m_editor, &QsciScintilla::cursorPositionChanged, this, [this](int line, int index){
|
|
||||||
// FIXME: not get called at all?
|
|
||||||
qDebug() << line << index;
|
|
||||||
m_cursorPosStatusLabel->setText(QString("Ln: %1 Col: %2").arg(line, index));
|
|
||||||
});
|
|
||||||
|
|
||||||
setupActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::setupActions()
|
|
||||||
{
|
|
||||||
using namespace Qt::Literals::StringLiterals;
|
|
||||||
|
|
||||||
// "File" menu
|
|
||||||
KStandardAction::openNew(this, [](){}, actionCollection());
|
|
||||||
KStandardAction::open(this, [](){}, actionCollection());
|
|
||||||
KStandardAction::save(this, [](){}, actionCollection());
|
|
||||||
KStandardAction::close(this, [](){}, actionCollection());
|
|
||||||
KStandardAction::quit(qApp, &QApplication::quit, actionCollection());
|
|
||||||
|
|
||||||
// "Edit" menu
|
|
||||||
KStandardAction::undo(this, [this](){
|
|
||||||
m_editor->undo();
|
|
||||||
}, actionCollection());
|
|
||||||
KStandardAction::redo(this, [this](){
|
|
||||||
m_editor->redo();
|
|
||||||
}, actionCollection());
|
|
||||||
KStandardAction::cut(this, [this](){
|
|
||||||
m_editor->cut();
|
|
||||||
}, actionCollection());
|
|
||||||
KStandardAction::copy(this, [this](){
|
|
||||||
m_editor->copy();
|
|
||||||
}, actionCollection());
|
|
||||||
KStandardAction::paste(this, [this](){
|
|
||||||
m_editor->paste();
|
|
||||||
}, actionCollection());
|
|
||||||
|
|
||||||
// "Search" menu
|
|
||||||
KStandardAction::find(this, [](){}, actionCollection());
|
|
||||||
KStandardAction::findNext(this, [](){}, actionCollection());
|
|
||||||
KStandardAction::findPrev(this, [](){}, actionCollection());
|
|
||||||
KStandardAction::replace(this, [](){}, actionCollection());
|
|
||||||
qDebug() << KStandardAction::name(KStandardAction::Replace);
|
|
||||||
|
|
||||||
// "Language" menu
|
|
||||||
QAction *lexerNoneAction = new QAction(this);
|
|
||||||
lexerNoneAction->setText("None (Normal Text)");
|
|
||||||
actionCollection()->addAction(u"lexer_none"_s, lexerNoneAction);
|
|
||||||
connect(lexerNoneAction, &QAction::triggered, this, [this](){
|
|
||||||
m_editor->setLexer(nullptr);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (int i = 0; i <= LexerGroupActionMenu::LANG_GRP_LAST; i++) {
|
|
||||||
LexerGroupActionMenu::LanguageGroup group = static_cast<LexerGroupActionMenu::LanguageGroup>(i);
|
|
||||||
const QString groupName(LexerGroupActionMenu::groupName(group));
|
|
||||||
LexerGroupActionMenu *lexerGroupMenu = new LexerGroupActionMenu(groupName, group, this);
|
|
||||||
actionCollection()->addAction(QStringLiteral("lexer_group_") % groupName.toLower(), lexerGroupMenu);
|
|
||||||
connect(lexerGroupMenu, &LexerGroupActionMenu::lexerSelected, this, &MainWindow::applyLexer);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toolbar actions
|
|
||||||
KStandardAction::zoomIn(this, [this](){
|
|
||||||
m_editor->zoomIn();
|
|
||||||
}, actionCollection());
|
|
||||||
KStandardAction::zoomOut(this, [this](){
|
|
||||||
m_editor->zoomOut();
|
|
||||||
}, actionCollection());
|
|
||||||
|
|
||||||
KStandardAction::preferences(this, &MainWindow::showSettings, actionCollection());
|
|
||||||
|
|
||||||
QAction *toggleWrapModeAction = new QAction(this);
|
|
||||||
toggleWrapModeAction->setText("Toggle Wrap Mode");
|
|
||||||
toggleWrapModeAction->setIcon(QIcon::fromTheme(u"text-wrap"_s));
|
|
||||||
toggleWrapModeAction->setCheckable(true);
|
|
||||||
actionCollection()->addAction(u"toggle_wrap_mode"_s, toggleWrapModeAction);
|
|
||||||
connect(toggleWrapModeAction, &QAction::triggered, this, [this, toggleWrapModeAction](){
|
|
||||||
bool switchToWrapNone = m_editor->wrapMode() == QsciScintilla::WrapWord;
|
|
||||||
m_editor->setWrapMode(switchToWrapNone ? QsciScintilla::WrapNone : QsciScintilla::WrapWord);
|
|
||||||
toggleWrapModeAction->setChecked(!switchToWrapNone);
|
|
||||||
});
|
|
||||||
|
|
||||||
QAction *toggleWhitespaceVisibilityAction = new QAction(this);
|
|
||||||
toggleWhitespaceVisibilityAction->setText("Show All Characters");
|
|
||||||
toggleWhitespaceVisibilityAction->setCheckable(true);
|
|
||||||
// toggleWhitespaceVisibilityAction->setIcon(QIcon::fromTheme(u"text-wrap"_s));
|
|
||||||
actionCollection()->addAction(u"toggle_show_all_characters"_s, toggleWhitespaceVisibilityAction);
|
|
||||||
connect(toggleWhitespaceVisibilityAction, &QAction::triggered, this, [this, toggleWhitespaceVisibilityAction](){
|
|
||||||
bool switchToVisible = m_editor->whitespaceVisibility() == QsciScintilla::WsInvisible;
|
|
||||||
m_editor->setWhitespaceVisibility(switchToVisible ? QsciScintilla::WsVisible : QsciScintilla::WsInvisible);
|
|
||||||
m_editor->setEolVisibility(switchToVisible);
|
|
||||||
toggleWhitespaceVisibilityAction->setChecked(switchToVisible);
|
|
||||||
});
|
|
||||||
|
|
||||||
QAction *toggleIndentGuideAction = new QAction(this);
|
|
||||||
toggleIndentGuideAction->setText("Toggle Indent Guide");
|
|
||||||
toggleIndentGuideAction->setIcon(QIcon::fromTheme(u"show-guides"_s));
|
|
||||||
actionCollection()->addAction(u"toggle_indent_guide"_s, toggleIndentGuideAction);
|
|
||||||
connect(toggleIndentGuideAction, &QAction::triggered, this, [this](){
|
|
||||||
m_editor->setIndentationGuides(!m_editor->indentationGuides());
|
|
||||||
});
|
|
||||||
|
|
||||||
// Load themes
|
|
||||||
KColorSchemeManager *manager = new KColorSchemeManager(this);
|
|
||||||
auto *colorSelectionMenu = KColorSchemeMenu::createMenu(manager, this);
|
|
||||||
colorSelectionMenu->menu()->setTitle("&Window Color Scheme");
|
|
||||||
actionCollection()->addAction(QStringLiteral("colorscheme_menu"), colorSelectionMenu);
|
|
||||||
|
|
||||||
setupGUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showSettings()
|
|
||||||
{
|
|
||||||
if (KConfigDialog::showDialog(QStringLiteral("settings"))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), AppSettings::self());
|
|
||||||
dialog->setFaceType(KPageDialog::FlatList);
|
|
||||||
dialog->addPage(new SettingsPage<Ui::GeneralSettings>(dialog), "Appearance", "preferences-desktop-theme-global");
|
|
||||||
|
|
||||||
connect(dialog, &KConfigDialog::settingsChanged, this, [](const QString &dialogName){
|
|
||||||
qDebug() << dialogName << "changed";
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::applyLexer(const QString &lexer)
|
|
||||||
{
|
|
||||||
QsciLexer * ret = LexerGroupActionMenu::createLexerByLanguage(lexer);
|
|
||||||
if (ret) {
|
|
||||||
ret->setFont(AppSettings::self()->editorFont());
|
|
||||||
}
|
|
||||||
m_editor->setLexer(ret);
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <KXmlGuiWindow>
|
|
||||||
|
|
||||||
#include "ui_GeneralSettings.h"
|
|
||||||
|
|
||||||
class QLabel;
|
|
||||||
class QsciScintilla;
|
|
||||||
class MainWindow : public KXmlGuiWindow
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
|
||||||
~MainWindow();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void setupActions();
|
|
||||||
void showSettings();
|
|
||||||
void applyLexer(const QString & lexer);
|
|
||||||
|
|
||||||
QsciScintilla * m_editor;
|
|
||||||
QLabel * m_cursorPosStatusLabel;
|
|
||||||
};
|
|
||||||
|
|
||||||
// plainly for KConfigDialog
|
|
||||||
// void setupUi(QWidget *GeneralSettings)
|
|
||||||
template <typename T>
|
|
||||||
class SettingsPage : public QWidget
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SettingsPage(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
ui.setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T ui;
|
|
||||||
};
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!--
|
|
||||||
DTD: https://github.com/KDE/kxmlgui/blob/master/src/kpartgui.dtd
|
|
||||||
Template: https://github.com/KDE/kxmlgui/blob/master/src/ui_standards.rc
|
|
||||||
-->
|
|
||||||
<gui name="pineapple-notepad"
|
|
||||||
version="1"
|
|
||||||
xmlns="http://www.kde.org/standards/kxmlgui/1.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0
|
|
||||||
http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd">
|
|
||||||
<MenuBar>
|
|
||||||
<Menu name="file" >
|
|
||||||
</Menu>
|
|
||||||
<Menu name="edit">
|
|
||||||
</Menu>
|
|
||||||
<Menu name="search"><text>&Search</text>
|
|
||||||
<Action name="edit_find" />
|
|
||||||
<Action name="edit_find_next" />
|
|
||||||
<Action name="edit_find_prev" />
|
|
||||||
<Action name="edit_replace" />
|
|
||||||
</Menu>
|
|
||||||
<Menu name="view">
|
|
||||||
<!-- <Menu><text>&Zoom</text>
|
|
||||||
<Action name="view_zoom_in"/>
|
|
||||||
<Action name="view_zoom_out"/>
|
|
||||||
</Menu>-->
|
|
||||||
<Action name="toggle_wrap_mode" />
|
|
||||||
</Menu>
|
|
||||||
<Menu name="encoding"><text>E&ncoding</text>
|
|
||||||
</Menu>
|
|
||||||
<Menu name="language"><text>&Language</text>
|
|
||||||
<Action name="lexer_none" />
|
|
||||||
<Separator/>
|
|
||||||
<!-- FIXME: those lexer_group_ actions should be exclude from Edit ToolBar dialog -->
|
|
||||||
<Action name="lexer_group_b" />
|
|
||||||
<Action name="lexer_group_c" />
|
|
||||||
<Action name="lexer_group_d" />
|
|
||||||
<Action name="lexer_group_h" />
|
|
||||||
<Action name="lexer_group_j" />
|
|
||||||
<Action name="lexer_group_l" />
|
|
||||||
<Action name="lexer_group_m" />
|
|
||||||
<Action name="lexer_group_p" />
|
|
||||||
<Action name="lexer_group_r" />
|
|
||||||
<Action name="lexer_group_x" />
|
|
||||||
<Action name="lexer_group_y" />
|
|
||||||
</Menu>
|
|
||||||
<Menu name="settings">
|
|
||||||
<Action name="colorscheme_menu"/>
|
|
||||||
</Menu>
|
|
||||||
<!-- FIXME: This is NOT a KDE project -->
|
|
||||||
<menu name="help">
|
|
||||||
</menu>
|
|
||||||
</MenuBar>
|
|
||||||
<ToolBar name="mainToolBar" >
|
|
||||||
<text>Main Toolbar</text>
|
|
||||||
<Action name="toggle_wrap_mode" />
|
|
||||||
<Action name="toggle_show_all_characters" />
|
|
||||||
<Action name="toggle_indent_guide" />
|
|
||||||
</ToolBar>
|
|
||||||
</gui>
|
|
||||||
Reference in new issue
Block a user