Skip to content

Commit

Permalink
v0.0.67
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefvand committed Dec 5, 2024
1 parent ac907a9 commit cab5816
Show file tree
Hide file tree
Showing 8 changed files with 183 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

============

## 0.0.67

- Implemented:
- View Menu -> Move to a New View

## 0.0.66

- Implemented:
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ set(PROJECT_SOURCES
src/aboutdialog.h
src/view/movetootherview.cpp
src/view/movetootherview.h
src/view/movetonewview.cpp
src/view/movetonewview.h
${PROJECT_UI}
)

Expand Down
26 changes: 13 additions & 13 deletions CMakeLists.txt.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 14.0.2, 2024-12-04T22:09:47. -->
<!-- Written by QtCreator 14.0.2, 2024-12-05T12:06:40. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -102,14 +102,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Debug
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}</value>
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="CMake.Source.Directory">/data/Code/Qt/Notepad--</value>
<value type="int" key="EnableQmlDebugging">0</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/data/Code/Qt/Notepad--/build/Desktop-Debug</value>
Expand Down Expand Up @@ -160,14 +160,14 @@
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Release
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}</value>
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DCMAKE_GENERATOR:STRING=Ninja</value>
<value type="QString" key="CMake.Source.Directory">/data/Code/Qt/Notepad--</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/data/Code/Qt/Notepad--/build/Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
Expand Down
42 changes: 33 additions & 9 deletions src/aboutdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>222</width>
<height>198</height>
<height>241</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -52,9 +52,9 @@
<widget class="QLabel" name="label_3">
<property name="geometry">
<rect>
<x>16</x>
<y>90</y>
<width>191</width>
<x>30</x>
<y>140</y>
<width>171</width>
<height>31</height>
</rect>
</property>
Expand All @@ -64,14 +64,14 @@
</font>
</property>
<property name="text">
<string>By: Remisa Yousefvand</string>
<string>- Remisa Yousefvand</string>
</property>
</widget>
<widget class="QPushButton" name="closeButton">
<property name="geometry">
<rect>
<x>70</x>
<y>160</y>
<y>200</y>
<width>80</width>
<height>25</height>
</rect>
Expand All @@ -83,8 +83,8 @@
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>14</x>
<y>123</y>
<x>16</x>
<y>83</y>
<width>191</width>
<height>31</height>
</rect>
Expand All @@ -95,7 +95,31 @@
</font>
</property>
<property name="text">
<string>https://github.com/yousefvand</string>
<string>&lt;a href=&quot;https://github.com/yousefvand&quot;&gt;https://github.com/yousefvand&lt;/a&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextInteractionFlag::TextBrowserInteraction</set>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>20</x>
<y>110</y>
<width>111</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Contributors:</string>
</property>
</widget>
</widget>
Expand Down
30 changes: 30 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "systemfind/systemfinddialog.h"
#include "systemreplace/systemreplacedialog.h"
#include "view/movetootherview.h"
#include "view/movetonewview.h"
#include "aboutdialog.h"

MainWindow::MainWindow(QWidget* parent)
Expand Down Expand Up @@ -77,6 +78,7 @@ MainWindow::~MainWindow() {
delete m_systemReplaceDialog;
delete m_mainWindowConfigLoader;
delete m_moveToOtherView;
delete m_moveToNewView;
}

Ui::MainWindow* MainWindow::getUi() const {
Expand Down Expand Up @@ -619,6 +621,34 @@ void MainWindow::on_action_Move_to_Other_View_triggered()
}
}

void MainWindow::on_actionMove_to_a_New_View_triggered()
{
if (!ui->documentsTab) {
qDebug() << "documentsTab is null!";
return;
}

if (m_moveToNewView) {
m_moveToNewView->execute();
} else {
MoveToNewView* m_moveToNewView = new MoveToNewView(ui->documentsTab, this);
m_moveToNewView->execute();
}
}

















