Skip to content

Commit

Permalink
Replace UI
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefvand committed Nov 3, 2024
1 parent 156b25f commit 1573708
Show file tree
Hide file tree
Showing 15 changed files with 937 additions and 395 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 0.0.43

- Implemented:
- Search -> Replace UI


## 0.0.42

- Implemented:
Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ set(TS_FILES translations/Notepad--_en_GB.ts)
set(PROJECT_UI
src/mainwindow.ui
src/indentation/indentationdialog.ui
src/search/searchdialog.ui
src/find/finddialog.ui
src/replace/replacedialog.ui
)

set(PROJECT_SOURCES
Expand Down Expand Up @@ -69,8 +70,10 @@ set(PROJECT_SOURCES
src/indentation/indentationdialog.h
src/indentation/indentationmanager.cpp
src/indentation/indentationmanager.h
src/search/searchdialog.cpp
src/search/searchdialog.h
src/find/finddialog.cpp
src/find/finddialog.h
src/replace/replacedialog.cpp
src/replace/replacedialog.h
${PROJECT_UI}
)

Expand Down
18 changes: 9 additions & 9 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-11-03T01:01:12. -->
<!-- Written by QtCreator 14.0.2, 2024-11-04T00:50:59. -->
<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_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_BUILD_TYPE:STRING=Debug
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}</value>
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</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_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_BUILD_TYPE:STRING=Release
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_GENERATOR:STRING=Ninja
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}</value>
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}</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
1 change: 1 addition & 0 deletions src/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,5 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) {

void CodeEditor::applyIndentation(bool useTabs, int indentationWidth) {
// TODO: Implement indentation
qDebug() << "Indentation. Use Tabs: " << useTabs << ". Indentation width: " << indentationWidth;
}
147 changes: 147 additions & 0 deletions src/find/finddialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#include <QVBoxLayout>
#include "finddialog.h"
#include "ui_finddialog.h"

FindDialog::FindDialog(QWidget* parent)
: QDialog(parent), ui(new Ui::FindDialog) {
ui->setupUi(this);

const int move = 180;
const int reduceHeight = 170;

// Adjust the vertical positions of the buttons to move them up
ui->findNext->move(ui->findNext->x(), ui->findNext->y() - move);
ui->findPrevious->move(ui->findPrevious->x(), ui->findPrevious->y() - move);
ui->selectAll->move(ui->selectAll->x(), ui->selectAll->y() - move);

// Initially hide the advanced options and decrease the form and tabWidget height
ui->groupBoxAdvanced->hide();
resize(width(), height() - reduceHeight);

// Connect advancedOptions checkbox to toggle advanced options visibility
connect(ui->advancedOptions, &QCheckBox::toggled, this, &FindDialog::toggleAdvancedOptions);
}

FindDialog::~FindDialog()
{
delete ui;
}

QString FindDialog::getFindText() const {
return ui->findLineEdit->currentText();
}

bool FindDialog::isMatchCaseChecked() const {
return ui->matchCase->isChecked();
}

bool FindDialog::isWholeWordsChecked() const {
return ui->matchWholeWord->isChecked();
}

void FindDialog::showDialog(QWidget *parent) {
FindDialog dialog(parent);
dialog.setModal(true);
dialog.exec();
}

void FindDialog::on_findNext_clicked() {
handleFindRequest(ui->findLineEdit->currentText(),
ui->matchCase->isChecked(),
ui->matchWholeWord->isChecked(),
selectedFindMode()); // Get current find mode
}

void FindDialog::on_advancedOptions_checkStateChanged(const Qt::CheckState &arg1)
{
qDebug() << "on_advancedOptions_checkStateChanged";
}

void FindDialog::on_findPrevious_clicked() {
handleFindRequest(ui->findLineEdit->currentText(),
ui->matchCase->isChecked(),
ui->matchWholeWord->isChecked(),
selectedFindMode()); // Get current find mode
}

void FindDialog::on_selectAll_clicked()
{
qDebug() << "on_selectAll_clicked";
}

void FindDialog::performFind() {
FindMode mode = selectedFindMode();

switch (mode) {
case PlainText:
qDebug() << "Performing Plain Text find";
// Implement plain text find logic here
break;
case RegularExpression:
qDebug() << "Performing Regular Expression find";
// Implement regex find logic here
break;
case SpecialCharacters:
qDebug() << "Performing Special Characters find";
// Implement special character find logic here
break;
}
}

FindDialog::FindMode FindDialog::selectedFindMode() const {
if (ui->findPlainText->isChecked()) {
return PlainText;
} else if (ui->findRegularExpression->isChecked()) {
return RegularExpression;
} else if (ui->findSpecialCharachters->isChecked()) {
return SpecialCharacters;
}
return PlainText; // Default fallback
}

void FindDialog::handleFindRequest(const QString& findText, bool matchCase, bool matchWholeWord, FindMode mode) {
switch (mode) {
case PlainText:
qDebug() << "Performing Plain Text find for:" << findText;
break;
case RegularExpression:
qDebug() << "Performing Regular Expression find for:" << findText;
break;
case SpecialCharacters:
qDebug() << "Performing Special Characters find for:" << findText;
break;
}
// Implement your actual find logic here
}

void FindDialog::onAdvancedOptionsToggled(bool checked) {
ui->groupBoxAdvanced->setVisible(checked);
}

void FindDialog::toggleAdvancedOptions(bool checked) {
const int move = 180;
const int increaseHeight = 170;

if (checked) {
// Move buttons down, resize form and tabWidget, and show advanced options
ui->findNext->move(ui->findNext->x(), ui->findNext->y() + move);
ui->findPrevious->move(ui->findPrevious->x(), ui->findPrevious->y() + move);
ui->selectAll->move(ui->selectAll->x(), ui->selectAll->y() + move);

resize(width(), height() + increaseHeight);

ui->groupBoxAdvanced->show();
} else {
// Return to compact layout with buttons moved up and form resized
ui->findNext->move(ui->findNext->x(), ui->findNext->y() - move);
ui->findPrevious->move(ui->findPrevious->x(), ui->findPrevious->y() - move);
ui->selectAll->move(ui->selectAll->x(), ui->selectAll->y() - move);

resize(width(), height() - increaseHeight);

ui->groupBoxAdvanced->hide();
}
}



22 changes: 11 additions & 11 deletions src/search/searchdialog.h → src/find/finddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
#include <QDialog>

namespace Ui {
class SearchDialog;
class FindDialog;
}

class SearchDialog : public QDialog
class FindDialog : public QDialog
{
Q_OBJECT

public:
explicit SearchDialog(QWidget *parent = nullptr);
~SearchDialog();
explicit FindDialog(QWidget *parent = nullptr);
~FindDialog();

enum SearchMode {
enum FindMode {
PlainText,
RegularExpression,
SpecialCharacters
};

void performSearch();
void performFind();
static void showDialog(QWidget *parent = nullptr);
QString getSearchText() const;
QString getFindText() const;
bool isMatchCaseChecked() const;
bool isWholeWordsChecked() const;

signals:
void searchRequested(const QString& searchText, bool matchCase, bool matchWholeWord, SearchDialog::SearchMode mode);
void findRequested(const QString& findText, bool matchCase, bool matchWholeWord, FindDialog::FindMode mode);

private slots:
void on_advancedOptions_checkStateChanged(const Qt::CheckState &arg1);
Expand All @@ -38,14 +38,14 @@ private slots:

void on_selectAll_clicked();

void handleSearchRequest(const QString& searchText, bool matchCase, bool matchWholeWord, SearchMode mode);
void handleFindRequest(const QString& findText, bool matchCase, bool matchWholeWord, FindMode mode);

void onAdvancedOptionsToggled(bool checked);

void toggleAdvancedOptions(bool checked);

private:
Ui::SearchDialog *ui;
SearchMode selectedSearchMode() const;
Ui::FindDialog *ui;
FindMode selectedFindMode() const;
};

Loading

0 comments on commit 1573708

Please sign in to comment.