Skip to content

Commit cb746de

Browse files
authored
Merge pull request #8 from GTRONICK/development
Development
2 parents 2e598f8 + d38d231 commit cb746de

File tree

5 files changed

+18
-39
lines changed

5 files changed

+18
-39
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# QNote
22
Lightweight yet powerful and fast QT Text editor
33

4-
![QNote_GUI](https://sites.google.com/site/gtronick/QNote_1.7.4.png)
4+
![QNote_GUI](https://sites.google.com/site/gtronick/QNote_1.7.5.png)
55
*Preview in Plasma Desktop*
66

77
# HOW TO INSTALL:
88

99
**Windows:**
10-
Download from here: ![https://github.com/GTRONICK/QNote/releases/download/v1.7.4/QNote_Windows.zip](https://github.com/GTRONICK/QNote/releases/download/v1.7.4/QNote_Windows.zip)
10+
Download from here: ![https://github.com/GTRONICK/QNote/releases/download/v1.7.5/QNote_Windows.zip](https://github.com/GTRONICK/QNote/releases/download/v1.7.5/QNote_Windows.zip)
1111

1212
Just decompress the zip file and run QNote.exe or, if you have a previous QNote version, just download the QNote.exe file and replace the existing one.
1313

1414
**Linux:**
15-
Download from here: ![https://github.com/GTRONICK/QNote/releases/download/v1.7.4/QNote_Linux.zip](https://github.com/GTRONICK/QNote/releases/download/v1.7.4/QNote_Linux.zip)
15+
Download from here: ![https://github.com/GTRONICK/QNote/releases/download/v1.7.5/QNote_Linux.zip](https://github.com/GTRONICK/QNote/releases/download/v1.7.5/QNote_Linux.zip)
1616

1717
Just decompress the zip file and run
1818

@@ -101,7 +101,7 @@ Click on the status bar, at the file path location to open the containing folder
101101

102102
1. General bug fixes.
103103
2. Reduced code size.
104-
3. Improved recent files ordering.
104+
3. Performance improvements.
105105

106106
QNote is now compiled with QT5.11.
107107

customtextedit.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,9 @@ void CustomTextEdit::keyPressEvent(QKeyEvent *e){
138138
} else if(block.text().startsWith("\t")) {
139139
this->insertTabs(liTabCount);
140140
this->insertSpaces(liSpaceCount);
141+
} else {
142+
this->setTextCursor(cursor);
141143
}
142-
143-
this->centerCursor();
144-
145144
}else {
146145
QPlainTextEdit::keyPressEvent(e);
147146
}

mainwindow.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ MainWindow::MainWindow(QWidget *parent) :
3434
gbIsReloadFile = false;
3535
gbSaveCancelled = false;
3636
gbShowEraseAndSaveMessageBox = true;
37-
gfMaxFileSize = 1000.00;
3837
giCurrentFileIndex = 0;
3938
giCurrentTabIndex = 0;
4039
giDefaultDirCounter = 0;
@@ -54,18 +53,16 @@ MainWindow::MainWindow(QWidget *parent) :
5453
workerThread = new QThread;
5554
setAcceptDrops(true);
5655
loadConfig();
57-
QShortcut *menuBar_shortcut = new QShortcut(QKeySequence(tr("Ctrl+M")),this);
5856

57+
QShortcut *menuBar_shortcut = new QShortcut(QKeySequence(tr("Ctrl+M")),this);
5958
QShortcut *gr1_shortcut = new QShortcut(QKeySequence(tr("Ctrl+1")),this);
6059
QShortcut *gr2_shortcut = new QShortcut(QKeySequence(tr("Ctrl+2")),this);
6160
QShortcut *gr3_shortcut = new QShortcut(QKeySequence(tr("Ctrl+3")),this);
6261
QShortcut *gr4_shortcut = new QShortcut(QKeySequence(tr("Ctrl+4")),this);
63-
6462
QShortcut *paste_gr1_shortcut = new QShortcut(QKeySequence(tr("F1")),this);
6563
QShortcut *paste_gr2_shortcut = new QShortcut(QKeySequence(tr("F2")),this);
6664
QShortcut *paste_gr3_shortcut = new QShortcut(QKeySequence(tr("F3")),this);
6765
QShortcut *paste_gr4_shortcut = new QShortcut(QKeySequence(tr("F4")),this);
68-
6966
QShortcut *openFileLocation_shortCut = new QShortcut(QKeySequence(tr("F9")),this);
7067

7168
connect(ui->tabWidget,SIGNAL(currentChanged(int)),this,SLOT(main_slot_tabChanged(int)));
@@ -86,7 +83,6 @@ MainWindow::MainWindow(QWidget *parent) :
8683
connect(gr2_shortcut,SIGNAL(activated()),this,SLOT(main_slot_gr2()));
8784
connect(gr3_shortcut,SIGNAL(activated()),this,SLOT(main_slot_gr3()));
8885
connect(gr4_shortcut,SIGNAL(activated()),this,SLOT(main_slot_gr4()));
89-
9086
connect(paste_gr1_shortcut,SIGNAL(activated()),this,SLOT(main_slot_pasteGr1()));
9187
connect(paste_gr2_shortcut,SIGNAL(activated()),this,SLOT(main_slot_pasteGr2()));
9288
connect(paste_gr3_shortcut,SIGNAL(activated()),this,SLOT(main_slot_pasteGr3()));
@@ -229,7 +225,6 @@ bool MainWindow::saveConfig()
229225
configText = configText + "[ALERTS]" + "\n";
230226
configText = configText + "showEraseAlert=" + QString("%1").arg(this->gbShowEraseAndSaveMessageBox) + "\n";
231227
configText = configText + "[FILESIZE]" + "\n";
232-
configText = configText + "maxFileSize=" + QString("%1").arg(gfMaxFileSize) + "\n";
233228
configText = configText + "[RELOAD]" + "\n";
234229
configText = configText + "delay=" + QString("%1").arg(giTimerDelay) + "\n";
235230
configText = configText + "[RECENTS]" + "\n";
@@ -278,7 +273,6 @@ bool MainWindow::loadConfig()
278273
else if(line.startsWith("x") && liIsMaximized == 0) this->move(line.split("=").at(1).toInt(),this->geometry().y());
279274
else if(line.startsWith("y") && liIsMaximized == 0) this->move(this->geometry().x(),line.split("=").at(1).toInt());
280275
else if(line.startsWith("showEraseAlert")) gbShowEraseAndSaveMessageBox = line.split("=").at(1).toInt();
281-
else if(line.startsWith("maxFileSize")) gfMaxFileSize = line.split("=").at(1).toFloat();
282276
else if(line.startsWith("delay")) giTimerDelay = line.split("=").at(1).toInt();
283277
else if(line.startsWith("recentFiles")) {
284278
QStringList lobRecentList= line.split("@@");
@@ -312,7 +306,7 @@ bool MainWindow::loadConfig()
312306

313307
void MainWindow::on_actionAbout_QNote_triggered()
314308
{
315-
QMessageBox::about(this,"QNote 1.7.4",
309+
QMessageBox::about(this,"QNote 1.7.5",
316310
"<style>"
317311
"a:link {"
318312
"color: orange;"
@@ -356,11 +350,10 @@ void MainWindow::on_actionNew_Tab_triggered()
356350
connect(this,SIGNAL(main_signal_refreshHighlight()),lobPlainTexEdit,SLOT(highlightCurrentLine()));
357351
connect(gobSearchDialog,SIGNAL(search_signal_disableHighLight()),lobPlainTexEdit,SLOT(cte_slot_disableHighLight()));
358352
connect(gobSearchDialog,SIGNAL(search_signal_enableHighLight()),lobPlainTexEdit,SLOT(cte_slot_enableHighLight()));
359-
QFont serifFont(gsSavedFont, giSavedFontPointSize, giSavedFontStyle);
360-
lobPlainTexEdit->setFont(serifFont);
353+
QFont lobFont(gsSavedFont, giSavedFontPointSize, giSavedFontStyle);
354+
lobPlainTexEdit->setFont(lobFont);
361355
giCurrentTabIndex = this->ui->tabWidget->addTab(lobPlainTexEdit,"New " + QString::number(giTotalTabs));
362356
this->ui->tabWidget->setCurrentIndex(giCurrentTabIndex);
363-
gobFilePathsHash.insert(giCurrentTabIndex,"");
364357
gobIsModifiedTextHash.insert(giCurrentTabIndex,false);
365358
}
366359

@@ -921,7 +914,8 @@ void MainWindow::checkIfUnsaved(int index)
921914
}
922915
break;
923916
case QMessageBox::Discard:
924-
closeTab(index);
917+
if(!gbIsReloadFile && !gbIsAutoreloadEnabled) closeTab(index);
918+
else ui->indicatorLabel->clear();
925919
break;
926920
case QMessageBox::Cancel:
927921
gbSaveCancelled = true;
@@ -981,8 +975,6 @@ void MainWindow::closeTab(int index)
981975

982976
void MainWindow::loadFile(QString asFileName)
983977
{
984-
//qDebug() << "Begin loadFile, asFileName: " << asFileName;
985-
986978
QFile *lobFile = new QFile(asFileName);
987979

988980
if(!asFileName.isEmpty() && lobFile->exists()){
@@ -991,7 +983,7 @@ void MainWindow::loadFile(QString asFileName)
991983

992984
emit main_signal_setCurrentFileSize(lobFile->size());
993985

994-
if(gobFilePathsHash.value(giCurrentTabIndex) != NULL && gobFilePathsHash.value(giCurrentTabIndex) != ""){
986+
if((gobFilePathsHash.value(giCurrentTabIndex) != NULL && gobFilePathsHash.value(giCurrentTabIndex) != "") || gobIsModifiedTextHash.value(giCurrentTabIndex) == true){
995987
on_actionNew_Tab_triggered();
996988
}
997989

@@ -1005,7 +997,7 @@ void MainWindow::loadFile(QString asFileName)
1005997
}
1006998

1007999
gobCurrentPlainTextEdit = qobject_cast<CustomTextEdit*>(ui->tabWidget->widget(giCurrentTabIndex));
1008-
giCurrentFileIndex ++; //Aumenta el cursor para leer el siguiente archivo en el mapa global de archivos
1000+
giCurrentFileIndex ++;
10091001
emit main_signal_loadFile(lobFile);
10101002

10111003
addRecentFiles();
@@ -1014,7 +1006,6 @@ void MainWindow::loadFile(QString asFileName)
10141006
QMessageBox::warning(this,"Error!","The file " + asFileName + " can't be opened.");
10151007
gobFileNames.removeAt(giCurrentFileIndex);
10161008
}
1017-
//qDebug() << "End loadFile";
10181009
}
10191010

10201011
void MainWindow::setFileNameFromCommandLine(QStringList asFileNames)
@@ -1062,11 +1053,9 @@ void MainWindow::dropEvent(QDropEvent *event)
10621053
const QMimeData* mimeData = event->mimeData();
10631054

10641055
if (mimeData->hasUrls()){
1065-
10661056
QList<QUrl> urlList = mimeData->urls();
10671057

1068-
for (int i = 0; i < urlList.size(); i++)
1069-
{
1058+
for (int i = 0; i < urlList.size(); i++) {
10701059
gobCurrentPlainTextEdit->appendPlainText(urlList.at(i).toLocalFile());
10711060
}
10721061

mainwindow.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ private slots:
102102
void disableAutoReload();
103103
QStringList removeDuplicates(QStringList aobList);
104104

105-
Ui::MainWindow *ui; //Interfaz de usuario
106-
107-
float gfMaxFileSize;
105+
Ui::MainWindow *ui;
108106

109107
int giCurrentFileIndex; //indice para el archivo actual que se abrirá
110108
int giCurrentTabIndex; //indice para la pestaña actual
@@ -122,18 +120,15 @@ private slots:
122120
bool gbSaveCancelled; //Bandera que indica si se canceló el guardado del archivo
123121

124122
QHash<int, QString> gobFilePathsHash; //Mapa que almacena índice del tab y ruta de archivo
125-
QHash<int, bool> gobIsModifiedTextHash; //Mapa que almacena índice del tab, y si el archivo correspondiente ha sido modificado
126-
QHash<int, bool> gobIsReloadingHash; //Mapa que almacena índice del tab, y si el archivo se encuentra en recarga automática
123+
QHash<int, bool> gobIsModifiedTextHash; //Mapa que almacena índice del tab, y si el archivo correspondiente ha sido modificado
127124

128125
QString gsDefaultDir; //Cadena con la ruta del directorio por defecto a mostrar al abrir un archivo.
129126
QString gsGr1;
130127
QString gsGr2;
131128
QString gsGr3;
132129
QString gsGr4;
133-
QString gsGr5;
134130
QString gsSavedFont;
135-
QString gsStatusBarTemporalText;
136-
QString gsThemeFile; //Ruta del archivo del tema usado (style.qss)
131+
QString gsThemeFile; //Ruta del archivo del tema usado
137132
QString gsStatusBarColor;
138133

139134
QStringList gobFileNames; //Lista de archivos arrastrados o abiertos.

worker.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ Worker::Worker(QObject *parent) : QObject(parent){
88

99
void Worker::worker_slot_loadFile(QFile *file)
1010
{
11-
//qDebug() << "Begin worker_slot_loadFile, file: " << file->fileName();
12-
1311
QString line = "";
1412
QString text = "";
1513
QTextStream in(file);
@@ -21,8 +19,6 @@ void Worker::worker_slot_loadFile(QFile *file)
2119
file->close();
2220
text.remove(text.lastIndexOf("\n"),1);
2321
emit worker_signal_appendText(text);
24-
25-
//qDebug() << "End worker_slot_loadFile";
2622
}
2723

2824
void Worker::worker_slot_tailFile(QFile *file)

0 commit comments

Comments
 (0)