several improvements

This commit is contained in:
Zira project 2020-06-20 16:14:35 +05:00
parent 9c7150f404
commit eab05eec01
5 changed files with 52 additions and 19 deletions

View file

@ -1,8 +1,8 @@
scheme = dark scheme = dark
editor_line_number_bg_color = #323235 editor_line_number_bg_color = #323235
editor_line_number_color = #606366 editor_line_number_color = #606366
editor_line_number_modified_bg_color = #0b463a editor_line_number_modified_bg_color = #075a4b
editor_line_number_modified_color = #999999 editor_line_number_modified_color = #aaaaaa
editor_line_number_deleted_border_color = #ba1205 editor_line_number_deleted_border_color = #ba1205
editor_line_mark_bg_color = #323235 editor_line_mark_bg_color = #323235
editor_line_map_bg_color = #323235 editor_line_map_bg_color = #323235

View file

@ -103,6 +103,8 @@ public:
void highlightError(int pos, int length); void highlightError(int pos, int length);
void highlightErrorLine(int line); void highlightErrorLine(int line);
void setIsBigFile(bool isBig); void setIsBigFile(bool isBig);
void setFileIsDeleted();
void setFileIsOutdated();
protected: protected:
void focusInEvent(QFocusEvent *e) override; void focusInEvent(QFocusEvent *e) override;
void focusOutEvent(QFocusEvent *e) override; void focusOutEvent(QFocusEvent *e) override;

View file

