Compare commits

...

7 Commits

Author SHA1 Message Date
MaurycyLiebner
ab466faa5b
Merge pull request #249 from AlexKiryanov/AlexKiryanov-branch
Add views menu in view menu bar
2021-06-02 15:41:11 +02:00
AlexKiryanov
0d47901a43
Add views menu in view menu bar
The View menu is available in all applications. This menu allows you to transform the viewport window. The commands are standard. This is a duplicate of the existing functions. Simply. Now they can be called from this menu, as in all standard applications.
2021-06-02 13:42:33 +03:00
AlexKiryanov
bd58a62764
Delete canvaswindowevents.cpp 2021-06-02 13:40:11 +03:00
AlexKiryanov
c8390880f6
Delete mainwindow.h 2021-06-02 13:39:58 +03:00
AlexKiryanov
e7497a9cc5
Delete mainwindow.cpp 2021-06-02 13:39:43 +03:00
AlexKiryanov
6630d4d8bc
Delete canvaswindow.h 2021-06-02 13:39:25 +03:00
AlexKiryanov
740ef0dac3
Add Views menu in View menu bar
The View menu is available in all applications. This menu allows you to transform the viewport window. The commands are standard. This is a duplicate of the existing functions. Simply. Now they can be called from this menu, as in all standard applications.
2021-06-02 13:35:24 +03:00
4 changed files with 70 additions and 0 deletions

View File

@ -155,6 +155,8 @@ public:
void fitCanvasToSize();
void resetTransormation();
void zoomInView();
void zoomOutView();
};
#endif // CANVASWINDOW_H

View File

@ -70,6 +70,22 @@ void CanvasWindow::fitCanvasToSize() {
mViewTransform.scale(minScale, minScale);
}
void CanvasWindow::zoomInView() {
if(!mCurrentCanvas) return;
const auto canvasSize = mCurrentCanvas->getCanvasSize();
mViewTransform.translate(canvasSize.width()*0.5, canvasSize.height()*0.5);
mViewTransform.scale(1.1, 1.1);
mViewTransform.translate(-canvasSize.width()*0.5, -canvasSize.height()*0.5);
}
void CanvasWindow::zoomOutView() {
if(!mCurrentCanvas) return;
const auto canvasSize = mCurrentCanvas->getCanvasSize();
mViewTransform.translate(canvasSize.width()*0.5, canvasSize.height()*0.5);
mViewTransform.scale(0.9, 0.9);
mViewTransform.translate(-canvasSize.width()*0.5, -canvasSize.height()*0.5);
}
#include <QEvent>
bool CanvasWindow::event(QEvent *e) {

View File

@ -606,6 +606,53 @@ void MainWindow::setupMenuBar() {
mViewMenu = mMenuBar->addMenu(tr("View", "MenuBar"));
const auto ViewTransformMenu = mViewMenu->addMenu(
tr("Views","MenuBar_View"));
mZoomInMenu = ViewTransformMenu->addAction(
tr("Zoom In", "MenuBar_Views"));
mZoomInMenu->setShortcut(Qt::Key_Plus);
connect(mZoomInMenu, &QAction::triggered,
this, [](){
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
if (!cwTarget) return;
cwTarget->zoomInView();
});
mZoomOutMenu = ViewTransformMenu->addAction(
tr("Zoom Out", "MenuBar_Views"));
mZoomOutMenu->setShortcut(Qt::Key_Minus);
connect(mZoomOutMenu, &QAction::triggered,
this, [](){
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
if (!cwTarget) return;
cwTarget->zoomOutView();
});
mFitViewMenu = ViewTransformMenu->addAction(
tr("Fit to Canvas", "MenuBar_Views"));
mFitViewMenu->setShortcut(Qt::Key_0);
connect(mFitViewMenu, &QAction::triggered,
this, [](){
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
if (!cwTarget) return;
cwTarget->fitCanvasToSize();
});
mResetZoomMenu = ViewTransformMenu->addAction(
tr("Reset Zoom", "MenuBar_Views"));
mResetZoomMenu->setShortcut(Qt::Key_1);
connect(mResetZoomMenu, &QAction::triggered,
this, [](){
const auto target = KeyFocusTarget::KFT_getCurrentTarget();
const auto cwTarget = dynamic_cast<CanvasWindow*>(target);
if (!cwTarget) return;
cwTarget->resetTransormation();
});
const auto filteringMenu = mViewMenu->addMenu(
tr("Filtering", "MenuBar_View"));

View File

@ -282,6 +282,11 @@ private:
//
ActionButton *mActionNewEmptyPaintFrame;
QAction *mActionNewEmptyPaintFrameAct;
//
QAction *mResetZoomMenu;
QAction *mZoomInMenu;
QAction *mZoomOutMenu;
QAction *mFitViewMenu;
//
QAction *mNoneQuality;
QAction *mLowQuality;