13 |
14 | SW_About::SW_About(QWidget *parent) : QMainWindow(parent) {
15 | setWindowFlags(Qt::Dialog);
16 | setWindowModality(Qt::ApplicationModal);
17 | setWindowIcon(QIcon(QApplication::applicationDirPath() +
18 | "/resources/icons/solidwriting_icon.png"));
19 |
20 | QRect screenGeometry = QGuiApplication::primaryScreen()->availableGeometry();
21 | QRect alignedRect = QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter,
22 | size(), screenGeometry);
23 | setGeometry(alignedRect);
24 |
25 | QWidget *centralWidget = new QWidget(this);
26 | setCentralWidget(centralWidget);
27 | QVBoxLayout *mainLayout = new QVBoxLayout(centralWidget);
28 |
29 | aboutLabel = new QLabel(this);
30 | aboutLabel->setWordWrap(true);
31 | aboutLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
32 | aboutLabel->setTextFormat(Qt::RichText);
33 | aboutLabel->setText(
34 | ""
35 | "SolidWriting 2025.04
"
36 | "A supercharged word processor with AI integration, supporting real-time "
37 | "computing and advanced formatting.
"
38 | "Made by Berkay Gediz
"
39 | "GNU General Public License v3.0
GNU LESSER GENERAL PUBLIC LICENSE "
40 | "v3.0
Mozilla Public License Version 2.0
"
41 | "Libraries: ggml-org/llama.cpp
"
42 | "OpenGL: ON"
43 | "");
44 |
45 | mainLayout->addWidget(aboutLabel);
46 |
47 | QHBoxLayout *buttonLayout = new QHBoxLayout();
48 |
49 | donateGithub = new QPushButton("GitHub Sponsors", this);
50 | connect(donateGithub, &QPushButton::clicked, this,
51 | [=]() { donationLink("github"); });
52 | buttonLayout->addWidget(donateGithub);
53 |
54 | donateBuyMeACoffee = new QPushButton("Buy Me a Coffee", this);
55 | connect(donateBuyMeACoffee, &QPushButton::clicked, this,
56 | [=]() { donationLink("buymeacoffee"); });
57 | buttonLayout->addWidget(donateBuyMeACoffee);
58 |
59 | // QLabel *newLabel = new QLabel(this);
60 | // newLabel->setText(
61 | // Globals::translations[currentLanguage].value("welcome-title", "???"));
62 | // mainLayout->addWidget(newLabel);
63 |
64 | mainLayout->addLayout(buttonLayout);
65 | }
66 |
67 | void SW_About::donationLink(const QString &origin) {
68 | if (origin == "github") {
69 | QDesktopServices::openUrl(QUrl("https://github.com/sponsors/berkaygediz"));
70 | } else if (origin == "buymeacoffee") {
71 | QDesktopServices::openUrl(QUrl("https://buymeacoffee.com/berkaygediz"));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/solidwriting_cuda_windows.md:
--------------------------------------------------------------------------------
1 | # SolidWriting Documentation - CUDA / llama-cpp-python
2 |
3 | This guide provides step-by-step instructions to enable CUDA acceleration for `llama-cpp-python` in SolidWriting.
4 |
5 | ---
6 |
7 | ## 1. Install NVIDIA CUDA (v12.9 or Newer)
8 |
9 | Download and install **NVIDIA CUDA v12.9** or a newer version from the [official NVIDIA website](https://developer.nvidia.com/cuda-downloads).
10 |
11 | ---
12 |
13 | ## 2. Download and Install NVIDIA cuDNN
14 |
15 | 1. Download the cuDNN version compatible with **CUDA v12** from the [NVIDIA cuDNN download page](https://developer.nvidia.com/cudnn) (requires an NVIDIA Developer account).
16 | 2. Extract the downloaded `cudnn.zip` file.
17 |
18 | ---
19 |
20 | ## 3. Copy cuDNN Files
21 |
22 | Copy the `bin`, `include`, and `lib` folders from the extracted cuDNN archive to the CUDA installation directory:
23 |
24 | ```powershell
25 | C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9
26 | ```
27 |
28 | ---
29 |
30 | ## 4. Copy Visual Studio MSBuild Files
31 |
32 | Copy the MSBuild extension files from:
33 |
34 | ```powershell
35 | C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9\extras\visual_studio_integration\MSBuildExtensions
36 | ```
37 |
38 | Paste them into:
39 |
40 | ```powershell
41 | C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\BuildCustomizations
42 | ```
43 |
44 | ---
45 |
46 | ## 5. Enable CUDA Support for `llama-cpp-python`
47 |
48 | For official documentation and additional configuration details, refer to the [llama-cpp-python GitHub repository](https://github.com/abetlen/llama-cpp-python).
49 |
50 | ---
51 |
52 | ## 6. Set Environment Variables
53 |
54 | Configure the environment variables required for CUDA compilation.
55 |
56 | - Set the **CUDA compiler (`nvcc.exe`) path**:
57 |
58 | ```powershell
59 | $env:CUDACXX="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9\bin\nvcc.exe"
60 | ```
61 |
62 | - Set **CMake arguments** for the build process:
63 |
64 | ```powershell
65 | set CMAKE_ARGS=-DGGML_CUDA=on -DCMAKE_GENERATOR_TOOLSET="cuda=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9"
66 | ```
67 |
68 | - Set the **CUDA toolkit directory**:
69 |
70 | ```powershell
71 | $env:CudaToolkitDir="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.9\"
72 | ```
73 |
74 | ---
75 |
76 | ## 7. Install or Reinstall `llama-cpp-python`
77 |
78 | Since CUDA support requires compilation, reinstall `llama-cpp-python` using the following command (**compilation may take 30-50 minutes**):
79 |
80 | ```bash
81 | pip install llama-cpp-python --upgrade --force-reinstall --no-cache-dir --verbose
82 | ```
83 |
84 | ---
85 |
86 | ## 8. Install PyTorch with CUDA Support
87 |
88 | To install `torch`, `torchvision`, and `torchaudio` with CUDA acceleration, use the official PyTorch package index:
89 |
90 | ```bash
91 | pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
92 | ```
93 |
94 | ---
95 |
96 | After completing these steps, CUDA should be properly configured for `llama-cpp-python` in SolidWriting. 🚀
97 |
--------------------------------------------------------------------------------
/images/icons/ios/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "filename": "AppIcon@2x.png",
5 | "idiom": "iphone",
6 | "scale": "2x",
7 | "size": "60x60"
8 | },
9 | {
10 | "filename": "AppIcon@3x.png",
11 | "idiom": "iphone",
12 | "scale": "3x",
13 | "size": "60x60"
14 | },
15 | {
16 | "filename": "AppIcon~ipad.png",
17 | "idiom": "ipad",
18 | "scale": "1x",
19 | "size": "76x76"
20 | },
21 | {
22 | "filename": "AppIcon@2x~ipad.png",
23 | "idiom": "ipad",
24 | "scale": "2x",
25 | "size": "76x76"
26 | },
27 | {
28 | "filename": "AppIcon-83.5@2x~ipad.png",
29 | "idiom": "ipad",
30 | "scale": "2x",
31 | "size": "83.5x83.5"
32 | },
33 | {
34 | "filename": "AppIcon-40@2x.png",
35 | "idiom": "iphone",
36 | "scale": "2x",
37 | "size": "40x40"
38 | },
39 | {
40 | "filename": "AppIcon-40@3x.png",
41 | "idiom": "iphone",
42 | "scale": "3x",
43 | "size": "40x40"
44 | },
45 | {
46 | "filename": "AppIcon-40~ipad.png",
47 | "idiom": "ipad",
48 | "scale": "1x",
49 | "size": "40x40"
50 | },
51 | {
52 | "filename": "AppIcon-40@2x~ipad.png",
53 | "idiom": "ipad",
54 | "scale": "2x",
55 | "size": "40x40"
56 | },
57 | {
58 | "filename": "AppIcon-20@2x.png",
59 | "idiom": "iphone",
60 | "scale": "2x",
61 | "size": "20x20"
62 | },
63 | {
64 | "filename": "AppIcon-20@3x.png",
65 | "idiom": "iphone",
66 | "scale": "3x",
67 | "size": "20x20"
68 | },
69 | {
70 | "filename": "AppIcon-20~ipad.png",
71 | "idiom": "ipad",
72 | "scale": "1x",
73 | "size": "20x20"
74 | },
75 | {
76 | "filename": "AppIcon-20@2x~ipad.png",
77 | "idiom": "ipad",
78 | "scale": "2x",
79 | "size": "20x20"
80 | },
81 | {
82 | "filename": "AppIcon-29.png",
83 | "idiom": "iphone",
84 | "scale": "1x",
85 | "size": "29x29"
86 | },
87 | {
88 | "filename": "AppIcon-29@2x.png",
89 | "idiom": "iphone",
90 | "scale": "2x",
91 | "size": "29x29"
92 | },
93 | {
94 | "filename": "AppIcon-29@3x.png",
95 | "idiom": "iphone",
96 | "scale": "3x",
97 | "size": "29x29"
98 | },
99 | {
100 | "filename": "AppIcon-29~ipad.png",
101 | "idiom": "ipad",
102 | "scale": "1x",
103 | "size": "29x29"
104 | },
105 | {
106 | "filename": "AppIcon-29@2x~ipad.png",
107 | "idiom": "ipad",
108 | "scale": "2x",
109 | "size": "29x29"
110 | },
111 | {
112 | "filename": "AppIcon-60@2x~car.png",
113 | "idiom": "car",
114 | "scale": "2x",
115 | "size": "60x60"
116 | },
117 | {
118 | "filename": "AppIcon-60@3x~car.png",
119 | "idiom": "car",
120 | "scale": "3x",
121 | "size": "60x60"
122 | },
123 | {
124 | "filename": "AppIcon~ios-marketing.png",
125 | "idiom": "ios-marketing",
126 | "scale": "1x",
127 | "size": "1024x1024"
128 | }
129 | ],
130 | "info": {
131 | "author": "iconkitchen",
132 | "version": 1
133 | }
134 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SolidWriting
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | SolidWriting offers an intuitive interface and powerful features for creating and editing documents. Easily open, edit, and save SWDOC/SWDOC64 and DOCX files. With advanced text formatting, offline AI assistance, and multilingual support, streamline your writing process.
20 |
21 | ## Features
22 |
23 | - [x] **Cross-Platform**: Compatible with Windows, macOS (experimental), and Linux (experimental).
24 | - [x] **Document Management**: Create, open, save, and print documents effortlessly.
25 | - [x] **Find & Replace**: Search and replace text within your document.
26 | - [x] **Printing & Exporting**: Print documents or export them as PDFs.
27 | - [x] **File Format Support**: Supports .txt, .html, .docx (partial), and .swdoc/.swdoc64 (SolidWriting).
28 | - [x] **Text Formatting**: Customize text with bold, italic, underline, font selection, size adjustment, color, background color, and alignment options.
29 | - [x] **Undo & Redo**: Easily reverse or reapply changes.
30 | - [x] **Cut, Copy, Paste**: Standard clipboard functions for efficient editing.
31 | - [x] **Lists & Tables**: Create numbered/bulleted lists and insert customizable tables.
32 | - [x] **Hyperlinks**: Add and open hyperlinks to reference external resources.
33 | - [x] **Image Support**: Embed images in documents with Base64 encoding.
34 | - [x] **Performance & Power Saving**: Fast and lightweight, with threading support and hardware acceleration. Optimized for power efficiency with hybrid ultra and standard power saving modes.
35 | - [x] **Document Statistics**: Provides key statistical information about the document.
36 | - [x] **User Experience**: Drag and drop functionality, dark mode support, and alerts for unsaved changes.
37 | - [x] **Customizable Toolbar**: Personalize the user interface toolbar to suit your workflow.
38 | - [x] **Multilingual Support**: English, Deutsch, Español, Türkçe, Azərbaycanca, 中文 (Chinese), 한국어 (Korean), 日本語 (Japanese), العربية (Arabic), Русский (Russian), Français, Ελληνικά (Greek), Kinyarwanda (Rwandan), Hebrew (עברית).
39 | - [x] **Offline AI Chat**: Built-in AI assistant (offline mode) for content generation & Q&A, with automatic language detection and a context menu for seamless interaction.
40 |
41 | ## Prerequisites
42 |
43 | - Python 3.12+
44 | - PySide6
45 | - mammoth
46 | - chardet
47 | - psutil
48 | - langdetect
49 | - pyinstaller
50 | - llama-cpp-python
51 | - torch
52 |
53 | ## Installation
54 |
55 | 1. Clone the repository:
56 |
57 | ```bash
58 | git clone https://github.com/berkaygediz/SolidWriting.git
59 | ```
60 |
61 | 2. Install requirements:
62 |
63 | ```bash
64 | pip install -r requirements.txt
65 | ```
66 |
67 | 3. Creating a executable file (Unsigned):
68 |
69 | ```bash
70 | pyinstaller --name="SolidWriting" --noconsole --onedir --windowed --optimize "2" --clean --noconfirm --icon=".\solidwriting_icon.ico" --add-data "./.venv/Lib/site-packages/llama_cpp/*:llama_cpp" --add-binary "./.venv/Lib/site-packages/llama_cpp/*:llama_cpp" ".\SolidWriting.py"
71 | ```
72 |
73 | ## Usage
74 |
75 | Launch SolidWriting from the command line:
76 |
77 | ```bash
78 | python SolidWriting.py
79 | ```
80 |
81 | ## Contributing
82 |
83 | Contributions to the SolidWriting project are welcomed. Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute and our code of conduct.
84 |
85 | ## License
86 |
87 | This project is licensed under GNU GPLv3, GNU LGPLv3, and Mozilla Public License Version 2.0.
88 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | share/python-wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | MANIFEST
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .nox/
43 | .coverage
44 | .coverage.*
45 | .cache
46 | nosetests.xml
47 | coverage.xml
48 | *.cover
49 | *.py,cover
50 | .hypothesis/
51 | .pytest_cache/
52 | cover/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 | solidwriting.db
64 | solidwriting.db-*
65 |
66 | # Flask stuff:
67 | instance/
68 | .webassets-cache
69 |
70 | # Scrapy stuff:
71 | .scrapy
72 |
73 | # Sphinx documentation
74 | docs/_build/
75 |
76 | # PyBuilder
77 | .pybuilder/
78 | target/
79 |
80 | # Jupyter Notebook
81 | .ipynb_checkpoints
82 |
83 | # IPython
84 | profile_default/
85 | ipython_config.py
86 |
87 | # pyenv
88 | # For a library or package, you might want to ignore these files since the code is
89 | # intended to run in multiple environments; otherwise, check them in:
90 | # .python-version
91 |
92 | # pipenv
93 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
95 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
96 | # install all needed dependencies.
97 | #Pipfile.lock
98 |
99 | # poetry
100 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
101 | # This is especially recommended for binary packages to ensure reproducibility, and is more
102 | # commonly ignored for libraries.
103 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
104 | #poetry.lock
105 |
106 | # pdm
107 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
108 | #pdm.lock
109 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
110 | # in version control.
111 | # https://pdm.fming.dev/#use-with-ide
112 | .pdm.toml
113 |
114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115 | __pypackages__/
116 |
117 | # Celery stuff
118 | celerybeat-schedule
119 | celerybeat.pid
120 |
121 | # SageMath parsed files
122 | *.sage.py
123 |
124 | # Environments
125 | .env
126 | .venv
127 | env/
128 | venv/
129 | ENV/
130 | env.bak/
131 | venv.bak/
132 |
133 | # Spyder project settings
134 | .spyderproject
135 | .spyproject
136 |
137 | # Rope project settings
138 | .ropeproject
139 |
140 | # mkdocs documentation
141 | /site
142 |
143 | # mypy
144 | .mypy_cache/
145 | .dmypy.json
146 | dmypy.json
147 |
148 | # Pyre type checker
149 | .pyre/
150 |
151 | # pytype static type analyzer
152 | .pytype/
153 |
154 | # Cython debug symbols
155 | cython_debug/
156 |
157 | # PyCharm
158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160 | # and can be added to the global gitignore or merged into this file. For a more nuclear
161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162 | #.idea/
163 |
164 | .vscode/*
165 | !.vscode/settings.json
166 | !.vscode/tasks.json
167 | !.vscode/launch.json
168 | !.vscode/extensions.json
169 | !.vscode/*.code-snippets
170 |
171 | # Local History for Visual Studio Code
172 | .history/
173 |
174 | # Built Visual Studio Code Extensions
175 | *.vsix
176 |
177 | *.gguf
178 | .vscode
179 |
--------------------------------------------------------------------------------
/experimental/cpp/sw_workspace.h:
--------------------------------------------------------------------------------
1 | #ifndef RS_WORKSPACE_H
2 | #define RS_WORKSPACE_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include
42 |
43 | QT_BEGIN_NAMESPACE
44 | namespace Ui {
45 | class RS_Workspace;
46 | }
47 | QT_END_NAMESPACE
48 |
49 | class RS_Workspace : public QMainWindow {
50 | Q_OBJECT
51 |
52 | public:
53 | RS_Workspace(QWidget *parent = nullptr);
54 | ~RS_Workspace();
55 |
56 | private:
57 | QComboBox *language_combobox;
58 | QAction *hide_ai_dock;
59 | int adaptiveResponse;
60 | QLabel *statistics_label;
61 | QTextEdit *input_text;
62 | QPushButton *predict_button;
63 | QScrollArea *scrollableArea;
64 | QVBoxLayout *messages_layout;
65 | QSettings settings;
66 | Ui::RS_Workspace *ui;
67 | QTextEdit *documentArea;
68 | bool isSaved;
69 | QString selectedFile;
70 | QString fileName;
71 | QString defaultDirectory;
72 | QString directory;
73 | QObject *llm;
74 | QPalette lightTheme;
75 | QPalette darkTheme;
76 |
77 | QAction *newaction, *openaction, *saveaction, *saveasaction, *printaction;
78 | QAction *undoaction, *redoaction, *theme_action, *powersaveraction,
79 | *findaction;
80 | QAction *replaceaction, *helpAction, *aboutAction;
81 | QAction *alignrightevent, *aligncenterevent, *alignleftevent,
82 | *alignjustifiedevent;
83 | QAction *bold, *italic, *underline, *bulletevent, *numberedevent, *color;
84 | QAction *backgroundcolor, *fontfamily, *addimage;
85 | QToolBar *file_toolbar, *ui_toolbar, *edit_toolbar, *font_toolbar,
86 | *list_toolbar;
87 | QToolBar *color_toolbar, *multimedia_toolbar;
88 | QWidget ai_widget;
89 |
90 | private slots:
91 | void newFile();
92 | void openFile();
93 | void saveFile();
94 | bool saveAs();
95 | void saveProcess();
96 | void printDocument();
97 | void readSettings();
98 | void initUI();
99 | void closeEvent(QCloseEvent *event);
100 | void themeAction();
101 | void toolbarTheme();
102 | void toolbarTranslate();
103 | void updateStatistics();
104 | void themePalette();
105 | void translateToolbarLabel(QToolBar *toolbar, const QString &labelKey,
106 | const QString &lang);
107 | void updateToolbarLabel(QToolBar *toolbar, const QString &newLabel);
108 | void LLMwarningCPU();
109 | void LLMinitDock();
110 | void LLMpredict();
111 | void LLMmessage(const QString &text, bool is_user);
112 | void changeLanguage();
113 | void updateTitle();
114 | // void threadStart();
115 | // void textChanged();
116 | // void saveState();
117 | // void restoreState();
118 | // void restoreTheme();
119 | // void translateToolbarLabel();
120 | // void updateToolbarLabel();
121 | void initArea();
122 | // void loadLLM();
123 | // void _load_model();
124 | // int acceleratorHardware();
125 | void LLMcontextPredict(bool action_type);
126 | void LLMprompt(const QString &prompt);
127 | QString LLMresponse(const QString &prompt);
128 | QString LLMconvertMarkdownHTML(const QString &markdown_text);
129 | QString convertBoldItalic(const QString &text);
130 | static QString LLMescapeHTML(const QString &text);
131 | void toolbarLabel(QToolBar *toolbar, const QString &text);
132 | QAction *createAction(const QString &text, const QString &statusTip,
133 | std::function function,
134 | const QKeySequence &shortcut);
135 |
136 | QString LLMconvertCodeHTML(const QString &text);
137 | void initActions();
138 | void initToolbar();
139 | void toggleDock();
140 | void hybridSaver(bool checked);
141 | void addImage();
142 | // void viewAbout();
143 | // void viewHelp();
144 | void bulletList();
145 | void numberedList();
146 | void contentAlign(Qt::Alignment alignment);
147 | void contentBold();
148 | void contentItalic();
149 | void contentUnderline();
150 | void contentColor();
151 | void contentBGColor();
152 | void contentFont();
153 | void incFont();
154 | void decFont();
155 | void find();
156 | void findText(const QString &text);
157 | void replace();
158 | void replaceText(const QString &text);
159 | QString detectEncoding(const QString &file_path);
160 | void setDocumentDefaultStyle();
161 | };
162 | #endif // RS_WORKSPACE_H
163 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | .
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | .
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | . Translations are available at
128 | .
129 |
--------------------------------------------------------------------------------
/experimental/sw_testwindow.py:
--------------------------------------------------------------------------------
1 | import sys
2 |
3 | from PySide6.QtGui import QColor, QPainter, QPen, Qt
4 | from PySide6.QtWidgets import (QApplication, QComboBox, QFrame, QLabel,
5 | QSpinBox, QTextEdit, QVBoxLayout, QWidget)
6 |
7 |
8 | class SW_Ruler(QFrame):
9 | def __init__(self, parent=None):
10 | super().__init__(parent)
11 | self.setFixedHeight(30)
12 | self.setStyleSheet("background-color: lightgray;")
13 | self.margin_left = 3
14 | self.margin_right = 1.5
15 | self.scale_factor = 1
16 | self.offset = 0
17 | self.setMouseTracking(True)
18 |
19 | self.drag = False
20 | self.l_x = 0
21 |
22 | def paintEvent(self, event):
23 | painter = QPainter(self)
24 | pen = QPen(QColor(0, 0, 0))
25 | painter.setPen(pen)
26 | width = self.width()
27 |
28 | for i in range(-50, int(18 * 100), 10):
29 | x_position = (i + 500 - self.offset) * self.scale_factor
30 | if x_position >= 0 and x_position <= width:
31 | painter.drawLine(x_position, 5, x_position, 20)
32 | if i % 50 == 0:
33 | painter.drawText(x_position + 2, 25, f"{i / 10:.1f} cm")
34 |
35 | pen.setColor(QColor(255, 0, 0))
36 | pen.setWidth(3)
37 | painter.setPen(pen)
38 | painter.drawLine(
39 | self.margin_left * 10 * self.scale_factor - self.offset,
40 | 5,
41 | self.margin_left * 10 * self.scale_factor - self.offset,
42 | 20,
43 | )
44 | painter.drawLine(
45 | width - self.margin_right * 10 * self.scale_factor - self.offset,
46 | 5,
47 | width - self.margin_right * 10 * self.scale_factor - self.offset,
48 | 20,
49 | )
50 |
51 | def updateScaleFactor(self, factor):
52 | self.scale_factor = factor
53 | self.update()
54 |
55 | def setMargins(self, left, right):
56 | self.margin_left = left
57 | self.margin_right = right
58 | self.update()
59 |
60 | def mousePressEvent(self, event):
61 | if event.button() == Qt.LeftButton:
62 | self.drag = True
63 | self.l_x = event.position().x()
64 |
65 | def mouseMoveEvent(self, event):
66 | if self.drag:
67 | delta = event.position().x() - self.l_x
68 | self.offset += delta
69 | self.l_x = event.position().x()
70 | self.update()
71 |
72 | def mouseReleaseEvent(self, event):
73 | if event.button() == Qt.LeftButton:
74 | self.drag = False
75 |
76 |
77 | class SW_TestWindow(QWidget):
78 | def __init__(self):
79 | super().__init__()
80 |
81 | layout = QVBoxLayout()
82 |
83 | self.ruler = SW_Ruler(self)
84 |
85 | self.text_container = QFrame(self)
86 | self.text_container.setStyleSheet("border: 1px solid black;")
87 | self.text_layout = QVBoxLayout(self.text_container)
88 |
89 | self.text_edit = QTextEdit(self)
90 | self.text_edit.setAcceptRichText(True)
91 | self.text_edit.setLineWrapMode(QTextEdit.WidgetWidth)
92 | self.text_edit.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
93 |
94 | self.text_layout.addWidget(self.text_edit)
95 |
96 | self.margin_left_input = QSpinBox(self)
97 | self.margin_left_input.setValue(3)
98 | self.margin_left_input.setRange(0, 20)
99 | self.margin_left_input.valueChanged.connect(self.updateMargins)
100 |
101 | self.margin_right_input = QSpinBox(self)
102 | self.margin_right_input.setValue(1.5)
103 | self.margin_right_input.setRange(0, 20)
104 | self.margin_right_input.valueChanged.connect(self.updateMargins)
105 |
106 | self.zoom_input = QComboBox(self)
107 | self.zoom_input.addItems(["100%", "125%", "150%", "200%", "250%"])
108 | self.zoom_input.currentIndexChanged.connect(self.updateZoomFactor)
109 |
110 | self.setMargins()
111 |
112 | layout.addWidget(self.ruler)
113 | layout.addWidget(self.text_container)
114 |
115 | layout.addWidget(QLabel("Left Margin (cm):"))
116 | layout.addWidget(self.margin_left_input)
117 | layout.addWidget(QLabel("Right Margin (cm):"))
118 | layout.addWidget(self.margin_right_input)
119 | layout.addWidget(QLabel("Zoom:"))
120 | layout.addWidget(self.zoom_input)
121 |
122 | self.setLayout(layout)
123 |
124 | self.setWindowTitle("SolidWriting - Experimental - Ruler & Zoom")
125 | self.resize(800, 600)
126 |
127 | def setMargins(self):
128 | self.ruler.setMargins(
129 | self.margin_left_input.value(), self.margin_right_input.value()
130 | )
131 |
132 | l_margin = self.margin_left_input.value() * 10
133 | r_margin = self.margin_right_input.value() * 10
134 |
135 | self.text_container.setStyleSheet(
136 | f"""
137 | border: 1px solid #000;
138 | padding-left: {self.margin_left_input.value()}cm;
139 | padding-right: {self.margin_right_input.value()}cm;
140 | """
141 | )
142 |
143 | self.text_edit.document().setDocumentMargin(l_margin)
144 | self.text_edit.setFixedWidth(600)
145 |
146 | def updateMargins(self):
147 | self.setMargins()
148 |
149 | def updateZoomFactor(self):
150 | zoom_percent = self.zoom_input.currentText()
151 | zoom_factor = int(zoom_percent.replace("%", ""))
152 |
153 | self.text_edit.setStyleSheet(
154 | f"""
155 | border: 1px solid #000;
156 | margin-left: {self.margin_left_input.value()}cm;
157 | margin-right: {self.margin_right_input.value()}cm;
158 | """
159 | )
160 | self.text_container.setFixedWidth(600 * (zoom_factor / 100))
161 |
162 |
163 | if __name__ == "__main__":
164 | app = QApplication(sys.argv)
165 | window = SW_TestWindow()
166 | window.show()
167 | sys.exit(app.exec())
168 |
--------------------------------------------------------------------------------
/experimental/cpp/llamatest.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | #include "llama.h"
14 |
15 | llama_model *model = nullptr;
16 | llama_context *ctx = nullptr;
17 | llama_sampler *sampler = nullptr;
18 |
19 | bool init_llama() {
20 | QString modelPath = "";
21 | if (!QFile::exists(modelPath)) {
22 | qCritical() << "Model dosyası bulunamadı: " << modelPath;
23 | return false;
24 | }
25 |
26 | qDebug() << "Model dosyası bulundu. Yükleniyor...";
27 |
28 | llama_backend_init();
29 |
30 | llama_model_params model_params = llama_model_default_params();
31 | model =
32 | llama_model_load_from_file(modelPath.toStdString().c_str(), model_params);
33 | if (!model) {
34 | qCritical() << "Model yüklenemedi!";
35 | return false;
36 | }
37 |
38 | qDebug() << "Model başarıyla yüklendi.";
39 |
40 | llama_context_params ctx_params = llama_context_default_params();
41 | ctx_params.n_ctx = 2048;
42 | ctx = llama_init_from_model(model, ctx_params);
43 | if (!ctx) {
44 | qCritical() << "Model bağlanırken hata oluştu!";
45 | return false;
46 | }
47 |
48 | llama_sampler_chain_params sparams = llama_sampler_chain_default_params();
49 | sampler = llama_sampler_chain_init(sparams);
50 | llama_sampler_chain_add(sampler, llama_sampler_init_top_k(40));
51 | llama_sampler_chain_add(sampler, llama_sampler_init_top_p(0.9f, 1));
52 | llama_sampler_chain_add(sampler, llama_sampler_init_temp(0.8f));
53 | llama_sampler_chain_add(sampler, llama_sampler_init_dist(42));
54 |
55 | qDebug() << "Model başarıyla başlatıldı ve hazır.";
56 |
57 | return true;
58 | }
59 |
60 | QString token_to_string(llama_token token) {
61 | char buf[128] = {0};
62 | const struct llama_vocab *vocab = llama_model_get_vocab(model);
63 | llama_token_to_piece(vocab, token, buf, sizeof(buf), 0, false);
64 | return QString::fromUtf8(buf);
65 | }
66 |
67 | QString generate_response(const QString &prompt) {
68 | std::string input = prompt.toStdString();
69 |
70 | qDebug() << "Tokenizing input...";
71 |
72 | const struct llama_vocab *vocab = llama_model_get_vocab(model);
73 | std::vector tokens(input.size() + 8);
74 | int n_tokens = llama_tokenize(vocab, input.c_str(),
75 | static_cast(input.size()), tokens.data(),
76 | static_cast(tokens.size()), true, false);
77 | if (n_tokens < 0) {
78 | qCritical() << "Tokenize işlemi başarısız!";
79 | return "[Tokenize edilemedi]";
80 | }
81 |
82 | qDebug() << "Tokenize başarıyla tamamlandı!";
83 |
84 | llama_batch batch = llama_batch_init(static_cast(tokens.size()), 0, 1);
85 | for (size_t i = 0; i < static_cast(tokens.size()); ++i) {
86 | batch.token[i] = tokens[i];
87 | batch.pos[i] = static_cast(i);
88 | batch.n_seq_id[i] = 1;
89 | batch.seq_id[i] = nullptr;
90 | batch.logits[i] = false;
91 | }
92 |
93 | llama_decode(ctx, batch);
94 | llama_batch_free(batch);
95 |
96 | QString result;
97 | for (int i = 0; i < 64; ++i) {
98 | llama_token token = llama_sampler_sample(sampler, ctx, -1);
99 | if (llama_vocab_is_eog(vocab, token))
100 | break;
101 |
102 | result += token_to_string(token);
103 |
104 | llama_batch batch_out = llama_batch_init(1, 0, 1);
105 | batch_out.token[0] = token;
106 | batch_out.pos[0] = static_cast(tokens.size()) + i;
107 | batch_out.n_seq_id[0] = 1;
108 | batch_out.seq_id[0] = nullptr;
109 | batch_out.logits[0] = false;
110 | llama_decode(ctx, batch_out);
111 | llama_batch_free(batch_out);
112 |
113 | llama_sampler_accept(sampler, token);
114 | }
115 |
116 | return result;
117 | }
118 |
119 | class GenerateResponseThread : public QThread {
120 | Q_OBJECT
121 | public:
122 | GenerateResponseThread(const QString &inputText, QTextEdit *chatDisplay)
123 | : input(inputText), display(chatDisplay) {}
124 |
125 | void run() override {
126 | try {
127 | qDebug() << "Yanıt üretmeye başlandı...";
128 | QString response = generate_response(input);
129 | emit responseReady(response);
130 | } catch (const std::exception &e) {
131 | qCritical() << "Yanıt üretme sırasında hata: " << e.what();
132 | emit responseReady("[Yanıt üretilemedi]");
133 | }
134 | }
135 |
136 | signals:
137 | void responseReady(const QString &response);
138 |
139 | private:
140 | QString input;
141 | QTextEdit *display;
142 | };
143 |
144 | int main(int argc, char *argv[]) {
145 | QApplication app(argc, argv);
146 |
147 | qDebug() << "Qt Uygulama başlatıldı!";
148 |
149 | if (!init_llama()) {
150 | qCritical() << "LLaMA başlatılamadı!";
151 | return -1;
152 | }
153 |
154 | qDebug() << "LLaMA başlatıldı.";
155 |
156 | QWidget window;
157 | window.setWindowTitle("🦙 LLaMA Chat (Qt6)");
158 |
159 | QVBoxLayout *layout = new QVBoxLayout(&window);
160 |
161 | QLabel *label = new QLabel("💬 Mesaj:");
162 | layout->addWidget(label);
163 |
164 | QTextEdit *chatDisplay = new QTextEdit();
165 | chatDisplay->setReadOnly(true);
166 | layout->addWidget(chatDisplay);
167 |
168 | QLineEdit *inputField = new QLineEdit();
169 | layout->addWidget(inputField);
170 |
171 | QPushButton *sendButton = new QPushButton("Gönder");
172 | layout->addWidget(sendButton);
173 |
174 | QObject::connect(sendButton, &QPushButton::clicked, [&]() {
175 | QString userInput = inputField->text();
176 | if (!userInput.isEmpty()) {
177 | chatDisplay->append("👤 Siz: " + userInput);
178 |
179 | GenerateResponseThread *thread =
180 | new GenerateResponseThread(userInput, chatDisplay);
181 | QObject::connect(thread, &GenerateResponseThread::responseReady,
182 | [&](const QString &response) {
183 | chatDisplay->append("🤖 LLaMA: " + response);
184 | });
185 |
186 | thread->start();
187 | inputField->clear();
188 | }
189 | });
190 |
191 | window.resize(520, 420);
192 | window.show();
193 |
194 | return app.exec();
195 | }
196 |
197 | #include "main.moc"
198 |
--------------------------------------------------------------------------------
/COPYING.LGPL:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/experimental/cpp/.gitignore:
--------------------------------------------------------------------------------
1 | # C++ objects and libs
2 | *.slo
3 | *.lo
4 | *.o
5 | *.a
6 | *.la
7 | *.lai
8 | *.so
9 | *.so.*
10 | *.dll
11 | *.dylib
12 |
13 | # Qt-es
14 | object_script.*.Release
15 | object_script.*.Debug
16 | *_plugin_import.cpp
17 | /.qmake.cache
18 | /.qmake.stash
19 | *.pro.user
20 | *.pro.user.*
21 | *.qbs.user
22 | *.qbs.user.*
23 | *.moc
24 | moc_*.cpp
25 | moc_*.h
26 | qrc_*.cpp
27 | ui_*.h
28 | *.qmlc
29 | *.jsc
30 | Makefile*
31 | *build-*
32 | *.qm
33 | *.prl
34 |
35 | # Qt unit tests
36 | target_wrapper.*
37 |
38 | # QtCreator
39 | *.autosave
40 |
41 | # QtCreator Qml
42 | *.qmlproject.user
43 | *.qmlproject.user.*
44 |
45 | # QtCreator CMake
46 | CMakeLists.txt.user*
47 |
48 | # QtCreator 4.8< compilation database
49 | compile_commands.json
50 |
51 | # QtCreator local machine specific files for imported projects
52 | *creator.user*
53 |
54 | *_qmlcache.qrc
55 | /build
56 | /.cache
57 |
58 | CMakeLists.txt.user
59 | CMakeCache.txt
60 | CMakeFiles
61 | CMakeScripts
62 | Testing
63 | Makefile
64 | cmake_install.cmake
65 | install_manifest.txt
66 | compile_commands.json
67 | CTestTestfile.cmake
68 | _deps
69 | CMakeUserPresets.json
70 |
71 | ## Ignore Visual Studio temporary files, build results, and
72 | ## files generated by popular Visual Studio add-ons.
73 | ##
74 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
75 |
76 | # User-specific files
77 | *.rsuser
78 | *.suo
79 | *.user
80 | *.userosscache
81 | *.sln.docstates
82 |
83 | # User-specific files (MonoDevelop/Xamarin Studio)
84 | *.userprefs
85 |
86 | # Mono auto generated files
87 | mono_crash.*
88 |
89 | # Build results
90 | [Dd]ebug/
91 | [Dd]ebugPublic/
92 | [Rr]elease/
93 | [Rr]eleases/
94 | x64/
95 | x86/
96 | [Ww][Ii][Nn]32/
97 | [Aa][Rr][Mm]/
98 | [Aa][Rr][Mm]64/
99 | bld/
100 | [Bb]in/
101 | [Oo]bj/
102 | [Ll]og/
103 | [Ll]ogs/
104 |
105 | # Visual Studio 2015/2017 cache/options directory
106 | .vs/
107 | # Uncomment if you have tasks that create the project's static files in wwwroot
108 | #wwwroot/
109 |
110 | # Visual Studio 2017 auto generated files
111 | Generated\ Files/
112 |
113 | # MSTest test Results
114 | [Tt]est[Rr]esult*/
115 | [Bb]uild[Ll]og.*
116 |
117 | # NUnit
118 | *.VisualState.xml
119 | TestResult.xml
120 | nunit-*.xml
121 |
122 | # Build Results of an ATL Project
123 | [Dd]ebugPS/
124 | [Rr]eleasePS/
125 | dlldata.c
126 |
127 | # Benchmark Results
128 | BenchmarkDotNet.Artifacts/
129 |
130 | # .NET Core
131 | project.lock.json
132 | project.fragment.lock.json
133 | artifacts/
134 |
135 | # ASP.NET Scaffolding
136 | ScaffoldingReadMe.txt
137 |
138 | # StyleCop
139 | StyleCopReport.xml
140 |
141 | # Files built by Visual Studio
142 | *_i.c
143 | *_p.c
144 | *_h.h
145 | *.ilk
146 | *.meta
147 | *.obj
148 | *.iobj
149 | *.pch
150 | *.pdb
151 | *.ipdb
152 | *.pgc
153 | *.pgd
154 | *.rsp
155 | # but not Directory.Build.rsp, as it configures directory-level build defaults
156 | !Directory.Build.rsp
157 | *.sbr
158 | *.tlb
159 | *.tli
160 | *.tlh
161 | *.tmp
162 | *.tmp_proj
163 | *_wpftmp.csproj
164 | *.log
165 | *.tlog
166 | *.vspscc
167 | *.vssscc
168 | .builds
169 | *.pidb
170 | *.svclog
171 | *.scc
172 |
173 | # Chutzpah Test files
174 | _Chutzpah*
175 |
176 | # Visual C++ cache files
177 | ipch/
178 | *.aps
179 | *.ncb
180 | *.opendb
181 | *.opensdf
182 | *.sdf
183 | *.cachefile
184 | *.VC.db
185 | *.VC.VC.opendb
186 |
187 | # Visual Studio profiler
188 | *.psess
189 | *.vsp
190 | *.vspx
191 | *.sap
192 |
193 | # Visual Studio Trace Files
194 | *.e2e
195 |
196 | # TFS 2012 Local Workspace
197 | $tf/
198 |
199 | # Guidance Automation Toolkit
200 | *.gpState
201 |
202 | # ReSharper is a .NET coding add-in
203 | _ReSharper*/
204 | *.[Rr]e[Ss]harper
205 | *.DotSettings.user
206 |
207 | # TeamCity is a build add-in
208 | _TeamCity*
209 |
210 | # DotCover is a Code Coverage Tool
211 | *.dotCover
212 |
213 | # AxoCover is a Code Coverage Tool
214 | .axoCover/*
215 | !.axoCover/settings.json
216 |
217 | # Coverlet is a free, cross platform Code Coverage Tool
218 | coverage*.json
219 | coverage*.xml
220 | coverage*.info
221 |
222 | # Visual Studio code coverage results
223 | *.coverage
224 | *.coveragexml
225 |
226 | # NCrunch
227 | _NCrunch_*
228 | .*crunch*.local.xml
229 | nCrunchTemp_*
230 |
231 | # MightyMoose
232 | *.mm.*
233 | AutoTest.Net/
234 |
235 | # Web workbench (sass)
236 | .sass-cache/
237 |
238 | # Installshield output folder
239 | [Ee]xpress/
240 |
241 | # DocProject is a documentation generator add-in
242 | DocProject/buildhelp/
243 | DocProject/Help/*.HxT
244 | DocProject/Help/*.HxC
245 | DocProject/Help/*.hhc
246 | DocProject/Help/*.hhk
247 | DocProject/Help/*.hhp
248 | DocProject/Help/Html2
249 | DocProject/Help/html
250 |
251 | # Click-Once directory
252 | publish/
253 |
254 | # Publish Web Output
255 | *.[Pp]ublish.xml
256 | *.azurePubxml
257 | # Note: Comment the next line if you want to checkin your web deploy settings,
258 | # but database connection strings (with potential passwords) will be unencrypted
259 | *.pubxml
260 | *.publishproj
261 |
262 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
263 | # checkin your Azure Web App publish settings, but sensitive information contained
264 | # in these scripts will be unencrypted
265 | PublishScripts/
266 |
267 | # NuGet Packages
268 | *.nupkg
269 | # NuGet Symbol Packages
270 | *.snupkg
271 | # The packages folder can be ignored because of Package Restore
272 | **/[Pp]ackages/*
273 | # except build/, which is used as an MSBuild target.
274 | !**/[Pp]ackages/build/
275 | # Uncomment if necessary however generally it will be regenerated when needed
276 | #!**/[Pp]ackages/repositories.config
277 | # NuGet v3's project.json files produces more ignorable files
278 | *.nuget.props
279 | *.nuget.targets
280 |
281 | # Microsoft Azure Build Output
282 | csx/
283 | *.build.csdef
284 |
285 | # Microsoft Azure Emulator
286 | ecf/
287 | rcf/
288 |
289 | # Windows Store app package directories and files
290 | AppPackages/
291 | BundleArtifacts/
292 | Package.StoreAssociation.xml
293 | _pkginfo.txt
294 | *.appx
295 | *.appxbundle
296 | *.appxupload
297 |
298 | # Visual Studio cache files
299 | # files ending in .cache can be ignored
300 | *.[Cc]ache
301 | # but keep track of directories ending in .cache
302 | !?*.[Cc]ache/
303 |
304 | # Others
305 | ClientBin/
306 | ~$*
307 | *~
308 | *.dbmdl
309 | *.dbproj.schemaview
310 | *.jfm
311 | *.pfx
312 | *.publishsettings
313 | orleans.codegen.cs
314 |
315 | # Including strong name files can present a security risk
316 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
317 | #*.snk
318 |
319 | # Since there are multiple workflows, uncomment next line to ignore bower_components
320 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
321 | #bower_components/
322 |
323 | # RIA/Silverlight projects
324 | Generated_Code/
325 |
326 | # Backup & report files from converting an old project file
327 | # to a newer Visual Studio version. Backup files are not needed,
328 | # because we have git ;-)
329 | _UpgradeReport_Files/
330 | Backup*/
331 | UpgradeLog*.XML
332 | UpgradeLog*.htm
333 | ServiceFabricBackup/
334 | *.rptproj.bak
335 |
336 | # SQL Server files
337 | *.mdf
338 | *.ldf
339 | *.ndf
340 |
341 | # Business Intelligence projects
342 | *.rdl.data
343 | *.bim.layout
344 | *.bim_*.settings
345 | *.rptproj.rsuser
346 | *- [Bb]ackup.rdl
347 | *- [Bb]ackup ([0-9]).rdl
348 | *- [Bb]ackup ([0-9][0-9]).rdl
349 |
350 | # Microsoft Fakes
351 | FakesAssemblies/
352 |
353 | # GhostDoc plugin setting file
354 | *.GhostDoc.xml
355 |
356 | # Node.js Tools for Visual Studio
357 | .ntvs_analysis.dat
358 | node_modules/
359 |
360 | # Visual Studio 6 build log
361 | *.plg
362 |
363 | # Visual Studio 6 workspace options file
364 | *.opt
365 |
366 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
367 | *.vbw
368 |
369 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
370 | *.vbp
371 |
372 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
373 | *.dsw
374 | *.dsp
375 |
376 | # Visual Studio 6 technical files
377 | *.ncb
378 | *.aps
379 |
380 | # Visual Studio LightSwitch build output
381 | **/*.HTMLClient/GeneratedArtifacts
382 | **/*.DesktopClient/GeneratedArtifacts
383 | **/*.DesktopClient/ModelManifest.xml
384 | **/*.Server/GeneratedArtifacts
385 | **/*.Server/ModelManifest.xml
386 | _Pvt_Extensions
387 |
388 | # Paket dependency manager
389 | .paket/paket.exe
390 | paket-files/
391 |
392 | # FAKE - F# Make
393 | .fake/
394 |
395 | # CodeRush personal settings
396 | .cr/personal
397 |
398 | # Python Tools for Visual Studio (PTVS)
399 | __pycache__/
400 | *.pyc
401 |
402 | # Cake - Uncomment if you are using it
403 | # tools/**
404 | # !tools/packages.config
405 |
406 | # Tabs Studio
407 | *.tss
408 |
409 | # Telerik's JustMock configuration file
410 | *.jmconfig
411 |
412 | # BizTalk build output
413 | *.btp.cs
414 | *.btm.cs
415 | *.odx.cs
416 | *.xsd.cs
417 |
418 | # OpenCover UI analysis results
419 | OpenCover/
420 |
421 | # Azure Stream Analytics local run output
422 | ASALocalRun/
423 |
424 | # MSBuild Binary and Structured Log
425 | *.binlog
426 |
427 | # NVidia Nsight GPU debugger configuration file
428 | *.nvuser
429 |
430 | # MFractors (Xamarin productivity tool) working folder
431 | .mfractor/
432 |
433 | # Local History for Visual Studio
434 | .localhistory/
435 |
436 | # Visual Studio History (VSHistory) files
437 | .vshistory/
438 |
439 | # BeatPulse healthcheck temp database
440 | healthchecksdb
441 |
442 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
443 | MigrationBackup/
444 |
445 | # Ionide (cross platform F# VS Code tools) working folder
446 | .ionide/
447 |
448 | # Fody - auto-generated XML schema
449 | FodyWeavers.xsd
450 |
451 | # VS Code files for those working on multiple tools
452 | .vscode/*
453 | !.vscode/settings.json
454 | !.vscode/tasks.json
455 | !.vscode/launch.json
456 | !.vscode/extensions.json
457 | *.code-workspace
458 |
459 | # Local History for Visual Studio Code
460 | .history/
461 |
462 | # Windows Installer files from build outputs
463 | *.cab
464 | *.msi
465 | *.msix
466 | *.msm
467 | *.msp
468 |
469 | # JetBrains Rider
470 | *.sln.iml
471 |
472 | # Prerequisites
473 | *.d
474 |
475 | # Compiled Object files
476 | *.slo
477 | *.lo
478 | *.o
479 | *.obj
480 |
481 | # Precompiled Headers
482 | *.gch
483 | *.pch
484 |
485 | # Compiled Dynamic libraries
486 | *.so
487 | *.dylib
488 | *.dll
489 |
490 | # Fortran module files
491 | *.mod
492 | *.smod
493 |
494 | # Compiled Static libraries
495 | *.lai
496 | *.la
497 | *.a
498 | *.lib
499 |
500 | # Executables
501 | *.exe
502 | *.out
503 | *.app
504 |
505 | # C++ objects and libs
506 | *.slo
507 | *.lo
508 | *.o
509 | *.a
510 | *.la
511 | *.lai
512 | *.so
513 | *.so.*
514 | *.dll
515 | *.dylib
516 |
517 | # Qt-es
518 | object_script.*.Release
519 | object_script.*.Debug
520 | *_plugin_import.cpp
521 | /.qmake.cache
522 | /.qmake.stash
523 | *.pro.user
524 | *.pro.user.*
525 | *.qbs.user
526 | *.qbs.user.*
527 | *.moc
528 | moc_*.cpp
529 | moc_*.h
530 | qrc_*.cpp
531 | ui_*.h
532 | *.qmlc
533 | *.jsc
534 | Makefile*
535 | *build-*
536 | *.qm
537 | *.prl
538 |
539 | # Qt unit tests
540 | target_wrapper.*
541 |
542 | # QtCreator
543 | *.autosave
544 |
545 | # QtCreator Qml
546 | *.qmlproject.user
547 | *.qmlproject.user.*
548 |
549 | # QtCreator CMake
550 | CMakeLists.txt.user*
551 |
552 | # QtCreator 4.8< compilation database
553 | compile_commands.json
554 |
555 | # QtCreator local machine specific files for imported projects
556 | *creator.user*
557 |
558 | *_qmlcache.qrc
559 |
560 | # Ignore files in externals/llama.cpp directory
561 | externals/*
562 |
563 | *.vcxproj
564 | *.vcxproj.filters
565 | *.sln
566 | .qt/
567 | SolidWriting_autogen/
568 | SolidWriting_dir/
--------------------------------------------------------------------------------
/COPYING.MPL:
--------------------------------------------------------------------------------
1 | Mozilla Public License Version 2.0
2 | ==================================
3 |
4 | 1. Definitions
5 | --------------
6 |
7 | 1.1. "Contributor"
8 | means each individual or legal entity that creates, contributes to
9 | the creation of, or owns Covered Software.
10 |
11 | 1.2. "Contributor Version"
12 | means the combination of the Contributions of others (if any) used
13 | by a Contributor and that particular Contributor's Contribution.
14 |
15 | 1.3. "Contribution"
16 | means Covered Software of a particular Contributor.
17 |
18 | 1.4. "Covered Software"
19 | means Source Code Form to which the initial Contributor has attached
20 | the notice in Exhibit A, the Executable Form of such Source Code
21 | Form, and Modifications of such Source Code Form, in each case
22 | including portions thereof.
23 |
24 | 1.5. "Incompatible With Secondary Licenses"
25 | means
26 |
27 | (a) that the initial Contributor has attached the notice described
28 | in Exhibit B to the Covered Software; or
29 |
30 | (b) that the Covered Software was made available under the terms of
31 | version 1.1 or earlier of the License, but not also under the
32 | terms of a Secondary License.
33 |
34 | 1.6. "Executable Form"
35 | means any form of the work other than Source Code Form.
36 |
37 | 1.7. "Larger Work"
38 | means a work that combines Covered Software with other material, in
39 | a separate file or files, that is not Covered Software.
40 |
41 | 1.8. "License"
42 | means this document.
43 |
44 | 1.9. "Licensable"
45 | means having the right to grant, to the maximum extent possible,
46 | whether at the time of the initial grant or subsequently, any and
47 | all of the rights conveyed by this License.
48 |
49 | 1.10. "Modifications"
50 | means any of the following:
51 |
52 | (a) any file in Source Code Form that results from an addition to,
53 | deletion from, or modification of the contents of Covered
54 | Software; or
55 |
56 | (b) any new file in Source Code Form that contains any Covered
57 | Software.
58 |
59 | 1.11. "Patent Claims" of a Contributor
60 | means any patent claim(s), including without limitation, method,
61 | process, and apparatus claims, in any patent Licensable by such
62 | Contributor that would be infringed, but for the grant of the
63 | License, by the making, using, selling, offering for sale, having
64 | made, import, or transfer of either its Contributions or its
65 | Contributor Version.
66 |
67 | 1.12. "Secondary License"
68 | means either the GNU General Public License, Version 2.0, the GNU
69 | Lesser General Public License, Version 2.1, the GNU Affero General
70 | Public License, Version 3.0, or any later versions of those
71 | licenses.
72 |
73 | 1.13. "Source Code Form"
74 | means the form of the work preferred for making modifications.
75 |
76 | 1.14. "You" (or "Your")
77 | means an individual or a legal entity exercising rights under this
78 | License. For legal entities, "You" includes any entity that
79 | controls, is controlled by, or is under common control with You. For
80 | purposes of this definition, "control" means (a) the power, direct
81 | or indirect, to cause the direction or management of such entity,
82 | whether by contract or otherwise, or (b) ownership of more than
83 | fifty percent (50%) of the outstanding shares or beneficial
84 | ownership of such entity.
85 |
86 | 2. License Grants and Conditions
87 | --------------------------------
88 |
89 | 2.1. Grants
90 |
91 | Each Contributor hereby grants You a world-wide, royalty-free,
92 | non-exclusive license:
93 |
94 | (a) under intellectual property rights (other than patent or trademark)
95 | Licensable by such Contributor to use, reproduce, make available,
96 | modify, display, perform, distribute, and otherwise exploit its
97 | Contributions, either on an unmodified basis, with Modifications, or
98 | as part of a Larger Work; and
99 |
100 | (b) under Patent Claims of such Contributor to make, use, sell, offer
101 | for sale, have made, import, and otherwise transfer either its
102 | Contributions or its Contributor Version.
103 |
104 | 2.2. Effective Date
105 |
106 | The licenses granted in Section 2.1 with respect to any Contribution
107 | become effective for each Contribution on the date the Contributor first
108 | distributes such Contribution.
109 |
110 | 2.3. Limitations on Grant Scope
111 |
112 | The licenses granted in this Section 2 are the only rights granted under
113 | this License. No additional rights or licenses will be implied from the
114 | distribution or licensing of Covered Software under this License.
115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a
116 | Contributor:
117 |
118 | (a) for any code that a Contributor has removed from Covered Software;
119 | or
120 |
121 | (b) for infringements caused by: (i) Your and any other third party's
122 | modifications of Covered Software, or (ii) the combination of its
123 | Contributions with other software (except as part of its Contributor
124 | Version); or
125 |
126 | (c) under Patent Claims infringed by Covered Software in the absence of
127 | its Contributions.
128 |
129 | This License does not grant any rights in the trademarks, service marks,
130 | or logos of any Contributor (except as may be necessary to comply with
131 | the notice requirements in Section 3.4).
132 |
133 | 2.4. Subsequent Licenses
134 |
135 | No Contributor makes additional grants as a result of Your choice to
136 | distribute the Covered Software under a subsequent version of this
137 | License (see Section 10.2) or under the terms of a Secondary License (if
138 | permitted under the terms of Section 3.3).
139 |
140 | 2.5. Representation
141 |
142 | Each Contributor represents that the Contributor believes its
143 | Contributions are its original creation(s) or it has sufficient rights
144 | to grant the rights to its Contributions conveyed by this License.
145 |
146 | 2.6. Fair Use
147 |
148 | This License is not intended to limit any rights You have under
149 | applicable copyright doctrines of fair use, fair dealing, or other
150 | equivalents.
151 |
152 | 2.7. Conditions
153 |
154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155 | in Section 2.1.
156 |
157 | 3. Responsibilities
158 | -------------------
159 |
160 | 3.1. Distribution of Source Form
161 |
162 | All distribution of Covered Software in Source Code Form, including any
163 | Modifications that You create or to which You contribute, must be under
164 | the terms of this License. You must inform recipients that the Source
165 | Code Form of the Covered Software is governed by the terms of this
166 | License, and how they can obtain a copy of this License. You may not
167 | attempt to alter or restrict the recipients' rights in the Source Code
168 | Form.
169 |
170 | 3.2. Distribution of Executable Form
171 |
172 | If You distribute Covered Software in Executable Form then:
173 |
174 | (a) such Covered Software must also be made available in Source Code
175 | Form, as described in Section 3.1, and You must inform recipients of
176 | the Executable Form how they can obtain a copy of such Source Code
177 | Form by reasonable means in a timely manner, at a charge no more
178 | than the cost of distribution to the recipient; and
179 |
180 | (b) You may distribute such Executable Form under the terms of this
181 | License, or sublicense it under different terms, provided that the
182 | license for the Executable Form does not attempt to limit or alter
183 | the recipients' rights in the Source Code Form under this License.
184 |
185 | 3.3. Distribution of a Larger Work
186 |
187 | You may create and distribute a Larger Work under terms of Your choice,
188 | provided that You also comply with the requirements of this License for
189 | the Covered Software. If the Larger Work is a combination of Covered
190 | Software with a work governed by one or more Secondary Licenses, and the
191 | Covered Software is not Incompatible With Secondary Licenses, this
192 | License permits You to additionally distribute such Covered Software
193 | under the terms of such Secondary License(s), so that the recipient of
194 | the Larger Work may, at their option, further distribute the Covered
195 | Software under the terms of either this License or such Secondary
196 | License(s).
197 |
198 | 3.4. Notices
199 |
200 | You may not remove or alter the substance of any license notices
201 | (including copyright notices, patent notices, disclaimers of warranty,
202 | or limitations of liability) contained within the Source Code Form of
203 | the Covered Software, except that You may alter any license notices to
204 | the extent required to remedy known factual inaccuracies.
205 |
206 | 3.5. Application of Additional Terms
207 |
208 | You may choose to offer, and to charge a fee for, warranty, support,
209 | indemnity or liability obligations to one or more recipients of Covered
210 | Software. However, You may do so only on Your own behalf, and not on
211 | behalf of any Contributor. You must make it absolutely clear that any
212 | such warranty, support, indemnity, or liability obligation is offered by
213 | You alone, and You hereby agree to indemnify every Contributor for any
214 | liability incurred by such Contributor as a result of warranty, support,
215 | indemnity or liability terms You offer. You may include additional
216 | disclaimers of warranty and limitations of liability specific to any
217 | jurisdiction.
218 |
219 | 4. Inability to Comply Due to Statute or Regulation
220 | ---------------------------------------------------
221 |
222 | If it is impossible for You to comply with any of the terms of this
223 | License with respect to some or all of the Covered Software due to
224 | statute, judicial order, or regulation then You must: (a) comply with
225 | the terms of this License to the maximum extent possible; and (b)
226 | describe the limitations and the code they affect. Such description must
227 | be placed in a text file included with all distributions of the Covered
228 | Software under this License. Except to the extent prohibited by statute
229 | or regulation, such description must be sufficiently detailed for a
230 | recipient of ordinary skill to be able to understand it.
231 |
232 | 5. Termination
233 | --------------
234 |
235 | 5.1. The rights granted under this License will terminate automatically
236 | if You fail to comply with any of its terms. However, if You become
237 | compliant, then the rights granted under this License from a particular
238 | Contributor are reinstated (a) provisionally, unless and until such
239 | Contributor explicitly and finally terminates Your grants, and (b) on an
240 | ongoing basis, if such Contributor fails to notify You of the
241 | non-compliance by some reasonable means prior to 60 days after You have
242 | come back into compliance. Moreover, Your grants from a particular
243 | Contributor are reinstated on an ongoing basis if such Contributor
244 | notifies You of the non-compliance by some reasonable means, this is the
245 | first time You have received notice of non-compliance with this License
246 | from such Contributor, and You become compliant prior to 30 days after
247 | Your receipt of the notice.
248 |
249 | 5.2. If You initiate litigation against any entity by asserting a patent
250 | infringement claim (excluding declaratory judgment actions,
251 | counter-claims, and cross-claims) alleging that a Contributor Version
252 | directly or indirectly infringes any patent, then the rights granted to
253 | You by any and all Contributors for the Covered Software under Section
254 | 2.1 of this License shall terminate.
255 |
256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257 | end user license agreements (excluding distributors and resellers) which
258 | have been validly granted by You or Your distributors under this License
259 | prior to termination shall survive termination.
260 |
261 | ************************************************************************
262 | * *
263 | * 6. Disclaimer of Warranty *
264 | * ------------------------- *
265 | * *
266 | * Covered Software is provided under this License on an "as is" *
267 | * basis, without warranty of any kind, either expressed, implied, or *
268 | * statutory, including, without limitation, warranties that the *
269 | * Covered Software is free of defects, merchantable, fit for a *
270 | * particular purpose or non-infringing. The entire risk as to the *
271 | * quality and performance of the Covered Software is with You. *
272 | * Should any Covered Software prove defective in any respect, You *
273 | * (not any Contributor) assume the cost of any necessary servicing, *
274 | * repair, or correction. This disclaimer of warranty constitutes an *
275 | * essential part of this License. No use of any Covered Software is *
276 | * authorized under this License except under this disclaimer. *
277 | * *
278 | ************************************************************************
279 |
280 | ************************************************************************
281 | * *
282 | * 7. Limitation of Liability *
283 | * -------------------------- *
284 | * *
285 | * Under no circumstances and under no legal theory, whether tort *
286 | * (including negligence), contract, or otherwise, shall any *
287 | * Contributor, or anyone who distributes Covered Software as *
288 | * permitted above, be liable to You for any direct, indirect, *
289 | * special, incidental, or consequential damages of any character *
290 | * including, without limitation, damages for lost profits, loss of *
291 | * goodwill, work stoppage, computer failure or malfunction, or any *
292 | * and all other commercial damages or losses, even if such party *
293 | * shall have been informed of the possibility of such damages. This *
294 | * limitation of liability shall not apply to liability for death or *
295 | * personal injury resulting from such party's negligence to the *
296 | * extent applicable law prohibits such limitation. Some *
297 | * jurisdictions do not allow the exclusion or limitation of *
298 | * incidental or consequential damages, so this exclusion and *
299 | * limitation may not apply to You. *
300 | * *
301 | ************************************************************************
302 |
303 | 8. Litigation
304 | -------------
305 |
306 | Any litigation relating to this License may be brought only in the
307 | courts of a jurisdiction where the defendant maintains its principal
308 | place of business and such litigation shall be governed by laws of that
309 | jurisdiction, without reference to its conflict-of-law provisions.
310 | Nothing in this Section shall prevent a party's ability to bring
311 | cross-claims or counter-claims.
312 |
313 | 9. Miscellaneous
314 | ----------------
315 |
316 | This License represents the complete agreement concerning the subject
317 | matter hereof. If any provision of this License is held to be
318 | unenforceable, such provision shall be reformed only to the extent
319 | necessary to make it enforceable. Any law or regulation which provides
320 | that the language of a contract shall be construed against the drafter
321 | shall not be used to construe this License against a Contributor.
322 |
323 | 10. Versions of the License
324 | ---------------------------
325 |
326 | 10.1. New Versions
327 |
328 | Mozilla Foundation is the license steward. Except as provided in Section
329 | 10.3, no one other than the license steward has the right to modify or
330 | publish new versions of this License. Each version will be given a
331 | distinguishing version number.
332 |
333 | 10.2. Effect of New Versions
334 |
335 | You may distribute the Covered Software under the terms of the version
336 | of the License under which You originally received the Covered Software,
337 | or under the terms of any subsequent version published by the license
338 | steward.
339 |
340 | 10.3. Modified Versions
341 |
342 | If you create software not governed by this License, and you want to
343 | create a new license for such software, you may create and use a
344 | modified version of this License if you rename the license and remove
345 | any references to the name of the license steward (except to note that
346 | such modified license differs from this License).
347 |
348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary
349 | Licenses
350 |
351 | If You choose to distribute Source Code Form that is Incompatible With
352 | Secondary Licenses under the terms of this version of the License, the
353 | notice described in Exhibit B of this License must be attached.
354 |
355 | Exhibit A - Source Code Form License Notice
356 | -------------------------------------------
357 |
358 | This Source Code Form is subject to the terms of the Mozilla Public
359 | License, v. 2.0. If a copy of the MPL was not distributed with this
360 | file, You can obtain one at http://mozilla.org/MPL/2.0/.
361 |
362 | If it is not possible or desirable to put the notice in a particular
363 | file, then You may include the notice in a location (such as a LICENSE
364 | file in a relevant directory) where a recipient would be likely to look
365 | for such a notice.
366 |
367 | You may add additional accurate notices of copyright ownership.
368 |
369 | Exhibit B - "Incompatible With Secondary Licenses" Notice
370 | ---------------------------------------------------------
371 |
372 | This Source Code Form is "Incompatible With Secondary Licenses", as
373 | defined by the Mozilla Public License, v. 2.0.
374 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 | SolidWriting
635 | Copyright (C) 2025 Berkay Gediz
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | SolidWriting Copyright (C) 2025 Berkay Gediz
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/experimental/cpp/sw_workspace.cpp:
--------------------------------------------------------------------------------
1 | #include "./globals.h"
2 | #include "rs_workspace.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #include
33 | #include
34 | #include
35 | #include
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | #ifdef Q_OS_WIN
43 | #include
44 |
45 | #include
46 | #endif
47 |
48 | using namespace std::chrono;
49 | using std::string;
50 |
51 | FallbackValues fallback;
52 |
53 | #include
54 | #include
55 |
56 | RS_Workspace::RS_Workspace(QWidget *parent)
57 | : QMainWindow(parent), isSaved(false), llm(nullptr),
58 | ui(new Ui::RS_Workspace) {
59 | ui->setupUi(this);
60 | QTimer::singleShot(0, this, &RS_Workspace::initUI);
61 | }
62 |
63 | RS_Workspace::~RS_Workspace() { delete ui; }
64 |
65 | void RS_Workspace::readSettings() {
66 | try {
67 | QSettings settings("berkaygediz", "SolidWriting");
68 | QString lang = settings.value("appLanguage").toString();
69 |
70 | if (lang.isEmpty()) {
71 | settings.setValue("appLanguage", "1252");
72 | settings.sync();
73 | }
74 |
75 | if (settings.value("adaptiveResponse").isNull()) {
76 | settings.setValue("adaptiveResponse", 1);
77 | settings.sync();
78 | }
79 | } catch (const QException &e) {
80 | qWarning() << "Error while reading settings: " << e.what();
81 | }
82 | }
83 |
84 | void RS_Workspace::initUI() {
85 | auto starttime = QDateTime::currentDateTime();
86 | FallbackValues fallback;
87 | setWindowIcon(QIcon(":/resources/solidwriting_icon.ico"));
88 | setWindowModality(Qt::ApplicationModal);
89 |
90 | setMinimumSize(768, 540);
91 |
92 | QString system_language = QLocale::system().name().section('_', 0, 0);
93 | if (!languages.contains(system_language)) {
94 | QSettings settings;
95 | settings.setValue("appLanguage", "1252");
96 | settings.sync();
97 | }
98 |
99 | QSettings settings;
100 | if (settings.value("adaptiveResponse") == QVariant()) {
101 | settings.setValue("adaptiveResponse", 1);
102 | settings.sync();
103 | }
104 | QWidget *centralWidget = new QWidget(this);
105 | QVBoxLayout *layout = new QVBoxLayout(centralWidget);
106 |
107 | documentArea = new QTextEdit(this);
108 | documentArea->setFocus();
109 | documentArea->setAcceptRichText(true);
110 | documentArea->setTextInteractionFlags(Qt::TextEditorInteraction);
111 | layout->addWidget(documentArea);
112 |
113 | setCentralWidget(centralWidget);
114 |
115 | connect(documentArea, &QTextEdit::textChanged, this,
116 | &RS_Workspace::updateStatistics);
117 |
118 | themePalette();
119 | selectedFile = "";
120 | fileName = "";
121 | isSaved = false;
122 | defaultDirectory = QDir::homePath();
123 | directory = defaultDirectory;
124 |
125 | LLMinitDock();
126 | QStatusBar *status_bar = statusBar();
127 | // documentArea->setContextMenuPolicy(Qt::CustomContextMenu);
128 | // connect(documentArea,
129 | // &QTextEdit::customContextMenuRequested,
130 | // this,
131 | // &RS_Workspace::showContextMenu);
132 |
133 | initArea();
134 |
135 | documentArea->setDisabled(true);
136 |
137 | initActions();
138 | initToolbar();
139 |
140 | adaptiveResponse = settings.value("adaptiveResponse").toInt();
141 | setPalette(lightTheme);
142 |
143 | showMaximized();
144 |
145 | // QTimer::singleShot(50 * adaptiveResponse, this,
146 | // &RS_Workspace::restoreTheme); QTimer::singleShot(150 * adaptiveResponse,
147 | // this, &RS_Workspace::restoreState);
148 |
149 | documentArea->setDisabled(false);
150 |
151 | updateTitle();
152 |
153 | auto endtime = QDateTime::currentDateTime();
154 | status_bar->showMessage(QString::number(starttime.msecsTo(endtime)) + " ms",
155 | 2500);
156 |
157 | // if (acceleratorHardware() == "cpu") {
158 | // LLMwarningCPU();
159 | // }
160 | }
161 |
162 | void RS_Workspace::changeLanguage() {
163 | QSettings settings;
164 | settings.setValue("appLanguage", language_combobox->currentData());
165 | settings.sync();
166 |
167 | toolbarTranslate();
168 | updateStatistics();
169 | updateTitle();
170 | }
171 |
172 | void RS_Workspace::updateTitle() {
173 | QSettings settings;
174 | QString lang = settings.value("appLanguage").toString();
175 |
176 | QString file = !fileName.isEmpty() ? fileName : translations[lang]["new"];
177 | QString textMode =
178 | file.endsWith(".docx") ? translations[lang]["readonly"] : "";
179 |
180 | QString asterisk = textMode.isEmpty() && !isSaved ? "*" : "";
181 |
182 | setWindowTitle(file + asterisk + textMode + " — " +
183 | qApp->applicationDisplayName());
184 | }
185 |
186 | // void RS_Workspace::threadStart() {
187 | // if (!thread_running) {
188 | // solidwriting_thread->start();
189 | // thread_running = true;
190 | // }
191 | // }
192 |
193 | // void RS_Workspace::textChanged() {
194 | // if (!text_changed_timer->isActive()) {
195 | // text_changed_timer->start();
196 | // }
197 | // }
198 |
199 | void RS_Workspace::closeEvent(QCloseEvent *event) {
200 | QSettings settings;
201 | QString lang = settings.value("appLanguage").toString();
202 |
203 | if (!isSaved) {
204 | QMessageBox::StandardButton reply = QMessageBox::question(
205 | this, qApp->applicationDisplayName(), "Exit",
206 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
207 |
208 | if (reply == QMessageBox::Yes) {
209 | // saveState();
210 | event->accept();
211 | } else {
212 | // saveState();
213 | event->ignore();
214 | }
215 | } else {
216 | // saveState();
217 | event->accept();
218 | }
219 | }
220 | void RS_Workspace::updateStatistics() {
221 | QString text = documentArea->toPlainText();
222 |
223 | int character_count = text.length();
224 | int word_count =
225 | text.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts).size();
226 | int line_count = text.count("\n") + 1;
227 |
228 | double avg_word_length = 0.0;
229 | double avg_line_length = 0.0;
230 | int uppercase_count = 0;
231 | int lowercase_count = 0;
232 | QString detected_language;
233 | QString lang = settings.value("appLanguage").toString();
234 |
235 | if (word_count > 0 && line_count > 0 && character_count > 0 &&
236 | !text.isEmpty()) {
237 | avg_word_length = static_cast(character_count) / word_count;
238 | avg_line_length = static_cast(character_count) / line_count;
239 |
240 | for (QChar c : text) {
241 | if (c.isUpper())
242 | uppercase_count++;
243 | if (c.isLower())
244 | lowercase_count++;
245 | }
246 | }
247 |
248 | QString statistics = "";
257 |
258 | statistics += QString("| %1 | ").arg(translations[lang]["analysis"]);
259 | statistics += QString("%1 | ")
260 | .arg(translations[lang]["analysis_message_1"].arg(
261 | QString::number(avg_word_length, 'f', 1)));
262 | statistics += QString("%1 | ")
263 | .arg(translations[lang]["analysis_message_2"].arg(
264 | QString::number(avg_line_length, 'f', 1)));
265 | statistics +=
266 | QString("%1 | ")
267 | .arg(translations[lang]["analysis_message_3"].arg(uppercase_count));
268 | statistics +=
269 | QString("%1 | ")
270 | .arg(translations[lang]["analysis_message_4"].arg(lowercase_count));
271 |
272 | if (!detected_language.isEmpty()) {
273 | statistics += QString("%1 | ")
274 | .arg(translations[lang]["analysis_message_5"].arg(
275 | detected_language));
276 | }
277 |
278 | statistics += QString("%1 | ").arg(translations[lang]["statistic"]);
279 | statistics +=
280 | QString("%1 | ")
281 | .arg(translations[lang]["statistic_message_1"].arg(line_count));
282 | statistics +=
283 | QString("%1 | ")
284 | .arg(translations[lang]["statistic_message_2"].arg(word_count));
285 | statistics +=
286 | QString("%1 | ")
287 | .arg(translations[lang]["statistic_message_3"].arg(character_count));
288 |
289 | statistics +=
290 | QString("%1 | ").arg(qApp->applicationDisplayName());
291 |
292 | statistics += "
";
293 |
294 | QString new_text = documentArea->toPlainText();
295 | if (new_text != fallback.content) {
296 | isSaved = false;
297 | } else {
298 | isSaved = true;
299 | }
300 |
301 | updateTitle();
302 | }
303 |
304 | void RS_Workspace::themePalette() {
305 | lightTheme.setColor(QPalette::Window, QColor(3, 65, 135));
306 | lightTheme.setColor(QPalette::WindowText, QColor(255, 255, 255));
307 | lightTheme.setColor(QPalette::Base, QColor(255, 255, 255));
308 | lightTheme.setColor(QPalette::Text, QColor(0, 0, 0));
309 | lightTheme.setColor(QPalette::Highlight, QColor(105, 117, 156));
310 | lightTheme.setColor(QPalette::Button, QColor(0, 0, 0));
311 | lightTheme.setColor(QPalette::ButtonText, QColor(255, 255, 255));
312 |
313 | darkTheme.setColor(QPalette::Window, QColor(35, 39, 52));
314 | darkTheme.setColor(QPalette::WindowText, QColor(255, 255, 255));
315 | darkTheme.setColor(QPalette::Base, QColor(80, 85, 122));
316 | darkTheme.setColor(QPalette::Text, QColor(255, 255, 255));
317 | darkTheme.setColor(QPalette::Highlight, QColor(105, 117, 156));
318 | darkTheme.setColor(QPalette::Button, QColor(0, 0, 0));
319 | darkTheme.setColor(QPalette::ButtonText, QColor(255, 255, 255));
320 | }
321 |
322 | void RS_Workspace::themeAction() {
323 | if (palette() == lightTheme) {
324 | setPalette(darkTheme);
325 | settings.setValue("appTheme", "dark");
326 | } else {
327 | setPalette(lightTheme);
328 | settings.setValue("appTheme", "light");
329 | }
330 | toolbarTheme();
331 | }
332 |
333 | void RS_Workspace::toolbarTheme() {
334 | QPalette currentPalette = palette();
335 | QColor textColor = (currentPalette == lightTheme) ? QColor(255, 255, 255)
336 | : QColor(255, 255, 255);
337 |
338 | foreach (QToolBar *toolbar, findChildren()) {
339 | foreach (QAction *action, toolbar->actions()) {
340 | if (!action->text().isEmpty()) {
341 | QPalette actionColor;
342 | actionColor.setColor(QPalette::ButtonText, textColor);
343 | actionColor.setColor(QPalette::WindowText, textColor);
344 | toolbar->setPalette(actionColor);
345 | }
346 | }
347 | }
348 | }
349 |
350 | void RS_Workspace::toolbarTranslate() {
351 | QString lang = settings.value("appLanguage", "en").toString();
352 |
353 | QMap> actions = {
354 | {newaction, {"new", "new_message"}},
355 | {openaction, {"open", "open_message"}},
356 | {saveaction, {"save", "save_message"}},
357 | {saveasaction, {"save_as", "save_as_message"}},
358 | {printaction, {"print", "print_message"}},
359 | {undoaction, {"undo", "undo_message"}},
360 | {redoaction, {"redo", "redo_message"}},
361 | {theme_action, {"darklight", "darklight_message"}},
362 | {powersaveraction, {"powersaver", "powersaver_message"}},
363 | {findaction, {"find", "find_message"}},
364 | {replaceaction, {"replace", "replace_message"}},
365 | {helpAction, {"help", "help"}},
366 | {aboutAction, {"about", "about"}},
367 | {alignrightevent, {"right", "right_message"}},
368 | {aligncenterevent, {"center", "center_message"}},
369 | {alignleftevent, {"left", "left_message"}},
370 | {alignjustifiedevent, {"justify", "justify_message"}},
371 | {bold, {"bold", "bold_message"}},
372 | {italic, {"italic", "italic_message"}},
373 | {underline, {"underline", "underline_message"}},
374 | {bulletevent, {"bullet", "bullet"}},
375 | {numberedevent, {"numbered", "numbered"}},
376 | {color, {"font_color", "font_color_message"}},
377 | {backgroundcolor,
378 | {"contentBackgroundColor", "contentBackgroundColor_message"}},
379 | {fontfamily, {"font", "font_message"}},
380 | {addimage, {"image", "image_message"}}};
381 |
382 | for (auto it = actions.begin(); it != actions.end(); ++it) {
383 | QAction *action = it.key();
384 | QString textKey = it.value().first;
385 | QString statusKey = it.value().second;
386 |
387 | action->setText(translations[lang][textKey]);
388 | action->setStatusTip(translations[lang][statusKey]);
389 | }
390 |
391 | ai_widget.setWindowTitle("AI");
392 |
393 | translateToolbarLabel(file_toolbar, "file", lang);
394 | translateToolbarLabel(ui_toolbar, "ui", lang);
395 | translateToolbarLabel(edit_toolbar, "edit", lang);
396 | translateToolbarLabel(font_toolbar, "font", lang);
397 | translateToolbarLabel(list_toolbar, "list", lang);
398 | translateToolbarLabel(color_toolbar, "color", lang);
399 | translateToolbarLabel(multimedia_toolbar, "multimedia", lang);
400 | }
401 |
402 | void RS_Workspace::translateToolbarLabel(QToolBar *toolbar,
403 | const QString &labelKey,
404 | const QString &lang) {
405 | QString translatedLabel = translations[lang].value(labelKey, labelKey) + ": ";
406 | updateToolbarLabel(toolbar, translatedLabel);
407 | }
408 |
409 | void RS_Workspace::updateToolbarLabel(QToolBar *toolbar,
410 | const QString &newLabel) {
411 | for (QObject *widget : toolbar->children()) {
412 | QLabel *label = qobject_cast(widget);
413 | if (label) {
414 | label->setText(QString("%1").arg(newLabel));
415 | return;
416 | }
417 | }
418 | }
419 |
420 | void RS_Workspace::initArea() {
421 | documentArea->setFontFamily(fallback.fontFamily);
422 | documentArea->setFontPointSize(fallback.fontSize);
423 | documentArea->setFontWeight(100 ? fallback.bold : 50);
424 | documentArea->setFontItalic(fallback.italic);
425 | documentArea->setFontUnderline(fallback.underline);
426 | documentArea->setAlignment(fallback.contentAlign);
427 | documentArea->setTextColor(fallback.contentColor);
428 | documentArea->setTextBackgroundColor(fallback.contentBackgroundColor);
429 | documentArea->setTabStopDistance(27);
430 | documentArea->document()->setDocumentMargin(this->width() * 0.25);
431 | }
432 |
433 | void RS_Workspace::LLMwarningCPU() {
434 | QString message = "Your device does not have GPU support. Running intensive "
435 | "AI operations on the CPU "
436 | "may result in high CPU utilization, causing system "
437 | "performance degradation and potential "
438 | "long-term damage. This could lead to overheating, system "
439 | "instability, or permanent hardware damage. "
440 | "By proceeding with CPU usage, you acknowledge and accept "
441 | "the risks associated with these operations. "
442 | "Do you still wish to continue?";
443 |
444 | QMessageBox::StandardButton reply = QMessageBox::question(
445 | this, QString(), message, QMessageBox::Yes | QMessageBox::No,
446 | QMessageBox::No);
447 |
448 | if (reply == QMessageBox::Yes) {
449 | // QTimer::singleShot(500, this, &RS_Workspace::loadLLM);
450 | }
451 |
452 | if (reply == QMessageBox::No) {
453 | // ai_widget->setWidget(new QLabel("GPU/NPU not available."));
454 | }
455 | }
456 |
457 | void RS_Workspace::LLMinitDock() {
458 | QDockWidget *ai_widget = new QDockWidget("AI", this);
459 | ai_widget->setObjectName("AI");
460 | ai_widget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
461 |
462 | QVBoxLayout *main_layout = new QVBoxLayout();
463 |
464 | scrollableArea = new QScrollArea();
465 | messages_layout = new QVBoxLayout();
466 |
467 | input_text = new QTextEdit();
468 | input_text->setPlaceholderText("...");
469 | input_text->setFixedHeight(80);
470 | main_layout->addWidget(input_text);
471 |
472 | predict_button = new QPushButton("->");
473 | connect(predict_button, &QPushButton::clicked, this,
474 | &RS_Workspace::LLMpredict);
475 | main_layout->addWidget(predict_button);
476 |
477 | scrollableArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
478 | scrollableArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
479 | scrollableArea->setWidgetResizable(true);
480 |
481 | QWidget *scroll_contents = new QWidget();
482 | scroll_contents->setLayout(messages_layout);
483 | scrollableArea->setWidget(scroll_contents);
484 |
485 | main_layout->addWidget(scrollableArea);
486 |
487 | QWidget *container = new QWidget();
488 | container->setLayout(main_layout);
489 |
490 | ai_widget->setWidget(container);
491 | ai_widget->setFeatures(QDockWidget::DockWidgetClosable);
492 |
493 | addDockWidget(Qt::RightDockWidgetArea, ai_widget);
494 | }
495 |
496 | void RS_Workspace::LLMmessage(const QString &text, bool is_user = true) {
497 | QString current_time =
498 | QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
499 |
500 | // QString formatted_text = text.replace("\n", "
");
501 | // formatted_text = LLMconvertMarkdownHTML(formatted_text);
502 |
503 | QWidget *message_widget = new QWidget();
504 | QHBoxLayout *message_layout = new QHBoxLayout();
505 |
506 | // QString message_label_content = formatted_text;
507 |
508 | // message_label_content += QString("
(%1)").arg(current_time);
509 |
510 | QLabel *message_label = new QLabel(text);
511 | message_label->setWordWrap(true);
512 | message_label->setTextInteractionFlags(Qt::TextSelectableByMouse);
513 | message_label->setTextFormat(Qt::RichText);
514 | message_label->setMaximumWidth(400);
515 |
516 | if (is_user) {
517 | message_label->setStyleSheet(
518 | "background-color: #d1e7ff; color: #000; border-radius: 15px; padding: "
519 | "10px; margin: 5px;");
520 | message_layout->addWidget(message_label, Qt::AlignRight);
521 | } else {
522 | message_label->setStyleSheet(
523 | "background-color: #f1f1f1; color: #000; border-radius: 15px; padding: "
524 | "10px; margin: 5px;");
525 | message_layout->addWidget(message_label, Qt::AlignLeft);
526 | }
527 |
528 | message_widget->setLayout(message_layout);
529 |
530 | messages_layout->addWidget(message_widget);
531 | }
532 |
533 | void RS_Workspace::LLMpredict() {
534 | QString prompt = input_text->toPlainText().trimmed();
535 |
536 | if (prompt.isEmpty()) {
537 | LLMmessage("Please enter a question.", false);
538 | return;
539 | }
540 |
541 | LLMmessage(prompt, true);
542 |
543 | predict_button->setText("...");
544 | predict_button->setEnabled(false);
545 |
546 | // QTimer::singleShot(100, this, &RS_Workspace::LLMprompt);
547 | }
548 |
549 | void RS_Workspace::LLMcontextPredict(bool action_type) {
550 | QString selected_text = documentArea->textCursor().selectedText().trimmed();
551 |
552 | QString prompt;
553 | if (action_type) {
554 | prompt = QString("%1: %2").arg(action_type ? "Action" : "No Action",
555 | selected_text);
556 | } else {
557 | prompt = selected_text;
558 | }
559 |
560 | ai_widget.show();
561 | LLMmessage(prompt, true);
562 | predict_button->setText("...");
563 | predict_button->setEnabled(false);
564 |
565 | if (selected_text.isEmpty()) {
566 | LLMmessage("No text selected.", false); // Bot message
567 | return;
568 | }
569 |
570 | QTimer::singleShot(100, [this, prompt]() { LLMprompt(prompt); });
571 | }
572 |
573 | void RS_Workspace::LLMprompt(const QString &prompt) {
574 | if (!prompt.isEmpty()) {
575 | QString response = LLMresponse(prompt);
576 | LLMmessage(response, false); // Bot message
577 | input_text->clear();
578 | } else {
579 | LLMmessage("Please enter a question.", false); // Bot message
580 | }
581 |
582 | predict_button->setText("->");
583 | predict_button->setEnabled(true);
584 | }
585 |
586 | QString RS_Workspace::LLMresponse(const QString &prompt) {
587 | try {
588 | QString response = "Simulated response to: " + prompt;
589 | return response;
590 | } catch (const std::exception &e) {
591 | return QString("Error: %1").arg(e.what());
592 | }
593 | }
594 |
595 | QString RS_Workspace::LLMconvertMarkdownHTML(const QString &markdown_text) {
596 | QString text = LLMconvertCodeHTML(markdown_text);
597 | text = convertBoldItalic(text);
598 | return text;
599 | }
600 |
601 | QString RS_Workspace::convertBoldItalic(const QString &text) {
602 | QString modified_text = text;
603 | modified_text.replace(QRegularExpression("\\*\\*(.*?)\\*\\*"),
604 | "\\1"); // **bold**
605 | modified_text.replace(QRegularExpression("__(.*?)__"),
606 | "\\1"); // __bold__
607 | modified_text.replace(QRegularExpression("\\*(.*?)\\*"),
608 | "\\1"); // *italic*
609 | modified_text.replace(QRegularExpression("_(.*?)_"),
610 | "\\1"); // _italic_
611 | return modified_text;
612 | }
613 |
614 | QString RS_Workspace::LLMconvertCodeHTML(const QString &input_text) {
615 | QString modified_text = input_text;
616 |
617 | QRegularExpression code_block_regex(
618 | R"(\[code\](.*?)\[/code\])",
619 | QRegularExpression::DotMatchesEverythingOption);
620 |
621 | auto replace_code_block =
622 | [](const QRegularExpressionMatch &match) -> QString {
623 | QString code_content = match.captured(1);
624 | return "" + code_content + "
";
625 | };
626 |
627 | QRegularExpressionMatchIterator matchIterator =
628 | code_block_regex.globalMatch(modified_text);
629 |
630 | int offset = 0;
631 | while (matchIterator.hasNext()) {
632 | QRegularExpressionMatch match = matchIterator.next();
633 | QString replacement = replace_code_block(match);
634 | modified_text.replace(match.capturedStart(), match.capturedLength(),
635 | replacement);
636 | }
637 |
638 | return modified_text;
639 | }
640 |
641 | QString RS_Workspace::LLMescapeHTML(const QString &text) {
642 | QString modified_text = text;
643 |
644 | QRegularExpression html_escape_regex(R"([&<>\"'])");
645 |
646 | QRegularExpressionMatchIterator matchIterator =
647 | html_escape_regex.globalMatch(modified_text);
648 |
649 | int offset = 0;
650 | while (matchIterator.hasNext()) {
651 | QRegularExpressionMatch match = matchIterator.next();
652 |
653 | QString matched_char = match.captured(0);
654 | QString replacement;
655 |
656 | switch (matched_char[0].toLatin1()) {
657 | case '&':
658 | replacement = "&";
659 | break;
660 | case '<':
661 | replacement = "<";
662 | break;
663 | case '>':
664 | replacement = ">";
665 | break;
666 | case '"':
667 | replacement = """;
668 | break;
669 | case '\'':
670 | replacement = "'";
671 | break;
672 | default:
673 | replacement = matched_char;
674 | break;
675 | }
676 |
677 | modified_text.replace(match.capturedStart(), match.capturedLength(),
678 | replacement);
679 | }
680 |
681 | return modified_text;
682 | }
683 |
684 | QAction *RS_Workspace::createAction(const QString &text,
685 | const QString &statusTip,
686 | std::function function,
687 | const QKeySequence &shortcut) {
688 | QAction *action = new QAction(text);
689 | action->setStatusTip(statusTip);
690 |
691 | connect(action, &QAction::triggered, this,
692 | [this, function]() { function(); });
693 |
694 | if (!shortcut.isEmpty()) {
695 | action->setShortcut(shortcut);
696 | }
697 |
698 | return action;
699 | }
700 |
701 | void RS_Workspace::toolbarLabel(QToolBar *toolbar, const QString &text) {
702 | QLabel *label = new QLabel("" + text + "");
703 | toolbar->addWidget(label);
704 | }
705 |
706 | void RS_Workspace::initActions() {
707 | struct ActionDefinition {
708 | QString name;
709 | QString text;
710 | QString statusTip;
711 | std::function function;
712 | QKeySequence shortcut;
713 | };
714 |
715 | QList actionDefinitions = {
716 | {"newaction", "New", "Create a new file", [this]() { newFile(); },
717 | QKeySequence::New},
718 | {"openaction", "Open", "Open an existing file", [this]() { openFile(); },
719 | QKeySequence::Open},
720 | {"saveaction", "Save", "Save the current file", [this]() { saveFile(); },
721 | QKeySequence::Save},
722 | {"saveasaction", "Save As", "Save the file with a new name",
723 | [this]() { saveAs(); }, QKeySequence::SaveAs},
724 | {"printaction", "Print", "Print the document",
725 | [this]() { printDocument(); }, QKeySequence::Print},
726 | {"findaction", "Find", "Find text in the document", [this]() { find(); },
727 | QKeySequence::Find},
728 | {"replaceaction", "Replace", "Replace text in the document",
729 | [this]() { replace(); }, QKeySequence::Replace},
730 | {"undoaction", "Undo", "Undo the last action",
731 | [this]() { documentArea->undo(); }, QKeySequence::Undo},
732 | {"redoaction", "Redo", "Redo the last undone action",
733 | [this]() { documentArea->redo(); }, QKeySequence::Redo},
734 | {"alignrightevent", "Align Right", "Align the text to the right",
735 | [this]() { contentAlign(Qt::AlignRight); }, QKeySequence()},
736 | {"alignleftevent", "Align Left", "Align the text to the left",
737 | [this]() { contentAlign(Qt::AlignLeft); }, QKeySequence()},
738 | {"aligncenterevent", "Align Center", "Align the text to the center",
739 | [this]() { contentAlign(Qt::AlignCenter); }, QKeySequence()},
740 | {"alignjustifiedevent", "Justify", "Justify the text",
741 | [this]() { contentAlign(Qt::AlignJustify); }, QKeySequence()},
742 | {"bulletevent", "Bullet List", "Insert a bullet list",
743 | [this]() { bulletList(); }, QKeySequence("Ctrl+Shift+U")},
744 | {"numberedevent", "Numbered List", "Insert a numbered list",
745 | [this]() { numberedList(); }, QKeySequence("Ctrl+Shift+O")},
746 | {"bold", "Bold", "Bold the selected text", [this]() { contentBold(); },
747 | QKeySequence::Bold},
748 | {"italic", "Italic", "Italicize the selected text",
749 | [this]() { contentItalic(); }, QKeySequence::Italic},
750 | {"underline", "Underline", "Underline the selected text",
751 | [this]() { contentUnderline(); }, QKeySequence::Underline},
752 | {"color", "Font Color", "Change the font color",
753 | [this]() { contentColor(); }, QKeySequence("Ctrl+Shift+C")},
754 | {"backgroundcolor", "Background Color", "Change the background color",
755 | [this]() { contentBGColor(); }, QKeySequence("Ctrl+Shift+B")},
756 | {"fontfamily", "Font", "Change the font", [this]() { contentFont(); },
757 | QKeySequence("Ctrl+Shift+F")},
758 | {"inc_fontaction", "Increase Font", "Increase the font size",
759 | [this]() { incFont(); }, QKeySequence("Ctrl++")},
760 | {"dec_fontaction", "Decrease Font", "Decrease the font size",
761 | [this]() { decFont(); }, QKeySequence("Ctrl+-")},
762 | {"addimage", "Add Image", "Insert an image", [this]() { addImage(); },
763 | QKeySequence("Ctrl+Shift+P")},
764 | // {"helpAction",
765 | // "Help",
766 | // "View help documentation",
767 | // [this]() { viewHelp(); },
768 | // QKeySequence("Ctrl+H")},
769 | // {"aboutAction",
770 | // "About",
771 | // "View information about the application",
772 | // [this]() { viewAbout(); },
773 | // QKeySequence("Ctrl+Shift+I")}
774 | };
775 |
776 | for (const ActionDefinition &actionDef : actionDefinitions) {
777 | QAction *action = createAction(actionDef.text, actionDef.statusTip,
778 | actionDef.function, actionDef.shortcut);
779 | action->setObjectName(actionDef.name);
780 | addAction(action);
781 | }
782 | }
783 |
784 | void RS_Workspace::addImage() {
785 | QFileDialog::Options options;
786 | options |= QFileDialog::ReadOnly;
787 | QString selectedFile = QFileDialog::getOpenFileName(
788 | this, "Open", directory, "Images (*.png *.jpg *.bmp);;All Files (*)",
789 | nullptr, options);
790 |
791 | if (!selectedFile.isEmpty()) {
792 | QString mimeType = QMimeDatabase().mimeTypeForFile(selectedFile).name();
793 | if (mimeType.isEmpty()) {
794 | mimeType = "image/png";
795 | }
796 |
797 | QFile file(selectedFile);
798 | if (file.open(QIODevice::ReadOnly)) {
799 | QByteArray data = file.readAll();
800 | QString encodedData = data.toBase64();
801 | QString imgTag = QString("
")
802 | .arg(mimeType, encodedData);
803 | documentArea->insertHtml(imgTag);
804 | }
805 | }
806 | }
807 |
808 | // void RS_Workspace::viewAbout() {
809 | // aboutWindow = new RS_About(this);
810 | // aboutWindow->show();
811 | // }
812 |
813 | // void RS_Workspace::viewHelp() {
814 | // RS_Help *helpWindow = new RS_Help(this);
815 | // helpWindow->show();
816 | // }
817 |
818 | void RS_Workspace::bulletList() {
819 | QTextCursor cursor = documentArea->textCursor();
820 | cursor.beginEditBlock();
821 | QString selectedText = cursor.selectedText();
822 | QTextCharFormat charFormat = cursor.charFormat();
823 | cursor.removeSelectedText();
824 | cursor.insertList(QTextListFormat::ListDisc);
825 | cursor.insertText(selectedText);
826 | QTextCursor newCursor = documentArea->textCursor();
827 | newCursor.movePosition(QTextCursor::PreviousBlock);
828 | newCursor.mergeCharFormat(charFormat);
829 | cursor.endEditBlock();
830 | }
831 |
832 | void RS_Workspace::numberedList() {
833 | QTextCursor cursor = documentArea->textCursor();
834 | cursor.beginEditBlock();
835 | QString selectedText = cursor.selectedText();
836 | QTextCharFormat charFormat = cursor.charFormat();
837 | cursor.removeSelectedText();
838 | cursor.insertList(QTextListFormat::ListDecimal);
839 | cursor.insertText(selectedText);
840 | QTextCursor newCursor = documentArea->textCursor();
841 | newCursor.movePosition(QTextCursor::PreviousBlock);
842 | newCursor.mergeCharFormat(charFormat);
843 | cursor.endEditBlock();
844 | }
845 |
846 | void RS_Workspace::contentAlign(Qt::Alignment alignment) {
847 | documentArea->setAlignment(alignment);
848 | }
849 |
850 | void RS_Workspace::contentBold() {
851 | QFont font = documentArea->currentFont();
852 | font.setBold(!font.bold());
853 | documentArea->setCurrentFont(font);
854 | }
855 |
856 | void RS_Workspace::contentItalic() {
857 | QFont font = documentArea->currentFont();
858 | font.setItalic(!font.italic());
859 | documentArea->setCurrentFont(font);
860 | }
861 |
862 | void RS_Workspace::contentUnderline() {
863 | QFont font = documentArea->currentFont();
864 | font.setUnderline(!font.underline());
865 | documentArea->setCurrentFont(font);
866 | }
867 |
868 | void RS_Workspace::contentColor() {
869 | QColor color = QColorDialog::getColor();
870 | if (color.isValid()) {
871 | documentArea->setTextColor(color);
872 | }
873 | }
874 |
875 | void RS_Workspace::contentBGColor() {
876 | QColor color = QColorDialog::getColor();
877 | if (color.isValid()) {
878 | documentArea->setTextBackgroundColor(color);
879 | }
880 | }
881 |
882 | void RS_Workspace::contentFont() {
883 | bool ok;
884 | QFont font = QFontDialog::getFont(&ok, documentArea->currentFont(), this);
885 | if (ok) {
886 | documentArea->setCurrentFont(font);
887 | }
888 | }
889 |
890 | void RS_Workspace::incFont() {
891 | QFont font = documentArea->currentFont();
892 | font.setPointSize(font.pointSize() + 1);
893 | documentArea->setCurrentFont(font);
894 | }
895 |
896 | void RS_Workspace::decFont() {
897 | QFont font = documentArea->currentFont();
898 | font.setPointSize(font.pointSize() - 1);
899 | documentArea->setCurrentFont(font);
900 | }
901 |
902 | void RS_Workspace::find() {
903 | QInputDialog *findDialog = new QInputDialog(this);
904 | findDialog->setInputMode(QInputDialog::TextInput);
905 | findDialog->setLabelText("Find");
906 | findDialog->setWindowTitle("Find");
907 | findDialog->setOkButtonText("Find");
908 | findDialog->setCancelButtonText("Cancel");
909 | connect(findDialog, &QInputDialog::textValueSelected, this,
910 | &RS_Workspace::findText);
911 | findDialog->show();
912 | }
913 |
914 | void RS_Workspace::findText(const QString &text) { documentArea->find(text); }
915 |
916 | void RS_Workspace::replace() {
917 | QInputDialog *replaceDialog = new QInputDialog(this);
918 | replaceDialog->setInputMode(QInputDialog::TextInput);
919 | replaceDialog->setLabelText("Replace");
920 | replaceDialog->setWindowTitle("Replace");
921 | replaceDialog->setOkButtonText("Replace");
922 | replaceDialog->setCancelButtonText("Cancel");
923 | connect(replaceDialog, &QInputDialog::textValueSelected, this,
924 | &RS_Workspace::replaceText);
925 | replaceDialog->show();
926 | }
927 |
928 | void RS_Workspace::replaceText(const QString &text) {
929 | QTextCursor cursor = documentArea->textCursor();
930 | cursor.removeSelectedText();
931 | cursor.insertText(text);
932 | }
933 |
934 | void RS_Workspace::initToolbar() {
935 | file_toolbar = addToolBar("File");
936 | toolbarLabel(file_toolbar, "File: ");
937 | file_toolbar->addActions(
938 | {createAction(
939 | "New", "Create a new file", [this]() { newFile(); },
940 | QKeySequence::New),
941 | createAction(
942 | "Open", "Open an existing file", [this]() { openFile(); },
943 | QKeySequence::Open),
944 | createAction(
945 | "Save", "Save the current file", [this]() { saveFile(); },
946 | QKeySequence::Save),
947 | createAction(
948 | "Save As", "Save the file with a new name", [this]() { saveAs(); },
949 | QKeySequence::SaveAs),
950 | createAction(
951 | "Print", "Print the document", [this]() { printDocument(); },
952 | QKeySequence::Print),
953 | createAction(
954 | "Undo", "Undo the last action", [this]() { /* Undo logic */ },
955 | QKeySequence::Undo),
956 | createAction(
957 | "Redo", "Redo the last undone action", [this]() { /* Redo logic */ },
958 | QKeySequence::Redo),
959 | createAction(
960 | "Find", "Find text in the document", [this]() { find(); },
961 | QKeySequence::Find),
962 | createAction(
963 | "Replace", "Replace text in the document", [this]() { replace(); },
964 | QKeySequence::Replace)});
965 |
966 | ui_toolbar = addToolBar("UI");
967 | toolbarLabel(ui_toolbar, "UI: ");
968 | theme_action = createAction(
969 | "Dark/Light Mode", "Toggle Dark/Light theme", [this]() { themeAction(); },
970 | QKeySequence("Ctrl+Shift+T"));
971 | theme_action->setCheckable(true);
972 | // theme_action->setChecked();
973 | ui_toolbar->addAction(theme_action);
974 |
975 | powersaveraction = new QAction("Power Saver", this);
976 | powersaveraction->setStatusTip("Enable or disable power saver mode");
977 | powersaveraction->setCheckable(true);
978 | // powersaveraction->setChecked();
979 | connect(powersaveraction, &QAction::toggled, this,
980 | &RS_Workspace::hybridSaver);
981 | ui_toolbar->addAction(powersaveraction);
982 |
983 | hide_ai_dock = createAction(
984 | "AI", "Show or hide the AI dock", [this]() { toggleDock(); },
985 | QKeySequence("Ctrl+Shift+D"));
986 | ui_toolbar->addAction(hide_ai_dock);
987 |
988 | // ui_toolbar->addAction(
989 | // createAction("Help", "View help", [this]() { viewHelp(); },
990 | // QKeySequence("Ctrl+H")));
991 | // ui_toolbar->addAction(
992 | // createAction("About", "View about", [this]() { viewAbout(); },
993 | // QKeySequence("Ctrl+Shift+I")));
994 |
995 | language_combobox = new QComboBox(this);
996 | for (const auto &language : languages) {
997 | // language_combobox->addItem(language.second, language.first);
998 | }
999 | // language_combobox->currentIndexChanged(this,
1000 | // &RS_Workspace::changeLanguage);
1001 | ui_toolbar->addWidget(language_combobox);
1002 |
1003 | addToolBarBreak();
1004 |
1005 | edit_toolbar = addToolBar("Edit");
1006 | toolbarLabel(edit_toolbar, "Edit: ");
1007 | edit_toolbar->addActions({createAction(
1008 | "Align Left", "Align text to the left",
1009 | [this]() { contentAlign(Qt::AlignLeft); },
1010 | QKeySequence(Qt::CTRL + Qt::Key_L)),
1011 | createAction(
1012 | "Align Center", "Align text to the center",
1013 | [this]() { contentAlign(Qt::AlignCenter); },
1014 | QKeySequence(Qt::CTRL + Qt::Key_C)),
1015 | createAction(
1016 | "Align Right", "Align text to the right",
1017 | [this]() { contentAlign(Qt::AlignRight); },
1018 | QKeySequence(Qt::CTRL + Qt::Key_R)),
1019 | createAction(
1020 | "Justify", "Justify text",
1021 | [this]() { contentAlign(Qt::AlignJustify); },
1022 | QKeySequence(Qt::CTRL + Qt::Key_J))});
1023 |
1024 | addToolBarBreak();
1025 |
1026 | font_toolbar = addToolBar("Font");
1027 | toolbarLabel(font_toolbar, "Font: ");
1028 | font_toolbar->addActions(
1029 | {createAction(
1030 | "Bold", "Make text bold", [this]() { contentBold(); },
1031 | QKeySequence(Qt::CTRL + Qt::Key_B)),
1032 | createAction(
1033 | "Italic", "Make text italic", [this]() { contentItalic(); },
1034 | QKeySequence(Qt::CTRL + Qt::Key_I)),
1035 | createAction(
1036 | "Underline", "Underline text", [this]() { contentUnderline(); },
1037 | QKeySequence(Qt::CTRL + Qt::Key_U))});
1038 |
1039 | addToolBarBreak();
1040 |
1041 | list_toolbar = addToolBar("List");
1042 | toolbarLabel(list_toolbar, "List: ");
1043 | list_toolbar->addActions(
1044 | {createAction(
1045 | "Bullet List", "Insert a bullet list", [this]() { bulletList(); },
1046 | QKeySequence(Qt::CTRL + Qt::Key_B)),
1047 | createAction(
1048 | "Numbered List", "Insert a numbered list",
1049 | [this]() { numberedList(); }, QKeySequence(Qt::CTRL + Qt::Key_B))});
1050 |
1051 | addToolBarBreak();
1052 |
1053 | color_toolbar = addToolBar("Color");
1054 | toolbarLabel(color_toolbar, "Color: ");
1055 | color_toolbar->addActions(
1056 | {createAction(
1057 | "Font Color", "Change font color", [this]() { contentColor(); },
1058 | QKeySequence(Qt::CTRL + Qt::Key_B)),
1059 | createAction(
1060 | "Background Color", "Change background color",
1061 | [this]() { contentBGColor(); }, QKeySequence(Qt::CTRL + Qt::Key_B)),
1062 | createAction(
1063 | "Font Family", "Change font family", [this]() { contentFont(); },
1064 | QKeySequence(Qt::CTRL + Qt::Key_F)),
1065 | createAction(
1066 | "A+", "Increase font size", [this]() { incFont(); },
1067 | QKeySequence(Qt::CTRL + Qt::Key_J)),
1068 | createAction(
1069 | "A-", "Decrease font size", [this]() { decFont(); },
1070 | QKeySequence(Qt::CTRL + Qt::Key_Minus))});
1071 |
1072 | multimedia_toolbar = addToolBar("Multimedia");
1073 | toolbarLabel(multimedia_toolbar, "Multimedia: ");
1074 | multimedia_toolbar->addActions({createAction(
1075 | "Add Image", "Add an image", [this]() { addImage(); },
1076 | QKeySequence(Qt::CTRL + Qt::Key_X))});
1077 | }
1078 |
1079 | void RS_Workspace::toggleDock() {
1080 | if (ai_widget.isHidden()) {
1081 | ai_widget.show();
1082 | } else {
1083 | ai_widget.hide();
1084 | }
1085 | }
1086 |
1087 | void RS_Workspace::hybridSaver(bool checked) {
1088 | QSettings settings("berkaygediz", "SolidWriting");
1089 | FallbackValues fallback;
1090 |
1091 | if (checked) {
1092 | // psutil::sensors_battery battery = psutil::sensors_battery();
1093 | // if (battery.percent <= 35 && !battery.power_plugged) {
1094 | // adaptiveResponse = 12; // Ultra power saver
1095 | // } else {
1096 | // adaptiveResponse = 6; // Standard power saver
1097 | // }
1098 | } else {
1099 | adaptiveResponse = fallback.adaptiveResponse;
1100 | }
1101 |
1102 | settings.setValue("adaptiveResponse", adaptiveResponse);
1103 | settings.sync();
1104 | }
1105 |
1106 | QString RS_Workspace::detectEncoding(const QString &file_path) {
1107 | QFile file(file_path);
1108 | if (!file.open(QIODevice::ReadOnly)) {
1109 | return "utf-8";
1110 | }
1111 |
1112 | QByteArray byteArray = file.readAll();
1113 | QTextStream stream(&file);
1114 | QString text;
1115 |
1116 | stream.autoDetectUnicode();
1117 | text = stream.readAll();
1118 | if (!text.isEmpty()) {
1119 | return "UTF-8";
1120 | }
1121 |
1122 | stream.autoDetectUnicode();
1123 | text = stream.readAll();
1124 | if (!text.isEmpty()) {
1125 | return "ISO-8859-1";
1126 | }
1127 |
1128 | return "UTF-8";
1129 | }
1130 |
1131 | void RS_Workspace::newFile() {
1132 | if (isSaved) {
1133 | documentArea->clear();
1134 | initArea();
1135 | fileName.clear();
1136 | directory = defaultDirectory;
1137 | isSaved = false;
1138 | updateTitle();
1139 | } else {
1140 | QMessageBox::StandardButton reply = QMessageBox::question(
1141 | this, qApp->applicationDisplayName(), "New",
1142 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
1143 |
1144 | if (reply == QMessageBox::Yes) {
1145 | documentArea->clear();
1146 | initArea();
1147 | fileName.clear();
1148 | directory = defaultDirectory;
1149 | isSaved = false;
1150 | updateTitle();
1151 | }
1152 | }
1153 | }
1154 |
1155 | void RS_Workspace::setDocumentDefaultStyle() { initArea(); }
1156 |
1157 | void RS_Workspace::openFile() {
1158 | // QFileDialog::Options options;
1159 | // options |= QFileDialog::ReadOnly;
1160 |
1161 | // QString selected_file = file_to_open.isEmpty()
1162 | // ? QFileDialog::getOpenFileName(this,
1163 | // "Open — "
1164 | // +
1165 | // qApp->applicationDisplayName(),
1166 | // directory,
1167 | // fallback.readFilter,
1168 | // options)
1169 | // : file_to_open;
1170 |
1171 | // if (!selected_file.isEmpty()) {
1172 | // fileName = selected_file;
1173 | // QString encoding = detectEncoding(fileName);
1174 |
1175 | // QFile file((fileName));
1176 | // if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
1177 | // QTextStream in(&file);
1178 | // // in.setCodec(encoding.toUtf8());
1179 |
1180 | // if (fileName.endsWith(".docx")) {
1181 | // // Load DOCX file using a third-party library
1182 | // } else {
1183 | // if (fileName.endsWith(".rsdoc") || fileName.endsWith(".html")
1184 | // || fileName.endsWith(".htm")) {
1185 | // documentArea->setHtml(in.readAll());
1186 | // } else if (fileName.endsWith(".md")) {
1187 | // documentArea->setMarkdown(in.readAll());
1188 | // } else {
1189 | // documentArea->setPlainText(in.readAll());
1190 | // }
1191 | // }
1192 | // }
1193 | // directory = QFileInfo(fileName).absolutePath();
1194 | // isSaved = true;
1195 | // updateTitle();
1196 | // }
1197 | }
1198 |
1199 | void RS_Workspace::saveFile() {
1200 | if (!isSaved) {
1201 | saveProcess();
1202 | } else if (fileName.isEmpty()) {
1203 | saveAs();
1204 | } else {
1205 | saveProcess();
1206 | }
1207 | }
1208 |
1209 | bool RS_Workspace::saveAs() {
1210 | // QFileDialog::Options options;
1211 | // options |= QFileDialog::ReadOnly;
1212 |
1213 | // QString selected_file = QFileDialog::getSaveFileName(this,
1214 | // "Save As — "
1215 | // +
1216 | // qApp->applicationDisplayName(),
1217 | // directory,
1218 | // fallback.writeFilter,
1219 | // options);
1220 |
1221 | // if (!selected_file.isEmpty()) {
1222 | // fileName = selected_file;
1223 | // directory = QFileInfo(fileName).absolutePath();
1224 | // saveProcess();
1225 | // return true;
1226 | // }
1227 | return false;
1228 | }
1229 | void RS_Workspace::saveProcess() {
1230 | if (fileName.isEmpty()) {
1231 | saveAs();
1232 | } else {
1233 | QFile file((fileName));
1234 | if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
1235 | QTextStream out(&file);
1236 | // out.setCodec("UTF-8");
1237 |
1238 | if (fileName.endsWith(".rsdoc") || fileName.endsWith(".html") ||
1239 | fileName.endsWith(".htm")) {
1240 | out << documentArea->toHtml();
1241 | } else if (fileName.endsWith(".md")) {
1242 | out << documentArea->toMarkdown();
1243 | } else {
1244 | out << documentArea->toPlainText();
1245 | }
1246 | }
1247 |
1248 | statusBar()->showMessage("Saved.", 2000);
1249 | isSaved = true;
1250 | updateTitle();
1251 | }
1252 | }
1253 | void RS_Workspace::printDocument() {
1254 | // QPrinter printer;
1255 | // printer.setResolution(QPrinter::HighResolution);
1256 | // printer.setPageOrientation(QPageLayout::Portrait);
1257 | // printer.setPageMargins(QMargins(10, 10, 10, 10), QPageLayout::Millimeter);
1258 | // printer.setFullPage(true);
1259 | // printer.setDocName(fileName);
1260 |
1261 | // QPrintPreviewDialog preview_dialog(&printer, this);
1262 | // connect(&preview_dialog, &QPrintPreviewDialog::paintRequested,
1263 | // documentArea, &QTextEdit::print); preview_dialog.exec();
1264 | }
1265 |
--------------------------------------------------------------------------------