diff --git a/EasyNotepad/etab.cpp b/EasyNotepad/etab.cpp
index f3387a9..d25048c 100644
--- a/EasyNotepad/etab.cpp
+++ b/EasyNotepad/etab.cpp
@@ -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);
}
@@ -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(""+text+" ");
- }
+ cursor.insertHtml(""+text+" ");
}
void ETab::createLink() {
diff --git a/EasyNotepad/etab.h b/EasyNotepad/etab.h
index d61e187..b74b5d9 100644
--- a/EasyNotepad/etab.h
+++ b/EasyNotepad/etab.h
@@ -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);
diff --git a/EasyNotepad/mainwindow.cpp b/EasyNotepad/mainwindow.cpp
index 520e312..1e36a3f 100644
--- a/EasyNotepad/mainwindow.cpp
+++ b/EasyNotepad/mainwindow.cpp
@@ -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
@@ -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());
diff --git a/EasyNotepad/mainwindow.h b/EasyNotepad/mainwindow.h
index 216404e..e6fdc7c 100644
--- a/EasyNotepad/mainwindow.h
+++ b/EasyNotepad/mainwindow.h
@@ -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,