@ -730,6 +730,7 @@ void Editor::setParseResult(ParseCSS::ParseResult result)
void Editor::setGitAnnotations(QHash<int, Git::Annotation> annotations) void Editor::setGitAnnotations(QHash<int, Git::Annotation> annotations)
{ {
if (warningDisplayed) return;
gitAnnotations = annotations; gitAnnotations = annotations;
gitAnnotationLastLineNumber = -1; gitAnnotationLastLineNumber = -1;
showLineAnnotation(); showLineAnnotation();
@ -737,6 +738,7 @@ void Editor::setGitAnnotations(QHash<int, Git::Annotation> annotations)
void Editor::setGitDiffLines(QHash<int, Git::DiffLine> mLines) void Editor::setGitDiffLines(QHash<int, Git::DiffLine> mLines)
{ {
if (warningDisplayed) return;
gitDiffLines = mLines; gitDiffLines = mLines;
updateLineWidgetsArea(); updateLineWidgetsArea();
} }
@ -1653,20 +1655,12 @@ void Editor::focusInEvent(QFocusEvent *e)
{ {
focused = true; focused = true;
if (fileName.size() > 0 && !Helper::fileExists(fileName) && !warningDisplayed) { if (fileName.size() > 0 && !Helper::fileExists(fileName) && !warningDisplayed) {
warningDisplayed = true; setFileIsDeleted();
if (modified) emit modifiedStateChanged(tabIndex, false);
modified = true;
emit warning(tabIndex, "deleted", QObject::tr("File \"%1\" not found.").arg(fileName));
emit modifiedStateChanged(tabIndex, modified);
} else if (fileName.size() > 0 && Helper::fileExists(fileName) && lastModifiedMsec > 0 && !warningDisplayed) { } else if (fileName.size() > 0 && Helper::fileExists(fileName) && lastModifiedMsec > 0 && !warningDisplayed) {
QFileInfo fInfo(fileName); QFileInfo fInfo(fileName);
QDateTime dtModified = fInfo.lastModified(); QDateTime dtModified = fInfo.lastModified();
if (dtModified.time().msec() != lastModifiedMsec) { if (dtModified.time().msec() != lastModifiedMsec) {
warningDisplayed = true; setFileIsOutdated();
if (modified) emit modifiedStateChanged(tabIndex, false);
modified = true;
emit warning(tabIndex, "outdated", QObject::tr("File \"%1\" was modified externally.").arg(fileName));
emit modifiedStateChanged(tabIndex, modified);
} }
} }
if (static_cast<Search *>(search)->isVisible()) { if (static_cast<Search *>(search)->isVisible()) {
@ -1683,6 +1677,26 @@ void Editor::focusOutEvent(QFocusEvent *e)
QTextEdit::focusOutEvent(e); QTextEdit::focusOutEvent(e);
} }
void Editor::setFileIsDeleted()
{
if (warningDisplayed) return;
warningDisplayed = true;
if (modified) emit modifiedStateChanged(tabIndex, false);
modified = true;
emit warning(tabIndex, "deleted", QObject::tr("File \"%1\" not found.").arg(fileName));
emit modifiedStateChanged(tabIndex, modified);
}
void Editor::setFileIsOutdated()
{
if (warningDisplayed) return;
warningDisplayed = true;
if (modified) emit modifiedStateChanged(tabIndex, false);
modified = true;
emit warning(tabIndex, "outdated", QObject::tr("File \"%1\" was modified externally.").arg(fileName));
emit modifiedStateChanged(tabIndex, modified);
}
void Editor::keyPressEvent(QKeyEvent *e) void Editor::keyPressEvent(QKeyEvent *e)
{ {
bool shift = false, ctrl = false; bool shift = false, ctrl = false;

View file

@ -957,8 +957,13 @@ void MainWindow::on_actionSplitTab_triggered()
if (textEditor != nullptr) { if (textEditor != nullptr) {
QString fileName = textEditor->getFileName(); QString fileName = textEditor->getFileName();
if (fileName.size() > 0 && Helper::fileExists(fileName)) { if (fileName.size() > 0 && Helper::fileExists(fileName)) {
if (!tabWidgetSplit->isVisible()) tabWidgetSplit->show(); Editor * textEditorSplit = editorTabsSplit->getActiveEditor();
editorTabsSplit->openFile(fileName); if (textEditorSplit != nullptr && textEditorSplit->getFileName() == fileName) {
editorTabsSplit->closeTab(textEditorSplit->getTabIndex());
} else {
if (!tabWidgetSplit->isVisible()) tabWidgetSplit->show();
editorTabsSplit->openFile(fileName);
}
} }
} }
} }
@ -1999,14 +2004,26 @@ void MainWindow::editorSaved(int index)
{ {
Editor * textEditor = editorTabs->getActiveEditor(); Editor * textEditor = editorTabs->getActiveEditor();
if (textEditor == nullptr || textEditor->getTabIndex() != index) return; if (textEditor == nullptr || textEditor->getTabIndex() != index) return;
Editor * textEditorSplit = editorTabsSplit->getActiveEditor();
if (textEditorSplit != nullptr && textEditorSplit->getFileName() == textEditor->getFileName()) {
textEditorSplit->setFileIsOutdated();
}
parseTab(); parseTab();
gitTabRefreshRequested(); gitTabRefreshRequested();
} }
void MainWindow::editorSplitSaved(int index) void MainWindow::editorSplitSaved(int index)
{ {
Editor * textEditor = editorTabsSplit->getActiveEditor(); Editor * textEditorSplit = editorTabsSplit->getActiveEditor();
if (textEditor == nullptr || textEditor->getTabIndex() != index) return; if (textEditorSplit == nullptr || textEditorSplit->getTabIndex() != index) return;
Editor * textEditor = editorTabs->getActiveEditor();
if (textEditor != nullptr && textEditor->getFileName() == textEditorSplit->getFileName()) {
textEditor->setFileIsOutdated();
}
parseTabSplit(); parseTabSplit();
gitTabRefreshRequested(); gitTabRefreshRequested();
} }

View file

@ -199,8 +199,8 @@ void Settings::applyDarkColors()
data[COLOR_SCHEME_TYPE.toStdString()] = COLOR_SCHEME_DARK.toStdString(); data[COLOR_SCHEME_TYPE.toStdString()] = COLOR_SCHEME_DARK.toStdString();
data["editor_line_number_bg_color"] = "#232627"; data["editor_line_number_bg_color"] = "#232627";
data["editor_line_number_color"] = "#555555"; data["editor_line_number_color"] = "#555555";
data["editor_line_number_modified_bg_color"] = "#093833"; data["editor_line_number_modified_bg_color"] = "#075a4b";
data["editor_line_number_modified_color"] = "#999999"; data["editor_line_number_modified_color"] = "#aaaaaa";
data["editor_line_number_deleted_border_color"] = "#ba1205"; data["editor_line_number_deleted_border_color"] = "#ba1205";
data["editor_line_mark_bg_color"] = "#232627"; data["editor_line_mark_bg_color"] = "#232627";
data["editor_line_map_bg_color"] = "#232627"; data["editor_line_map_bg_color"] = "#232627";
@ -239,7 +239,7 @@ void Settings::applyDarkColors()
data["highlight_function_color"] = "#00b7ae"; data["highlight_function_color"] = "#00b7ae";
data["highlight_known_function_color"] = "#1071ff"; data["highlight_known_function_color"] = "#1071ff";
data["highlight_variable_color"] = "#05aeff"; data["highlight_variable_color"] = "#05aeff";
data["highlight_known_variable_color"] = "#ffcd56"; data["highlight_known_variable_color"] = "#ffb58c";
data["highlight_unused_variable_color"] = "#858871"; data["highlight_unused_variable_color"] = "#858871";
data["highlight_single_line_comment_color"] = "#5d5d5d"; data["highlight_single_line_comment_color"] = "#5d5d5d";
data["highlight_multi_line_comment_color"] = "#6c7556"; data["highlight_multi_line_comment_color"] = "#6c7556";