Skip to content

Commit

Permalink
Fixed bug with autosave. Finished hyperlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
maurictg committed Oct 28, 2020
1 parent f6d36a4 commit d6dd625
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
9 changes: 3 additions & 6 deletions EasyNotepad/etab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ void ETab::useFile(bool write){
}

void ETab::openFile() { this->useFile(false);}
void ETab::saveFile() {
if(changes)
void ETab::saveFile(bool force) {
if(changes || force)
this->useFile(true);
}

Expand Down Expand Up @@ -228,10 +228,7 @@ void ETab::mergeFormat(QTextCharFormat format){

void ETab::insertLink(QString text, QString url) {
QTextCursor cursor = ui->textEdit->textCursor();
if(cursor.hasSelection())
{
cursor.insertHtml("<a href=\""+url+"\">"+text+"</a>&nbsp;");
}
cursor.insertHtml("<a href=\""+url+"\">"+text+"</a>&nbsp;");
}

void ETab::createLink() {
Expand Down
2 changes: 1 addition & 1 deletion EasyNotepad/etab.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ETab : public QWidget
void changeFont();
void changeColor();
void openFile();
void saveFile();
void saveFile(bool force = false);
void setAutoSave(bool enabled);
void setStyle(int type);
void setAlign(int type);
Expand Down
7 changes: 6 additions & 1 deletion EasyNotepad/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void MainWindow::on_actionSave_as_triggered()
QFile f(filename);
f.open(QIODevice::ReadWrite); //This creates the file
ui->tabs->setTabText(ui->tabs->currentIndex(), info.fileName());
changeTab(ACTION::SAVE);
changeTab(ACTION::SAVEAS);
}

//Save file
Expand Down Expand Up @@ -534,6 +534,11 @@ void MainWindow::changeTab(ACTION action, int argument){
selected->saveFile();
}
break;
case ACTION::SAVEAS:
{
selected->saveFile(true);
}
break;
case ACTION::DELETE:
{
QFile file(selected->getFileName());
Expand Down
2 changes: 1 addition & 1 deletion EasyNotepad/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MainWindow : public QMainWindow
void updateMessage(QString message);
void updateAutoSave(bool checked);
enum ACTION {
CHANGEFONTSIZE, CHANGEFONT, CHANGECOLOR, CLOSE, SAVE, DELETE, SETAUTOSAVE,
CHANGEFONTSIZE, CHANGEFONT, CHANGECOLOR, CLOSE, SAVE, SAVEAS, DELETE, SETAUTOSAVE,
SETHNORMAL, SETH1, SETH2, SETH3, SETH4, SETH5, SETH6,
LISTDISK, LISTCIRCLE, LISTSQUARE, LISTUNCHECKED, LISTCHECKED, LISTDECIMAL,
LISTALPHALOWER, LISTALPHAUPPER, LISTROMANLOWER, LISTROMANUPPER,
Expand Down

0 comments on commit d6dd625

Please sign in to comment.