Expand Down
4 changes: 4 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "systemreplace/systemreplacedialog.h"
#include "systemsearchresultdialog.h"
#include "view/movetootherview.h"
#include "view/movetonewview.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
Expand Down Expand Up @@ -171,6 +172,8 @@ private slots:

void on_action_Move_to_Other_View_triggered();

void on_actionMove_to_a_New_View_triggered();

private:
Ui::MainWindow* ui;
FileOperations* fileOperations;
Expand Down Expand Up @@ -202,4 +205,5 @@ private slots:
Find* m_find = nullptr;
MainWindowConfigLoader* m_mainWindowConfigLoader;
MoveToOtherView* m_moveToOtherView = nullptr;
MoveToNewView* m_moveToNewView = nullptr;
};
76 changes: 76 additions & 0 deletions src/view/movetonewview.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#include <QHBoxLayout>
#include <QTabWidget>
#include <QDebug>
#include "../codeeditor.h"
#include "movetonewview.h"
#include "../document.h"

MoveToNewView::MoveToNewView(QTabWidget *tabWidget, QWidget *parent)
: QWidget(parent), m_tabWidget(tabWidget) {}

void MoveToNewView::execute() {
// Get the index of the current tab
int currentIndex = m_tabWidget->currentIndex();
if (currentIndex < 0) {
qDebug() << "No active tab found in the documentsTab.";
return;
}

// Get the current tab widget
QWidget* currentWidget = m_tabWidget->widget(currentIndex);
if (!currentWidget) {
qDebug() << "No widget found in the current tab.";
return;
}

qDebug() << "Current widget type:" << currentWidget->metaObject()->className();

// Locate the editor in the current widget (Document)
QString currentContent;
if (Document* currentDocument = qobject_cast<Document*>(currentWidget)) {
// Assuming CodeEditor is a child of Document
if (CodeEditor* editor = currentDocument->findChild<CodeEditor*>()) {
currentContent = editor->toPlainText();
qDebug() << "Content retrieved from CodeEditor:" << currentContent;
} else {
qDebug() << "The Document does not contain a CodeEditor.";
}
} else if (QTextEdit* editor = qobject_cast<QTextEdit*>(currentWidget)) {
currentContent = editor->toPlainText();
qDebug() << "Content retrieved directly from QTextEdit tab:" << currentContent;
} else {
qDebug() << "Current tab does not contain a known editor type.";
}

// Shift all tabs on the right of the current tab by one
int tabCount = m_tabWidget->count();
for (int i = tabCount - 1; i > currentIndex; --i) {
QWidget* tab = m_tabWidget->widget(i);
QString tabText = m_tabWidget->tabText(i);
QIcon tabIcon = m_tabWidget->tabIcon(i);

m_tabWidget->removeTab(i);
m_tabWidget->insertTab(i + 1, tab, tabIcon, tabText);
}

// Create a new tab
Document* newDocument = new Document("", m_tabWidget); // Assuming Document is your tab widget class
if (!currentContent.isEmpty()) {
if (CodeEditor* newEditor = newDocument->findChild<CodeEditor*>()) {
newEditor->setPlainText(currentContent);
qDebug() << "Content set for the new tab.";
} else {
qDebug() << "No editor found in the new Document to set content.";
}
} else {
qDebug() << "No content to set for the new tab.";
}

// Insert the new tab
m_tabWidget->insertTab(currentIndex + 1, newDocument, QIcon(), "New View");

// Set focus to the new tab
m_tabWidget->setCurrentIndex(currentIndex + 1);

qDebug() << "Shifted tabs, created a new tab, and set its content at index:" << currentIndex + 1;
}
20 changes: 20 additions & 0 deletions src/view/movetonewview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include <QWidget>
#include <QTextEdit>
#include <QTabWidget>
#include <QHBoxLayout>
#include <QString>

class MoveToNewView : public QWidget {
Q_OBJECT

public:
explicit MoveToNewView(QTabWidget *tabWidget, QWidget *parent = nullptr);

void execute();

private:
QTabWidget *m_tabWidget;
};

0 comments on commit cab5816

Please sign in to comment.