-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d6108e
commit 5c244b7
Showing
26 changed files
with
850 additions
and
1,095 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include <QSettings> | ||
#include "indentationdialog.h" | ||
#include "ui_indentationdialog.h" | ||
#include "../settings.h" | ||
#include "../document.h" | ||
#include "../codeeditor.h" | ||
#include "../mainwindow/helpers.h" | ||
|
||
IndentationDialog::IndentationDialog(QWidget *parent) | ||
: QDialog(parent), ui(new Ui::IndentationDialog) | ||
{ | ||
ui->setupUi(this); | ||
|
||
loadSettings(); | ||
|
||
connect(ui->tabs, &QRadioButton::clicked, this, &IndentationDialog::onIndentationSelected); | ||
connect(ui->spaces, &QRadioButton::clicked, this, &IndentationDialog::onIndentationSelected); | ||
|
||
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &IndentationDialog::onOkClicked); | ||
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &IndentationDialog::reject); | ||
} | ||
|
||
IndentationDialog::~IndentationDialog() | ||
{ | ||
delete ui; | ||
} | ||
|
||
bool IndentationDialog::isTabsSelected() const { | ||
return ui->tabs->isChecked(); | ||
} | ||
|
||
int IndentationDialog::getIndentationValue() const { | ||
return ui->number->value(); | ||
} | ||
|
||
void IndentationDialog::onIndentationSelected() { | ||
// Your logic when the indentation is selected | ||
qDebug() << "Indentation option selected."; | ||
} | ||
|
||
void IndentationDialog::loadSettings() { | ||
QSettings settings("Remisa", "Notepad--"); | ||
settings.beginGroup("IndentationSettings"); | ||
QString value = settings.value("indentationOption", "Tabs").toString(); // Default to tabs if no value found | ||
int indentationSize = settings.value("indentationSize", 1).toInt(); // Default to 1 if no value found | ||
settings.endGroup(); | ||
|
||
ui->tabs->setChecked(value == "Tabs"); | ||
ui->spaces->setChecked(value == "Spaces"); | ||
ui->number->setValue(indentationSize); | ||
} | ||
|
||
void IndentationDialog::saveSettings() { | ||
QSettings settings("Remisa", "Notepad--"); // Adjust organization and application name | ||
settings.beginGroup("IndentationSettings"); | ||
settings.setValue("indentationOption", ui->tabs->isChecked() ? "Tabs" : "Spaces"); | ||
settings.setValue("indentationSize", ui->number->value()); | ||
settings.endGroup(); | ||
} | ||
|
||
void IndentationDialog::onOkClicked() { | ||
saveSettings(); // Save settings when OK is clicked | ||
accept(); | ||
} | ||
|
||
void IndentationDialog::setTabsChecked(bool checked) { | ||
ui->tabs->setChecked(checked); | ||
} | ||
|
||
bool IndentationDialog::isTabsChecked() const { | ||
return ui->tabs->isChecked(); | ||
} | ||
|
||
void IndentationDialog::on_buttonBox_accepted() | ||
{ | ||
bool useTabs = ui->tabs->isChecked(); | ||
int indentationWidth = ui->number->value(); | ||
|
||
auto* settings = Settings::instance(); | ||
settings->setValue("IndentationSettings/indentationOption", useTabs ? "Tabs" : "Spaces"); | ||
settings->setValue("IndentationSettings/indentationSize", indentationWidth); | ||
|
||
Document* doc = qobject_cast<Document*>(parent()); | ||
if (doc && doc->editor()) { | ||
doc->editor()->applyIndentation(useTabs, indentationWidth); | ||
} | ||
Helpers::notImplemented(this); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#pragma once | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class IndentationDialog; | ||
} | ||
|
||
class IndentationDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit IndentationDialog(QWidget *parent = nullptr); | ||
~IndentationDialog(); | ||
|
||
bool isTabsSelected() const; | ||
int getIndentationValue() const; | ||
void setTabsChecked(bool checked); | ||
bool isTabsChecked() const; | ||
|
||
private slots: | ||
void onIndentationSelected(); | ||
|
||
void on_buttonBox_accepted(); | ||
|
||
private: | ||
Ui::IndentationDialog *ui; | ||
void loadSettings(); | ||
void saveSettings(); | ||
void onOkClicked(); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>IndentationDialog</class> | ||
<widget class="QDialog" name="IndentationDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>364</width> | ||
<height>119</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>4</x> | ||
<y>70</y> | ||
<width>341</width> | ||
<height>41</height> | ||
</rect> | ||
</property> | ||
<property name="orientation"> | ||
<enum>Qt::Orientation::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set> | ||
</property> | ||
</widget> | ||
<widget class="QSpinBox" name="number"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>184</x> | ||
<y>40</y> | ||
<width>161</width> | ||
<height>26</height> | ||
</rect> | ||
</property> | ||
<property name="value"> | ||
<number>1</number> | ||
</property> | ||
</widget> | ||
<widget class="QRadioButton" name="spaces"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>98</x> | ||
<y>11</y> | ||
<width>71</width> | ||
<height>20</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string>Spaces</string> | ||
</property> | ||
</widget> | ||
<widget class="QRadioButton" name="tabs"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>30</x> | ||
<y>9</y> | ||
<width>51</width> | ||
<height>23</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string>Tabs</string> | ||
</property> | ||
<property name="checked"> | ||
<bool>true</bool> | ||
</property> | ||
</widget> | ||
<widget class="QLabel" name="label"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>32</x> | ||
<y>43</y> | ||
<width>121</width> | ||
<height>17</height> | ||
</rect> | ||
</property> | ||
<property name="text"> | ||
<string><html><head/><body><p><span style=" font-weight:700;">Indentation Width:</span></p></body></html></string> | ||
</property> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>IndentationDialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>IndentationDialog</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
Oops, something went wrong.