refactor: move prev/next picture button to bottom toolbar.
This commit is contained in:
@@ -43,13 +43,13 @@ void ActionManager::setupAction(MainWindow *mainWindow)
|
|||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionZoomOut, zoom-out);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionZoomOut, zoom-out);
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionToggleCheckerboard, view-background-checkerboard);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionToggleCheckerboard, view-background-checkerboard);
|
||||||
CREATE_NEW_ICON_ACTION(mainWindow, actionRotateClockwise, object-rotate-right);
|
CREATE_NEW_ICON_ACTION(mainWindow, actionRotateClockwise, object-rotate-right);
|
||||||
|
CREATE_NEW_ICON_ACTION(mainWindow, actionPrevPicture, go-previous);
|
||||||
|
CREATE_NEW_ICON_ACTION(mainWindow, actionNextPicture, go-next);
|
||||||
#undef CREATE_NEW_ICON_ACTION
|
#undef CREATE_NEW_ICON_ACTION
|
||||||
|
|
||||||
#define CREATE_NEW_ACTION(w, a) create_action(w, &a, QString(), ACTION_NAME(a))
|
#define CREATE_NEW_ACTION(w, a) create_action(w, &a, QString(), ACTION_NAME(a))
|
||||||
#define CREATE_NEW_THEMEICON_ACTION(w, a, i) create_action(w, &a, QLatin1String(STRIFY(i)), ACTION_NAME(a), true)
|
#define CREATE_NEW_THEMEICON_ACTION(w, a, i) create_action(w, &a, QLatin1String(STRIFY(i)), ACTION_NAME(a), true)
|
||||||
CREATE_NEW_ACTION(mainWindow, actionRotateCounterClockwise);
|
CREATE_NEW_ACTION(mainWindow, actionRotateCounterClockwise);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionPrevPicture);
|
|
||||||
CREATE_NEW_ACTION(mainWindow, actionNextPicture);
|
|
||||||
|
|
||||||
CREATE_NEW_ACTION(mainWindow, actionTogglePauseAnimation);
|
CREATE_NEW_ACTION(mainWindow, actionTogglePauseAnimation);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionAnimationNextFrame);
|
CREATE_NEW_ACTION(mainWindow, actionAnimationNextFrame);
|
||||||
@@ -147,3 +147,9 @@ void ActionManager::setupShortcuts()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActionManager::enablePrevNextPictureAction(bool enablePrevPictureAction, bool enableNextPictureAction)
|
||||||
|
{
|
||||||
|
actionPrevPicture->setEnabled(enablePrevPictureAction);
|
||||||
|
actionNextPicture->setEnabled(enableNextPictureAction);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public:
|
|||||||
void setupAction(MainWindow * mainWindow);
|
void setupAction(MainWindow * mainWindow);
|
||||||
void retranslateUi(MainWindow *MainWindow);
|
void retranslateUi(MainWindow *MainWindow);
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
|
void enablePrevNextPictureAction(bool enablePrevPictureAction, bool enableNextPictureAction);
|
||||||
|
|
||||||
static QIcon loadHidpiIcon(const QString &resp, QSize sz = QSize(32, 32));
|
static QIcon loadHidpiIcon(const QString &resp, QSize sz = QSize(32, 32));
|
||||||
|
|
||||||
|
|||||||
@@ -83,22 +83,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
connect(m_graphicsView, &GraphicsView::viewportRectChanged,
|
connect(m_graphicsView, &GraphicsView::viewportRectChanged,
|
||||||
m_gv, &NavigatorView::updateMainViewportRegion);
|
m_gv, &NavigatorView::updateMainViewportRegion);
|
||||||
|
|
||||||
m_prevButton = new ToolButton(false, m_graphicsView);
|
|
||||||
m_prevButton->setIconSize(QSize(75, 75));
|
|
||||||
m_prevButton->setIconResourcePath(":/icons/go-previous.svg");
|
|
||||||
m_prevButton->setVisible(false);
|
|
||||||
m_prevButton->setOpacity(0, false);
|
|
||||||
m_nextButton = new ToolButton(false, m_graphicsView);
|
|
||||||
m_nextButton->setIconSize(QSize(75, 75));
|
|
||||||
m_nextButton->setIconResourcePath(":/icons/go-next.svg");
|
|
||||||
m_nextButton->setVisible(false);
|
|
||||||
m_nextButton->setOpacity(0, false);
|
|
||||||
|
|
||||||
connect(m_prevButton, &QAbstractButton::clicked,
|
|
||||||
this, &MainWindow::galleryPrev);
|
|
||||||
connect(m_nextButton, &QAbstractButton::clicked,
|
|
||||||
this, &MainWindow::galleryNext);
|
|
||||||
|
|
||||||
m_am->setupAction(this);
|
m_am->setupAction(this);
|
||||||
|
|
||||||
m_bottomButtonGroup = new BottomButtonGroup({
|
m_bottomButtonGroup = new BottomButtonGroup({
|
||||||
@@ -106,6 +90,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
m_am->actionToggleMaximize,
|
m_am->actionToggleMaximize,
|
||||||
m_am->actionZoomIn,
|
m_am->actionZoomIn,
|
||||||
m_am->actionZoomOut,
|
m_am->actionZoomOut,
|
||||||
|
m_am->actionPrevPicture,
|
||||||
|
m_am->actionNextPicture,
|
||||||
m_am->actionToggleCheckerboard,
|
m_am->actionToggleCheckerboard,
|
||||||
m_am->actionRotateClockwise
|
m_am->actionRotateClockwise
|
||||||
}, this);
|
}, this);
|
||||||
@@ -291,9 +277,6 @@ void MainWindow::enterEvent(QEnterEvent *event)
|
|||||||
m_bottomButtonGroup->setOpacity(1);
|
m_bottomButtonGroup->setOpacity(1);
|
||||||
m_gv->setOpacity(1);
|
m_gv->setOpacity(1);
|
||||||
|
|
||||||
m_prevButton->setOpacity(1);
|
|
||||||
m_nextButton->setOpacity(1);
|
|
||||||
|
|
||||||
return FramelessWindow::enterEvent(event);
|
return FramelessWindow::enterEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,9 +285,6 @@ void MainWindow::leaveEvent(QEvent *event)
|
|||||||
m_bottomButtonGroup->setOpacity(0);
|
m_bottomButtonGroup->setOpacity(0);
|
||||||
m_gv->setOpacity(0);
|
m_gv->setOpacity(0);
|
||||||
|
|
||||||
m_prevButton->setOpacity(0);
|
|
||||||
m_nextButton->setOpacity(0);
|
|
||||||
|
|
||||||
return FramelessWindow::leaveEvent(event);
|
return FramelessWindow::leaveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,9 +532,6 @@ void MainWindow::closeWindow()
|
|||||||
|
|
||||||
void MainWindow::updateWidgetsPosition()
|
void MainWindow::updateWidgetsPosition()
|
||||||
{
|
{
|
||||||
m_prevButton->move(25, (height() - m_prevButton->sizeHint().height()) / 2);
|
|
||||||
m_nextButton->move(width() - m_nextButton->sizeHint().width() - 25,
|
|
||||||
(height() - m_prevButton->sizeHint().height()) / 2);
|
|
||||||
m_bottomButtonGroup->move((width() - m_bottomButtonGroup->width()) / 2,
|
m_bottomButtonGroup->move((width() - m_bottomButtonGroup->width()) / 2,
|
||||||
height() - m_bottomButtonGroup->height());
|
height() - m_bottomButtonGroup->height());
|
||||||
m_gv->move(width() - m_gv->width(), height() - m_gv->height());
|
m_gv->move(width() - m_gv->width(), height() - m_gv->height());
|
||||||
@@ -851,8 +828,7 @@ void MainWindow::updateGalleryButtonsVisibility()
|
|||||||
{
|
{
|
||||||
const int galleryFileCount = m_pm->totalCount();
|
const int galleryFileCount = m_pm->totalCount();
|
||||||
const bool loopGallery = Settings::instance()->loopGallery();
|
const bool loopGallery = Settings::instance()->loopGallery();
|
||||||
m_prevButton->setVisible(galleryFileCount > 1);
|
m_am->enablePrevNextPictureAction(
|
||||||
m_nextButton->setVisible(galleryFileCount > 1);
|
galleryFileCount > 1 && (loopGallery || !m_pm->isFirstIndex()),
|
||||||
m_prevButton->setEnabled(loopGallery || !m_pm->isFirstIndex());
|
galleryFileCount > 1 && (loopGallery || !m_pm->isLastIndex()));
|
||||||
m_nextButton->setEnabled(loopGallery || !m_pm->isLastIndex());
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,8 +111,6 @@ private:
|
|||||||
|
|
||||||
QPoint m_oldMousePos;
|
QPoint m_oldMousePos;
|
||||||
QFileSystemWatcher *m_fileSystemWatcher;
|
QFileSystemWatcher *m_fileSystemWatcher;
|
||||||
ToolButton *m_prevButton;
|
|
||||||
ToolButton *m_nextButton;
|
|
||||||
GraphicsView *m_graphicsView;
|
GraphicsView *m_graphicsView;
|
||||||
NavigatorView *m_gv;
|
NavigatorView *m_gv;
|
||||||
BottomButtonGroup *m_bottomButtonGroup;
|
BottomButtonGroup *m_bottomButtonGroup;
|
||||||
|
|||||||
Reference in New Issue
Block a user