mirror of
https://github.com/YACReader/yacreader
synced 2025-07-21 06:24:39 -04:00
Merged in daisuke_cato/yacreader/dev_cato6 (pull request #43)
Add drag and drop onto app icon (dock etc.) support for MacOS platform. (target branch = develop)
This commit is contained in:
@ -225,6 +225,12 @@ void GoToFlow::updateConfig(QSettings * settings)
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
}
|
||||
|
||||
void GoToFlow::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flow->setFlowRightToLeft(b);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//SlideInitializer
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -63,6 +63,8 @@ private slots:
|
||||
void setFlowType(FlowType flowType);
|
||||
void updateSize();
|
||||
void updateConfig(QSettings * settings);
|
||||
void setFlowRightToLeft(bool b);
|
||||
|
||||
signals:
|
||||
void goToPage(unsigned int page);
|
||||
|
||||
|
@ -164,3 +164,8 @@ void GoToFlowGL::resizeEvent(QResizeEvent *event)
|
||||
toolBar->move(0, event->size().height() - toolBar->height());
|
||||
toolBar->setFixedWidth(width());
|
||||
}
|
||||
|
||||
void GoToFlowGL::setFlowRightToLeft(bool b)
|
||||
{
|
||||
flow->setFlowRightToLeft(b);
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
void updateSize();
|
||||
|
||||
void updateConfig(QSettings * settings);
|
||||
void setFlowRightToLeft(bool b);
|
||||
|
||||
signals:
|
||||
void goToPage(unsigned int page);
|
||||
|
@ -29,6 +29,7 @@ public slots:
|
||||
virtual void setImageReady(int index,const QByteArray & image) = 0;
|
||||
virtual void updateSize() = 0;
|
||||
virtual void updateConfig(QSettings * settings) = 0;
|
||||
virtual void setFlowRightToLeft(bool b) = 0;
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
|
@ -655,13 +655,68 @@ void MainWindowViewer::createToolBars()
|
||||
fileMenu->addAction(openFolderAction);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(saveImageAction);
|
||||
fileMenu->addSeparator();
|
||||
|
||||
QMenu * recentmenu = new QMenu(tr("Open recent"));
|
||||
recentmenu->addActions(recentFilesActionList);
|
||||
recentmenu->addSeparator();
|
||||
recentmenu->addAction(clearRecentFilesAction);
|
||||
refreshRecentFilesActionList();
|
||||
fileMenu->addMenu(recentmenu);
|
||||
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(closeAction);
|
||||
|
||||
QMenu * editMenu = new QMenu(tr("Edit"));
|
||||
editMenu->addAction(leftRotationAction);
|
||||
editMenu->addAction(rightRotationAction);
|
||||
|
||||
QMenu * viewMenu = new QMenu(tr("View"));
|
||||
viewMenu->addAction(adjustHeightAction);
|
||||
viewMenu->addAction(adjustWidthAction);
|
||||
viewMenu->addAction(fitToPageAction);
|
||||
viewMenu->addAction(adjustToFullSizeAction);
|
||||
viewMenu->addSeparator();
|
||||
viewMenu->addAction(increasePageZoomAction);
|
||||
viewMenu->addAction(decreasePageZoomAction);
|
||||
viewMenu->addAction(resetZoomAction);
|
||||
viewMenu->addAction(showZoomSliderlAction);
|
||||
viewMenu->addSeparator();
|
||||
viewMenu->addAction(doublePageAction);
|
||||
viewMenu->addAction(doubleMangaPageAction);
|
||||
viewMenu->addSeparator();
|
||||
viewMenu->addAction(showMagnifyingGlassAction);
|
||||
|
||||
QMenu * goMenu = new QMenu(tr("Go"));
|
||||
goMenu->addAction(prevAction);
|
||||
goMenu->addAction(nextAction);
|
||||
goMenu->addAction(goToPageAction);
|
||||
goMenu->addSeparator();
|
||||
goMenu->addAction(setBookmarkAction);
|
||||
goMenu->addAction(showBookmarksAction);
|
||||
|
||||
QMenu * windowMenu = new QMenu(tr("Window"));
|
||||
windowMenu->addAction(optionsAction); // this action goes to MacOS's Preference menu by Qt
|
||||
windowMenu->addAction(showShorcutsAction);
|
||||
windowMenu->addAction(showFlowAction);
|
||||
windowMenu->addAction(showInfoAction);
|
||||
windowMenu->addAction(showDictionaryAction);
|
||||
|
||||
QMenu * helpMenu = new QMenu(tr("Help"));
|
||||
helpMenu->addAction(helpAboutAction);
|
||||
|
||||
menuBar->addMenu(fileMenu);
|
||||
menuBar->addMenu(editMenu);
|
||||
menuBar->addMenu(viewMenu);
|
||||
menuBar->addMenu(goMenu);
|
||||
menuBar->addMenu(windowMenu);
|
||||
menuBar->addMenu(helpMenu);
|
||||
|
||||
//tool bar
|
||||
//QMenu * toolbarMenu = new QMenu(tr("Toolbar"));
|
||||
//toolbarMenu->addAction();
|
||||
//TODO
|
||||
|
||||
menuBar->addMenu(fileMenu);
|
||||
//menu->addMenu(toolbarMenu);
|
||||
|
||||
//attach toolbar
|
||||
@ -1279,6 +1334,22 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
autoScrollBackwardAction->setData(AUTO_SCROLL_BACKWARD_ACTION_Y);
|
||||
autoScrollBackwardAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y));
|
||||
|
||||
QAction * autoScrollForwardHorizontalFirstAction = new QAction(tr("Autoscroll forward, horizontal first"),orphanActions);
|
||||
autoScrollForwardHorizontalFirstAction->setData(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y);
|
||||
autoScrollForwardHorizontalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y));
|
||||
|
||||
QAction * autoScrollBackwardHorizontalFirstAction = new QAction(tr("Autoscroll backward, horizontal first"),orphanActions);
|
||||
autoScrollBackwardHorizontalFirstAction->setData(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y);
|
||||
autoScrollBackwardHorizontalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y));
|
||||
|
||||
QAction * autoScrollForwardVerticalFirstAction = new QAction(tr("Autoscroll forward, vertical first"),orphanActions);
|
||||
autoScrollForwardVerticalFirstAction->setData(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y);
|
||||
autoScrollForwardVerticalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y));
|
||||
|
||||
QAction * autoScrollBackwardVerticalFirstAction = new QAction(tr("Autoscroll backward, vertical first"),orphanActions);
|
||||
autoScrollBackwardVerticalFirstAction->setData(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y);
|
||||
autoScrollBackwardVerticalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y));
|
||||
|
||||
QAction * moveDownAction = new QAction(tr("Move down"),orphanActions);
|
||||
moveDownAction->setData(MOVE_DOWN_ACTION_Y);
|
||||
moveDownAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y));
|
||||
@ -1311,6 +1382,10 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
<< showBookmarksAction
|
||||
<< autoScrollForwardAction
|
||||
<< autoScrollBackwardAction
|
||||
<< autoScrollForwardHorizontalFirstAction
|
||||
<< autoScrollBackwardHorizontalFirstAction
|
||||
<< autoScrollForwardVerticalFirstAction
|
||||
<< autoScrollBackwardVerticalFirstAction
|
||||
<< moveDownAction
|
||||
<< moveUpAction
|
||||
<< moveLeftAction
|
||||
|
@ -118,6 +118,11 @@ zoom(100)
|
||||
//animations
|
||||
verticalScroller = new QPropertyAnimation(verticalScrollBar(), "sliderPosition");
|
||||
connect(verticalScroller,SIGNAL(valueChanged (const QVariant &)),this,SIGNAL(backgroundChanges()));
|
||||
horizontalScroller = new QPropertyAnimation(horizontalScrollBar(), "sliderPosition");
|
||||
connect(horizontalScroller,SIGNAL(valueChanged (const QVariant &)),this,SIGNAL(backgroundChanges()));
|
||||
groupScroller = new QParallelAnimationGroup();
|
||||
groupScroller->addAnimation(verticalScroller);
|
||||
groupScroller->addAnimation(horizontalScroller);
|
||||
|
||||
notificationsLabel = new NotificationsLabelWidget(this);
|
||||
notificationsLabel->hide();
|
||||
@ -137,6 +142,8 @@ Viewer::~Viewer()
|
||||
delete hideCursorTimer;
|
||||
delete informationLabel;
|
||||
delete verticalScroller;
|
||||
delete horizontalScroller;
|
||||
delete groupScroller;
|
||||
delete bd;
|
||||
delete notificationsLabel;
|
||||
delete mglass;
|
||||
@ -456,6 +463,142 @@ void Viewer::scrollUp()
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::scrollForwardHorizontalFirst()
|
||||
{
|
||||
if (!doubleMangaPage)
|
||||
{
|
||||
scrollZigzag(RIGHT, DOWN, true); // right->right->lower left->right->...->next page
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollZigzag(LEFT, DOWN, true); // left->left->lower right->left->...->next page
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::scrollBackwardHorizontalFirst()
|
||||
{
|
||||
if (!doubleMangaPage)
|
||||
{
|
||||
scrollZigzag(LEFT, UP, false); // left->left->upper right->left->...->prev page
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollZigzag(RIGHT, UP, false); // right->right->upper left->right->...->prev page
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::scrollForwardVerticalFirst()
|
||||
{
|
||||
if (!doubleMangaPage)
|
||||
{
|
||||
scrollZigzag(DOWN, RIGHT, true); // down->down->upper right->down->...->next page
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollZigzag(DOWN, LEFT, true); // down->down->upper left->down->...->next page
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::scrollBackwardVerticalFirst()
|
||||
{
|
||||
if (!doubleMangaPage)
|
||||
{
|
||||
scrollZigzag(UP, LEFT, false); // up->up->lower left->up->...->prev page
|
||||
}
|
||||
else
|
||||
{
|
||||
scrollZigzag(UP, RIGHT, false); // up->up->lower right->up->...->prev page
|
||||
}
|
||||
}
|
||||
|
||||
bool Viewer::isEdge(scrollDirection d)
|
||||
{
|
||||
if(d == UP)
|
||||
return verticalScrollBar()->sliderPosition() == verticalScrollBar()->minimum();
|
||||
else if(d == DOWN)
|
||||
return verticalScrollBar()->sliderPosition() == verticalScrollBar()->maximum();
|
||||
else if(d == LEFT)
|
||||
return horizontalScrollBar()->sliderPosition() == horizontalScrollBar()->minimum();
|
||||
else // d == RIGHT
|
||||
return horizontalScrollBar()->sliderPosition() == horizontalScrollBar()->maximum();
|
||||
}
|
||||
|
||||
void Viewer::scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward)
|
||||
{
|
||||
if(!isEdge(d1))
|
||||
{
|
||||
if(d1 == UP)
|
||||
scrollTo(horizontalScrollBar()->sliderPosition(),
|
||||
verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80)));
|
||||
else if(d1 == DOWN)
|
||||
scrollTo(horizontalScrollBar()->sliderPosition(),
|
||||
verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80)));
|
||||
else if(d1 == LEFT)
|
||||
scrollTo(horizontalScrollBar()->sliderPosition()-static_cast<int>((width()*0.80)),
|
||||
verticalScrollBar()->sliderPosition());
|
||||
else // d1 == RIGHT
|
||||
scrollTo(horizontalScrollBar()->sliderPosition()+static_cast<int>((width()*0.80)),
|
||||
verticalScrollBar()->sliderPosition());
|
||||
}
|
||||
else if(!isEdge(d2))
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
if(d1 == UP)
|
||||
y = verticalScrollBar()->maximum();
|
||||
else if(d1 == DOWN)
|
||||
y = verticalScrollBar()->minimum();
|
||||
else if(d1 == LEFT)
|
||||
x = horizontalScrollBar()->maximum();
|
||||
else // d1 == RIGHT
|
||||
x = horizontalScrollBar()->minimum();
|
||||
|
||||
if(d2 == UP)
|
||||
y = std::max(verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80)), verticalScrollBar()->minimum());
|
||||
else if(d2 == DOWN)
|
||||
y = std::min(verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80)), verticalScrollBar()->maximum());
|
||||
else if(d2 == LEFT)
|
||||
x = std::max(horizontalScrollBar()->sliderPosition()-static_cast<int>((width()*0.80)), horizontalScrollBar()->minimum());
|
||||
else // d2 == RIGHT
|
||||
x = std::min(horizontalScrollBar()->sliderPosition()+static_cast<int>((width()*0.80)), horizontalScrollBar()->maximum());
|
||||
|
||||
scrollTo(x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// next or prev page's corner
|
||||
int savedPageNumber = getCurrentPageNumber();
|
||||
|
||||
if(forward)
|
||||
next();
|
||||
else
|
||||
prev();
|
||||
|
||||
if(savedPageNumber != getCurrentPageNumber()){
|
||||
if(d1 == LEFT || d2 == LEFT)
|
||||
horizontalScrollBar()->setSliderPosition(horizontalScrollBar()->maximum());
|
||||
else
|
||||
horizontalScrollBar()->setSliderPosition(horizontalScrollBar()->minimum());
|
||||
emit backgroundChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Viewer::scrollTo(int x, int y)
|
||||
{
|
||||
if(groupScroller->state() == QAbstractAnimation::Running)
|
||||
return;
|
||||
horizontalScroller->setDuration(250);
|
||||
horizontalScroller->setStartValue(horizontalScrollBar()->sliderPosition());
|
||||
horizontalScroller->setEndValue(x);
|
||||
verticalScroller->setDuration(250);
|
||||
verticalScroller->setStartValue(verticalScrollBar()->sliderPosition());
|
||||
verticalScroller->setEndValue(y);
|
||||
groupScroller->start();
|
||||
emit backgroundChanges();
|
||||
}
|
||||
|
||||
void Viewer::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(render->hasLoadedComic())
|
||||
@ -491,6 +634,26 @@ void Viewer::keyPressEvent(QKeyEvent *event)
|
||||
scrollUp();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y))
|
||||
{
|
||||
scrollForwardHorizontalFirst();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y))
|
||||
{
|
||||
scrollBackwardHorizontalFirst();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y))
|
||||
{
|
||||
scrollForwardVerticalFirst();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y))
|
||||
{
|
||||
scrollBackwardVerticalFirst();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y) ||
|
||||
@ -800,6 +963,7 @@ void Viewer::doubleMangaPageSwitch()
|
||||
doubleMangaPage = !doubleMangaPage;
|
||||
render->doubleMangaPageSwitch();
|
||||
Configuration::getConfiguration().setDoubleMangaPage(doubleMangaPage);
|
||||
goToFlow->setFlowRightToLeft(doubleMangaPage);
|
||||
}
|
||||
|
||||
void Viewer::resetContent()
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QCloseEvent>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <QSettings>
|
||||
|
||||
#include "scroll_management.h"
|
||||
@ -55,6 +56,10 @@ class NotificationsLabelWidget;
|
||||
void updateOptions();
|
||||
void scrollDown();
|
||||
void scrollUp();
|
||||
void scrollForwardHorizontalFirst();
|
||||
void scrollBackwardHorizontalFirst();
|
||||
void scrollForwardVerticalFirst();
|
||||
void scrollBackwardVerticalFirst();
|
||||
void magnifyingGlassSwitch();
|
||||
void showMagnifyingGlass();
|
||||
void hideMagnifyingGlass();
|
||||
@ -108,6 +113,8 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
PageLabelWidget * informationLabel;
|
||||
//QTimer * scroller;
|
||||
QPropertyAnimation * verticalScroller;
|
||||
QPropertyAnimation * horizontalScroller;
|
||||
QParallelAnimationGroup * groupScroller;
|
||||
int posByStep;
|
||||
int nextPos;
|
||||
GoToFlowWidget * goToFlow;
|
||||
@ -154,6 +161,12 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
void wheelEvent(QWheelEvent * event);
|
||||
void mouseMoveEvent(QMouseEvent * event);
|
||||
|
||||
//!ZigzagScroll
|
||||
enum scrollDirection{ UP, DOWN, LEFT, RIGHT };
|
||||
bool isEdge(scrollDirection d);
|
||||
void scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward);
|
||||
void scrollTo(int x, int y);
|
||||
|
||||
public:
|
||||
Viewer(QWidget * parent = 0);
|
||||
~Viewer();
|
||||
|
Reference in New Issue
Block a user