mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Merge pull request #189 from vedgy/enable-shortcuts-in-other-layouts
Fix keyboard shortcuts with alternative layouts; always limit Magnifying glass height; clean up related code
This commit is contained in:
commit
be684514e3
@ -41,8 +41,6 @@ void Configuration::load(QSettings *settings)
|
|||||||
settings->setValue(DOUBLE_PAGE, false);
|
settings->setValue(DOUBLE_PAGE, false);
|
||||||
if (!settings->contains(BACKGROUND_COLOR))
|
if (!settings->contains(BACKGROUND_COLOR))
|
||||||
settings->setValue(BACKGROUND_COLOR, QColor(40, 40, 40));
|
settings->setValue(BACKGROUND_COLOR, QColor(40, 40, 40));
|
||||||
if (!settings->contains(ALWAYS_ON_TOP))
|
|
||||||
settings->setValue(ALWAYS_ON_TOP, false);
|
|
||||||
if (!settings->contains(SHOW_TOOLBARS))
|
if (!settings->contains(SHOW_TOOLBARS))
|
||||||
settings->setValue(SHOW_TOOLBARS, true);
|
settings->setValue(SHOW_TOOLBARS, true);
|
||||||
if (!settings->contains(QUICK_NAVI_MODE))
|
if (!settings->contains(QUICK_NAVI_MODE))
|
||||||
|
@ -69,8 +69,6 @@ public:
|
|||||||
|
|
||||||
QColor getBackgroundColor() { return settings->value(BACKGROUND_COLOR).value<QColor>(); }
|
QColor getBackgroundColor() { return settings->value(BACKGROUND_COLOR).value<QColor>(); }
|
||||||
void setBackgroundColor(const QColor &color) { settings->value(BACKGROUND_COLOR, color); }
|
void setBackgroundColor(const QColor &color) { settings->value(BACKGROUND_COLOR, color); }
|
||||||
bool getAlwaysOnTop() { return settings->value(ALWAYS_ON_TOP).toBool(); }
|
|
||||||
void setAlwaysOnTop(bool b) { settings->setValue(ALWAYS_ON_TOP, b); }
|
|
||||||
bool getShowToolbars() { return settings->value(SHOW_TOOLBARS).toBool(); }
|
bool getShowToolbars() { return settings->value(SHOW_TOOLBARS).toBool(); }
|
||||||
void setShowToolbars(bool b) { settings->setValue(SHOW_TOOLBARS, b); }
|
void setShowToolbars(bool b) { settings->setValue(SHOW_TOOLBARS, b); }
|
||||||
bool getShowInformation() { return settings->value(SHOW_INFO, false).toBool(); }
|
bool getShowInformation() { return settings->value(SHOW_INFO, false).toBool(); }
|
||||||
|
@ -36,7 +36,7 @@ void MagnifyingGlass::updateImage(int x, int y)
|
|||||||
// image section augmented
|
// image section augmented
|
||||||
int zoomWidth = static_cast<int>(width() * zoomLevel);
|
int zoomWidth = static_cast<int>(width() * zoomLevel);
|
||||||
int zoomHeight = static_cast<int>(height() * zoomLevel);
|
int zoomHeight = static_cast<int>(height() * zoomLevel);
|
||||||
auto p = (Viewer *)parent();
|
auto *const p = qobject_cast<const Viewer *>(parentWidget());
|
||||||
int currentPos = p->verticalScrollBar()->sliderPosition();
|
int currentPos = p->verticalScrollBar()->sliderPosition();
|
||||||
const QPixmap image = p->pixmap();
|
const QPixmap image = p->pixmap();
|
||||||
int iWidth = image.width();
|
int iWidth = image.width();
|
||||||
@ -170,101 +170,113 @@ void MagnifyingGlass::wheelEvent(QWheelEvent *event)
|
|||||||
else
|
else
|
||||||
zoomOut();
|
zoomOut();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break; // Never propagate a wheel event to the parent widget, even if we ignore it.
|
||||||
}
|
}
|
||||||
updateImage();
|
|
||||||
event->setAccepted(true);
|
event->setAccepted(true);
|
||||||
}
|
}
|
||||||
void MagnifyingGlass::zoomIn()
|
void MagnifyingGlass::zoomIn()
|
||||||
{
|
{
|
||||||
if (zoomLevel > 0.2f)
|
if (zoomLevel > 0.2f) {
|
||||||
zoomLevel -= 0.025f;
|
zoomLevel -= 0.025f;
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::zoomOut()
|
void MagnifyingGlass::zoomOut()
|
||||||
{
|
{
|
||||||
if (zoomLevel < 0.9f)
|
if (zoomLevel < 0.9f) {
|
||||||
zoomLevel += 0.025f;
|
zoomLevel += 0.025f;
|
||||||
|
updateImage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::sizeUp()
|
void MagnifyingGlass::sizeUp()
|
||||||
{
|
{
|
||||||
auto p = (Viewer *)parent();
|
auto w = width();
|
||||||
if (width() < (p->width() * 0.90f))
|
auto h = height();
|
||||||
resize(width() + 30, height() + 15);
|
if (growWidth(w) | growHeight(h)) // bitwise OR prevents short-circuiting
|
||||||
|
resizeAndUpdate(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::sizeDown()
|
void MagnifyingGlass::sizeDown()
|
||||||
{
|
{
|
||||||
if (width() > 175)
|
auto w = width();
|
||||||
resize(width() - 30, height() - 15);
|
auto h = height();
|
||||||
|
if (shrinkWidth(w) | shrinkHeight(h)) // bitwise OR prevents short-circuiting
|
||||||
|
resizeAndUpdate(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::heightUp()
|
void MagnifyingGlass::heightUp()
|
||||||
{
|
{
|
||||||
auto p = (Viewer *)parent();
|
auto h = height();
|
||||||
if (height() < (p->height() * 0.90f))
|
if (growHeight(h))
|
||||||
resize(width(), height() + 15);
|
resizeAndUpdate(width(), h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::heightDown()
|
void MagnifyingGlass::heightDown()
|
||||||
{
|
{
|
||||||
if (height() > 80)
|
auto h = height();
|
||||||
resize(width(), height() - 15);
|
if (shrinkHeight(h))
|
||||||
|
resizeAndUpdate(width(), h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::widthUp()
|
void MagnifyingGlass::widthUp()
|
||||||
{
|
{
|
||||||
auto p = (Viewer *)parent();
|
auto w = width();
|
||||||
if (width() < (p->width() * 0.90f))
|
if (growWidth(w))
|
||||||
resize(width() + 30, height());
|
resizeAndUpdate(w, height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::widthDown()
|
void MagnifyingGlass::widthDown()
|
||||||
{
|
{
|
||||||
if (width() > 175)
|
auto w = width();
|
||||||
resize(width() - 30, height());
|
if (shrinkWidth(w))
|
||||||
|
resizeAndUpdate(w, height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
|
void MagnifyingGlass::resizeAndUpdate(int w, int h)
|
||||||
{
|
{
|
||||||
bool validKey = false;
|
resize(w, h);
|
||||||
|
|
||||||
int _key = event->key();
|
|
||||||
Qt::KeyboardModifiers modifiers = event->modifiers();
|
|
||||||
|
|
||||||
if (modifiers & Qt::ShiftModifier)
|
|
||||||
_key |= Qt::SHIFT;
|
|
||||||
if (modifiers & Qt::ControlModifier)
|
|
||||||
_key |= Qt::CTRL;
|
|
||||||
if (modifiers & Qt::MetaModifier)
|
|
||||||
_key |= Qt::META;
|
|
||||||
if (modifiers & Qt::AltModifier)
|
|
||||||
_key |= Qt::ALT;
|
|
||||||
|
|
||||||
QKeySequence key(_key);
|
|
||||||
|
|
||||||
if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y)) {
|
|
||||||
sizeUp();
|
|
||||||
validKey = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y)) {
|
|
||||||
sizeDown();
|
|
||||||
validKey = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y)) {
|
|
||||||
zoomIn();
|
|
||||||
validKey = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y)) {
|
|
||||||
zoomOut();
|
|
||||||
validKey = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (validKey) {
|
|
||||||
updateImage();
|
updateImage();
|
||||||
event->setAccepted(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr auto maxRelativeDimension = 0.9;
|
||||||
|
static constexpr auto widthStep = 30;
|
||||||
|
static constexpr auto heightStep = 15;
|
||||||
|
|
||||||
|
bool MagnifyingGlass::growWidth(int &w) const
|
||||||
|
{
|
||||||
|
const auto maxWidth = parentWidget()->width() * maxRelativeDimension;
|
||||||
|
if (w >= maxWidth)
|
||||||
|
return false;
|
||||||
|
w += widthStep;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MagnifyingGlass::shrinkWidth(int &w) const
|
||||||
|
{
|
||||||
|
constexpr auto minWidth = 175;
|
||||||
|
if (w <= minWidth)
|
||||||
|
return false;
|
||||||
|
w -= widthStep;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MagnifyingGlass::growHeight(int &h) const
|
||||||
|
{
|
||||||
|
const auto maxHeight = parentWidget()->height() * maxRelativeDimension;
|
||||||
|
if (h >= maxHeight)
|
||||||
|
return false;
|
||||||
|
h += heightStep;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MagnifyingGlass::shrinkHeight(int &h) const
|
||||||
|
{
|
||||||
|
constexpr auto minHeight = 80;
|
||||||
|
if (h <= minHeight)
|
||||||
|
return false;
|
||||||
|
h -= heightStep;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,15 @@ class MagnifyingGlass : public QLabel
|
|||||||
private:
|
private:
|
||||||
float zoomLevel;
|
float zoomLevel;
|
||||||
void setup(const QSize &size);
|
void setup(const QSize &size);
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
void resizeAndUpdate(int w, int h);
|
||||||
|
|
||||||
|
// The following 4 functions increase/decrease their argument and return true,
|
||||||
|
// unless the maximum dimension value has been reached, in which case they
|
||||||
|
// do not modify the argument and return false.
|
||||||
|
bool growWidth(int &w) const;
|
||||||
|
bool shrinkWidth(int &w) const;
|
||||||
|
bool growHeight(int &h) const;
|
||||||
|
bool shrinkHeight(int &h) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MagnifyingGlass(int width, int height, QWidget *parent);
|
MagnifyingGlass(int width, int height, QWidget *parent);
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
@ -70,7 +72,7 @@ public:
|
|||||||
#endif*/
|
#endif*/
|
||||||
|
|
||||||
MainWindowViewer::MainWindowViewer()
|
MainWindowViewer::MainWindowViewer()
|
||||||
: QMainWindow(), fullscreen(false), toolbars(true), alwaysOnTop(false), currentDirectory("."), currentDirectoryImgDest("."), isClient(false)
|
: QMainWindow(), fullscreen(false), toolbars(true), currentDirectory("."), currentDirectoryImgDest("."), isClient(false)
|
||||||
{
|
{
|
||||||
loadConfiguration();
|
loadConfiguration();
|
||||||
setupUI();
|
setupUI();
|
||||||
@ -118,7 +120,6 @@ MainWindowViewer::~MainWindowViewer()
|
|||||||
delete showInfoAction;
|
delete showInfoAction;
|
||||||
delete closeAction;
|
delete closeAction;
|
||||||
delete showDictionaryAction;
|
delete showDictionaryAction;
|
||||||
delete alwaysOnTopAction;
|
|
||||||
delete adjustToFullSizeAction;
|
delete adjustToFullSizeAction;
|
||||||
delete fitToPageAction;
|
delete fitToPageAction;
|
||||||
delete showFlowAction;
|
delete showFlowAction;
|
||||||
@ -138,6 +139,12 @@ void MainWindowViewer::setupUI()
|
|||||||
// setUnifiedTitleAndToolBarOnMac(true);
|
// setUnifiedTitleAndToolBarOnMac(true);
|
||||||
|
|
||||||
viewer = new Viewer(this);
|
viewer = new Viewer(this);
|
||||||
|
connect(viewer, &Viewer::comicLoaded, this, [this] {
|
||||||
|
if (viewer->magnifyingGlassIsVisible())
|
||||||
|
setMglassActionsEnabled(true);
|
||||||
|
setLoadedComicActionsEnabled(true);
|
||||||
|
});
|
||||||
|
connect(viewer, &Viewer::magnifyingGlassVisibilityChanged, this, &MainWindowViewer::setMglassActionsEnabled);
|
||||||
connect(viewer, &Viewer::reset, this, &MainWindowViewer::processReset);
|
connect(viewer, &Viewer::reset, this, &MainWindowViewer::processReset);
|
||||||
// detected end of comic
|
// detected end of comic
|
||||||
connect(viewer, &Viewer::openNextComic, this, &MainWindowViewer::openNextComic);
|
connect(viewer, &Viewer::openNextComic, this, &MainWindowViewer::openNextComic);
|
||||||
@ -179,6 +186,8 @@ void MainWindowViewer::setupUI()
|
|||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
setUpShortcutsManagement();
|
setUpShortcutsManagement();
|
||||||
|
disableActions();
|
||||||
|
disablePreviousNextComicActions();
|
||||||
|
|
||||||
createToolBars();
|
createToolBars();
|
||||||
|
|
||||||
@ -188,11 +197,6 @@ void MainWindowViewer::setupUI()
|
|||||||
|
|
||||||
viewer->setFocusPolicy(Qt::StrongFocus);
|
viewer->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
|
||||||
// if(Configuration::getConfiguration().getAlwaysOnTop())
|
|
||||||
//{
|
|
||||||
// setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
|
|
||||||
// }
|
|
||||||
|
|
||||||
previousWindowFlags = windowFlags();
|
previousWindowFlags = windowFlags();
|
||||||
previousPos = pos();
|
previousPos = pos();
|
||||||
previousSize = size();
|
previousSize = size();
|
||||||
@ -246,10 +250,8 @@ void MainWindowViewer::createActions()
|
|||||||
openFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_FOLDER_ACTION_Y));
|
openFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_FOLDER_ACTION_Y));
|
||||||
connect(openFolderAction, &QAction::triggered, this, &MainWindowViewer::openFolder);
|
connect(openFolderAction, &QAction::triggered, this, &MainWindowViewer::openFolder);
|
||||||
|
|
||||||
openLatestComicAction = new QAction(tr("Open latest comic"), this);
|
openLatestComicAction = addActionWithShortcut(tr("Open latest comic"), OPEN_LATEST_COMIC_Y);
|
||||||
openLatestComicAction->setToolTip(tr("Open the latest comic opened in the previous reading session"));
|
openLatestComicAction->setToolTip(tr("Open the latest comic opened in the previous reading session"));
|
||||||
openLatestComicAction->setData(OPEN_LATEST_COMIC_Y);
|
|
||||||
openLatestComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_LATEST_COMIC_Y));
|
|
||||||
connect(openLatestComicAction, &QAction::triggered, this, &MainWindowViewer::openLatestComic);
|
connect(openLatestComicAction, &QAction::triggered, this, &MainWindowViewer::openLatestComic);
|
||||||
|
|
||||||
QAction *recentFileAction = nullptr;
|
QAction *recentFileAction = nullptr;
|
||||||
@ -268,7 +270,6 @@ void MainWindowViewer::createActions()
|
|||||||
saveImageAction = new QAction(tr("Save"), this);
|
saveImageAction = new QAction(tr("Save"), this);
|
||||||
saveImageAction->setIcon(QIcon(":/images/viewer_toolbar/save.png"));
|
saveImageAction->setIcon(QIcon(":/images/viewer_toolbar/save.png"));
|
||||||
saveImageAction->setToolTip(tr("Save current page"));
|
saveImageAction->setToolTip(tr("Save current page"));
|
||||||
saveImageAction->setDisabled(true);
|
|
||||||
saveImageAction->setData(SAVE_IMAGE_ACTION_Y);
|
saveImageAction->setData(SAVE_IMAGE_ACTION_Y);
|
||||||
saveImageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SAVE_IMAGE_ACTION_Y));
|
saveImageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SAVE_IMAGE_ACTION_Y));
|
||||||
connect(saveImageAction, &QAction::triggered, this, &MainWindowViewer::saveImage);
|
connect(saveImageAction, &QAction::triggered, this, &MainWindowViewer::saveImage);
|
||||||
@ -276,7 +277,6 @@ void MainWindowViewer::createActions()
|
|||||||
openComicOnTheLeftAction = new QAction(tr("Previous Comic"), this);
|
openComicOnTheLeftAction = new QAction(tr("Previous Comic"), this);
|
||||||
openComicOnTheLeftAction->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.png"));
|
openComicOnTheLeftAction->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.png"));
|
||||||
openComicOnTheLeftAction->setToolTip(tr("Open previous comic"));
|
openComicOnTheLeftAction->setToolTip(tr("Open previous comic"));
|
||||||
openComicOnTheLeftAction->setDisabled(true);
|
|
||||||
openComicOnTheLeftAction->setData(OPEN_PREVIOUS_COMIC_ACTION_Y);
|
openComicOnTheLeftAction->setData(OPEN_PREVIOUS_COMIC_ACTION_Y);
|
||||||
openComicOnTheLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_PREVIOUS_COMIC_ACTION_Y));
|
openComicOnTheLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_PREVIOUS_COMIC_ACTION_Y));
|
||||||
connect(openComicOnTheLeftAction, &QAction::triggered, this, &MainWindowViewer::openLeftComic);
|
connect(openComicOnTheLeftAction, &QAction::triggered, this, &MainWindowViewer::openLeftComic);
|
||||||
@ -284,7 +284,6 @@ void MainWindowViewer::createActions()
|
|||||||
openComicOnTheRightAction = new QAction(tr("Next Comic"), this);
|
openComicOnTheRightAction = new QAction(tr("Next Comic"), this);
|
||||||
openComicOnTheRightAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.png"));
|
openComicOnTheRightAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.png"));
|
||||||
openComicOnTheRightAction->setToolTip(tr("Open next comic"));
|
openComicOnTheRightAction->setToolTip(tr("Open next comic"));
|
||||||
openComicOnTheRightAction->setDisabled(true);
|
|
||||||
openComicOnTheRightAction->setData(OPEN_NEXT_COMIC_ACTION_Y);
|
openComicOnTheRightAction->setData(OPEN_NEXT_COMIC_ACTION_Y);
|
||||||
openComicOnTheRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_NEXT_COMIC_ACTION_Y));
|
openComicOnTheRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_NEXT_COMIC_ACTION_Y));
|
||||||
connect(openComicOnTheRightAction, &QAction::triggered, this, &MainWindowViewer::openRightComic);
|
connect(openComicOnTheRightAction, &QAction::triggered, this, &MainWindowViewer::openRightComic);
|
||||||
@ -293,7 +292,6 @@ void MainWindowViewer::createActions()
|
|||||||
goToPageOnTheLeftAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
|
goToPageOnTheLeftAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
|
||||||
goToPageOnTheLeftAction->setShortcutContext(Qt::WidgetShortcut);
|
goToPageOnTheLeftAction->setShortcutContext(Qt::WidgetShortcut);
|
||||||
goToPageOnTheLeftAction->setToolTip(tr("Go to previous page"));
|
goToPageOnTheLeftAction->setToolTip(tr("Go to previous page"));
|
||||||
goToPageOnTheLeftAction->setDisabled(true);
|
|
||||||
goToPageOnTheLeftAction->setData(PREV_ACTION_Y);
|
goToPageOnTheLeftAction->setData(PREV_ACTION_Y);
|
||||||
goToPageOnTheLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(PREV_ACTION_Y));
|
goToPageOnTheLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(PREV_ACTION_Y));
|
||||||
connect(goToPageOnTheLeftAction, &QAction::triggered, viewer, &Viewer::left);
|
connect(goToPageOnTheLeftAction, &QAction::triggered, viewer, &Viewer::left);
|
||||||
@ -302,7 +300,6 @@ void MainWindowViewer::createActions()
|
|||||||
goToPageOnTheRightAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
|
goToPageOnTheRightAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
|
||||||
goToPageOnTheRightAction->setShortcutContext(Qt::WidgetShortcut);
|
goToPageOnTheRightAction->setShortcutContext(Qt::WidgetShortcut);
|
||||||
goToPageOnTheRightAction->setToolTip(tr("Go to next page"));
|
goToPageOnTheRightAction->setToolTip(tr("Go to next page"));
|
||||||
goToPageOnTheRightAction->setDisabled(true);
|
|
||||||
goToPageOnTheRightAction->setData(NEXT_ACTION_Y);
|
goToPageOnTheRightAction->setData(NEXT_ACTION_Y);
|
||||||
goToPageOnTheRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(NEXT_ACTION_Y));
|
goToPageOnTheRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(NEXT_ACTION_Y));
|
||||||
connect(goToPageOnTheRightAction, &QAction::triggered, viewer, &Viewer::right);
|
connect(goToPageOnTheRightAction, &QAction::triggered, viewer, &Viewer::right);
|
||||||
@ -310,7 +307,6 @@ void MainWindowViewer::createActions()
|
|||||||
adjustHeightAction = new QAction(tr("Fit Height"), this);
|
adjustHeightAction = new QAction(tr("Fit Height"), this);
|
||||||
adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
|
adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
|
||||||
// adjustWidth->setCheckable(true);
|
// adjustWidth->setCheckable(true);
|
||||||
adjustHeightAction->setDisabled(true);
|
|
||||||
adjustHeightAction->setToolTip(tr("Fit image to height"));
|
adjustHeightAction->setToolTip(tr("Fit image to height"));
|
||||||
// adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
// adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
||||||
adjustHeightAction->setData(ADJUST_HEIGHT_ACTION_Y);
|
adjustHeightAction->setData(ADJUST_HEIGHT_ACTION_Y);
|
||||||
@ -321,7 +317,6 @@ void MainWindowViewer::createActions()
|
|||||||
adjustWidthAction = new QAction(tr("Fit Width"), this);
|
adjustWidthAction = new QAction(tr("Fit Width"), this);
|
||||||
adjustWidthAction->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
|
adjustWidthAction->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
|
||||||
// adjustWidth->setCheckable(true);
|
// adjustWidth->setCheckable(true);
|
||||||
adjustWidthAction->setDisabled(true);
|
|
||||||
adjustWidthAction->setToolTip(tr("Fit image to width"));
|
adjustWidthAction->setToolTip(tr("Fit image to width"));
|
||||||
// adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
// adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
||||||
adjustWidthAction->setData(ADJUST_WIDTH_ACTION_Y);
|
adjustWidthAction->setData(ADJUST_WIDTH_ACTION_Y);
|
||||||
@ -332,7 +327,6 @@ void MainWindowViewer::createActions()
|
|||||||
adjustToFullSizeAction = new QAction(tr("Show full size"), this);
|
adjustToFullSizeAction = new QAction(tr("Show full size"), this);
|
||||||
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
|
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
|
||||||
adjustToFullSizeAction->setCheckable(false);
|
adjustToFullSizeAction->setCheckable(false);
|
||||||
adjustToFullSizeAction->setDisabled(true);
|
|
||||||
adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y);
|
adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y);
|
||||||
adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y));
|
adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y));
|
||||||
adjustToFullSizeAction->setCheckable(true);
|
adjustToFullSizeAction->setCheckable(true);
|
||||||
@ -340,7 +334,6 @@ void MainWindowViewer::createActions()
|
|||||||
|
|
||||||
fitToPageAction = new QAction(tr("Fit to page"), this);
|
fitToPageAction = new QAction(tr("Fit to page"), this);
|
||||||
fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/fitToPage.png"));
|
fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/fitToPage.png"));
|
||||||
fitToPageAction->setDisabled(true);
|
|
||||||
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
|
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
|
||||||
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
|
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
|
||||||
fitToPageAction->setCheckable(true);
|
fitToPageAction->setCheckable(true);
|
||||||
@ -371,37 +364,31 @@ void MainWindowViewer::createActions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
resetZoomAction = new QAction(tr("Reset zoom"), this);
|
resetZoomAction = new QAction(tr("Reset zoom"), this);
|
||||||
resetZoomAction->setDisabled(true);
|
|
||||||
resetZoomAction->setData(RESET_ZOOM_ACTION_Y);
|
resetZoomAction->setData(RESET_ZOOM_ACTION_Y);
|
||||||
resetZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_ZOOM_ACTION_Y));
|
resetZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_ZOOM_ACTION_Y));
|
||||||
connect(resetZoomAction, &QAction::triggered, this, &MainWindowViewer::resetZoomLevel);
|
connect(resetZoomAction, &QAction::triggered, this, &MainWindowViewer::resetZoomLevel);
|
||||||
|
|
||||||
showZoomSliderlAction = new QAction(tr("Show zoom slider"), this);
|
showZoomSliderlAction = new QAction(tr("Show zoom slider"), this);
|
||||||
showZoomSliderlAction->setIcon(QIcon(":/images/viewer_toolbar/zoom.png"));
|
showZoomSliderlAction->setIcon(QIcon(":/images/viewer_toolbar/zoom.png"));
|
||||||
showZoomSliderlAction->setDisabled(true);
|
|
||||||
|
|
||||||
increasePageZoomAction = new QAction(tr("Zoom+"), this);
|
increasePageZoomAction = new QAction(tr("Zoom+"), this);
|
||||||
increasePageZoomAction->setDisabled(true);
|
|
||||||
increasePageZoomAction->setData(ZOOM_PLUS_ACTION_Y);
|
increasePageZoomAction->setData(ZOOM_PLUS_ACTION_Y);
|
||||||
increasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_PLUS_ACTION_Y));
|
increasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_PLUS_ACTION_Y));
|
||||||
connect(increasePageZoomAction, &QAction::triggered, this, &MainWindowViewer::increasePageZoomLevel);
|
connect(increasePageZoomAction, &QAction::triggered, this, &MainWindowViewer::increasePageZoomLevel);
|
||||||
|
|
||||||
decreasePageZoomAction = new QAction(tr("Zoom-"), this);
|
decreasePageZoomAction = new QAction(tr("Zoom-"), this);
|
||||||
decreasePageZoomAction->setDisabled(true);
|
|
||||||
decreasePageZoomAction->setData(ZOOM_MINUS_ACTION_Y);
|
decreasePageZoomAction->setData(ZOOM_MINUS_ACTION_Y);
|
||||||
decreasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_MINUS_ACTION_Y));
|
decreasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_MINUS_ACTION_Y));
|
||||||
connect(decreasePageZoomAction, &QAction::triggered, this, &MainWindowViewer::decreasePageZoomLevel);
|
connect(decreasePageZoomAction, &QAction::triggered, this, &MainWindowViewer::decreasePageZoomLevel);
|
||||||
|
|
||||||
leftRotationAction = new QAction(tr("Rotate image to the left"), this);
|
leftRotationAction = new QAction(tr("Rotate image to the left"), this);
|
||||||
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
|
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
|
||||||
leftRotationAction->setDisabled(true);
|
|
||||||
leftRotationAction->setData(LEFT_ROTATION_ACTION_Y);
|
leftRotationAction->setData(LEFT_ROTATION_ACTION_Y);
|
||||||
leftRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(LEFT_ROTATION_ACTION_Y));
|
leftRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(LEFT_ROTATION_ACTION_Y));
|
||||||
connect(leftRotationAction, &QAction::triggered, viewer, &Viewer::rotateLeft);
|
connect(leftRotationAction, &QAction::triggered, viewer, &Viewer::rotateLeft);
|
||||||
|
|
||||||
rightRotationAction = new QAction(tr("Rotate image to the right"), this);
|
rightRotationAction = new QAction(tr("Rotate image to the right"), this);
|
||||||
rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.png"));
|
rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.png"));
|
||||||
rightRotationAction->setDisabled(true);
|
|
||||||
rightRotationAction->setData(RIGHT_ROTATION_ACTION_Y);
|
rightRotationAction->setData(RIGHT_ROTATION_ACTION_Y);
|
||||||
rightRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RIGHT_ROTATION_ACTION_Y));
|
rightRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RIGHT_ROTATION_ACTION_Y));
|
||||||
connect(rightRotationAction, &QAction::triggered, viewer, &Viewer::rotateRight);
|
connect(rightRotationAction, &QAction::triggered, viewer, &Viewer::rotateRight);
|
||||||
@ -409,7 +396,6 @@ void MainWindowViewer::createActions()
|
|||||||
doublePageAction = new QAction(tr("Double page mode"), this);
|
doublePageAction = new QAction(tr("Double page mode"), this);
|
||||||
doublePageAction->setToolTip(tr("Switch to double page mode"));
|
doublePageAction->setToolTip(tr("Switch to double page mode"));
|
||||||
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
|
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
|
||||||
doublePageAction->setDisabled(true);
|
|
||||||
doublePageAction->setCheckable(true);
|
doublePageAction->setCheckable(true);
|
||||||
doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
|
doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
|
||||||
doublePageAction->setData(DOUBLE_PAGE_ACTION_Y);
|
doublePageAction->setData(DOUBLE_PAGE_ACTION_Y);
|
||||||
@ -420,7 +406,6 @@ void MainWindowViewer::createActions()
|
|||||||
doubleMangaPageAction = new QAction(tr("Double page manga mode"), this);
|
doubleMangaPageAction = new QAction(tr("Double page manga mode"), this);
|
||||||
doubleMangaPageAction->setToolTip(tr("Reverse reading order in double page mode"));
|
doubleMangaPageAction->setToolTip(tr("Reverse reading order in double page mode"));
|
||||||
doubleMangaPageAction->setIcon(QIcon(":/images/viewer_toolbar/doubleMangaPage.png"));
|
doubleMangaPageAction->setIcon(QIcon(":/images/viewer_toolbar/doubleMangaPage.png"));
|
||||||
doubleMangaPageAction->setDisabled(true);
|
|
||||||
doubleMangaPageAction->setCheckable(true);
|
doubleMangaPageAction->setCheckable(true);
|
||||||
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
|
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
|
||||||
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
|
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
|
||||||
@ -430,7 +415,6 @@ void MainWindowViewer::createActions()
|
|||||||
|
|
||||||
goToPageAction = new QAction(tr("Go To"), this);
|
goToPageAction = new QAction(tr("Go To"), this);
|
||||||
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
||||||
goToPageAction->setDisabled(true);
|
|
||||||
goToPageAction->setToolTip(tr("Go to page ..."));
|
goToPageAction->setToolTip(tr("Go to page ..."));
|
||||||
goToPageAction->setData(GO_TO_PAGE_ACTION_Y);
|
goToPageAction->setData(GO_TO_PAGE_ACTION_Y);
|
||||||
goToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_PAGE_ACTION_Y));
|
goToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_PAGE_ACTION_Y));
|
||||||
@ -454,7 +438,6 @@ void MainWindowViewer::createActions()
|
|||||||
showMagnifyingGlassAction = new QAction(tr("Magnifying glass"), this);
|
showMagnifyingGlassAction = new QAction(tr("Magnifying glass"), this);
|
||||||
showMagnifyingGlassAction->setToolTip(tr("Switch Magnifying glass"));
|
showMagnifyingGlassAction->setToolTip(tr("Switch Magnifying glass"));
|
||||||
showMagnifyingGlassAction->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.png"));
|
showMagnifyingGlassAction->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.png"));
|
||||||
showMagnifyingGlassAction->setDisabled(true);
|
|
||||||
showMagnifyingGlassAction->setCheckable(true);
|
showMagnifyingGlassAction->setCheckable(true);
|
||||||
showMagnifyingGlassAction->setData(SHOW_MAGNIFYING_GLASS_ACTION_Y);
|
showMagnifyingGlassAction->setData(SHOW_MAGNIFYING_GLASS_ACTION_Y);
|
||||||
showMagnifyingGlassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_MAGNIFYING_GLASS_ACTION_Y));
|
showMagnifyingGlassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_MAGNIFYING_GLASS_ACTION_Y));
|
||||||
@ -463,7 +446,6 @@ void MainWindowViewer::createActions()
|
|||||||
setBookmarkAction = new QAction(tr("Set bookmark"), this);
|
setBookmarkAction = new QAction(tr("Set bookmark"), this);
|
||||||
setBookmarkAction->setToolTip(tr("Set a bookmark on the current page"));
|
setBookmarkAction->setToolTip(tr("Set a bookmark on the current page"));
|
||||||
setBookmarkAction->setIcon(QIcon(":/images/viewer_toolbar/bookmark.png"));
|
setBookmarkAction->setIcon(QIcon(":/images/viewer_toolbar/bookmark.png"));
|
||||||
setBookmarkAction->setDisabled(true);
|
|
||||||
setBookmarkAction->setCheckable(true);
|
setBookmarkAction->setCheckable(true);
|
||||||
setBookmarkAction->setData(SET_BOOKMARK_ACTION_Y);
|
setBookmarkAction->setData(SET_BOOKMARK_ACTION_Y);
|
||||||
setBookmarkAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_BOOKMARK_ACTION_Y));
|
setBookmarkAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_BOOKMARK_ACTION_Y));
|
||||||
@ -474,7 +456,6 @@ void MainWindowViewer::createActions()
|
|||||||
showBookmarksAction = new QAction(tr("Show bookmarks"), this);
|
showBookmarksAction = new QAction(tr("Show bookmarks"), this);
|
||||||
showBookmarksAction->setToolTip(tr("Show the bookmarks of the current comic"));
|
showBookmarksAction->setToolTip(tr("Show the bookmarks of the current comic"));
|
||||||
showBookmarksAction->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.png"));
|
showBookmarksAction->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.png"));
|
||||||
showBookmarksAction->setDisabled(true);
|
|
||||||
showBookmarksAction->setData(SHOW_BOOKMARKS_ACTION_Y);
|
showBookmarksAction->setData(SHOW_BOOKMARKS_ACTION_Y);
|
||||||
showBookmarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_BOOKMARKS_ACTION_Y));
|
showBookmarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_BOOKMARKS_ACTION_Y));
|
||||||
connect(showBookmarksAction, &QAction::triggered, viewer->getBookmarksDialog(), &QWidget::show);
|
connect(showBookmarksAction, &QAction::triggered, viewer->getBookmarksDialog(), &QWidget::show);
|
||||||
@ -488,7 +469,6 @@ void MainWindowViewer::createActions()
|
|||||||
|
|
||||||
showInfoAction = new QAction(tr("Show Info"), this);
|
showInfoAction = new QAction(tr("Show Info"), this);
|
||||||
showInfoAction->setIcon(QIcon(":/images/viewer_toolbar/info.png"));
|
showInfoAction->setIcon(QIcon(":/images/viewer_toolbar/info.png"));
|
||||||
showInfoAction->setDisabled(true);
|
|
||||||
showInfoAction->setData(SHOW_INFO_ACTION_Y);
|
showInfoAction->setData(SHOW_INFO_ACTION_Y);
|
||||||
showInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_INFO_ACTION_Y));
|
showInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_INFO_ACTION_Y));
|
||||||
connect(showInfoAction, &QAction::triggered, viewer, &Viewer::informationSwitch);
|
connect(showInfoAction, &QAction::triggered, viewer, &Viewer::informationSwitch);
|
||||||
@ -502,24 +482,12 @@ void MainWindowViewer::createActions()
|
|||||||
showDictionaryAction = new QAction(tr("Show Dictionary"), this);
|
showDictionaryAction = new QAction(tr("Show Dictionary"), this);
|
||||||
showDictionaryAction->setIcon(QIcon(":/images/viewer_toolbar/translator.png"));
|
showDictionaryAction->setIcon(QIcon(":/images/viewer_toolbar/translator.png"));
|
||||||
// showDictionaryAction->setCheckable(true);
|
// showDictionaryAction->setCheckable(true);
|
||||||
showDictionaryAction->setDisabled(true);
|
|
||||||
showDictionaryAction->setData(SHOW_DICTIONARY_ACTION_Y);
|
showDictionaryAction->setData(SHOW_DICTIONARY_ACTION_Y);
|
||||||
showDictionaryAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_DICTIONARY_ACTION_Y));
|
showDictionaryAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_DICTIONARY_ACTION_Y));
|
||||||
connect(showDictionaryAction, &QAction::triggered, viewer, &Viewer::translatorSwitch);
|
connect(showDictionaryAction, &QAction::triggered, viewer, &Viewer::translatorSwitch);
|
||||||
|
|
||||||
// deprecated
|
|
||||||
alwaysOnTopAction = new QAction(tr("Always on top"), this);
|
|
||||||
alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png"));
|
|
||||||
alwaysOnTopAction->setCheckable(true);
|
|
||||||
alwaysOnTopAction->setDisabled(true);
|
|
||||||
alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop());
|
|
||||||
alwaysOnTopAction->setData(ALWAYS_ON_TOP_ACTION_Y);
|
|
||||||
alwaysOnTopAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ALWAYS_ON_TOP_ACTION_Y));
|
|
||||||
connect(alwaysOnTopAction, &QAction::triggered, this, &MainWindowViewer::alwaysOnTopSwitch);
|
|
||||||
|
|
||||||
showFlowAction = new QAction(tr("Show go to flow"), this);
|
showFlowAction = new QAction(tr("Show go to flow"), this);
|
||||||
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
||||||
showFlowAction->setDisabled(true);
|
|
||||||
showFlowAction->setData(SHOW_FLOW_ACTION_Y);
|
showFlowAction->setData(SHOW_FLOW_ACTION_Y);
|
||||||
showFlowAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_FLOW_ACTION_Y));
|
showFlowAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_FLOW_ACTION_Y));
|
||||||
connect(showFlowAction, &QAction::triggered, viewer, &Viewer::goToFlowSwitch);
|
connect(showFlowAction, &QAction::triggered, viewer, &Viewer::goToFlowSwitch);
|
||||||
@ -530,6 +498,15 @@ void MainWindowViewer::createActions()
|
|||||||
connect(showEditShortcutsAction, &QAction::triggered, editShortcutsDialog, &QWidget::show);
|
connect(showEditShortcutsAction, &QAction::triggered, editShortcutsDialog, &QWidget::show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAction *MainWindowViewer::addActionWithShortcut(const QString &text, const QString &shortcutKey)
|
||||||
|
{
|
||||||
|
auto *const action = new QAction(text, this);
|
||||||
|
action->setData(shortcutKey);
|
||||||
|
action->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(shortcutKey));
|
||||||
|
addAction(action);
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowViewer::createToolBars()
|
void MainWindowViewer::createToolBars()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
@ -987,31 +964,7 @@ void MainWindowViewer::saveImage()
|
|||||||
|
|
||||||
void MainWindowViewer::enableActions()
|
void MainWindowViewer::enableActions()
|
||||||
{
|
{
|
||||||
saveImageAction->setDisabled(false);
|
setActionsEnabled(true);
|
||||||
goToPageOnTheLeftAction->setDisabled(false);
|
|
||||||
goToPageOnTheRightAction->setDisabled(false);
|
|
||||||
adjustHeightAction->setDisabled(false);
|
|
||||||
adjustWidthAction->setDisabled(false);
|
|
||||||
goToPageAction->setDisabled(false);
|
|
||||||
// alwaysOnTopAction->setDisabled(false);
|
|
||||||
leftRotationAction->setDisabled(false);
|
|
||||||
rightRotationAction->setDisabled(false);
|
|
||||||
showMagnifyingGlassAction->setDisabled(false);
|
|
||||||
doublePageAction->setDisabled(false);
|
|
||||||
doubleMangaPageAction->setDisabled(false);
|
|
||||||
adjustToFullSizeAction->setDisabled(false);
|
|
||||||
adjustToFullSizeAction->setDisabled(false);
|
|
||||||
fitToPageAction->setDisabled(false);
|
|
||||||
showZoomSliderlAction->setDisabled(false);
|
|
||||||
increasePageZoomAction->setDisabled(false);
|
|
||||||
decreasePageZoomAction->setDisabled(false);
|
|
||||||
resetZoomAction->setDisabled(false);
|
|
||||||
// setBookmark->setDisabled(false);
|
|
||||||
showBookmarksAction->setDisabled(false);
|
|
||||||
showInfoAction->setDisabled(false); // TODO enable goTo and showInfo (or update) when numPages emited
|
|
||||||
showDictionaryAction->setDisabled(false);
|
|
||||||
showFlowAction->setDisabled(false);
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
activateWindow();
|
activateWindow();
|
||||||
raise();
|
raise();
|
||||||
@ -1019,61 +972,16 @@ void MainWindowViewer::enableActions()
|
|||||||
}
|
}
|
||||||
void MainWindowViewer::disableActions()
|
void MainWindowViewer::disableActions()
|
||||||
{
|
{
|
||||||
saveImageAction->setDisabled(true);
|
setActionsEnabled(false);
|
||||||
goToPageOnTheLeftAction->setDisabled(true);
|
setMglassActionsEnabled(false);
|
||||||
goToPageOnTheRightAction->setDisabled(true);
|
setLoadedComicActionsEnabled(false);
|
||||||
adjustHeightAction->setDisabled(true);
|
setBookmarkAction->setEnabled(false);
|
||||||
adjustWidthAction->setDisabled(true);
|
|
||||||
goToPageAction->setDisabled(true);
|
|
||||||
// alwaysOnTopAction->setDisabled(true);
|
|
||||||
leftRotationAction->setDisabled(true);
|
|
||||||
rightRotationAction->setDisabled(true);
|
|
||||||
showMagnifyingGlassAction->setDisabled(true);
|
|
||||||
doublePageAction->setDisabled(true);
|
|
||||||
doubleMangaPageAction->setDisabled(true);
|
|
||||||
adjustToFullSizeAction->setDisabled(true);
|
|
||||||
fitToPageAction->setDisabled(true);
|
|
||||||
showZoomSliderlAction->setDisabled(true);
|
|
||||||
increasePageZoomAction->setDisabled(true);
|
|
||||||
decreasePageZoomAction->setDisabled(true);
|
|
||||||
resetZoomAction->setDisabled(true);
|
|
||||||
setBookmarkAction->setDisabled(true);
|
|
||||||
showBookmarksAction->setDisabled(true);
|
|
||||||
showInfoAction->setDisabled(true); // TODO enable goTo and showInfo (or update) when numPages emited
|
|
||||||
openComicOnTheLeftAction->setDisabled(true);
|
|
||||||
openComicOnTheRightAction->setDisabled(true);
|
|
||||||
showDictionaryAction->setDisabled(true);
|
|
||||||
showFlowAction->setDisabled(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::keyPressEvent(QKeyEvent *event)
|
void MainWindowViewer::disablePreviousNextComicActions()
|
||||||
{
|
{
|
||||||
// TODO remove unused keys
|
for (auto *a : { openComicOnTheLeftAction, openComicOnTheRightAction })
|
||||||
int _key = event->key();
|
a->setEnabled(false);
|
||||||
Qt::KeyboardModifiers modifiers = event->modifiers();
|
|
||||||
|
|
||||||
if (modifiers & Qt::ShiftModifier)
|
|
||||||
_key |= Qt::SHIFT;
|
|
||||||
if (modifiers & Qt::ControlModifier)
|
|
||||||
_key |= Qt::CTRL;
|
|
||||||
if (modifiers & Qt::MetaModifier)
|
|
||||||
_key |= Qt::META;
|
|
||||||
if (modifiers & Qt::AltModifier)
|
|
||||||
_key |= Qt::ALT;
|
|
||||||
|
|
||||||
QKeySequence key(_key);
|
|
||||||
|
|
||||||
if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_Y)) {
|
|
||||||
toggleFullScreen();
|
|
||||||
event->accept();
|
|
||||||
} else if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y)) {
|
|
||||||
toggleToolBars();
|
|
||||||
event->accept();
|
|
||||||
} else if (key == ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y)) {
|
|
||||||
toggleWidthHeight();
|
|
||||||
event->accept();
|
|
||||||
} else
|
|
||||||
QWidget::keyPressEvent(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::mouseDoubleClickEvent(QMouseEvent *event)
|
void MainWindowViewer::mouseDoubleClickEvent(QMouseEvent *event)
|
||||||
@ -1238,24 +1146,13 @@ void MainWindowViewer::checkNewVersion()
|
|||||||
|
|
||||||
void MainWindowViewer::processReset()
|
void MainWindowViewer::processReset()
|
||||||
{
|
{
|
||||||
if (isClient) {
|
|
||||||
if (siblingComics.count() > 1) {
|
|
||||||
bool openNextB = openComicOnTheRightAction->isEnabled();
|
|
||||||
bool openPrevB = openComicOnTheLeftAction->isEnabled();
|
|
||||||
disableActions();
|
|
||||||
openComicOnTheRightAction->setEnabled(openNextB);
|
|
||||||
openComicOnTheLeftAction->setEnabled(openPrevB);
|
|
||||||
} else
|
|
||||||
disableActions();
|
|
||||||
} else
|
|
||||||
disableActions();
|
disableActions();
|
||||||
|
if (!isClient || siblingComics.size() <= 1)
|
||||||
|
disablePreviousNextComicActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::setUpShortcutsManagement()
|
void MainWindowViewer::setUpShortcutsManagement()
|
||||||
{
|
{
|
||||||
// actions holder
|
|
||||||
auto orphanActions = new QObject;
|
|
||||||
|
|
||||||
QList<QAction *> allActions;
|
QList<QAction *> allActions;
|
||||||
QList<QAction *> tmpList;
|
QList<QAction *> tmpList;
|
||||||
|
|
||||||
@ -1269,14 +1166,11 @@ void MainWindowViewer::setUpShortcutsManagement()
|
|||||||
|
|
||||||
allActions << tmpList;
|
allActions << tmpList;
|
||||||
|
|
||||||
// keys without actions (General)
|
auto *const toggleFullScreenAction = addActionWithShortcut(tr("Toggle fullscreen mode"), TOGGLE_FULL_SCREEN_ACTION_Y);
|
||||||
QAction *toggleFullScreenAction = new QAction(tr("Toggle fullscreen mode"), orphanActions);
|
connect(toggleFullScreenAction, &QAction::triggered, this, &MainWindowViewer::toggleFullScreen);
|
||||||
toggleFullScreenAction->setData(TOGGLE_FULL_SCREEN_ACTION_Y);
|
|
||||||
toggleFullScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_Y));
|
|
||||||
|
|
||||||
QAction *toggleToolbarsAction = new QAction(tr("Hide/show toolbar"), orphanActions);
|
auto *const toggleToolbarsAction = addActionWithShortcut(tr("Hide/show toolbar"), TOGGLE_TOOL_BARS_ACTION_Y);
|
||||||
toggleToolbarsAction->setData(TOGGLE_TOOL_BARS_ACTION_Y);
|
connect(toggleToolbarsAction, &QAction::triggered, this, &MainWindowViewer::toggleToolBars);
|
||||||
toggleToolbarsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y));
|
|
||||||
|
|
||||||
editShortcutsDialog->addActionsGroup(tr("General"), QIcon(":/images/shortcuts_group_general.png"),
|
editShortcutsDialog->addActionsGroup(tr("General"), QIcon(":/images/shortcuts_group_general.png"),
|
||||||
tmpList = QList<QAction *>()
|
tmpList = QList<QAction *>()
|
||||||
@ -1297,37 +1191,31 @@ void MainWindowViewer::setUpShortcutsManagement()
|
|||||||
|
|
||||||
allActions << tmpList;
|
allActions << tmpList;
|
||||||
|
|
||||||
// keys without actions (MGlass)
|
auto *const sizeUpMglassAction = addActionWithShortcut(tr("Size up magnifying glass"), SIZE_UP_MGLASS_ACTION_Y);
|
||||||
auto sizeUpMglassAction = new QAction(tr("Size up magnifying glass"), orphanActions);
|
connect(sizeUpMglassAction, &QAction::triggered, viewer, &Viewer::magnifyingGlassSizeUp);
|
||||||
sizeUpMglassAction->setData(SIZE_UP_MGLASS_ACTION_Y);
|
|
||||||
sizeUpMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y));
|
|
||||||
|
|
||||||
auto sizeDownMglassAction = new QAction(tr("Size down magnifying glass"), orphanActions);
|
auto *const sizeDownMglassAction = addActionWithShortcut(tr("Size down magnifying glass"), SIZE_DOWN_MGLASS_ACTION_Y);
|
||||||
sizeDownMglassAction->setData(SIZE_DOWN_MGLASS_ACTION_Y);
|
connect(sizeDownMglassAction, &QAction::triggered, viewer, &Viewer::magnifyingGlassSizeDown);
|
||||||
sizeDownMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y));
|
|
||||||
|
|
||||||
auto zoomInMglassAction = new QAction(tr("Zoom in magnifying glass"), orphanActions);
|
auto *const zoomInMglassAction = addActionWithShortcut(tr("Zoom in magnifying glass"), ZOOM_IN_MGLASS_ACTION_Y);
|
||||||
zoomInMglassAction->setData(ZOOM_IN_MGLASS_ACTION_Y);
|
connect(zoomInMglassAction, &QAction::triggered, viewer, &Viewer::magnifyingGlassZoomIn);
|
||||||
zoomInMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y));
|
|
||||||
|
|
||||||
auto zoomOutMglassAction = new QAction(tr("Zoom out magnifying glass"), orphanActions);
|
auto *const zoomOutMglassAction = addActionWithShortcut(tr("Zoom out magnifying glass"), ZOOM_OUT_MGLASS_ACTION_Y);
|
||||||
zoomOutMglassAction->setData(ZOOM_OUT_MGLASS_ACTION_Y);
|
connect(zoomOutMglassAction, &QAction::triggered, viewer, &Viewer::magnifyingGlassZoomOut);
|
||||||
zoomOutMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y));
|
|
||||||
|
mglassActions = { sizeUpMglassAction, sizeDownMglassAction,
|
||||||
|
zoomInMglassAction, zoomOutMglassAction };
|
||||||
|
|
||||||
editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"), QIcon(":/images/shortcuts_group_mglass.png"),
|
editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"), QIcon(":/images/shortcuts_group_mglass.png"),
|
||||||
tmpList = QList<QAction *>()
|
tmpList = QList<QAction *>()
|
||||||
<< showMagnifyingGlassAction
|
<< showMagnifyingGlassAction
|
||||||
<< sizeUpMglassAction
|
<< mglassActions);
|
||||||
<< sizeDownMglassAction
|
|
||||||
<< zoomInMglassAction
|
|
||||||
<< zoomOutMglassAction);
|
|
||||||
|
|
||||||
allActions << tmpList;
|
allActions << tmpList;
|
||||||
|
|
||||||
// keys without actions
|
auto *const toggleFitToScreenAction = addActionWithShortcut(tr("Toggle between fit to width and fit to height"),
|
||||||
auto toggleFitToScreenAction = new QAction(tr("Toggle between fit to width and fit to height"), orphanActions);
|
CHANGE_FIT_ACTION_Y);
|
||||||
toggleFitToScreenAction->setData(CHANGE_FIT_ACTION_Y);
|
connect(toggleFitToScreenAction, &QAction::triggered, this, &MainWindowViewer::toggleWidthHeight);
|
||||||
toggleFitToScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y));
|
|
||||||
|
|
||||||
editShortcutsDialog->addActionsGroup(tr("Page adjustement"), QIcon(":/images/shortcuts_group_page.png"),
|
editShortcutsDialog->addActionsGroup(tr("Page adjustement"), QIcon(":/images/shortcuts_group_page.png"),
|
||||||
tmpList = QList<QAction *>()
|
tmpList = QList<QAction *>()
|
||||||
@ -1346,53 +1234,58 @@ void MainWindowViewer::setUpShortcutsManagement()
|
|||||||
|
|
||||||
allActions << tmpList;
|
allActions << tmpList;
|
||||||
|
|
||||||
auto autoScrollForwardAction = new QAction(tr("Autoscroll down"), orphanActions);
|
auto *const autoScrollForwardAction = addActionWithShortcut(tr("Autoscroll down"), AUTO_SCROLL_FORWARD_ACTION_Y);
|
||||||
autoScrollForwardAction->setData(AUTO_SCROLL_FORWARD_ACTION_Y);
|
connect(autoScrollForwardAction, &QAction::triggered, viewer, &Viewer::scrollForward);
|
||||||
autoScrollForwardAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y));
|
|
||||||
|
|
||||||
auto autoScrollBackwardAction = new QAction(tr("Autoscroll up"), orphanActions);
|
auto *const autoScrollBackwardAction = addActionWithShortcut(tr("Autoscroll up"), AUTO_SCROLL_BACKWARD_ACTION_Y);
|
||||||
autoScrollBackwardAction->setData(AUTO_SCROLL_BACKWARD_ACTION_Y);
|
connect(autoScrollBackwardAction, &QAction::triggered, viewer, &Viewer::scrollBackward);
|
||||||
autoScrollBackwardAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y));
|
|
||||||
|
|
||||||
auto autoScrollForwardHorizontalFirstAction = new QAction(tr("Autoscroll forward, horizontal first"), orphanActions);
|
auto *const autoScrollForwardHorizontalFirstAction = addActionWithShortcut(tr("Autoscroll forward, horizontal first"),
|
||||||
autoScrollForwardHorizontalFirstAction->setData(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y);
|
AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y);
|
||||||
autoScrollForwardHorizontalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_HORIZONTAL_FIRST_ACTION_Y));
|
connect(autoScrollForwardHorizontalFirstAction, &QAction::triggered, viewer, &Viewer::scrollForwardHorizontalFirst);
|
||||||
|
|
||||||
auto autoScrollBackwardHorizontalFirstAction = new QAction(tr("Autoscroll backward, horizontal first"), orphanActions);
|
auto *const autoScrollBackwardHorizontalFirstAction = addActionWithShortcut(tr("Autoscroll backward, horizontal first"),
|
||||||
autoScrollBackwardHorizontalFirstAction->setData(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y);
|
AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y);
|
||||||
autoScrollBackwardHorizontalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_HORIZONTAL_FIRST_ACTION_Y));
|
connect(autoScrollBackwardHorizontalFirstAction, &QAction::triggered, viewer, &Viewer::scrollBackwardHorizontalFirst);
|
||||||
|
|
||||||
auto autoScrollForwardVerticalFirstAction = new QAction(tr("Autoscroll forward, vertical first"), orphanActions);
|
auto *const autoScrollForwardVerticalFirstAction = addActionWithShortcut(tr("Autoscroll forward, vertical first"),
|
||||||
autoScrollForwardVerticalFirstAction->setData(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y);
|
AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y);
|
||||||
autoScrollForwardVerticalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_VERTICAL_FIRST_ACTION_Y));
|
connect(autoScrollForwardVerticalFirstAction, &QAction::triggered, viewer, &Viewer::scrollForwardVerticalFirst);
|
||||||
|
|
||||||
auto autoScrollBackwardVerticalFirstAction = new QAction(tr("Autoscroll backward, vertical first"), orphanActions);
|
auto *const autoScrollBackwardVerticalFirstAction = addActionWithShortcut(tr("Autoscroll backward, vertical first"),
|
||||||
autoScrollBackwardVerticalFirstAction->setData(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y);
|
AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y);
|
||||||
autoScrollBackwardVerticalFirstAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_VERTICAL_FIRST_ACTION_Y));
|
connect(autoScrollBackwardVerticalFirstAction, &QAction::triggered, viewer, &Viewer::scrollBackwardVerticalFirst);
|
||||||
|
|
||||||
auto moveDownAction = new QAction(tr("Move down"), orphanActions);
|
auto *const moveDownAction = addActionWithShortcut(tr("Move down"), MOVE_DOWN_ACTION_Y);
|
||||||
moveDownAction->setData(MOVE_DOWN_ACTION_Y);
|
connect(moveDownAction, &QAction::triggered, viewer, [this] { viewer->moveView(Qt::Key_Down); });
|
||||||
moveDownAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y));
|
|
||||||
|
|
||||||
auto moveUpAction = new QAction(tr("Move up"), orphanActions);
|
auto *const moveUpAction = addActionWithShortcut(tr("Move up"), MOVE_UP_ACTION_Y);
|
||||||
moveUpAction->setData(MOVE_UP_ACTION_Y);
|
connect(moveUpAction, &QAction::triggered, viewer, [this] { viewer->moveView(Qt::Key_Up); });
|
||||||
moveUpAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y));
|
|
||||||
|
|
||||||
auto moveLeftAction = new QAction(tr("Move left"), orphanActions);
|
auto *const moveLeftAction = addActionWithShortcut(tr("Move left"), MOVE_LEFT_ACTION_Y);
|
||||||
moveLeftAction->setData(MOVE_LEFT_ACTION_Y);
|
connect(moveLeftAction, &QAction::triggered, viewer, [this] { viewer->moveView(Qt::Key_Left); });
|
||||||
moveLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y));
|
|
||||||
|
|
||||||
auto moveRightAction = new QAction(tr("Move right"), orphanActions);
|
auto *const moveRightAction = addActionWithShortcut(tr("Move right"), MOVE_RIGHT_ACTION_Y);
|
||||||
moveRightAction->setData(MOVE_RIGHT_ACTION_Y);
|
connect(moveRightAction, &QAction::triggered, viewer, [this] { viewer->moveView(Qt::Key_Right); });
|
||||||
moveRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y));
|
|
||||||
|
|
||||||
auto goToFirstPageAction = new QAction(tr("Go to the first page"), orphanActions);
|
auto *const goToFirstPageAction = addActionWithShortcut(tr("Go to the first page"), GO_TO_FIRST_PAGE_ACTION_Y);
|
||||||
goToFirstPageAction->setData(GO_TO_FIRST_PAGE_ACTION_Y);
|
connect(goToFirstPageAction, &QAction::triggered, viewer, &Viewer::goToFirstPage);
|
||||||
goToFirstPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y));
|
|
||||||
|
|
||||||
auto goToLastPageAction = new QAction(tr("Go to the last page"), orphanActions);
|
auto *const goToLastPageAction = addActionWithShortcut(tr("Go to the last page"), GO_TO_LAST_PAGE_ACTION_Y);
|
||||||
goToLastPageAction->setData(GO_TO_LAST_PAGE_ACTION_Y);
|
connect(goToLastPageAction, &QAction::triggered, viewer, &Viewer::goToLastPage);
|
||||||
goToLastPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y));
|
|
||||||
|
loadedComicActions = { autoScrollForwardAction,
|
||||||
|
autoScrollBackwardAction,
|
||||||
|
autoScrollForwardHorizontalFirstAction,
|
||||||
|
autoScrollBackwardHorizontalFirstAction,
|
||||||
|
autoScrollForwardVerticalFirstAction,
|
||||||
|
autoScrollBackwardVerticalFirstAction,
|
||||||
|
moveDownAction,
|
||||||
|
moveUpAction,
|
||||||
|
moveLeftAction,
|
||||||
|
moveRightAction,
|
||||||
|
goToFirstPageAction,
|
||||||
|
goToLastPageAction };
|
||||||
|
|
||||||
editShortcutsDialog->addActionsGroup(tr("Reading"), QIcon(":/images/shortcuts_group_reading.png"),
|
editShortcutsDialog->addActionsGroup(tr("Reading"), QIcon(":/images/shortcuts_group_reading.png"),
|
||||||
tmpList = QList<QAction *>()
|
tmpList = QList<QAction *>()
|
||||||
@ -1400,18 +1293,7 @@ void MainWindowViewer::setUpShortcutsManagement()
|
|||||||
<< goToPageOnTheLeftAction
|
<< goToPageOnTheLeftAction
|
||||||
<< setBookmarkAction
|
<< setBookmarkAction
|
||||||
<< showBookmarksAction
|
<< showBookmarksAction
|
||||||
<< autoScrollForwardAction
|
<< loadedComicActions
|
||||||
<< autoScrollBackwardAction
|
|
||||||
<< autoScrollForwardHorizontalFirstAction
|
|
||||||
<< autoScrollBackwardHorizontalFirstAction
|
|
||||||
<< autoScrollForwardVerticalFirstAction
|
|
||||||
<< autoScrollBackwardVerticalFirstAction
|
|
||||||
<< moveDownAction
|
|
||||||
<< moveUpAction
|
|
||||||
<< moveLeftAction
|
|
||||||
<< moveRightAction
|
|
||||||
<< goToFirstPageAction
|
|
||||||
<< goToLastPageAction
|
|
||||||
<< goToPageAction);
|
<< goToPageAction);
|
||||||
|
|
||||||
allActions << tmpList;
|
allActions << tmpList;
|
||||||
@ -1608,6 +1490,46 @@ void MainWindowViewer::getSiblingComics(QString path, QString currentComic)
|
|||||||
updatePrevNextActions(index > 0, index + 1 < list.count());
|
updatePrevNextActions(index > 0, index + 1 < list.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowViewer::setActionsEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
// TODO enable goTo and showInfo (or update) when numPages emited
|
||||||
|
const auto actions = { saveImageAction,
|
||||||
|
goToPageOnTheLeftAction,
|
||||||
|
goToPageOnTheRightAction,
|
||||||
|
adjustHeightAction,
|
||||||
|
adjustWidthAction,
|
||||||
|
goToPageAction,
|
||||||
|
leftRotationAction,
|
||||||
|
rightRotationAction,
|
||||||
|
showMagnifyingGlassAction,
|
||||||
|
doublePageAction,
|
||||||
|
doubleMangaPageAction,
|
||||||
|
adjustToFullSizeAction,
|
||||||
|
fitToPageAction,
|
||||||
|
showZoomSliderlAction,
|
||||||
|
increasePageZoomAction,
|
||||||
|
decreasePageZoomAction,
|
||||||
|
resetZoomAction,
|
||||||
|
showBookmarksAction,
|
||||||
|
showInfoAction,
|
||||||
|
showDictionaryAction,
|
||||||
|
showFlowAction };
|
||||||
|
for (auto *a : actions)
|
||||||
|
a->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowViewer::setMglassActionsEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
for (auto *a : std::as_const(mglassActions))
|
||||||
|
a->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindowViewer::setLoadedComicActionsEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
for (auto *a : std::as_const(loadedComicActions))
|
||||||
|
a->setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowViewer::dropEvent(QDropEvent *event)
|
void MainWindowViewer::dropEvent(QDropEvent *event)
|
||||||
{
|
{
|
||||||
QList<QUrl> urlList;
|
QList<QUrl> urlList;
|
||||||
@ -1644,18 +1566,6 @@ void MainWindowViewer::dragEnterEvent(QDragEnterEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::alwaysOnTopSwitch()
|
|
||||||
{
|
|
||||||
if (!Configuration::getConfiguration().getAlwaysOnTop()) {
|
|
||||||
setWindowFlags(this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); // always on top
|
|
||||||
show();
|
|
||||||
} else {
|
|
||||||
setWindowFlags(this->windowFlags() ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
Configuration::getConfiguration().setAlwaysOnTop(!Configuration::getConfiguration().getAlwaysOnTop());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindowViewer::adjustToFullSizeSwitch()
|
void MainWindowViewer::adjustToFullSizeSwitch()
|
||||||
{
|
{
|
||||||
Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullRes);
|
Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullRes);
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -46,6 +45,7 @@ public slots:
|
|||||||
void showToolBars();
|
void showToolBars();
|
||||||
void enableActions();
|
void enableActions();
|
||||||
void disableActions();
|
void disableActions();
|
||||||
|
void disablePreviousNextComicActions();
|
||||||
void toggleFullScreen();
|
void toggleFullScreen();
|
||||||
void toFullScreen();
|
void toFullScreen();
|
||||||
void toNormal();
|
void toNormal();
|
||||||
@ -60,7 +60,6 @@ public slots:
|
|||||||
void openComic(QString pathFile);
|
void openComic(QString pathFile);
|
||||||
void openFolderFromPath(QString pathDir);
|
void openFolderFromPath(QString pathDir);
|
||||||
void openFolderFromPath(QString pathFile, QString atFileName);
|
void openFolderFromPath(QString pathFile, QString atFileName);
|
||||||
void alwaysOnTopSwitch();
|
|
||||||
void adjustToFullSizeSwitch();
|
void adjustToFullSizeSwitch();
|
||||||
void fitToPageSwitch();
|
void fitToPageSwitch();
|
||||||
void resetZoomLevel();
|
void resetZoomLevel();
|
||||||
@ -86,7 +85,6 @@ private:
|
|||||||
//! State
|
//! State
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool toolbars;
|
bool toolbars;
|
||||||
bool alwaysOnTop;
|
|
||||||
bool fromMaximized;
|
bool fromMaximized;
|
||||||
|
|
||||||
// QTBUG-41883
|
// QTBUG-41883
|
||||||
@ -140,7 +138,6 @@ private:
|
|||||||
QAction *doubleMangaPageAction;
|
QAction *doubleMangaPageAction;
|
||||||
QAction *showShorcutsAction;
|
QAction *showShorcutsAction;
|
||||||
QAction *showDictionaryAction;
|
QAction *showDictionaryAction;
|
||||||
QAction *alwaysOnTopAction;
|
|
||||||
QAction *adjustToFullSizeAction;
|
QAction *adjustToFullSizeAction;
|
||||||
QAction *fitToPageAction;
|
QAction *fitToPageAction;
|
||||||
QAction *resetZoomAction;
|
QAction *resetZoomAction;
|
||||||
@ -151,6 +148,9 @@ private:
|
|||||||
|
|
||||||
QAction *showEditShortcutsAction;
|
QAction *showEditShortcutsAction;
|
||||||
|
|
||||||
|
QList<QAction *> mglassActions;
|
||||||
|
QList<QAction *> loadedComicActions;
|
||||||
|
|
||||||
YACReaderSlider *zoomSliderAction;
|
YACReaderSlider *zoomSliderAction;
|
||||||
|
|
||||||
HttpVersionChecker *versionChecker;
|
HttpVersionChecker *versionChecker;
|
||||||
@ -159,13 +159,16 @@ private:
|
|||||||
//! Método que inicializa el interfaz.
|
//! Método que inicializa el interfaz.
|
||||||
void setupUI();
|
void setupUI();
|
||||||
void createActions();
|
void createActions();
|
||||||
|
QAction *addActionWithShortcut(const QString &text, const QString &shortcutKey);
|
||||||
void createToolBars();
|
void createToolBars();
|
||||||
void refreshRecentFilesActionList();
|
void refreshRecentFilesActionList();
|
||||||
void clearRecentFiles();
|
void clearRecentFiles();
|
||||||
void getSiblingComics(QString path, QString currentComic);
|
void getSiblingComics(QString path, QString currentComic);
|
||||||
|
void setActionsEnabled(bool enabled);
|
||||||
|
void setMglassActionsEnabled(bool enabled);
|
||||||
|
void setLoadedComicActionsEnabled(bool enabled);
|
||||||
|
|
||||||
//! Manejadores de evento:
|
//! Manejadores de evento:
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
|
||||||
// void resizeEvent(QResizeEvent * event);
|
// void resizeEvent(QResizeEvent * event);
|
||||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||||
void dropEvent(QDropEvent *event) override;
|
void dropEvent(QDropEvent *event) override;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "opengl_checker.h"
|
#include "opengl_checker.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
#include <QsLog.h>
|
#include <QsLog.h>
|
||||||
|
|
||||||
@ -34,10 +35,9 @@ Viewer::Viewer(QWidget *parent)
|
|||||||
wheelStop(false),
|
wheelStop(false),
|
||||||
direction(1),
|
direction(1),
|
||||||
drag(false),
|
drag(false),
|
||||||
numScrollSteps(22),
|
|
||||||
shouldOpenNext(false),
|
shouldOpenNext(false),
|
||||||
shouldOpenPrevious(false),
|
shouldOpenPrevious(false),
|
||||||
magnifyingGlassShowed(false),
|
magnifyingGlassShown(false),
|
||||||
restoreMagnifyingGlass(false)
|
restoreMagnifyingGlass(false)
|
||||||
{
|
{
|
||||||
translator = new YACReaderTranslator(this);
|
translator = new YACReaderTranslator(this);
|
||||||
@ -155,6 +155,11 @@ void Viewer::createConnections()
|
|||||||
// magnifyingGlass (update mg after a background change
|
// magnifyingGlass (update mg after a background change
|
||||||
connect(this, &Viewer::backgroundChanges, mglass, QOverload<>::of(&MagnifyingGlass::updateImage));
|
connect(this, &Viewer::backgroundChanges, mglass, QOverload<>::of(&MagnifyingGlass::updateImage));
|
||||||
|
|
||||||
|
connect(this, &Viewer::magnifyingGlassSizeUp, mglass, &MagnifyingGlass::sizeUp);
|
||||||
|
connect(this, &Viewer::magnifyingGlassSizeDown, mglass, &MagnifyingGlass::sizeDown);
|
||||||
|
connect(this, &Viewer::magnifyingGlassZoomIn, mglass, &MagnifyingGlass::zoomIn);
|
||||||
|
connect(this, &Viewer::magnifyingGlassZoomOut, mglass, &MagnifyingGlass::zoomOut);
|
||||||
|
|
||||||
// goToDialog
|
// goToDialog
|
||||||
connect(goToDialog, &GoToDialog::goToPage, this, &Viewer::goTo);
|
connect(goToDialog, &GoToDialog::goToPage, this, &Viewer::goTo);
|
||||||
|
|
||||||
@ -179,6 +184,7 @@ void Viewer::createConnections()
|
|||||||
connect(render, &Render::crcError, this, &Viewer::processCRCError);
|
connect(render, &Render::crcError, this, &Viewer::processCRCError);
|
||||||
connect(render, QOverload<unsigned int>::of(&Render::numPages), goToFlow, &GoToFlowWidget::setNumSlides);
|
connect(render, QOverload<unsigned int>::of(&Render::numPages), goToFlow, &GoToFlowWidget::setNumSlides);
|
||||||
connect(render, QOverload<unsigned int>::of(&Render::numPages), goToDialog, &GoToDialog::setNumPages);
|
connect(render, QOverload<unsigned int>::of(&Render::numPages), goToDialog, &GoToDialog::setNumPages);
|
||||||
|
connect(render, qOverload<unsigned int>(&Render::numPages), this, &Viewer::comicLoaded);
|
||||||
connect(render, QOverload<int, const QByteArray &>::of(&Render::imageLoaded), goToFlow, &GoToFlowWidget::setImageReady);
|
connect(render, QOverload<int, const QByteArray &>::of(&Render::imageLoaded), goToFlow, &GoToFlowWidget::setImageReady);
|
||||||
connect(render, &Render::currentPageReady, this, &Viewer::updatePage);
|
connect(render, &Render::currentPageReady, this, &Viewer::updatePage);
|
||||||
connect(render, &Render::processingPage, this, &Viewer::setLoadingMessage);
|
connect(render, &Render::processingPage, this, &Viewer::setLoadingMessage);
|
||||||
@ -285,6 +291,14 @@ void Viewer::showGoToDialog()
|
|||||||
{
|
{
|
||||||
goToDialog->open();
|
goToDialog->open();
|
||||||
}
|
}
|
||||||
|
void Viewer::goToFirstPage()
|
||||||
|
{
|
||||||
|
goTo(0);
|
||||||
|
}
|
||||||
|
void Viewer::goToLastPage()
|
||||||
|
{
|
||||||
|
goTo(this->render->numPages() - 1);
|
||||||
|
}
|
||||||
void Viewer::goTo(unsigned int page)
|
void Viewer::goTo(unsigned int page)
|
||||||
{
|
{
|
||||||
direction = 1; // in "go to" direction is always fordward
|
direction = 1; // in "go to" direction is always fordward
|
||||||
@ -457,6 +471,18 @@ void Viewer::scrollUp()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Viewer::scrollForward()
|
||||||
|
{
|
||||||
|
nextPos = verticalScrollBar()->sliderPosition() + verticalScrollStep();
|
||||||
|
scrollDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Viewer::scrollBackward()
|
||||||
|
{
|
||||||
|
nextPos = verticalScrollBar()->sliderPosition() - verticalScrollStep();
|
||||||
|
scrollUp();
|
||||||
|
}
|
||||||
|
|
||||||
void Viewer::scrollForwardHorizontalFirst()
|
void Viewer::scrollForwardHorizontalFirst()
|
||||||
{
|
{
|
||||||
if (!doubleMangaPage) {
|
if (!doubleMangaPage) {
|
||||||
@ -493,6 +519,18 @@ void Viewer::scrollBackwardVerticalFirst()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr auto relativeScrollStep = 0.80;
|
||||||
|
|
||||||
|
int Viewer::verticalScrollStep() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(height() * relativeScrollStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Viewer::horizontalScrollStep() const
|
||||||
|
{
|
||||||
|
return static_cast<int>(width() * relativeScrollStep);
|
||||||
|
}
|
||||||
|
|
||||||
bool Viewer::isEdge(scrollDirection d)
|
bool Viewer::isEdge(scrollDirection d)
|
||||||
{
|
{
|
||||||
if (d == UP)
|
if (d == UP)
|
||||||
@ -510,15 +548,15 @@ void Viewer::scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward)
|
|||||||
if (!isEdge(d1)) {
|
if (!isEdge(d1)) {
|
||||||
if (d1 == UP)
|
if (d1 == UP)
|
||||||
scrollTo(horizontalScrollBar()->sliderPosition(),
|
scrollTo(horizontalScrollBar()->sliderPosition(),
|
||||||
verticalScrollBar()->sliderPosition() - static_cast<int>((height() * 0.80)));
|
verticalScrollBar()->sliderPosition() - verticalScrollStep());
|
||||||
else if (d1 == DOWN)
|
else if (d1 == DOWN)
|
||||||
scrollTo(horizontalScrollBar()->sliderPosition(),
|
scrollTo(horizontalScrollBar()->sliderPosition(),
|
||||||
verticalScrollBar()->sliderPosition() + static_cast<int>((height() * 0.80)));
|
verticalScrollBar()->sliderPosition() + verticalScrollStep());
|
||||||
else if (d1 == LEFT)
|
else if (d1 == LEFT)
|
||||||
scrollTo(horizontalScrollBar()->sliderPosition() - static_cast<int>((width() * 0.80)),
|
scrollTo(horizontalScrollBar()->sliderPosition() - horizontalScrollStep(),
|
||||||
verticalScrollBar()->sliderPosition());
|
verticalScrollBar()->sliderPosition());
|
||||||
else // d1 == RIGHT
|
else // d1 == RIGHT
|
||||||
scrollTo(horizontalScrollBar()->sliderPosition() + static_cast<int>((width() * 0.80)),
|
scrollTo(horizontalScrollBar()->sliderPosition() + horizontalScrollStep(),
|
||||||
verticalScrollBar()->sliderPosition());
|
verticalScrollBar()->sliderPosition());
|
||||||
} else if (!isEdge(d2)) {
|
} else if (!isEdge(d2)) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
@ -534,13 +572,13 @@ void Viewer::scrollZigzag(scrollDirection d1, scrollDirection d2, bool forward)
|
|||||||
x = horizontalScrollBar()->minimum();
|
x = horizontalScrollBar()->minimum();
|
||||||
|
|
||||||
if (d2 == UP)
|
if (d2 == UP)
|
||||||
y = std::max(verticalScrollBar()->sliderPosition() - static_cast<int>((height() * 0.80)), verticalScrollBar()->minimum());
|
y = std::max(verticalScrollBar()->sliderPosition() - verticalScrollStep(), verticalScrollBar()->minimum());
|
||||||
else if (d2 == DOWN)
|
else if (d2 == DOWN)
|
||||||
y = std::min(verticalScrollBar()->sliderPosition() + static_cast<int>((height() * 0.80)), verticalScrollBar()->maximum());
|
y = std::min(verticalScrollBar()->sliderPosition() + verticalScrollStep(), verticalScrollBar()->maximum());
|
||||||
else if (d2 == LEFT)
|
else if (d2 == LEFT)
|
||||||
x = std::max(horizontalScrollBar()->sliderPosition() - static_cast<int>((width() * 0.80)), horizontalScrollBar()->minimum());
|
x = std::max(horizontalScrollBar()->sliderPosition() - horizontalScrollStep(), horizontalScrollBar()->minimum());
|
||||||
else // d2 == RIGHT
|
else // d2 == RIGHT
|
||||||
x = std::min(horizontalScrollBar()->sliderPosition() + static_cast<int>((width() * 0.80)), horizontalScrollBar()->maximum());
|
x = std::min(horizontalScrollBar()->sliderPosition() + horizontalScrollStep(), horizontalScrollBar()->maximum());
|
||||||
|
|
||||||
scrollTo(x, y);
|
scrollTo(x, y);
|
||||||
} else {
|
} else {
|
||||||
@ -576,101 +614,13 @@ void Viewer::scrollTo(int x, int y)
|
|||||||
emit backgroundChanges();
|
emit backgroundChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::keyPressEvent(QKeyEvent *event)
|
void Viewer::moveView(Qt::Key directionKey)
|
||||||
{
|
{
|
||||||
if (render->hasLoadedComic()) {
|
QKeyEvent event(QEvent::KeyPress, directionKey, Qt::NoModifier);
|
||||||
int _key = event->key();
|
QAbstractScrollArea::keyPressEvent(&event);
|
||||||
Qt::KeyboardModifiers modifiers = event->modifiers();
|
|
||||||
|
|
||||||
if (modifiers & Qt::ShiftModifier)
|
|
||||||
_key |= Qt::SHIFT;
|
|
||||||
if (modifiers & Qt::ControlModifier)
|
|
||||||
_key |= Qt::CTRL;
|
|
||||||
if (modifiers & Qt::MetaModifier)
|
|
||||||
_key |= Qt::META;
|
|
||||||
if (modifiers & Qt::AltModifier)
|
|
||||||
_key |= Qt::ALT;
|
|
||||||
|
|
||||||
QKeySequence key(_key);
|
|
||||||
/*if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
|
|
||||||
QCoreApplication::sendEvent(goToFlow,event);
|
|
||||||
else*/
|
|
||||||
|
|
||||||
if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y)) {
|
|
||||||
posByStep = height() / numScrollSteps;
|
|
||||||
nextPos = verticalScrollBar()->sliderPosition() + static_cast<int>((height() * 0.80));
|
|
||||||
scrollDown();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y)) {
|
|
||||||
posByStep = height() / numScrollSteps;
|
|
||||||
nextPos = verticalScrollBar()->sliderPosition() - static_cast<int>((height() * 0.80));
|
|
||||||
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) ||
|
|
||||||
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y)) {
|
|
||||||
moveAction(key);
|
|
||||||
emit backgroundChanges();
|
emit backgroundChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y)) {
|
|
||||||
goTo(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y)) {
|
|
||||||
goTo(this->render->numPages() - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
QAbstractScrollArea::keyPressEvent(event);
|
|
||||||
|
|
||||||
if (mglass->isVisible() && (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y) || key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y) || key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y) || key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y))) {
|
|
||||||
QCoreApplication::sendEvent(mglass, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else
|
|
||||||
QAbstractScrollArea::keyPressEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Viewer::moveAction(const QKeySequence &key)
|
|
||||||
{
|
|
||||||
int _key = 0;
|
|
||||||
|
|
||||||
if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y))
|
|
||||||
_key = Qt::Key_Down;
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y))
|
|
||||||
_key = Qt::Key_Up;
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y))
|
|
||||||
_key = Qt::Key_Left;
|
|
||||||
|
|
||||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y))
|
|
||||||
_key = Qt::Key_Right;
|
|
||||||
|
|
||||||
QKeyEvent _event = QKeyEvent(QEvent::KeyPress, _key, Qt::NoModifier);
|
|
||||||
QAbstractScrollArea::keyPressEvent(&_event);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void animateScroll(QPropertyAnimation &scroller, const QScrollBar &scrollBar, int delta)
|
static void animateScroll(QPropertyAnimation &scroller, const QScrollBar &scrollBar, int delta)
|
||||||
{
|
{
|
||||||
int deltaNotFinished = 0;
|
int deltaNotFinished = 0;
|
||||||
@ -744,7 +694,7 @@ void Viewer::mouseMoveEvent(QMouseEvent *event)
|
|||||||
showCursor();
|
showCursor();
|
||||||
hideCursorTimer->start(2500);
|
hideCursorTimer->start(2500);
|
||||||
|
|
||||||
if (magnifyingGlassShowed)
|
if (magnifyingGlassShown)
|
||||||
mglass->move(static_cast<int>(event->x() - float(mglass->width()) / 2), static_cast<int>(event->y() - float(mglass->height()) / 2));
|
mglass->move(static_cast<int>(event->x() - float(mglass->width()) / 2), static_cast<int>(event->y() - float(mglass->height()) / 2));
|
||||||
|
|
||||||
if (render->hasLoadedComic()) {
|
if (render->hasLoadedComic()) {
|
||||||
@ -777,7 +727,7 @@ void Viewer::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPixmap Viewer::pixmap()
|
QPixmap Viewer::pixmap() const
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
return content->pixmap();
|
return content->pixmap();
|
||||||
@ -788,7 +738,7 @@ const QPixmap Viewer::pixmap()
|
|||||||
|
|
||||||
void Viewer::magnifyingGlassSwitch()
|
void Viewer::magnifyingGlassSwitch()
|
||||||
{
|
{
|
||||||
magnifyingGlassShowed ? hideMagnifyingGlass() : showMagnifyingGlass();
|
magnifyingGlassShown ? hideMagnifyingGlass() : showMagnifyingGlass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::showMagnifyingGlass()
|
void Viewer::showMagnifyingGlass()
|
||||||
@ -799,14 +749,22 @@ void Viewer::showMagnifyingGlass()
|
|||||||
mglass->move(static_cast<int>(p.x() - float(mglass->width()) / 2), static_cast<int>(p.y() - float(mglass->height()) / 2));
|
mglass->move(static_cast<int>(p.x() - float(mglass->width()) / 2), static_cast<int>(p.y() - float(mglass->height()) / 2));
|
||||||
mglass->show();
|
mglass->show();
|
||||||
mglass->updateImage(mglass->x() + mglass->width() / 2, mglass->y() + mglass->height() / 2);
|
mglass->updateImage(mglass->x() + mglass->width() / 2, mglass->y() + mglass->height() / 2);
|
||||||
magnifyingGlassShowed = true;
|
setMagnifyingGlassShown(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::hideMagnifyingGlass()
|
void Viewer::hideMagnifyingGlass()
|
||||||
{
|
{
|
||||||
mglass->hide();
|
mglass->hide();
|
||||||
magnifyingGlassShowed = false;
|
setMagnifyingGlassShown(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Viewer::setMagnifyingGlassShown(bool shown)
|
||||||
|
{
|
||||||
|
if (magnifyingGlassShown != shown) {
|
||||||
|
magnifyingGlassShown = shown;
|
||||||
|
emit magnifyingGlassVisibilityChanged(magnifyingGlassShown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Viewer::informationSwitch()
|
void Viewer::informationSwitch()
|
||||||
@ -961,7 +919,7 @@ void Viewer::resetContent()
|
|||||||
|
|
||||||
void Viewer::setLoadingMessage()
|
void Viewer::setLoadingMessage()
|
||||||
{
|
{
|
||||||
if (magnifyingGlassShowed) {
|
if (magnifyingGlassShown) {
|
||||||
hideMagnifyingGlass();
|
hideMagnifyingGlass();
|
||||||
restoreMagnifyingGlass = true;
|
restoreMagnifyingGlass = true;
|
||||||
}
|
}
|
||||||
@ -971,7 +929,7 @@ void Viewer::setLoadingMessage()
|
|||||||
|
|
||||||
void Viewer::setPageUnavailableMessage()
|
void Viewer::setPageUnavailableMessage()
|
||||||
{
|
{
|
||||||
if (magnifyingGlassShowed) {
|
if (magnifyingGlassShown) {
|
||||||
hideMagnifyingGlass();
|
hideMagnifyingGlass();
|
||||||
restoreMagnifyingGlass = true;
|
restoreMagnifyingGlass = true;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QKeyEvent>
|
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
@ -51,6 +50,8 @@ public slots:
|
|||||||
void left();
|
void left();
|
||||||
void right();
|
void right();
|
||||||
void showGoToDialog();
|
void showGoToDialog();
|
||||||
|
void goToFirstPage();
|
||||||
|
void goToLastPage();
|
||||||
void goTo(unsigned int page);
|
void goTo(unsigned int page);
|
||||||
void updatePage();
|
void updatePage();
|
||||||
void updateContentSize();
|
void updateContentSize();
|
||||||
@ -58,6 +59,8 @@ public slots:
|
|||||||
void updateOptions();
|
void updateOptions();
|
||||||
void scrollDown();
|
void scrollDown();
|
||||||
void scrollUp();
|
void scrollUp();
|
||||||
|
void scrollForward();
|
||||||
|
void scrollBackward();
|
||||||
void scrollForwardHorizontalFirst();
|
void scrollForwardHorizontalFirst();
|
||||||
void scrollBackwardHorizontalFirst();
|
void scrollBackwardHorizontalFirst();
|
||||||
void scrollForwardVerticalFirst();
|
void scrollForwardVerticalFirst();
|
||||||
@ -74,7 +77,7 @@ public slots:
|
|||||||
void animateHideGoToFlow();
|
void animateHideGoToFlow();
|
||||||
void rotateLeft();
|
void rotateLeft();
|
||||||
void rotateRight();
|
void rotateRight();
|
||||||
bool magnifyingGlassIsVisible() { return magnifyingGlassShowed; }
|
bool magnifyingGlassIsVisible() const { return magnifyingGlassShown; }
|
||||||
void setBookmark(bool);
|
void setBookmark(bool);
|
||||||
void save();
|
void save();
|
||||||
void doublePageSwitch();
|
void doublePageSwitch();
|
||||||
@ -119,7 +122,6 @@ private:
|
|||||||
QPropertyAnimation *verticalScroller;
|
QPropertyAnimation *verticalScroller;
|
||||||
QPropertyAnimation *horizontalScroller;
|
QPropertyAnimation *horizontalScroller;
|
||||||
QParallelAnimationGroup *groupScroller;
|
QParallelAnimationGroup *groupScroller;
|
||||||
int posByStep;
|
|
||||||
int nextPos;
|
int nextPos;
|
||||||
GoToFlowWidget *goToFlow;
|
GoToFlowWidget *goToFlow;
|
||||||
QPropertyAnimation *showGoToFlowAnimation;
|
QPropertyAnimation *showGoToFlowAnimation;
|
||||||
@ -135,7 +137,6 @@ private:
|
|||||||
QTimer *hideCursorTimer;
|
QTimer *hideCursorTimer;
|
||||||
int direction;
|
int direction;
|
||||||
bool drag;
|
bool drag;
|
||||||
int numScrollSteps;
|
|
||||||
|
|
||||||
//! Widgets
|
//! Widgets
|
||||||
QLabel *content;
|
QLabel *content;
|
||||||
@ -155,16 +156,17 @@ private:
|
|||||||
private:
|
private:
|
||||||
//! Magnifying glass
|
//! Magnifying glass
|
||||||
MagnifyingGlass *mglass;
|
MagnifyingGlass *mglass;
|
||||||
bool magnifyingGlassShowed;
|
bool magnifyingGlassShown;
|
||||||
bool restoreMagnifyingGlass;
|
bool restoreMagnifyingGlass;
|
||||||
|
void setMagnifyingGlassShown(bool shown);
|
||||||
|
|
||||||
//! Manejadores de evento:
|
//! Manejadores de evento:
|
||||||
void keyPressEvent(QKeyEvent *event) override;
|
|
||||||
void resizeEvent(QResizeEvent *event) override;
|
void resizeEvent(QResizeEvent *event) override;
|
||||||
void wheelEvent(QWheelEvent *event) override;
|
void wheelEvent(QWheelEvent *event) override;
|
||||||
void mouseMoveEvent(QMouseEvent *event) override;
|
void mouseMoveEvent(QMouseEvent *event) override;
|
||||||
|
|
||||||
void moveAction(const QKeySequence &key);
|
int verticalScrollStep() const;
|
||||||
|
int horizontalScrollStep() const;
|
||||||
|
|
||||||
//! ZigzagScroll
|
//! ZigzagScroll
|
||||||
enum scrollDirection { UP,
|
enum scrollDirection { UP,
|
||||||
@ -178,20 +180,30 @@ private:
|
|||||||
public:
|
public:
|
||||||
Viewer(QWidget *parent = nullptr);
|
Viewer(QWidget *parent = nullptr);
|
||||||
~Viewer();
|
~Viewer();
|
||||||
const QPixmap pixmap();
|
QPixmap pixmap() const;
|
||||||
// Comic * getComic(){return comic;}
|
// Comic * getComic(){return comic;}
|
||||||
const BookmarksDialog *getBookmarksDialog() { return bd; }
|
const BookmarksDialog *getBookmarksDialog() { return bd; }
|
||||||
// returns the current index starting in 1 [1,nPages]
|
// returns the current index starting in 1 [1,nPages]
|
||||||
unsigned int getIndex();
|
unsigned int getIndex();
|
||||||
void updateComic(ComicDB &comic);
|
void updateComic(ComicDB &comic);
|
||||||
|
void moveView(Qt::Key directionKey);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void backgroundChanges();
|
void backgroundChanges();
|
||||||
void pageAvailable(bool);
|
void pageAvailable(bool);
|
||||||
void pageIsBookmark(bool);
|
void pageIsBookmark(bool);
|
||||||
|
void comicLoaded();
|
||||||
void reset();
|
void reset();
|
||||||
void openNextComic();
|
void openNextComic();
|
||||||
void openPreviousComic();
|
void openPreviousComic();
|
||||||
void zoomUpdated(int);
|
void zoomUpdated(int);
|
||||||
|
void magnifyingGlassVisibilityChanged(bool visible);
|
||||||
|
|
||||||
|
// The following signals are emitted by users of this class and propagated to mglass.
|
||||||
|
void magnifyingGlassSizeUp();
|
||||||
|
void magnifyingGlassSizeDown();
|
||||||
|
void magnifyingGlassZoomIn();
|
||||||
|
void magnifyingGlassZoomOut();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE"
|
#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE"
|
||||||
#define COVER_IS_SP "COVER_IS_SP"
|
#define COVER_IS_SP "COVER_IS_SP"
|
||||||
#define BACKGROUND_COLOR "BACKGROUND_COLOR"
|
#define BACKGROUND_COLOR "BACKGROUND_COLOR"
|
||||||
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
|
|
||||||
#define SHOW_TOOLBARS "SHOW_TOOLBARS"
|
#define SHOW_TOOLBARS "SHOW_TOOLBARS"
|
||||||
#define BRIGHTNESS "BRIGHTNESS"
|
#define BRIGHTNESS "BRIGHTNESS"
|
||||||
#define CONTRAST "CONTRAST"
|
#define CONTRAST "CONTRAST"
|
||||||
|
@ -52,7 +52,6 @@ void ShortcutsManager::initDefaultShorcuts()
|
|||||||
defaultShorcuts.insert(SHOW_INFO_ACTION_Y, Qt::Key_I);
|
defaultShorcuts.insert(SHOW_INFO_ACTION_Y, Qt::Key_I);
|
||||||
defaultShorcuts.insert(CLOSE_ACTION_Y, Qt::Key_Escape);
|
defaultShorcuts.insert(CLOSE_ACTION_Y, Qt::Key_Escape);
|
||||||
defaultShorcuts.insert(SHOW_DICTIONARY_ACTION_Y, Qt::Key_T);
|
defaultShorcuts.insert(SHOW_DICTIONARY_ACTION_Y, Qt::Key_T);
|
||||||
defaultShorcuts.insert(ALWAYS_ON_TOP_ACTION_Y, Qt::Key_Q); // deprecated
|
|
||||||
defaultShorcuts.insert(ADJUST_TO_FULL_SIZE_ACTION_Y, Qt::Key_W);
|
defaultShorcuts.insert(ADJUST_TO_FULL_SIZE_ACTION_Y, Qt::Key_W);
|
||||||
defaultShorcuts.insert(SHOW_FLOW_ACTION_Y, Qt::Key_S);
|
defaultShorcuts.insert(SHOW_FLOW_ACTION_Y, Qt::Key_S);
|
||||||
defaultShorcuts.insert(ZOOM_PLUS_ACTION_Y, Qt::Key_Plus);
|
defaultShorcuts.insert(ZOOM_PLUS_ACTION_Y, Qt::Key_Plus);
|
||||||
|
@ -116,7 +116,6 @@ public:
|
|||||||
#define SHOW_INFO_ACTION_Y "SHOW_INFO_ACTION_Y"
|
#define SHOW_INFO_ACTION_Y "SHOW_INFO_ACTION_Y"
|
||||||
#define CLOSE_ACTION_Y "CLOSE_ACTION_Y"
|
#define CLOSE_ACTION_Y "CLOSE_ACTION_Y"
|
||||||
#define SHOW_DICTIONARY_ACTION_Y "SHOW_DICTIONARY_ACTION_Y"
|
#define SHOW_DICTIONARY_ACTION_Y "SHOW_DICTIONARY_ACTION_Y"
|
||||||
#define ALWAYS_ON_TOP_ACTION_Y "ALWAYS_ON_TOP_ACTION_Y"
|
|
||||||
#define ADJUST_TO_FULL_SIZE_ACTION_Y "ADJUST_TO_FULL_SIZE_ACTION_Y"
|
#define ADJUST_TO_FULL_SIZE_ACTION_Y "ADJUST_TO_FULL_SIZE_ACTION_Y"
|
||||||
#define FIT_TO_PAGE_ACTION_Y "FIT_TO_PAGE_ACTION_Y"
|
#define FIT_TO_PAGE_ACTION_Y "FIT_TO_PAGE_ACTION_Y"
|
||||||
#define SHOW_FLOW_ACTION_Y "SHOW_FLOW_ACTION_Y"
|
#define SHOW_FLOW_ACTION_Y "SHOW_FLOW_ACTION_Y"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user