Skip to content

Commit

Permalink
Fixed some bugs in Indent Options
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushGupta69 committed Sep 18, 2023
1 parent 2c1356e commit 47fa25c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
13 changes: 6 additions & 7 deletions FrameWorkCode/indentoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ indentOptions::indentOptions(QWidget *parent, int* left, int* right) :
ui->setupUi(this);
this->left = left;
this->right = right;
setWindowTitle("Indentation Options");
}

indentOptions::~indentOptions()
Expand All @@ -17,30 +18,28 @@ indentOptions::~indentOptions()

void indentOptions::closeEvent(QCloseEvent* event)
{

reject();// Set check_b to true when the dialog is closed
emit dialogRejected();
QDialog::closeEvent(event);
}

void indentOptions::on_buttonBox_accepted()
{

int l = ui->textEdit_left->toPlainText().toInt();
int r = ui->textEdit_right->toPlainText().toInt();
if(l==0 && r==0){
reject();
emit dialogRejected();
return;
}

*left = l;
*right = r;
accept();


emit dialogAccepted();
}


void indentOptions::on_buttonBox_rejected()
{
reject();
emit dialogRejected();
this->close();
}
4 changes: 3 additions & 1 deletion FrameWorkCode/indentoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ class indentOptions : public QDialog
public:
explicit indentOptions(QWidget *parent = nullptr, int * left = nullptr, int * right = nullptr);
~indentOptions();

signals:
void dialogAccepted();
void dialogRejected();

protected:
void closeEvent(QCloseEvent* event) override;
Expand Down
16 changes: 7 additions & 9 deletions FrameWorkCode/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10582,20 +10582,18 @@ void MainWindow::on_actionDecrease_Indent_triggered()

void MainWindow::on_actionIndentation_Options_triggered()
{

int left = 0, right = 0;
indentOptions i(this, &left, &right);

if (i.exec() == QDialog::Accepted) { // Check if the dialog was accepted
indentOptions *i = new indentOptions(this, &left, &right);
i->show();

if (left + right <= 14) {
connect(i, &indentOptions::dialogAccepted, this, [=](){
if(left + right <= 14){
on_actionIncrease_Indent_triggered(left, right);
}
}



i->deleteLater();
});
}

/*!
* \fn MainWindow::on_actionSpecial_Characters_triggered()
* \brief This function displays the special symbol dialog
Expand Down

0 comments on commit 47fa25c

Please sign in to comment.