From aa80b74719d0fc954b3ab6c5535a2419b4198d8e Mon Sep 17 00:00:00 2001 From: Remisa Yousefvand Date: Sun, 15 Dec 2024 00:02:44 +0330 Subject: [PATCH] v0.0.70 --- CHANGELOG.md | 5 + CMakeLists.txt | 2 + CMakeLists.txt.user | 189 ++++++++-- CMakeLists.txt.user.5653f27 | 425 ---------------------- src/codeeditor.cpp | 6 + src/codeeditor.h | 2 + src/mainwindow.cpp | 55 ++- src/mainwindow.h | 7 + src/mainwindow/mainwindowconfigloader.cpp | 5 + src/mainwindow/mainwindowconfigloader.h | 1 + src/view/toggletoformertab.cpp | 36 ++ src/view/toggletoformertab.h | 18 + 12 files changed, 302 insertions(+), 449 deletions(-) mode change 100755 => 100644 CMakeLists.txt.user delete mode 100755 CMakeLists.txt.user.5653f27 create mode 100644 src/view/toggletoformertab.cpp create mode 100644 src/view/toggletoformertab.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 574895a..8eb6494 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ============ +## 0.0.70 + +- Implemented: +- View Menu -> Toggle to Former Tab + ## 0.0.69 - Implemented: diff --git a/CMakeLists.txt b/CMakeLists.txt index c34f227..25d1632 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,6 +115,8 @@ set(PROJECT_SOURCES src/view/openinnewwindow.h src/view/wordwrap.cpp src/view/wordwrap.h + src/view/toggletoformertab.cpp + src/view/toggletoformertab.h ${PROJECT_UI} ) diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user old mode 100755 new mode 100644 index 605e694..47fd021 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,10 +1,10 @@ - + EnvironmentId - {6434b5f3-d750-40e0-8f85-3dc95dcd510d} + {8d9160d8-ad41-44aa-87e4-cafeb5abba83} ProjectExplorer.Project.ActiveTarget @@ -33,6 +33,7 @@ false 4 false + 0 80 true true @@ -91,9 +92,9 @@ ProjectExplorer.Project.Target.0 Desktop - Qt 6.7.2 (System) - Qt 6.7.2 (System) - {5fcd4be8-31fb-480b-a925-a47ce5b3bbaf} + Desktop Qt 6.8.1 + Desktop Qt 6.8.1 + qt.qt6.681.linux_gcc_64_kit 0 0 0 @@ -102,17 +103,16 @@ 2 false - -DCMAKE_BUILD_TYPE:STRING=Debug --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_GENERATOR:STRING=Ninja + -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake - /data/Code/Qt/Notepad-- +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_GENERATOR:STRING=Ninja 0 - /data/Code/Qt/Notepad--/build/Desktop-Debug + /data/Code/Qt/Notepad--/build/Desktop_Qt_6_8_1-Debug @@ -160,16 +160,15 @@ 2 false - -DCMAKE_BUILD_TYPE:STRING=Release --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_GENERATOR:STRING=Ninja + -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake - /data/Code/Qt/Notepad-- - /data/Code/Qt/Notepad--/build/Desktop-Release +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_GENERATOR:STRING=Ninja + /data/Code/Qt/Notepad--/build/Desktop_Qt_6_8_1-Release @@ -212,7 +211,117 @@ Release CMakeProjectManager.CMakeBuildConfiguration - 2 + + MinSizeRel + 2 + false + + -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_BUILD_TYPE:STRING=MinSizeRel +-DCMAKE_GENERATOR:STRING=Ninja + /data/Code/Qt/Notepad--/build/Desktop_Qt_6_8_1-MinSizeRel + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + + Debug + 2 + false + + -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} +-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_GENERATOR:STRING=Ninja + /data/Code/Qt/Notepad-- + 0 + /data/Code/Qt/Notepad--/build/Desktop_Qt_6_8_1-Debug + + + + + all + + false + + true + CMakeProjectManager.MakeStep + + 1 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + + + clean + + false + + true + CMakeProjectManager.MakeStep + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug2 + CMakeProjectManager.CMakeBuildConfiguration + + 4 0 @@ -225,7 +334,41 @@ false ProjectExplorer.DefaultDeployConfiguration - 1 + + + + + + + + false + + true + ApplicationManagerPlugin.Deploy.CMakePackageStep + + + install-package --acknowledge + true + Install Application Manager package + ApplicationManagerPlugin.Deploy.InstallPackageStep + + + + + + + + 2 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ApplicationManagerPlugin.Deploy.Configuration + + 2 true true @@ -237,13 +380,13 @@ false -e cpu-cycles --call-graph dwarf,4096 -F 250 Notepad-- - CMakeProjectManager.CMakeRunConfiguration.Notepad-- + CMakeProjectManager.CMakeRunConfiguration. Notepad-- false true true true - /data/Code/Qt/Notepad--/build/Desktop-Debug + /data/Code/Qt/Notepad--/build/Desktop_Qt_6_8_1-Debug 1 diff --git a/CMakeLists.txt.user.5653f27 b/CMakeLists.txt.user.5653f27 deleted file mode 100755 index 840d1e9..0000000 --- a/CMakeLists.txt.user.5653f27 +++ /dev/null @@ -1,425 +0,0 @@ - - - - - - EnvironmentId - {5653f278-85a7-4a35-96ca-764f2841b801} - - - ProjectExplorer.Project.ActiveTarget - 0 - - - ProjectExplorer.Project.EditorSettings - - true - false - true - - Cpp - - CppGlobal - - - - QmlJS - - QmlJSGlobal - - - 2 - UTF-8 - false - 4 - false - 80 - true - true - 1 - 0 - false - true - false - 2 - true - true - 0 - 8 - true - false - 1 - true - true - true - *.md, *.MD, Makefile - false - true - true - - - - ProjectExplorer.Project.PluginSettings - - - true - false - true - true - true - true - - false - - - 0 - true - - true - true - Builtin.DefaultTidyAndClazy - 2 - true - - - - true - - - - - - ProjectExplorer.Project.Target.0 - - Desktop - Desktop - Desktop - {60984d1e-a0c6-4740-aaac-7975ffd27e09} - 0 - 0 - 0 - - Debug - 2 - false - - -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_BUILD_TYPE:STRING=Debug - 0 - /data/Code/Qt/Notepad--/build/Desktop-Debug - - - - - all - - false - - true - Build - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - Build - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Debug - CMakeProjectManager.CMakeBuildConfiguration - - - Release - 2 - false - - -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_BUILD_TYPE:STRING=Release - /data/Code/Qt/Notepad--/build/Desktop-Release - - - - - all - - false - - true - Build - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - Build - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release - CMakeProjectManager.CMakeBuildConfiguration - - - RelWithDebInfo - 2 - false - - -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo - /data/Code/Qt/Notepad--/build/Desktop-RelWithDebInfo - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Release with Debug Information - CMakeProjectManager.CMakeBuildConfiguration - - - RelWithDebInfo - 2 - false - - -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo - 0 - /data/Code/Qt/Notepad--/build/Desktop-Profile - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Profile - CMakeProjectManager.CMakeBuildConfiguration - - - MinSizeRel - 2 - false - - -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} --DCMAKE_GENERATOR:STRING=Ninja --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} --DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DCMAKE_BUILD_TYPE:STRING=MinSizeRel - /data/Code/Qt/Notepad--/build/Desktop-MinSizeRel - - - - - all - - false - - true - CMakeProjectManager.MakeStep - - 1 - Build - Build - ProjectExplorer.BuildSteps.Build - - - - - - clean - - false - - true - CMakeProjectManager.MakeStep - - 1 - Clean - Clean - ProjectExplorer.BuildSteps.Clean - - 2 - false - - false - - Minimum Size Release - CMakeProjectManager.CMakeBuildConfiguration - - 5 - - - 0 - Deploy - Deploy - ProjectExplorer.BuildSteps.Deploy - - 1 - - false - ProjectExplorer.DefaultDeployConfiguration - - 1 - - true - true - 0 - true - - 2 - - false - -e cpu-cycles --call-graph dwarf,4096 -F 250 - Notepad-- - CMakeProjectManager.CMakeRunConfiguration.Notepad-- - Notepad-- - false - true - true - true - /data/Code/Qt/Notepad--/build/Desktop-Debug - - 1 - - - - ProjectExplorer.Project.TargetCount - 1 - - - ProjectExplorer.Project.Updater.FileVersion - 22 - - - Version - 22 - - diff --git a/src/codeeditor.cpp b/src/codeeditor.cpp index 3d229c1..59e3f74 100755 --- a/src/codeeditor.cpp +++ b/src/codeeditor.cpp @@ -37,6 +37,7 @@ CodeEditor::CodeEditor(QWidget *parent) m_showIndentGuide = Settings::instance()->loadSetting("View", "ShowIndentGuide", "false") == "true"; m_showWrapSymbol = Settings::instance()->loadSetting("View", "ShowWrapSymbol", "false") == "true"; m_tabWidth = Settings::instance()->loadSetting("View", "TabWidth", "4").toInt(); + m_showMathRendering = Settings::instance()->loadSetting("View", "MathRendering", "false") == "true"; if (m_showAllCharacters) { m_showTabs = true; @@ -318,6 +319,11 @@ void CodeEditor::setTabWidth(int width = 4) { viewport()->update(); // Trigger a repaint to apply the new width } +void CodeEditor::setShowMathRendering(bool enabled) { + Q_UNUSED(enabled); + // TODO: Implement +} + void CodeEditor::paintTabs(QPainter& painter, const QTextBlock& block, int top) { QTextLayout* layout = block.layout(); if (!layout) return; diff --git a/src/codeeditor.h b/src/codeeditor.h index a9cafa8..afe3d84 100755 --- a/src/codeeditor.h +++ b/src/codeeditor.h @@ -34,6 +34,7 @@ class CodeEditor : public QPlainTextEdit { void zoomIn(); void zoomOut(); void defaultZoom(); + void setShowMathRendering(bool enabled); protected: void resizeEvent(QResizeEvent *event) override; @@ -59,6 +60,7 @@ private slots: bool m_showIndentGuide = false; bool m_showWrapSymbol = false; int m_tabWidth; + bool m_showMathRendering = false; void paintTabs(QPainter& painter, const QTextBlock& block, int top); void paintSpaces(QPainter& painter, const QTextBlock& block, int top); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0b18d10..6f2ec39 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -25,13 +25,16 @@ #include "view/openinnewwindow.h" #include "view/wordwrap.h" #include "aboutdialog.h" +#include "view/toggletoformertab.h" MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWindow), indentationManager(new IndentationManager(this)), findDialog(new FindDialog(this)), - replaceDialog(new ReplaceDialog(this)) + replaceDialog(new ReplaceDialog(this)), + m_currentTabIndex(-1), + m_formerTabIndex(-1) { ui->setupUi(this); // Ensure the UI is set up before using it @@ -66,6 +69,11 @@ MainWindow::MainWindow(QWidget* parent) m_mainWindowConfigLoader = new MainWindowConfigLoader(this); m_mainWindowConfigLoader->loadMainWindowConfig(); + connect(ui->documentsTab, &QTabWidget::currentChanged, this, &MainWindow::onTabChanged); + if (ui->documentsTab->count() > 0) { + m_currentTabIndex = ui->documentsTab->currentIndex(); + } + qDebug() << "MainWindow initialized..."; } @@ -682,6 +690,51 @@ void MainWindow::toggleWordWrap() { } } +void MainWindow::onTabChanged(int currentIndex) +{ + // Skip updates if the change was triggered by toggling + if (currentIndex == m_formerTabIndex) { + return; // Do nothing; indices are already updated in the toggle logic + } + + // Update former and current tab indices + m_formerTabIndex = m_currentTabIndex; + m_currentTabIndex = currentIndex; +} + +void MainWindow::on_actionMath_Rendering_triggered(bool checked) +{ + Helpers::notImplemented(this); + Settings::instance()->saveSetting("View", "MathRendering", checked); + + for (int i = 0; i < ui->documentsTab->count(); ++i) { + Document *doc = qobject_cast(ui->documentsTab->widget(i)); + if (doc) { + doc->editor()->setShowMathRendering(checked); + } + } +} + +void MainWindow::on_actionToggle_to_Former_Tab_triggered() +{ + // Ensure a valid former tab exists + if (m_formerTabIndex != -1) { + // Temporarily disconnect the currentChanged signal to avoid overwriting indices + disconnect(ui->documentsTab, &QTabWidget::currentChanged, this, &MainWindow::onTabChanged); + + // Swap the tabs + ui->documentsTab->setCurrentIndex(m_formerTabIndex); + + // Update indices after the toggle + std::swap(m_currentTabIndex, m_formerTabIndex); + + // Reconnect the currentChanged signal + connect(ui->documentsTab, &QTabWidget::currentChanged, this, &MainWindow::onTabChanged); + } +} + + + diff --git a/src/mainwindow.h b/src/mainwindow.h index 1c1b4af..4e9b748 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -56,6 +56,7 @@ private slots: void on_action_Save_triggered(); void onActionZ80Triggered(); void toggleWordWrap(); + void onTabChanged(int currentIndex); void on_actionOpen_Folder_triggered(); @@ -181,6 +182,10 @@ private slots: void on_action_Word_wrap_triggered(); + void on_actionToggle_to_Former_Tab_triggered(); + + void on_actionMath_Rendering_triggered(bool checked); + private: Ui::MainWindow* ui; FileOperations* fileOperations; @@ -215,4 +220,6 @@ private slots: MoveToNewView* m_moveToNewView = nullptr; OpenInNewWindow* m_openInNewWindow = nullptr; WordWrap* m_wordWrap = nullptr; + int m_currentTabIndex; + int m_formerTabIndex; }; diff --git a/src/mainwindow/mainwindowconfigloader.cpp b/src/mainwindow/mainwindowconfigloader.cpp index 712000f..cf11765 100644 --- a/src/mainwindow/mainwindowconfigloader.cpp +++ b/src/mainwindow/mainwindowconfigloader.cpp @@ -14,6 +14,7 @@ void MainWindowConfigLoader::loadMainWindowConfig() { m_mainWindow->getUi()->actionShow_Indent_Guide->setChecked(showIndentGuide()); m_mainWindow->getUi()->actionShow_Wrap_Symbol->setChecked(showWrapSymbol()); m_mainWindow->getUi()->action_Word_wrap->setChecked(wordWrap()); + m_mainWindow->getUi()->actionMath_Rendering->setChecked(mathRendering()); } } @@ -45,6 +46,10 @@ bool MainWindowConfigLoader::wordWrap() const { return Settings::instance()->loadSetting("View", "WordWrap", "false") == true; } +bool MainWindowConfigLoader::mathRendering() const { + return Settings::instance()->loadSetting("View", "MathRendering", "false") == true; +} + diff --git a/src/mainwindow/mainwindowconfigloader.h b/src/mainwindow/mainwindowconfigloader.h index 60c8eef..36c21a2 100644 --- a/src/mainwindow/mainwindowconfigloader.h +++ b/src/mainwindow/mainwindowconfigloader.h @@ -18,5 +18,6 @@ class MainWindowConfigLoader bool showIndentGuide() const; bool showWrapSymbol() const; bool wordWrap() const; + bool mathRendering() const; }; diff --git a/src/view/toggletoformertab.cpp b/src/view/toggletoformertab.cpp new file mode 100644 index 0000000..313a9a6 --- /dev/null +++ b/src/view/toggletoformertab.cpp @@ -0,0 +1,36 @@ +#include "toggletoformertab.h" + +ToggleToFormerTab::ToggleToFormerTab(QTabWidget* tabWidget) + : m_tabWidget(tabWidget), + m_currentTabIndex(-1), + m_formerTabIndex(-1), + m_isToggleToFormerTabActive(false) { + if (m_tabWidget && m_tabWidget->count() > 0) { + m_currentTabIndex = m_tabWidget->currentIndex(); + } +} + +void ToggleToFormerTab::updateTabIndex(int currentIndex) { + if (currentIndex == m_currentTabIndex) + return; + + m_formerTabIndex = m_currentTabIndex; + m_currentTabIndex = currentIndex; +} + +void ToggleToFormerTab::setToggleActive(bool active) { + m_isToggleToFormerTabActive = active; + if (m_isToggleToFormerTabActive) { + toggle(); + } +} + +void ToggleToFormerTab::toggle() { + if (!m_tabWidget || m_formerTabIndex == -1) { + return; // No former tab to toggle to + } + + // Swap current and former indices and activate the former tab + std::swap(m_currentTabIndex, m_formerTabIndex); + m_tabWidget->setCurrentIndex(m_currentTabIndex); +} diff --git a/src/view/toggletoformertab.h b/src/view/toggletoformertab.h new file mode 100644 index 0000000..95f9d9b --- /dev/null +++ b/src/view/toggletoformertab.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +class ToggleToFormerTab { +public: + explicit ToggleToFormerTab(QTabWidget* tabWidget); + + void toggle(); // Perform the toggle operation + void updateTabIndex(int currentIndex); // Update tab indices + void setToggleActive(bool active); // Set toggle state + +private: + QTabWidget* m_tabWidget; + int m_currentTabIndex; + int m_formerTabIndex; + bool m_isToggleToFormerTabActive; // Toggle active state +};