diff --git a/CHANGELOG.md b/CHANGELOG.md index 471b211..1c2e9f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ============ +## 0.0.65 + +- Implemented: +- View Menu -> Zoom + ## 0.0.64 - Implemented: diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user index 8b48a59..f4f3df8 100755 --- a/CMakeLists.txt.user +++ b/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -102,14 +102,14 @@ 2 false - -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=Debug +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_BUILD_TYPE:STRING=Debug --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} /data/Code/Qt/Notepad-- 0 /data/Code/Qt/Notepad--/build/Desktop-Debug @@ -160,14 +160,14 @@ 2 false - -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake --DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} + -DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_BUILD_TYPE:STRING=Release +-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} +-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake +-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX} --DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} --DCMAKE_BUILD_TYPE:STRING=Release --DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} --DCMAKE_GENERATOR:STRING=Ninja +-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} /data/Code/Qt/Notepad-- /data/Code/Qt/Notepad--/build/Desktop-Release diff --git a/src/codeeditor.cpp b/src/codeeditor.cpp index 23d7a63..3d229c1 100755 --- a/src/codeeditor.cpp +++ b/src/codeeditor.cpp @@ -360,6 +360,7 @@ void CodeEditor::paintSpaces(QPainter& painter, const QTextBlock& block, int top } void CodeEditor::paintEOL(QPainter& painter, const QTextBlock& block, int top, int bottom) { + Q_UNUSED(bottom); QFontMetrics metrics(font()); QString text = block.text(); QTextCursor blockCursor(block); @@ -460,3 +461,29 @@ void CodeEditor::paintEvent(QPaintEvent* event) { block = block.next(); } } + +void CodeEditor::zoomIn() { + QFont currentFont = this->font(); + int currentSize = currentFont.pointSize(); + if (currentSize < 72) { + currentFont.setPointSize(currentSize + 1); + this->setFont(currentFont); + } +} + +void CodeEditor::zoomOut() { + QFont currentFont = this->font(); + int currentSize = currentFont.pointSize(); + if (currentSize > 8) { + currentFont.setPointSize(currentSize - 1); + this->setFont(currentFont); + } +} + +void CodeEditor::defaultZoom() { + QFont currentFont = this->font(); + currentFont.setPointSize(12); + this->setFont(currentFont); +} + + diff --git a/src/codeeditor.h b/src/codeeditor.h index 4ea1467..a9cafa8 100755 --- a/src/codeeditor.h +++ b/src/codeeditor.h @@ -31,6 +31,9 @@ class CodeEditor : public QPlainTextEdit { void setShowIndentGuide(bool enabled); void setShowWrapSymbol(bool enabled); void setTabWidth(int width); + void zoomIn(); + void zoomOut(); + void defaultZoom(); protected: void resizeEvent(QResizeEvent *event) override; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4186006..1702c0d 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -572,6 +572,37 @@ void MainWindow::on_actionShow_Wrap_Symbol_triggered(bool checked) } } +void MainWindow::on_actionZoom_In_triggered() +{ + for (int i = 0; i < ui->documentsTab->count(); ++i) { + Document *doc = qobject_cast(ui->documentsTab->widget(i)); + if (doc) { + doc->editor()->zoomIn(); + } + } +} + +void MainWindow::on_actionoom_Out_triggered() +{ + for (int i = 0; i < ui->documentsTab->count(); ++i) { + Document *doc = qobject_cast(ui->documentsTab->widget(i)); + if (doc) { + doc->editor()->zoomOut(); + } + } +} + +void MainWindow::on_action_Restore_Default_Zoom_triggered() +{ + for (int i = 0; i < ui->documentsTab->count(); ++i) { + Document *doc = qobject_cast(ui->documentsTab->widget(i)); + if (doc) { + doc->editor()->defaultZoom(); + } + } +} + + diff --git a/src/mainwindow.h b/src/mainwindow.h index bc662ce..b46dfda 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -162,6 +162,12 @@ private slots: void on_actionShow_Wrap_Symbol_triggered(bool checked); + void on_actionZoom_In_triggered(); + + void on_actionoom_Out_triggered(); + + void on_action_Restore_Default_Zoom_triggered(); + private: Ui::MainWindow* ui; FileOperations* fileOperations;