merged
@ -8,5 +8,5 @@ Terminal=false
|
|||||||
Type=Application
|
Type=Application
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
Categories=Graphics;Viewer;
|
Categories=Graphics;Viewer;
|
||||||
MimeType=application/x-cbz;application/x-cbr;application/x-cbt;application/x-cb7;
|
MimeType=application/x-cbz;application/x-cbr;application/x-cbt;application/x-cb7;application/x-pdf;application/x-zip;application/x-rar;application/x-7z;inode/directory;
|
||||||
X-Desktop-File-Install-Version=0.22
|
X-Desktop-File-Install-Version=0.22
|
||||||
|
@ -134,6 +134,7 @@ SOURCES += $$PWD/../common/comic.cpp \
|
|||||||
|
|
||||||
include($$PWD/../custom_widgets/custom_widgets_yacreader.pri)
|
include($$PWD/../custom_widgets/custom_widgets_yacreader.pri)
|
||||||
include($$PWD/../compressed_archive/wrapper.pri)
|
include($$PWD/../compressed_archive/wrapper.pri)
|
||||||
|
include($$PWD/../shortcuts_management/shortcuts_management.pri)
|
||||||
|
|
||||||
RESOURCES += $$PWD/yacreader_images.qrc \
|
RESOURCES += $$PWD/yacreader_images.qrc \
|
||||||
$$PWD/yacreader_files.qrc
|
$$PWD/yacreader_files.qrc
|
||||||
|
@ -6,7 +6,7 @@ TARGET = YACReader
|
|||||||
DEPENDPATH += . \
|
DEPENDPATH += . \
|
||||||
release
|
release
|
||||||
|
|
||||||
DEFINES += NOMINMAX
|
DEFINES += NOMINMAX YACREADER
|
||||||
|
|
||||||
unix:!macx{
|
unix:!macx{
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "magnifying_glass.h"
|
#include "magnifying_glass.h"
|
||||||
#include "viewer.h"
|
#include "viewer.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
#include "shortcuts_manager.h"
|
||||||
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
|
||||||
@ -244,26 +245,48 @@ void MagnifyingGlass::widthDown()
|
|||||||
void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
|
void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
bool validKey = false;
|
bool validKey = false;
|
||||||
switch (event->key())
|
|
||||||
{
|
int _key = event->key();
|
||||||
case Qt::Key_Plus:
|
Qt::KeyboardModifiers modifiers = event->modifiers();
|
||||||
sizeUp();
|
|
||||||
validKey = true;
|
if(modifiers & Qt::ShiftModifier)
|
||||||
break;
|
_key |= Qt::SHIFT;
|
||||||
case Qt::Key_Minus:
|
if (modifiers & Qt::ControlModifier)
|
||||||
sizeDown();
|
_key |= Qt::CTRL;
|
||||||
validKey = true;
|
if (modifiers & Qt::MetaModifier)
|
||||||
break;
|
_key |= Qt::META;
|
||||||
case Qt::Key_Underscore:
|
if (modifiers & Qt::AltModifier)
|
||||||
zoomOut();
|
_key |= Qt::ALT;
|
||||||
validKey = true;
|
|
||||||
break;
|
QKeySequence key(_key);
|
||||||
case Qt::Key_Asterisk:
|
|
||||||
zoomIn();
|
if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y))
|
||||||
validKey = true;
|
{
|
||||||
break;
|
sizeUp();
|
||||||
}
|
validKey = true;
|
||||||
updateImage();
|
}
|
||||||
|
|
||||||
|
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)
|
if(validKey)
|
||||||
|
{
|
||||||
|
updateImage();
|
||||||
event->setAccepted(true);
|
event->setAccepted(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#include "yacreader_local_client.h"
|
#include "yacreader_local_client.h"
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
|
#include "edit_shortcuts_dialog.h"
|
||||||
|
#include "shortcuts_manager.h"
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -87,19 +89,19 @@ MainWindowViewer::~MainWindowViewer()
|
|||||||
delete openNextComicAction;
|
delete openNextComicAction;
|
||||||
delete prevAction;
|
delete prevAction;
|
||||||
delete nextAction;
|
delete nextAction;
|
||||||
delete adjustHeight;
|
delete adjustHeightAction;
|
||||||
delete adjustWidth;
|
delete adjustWidthAction;
|
||||||
delete leftRotationAction;
|
delete leftRotationAction;
|
||||||
delete rightRotationAction;
|
delete rightRotationAction;
|
||||||
delete doublePageAction;
|
delete doublePageAction;
|
||||||
delete goToPage;
|
delete goToPageAction;
|
||||||
delete optionsAction;
|
delete optionsAction;
|
||||||
delete helpAboutAction;
|
delete helpAboutAction;
|
||||||
delete showMagnifyingGlass;
|
delete showMagnifyingGlassAction;
|
||||||
delete setBookmark;
|
delete setBookmarkAction;
|
||||||
delete showBookmarks;
|
delete showBookmarksAction;
|
||||||
delete showShorcutsAction;
|
delete showShorcutsAction;
|
||||||
delete showInfo;
|
delete showInfoAction;
|
||||||
delete closeAction;
|
delete closeAction;
|
||||||
delete showDictionaryAction;
|
delete showDictionaryAction;
|
||||||
delete alwaysOnTopAction;
|
delete alwaysOnTopAction;
|
||||||
@ -163,8 +165,12 @@ void MainWindowViewer::setupUI()
|
|||||||
|
|
||||||
optionsDialog->restoreOptions(settings);
|
optionsDialog->restoreOptions(settings);
|
||||||
shortcutsDialog = new ShortcutsDialog(this);
|
shortcutsDialog = new ShortcutsDialog(this);
|
||||||
|
editShortcutsDialog = new EditShortcutsDialog(this);
|
||||||
|
connect(optionsDialog,SIGNAL(editShortcuts()),editShortcutsDialog,SLOT(show()));
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
|
setUpShortcutsManagement();
|
||||||
|
|
||||||
createToolBars();
|
createToolBars();
|
||||||
|
|
||||||
setWindowTitle("YACReader");
|
setWindowTitle("YACReader");
|
||||||
@ -194,181 +200,216 @@ void MainWindowViewer::setupUI()
|
|||||||
|
|
||||||
void MainWindowViewer::createActions()
|
void MainWindowViewer::createActions()
|
||||||
{
|
{
|
||||||
openAction = new QAction(tr("&Open"),this);
|
openAction = new QAction(tr("&Open"),this);
|
||||||
openAction->setShortcut(tr("O"));
|
openAction->setIcon(QIcon(":/images/viewer_toolbar/open.png"));
|
||||||
openAction->setIcon(QIcon(":/images/viewer_toolbar/open.png"));
|
openAction->setToolTip(tr("Open a comic"));
|
||||||
openAction->setToolTip(tr("Open a comic"));
|
openAction->setData(OPEN_ACTION_Y);
|
||||||
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
openAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_ACTION_Y));
|
||||||
|
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||||
|
|
||||||
openFolderAction = new QAction(tr("Open Folder"),this);
|
openFolderAction = new QAction(tr("Open Folder"),this);
|
||||||
openFolderAction->setShortcut(tr("Ctrl+O"));
|
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
|
||||||
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
|
openFolderAction->setToolTip(tr("Open image folder"));
|
||||||
openFolderAction->setToolTip(tr("Open image folder"));
|
openFolderAction->setData(OPEN_FOLDER_ACTION_Y);
|
||||||
connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openFolder()));
|
openFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_FOLDER_ACTION_Y));
|
||||||
|
connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openFolder()));
|
||||||
|
|
||||||
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->setDisabled(true);
|
||||||
connect(saveImageAction,SIGNAL(triggered()),this,SLOT(saveImage()));
|
saveImageAction->setData(SAVE_IMAGE_ACTION_Y);
|
||||||
|
saveImageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SAVE_IMAGE_ACTION_Y));
|
||||||
|
connect(saveImageAction,SIGNAL(triggered()),this,SLOT(saveImage()));
|
||||||
|
|
||||||
openPreviousComicAction = new QAction(tr("Previous Comic"),this);
|
openPreviousComicAction = new QAction(tr("Previous Comic"),this);
|
||||||
openPreviousComicAction->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.png"));
|
openPreviousComicAction->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.png"));
|
||||||
openPreviousComicAction->setShortcut(Qt::CTRL + Qt::Key_Left);
|
openPreviousComicAction->setToolTip(tr("Open previous comic"));
|
||||||
openPreviousComicAction->setToolTip(tr("Open previous comic"));
|
openPreviousComicAction->setDisabled(true);
|
||||||
openPreviousComicAction->setDisabled(true);
|
openPreviousComicAction->setData(OPEN_PREVIOUS_COMIC_ACTION_Y);
|
||||||
connect(openPreviousComicAction,SIGNAL(triggered()),this,SLOT(openPreviousComic()));
|
openPreviousComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_PREVIOUS_COMIC_ACTION_Y));
|
||||||
|
connect(openPreviousComicAction,SIGNAL(triggered()),this,SLOT(openPreviousComic()));
|
||||||
|
|
||||||
openNextComicAction = new QAction(tr("Next Comic"),this);
|
openNextComicAction = new QAction(tr("Next Comic"),this);
|
||||||
openNextComicAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.png"));
|
openNextComicAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.png"));
|
||||||
openNextComicAction->setShortcut(Qt::CTRL + Qt::Key_Right);
|
openNextComicAction->setToolTip(tr("Open next comic"));
|
||||||
openNextComicAction->setToolTip(tr("Open next comic"));
|
openNextComicAction->setDisabled(true);
|
||||||
openNextComicAction->setDisabled(true);
|
openNextComicAction->setData(OPEN_NEXT_COMIC_ACTION_Y);
|
||||||
connect(openNextComicAction,SIGNAL(triggered()),this,SLOT(openNextComic()));
|
openNextComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_NEXT_COMIC_ACTION_Y));
|
||||||
|
connect(openNextComicAction,SIGNAL(triggered()),this,SLOT(openNextComic()));
|
||||||
|
|
||||||
prevAction = new QAction(tr("&Previous"),this);
|
prevAction = new QAction(tr("&Previous"),this);
|
||||||
prevAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
|
prevAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
|
||||||
prevAction->setShortcut(Qt::Key_Left);
|
prevAction->setShortcutContext(Qt::WidgetShortcut);
|
||||||
prevAction->setShortcutContext(Qt::WidgetShortcut);
|
prevAction->setToolTip(tr("Go to previous page"));
|
||||||
prevAction->setToolTip(tr("Go to previous page"));
|
prevAction->setDisabled(true);
|
||||||
prevAction->setDisabled(true);
|
prevAction->setData(PREV_ACTION_Y);
|
||||||
connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev()));
|
prevAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(PREV_ACTION_Y));
|
||||||
|
connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev()));
|
||||||
|
|
||||||
nextAction = new QAction(tr("&Next"),this);
|
nextAction = new QAction(tr("&Next"),this);
|
||||||
nextAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
|
nextAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
|
||||||
nextAction->setShortcut(Qt::Key_Right);
|
nextAction->setShortcutContext(Qt::WidgetShortcut);
|
||||||
nextAction->setShortcutContext(Qt::WidgetShortcut);
|
nextAction->setToolTip(tr("Go to next page"));
|
||||||
nextAction->setToolTip(tr("Go to next page"));
|
|
||||||
nextAction->setDisabled(true);
|
nextAction->setDisabled(true);
|
||||||
|
nextAction->setData(NEXT_ACTION_Y);
|
||||||
|
nextAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(NEXT_ACTION_Y));
|
||||||
connect(nextAction, SIGNAL(triggered()),viewer,SLOT(next()));
|
connect(nextAction, SIGNAL(triggered()),viewer,SLOT(next()));
|
||||||
|
|
||||||
adjustHeight = new QAction(tr("Fit Height"),this);
|
adjustHeightAction = new QAction(tr("Fit Height"),this);
|
||||||
adjustHeight->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
|
adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
|
||||||
//adjustWidth->setCheckable(true);
|
//adjustWidth->setCheckable(true);
|
||||||
adjustHeight->setDisabled(true);
|
adjustHeightAction->setDisabled(true);
|
||||||
adjustHeight->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
adjustHeightAction->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||||
adjustHeight->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"));
|
||||||
connect(adjustHeight, SIGNAL(triggered()),this,SLOT(fitToHeight()));
|
adjustHeightAction->setData(ADJUST_HEIGHT_ACTION_Y);
|
||||||
|
adjustHeightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_HEIGHT_ACTION_Y));
|
||||||
|
connect(adjustHeightAction, SIGNAL(triggered()),this,SLOT(fitToHeight()));
|
||||||
|
|
||||||
adjustWidth = new QAction(tr("Fit Width"),this);
|
adjustWidthAction = new QAction(tr("Fit Width"),this);
|
||||||
adjustWidth->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
|
adjustWidthAction->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
|
||||||
//adjustWidth->setCheckable(true);
|
//adjustWidth->setCheckable(true);
|
||||||
adjustWidth->setDisabled(true);
|
adjustWidthAction->setDisabled(true);
|
||||||
adjustWidth->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
adjustWidthAction->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||||
adjustWidth->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"));
|
||||||
connect(adjustWidth, SIGNAL(triggered()),this,SLOT(fitToWidth()));
|
adjustWidthAction->setData(ADJUST_WIDTH_ACTION_Y);
|
||||||
|
adjustWidthAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_WIDTH_ACTION_Y));
|
||||||
|
connect(adjustWidthAction, SIGNAL(triggered()),this,SLOT(fitToWidth()));
|
||||||
|
|
||||||
leftRotationAction = new QAction(tr("Rotate image to the left"),this);
|
leftRotationAction = new QAction(tr("Rotate image to the left"),this);
|
||||||
leftRotationAction->setShortcut(tr("L"));
|
|
||||||
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
|
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
|
||||||
leftRotationAction->setDisabled(true);
|
leftRotationAction->setDisabled(true);
|
||||||
|
leftRotationAction->setData(LEFT_ROTATION_ACTION_Y);
|
||||||
|
leftRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(LEFT_ROTATION_ACTION_Y));
|
||||||
connect(leftRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateLeft()));
|
connect(leftRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateLeft()));
|
||||||
|
|
||||||
rightRotationAction = new QAction(tr("Rotate image to the right"),this);
|
rightRotationAction = new QAction(tr("Rotate image to the right"),this);
|
||||||
rightRotationAction->setShortcut(tr("R"));
|
|
||||||
rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.png"));
|
rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.png"));
|
||||||
rightRotationAction->setDisabled(true);
|
rightRotationAction->setDisabled(true);
|
||||||
|
rightRotationAction->setData(RIGHT_ROTATION_ACTION_Y);
|
||||||
|
rightRotationAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RIGHT_ROTATION_ACTION_Y));
|
||||||
connect(rightRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateRight()));
|
connect(rightRotationAction, SIGNAL(triggered()),viewer,SLOT(rotateRight()));
|
||||||
|
|
||||||
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->setShortcut(tr("D"));
|
|
||||||
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
|
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
|
||||||
doublePageAction->setDisabled(true);
|
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->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_PAGE_ACTION_Y));
|
||||||
connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch()));
|
connect(doublePageAction, SIGNAL(triggered()),viewer,SLOT(doublePageSwitch()));
|
||||||
|
|
||||||
goToPage = new QAction(tr("Go To"),this);
|
goToPageAction = new QAction(tr("Go To"),this);
|
||||||
goToPage->setShortcut(tr("G"));
|
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
||||||
goToPage->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
goToPageAction->setDisabled(true);
|
||||||
goToPage->setDisabled(true);
|
goToPageAction->setToolTip(tr("Go to page ..."));
|
||||||
goToPage->setToolTip(tr("Go to page ..."));
|
goToPageAction->setData(GO_TO_PAGE_ACTION_Y);
|
||||||
connect(goToPage, SIGNAL(triggered()),viewer,SLOT(showGoToDialog()));
|
goToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_PAGE_ACTION_Y));
|
||||||
|
connect(goToPageAction, SIGNAL(triggered()),viewer,SLOT(showGoToDialog()));
|
||||||
|
|
||||||
optionsAction = new QAction(tr("Options"),this);
|
optionsAction = new QAction(tr("Options"),this);
|
||||||
optionsAction->setShortcut(tr("C"));
|
|
||||||
optionsAction->setToolTip(tr("YACReader options"));
|
optionsAction->setToolTip(tr("YACReader options"));
|
||||||
|
optionsAction->setData(OPTIONS_ACTION_Y);
|
||||||
|
optionsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPTIONS_ACTION_Y));
|
||||||
optionsAction->setIcon(QIcon(":/images/viewer_toolbar/options.png"));
|
optionsAction->setIcon(QIcon(":/images/viewer_toolbar/options.png"));
|
||||||
|
|
||||||
connect(optionsAction, SIGNAL(triggered()),optionsDialog,SLOT(show()));
|
connect(optionsAction, SIGNAL(triggered()),optionsDialog,SLOT(show()));
|
||||||
|
|
||||||
helpAboutAction = new QAction(tr("Help"),this);
|
helpAboutAction = new QAction(tr("Help"),this);
|
||||||
helpAboutAction->setToolTip(tr("Help, About YACReader"));
|
helpAboutAction->setToolTip(tr("Help, About YACReader"));
|
||||||
helpAboutAction->setShortcut(Qt::Key_F1);
|
|
||||||
helpAboutAction->setIcon(QIcon(":/images/viewer_toolbar/help.png"));
|
helpAboutAction->setIcon(QIcon(":/images/viewer_toolbar/help.png"));
|
||||||
|
helpAboutAction->setData(HELP_ABOUT_ACTION_Y);
|
||||||
|
helpAboutAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(HELP_ABOUT_ACTION_Y));
|
||||||
connect(helpAboutAction, SIGNAL(triggered()),had,SLOT(show()));
|
connect(helpAboutAction, SIGNAL(triggered()),had,SLOT(show()));
|
||||||
|
|
||||||
showMagnifyingGlass = new QAction(tr("Magnifying glass"),this);
|
showMagnifyingGlassAction = new QAction(tr("Magnifying glass"),this);
|
||||||
showMagnifyingGlass->setToolTip(tr("Switch Magnifying glass"));
|
showMagnifyingGlassAction->setToolTip(tr("Switch Magnifying glass"));
|
||||||
showMagnifyingGlass->setShortcut(tr("Z"));
|
showMagnifyingGlassAction->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.png"));
|
||||||
showMagnifyingGlass->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.png"));
|
showMagnifyingGlassAction->setDisabled(true);
|
||||||
showMagnifyingGlass->setDisabled(true);
|
showMagnifyingGlassAction->setCheckable(true);
|
||||||
showMagnifyingGlass->setCheckable(true);
|
showMagnifyingGlassAction->setData(SHOW_MAGNIFYING_GLASS_ACTION_Y);
|
||||||
connect(showMagnifyingGlass, SIGNAL(triggered()),viewer,SLOT(magnifyingGlassSwitch()));
|
showMagnifyingGlassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_MAGNIFYING_GLASS_ACTION_Y));
|
||||||
|
connect(showMagnifyingGlassAction, SIGNAL(triggered()),viewer,SLOT(magnifyingGlassSwitch()));
|
||||||
|
|
||||||
setBookmark = new QAction(tr("Set bookmark"),this);
|
setBookmarkAction = new QAction(tr("Set bookmark"),this);
|
||||||
setBookmark->setToolTip(tr("Set a bookmark on the current page"));
|
setBookmarkAction->setToolTip(tr("Set a bookmark on the current page"));
|
||||||
setBookmark->setShortcut(Qt::CTRL+Qt::Key_M);
|
setBookmarkAction->setIcon(QIcon(":/images/viewer_toolbar/bookmark.png"));
|
||||||
setBookmark->setIcon(QIcon(":/images/viewer_toolbar/bookmark.png"));
|
setBookmarkAction->setDisabled(true);
|
||||||
setBookmark->setDisabled(true);
|
setBookmarkAction->setCheckable(true);
|
||||||
setBookmark->setCheckable(true);
|
setBookmarkAction->setData(SET_BOOKMARK_ACTION_Y);
|
||||||
connect(setBookmark,SIGNAL(triggered (bool)),viewer,SLOT(setBookmark(bool)));
|
setBookmarkAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_BOOKMARK_ACTION_Y));
|
||||||
connect(viewer,SIGNAL(pageAvailable(bool)),setBookmark,SLOT(setEnabled(bool)));
|
connect(setBookmarkAction,SIGNAL(triggered (bool)),viewer,SLOT(setBookmarkAction(bool)));
|
||||||
connect(viewer,SIGNAL(pageIsBookmark(bool)),setBookmark,SLOT(setChecked(bool)));
|
connect(viewer,SIGNAL(pageAvailable(bool)),setBookmarkAction,SLOT(setEnabled(bool)));
|
||||||
|
connect(viewer,SIGNAL(pageIsBookmark(bool)),setBookmarkAction,SLOT(setChecked(bool)));
|
||||||
|
|
||||||
showBookmarks = new QAction(tr("Show bookmarks"),this);
|
showBookmarksAction = new QAction(tr("Show bookmarks"),this);
|
||||||
showBookmarks->setToolTip(tr("Show the bookmarks of the current comic"));
|
showBookmarksAction->setToolTip(tr("Show the bookmarks of the current comic"));
|
||||||
showBookmarks->setShortcut(tr("M"));
|
showBookmarksAction->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.png"));
|
||||||
showBookmarks->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.png"));
|
showBookmarksAction->setDisabled(true);
|
||||||
showBookmarks->setDisabled(true);
|
showBookmarksAction->setData(SHOW_BOOKMARKS_ACTION_Y);
|
||||||
connect(showBookmarks, SIGNAL(triggered()),viewer->getBookmarksDialog(),SLOT(show()));
|
showBookmarksAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_BOOKMARKS_ACTION_Y));
|
||||||
|
connect(showBookmarksAction, SIGNAL(triggered()),viewer->getBookmarksDialog(),SLOT(show()));
|
||||||
|
|
||||||
showShorcutsAction = new QAction(tr("Show keyboard shortcuts"), this );
|
showShorcutsAction = new QAction(tr("Show keyboard shortcuts"), this );
|
||||||
showShorcutsAction->setIcon(QIcon(":/images/viewer_toolbar/shortcuts.png"));
|
showShorcutsAction->setIcon(QIcon(":/images/viewer_toolbar/shortcuts.png"));
|
||||||
|
showShorcutsAction->setData(SHOW_SHORCUTS_ACTION_Y);
|
||||||
|
showShorcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_SHORCUTS_ACTION_Y));
|
||||||
connect(showShorcutsAction, SIGNAL(triggered()),shortcutsDialog,SLOT(show()));
|
connect(showShorcutsAction, SIGNAL(triggered()),shortcutsDialog,SLOT(show()));
|
||||||
|
|
||||||
showInfo = new QAction(tr("Show Info"),this);
|
showInfoAction = new QAction(tr("Show Info"),this);
|
||||||
showInfo->setShortcut(tr("I"));
|
showInfoAction->setIcon(QIcon(":/images/viewer_toolbar/info.png"));
|
||||||
showInfo->setIcon(QIcon(":/images/viewer_toolbar/info.png"));
|
showInfoAction->setDisabled(true);
|
||||||
showInfo->setDisabled(true);
|
showInfoAction->setData(SHOW_INFO_ACTION_Y);
|
||||||
connect(showInfo, SIGNAL(triggered()),viewer,SLOT(informationSwitch()));
|
showInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_INFO_ACTION_Y));
|
||||||
|
connect(showInfoAction, SIGNAL(triggered()),viewer,SLOT(informationSwitch()));
|
||||||
|
|
||||||
closeAction = new QAction(tr("Close"),this);
|
closeAction = new QAction(tr("Close"),this);
|
||||||
closeAction->setShortcut(Qt::Key_Escape);
|
|
||||||
closeAction->setIcon(QIcon(":/images/viewer_toolbar/close.png"));
|
closeAction->setIcon(QIcon(":/images/viewer_toolbar/close.png"));
|
||||||
|
closeAction->setData(CLOSE_ACTION_Y);
|
||||||
|
closeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(CLOSE_ACTION_Y));
|
||||||
connect(closeAction,SIGNAL(triggered()),this,SLOT(close()));
|
connect(closeAction,SIGNAL(triggered()),this,SLOT(close()));
|
||||||
|
|
||||||
showDictionaryAction = new QAction(tr("Show Dictionary"),this);
|
showDictionaryAction = new QAction(tr("Show Dictionary"),this);
|
||||||
showDictionaryAction->setShortcut(Qt::Key_T);
|
|
||||||
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->setDisabled(true);
|
||||||
|
showDictionaryAction->setData(SHOW_DICTIONARY_ACTION_Y);
|
||||||
|
showDictionaryAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_DICTIONARY_ACTION_Y));
|
||||||
connect(showDictionaryAction,SIGNAL(triggered()),viewer,SLOT(translatorSwitch()));
|
connect(showDictionaryAction,SIGNAL(triggered()),viewer,SLOT(translatorSwitch()));
|
||||||
|
|
||||||
|
//deprecated
|
||||||
alwaysOnTopAction = new QAction(tr("Always on top"),this);
|
alwaysOnTopAction = new QAction(tr("Always on top"),this);
|
||||||
alwaysOnTopAction->setShortcut(Qt::Key_Q);
|
|
||||||
alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png"));
|
alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png"));
|
||||||
alwaysOnTopAction->setCheckable(true);
|
alwaysOnTopAction->setCheckable(true);
|
||||||
alwaysOnTopAction->setDisabled(true);
|
alwaysOnTopAction->setDisabled(true);
|
||||||
alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop());
|
alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop());
|
||||||
|
alwaysOnTopAction->setData(ALWAYS_ON_TOP_ACTION_Y);
|
||||||
|
alwaysOnTopAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ALWAYS_ON_TOP_ACTION_Y));
|
||||||
connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch()));
|
connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch()));
|
||||||
|
|
||||||
adjustToFullSizeAction = new QAction(tr("Show full size"),this);
|
adjustToFullSizeAction = new QAction(tr("Show full size"),this);
|
||||||
adjustToFullSizeAction->setShortcut(Qt::Key_W);
|
|
||||||
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
|
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
|
||||||
adjustToFullSizeAction->setCheckable(true);
|
adjustToFullSizeAction->setCheckable(true);
|
||||||
adjustToFullSizeAction->setDisabled(true);
|
adjustToFullSizeAction->setDisabled(true);
|
||||||
adjustToFullSizeAction->setChecked(Configuration::getConfiguration().getAdjustToFullSize());
|
adjustToFullSizeAction->setChecked(Configuration::getConfiguration().getAdjustToFullSize());
|
||||||
|
adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y);
|
||||||
|
adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y));
|
||||||
connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch()));
|
connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch()));
|
||||||
|
|
||||||
showFlowAction = new QAction(tr("Show go to flow"),this);
|
showFlowAction = new QAction(tr("Show go to flow"),this);
|
||||||
showFlowAction->setShortcut(Qt::Key_S);
|
|
||||||
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
||||||
showFlowAction->setDisabled(true);
|
showFlowAction->setDisabled(true);
|
||||||
|
showFlowAction->setData(SHOW_FLOW_ACTION_Y);
|
||||||
|
showFlowAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_FLOW_ACTION_Y));
|
||||||
connect(showFlowAction,SIGNAL(triggered()),viewer,SLOT(goToFlowSwitch()));
|
connect(showFlowAction,SIGNAL(triggered()),viewer,SLOT(goToFlowSwitch()));
|
||||||
|
|
||||||
|
showEditShortcutsAction = new QAction(tr("Edit shortcuts"),this);
|
||||||
|
showEditShortcutsAction->setData(SHOW_EDIT_SHORTCUTS_ACTION_Y);
|
||||||
|
showEditShortcutsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_EDIT_SHORTCUTS_ACTION_Y));
|
||||||
|
connect(showEditShortcutsAction,SIGNAL(triggered()),editShortcutsDialog,SLOT(show()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::createToolBars()
|
void MainWindowViewer::createToolBars()
|
||||||
@ -399,7 +440,7 @@ void MainWindowViewer::createToolBars()
|
|||||||
#endif
|
#endif
|
||||||
comicToolBar->addAction(prevAction);
|
comicToolBar->addAction(prevAction);
|
||||||
comicToolBar->addAction(nextAction);
|
comicToolBar->addAction(nextAction);
|
||||||
comicToolBar->addAction(goToPage);
|
comicToolBar->addAction(goToPageAction);
|
||||||
|
|
||||||
//#ifndef Q_OS_MAC
|
//#ifndef Q_OS_MAC
|
||||||
// comicToolBar->addSeparator();
|
// comicToolBar->addSeparator();
|
||||||
@ -440,7 +481,7 @@ void MainWindowViewer::createToolBars()
|
|||||||
);
|
);
|
||||||
menu->addAction(sliderAction);
|
menu->addAction(sliderAction);
|
||||||
QToolButton * tb2 = new QToolButton();
|
QToolButton * tb2 = new QToolButton();
|
||||||
tb2->addAction(adjustWidth);
|
tb2->addAction(adjustWidthAction);
|
||||||
tb2->setMenu(menu);
|
tb2->setMenu(menu);
|
||||||
|
|
||||||
connect(sliderAction,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
connect(sliderAction,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
||||||
@ -449,9 +490,9 @@ void MainWindowViewer::createToolBars()
|
|||||||
|
|
||||||
//tb2->addAction();
|
//tb2->addAction();
|
||||||
tb2->setPopupMode(QToolButton::MenuButtonPopup);
|
tb2->setPopupMode(QToolButton::MenuButtonPopup);
|
||||||
tb2->setDefaultAction(adjustWidth);
|
tb2->setDefaultAction(adjustWidthAction);
|
||||||
comicToolBar->addWidget(tb2);
|
comicToolBar->addWidget(tb2);
|
||||||
comicToolBar->addAction(adjustHeight);
|
comicToolBar->addAction(adjustHeightAction);
|
||||||
comicToolBar->addAction(adjustToFullSizeAction);
|
comicToolBar->addAction(adjustToFullSizeAction);
|
||||||
comicToolBar->addAction(leftRotationAction);
|
comicToolBar->addAction(leftRotationAction);
|
||||||
comicToolBar->addAction(rightRotationAction);
|
comicToolBar->addAction(rightRotationAction);
|
||||||
@ -462,15 +503,15 @@ void MainWindowViewer::createToolBars()
|
|||||||
#else
|
#else
|
||||||
comicToolBar->addSeparator();
|
comicToolBar->addSeparator();
|
||||||
#endif
|
#endif
|
||||||
comicToolBar->addAction(showMagnifyingGlass);
|
comicToolBar->addAction(showMagnifyingGlassAction);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||||
#else
|
#else
|
||||||
comicToolBar->addSeparator();
|
comicToolBar->addSeparator();
|
||||||
#endif
|
#endif
|
||||||
comicToolBar->addAction(setBookmark);
|
comicToolBar->addAction(setBookmarkAction);
|
||||||
comicToolBar->addAction(showBookmarks);
|
comicToolBar->addAction(showBookmarksAction);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||||
@ -479,7 +520,7 @@ void MainWindowViewer::createToolBars()
|
|||||||
#endif
|
#endif
|
||||||
comicToolBar->addAction(showDictionaryAction);
|
comicToolBar->addAction(showDictionaryAction);
|
||||||
comicToolBar->addAction(showFlowAction);
|
comicToolBar->addAction(showFlowAction);
|
||||||
comicToolBar->addAction(showInfo);
|
comicToolBar->addAction(showInfoAction);
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||||
@ -505,28 +546,29 @@ void MainWindowViewer::createToolBars()
|
|||||||
|
|
||||||
viewer->addAction(prevAction);
|
viewer->addAction(prevAction);
|
||||||
viewer->addAction(nextAction);
|
viewer->addAction(nextAction);
|
||||||
viewer->addAction(goToPage);
|
viewer->addAction(goToPageAction);
|
||||||
viewer->addAction(adjustHeight);
|
viewer->addAction(adjustHeightAction);
|
||||||
viewer->addAction(adjustWidth);
|
viewer->addAction(adjustWidthAction);
|
||||||
viewer->addAction(adjustToFullSizeAction);
|
viewer->addAction(adjustToFullSizeAction);
|
||||||
viewer->addAction(leftRotationAction);
|
viewer->addAction(leftRotationAction);
|
||||||
viewer->addAction(rightRotationAction);
|
viewer->addAction(rightRotationAction);
|
||||||
viewer->addAction(doublePageAction);
|
viewer->addAction(doublePageAction);
|
||||||
YACReader::addSperator(viewer);
|
YACReader::addSperator(viewer);
|
||||||
|
|
||||||
viewer->addAction(showMagnifyingGlass);
|
viewer->addAction(showMagnifyingGlassAction);
|
||||||
YACReader::addSperator(viewer);
|
YACReader::addSperator(viewer);
|
||||||
|
|
||||||
viewer->addAction(setBookmark);
|
viewer->addAction(setBookmarkAction);
|
||||||
viewer->addAction(showBookmarks);
|
viewer->addAction(showBookmarksAction);
|
||||||
YACReader::addSperator(viewer);
|
YACReader::addSperator(viewer);
|
||||||
|
|
||||||
viewer->addAction(showDictionaryAction);
|
viewer->addAction(showDictionaryAction);
|
||||||
viewer->addAction(showFlowAction);
|
viewer->addAction(showFlowAction);
|
||||||
viewer->addAction(showInfo);
|
viewer->addAction(showInfoAction);
|
||||||
YACReader::addSperator(viewer);
|
YACReader::addSperator(viewer);
|
||||||
|
|
||||||
viewer->addAction(showShorcutsAction);
|
viewer->addAction(showShorcutsAction);
|
||||||
|
viewer->addAction(showEditShortcutsAction);
|
||||||
viewer->addAction(optionsAction);
|
viewer->addAction(optionsAction);
|
||||||
viewer->addAction(helpAboutAction);
|
viewer->addAction(helpAboutAction);
|
||||||
YACReader::addSperator(viewer);
|
YACReader::addSperator(viewer);
|
||||||
@ -728,18 +770,18 @@ void MainWindowViewer::enableActions()
|
|||||||
saveImageAction->setDisabled(false);
|
saveImageAction->setDisabled(false);
|
||||||
prevAction->setDisabled(false);
|
prevAction->setDisabled(false);
|
||||||
nextAction->setDisabled(false);
|
nextAction->setDisabled(false);
|
||||||
adjustHeight->setDisabled(false);
|
adjustHeightAction->setDisabled(false);
|
||||||
adjustWidth->setDisabled(false);
|
adjustWidthAction->setDisabled(false);
|
||||||
goToPage->setDisabled(false);
|
goToPageAction->setDisabled(false);
|
||||||
//alwaysOnTopAction->setDisabled(false);
|
//alwaysOnTopAction->setDisabled(false);
|
||||||
leftRotationAction->setDisabled(false);
|
leftRotationAction->setDisabled(false);
|
||||||
rightRotationAction->setDisabled(false);
|
rightRotationAction->setDisabled(false);
|
||||||
showMagnifyingGlass->setDisabled(false);
|
showMagnifyingGlassAction->setDisabled(false);
|
||||||
doublePageAction->setDisabled(false);
|
doublePageAction->setDisabled(false);
|
||||||
adjustToFullSizeAction->setDisabled(false);
|
adjustToFullSizeAction->setDisabled(false);
|
||||||
//setBookmark->setDisabled(false);
|
//setBookmark->setDisabled(false);
|
||||||
showBookmarks->setDisabled(false);
|
showBookmarksAction->setDisabled(false);
|
||||||
showInfo->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
|
showInfoAction->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||||
showDictionaryAction->setDisabled(false);
|
showDictionaryAction->setDisabled(false);
|
||||||
showFlowAction->setDisabled(false);
|
showFlowAction->setDisabled(false);
|
||||||
}
|
}
|
||||||
@ -748,18 +790,18 @@ void MainWindowViewer::disableActions()
|
|||||||
saveImageAction->setDisabled(true);
|
saveImageAction->setDisabled(true);
|
||||||
prevAction->setDisabled(true);
|
prevAction->setDisabled(true);
|
||||||
nextAction->setDisabled(true);
|
nextAction->setDisabled(true);
|
||||||
adjustHeight->setDisabled(true);
|
adjustHeightAction->setDisabled(true);
|
||||||
adjustWidth->setDisabled(true);
|
adjustWidthAction->setDisabled(true);
|
||||||
goToPage->setDisabled(true);
|
goToPageAction->setDisabled(true);
|
||||||
//alwaysOnTopAction->setDisabled(true);
|
//alwaysOnTopAction->setDisabled(true);
|
||||||
leftRotationAction->setDisabled(true);
|
leftRotationAction->setDisabled(true);
|
||||||
rightRotationAction->setDisabled(true);
|
rightRotationAction->setDisabled(true);
|
||||||
showMagnifyingGlass->setDisabled(true);
|
showMagnifyingGlassAction->setDisabled(true);
|
||||||
doublePageAction->setDisabled(true);
|
doublePageAction->setDisabled(true);
|
||||||
adjustToFullSizeAction->setDisabled(true);
|
adjustToFullSizeAction->setDisabled(true);
|
||||||
setBookmark->setDisabled(true);
|
setBookmarkAction->setDisabled(true);
|
||||||
showBookmarks->setDisabled(true);
|
showBookmarksAction->setDisabled(true);
|
||||||
showInfo->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
|
showInfoAction->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||||
openPreviousComicAction->setDisabled(true);
|
openPreviousComicAction->setDisabled(true);
|
||||||
openNextComicAction->setDisabled(true);
|
openNextComicAction->setDisabled(true);
|
||||||
showDictionaryAction->setDisabled(true);
|
showDictionaryAction->setDisabled(true);
|
||||||
@ -768,28 +810,38 @@ void MainWindowViewer::disableActions()
|
|||||||
|
|
||||||
void MainWindowViewer::keyPressEvent(QKeyEvent *event)
|
void MainWindowViewer::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
//TODO remove unused keys
|
//TODO remove unused keys
|
||||||
switch (event->key())
|
int _key = event->key();
|
||||||
{
|
Qt::KeyboardModifiers modifiers = event->modifiers();
|
||||||
case Qt::Key_Escape:
|
|
||||||
this->close();
|
if(modifiers & Qt::ShiftModifier)
|
||||||
break;
|
_key |= Qt::SHIFT;
|
||||||
case Qt::Key_F:
|
if (modifiers & Qt::ControlModifier)
|
||||||
toggleFullScreen();
|
_key |= Qt::CTRL;
|
||||||
break;
|
if (modifiers & Qt::MetaModifier)
|
||||||
case Qt::Key_H:
|
_key |= Qt::META;
|
||||||
toggleToolBars();
|
if (modifiers & Qt::AltModifier)
|
||||||
break;
|
_key |= Qt::ALT;
|
||||||
case Qt::Key_O:
|
|
||||||
open();
|
QKeySequence key(_key);
|
||||||
break;
|
|
||||||
case Qt::Key_A:
|
if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_Y))
|
||||||
changeFit();
|
{
|
||||||
break;
|
toggleFullScreen();
|
||||||
default:
|
event->accept();
|
||||||
QWidget::keyPressEvent(event);
|
}
|
||||||
break;
|
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y))
|
||||||
}
|
{
|
||||||
|
toggleToolBars();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y))
|
||||||
|
{
|
||||||
|
changeFit();
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QWidget::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::mouseDoubleClickEvent ( QMouseEvent * event )
|
void MainWindowViewer::mouseDoubleClickEvent ( QMouseEvent * event )
|
||||||
@ -888,7 +940,7 @@ void MainWindowViewer::checkNewVersion()
|
|||||||
QTimer * tT = new QTimer;
|
QTimer * tT = new QTimer;
|
||||||
tT->setSingleShot(true);
|
tT->setSingleShot(true);
|
||||||
connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
|
connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
|
||||||
//versionChecker->get(); //TOD<4F>
|
//versionChecker->get(); //TOD<4F>
|
||||||
tT->start(100);
|
tT->start(100);
|
||||||
|
|
||||||
conf.setLastVersionCheck(current);
|
conf.setLastVersionCheck(current);
|
||||||
@ -914,6 +966,147 @@ void MainWindowViewer::processReset()
|
|||||||
disableActions();
|
disableActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindowViewer::setUpShortcutsManagement()
|
||||||
|
{
|
||||||
|
//actions holder
|
||||||
|
QObject * orphanActions = new QObject;
|
||||||
|
|
||||||
|
QList<QAction *> allActions;
|
||||||
|
QList<QAction *> tmpList;
|
||||||
|
|
||||||
|
|
||||||
|
editShortcutsDialog->addActionsGroup(tr("Comics"),QIcon(":/images/shortcuts_group_comics.png"),
|
||||||
|
tmpList = QList<QAction *>()
|
||||||
|
<< openAction
|
||||||
|
<< openFolderAction
|
||||||
|
<< saveImageAction
|
||||||
|
<< openPreviousComicAction
|
||||||
|
<< openNextComicAction);
|
||||||
|
|
||||||
|
allActions << tmpList;
|
||||||
|
|
||||||
|
//keys without actions (General)
|
||||||
|
QAction * toggleFullScreenAction = new QAction(tr("Toggle fullscreen mode"),orphanActions);
|
||||||
|
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);
|
||||||
|
toggleToolbarsAction->setData(TOGGLE_TOOL_BARS_ACTION_Y);
|
||||||
|
toggleToolbarsAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y));
|
||||||
|
|
||||||
|
editShortcutsDialog->addActionsGroup(tr("General"),QIcon(":/images/shortcuts_group_general.png"),
|
||||||
|
tmpList = QList<QAction *>()
|
||||||
|
<< optionsAction
|
||||||
|
<< helpAboutAction
|
||||||
|
<< showShorcutsAction
|
||||||
|
<< showInfoAction
|
||||||
|
<< closeAction
|
||||||
|
<< showDictionaryAction
|
||||||
|
<< showFlowAction
|
||||||
|
<< toggleFullScreenAction
|
||||||
|
<< toggleToolbarsAction
|
||||||
|
<< showEditShortcutsAction);
|
||||||
|
|
||||||
|
allActions << tmpList;
|
||||||
|
|
||||||
|
//keys without actions (MGlass)
|
||||||
|
QAction * sizeUpMglassAction = new QAction(tr("Size up magnifying glass"),orphanActions);
|
||||||
|
sizeUpMglassAction->setData(SIZE_UP_MGLASS_ACTION_Y);
|
||||||
|
sizeUpMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * sizeDownMglassAction = new QAction(tr("Size down magnifying glass"),orphanActions);
|
||||||
|
sizeDownMglassAction->setData(SIZE_DOWN_MGLASS_ACTION_Y);
|
||||||
|
sizeDownMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * zoomInMglassAction = new QAction(tr("Zoom in magnifying glass"),orphanActions);
|
||||||
|
zoomInMglassAction->setData(ZOOM_IN_MGLASS_ACTION_Y);
|
||||||
|
zoomInMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * zoomOutMglassAction = new QAction(tr("Zoom out magnifying glass"),orphanActions);
|
||||||
|
zoomOutMglassAction->setData(ZOOM_OUT_MGLASS_ACTION_Y);
|
||||||
|
zoomOutMglassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y));
|
||||||
|
|
||||||
|
editShortcutsDialog->addActionsGroup(tr("Magnifiying glass"),QIcon(":/images/shortcuts_group_mglass.png"),
|
||||||
|
tmpList = QList<QAction *>()
|
||||||
|
<< showMagnifyingGlassAction
|
||||||
|
<< sizeUpMglassAction
|
||||||
|
<< sizeDownMglassAction
|
||||||
|
<< zoomInMglassAction
|
||||||
|
<< zoomOutMglassAction);
|
||||||
|
|
||||||
|
allActions << tmpList;
|
||||||
|
|
||||||
|
//keys without actions
|
||||||
|
QAction * toggleFitToScreenAction = new QAction(tr("Toggle between fit to width and fit to height"),orphanActions);
|
||||||
|
toggleFitToScreenAction->setData(CHANGE_FIT_ACTION_Y);
|
||||||
|
toggleFitToScreenAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y));
|
||||||
|
|
||||||
|
editShortcutsDialog->addActionsGroup(tr("Page adjustement"),QIcon(":/images/shortcuts_group_page.png"),
|
||||||
|
tmpList = QList<QAction *>()
|
||||||
|
<< adjustHeightAction
|
||||||
|
<< adjustWidthAction
|
||||||
|
<< toggleFitToScreenAction
|
||||||
|
<< leftRotationAction
|
||||||
|
<< rightRotationAction
|
||||||
|
<< doublePageAction
|
||||||
|
<< adjustToFullSizeAction);
|
||||||
|
|
||||||
|
allActions << tmpList;
|
||||||
|
|
||||||
|
QAction * autoScrollForwardAction = new QAction(tr("Autoscroll down"),orphanActions);
|
||||||
|
autoScrollForwardAction->setData(AUTO_SCROLL_FORWARD_ACTION_Y);
|
||||||
|
autoScrollForwardAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * autoScrollBackwardAction = new QAction(tr("Autoscroll up"),orphanActions);
|
||||||
|
autoScrollBackwardAction->setData(AUTO_SCROLL_BACKWARD_ACTION_Y);
|
||||||
|
autoScrollBackwardAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_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));
|
||||||
|
|
||||||
|
QAction * moveUpAction = new QAction(tr("Move up"),orphanActions);
|
||||||
|
moveUpAction->setData(MOVE_UP_ACTION_Y);
|
||||||
|
moveUpAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * moveLeftAction = new QAction(tr("Move left"),orphanActions);
|
||||||
|
moveLeftAction->setData(MOVE_LEFT_ACTION_Y);
|
||||||
|
moveLeftAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * moveRightAction = new QAction(tr("Move right"),orphanActions);
|
||||||
|
moveRightAction->setData(MOVE_RIGHT_ACTION_Y);
|
||||||
|
moveRightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * goToFirstPageAction = new QAction(tr("Go to the first page"),orphanActions);
|
||||||
|
goToFirstPageAction->setData(GO_TO_FIRST_PAGE_ACTION_Y);
|
||||||
|
goToFirstPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y));
|
||||||
|
|
||||||
|
QAction * goToLastPageAction = new QAction(tr("Go to the last page"),orphanActions);
|
||||||
|
goToLastPageAction->setData(GO_TO_LAST_PAGE_ACTION_Y);
|
||||||
|
goToLastPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y));
|
||||||
|
|
||||||
|
editShortcutsDialog->addActionsGroup(tr("Reading"),QIcon(":/images/shortcuts_group_reading.png"),
|
||||||
|
tmpList = QList<QAction *>()
|
||||||
|
<< nextAction
|
||||||
|
<< prevAction
|
||||||
|
<< setBookmarkAction
|
||||||
|
<< showBookmarksAction
|
||||||
|
<< autoScrollForwardAction
|
||||||
|
<< autoScrollBackwardAction
|
||||||
|
<< moveDownAction
|
||||||
|
<< moveUpAction
|
||||||
|
<< moveLeftAction
|
||||||
|
<< moveRightAction
|
||||||
|
<< goToFirstPageAction
|
||||||
|
<< goToLastPageAction
|
||||||
|
<< goToPageAction);
|
||||||
|
|
||||||
|
allActions << tmpList;
|
||||||
|
|
||||||
|
ShortcutsManager::getShortcutsManager().registerActions(allActions);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindowViewer::changeFit()
|
void MainWindowViewer::changeFit()
|
||||||
{
|
{
|
||||||
Configuration & conf = Configuration::getConfiguration();
|
Configuration & conf = Configuration::getConfiguration();
|
||||||
|
@ -18,6 +18,7 @@ class HelpAboutDialog;
|
|||||||
class HttpVersionChecker;
|
class HttpVersionChecker;
|
||||||
class ShortcutsDialog;
|
class ShortcutsDialog;
|
||||||
class YACReaderSliderAction;
|
class YACReaderSliderAction;
|
||||||
|
class EditShortcutsDialog;
|
||||||
|
|
||||||
class MainWindowViewer : public QMainWindow
|
class MainWindowViewer : public QMainWindow
|
||||||
{
|
{
|
||||||
@ -52,6 +53,7 @@ class YACReaderSliderAction;
|
|||||||
void fitToHeight();
|
void fitToHeight();
|
||||||
void checkNewVersion();
|
void checkNewVersion();
|
||||||
void processReset();
|
void processReset();
|
||||||
|
void setUpShortcutsManagement();
|
||||||
/*void viewComic();
|
/*void viewComic();
|
||||||
void prev();
|
void prev();
|
||||||
void next();
|
void next();
|
||||||
@ -72,6 +74,7 @@ class YACReaderSliderAction;
|
|||||||
OptionsDialog * optionsDialog;
|
OptionsDialog * optionsDialog;
|
||||||
HelpAboutDialog * had;
|
HelpAboutDialog * had;
|
||||||
ShortcutsDialog * shortcutsDialog;
|
ShortcutsDialog * shortcutsDialog;
|
||||||
|
EditShortcutsDialog * editShortcutsDialog;
|
||||||
|
|
||||||
//! ToolBars
|
//! ToolBars
|
||||||
QToolBar *comicToolBar;
|
QToolBar *comicToolBar;
|
||||||
@ -84,17 +87,17 @@ class YACReaderSliderAction;
|
|||||||
QAction *openNextComicAction;
|
QAction *openNextComicAction;
|
||||||
QAction *nextAction;
|
QAction *nextAction;
|
||||||
QAction *prevAction;
|
QAction *prevAction;
|
||||||
QAction *adjustWidth;
|
QAction *adjustWidthAction;
|
||||||
QAction *adjustHeight;
|
QAction *adjustHeightAction;
|
||||||
QAction *goToPage;
|
QAction *goToPageAction;
|
||||||
QAction *optionsAction;
|
QAction *optionsAction;
|
||||||
QAction *helpAboutAction;
|
QAction *helpAboutAction;
|
||||||
QAction *showMagnifyingGlass;
|
QAction *showMagnifyingGlassAction;
|
||||||
QAction *setBookmark;
|
QAction *setBookmarkAction;
|
||||||
QAction *showBookmarks;
|
QAction *showBookmarksAction;
|
||||||
QAction *leftRotationAction;
|
QAction *leftRotationAction;
|
||||||
QAction *rightRotationAction;
|
QAction *rightRotationAction;
|
||||||
QAction *showInfo;
|
QAction *showInfoAction;
|
||||||
QAction *closeAction;
|
QAction *closeAction;
|
||||||
QAction *doublePageAction;
|
QAction *doublePageAction;
|
||||||
QAction *showShorcutsAction;
|
QAction *showShorcutsAction;
|
||||||
@ -103,6 +106,8 @@ class YACReaderSliderAction;
|
|||||||
QAction *adjustToFullSizeAction;
|
QAction *adjustToFullSizeAction;
|
||||||
QAction *showFlowAction;
|
QAction *showFlowAction;
|
||||||
|
|
||||||
|
QAction *showEditShortcutsAction;
|
||||||
|
|
||||||
YACReaderSliderAction * sliderAction;
|
YACReaderSliderAction * sliderAction;
|
||||||
|
|
||||||
HttpVersionChecker * versionChecker;
|
HttpVersionChecker * versionChecker;
|
||||||
@ -115,8 +120,8 @@ class YACReaderSliderAction;
|
|||||||
void getSiblingComics(QString path,QString currentComic);
|
void getSiblingComics(QString path,QString currentComic);
|
||||||
|
|
||||||
//! Manejadores de evento:
|
//! Manejadores de evento:
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
//void resizeEvent(QResizeEvent * event);
|
//void resizeEvent(QResizeEvent * event);
|
||||||
void mouseDoubleClickEvent ( QMouseEvent * event );
|
void mouseDoubleClickEvent ( QMouseEvent * event );
|
||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
|
@ -113,6 +113,7 @@ OptionsDialog::OptionsDialog(QWidget * parent)
|
|||||||
layoutGeneral->addWidget(slideSizeBox);
|
layoutGeneral->addWidget(slideSizeBox);
|
||||||
layoutGeneral->addWidget(fitBox);
|
layoutGeneral->addWidget(fitBox);
|
||||||
layoutGeneral->addWidget(colorBox);
|
layoutGeneral->addWidget(colorBox);
|
||||||
|
layoutGeneral->addWidget(shortcutsBox);
|
||||||
layoutGeneral->addStretch();
|
layoutGeneral->addStretch();
|
||||||
layoutFlow->addWidget(sw);
|
layoutFlow->addWidget(sw);
|
||||||
layoutFlow->addWidget(gl);
|
layoutFlow->addWidget(gl);
|
||||||
|
@ -51,7 +51,7 @@ ShortcutsDialog::ShortcutsDialog(QWidget * parent)
|
|||||||
|
|
||||||
setLayout(imgMainLayout);
|
setLayout(imgMainLayout);
|
||||||
|
|
||||||
setFixedSize(QSize(700,500));
|
setFixedSize(QSize(700,500));
|
||||||
|
|
||||||
QFile f(":/files/shortcuts.html");
|
QFile f(":/files/shortcuts.html");
|
||||||
f.open(QIODevice::ReadOnly);
|
f.open(QIODevice::ReadOnly);
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#include "page_label_widget.h"
|
#include "page_label_widget.h"
|
||||||
#include "notifications_label_widget.h"
|
#include "notifications_label_widget.h"
|
||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
|
#include "shortcuts_manager.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
|
||||||
@ -367,62 +369,72 @@ void Viewer::scrollUp()
|
|||||||
|
|
||||||
void Viewer::keyPressEvent(QKeyEvent *event)
|
void Viewer::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if(render->hasLoadedComic())
|
if(render->hasLoadedComic())
|
||||||
{
|
{
|
||||||
if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
|
int _key = event->key();
|
||||||
QCoreApplication::sendEvent(goToFlow,event);
|
Qt::KeyboardModifiers modifiers = event->modifiers();
|
||||||
else
|
|
||||||
switch (event->key())
|
if(modifiers & Qt::ShiftModifier)
|
||||||
{
|
_key |= Qt::SHIFT;
|
||||||
case Qt::Key_Space:
|
if (modifiers & Qt::ControlModifier)
|
||||||
posByStep = height()/numScrollSteps;
|
_key |= Qt::CTRL;
|
||||||
nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80));
|
if (modifiers & Qt::MetaModifier)
|
||||||
scrollDown();
|
_key |= Qt::META;
|
||||||
break;
|
if (modifiers & Qt::AltModifier)
|
||||||
case Qt::Key_B:
|
_key |= Qt::ALT;
|
||||||
posByStep = height()/numScrollSteps;
|
|
||||||
nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80));
|
QKeySequence key(_key);
|
||||||
scrollUp();
|
/*if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
|
||||||
break;
|
QCoreApplication::sendEvent(goToFlow,event);
|
||||||
case Qt::Key_S:
|
else*/
|
||||||
goToFlowSwitch();
|
|
||||||
break;
|
if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y))
|
||||||
case Qt::Key_T:
|
{
|
||||||
translatorSwitch();
|
posByStep = height()/numScrollSteps;
|
||||||
break;
|
nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80));
|
||||||
case Qt::Key_Down:
|
scrollDown();
|
||||||
/*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())
|
}
|
||||||
next();
|
|
||||||
else*/
|
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y))
|
||||||
QAbstractScrollArea::keyPressEvent(event);
|
{
|
||||||
emit backgroundChanges();
|
posByStep = height()/numScrollSteps;
|
||||||
break;
|
nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80));
|
||||||
case Qt::Key_Up:
|
scrollUp();
|
||||||
/*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum())
|
}
|
||||||
prev();
|
|
||||||
else*/
|
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y) ||
|
||||||
QAbstractScrollArea::keyPressEvent(event);
|
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y) ||
|
||||||
emit backgroundChanges();
|
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y) ||
|
||||||
break;
|
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y))
|
||||||
case Qt::Key_Home:
|
{
|
||||||
goTo(0);
|
QAbstractScrollArea::keyPressEvent(event);
|
||||||
break;
|
emit backgroundChanges();
|
||||||
case Qt::Key_End:
|
}
|
||||||
goTo(this->render->numPages()-1);
|
|
||||||
break;
|
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y))
|
||||||
default:
|
{
|
||||||
QAbstractScrollArea::keyPressEvent(event);
|
goTo(0);
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
if(mglass->isVisible())
|
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y))
|
||||||
switch(event->key())
|
{
|
||||||
{
|
goTo(this->render->numPages()-1);
|
||||||
case Qt::Key_Plus: case Qt::Key_Minus: case Qt::Key_Underscore: case Qt::Key_Asterisk:
|
}
|
||||||
QCoreApplication::sendEvent(mglass,event);
|
|
||||||
}
|
else
|
||||||
}
|
QAbstractScrollArea::keyPressEvent(event);
|
||||||
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::wheelEvent(QWheelEvent * event)
|
void Viewer::wheelEvent(QWheelEvent * event)
|
||||||
|
@ -73,5 +73,15 @@
|
|||||||
<file>../images/dropDownArrow.png</file>
|
<file>../images/dropDownArrow.png</file>
|
||||||
<file>../images/translatorSearch.png</file>
|
<file>../images/translatorSearch.png</file>
|
||||||
<file>../images/speaker.png</file>
|
<file>../images/speaker.png</file>
|
||||||
|
<file>../images/clear_shortcut.png</file>
|
||||||
|
<file>../images/accept_shortcut.png</file>
|
||||||
|
<file>../images/shortcuts_group_comics.png</file>
|
||||||
|
<file>../images/shortcuts_group_folders.png</file>
|
||||||
|
<file>../images/shortcuts_group_general.png</file>
|
||||||
|
<file>../images/shortcuts_group_libraries.png</file>
|
||||||
|
<file>../images/shortcuts_group_mglass.png</file>
|
||||||
|
<file>../images/shortcuts_group_page.png</file>
|
||||||
|
<file>../images/shortcuts_group_reading.png</file>
|
||||||
|
<file>../images/shortcuts_group_visualization.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -8,5 +8,5 @@ Terminal=false
|
|||||||
Type=Application
|
Type=Application
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
Categories=Graphics;Viewer;
|
Categories=Graphics;Viewer;
|
||||||
MimeType=application/x-cbz;application/x-cbr;application/x-cbt;application/x-cb7;
|
MimeType=
|
||||||
X-Desktop-File-Install-Version=0.22
|
X-Desktop-File-Install-Version=0.22
|
||||||
|
@ -13,7 +13,7 @@ INCLUDEPATH += ../common \
|
|||||||
./comic_vine \
|
./comic_vine \
|
||||||
./comic_vine/model
|
./comic_vine/model
|
||||||
|
|
||||||
DEFINES += SERVER_RELEASE NOMINMAX
|
DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY
|
||||||
|
|
||||||
win32 {
|
win32 {
|
||||||
|
|
||||||
@ -34,7 +34,6 @@ CONFIG -= embed_manifest_exe
|
|||||||
}
|
}
|
||||||
|
|
||||||
unix:!macx{
|
unix:!macx{
|
||||||
QMAKE_CXXFLAGS += -std=c++11
|
|
||||||
|
|
||||||
isEqual(QT_MAJOR_VERSION, 5) {
|
isEqual(QT_MAJOR_VERSION, 5) {
|
||||||
INCLUDEPATH += /usr/include/poppler/qt5
|
INCLUDEPATH += /usr/include/poppler/qt5
|
||||||
@ -67,6 +66,10 @@ CONFIG += objective_c
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unix{
|
||||||
|
QMAKE_CXXFLAGS += -std=c++11
|
||||||
|
}
|
||||||
|
|
||||||
#CONFIG += release
|
#CONFIG += release
|
||||||
CONFIG -= flat
|
CONFIG -= flat
|
||||||
QT += sql network opengl script
|
QT += sql network opengl script
|
||||||
@ -113,6 +116,10 @@ HEADERS += comic_flow.h \
|
|||||||
../common/http_worker.h \
|
../common/http_worker.h \
|
||||||
yacreader_libraries.h \
|
yacreader_libraries.h \
|
||||||
../common/exit_check.h \
|
../common/exit_check.h \
|
||||||
|
comics_view.h \
|
||||||
|
classic_comics_view.h \
|
||||||
|
empty_folder_widget.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += comic_flow.cpp \
|
SOURCES += comic_flow.cpp \
|
||||||
create_library_dialog.cpp \
|
create_library_dialog.cpp \
|
||||||
@ -156,6 +163,10 @@ SOURCES += comic_flow.cpp \
|
|||||||
../common/yacreader_global.cpp \
|
../common/yacreader_global.cpp \
|
||||||
yacreader_libraries.cpp \
|
yacreader_libraries.cpp \
|
||||||
../common/exit_check.cpp \
|
../common/exit_check.cpp \
|
||||||
|
comics_view.cpp \
|
||||||
|
classic_comics_view.cpp \
|
||||||
|
empty_folder_widget.cpp
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
include(./server/server.pri)
|
include(./server/server.pri)
|
||||||
@ -163,6 +174,7 @@ include(../custom_widgets/custom_widgets_yacreaderlibrary.pri)
|
|||||||
include(../compressed_archive/wrapper.pri)
|
include(../compressed_archive/wrapper.pri)
|
||||||
include(./comic_vine/comic_vine.pri)
|
include(./comic_vine/comic_vine.pri)
|
||||||
include(../QsLog/QsLog.pri)
|
include(../QsLog/QsLog.pri)
|
||||||
|
include(../shortcuts_management/shortcuts_management.pri)
|
||||||
|
|
||||||
RESOURCES += images.qrc files.qrc
|
RESOURCES += images.qrc files.qrc
|
||||||
win32:RESOURCES += images_win.qrc
|
win32:RESOURCES += images_win.qrc
|
||||||
@ -186,6 +198,21 @@ TRANSLATIONS = yacreaderlibrary_es.ts \
|
|||||||
isEqual(QT_MAJOR_VERSION, 5) {
|
isEqual(QT_MAJOR_VERSION, 5) {
|
||||||
Release:DESTDIR = ../release5
|
Release:DESTDIR = ../release5
|
||||||
Debug:DESTDIR = ../debug5
|
Debug:DESTDIR = ../debug5
|
||||||
|
|
||||||
|
#QML/GridView
|
||||||
|
QT += quick qml
|
||||||
|
|
||||||
|
HEADERS += grid_comics_view.h \
|
||||||
|
comics_view_transition.h
|
||||||
|
|
||||||
|
SOURCES += grid_comics_view.cpp \
|
||||||
|
comics_view_transition.cpp
|
||||||
|
|
||||||
|
RESOURCES += qml.qrc
|
||||||
|
win32:RESOURCES += qml_win.qrc
|
||||||
|
unix:!macx:RESOURCES += qml_win.qrc
|
||||||
|
macx:RESOURCES += qml_osx.qrc
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Release:DESTDIR = ../release
|
Release:DESTDIR = ../release
|
||||||
Debug:DESTDIR = ../debug
|
Debug:DESTDIR = ../debug
|
||||||
|
243
YACReaderLibrary/classic_comics_view.cpp
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
#include "classic_comics_view.h"
|
||||||
|
|
||||||
|
#include "yacreader_table_view.h"
|
||||||
|
|
||||||
|
#include "comic_flow_widget.h"
|
||||||
|
#include "QsLog.h"
|
||||||
|
|
||||||
|
ClassicComicsView::ClassicComicsView(QWidget *parent)
|
||||||
|
:ComicsView(parent)
|
||||||
|
{
|
||||||
|
QHBoxLayout * layout = new QHBoxLayout;
|
||||||
|
|
||||||
|
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat); //TODO unificar la creación del fichero de config con el servidor
|
||||||
|
settings->beginGroup("libraryConfig");
|
||||||
|
//FLOW-----------------------------------------------------------------------
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if(QGLFormat::hasOpenGL() && (settings->value(USE_OPEN_GL).toBool() == true))
|
||||||
|
comicFlow = new ComicFlowWidgetGL(0);
|
||||||
|
else
|
||||||
|
comicFlow = new ComicFlowWidgetSW(0);
|
||||||
|
|
||||||
|
comicFlow->updateConfig(settings);
|
||||||
|
comicFlow->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
comicFlow->setShowMarks(true);
|
||||||
|
setFocusProxy(comicFlow);
|
||||||
|
|
||||||
|
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||||
|
|
||||||
|
comicFlow->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
|
|
||||||
|
//TODO!!! set actions....
|
||||||
|
//comicFlow->addAction(toggleFullScreenAction);
|
||||||
|
//comicFlow->addAction(openComicAction);
|
||||||
|
|
||||||
|
//END FLOW----
|
||||||
|
|
||||||
|
|
||||||
|
//layout-----------------------------------------------
|
||||||
|
sVertical = new QSplitter(Qt::Vertical); //spliter derecha
|
||||||
|
|
||||||
|
sVertical->addWidget(comicFlow);
|
||||||
|
comics = new QWidget;
|
||||||
|
QVBoxLayout * comicsLayout = new QVBoxLayout;
|
||||||
|
comicsLayout->setSpacing(0);
|
||||||
|
comicsLayout->setContentsMargins(0,0,0,0);
|
||||||
|
//TODO ComicsView:(set toolbar) comicsLayout->addWidget(editInfoToolBar);
|
||||||
|
|
||||||
|
tableView = new YACReaderTableView;
|
||||||
|
tableView->verticalHeader()->hide();
|
||||||
|
tableView->setFocusPolicy(Qt::StrongFocus);
|
||||||
|
comicsLayout->addWidget(tableView);
|
||||||
|
comics->setLayout(comicsLayout);
|
||||||
|
sVertical->addWidget(comics);
|
||||||
|
|
||||||
|
//config--------------------------------------------------
|
||||||
|
if(settings->contains(COMICS_VIEW_HEADERS))
|
||||||
|
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
|
||||||
|
|
||||||
|
//connections---------------------------------------------
|
||||||
|
connect(tableView, SIGNAL(clicked(QModelIndex)), this, SLOT(centerComicFlow(QModelIndex)));
|
||||||
|
connect(comicFlow, SIGNAL(centerIndexChanged(int)), this, SLOT(updateTableView(int)));
|
||||||
|
connect(tableView, SIGNAL(comicRated(int,QModelIndex)), this, SIGNAL(comicRated(int,QModelIndex)));
|
||||||
|
connect(comicFlow, SIGNAL(selected(uint)), this, SIGNAL(selected(uint)));
|
||||||
|
connect(tableView->horizontalHeader(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveTableHeadersStatus()));
|
||||||
|
|
||||||
|
layout->addWidget(sVertical);
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
layout->setMargin(0);
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
sVertical->setCollapsible(1,false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::setToolBar(QToolBar *toolBar)
|
||||||
|
{
|
||||||
|
static_cast<QVBoxLayout *>(comics->layout())->insertWidget(0,toolBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::setModel(TableModel *model)
|
||||||
|
{
|
||||||
|
|
||||||
|
ComicsView::setModel(model);
|
||||||
|
|
||||||
|
if(model == NULL)
|
||||||
|
{
|
||||||
|
comicFlow->clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)), this, SLOT(applyModelChanges(QModelIndex,QModelIndex,QVector<int>)));
|
||||||
|
connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(removeItemsFromFlow(QModelIndex,int,int)));
|
||||||
|
|
||||||
|
tableView->setModel(model);
|
||||||
|
|
||||||
|
tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
tableView->horizontalHeader()->setSectionsMovable(true);
|
||||||
|
#else
|
||||||
|
tableView->horizontalHeader()->setMovable(true);
|
||||||
|
#endif
|
||||||
|
//TODO parametrizar la configuración de las columnas
|
||||||
|
for(int i = 0;i<tableView->horizontalHeader()->count();i++)
|
||||||
|
tableView->horizontalHeader()->hideSection(i);
|
||||||
|
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::Number);
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::Title);
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::FileName);
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::NumPages);
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::Hash); //Size is part of the Hash...TODO add Columns::Size to Columns
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::ReadColumn);
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::CurrentPage);
|
||||||
|
tableView->horizontalHeader()->showSection(TableModel::Rating);
|
||||||
|
|
||||||
|
//debido a un bug, qt4 no es capaz de ajustar el ancho teniendo en cuenta todas la filas (no sólo las visibles)
|
||||||
|
//así que se ecala la primera vez y después se deja el control al usuario.
|
||||||
|
//if(!settings->contains(COMICS_VIEW_HEADERS))
|
||||||
|
tableView->resizeColumnsToContents();
|
||||||
|
tableView->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
|
||||||
|
QStringList paths = model->getPaths(model->getCurrentPath());//TODO ComicsView: get currentpath from somewhere currentPath());
|
||||||
|
comicFlow->setImagePaths(paths);
|
||||||
|
comicFlow->setMarks(model->getReadList());
|
||||||
|
//comicFlow->setFocus(Qt::OtherFocusReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(settings->contains(COMICS_VIEW_HEADERS))
|
||||||
|
tableView->horizontalHeader()->restoreState(settings->value(COMICS_VIEW_HEADERS).toByteArray());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::setCurrentIndex(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
tableView->setCurrentIndex(index);
|
||||||
|
//TODO ComicsView: scroll comicFlow to index
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex ClassicComicsView::currentIndex()
|
||||||
|
{
|
||||||
|
return tableView->currentIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
QItemSelectionModel *ClassicComicsView::selectionModel()
|
||||||
|
{
|
||||||
|
return tableView->selectionModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint)
|
||||||
|
{
|
||||||
|
comicFlow->setCenterIndex(mi.row());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::toFullScreen()
|
||||||
|
{
|
||||||
|
comicFlow->hide();
|
||||||
|
comicFlow->setCenterIndex(comicFlow->centerIndex());
|
||||||
|
comics->hide();
|
||||||
|
|
||||||
|
//showFullScreen() //parent windows
|
||||||
|
|
||||||
|
comicFlow->show();
|
||||||
|
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::toNormal()
|
||||||
|
{
|
||||||
|
comicFlow->hide();
|
||||||
|
comicFlow->setCenterIndex(comicFlow->centerIndex());
|
||||||
|
comicFlow->render();
|
||||||
|
comics->show();
|
||||||
|
comicFlow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::updateConfig(QSettings *settings)
|
||||||
|
{
|
||||||
|
comicFlow->updateConfig(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::setItemActions(const QList<QAction *> &actions)
|
||||||
|
{
|
||||||
|
tableView->addActions(actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::setViewActions(const QList<QAction *> &actions)
|
||||||
|
{
|
||||||
|
comicFlow->addActions(actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::selectAll()
|
||||||
|
{
|
||||||
|
tableView->selectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::setShowMarks(bool show)
|
||||||
|
{
|
||||||
|
comicFlow->setShowMarks(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::centerComicFlow(const QModelIndex & mi)
|
||||||
|
{
|
||||||
|
comicFlow->showSlide(mi.row());
|
||||||
|
comicFlow->setFocus(Qt::OtherFocusReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::updateTableView(int i)
|
||||||
|
{
|
||||||
|
QModelIndex mi = model->index(i,2);
|
||||||
|
tableView->setCurrentIndex(mi);
|
||||||
|
tableView->scrollTo(mi,QAbstractItemView::EnsureVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::saveTableHeadersStatus()
|
||||||
|
{
|
||||||
|
settings->setValue(COMICS_VIEW_HEADERS,tableView->horizontalHeader()->saveState());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::applyModelChanges(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
|
||||||
|
{
|
||||||
|
Q_UNUSED(topLeft);
|
||||||
|
Q_UNUSED(bottomRight);
|
||||||
|
if(roles.contains(TableModel::ReadColumnRole))
|
||||||
|
{
|
||||||
|
comicFlow->setMarks(model->getReadList());
|
||||||
|
comicFlow->updateMarks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::removeItemsFromFlow(const QModelIndex &parent, int from, int to)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
for(int i = from; i<=to; i++)
|
||||||
|
comicFlow->remove(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassicComicsView::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
saveTableHeadersStatus();
|
||||||
|
ComicsView::closeEvent(event);
|
||||||
|
}
|
||||||
|
|
51
YACReaderLibrary/classic_comics_view.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef CLASSIC_COMICS_VIEW_H
|
||||||
|
#define CLASSIC_COMICS_VIEW_H
|
||||||
|
|
||||||
|
#include "comics_view.h"
|
||||||
|
|
||||||
|
#include <QModelIndex>
|
||||||
|
#include <QModelIndexList>
|
||||||
|
|
||||||
|
class YACReaderTableView;
|
||||||
|
class QSplitter;
|
||||||
|
class ComicFlowWidget;
|
||||||
|
class QToolBar;
|
||||||
|
class TableModel;
|
||||||
|
|
||||||
|
class ClassicComicsView : public ComicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ClassicComicsView(QWidget *parent = 0);
|
||||||
|
void setToolBar(QToolBar * toolBar);
|
||||||
|
void setModel(TableModel *model);
|
||||||
|
void setCurrentIndex(const QModelIndex &index);
|
||||||
|
QModelIndex currentIndex();
|
||||||
|
QItemSelectionModel * selectionModel();
|
||||||
|
void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint );
|
||||||
|
void toFullScreen();
|
||||||
|
void toNormal();
|
||||||
|
void updateConfig(QSettings * settings);
|
||||||
|
void setItemActions(const QList<QAction *> & actions);
|
||||||
|
void setViewActions(const QList<QAction *> & actions);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void centerComicFlow(const QModelIndex & mi);
|
||||||
|
void updateTableView(int i);
|
||||||
|
void saveTableHeadersStatus();
|
||||||
|
void applyModelChanges(const QModelIndex & topLeft,const QModelIndex & bottomRight,const QVector<int> & roles);
|
||||||
|
void removeItemsFromFlow(const QModelIndex & parent, int from, int to);
|
||||||
|
//ComicsView
|
||||||
|
void setShowMarks(bool show);
|
||||||
|
void selectAll();
|
||||||
|
|
||||||
|
private:
|
||||||
|
YACReaderTableView * tableView;
|
||||||
|
QWidget *comics;
|
||||||
|
QSplitter * sVertical;
|
||||||
|
ComicFlowWidget * comicFlow;
|
||||||
|
QSettings * settings;
|
||||||
|
void closeEvent ( QCloseEvent * event );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CLASSIC_COMICS_VIEW_H
|
11
YACReaderLibrary/comics_view.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "comics_view.h"
|
||||||
|
|
||||||
|
ComicsView::ComicsView(QWidget *parent) :
|
||||||
|
QWidget(parent),model(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicsView::setModel(TableModel *m)
|
||||||
|
{
|
||||||
|
model = m;
|
||||||
|
}
|
47
YACReaderLibrary/comics_view.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#ifndef COMICS_VIEW_H
|
||||||
|
#define COMICS_VIEW_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "tablemodel.h"
|
||||||
|
#include <QAbstractItemView>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QModelIndex>
|
||||||
|
#include <QModelIndexList>
|
||||||
|
|
||||||
|
class YACReaderTableView;
|
||||||
|
class QSplitter;
|
||||||
|
class ComicFlowWidget;
|
||||||
|
class QToolBar;
|
||||||
|
class TableModel;
|
||||||
|
class ComicsView : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ComicsView(QWidget *parent = 0);
|
||||||
|
virtual void setToolBar(QToolBar * toolBar) = 0;
|
||||||
|
virtual void setModel(TableModel *model);
|
||||||
|
virtual void setCurrentIndex(const QModelIndex &index) = 0;
|
||||||
|
virtual QModelIndex currentIndex() = 0;
|
||||||
|
virtual QItemSelectionModel * selectionModel() = 0;
|
||||||
|
virtual void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint ) = 0;
|
||||||
|
virtual void toFullScreen() = 0;
|
||||||
|
virtual void toNormal() = 0;
|
||||||
|
virtual void updateConfig(QSettings * settings) = 0;
|
||||||
|
//Actions for tableviews
|
||||||
|
virtual void setItemActions(const QList<QAction *> & actions) = 0;
|
||||||
|
//actions for visual-oriented views
|
||||||
|
virtual void setViewActions(const QList<QAction *> & actions) = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selected(unsigned int);
|
||||||
|
void comicRated(int,QModelIndex);
|
||||||
|
public slots:
|
||||||
|
virtual void setShowMarks(bool show) = 0;
|
||||||
|
virtual void selectAll() = 0;
|
||||||
|
protected:
|
||||||
|
TableModel * model;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COMICS_VIEW_H
|
74
YACReaderLibrary/comics_view_transition.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#include "comics_view_transition.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMovie>
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QSizePolicy>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
ComicsViewTransition::ComicsViewTransition(QWidget *parent) :
|
||||||
|
QWidget(parent),movie(0)
|
||||||
|
{
|
||||||
|
QVBoxLayout * layout = new QVBoxLayout;
|
||||||
|
|
||||||
|
settings = new QSettings(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
|
settings->beginGroup("libraryConfig");
|
||||||
|
|
||||||
|
movieLabel = new QLabel("Placeholder");
|
||||||
|
movieLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
QLabel * textLabel = new QLabel("Switching comics view");
|
||||||
|
textLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
textLabel->setStyleSheet("QLabel {color:#CCCCCC; font-size:24px;font-family:Arial;font-weight:bold;}");
|
||||||
|
//movieLabel->setFixedSize(450,350);
|
||||||
|
|
||||||
|
layout->addSpacing(100);
|
||||||
|
layout->addWidget(movieLabel);
|
||||||
|
layout->addSpacing(20);
|
||||||
|
layout->addWidget(textLabel);
|
||||||
|
layout->addStretch();
|
||||||
|
layout->setMargin(0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
setStyleSheet("QWidget {background:#2A2A2A}");
|
||||||
|
|
||||||
|
//QSizePolicy sp();
|
||||||
|
setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||||
|
//movieLabel->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize ComicsViewTransition::sizeHint()
|
||||||
|
{
|
||||||
|
return QSize(450,350);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicsViewTransition::startMovie()
|
||||||
|
{
|
||||||
|
if(movie)
|
||||||
|
delete movie;
|
||||||
|
|
||||||
|
if(settings->value(COMICS_VIEW_STATUS) == YACReader::Flow)
|
||||||
|
movie = new QMovie(":/images/flow_to_grid.gif");
|
||||||
|
else
|
||||||
|
movie = new QMovie(":/images/grid_to_flow.gif");
|
||||||
|
|
||||||
|
connect(movie,SIGNAL(finished()),this,SIGNAL(transitionFinished()));
|
||||||
|
//connect(movie,SIGNAL(finished()),movie,SLOT(deleteLater());
|
||||||
|
movie->setSpeed(200);
|
||||||
|
movie->jumpToFrame(0);
|
||||||
|
movieLabel->setMovie(movie);
|
||||||
|
|
||||||
|
QTimer::singleShot(100,movie,SLOT(start()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComicsViewTransition::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter (this);
|
||||||
|
painter.fillRect(0,0,width(),height(),QColor("#2A2A2A"));
|
||||||
|
}
|
31
YACReaderLibrary/comics_view_transition.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef COMICS_VIEW_TRANSITION_H
|
||||||
|
#define COMICS_VIEW_TRANSITION_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QMovie;
|
||||||
|
class QSettings;
|
||||||
|
class QLabel;
|
||||||
|
|
||||||
|
class ComicsViewTransition : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ComicsViewTransition(QWidget *parent = 0);
|
||||||
|
QSize sizeHint();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void transitionFinished();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void startMovie();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QMovie * movie;
|
||||||
|
QSettings * settings;
|
||||||
|
QLabel * movieLabel;
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // COMICS_VIEW_TRANSITION_H
|
@ -210,7 +210,7 @@ bool DataBaseManagement::createTables(QSqlDatabase & database)
|
|||||||
//queryDBInfo.finish();
|
//queryDBInfo.finish();
|
||||||
|
|
||||||
QSqlQuery query("INSERT INTO db_info (version) "
|
QSqlQuery query("INSERT INTO db_info (version) "
|
||||||
"VALUES ('"VERSION"')",database);
|
"VALUES ('" VERSION "')",database);
|
||||||
//query.finish();
|
//query.finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,7 +245,7 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
|||||||
queryComicsInfo.exec();*/
|
queryComicsInfo.exec();*/
|
||||||
|
|
||||||
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
||||||
"VALUES ('"VERSION"')",destDB);
|
"VALUES ('" VERSION "')",destDB);
|
||||||
//query.finish();
|
//query.finish();
|
||||||
|
|
||||||
QSqlQuery exportData(destDB);
|
QSqlQuery exportData(destDB);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
TableModel::TableModel(QObject *parent)
|
TableModel::TableModel(QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
|
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
|
||||||
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
|
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
|
||||||
@ -23,7 +23,7 @@ TableModel::TableModel(QObject *parent)
|
|||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
TableModel::TableModel( QSqlQuery &sqlquery, QObject *parent)
|
TableModel::TableModel( QSqlQuery &sqlquery, QObject *parent)
|
||||||
: QAbstractItemModel(parent)
|
: QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
setupModelData(sqlquery);
|
setupModelData(sqlquery);
|
||||||
}
|
}
|
||||||
@ -46,6 +46,27 @@ int TableModel::columnCount(const QModelIndex &parent) const
|
|||||||
}
|
}
|
||||||
//! [2]
|
//! [2]
|
||||||
|
|
||||||
|
QHash<int, QByteArray> TableModel::roleNames() const {
|
||||||
|
QHash<int, QByteArray> roles;
|
||||||
|
|
||||||
|
roles[NumberRole] = "number";
|
||||||
|
roles[TitleRole] = "title";
|
||||||
|
roles[FileNameRole] = "file_name";
|
||||||
|
roles[NumPagesRole] = "num_pages";
|
||||||
|
roles[IdRole] = "id";
|
||||||
|
roles[Parent_IdRole] = "parent_id";
|
||||||
|
roles[PathRole] = "path";
|
||||||
|
roles[HashRole] = "hash";
|
||||||
|
roles[ReadColumnRole] = "read_column";
|
||||||
|
roles[IsBisRole] = "is_bis";
|
||||||
|
roles[CurrentPageRole] = "current_page";
|
||||||
|
roles[RatingRole] = "rating";
|
||||||
|
roles[HasBeenOpenedRole] = "has_been_opened";
|
||||||
|
roles[CoverPathRole] = "cover_path";
|
||||||
|
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
//! [3]
|
//! [3]
|
||||||
QVariant TableModel::data(const QModelIndex &index, int role) const
|
QVariant TableModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
@ -84,10 +105,28 @@ QVariant TableModel::data(const QModelIndex &index, int role) const
|
|||||||
//TODO check here if any view is asking for TableModel::Roles
|
//TODO check here if any view is asking for TableModel::Roles
|
||||||
//these roles will be used from QML/GridView
|
//these roles will be used from QML/GridView
|
||||||
|
|
||||||
if (role != Qt::DisplayRole)
|
|
||||||
return QVariant();
|
|
||||||
|
|
||||||
TableItem *item = static_cast<TableItem*>(index.internalPointer());
|
TableItem *item = static_cast<TableItem*>(index.internalPointer());
|
||||||
|
|
||||||
|
if (role == NumberRole)
|
||||||
|
return item->data(Number);
|
||||||
|
else if (role == TitleRole)
|
||||||
|
return item->data(Title).isNull()?item->data(FileName):item->data(Title);
|
||||||
|
else if (role == RatingRole)
|
||||||
|
return item->data(Rating);
|
||||||
|
else if (role == CoverPathRole)
|
||||||
|
return "file:///"+_databasePath+"/covers/"+item->data(Hash).toString()+".jpg";
|
||||||
|
else if (role == NumPagesRole)
|
||||||
|
return item->data(NumPages);
|
||||||
|
else if (role == CurrentPageRole)
|
||||||
|
return item->data(CurrentPage);
|
||||||
|
else if (role == ReadColumnRole)
|
||||||
|
return item->data(ReadColumn).toBool();
|
||||||
|
else if (role == HasBeenOpenedRole)
|
||||||
|
return item->data(TableModel::HasBeenOpened);
|
||||||
|
|
||||||
|
if (role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
if(index.column() == TableModel::Hash)
|
if(index.column() == TableModel::Hash)
|
||||||
return QString::number(item->data(index.column()).toString().right(item->data(index.column()).toString().length()-40).toInt()/1024.0/1024.0,'f',2)+"Mb";
|
return QString::number(item->data(index.column()).toString().right(item->data(index.column()).toString().length()-40).toInt()/1024.0/1024.0,'f',2)+"Mb";
|
||||||
if(index.column() == TableModel::ReadColumn)
|
if(index.column() == TableModel::ReadColumn)
|
||||||
@ -265,7 +304,9 @@ void TableModel::setupModelData(unsigned long long int folderId,const QString &
|
|||||||
db.close();
|
db.close();
|
||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
endResetModel();
|
endResetModel();
|
||||||
//f.close();
|
|
||||||
|
if(_data.length()==0)
|
||||||
|
emit isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TableModel::getComicPath(QModelIndex mi)
|
QString TableModel::getComicPath(QModelIndex mi)
|
||||||
@ -467,7 +508,7 @@ QVector<YACReaderComicReadStatus> TableModel::setComicsRead(QList<QModelIndex> l
|
|||||||
db.close();
|
db.close();
|
||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
|
||||||
emit dataChanged(index(list.first().row(),TableModel::ReadColumn),index(list.last().row(),TableModel::CurrentPage+1));
|
emit dataChanged(index(list.first().row(),TableModel::ReadColumn),index(list.last().row(),TableModel::HasBeenOpened),QVector<int>() << ReadColumnRole << CurrentPageRole << HasBeenOpenedRole);
|
||||||
|
|
||||||
return getReadList();
|
return getReadList();
|
||||||
}
|
}
|
||||||
@ -553,10 +594,10 @@ void TableModel::remove(ComicDB * comic, int row)
|
|||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
ComicDB TableModel::getComic(int row)
|
/*ComicDB TableModel::getComic(int row)
|
||||||
{
|
{
|
||||||
return getComic(index(row,0));
|
return getComic(index(row,0));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
void TableModel::remove(int row)
|
void TableModel::remove(int row)
|
||||||
{
|
{
|
||||||
@ -580,8 +621,8 @@ void TableModel::reload(const ComicDB & comic)
|
|||||||
}
|
}
|
||||||
row++;
|
row++;
|
||||||
}
|
}
|
||||||
if(found)
|
if(found)
|
||||||
emit dataChanged(index(row,TableModel::CurrentPage),index(row,TableModel::CurrentPage));
|
emit dataChanged(index(row,ReadColumn),index(row,HasBeenOpened), QVector<int>() << ReadColumnRole << CurrentPageRole << HasBeenOpenedRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableModel::resetComicRating(const QModelIndex &mi)
|
void TableModel::resetComicRating(const QModelIndex &mi)
|
||||||
@ -600,27 +641,6 @@ void TableModel::resetComicRating(const QModelIndex &mi)
|
|||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> TableModel::roleNames()
|
|
||||||
{
|
|
||||||
QHash<int, QByteArray> roles;
|
|
||||||
|
|
||||||
roles[NumberRole] = "number";
|
|
||||||
roles[TitleRole] = "title";
|
|
||||||
roles[FileNameRole] = "file_name";
|
|
||||||
roles[NumPagesRole] = "num_pages";
|
|
||||||
roles[IdRole] = "id";
|
|
||||||
roles[Parent_IdRole] = "parent_id";
|
|
||||||
roles[PathRole] = "path";
|
|
||||||
roles[HashRole] = "hash";
|
|
||||||
roles[ReadColumnRole] = "read";
|
|
||||||
roles[IsBisRole] = "is_bis";
|
|
||||||
roles[CurrentPageRole] = "current_page";
|
|
||||||
roles[RatingRole] = "rating";
|
|
||||||
roles[HasBeenOpenedRole] = "has_been_opened";
|
|
||||||
roles[CoverPathRole] = "cover_path";
|
|
||||||
|
|
||||||
return roles;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TableModel::updateRating(int rating, QModelIndex mi)
|
void TableModel::updateRating(int rating, QModelIndex mi)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
TableModel(QObject *parent = 0);
|
TableModel(QObject *parent = 0);
|
||||||
TableModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
TableModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
||||||
~TableModel();
|
~TableModel();
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation,
|
QVariant headerData(int section, Qt::Orientation orientation,
|
||||||
@ -39,8 +39,9 @@ public:
|
|||||||
//M<>todos de conveniencia
|
//M<>todos de conveniencia
|
||||||
QStringList getPaths(const QString & _source);
|
QStringList getPaths(const QString & _source);
|
||||||
QString getComicPath(QModelIndex mi);
|
QString getComicPath(QModelIndex mi);
|
||||||
|
QString getCurrentPath(){return QString(_databasePath).remove("/.yacreaderlibrary");};
|
||||||
ComicDB getComic(const QModelIndex & mi); //--> para la edici<63>n
|
ComicDB getComic(const QModelIndex & mi); //--> para la edici<63>n
|
||||||
ComicDB getComic(int row);
|
//ComicDB getComic(int row);
|
||||||
QVector<YACReaderComicReadStatus> getReadList();
|
QVector<YACReaderComicReadStatus> getReadList();
|
||||||
QVector<YACReaderComicReadStatus> setAllComicsRead(YACReaderComicReadStatus readStatus);
|
QVector<YACReaderComicReadStatus> setAllComicsRead(YACReaderComicReadStatus readStatus);
|
||||||
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la informaci<63>n com<6F>n a los comics seleccionados
|
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la informaci<63>n com<6F>n a los comics seleccionados
|
||||||
@ -56,7 +57,7 @@ public:
|
|||||||
void reload(const ComicDB & comic);
|
void reload(const ComicDB & comic);
|
||||||
void resetComicRating(const QModelIndex & mi);
|
void resetComicRating(const QModelIndex & mi);
|
||||||
|
|
||||||
QHash<int, QByteArray> roleNames();
|
QHash<int, QByteArray> roleNames() const;
|
||||||
|
|
||||||
enum Columns {
|
enum Columns {
|
||||||
Number = 0,
|
Number = 0,
|
||||||
@ -98,6 +99,8 @@ public slots:
|
|||||||
void finishTransaction();
|
void finishTransaction();
|
||||||
void updateRating(int rating, QModelIndex mi);
|
void updateRating(int rating, QModelIndex mi);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData( QSqlQuery &sqlquery);
|
void setupModelData( QSqlQuery &sqlquery);
|
||||||
ComicDB _getComic(const QModelIndex & mi);
|
ComicDB _getComic(const QModelIndex & mi);
|
||||||
@ -110,6 +113,7 @@ private:
|
|||||||
signals:
|
signals:
|
||||||
void beforeReset();
|
void beforeReset();
|
||||||
void reset();
|
void reset();
|
||||||
|
void isEmpty();
|
||||||
};
|
};
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "data_base_management.h"
|
#include "data_base_management.h"
|
||||||
#include "folder.h"
|
#include "folder.h"
|
||||||
#include "db_helper.h"
|
#include "db_helper.h"
|
||||||
|
#include "qnaturalsorting.h"
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <QFileIconProvider>
|
#include <QFileIconProvider>
|
||||||
@ -106,7 +107,7 @@ TreeModel::TreeModel(QObject *parent)
|
|||||||
TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
|
TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
|
||||||
: QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false)
|
: QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false)
|
||||||
{
|
{
|
||||||
//lo m<>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
|
//lo m<>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
|
||||||
QList<QVariant> rootData;
|
QList<QVariant> rootData;
|
||||||
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
|
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
|
||||||
rootItem = new TreeItem(rootData);
|
rootItem = new TreeItem(rootData);
|
||||||
@ -265,7 +266,7 @@ void TreeModel::setupModelData(QString path)
|
|||||||
filterEnabled = false;
|
filterEnabled = false;
|
||||||
rootItem = 0;
|
rootItem = 0;
|
||||||
rootBeforeFilter = 0;
|
rootBeforeFilter = 0;
|
||||||
//inicializar el nodo ra<72>z
|
//inicializar el nodo ra<72>z
|
||||||
QList<QVariant> rootData;
|
QList<QVariant> rootData;
|
||||||
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
|
rootData << "root"; //id 0, padre 0, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
|
||||||
rootItem = new TreeItem(rootData);
|
rootItem = new TreeItem(rootData);
|
||||||
@ -291,10 +292,10 @@ void TreeModel::setupModelData(QString path)
|
|||||||
|
|
||||||
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||||
{
|
{
|
||||||
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
||||||
//el diccionario permitir<69> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
|
//el diccionario permitir<69> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
|
||||||
items.clear();
|
items.clear();
|
||||||
//se a<>ade el nodo 0
|
//se a<>ade el nodo 0
|
||||||
items.insert(parent->id,parent);
|
items.insert(parent->id,parent);
|
||||||
|
|
||||||
while (sqlquery.next()) {
|
while (sqlquery.next()) {
|
||||||
@ -308,11 +309,11 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
|||||||
TreeItem * item = new TreeItem(data);
|
TreeItem * item = new TreeItem(data);
|
||||||
|
|
||||||
item->id = record.value("id").toULongLong();
|
item->id = record.value("id").toULongLong();
|
||||||
//la inserci<63>n de hijos se hace de forma ordenada
|
//la inserci<63>n de hijos se hace de forma ordenada
|
||||||
TreeItem * parent = items.value(record.value("parentId").toULongLong());
|
TreeItem * parent = items.value(record.value("parentId").toULongLong());
|
||||||
if(parent !=0) //TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
|
if(parent !=0) //TODO if parent==0 the parent of item was removed from the DB and delete on cascade didn't work, ERROR.
|
||||||
parent->appendChild(item);
|
parent->appendChild(item);
|
||||||
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||||
items.insert(item->id,item);
|
items.insert(item->id,item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,12 +324,12 @@ void TreeModel::setupFilteredModelData()
|
|||||||
|
|
||||||
//TODO hay que liberar memoria de anteriores filtrados
|
//TODO hay que liberar memoria de anteriores filtrados
|
||||||
|
|
||||||
//inicializar el nodo ra<72>z
|
//inicializar el nodo ra<72>z
|
||||||
|
|
||||||
if(rootBeforeFilter == 0)
|
if(rootBeforeFilter == 0)
|
||||||
rootBeforeFilter = rootItem;
|
rootBeforeFilter = rootItem;
|
||||||
else
|
else
|
||||||
delete rootItem;//los resultados de la b<>squeda anterior deben ser borrados
|
delete rootItem;//los resultados de la b<>squeda anterior deben ser borrados
|
||||||
|
|
||||||
QList<QVariant> rootData;
|
QList<QVariant> rootData;
|
||||||
rootData << "root"; //id 1, padre 1, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
|
rootData << "root"; //id 1, padre 1, title "root" (el id, y el id del padre van a ir en la clase TreeItem)
|
||||||
@ -365,10 +366,10 @@ void TreeModel::setupFilteredModelData()
|
|||||||
|
|
||||||
void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||||
{
|
{
|
||||||
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
//64 bits para la primary key, es decir la misma precisi<73>n que soporta sqlit 2^64
|
||||||
filteredItems.clear();
|
filteredItems.clear();
|
||||||
|
|
||||||
//se a<>ade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro
|
//se a<>ade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro
|
||||||
filteredItems.insert(parent->id,parent);
|
filteredItems.insert(parent->id,parent);
|
||||||
|
|
||||||
while (sqlquery.next()) { //se procesan todos los folders que cumplen con el filtro
|
while (sqlquery.next()) { //se procesan todos los folders que cumplen con el filtro
|
||||||
@ -387,39 +388,39 @@ void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
|||||||
//id del padre
|
//id del padre
|
||||||
quint64 parentId = record.value("parentId").toULongLong();
|
quint64 parentId = record.value("parentId").toULongLong();
|
||||||
|
|
||||||
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
//se a<>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||||
if(!filteredItems.contains(item->id))
|
if(!filteredItems.contains(item->id))
|
||||||
filteredItems.insert(item->id,item);
|
filteredItems.insert(item->id,item);
|
||||||
|
|
||||||
//es necesario conocer las coordenadas de origen para poder realizar scroll autom<6F>tico en la vista
|
//es necesario conocer las coordenadas de origen para poder realizar scroll autom<6F>tico en la vista
|
||||||
item->originalItem = items.value(item->id);
|
item->originalItem = items.value(item->id);
|
||||||
|
|
||||||
//si el padre ya existe en el modelo, el item se a<>ade como hijo
|
//si el padre ya existe en el modelo, el item se a<>ade como hijo
|
||||||
if(filteredItems.contains(parentId))
|
if(filteredItems.contains(parentId))
|
||||||
filteredItems.value(parentId)->appendChild(item);
|
filteredItems.value(parentId)->appendChild(item);
|
||||||
else//si el padre a<>n no se ha a<>adido, hay que a<>adirlo a <20>l y todos los padres hasta el nodo ra<72>z
|
else//si el padre a<>n no se ha a<>adido, hay que a<>adirlo a <20>l y todos los padres hasta el nodo ra<72>z
|
||||||
{
|
{
|
||||||
//comprobamos con esta variable si el <20>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
|
//comprobamos con esta variable si el <20>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
|
||||||
bool parentPreviousInserted = false;
|
bool parentPreviousInserted = false;
|
||||||
|
|
||||||
//mientras no se alcance el nodo ra<72>z se procesan todos los padres (de abajo a arriba)
|
//mientras no se alcance el nodo ra<72>z se procesan todos los padres (de abajo a arriba)
|
||||||
while(parentId != ROOT )
|
while(parentId != ROOT )
|
||||||
{
|
{
|
||||||
//el padre no estaba en el modelo filtrado, as<61> que se rescata del modelo original
|
//el padre no estaba en el modelo filtrado, as<61> que se rescata del modelo original
|
||||||
TreeItem * parentItem = items.value(parentId);
|
TreeItem * parentItem = items.value(parentId);
|
||||||
//se debe crear un nuevo nodo (para no compartir los hijos con el nodo original)
|
//se debe crear un nuevo nodo (para no compartir los hijos con el nodo original)
|
||||||
TreeItem * newparentItem = new TreeItem(parentItem->getData()); //padre que se a<>adir<69> a la estructura de directorios filtrados
|
TreeItem * newparentItem = new TreeItem(parentItem->getData()); //padre que se a<>adir<69> a la estructura de directorios filtrados
|
||||||
newparentItem->id = parentId;
|
newparentItem->id = parentId;
|
||||||
|
|
||||||
newparentItem->originalItem = parentItem;
|
newparentItem->originalItem = parentItem;
|
||||||
|
|
||||||
//si el modelo contiene al padre, se a<>ade el item actual como hijo
|
//si el modelo contiene al padre, se a<>ade el item actual como hijo
|
||||||
if(filteredItems.contains(parentId))
|
if(filteredItems.contains(parentId))
|
||||||
{
|
{
|
||||||
filteredItems.value(parentId)->appendChild(item);
|
filteredItems.value(parentId)->appendChild(item);
|
||||||
parentPreviousInserted = true;
|
parentPreviousInserted = true;
|
||||||
}
|
}
|
||||||
//sino se registra el nodo para poder encontrarlo con posterioridad y se a<>ade el item actual como hijo
|
//sino se registra el nodo para poder encontrarlo con posterioridad y se a<>ade el item actual como hijo
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newparentItem->appendChild(item);
|
newparentItem->appendChild(item);
|
||||||
@ -432,7 +433,7 @@ void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
|||||||
parentId = parentItem->parentItem->id;
|
parentId = parentItem->parentItem->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
//si el nodo es hijo de 1 y no hab<61>a sido previamente insertado como hijo, se a<>ade como tal
|
//si el nodo es hijo de 1 y no hab<61>a sido previamente insertado como hijo, se a<>ade como tal
|
||||||
if(!parentPreviousInserted)
|
if(!parentPreviousInserted)
|
||||||
filteredItems.value(ROOT)->appendChild(item);
|
filteredItems.value(ROOT)->appendChild(item);
|
||||||
}
|
}
|
||||||
@ -468,7 +469,7 @@ void TreeModel::resetFilter()
|
|||||||
//items.clear();
|
//items.clear();
|
||||||
filteredItems.clear();
|
filteredItems.clear();
|
||||||
TreeItem * root = rootItem;
|
TreeItem * root = rootItem;
|
||||||
rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidar<61>a en modelo
|
rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidar<61>a en modelo
|
||||||
if(root !=0)
|
if(root !=0)
|
||||||
delete root;
|
delete root;
|
||||||
|
|
||||||
@ -518,3 +519,26 @@ void TreeModel::updateFolderFinishedStatus(const QModelIndexList &list, bool sta
|
|||||||
|
|
||||||
emit dataChanged(index(list.first().row(),TreeModel::Name),index(list.last().row(),TreeModel::Completed));
|
emit dataChanged(index(list.first().row(),TreeModel::Name),index(list.last().row(),TreeModel::Completed));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList TreeModel::getSubfoldersNames(const QModelIndex &mi)
|
||||||
|
{
|
||||||
|
QStringList result;
|
||||||
|
qulonglong id = 1;
|
||||||
|
if(mi.isValid()){
|
||||||
|
TreeItem * item = static_cast<TreeItem*>(mi.internalPointer());
|
||||||
|
id = item->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSqlDatabase db = DataBaseManagement::loadDatabase(_databasePath);
|
||||||
|
db.transaction();
|
||||||
|
|
||||||
|
result = DBHelper::loadSubfoldersNames(id,db);
|
||||||
|
|
||||||
|
db.commit();
|
||||||
|
db.close();
|
||||||
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
|
|
||||||
|
//TODO sort result))
|
||||||
|
qSort(result.begin(),result.end(),naturalSortLessThanCI);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -85,6 +85,8 @@ public:
|
|||||||
void updateFolderCompletedStatus(const QModelIndexList & list, bool status);
|
void updateFolderCompletedStatus(const QModelIndexList & list, bool status);
|
||||||
void updateFolderFinishedStatus(const QModelIndexList & list, bool status);
|
void updateFolderFinishedStatus(const QModelIndexList & list, bool status);
|
||||||
|
|
||||||
|
QStringList getSubfoldersNames(const QModelIndex & mi);
|
||||||
|
|
||||||
enum Columns {
|
enum Columns {
|
||||||
Name = 0,
|
Name = 0,
|
||||||
Path = 1,
|
Path = 1,
|
||||||
|
@ -254,6 +254,7 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
|||||||
updateComicInfo.bindValue(":notes",comicInfo->notes);
|
updateComicInfo.bindValue(":notes",comicInfo->notes);
|
||||||
|
|
||||||
bool read = comicInfo->read || comicInfo->currentPage == comicInfo->numPages.toInt(); //if current page is the las page, the comic is read(completed)
|
bool read = comicInfo->read || comicInfo->currentPage == comicInfo->numPages.toInt(); //if current page is the las page, the comic is read(completed)
|
||||||
|
comicInfo->read = read;
|
||||||
updateComicInfo.bindValue(":read", read?1:0);
|
updateComicInfo.bindValue(":read", read?1:0);
|
||||||
updateComicInfo.bindValue(":id", comicInfo->id);
|
updateComicInfo.bindValue(":id", comicInfo->id);
|
||||||
updateComicInfo.bindValue(":edited", comicInfo->edited?1:0);
|
updateComicInfo.bindValue(":edited", comicInfo->edited?1:0);
|
||||||
@ -312,6 +313,7 @@ void DBHelper::updateProgress(qulonglong libraryId, const ComicInfo &comicInfo)
|
|||||||
db.close();
|
db.close();
|
||||||
QSqlDatabase::removeDatabase(libraryPath);
|
QSqlDatabase::removeDatabase(libraryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//inserts
|
//inserts
|
||||||
qulonglong DBHelper::insert(Folder * folder, QSqlDatabase & db)
|
qulonglong DBHelper::insert(Folder * folder, QSqlDatabase & db)
|
||||||
{
|
{
|
||||||
@ -686,5 +688,18 @@ ComicInfo DBHelper::loadComicInfo(QString hash, QSqlDatabase & db)
|
|||||||
else
|
else
|
||||||
comicInfo.existOnDb = false;
|
comicInfo.existOnDb = false;
|
||||||
|
|
||||||
return comicInfo;
|
return comicInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QString> DBHelper::loadSubfoldersNames(qulonglong folderId, QSqlDatabase &db)
|
||||||
|
{
|
||||||
|
QList<QString> result;
|
||||||
|
QSqlQuery selectQuery(db);
|
||||||
|
selectQuery.prepare("SELECT name FROM folder WHERE parentId = :parentId AND id <> 1"); //do not select the root folder
|
||||||
|
selectQuery.bindValue(":parentId", folderId);
|
||||||
|
selectQuery.exec();
|
||||||
|
while(selectQuery.next()){
|
||||||
|
result << selectQuery.record().value("name").toString();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
static ComicDB loadComic(qulonglong id, QSqlDatabase & db);
|
static ComicDB loadComic(qulonglong id, QSqlDatabase & db);
|
||||||
static ComicDB loadComic(QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
static ComicDB loadComic(QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
||||||
static ComicInfo loadComicInfo(QString hash, QSqlDatabase & db);
|
static ComicInfo loadComicInfo(QString hash, QSqlDatabase & db);
|
||||||
|
static QList<QString> loadSubfoldersNames(qulonglong folderId, QSqlDatabase & db);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
89
YACReaderLibrary/empty_folder_widget.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#include "empty_folder_widget.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
|
||||||
|
#include <QStringListModel>
|
||||||
|
void testListView(QListView * l)
|
||||||
|
{
|
||||||
|
QStringListModel * slm = new QStringListModel(QStringList() << "Lorem ipsum" << "Hailer skualer"<< "Mumbaluba X" << "Finger layden" << "Pacum tactus filer" << "Aposum" << "En" << "Lorem ipsum" << "Hailer skualer" << "Mumbaluba X" << "Finger layden" << "Pacum tactus filer" << "Aposum" << "En" );
|
||||||
|
l->setModel(slm);
|
||||||
|
}
|
||||||
|
|
||||||
|
EmptyFolderWidget::EmptyFolderWidget(QWidget *parent) :
|
||||||
|
QWidget(parent),subfoldersModel(new QStringListModel())
|
||||||
|
{
|
||||||
|
QVBoxLayout * layout = new QVBoxLayout;
|
||||||
|
|
||||||
|
iconLabel = new QLabel();
|
||||||
|
iconLabel->setPixmap(QPixmap(":/images/empty_folder.png"));
|
||||||
|
iconLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
|
titleLabel = new QLabel("Subfolders in this folder");
|
||||||
|
titleLabel->setAlignment(Qt::AlignCenter);
|
||||||
|
titleLabel->setStyleSheet("QLabel {color:#CCCCCC; font-size:24px;font-family:Arial;font-weight:bold;}");
|
||||||
|
|
||||||
|
foldersView = new QListView();
|
||||||
|
foldersView->setMinimumWidth(282);
|
||||||
|
foldersView->setWrapping(true);
|
||||||
|
|
||||||
|
foldersView->setStyleSheet("QListView {background-color:transparent; border: none; color:#858585; outline:0; font-size: 18px; font:bold; show-decoration-selected: 0; margin:0}"
|
||||||
|
"QListView::item:selected {background-color: #212121; color:#CCCCCC;}"
|
||||||
|
"QListView::item:hover {background-color:#212121; color:#CCCCCC; }"
|
||||||
|
|
||||||
|
|
||||||
|
"QScrollBar:vertical { border: none; background: #212121; width: 14px; margin: 0 10px 0 0; }"
|
||||||
|
"QScrollBar::handle:vertical { background: #858585; width: 14px; min-height: 20px; }"
|
||||||
|
"QScrollBar::add-line:vertical { border: none; background: #212121; height: 0px; subcontrol-position: bottom; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||||
|
|
||||||
|
"QScrollBar::sub-line:vertical { border: none; background: #212121; height: 0px; subcontrol-position: top; subcontrol-origin: margin; margin: 0 3px 0 0;}"
|
||||||
|
"QScrollBar::up-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-up.png') center top no-repeat;}"
|
||||||
|
"QScrollBar::down-arrow:vertical {border:none;width: 9px;height: 6px;background: url(':/images/folders_view/line-down.png') center top no-repeat;}"
|
||||||
|
|
||||||
|
"QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {background: none; }"
|
||||||
|
"QScrollBar:horizontal{height:0px;}"
|
||||||
|
);
|
||||||
|
|
||||||
|
foldersView->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||||
|
testListView(foldersView);
|
||||||
|
|
||||||
|
layout->addSpacing(100);
|
||||||
|
layout->addWidget(iconLabel);
|
||||||
|
layout->addSpacing(30);
|
||||||
|
layout->addWidget(titleLabel);
|
||||||
|
layout->addSpacing(12);
|
||||||
|
layout->addWidget(foldersView,1,Qt::AlignHCenter);
|
||||||
|
layout->addStretch();
|
||||||
|
layout->setMargin(0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
setStyleSheet("QWidget {background:#2A2A2A}");
|
||||||
|
|
||||||
|
setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
connect(foldersView,SIGNAL(clicked(QModelIndex)),this,SLOT(onItemClicked(QModelIndex)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyFolderWidget::setSubfolders(const QModelIndex &mi, const QStringList &foldersNames)
|
||||||
|
{
|
||||||
|
parent = mi;
|
||||||
|
subfoldersModel->setStringList(foldersNames);
|
||||||
|
foldersView->setModel(subfoldersModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyFolderWidget::onItemClicked(const QModelIndex &mi)
|
||||||
|
{
|
||||||
|
emit subfolderSelected(parent,mi.row());
|
||||||
|
}
|
||||||
|
|
||||||
|
void EmptyFolderWidget::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter (this);
|
||||||
|
painter.fillRect(0,0,width(),height(),QColor("#2A2A2A"));
|
||||||
|
}
|
32
YACReaderLibrary/empty_folder_widget.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#ifndef EMPTY_FOLDER_WIDGET_H
|
||||||
|
#define EMPTY_FOLDER_WIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QListView;
|
||||||
|
class QStringListModel;
|
||||||
|
|
||||||
|
class EmptyFolderWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EmptyFolderWidget(QWidget *parent = 0);
|
||||||
|
void setSubfolders(const QModelIndex & mi, const QStringList & foldersNames);
|
||||||
|
signals:
|
||||||
|
void subfolderSelected(QModelIndex, int);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onItemClicked(const QModelIndex & mi);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QLabel * iconLabel;
|
||||||
|
QLabel * titleLabel;
|
||||||
|
QListView * foldersView;
|
||||||
|
QModelIndex parent;
|
||||||
|
QStringListModel * subfoldersModel;
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EMPTY_FOLDER_WIDGET_H
|
234
YACReaderLibrary/grid_comics_view.cpp
Normal file
@ -0,0 +1,234 @@
|
|||||||
|
#include "grid_comics_view.h"
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
#include <QtQuick>
|
||||||
|
|
||||||
|
#include "QsLog.h"
|
||||||
|
|
||||||
|
GridComicsView::GridComicsView(QWidget *parent) :
|
||||||
|
ComicsView(parent),_selectionModel(NULL)
|
||||||
|
{
|
||||||
|
qmlRegisterType<TableModel>("comicModel",1,0,"TableModel");
|
||||||
|
|
||||||
|
view = new QQuickView();
|
||||||
|
container = QWidget::createWindowContainer(view, this);
|
||||||
|
|
||||||
|
container->setMinimumSize(200, 200);
|
||||||
|
container->setFocusPolicy(Qt::TabFocus);
|
||||||
|
view->setSource(QUrl("qrc:/qml/GridComicsView.qml"));
|
||||||
|
|
||||||
|
setShowMarks(true);//TODO save this in settings
|
||||||
|
|
||||||
|
QVBoxLayout * l = new QVBoxLayout;
|
||||||
|
l->addWidget(container);
|
||||||
|
this->setLayout(l);
|
||||||
|
|
||||||
|
setContentsMargins(0,0,0,0);
|
||||||
|
l->setContentsMargins(0,0,0,0);
|
||||||
|
l->setSpacing(0);
|
||||||
|
|
||||||
|
QLOG_INFO() << "GridComicsView";
|
||||||
|
}
|
||||||
|
|
||||||
|
GridComicsView::~GridComicsView()
|
||||||
|
{
|
||||||
|
delete view;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::setToolBar(QToolBar *toolBar)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "setToolBar";
|
||||||
|
static_cast<QVBoxLayout *>(this->layout())->insertWidget(1,toolBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::setModel(TableModel *model)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "setModel";
|
||||||
|
|
||||||
|
QQmlContext *ctxt = view->rootContext();
|
||||||
|
|
||||||
|
//there is only one mothel in the system
|
||||||
|
ComicsView::setModel(model);
|
||||||
|
if(this->model != NULL)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "xxx";
|
||||||
|
|
||||||
|
if(_selectionModel != NULL)
|
||||||
|
delete _selectionModel;
|
||||||
|
_selectionModel = new QItemSelectionModel(this->model);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("comicsList", this->model);
|
||||||
|
ctxt->setContextProperty("comicsSelection", _selectionModel);
|
||||||
|
ctxt->setContextProperty("comicsSelectionHelper", this);
|
||||||
|
ctxt->setContextProperty("dummyValue", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
ctxt->setContextProperty("backgroundColor", "#EDEDED");
|
||||||
|
ctxt->setContextProperty("cellColor", "#FFFFFF");
|
||||||
|
ctxt->setContextProperty("selectedColor", "#DDDDDD");
|
||||||
|
ctxt->setContextProperty("titleColor", "#121212");
|
||||||
|
ctxt->setContextProperty("textColor", "#636363");
|
||||||
|
ctxt->setContextProperty("dropShadow",true);
|
||||||
|
#else
|
||||||
|
ctxt->setContextProperty("backgroundColor", "#2A2A2A");
|
||||||
|
ctxt->setContextProperty("cellColor", "#212121");
|
||||||
|
ctxt->setContextProperty("selectedColor", "#121212");
|
||||||
|
ctxt->setContextProperty("titleColor", "#E6E6E6");
|
||||||
|
ctxt->setContextProperty("textColor", "#E6E6E6");
|
||||||
|
ctxt->setContextProperty("dropShadow",false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::setCurrentIndex(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "setCurrentIndex";
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex GridComicsView::currentIndex()
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "currentIndex";
|
||||||
|
QModelIndexList indexes = _selectionModel->selectedRows();
|
||||||
|
if(indexes.length()>0)
|
||||||
|
return indexes[0];
|
||||||
|
|
||||||
|
this->selectIndex(0);
|
||||||
|
return _selectionModel->selectedRows()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
QItemSelectionModel *GridComicsView::selectionModel()
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "selectionModel";
|
||||||
|
QModelIndexList indexes = _selectionModel->selectedRows();
|
||||||
|
if(indexes.length()==0)
|
||||||
|
this->selectIndex(0);
|
||||||
|
|
||||||
|
return _selectionModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::scrollTo(const QModelIndex &mi, QAbstractItemView::ScrollHint hint)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "scrollTo";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::toFullScreen()
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "toFullScreen";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::toNormal()
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "toNormal";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::updateConfig(QSettings *settings)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "updateConfig";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::setItemActions(const QList<QAction *> &actions)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "setItemActions";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::setViewActions(const QList<QAction *> &actions)
|
||||||
|
{
|
||||||
|
//TODO generate QML Menu from actions
|
||||||
|
QLOG_INFO() << "setViewActions";
|
||||||
|
this->addActions(actions);
|
||||||
|
|
||||||
|
//TODO this is completely unsafe, but QActions can't be used directly in QML
|
||||||
|
if(actions.length()>17)
|
||||||
|
{
|
||||||
|
QQmlContext *ctxt = view->rootContext();
|
||||||
|
|
||||||
|
ctxt->setContextProperty("openComicAction",actions[0]);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("openContainingFolderComicAction",actions[2]);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("resetComicRatingAction",actions[4]);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("editSelectedComicsAction",actions[6]);
|
||||||
|
ctxt->setContextProperty("getInfoAction",actions[7]);
|
||||||
|
ctxt->setContextProperty("asignOrderAction",actions[8]);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("selectAllComicsAction",actions[10]);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("setAsReadAction",actions[12]);
|
||||||
|
ctxt->setContextProperty("setAsNonReadAction",actions[13]);
|
||||||
|
ctxt->setContextProperty("showHideMarksAction",actions[14]);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("deleteComicsAction",actions[16]);
|
||||||
|
|
||||||
|
ctxt->setContextProperty("toggleFullScreenAction",actions[18]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QLOG_ERROR() << "setViewActions invoked with the wrong number of actions";
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::selectAll()
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "selectAll";
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize GridComicsView::sizeHint()
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "sizeHint";
|
||||||
|
return QSize(1280,768);
|
||||||
|
}
|
||||||
|
|
||||||
|
//helper
|
||||||
|
void GridComicsView::selectIndex(int index)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "selectIndex" << index;
|
||||||
|
if(_selectionModel != NULL && model!=NULL)
|
||||||
|
_selectionModel->select(model->index(index,0),QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GridComicsView::isSelectedIndex(int index)
|
||||||
|
{
|
||||||
|
if(_selectionModel != NULL && model!=NULL)
|
||||||
|
{
|
||||||
|
QModelIndex mi = model->index(index,0);
|
||||||
|
return _selectionModel->isSelected(mi);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::clear()
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "clear";
|
||||||
|
if(_selectionModel != NULL)
|
||||||
|
{
|
||||||
|
_selectionModel->clear();
|
||||||
|
|
||||||
|
QQmlContext *ctxt = view->rootContext();
|
||||||
|
ctxt->setContextProperty("dummyValue", true);
|
||||||
|
}
|
||||||
|
//model->forceClear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::selectedItem(int index)
|
||||||
|
{
|
||||||
|
emit doubleClicked(model->index(index,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::setShowMarks(bool show)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "setShowMarks";
|
||||||
|
QQmlContext *ctxt = view->rootContext();
|
||||||
|
ctxt->setContextProperty("show_marks", show);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GridComicsView::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
QLOG_INFO() << "closeEvent";
|
||||||
|
QObject *object = view->rootObject();
|
||||||
|
QMetaObject::invokeMethod(object, "exit");
|
||||||
|
container->close();
|
||||||
|
view->close();
|
||||||
|
event->accept();
|
||||||
|
ComicsView::closeEvent(event);
|
||||||
|
}
|
59
YACReaderLibrary/grid_comics_view.h
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
#ifndef GRID_COMICS_VIEW_H
|
||||||
|
#define GRID_COMICS_VIEW_H
|
||||||
|
|
||||||
|
#include "comics_view.h"
|
||||||
|
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
class QAbstractListModel;
|
||||||
|
class QItemSelectionModel;
|
||||||
|
class QQuickView;
|
||||||
|
class QQuickView;
|
||||||
|
|
||||||
|
|
||||||
|
class GridComicsView : public ComicsView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit GridComicsView(QWidget *parent = 0);
|
||||||
|
virtual ~GridComicsView();
|
||||||
|
void setToolBar(QToolBar * toolBar);
|
||||||
|
void setModel(TableModel *model);
|
||||||
|
void setCurrentIndex(const QModelIndex &index);
|
||||||
|
QModelIndex currentIndex();
|
||||||
|
QItemSelectionModel * selectionModel();
|
||||||
|
void scrollTo(const QModelIndex & mi, QAbstractItemView::ScrollHint hint );
|
||||||
|
void toFullScreen();
|
||||||
|
void toNormal();
|
||||||
|
void updateConfig(QSettings * settings);
|
||||||
|
void setItemActions(const QList<QAction *> & actions);
|
||||||
|
void setViewActions(const QList<QAction *> & actions);
|
||||||
|
|
||||||
|
QSize sizeHint();
|
||||||
|
signals:
|
||||||
|
signals:
|
||||||
|
void comicRated(int,QModelIndex);
|
||||||
|
void doubleClicked(QModelIndex);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//selection helper
|
||||||
|
void selectIndex(int index);
|
||||||
|
bool isSelectedIndex(int index);
|
||||||
|
void clear();
|
||||||
|
//double clicked item
|
||||||
|
void selectedItem(int index);
|
||||||
|
|
||||||
|
//ComicsView
|
||||||
|
void setShowMarks(bool show);
|
||||||
|
void selectAll();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QItemSelectionModel * _selectionModel;
|
||||||
|
QQuickView *view;
|
||||||
|
QWidget *container;
|
||||||
|
bool dummy;
|
||||||
|
void closeEvent ( QCloseEvent * event );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GRID_COMICS_VIEW_H
|
@ -77,7 +77,7 @@
|
|||||||
<file>../images/social_dialog/shadow.png</file>
|
<file>../images/social_dialog/shadow.png</file>
|
||||||
<file>../images/social_dialog/twitter.png</file>
|
<file>../images/social_dialog/twitter.png</file>
|
||||||
<file>../images/social_dialog/separator.png</file>-->
|
<file>../images/social_dialog/separator.png</file>-->
|
||||||
<file>../images/main_toolbar/divider.png</file>
|
<file>../images/main_toolbar/divider.png</file>
|
||||||
<file>../images/collapsed_branch_osx.png</file>
|
<file>../images/collapsed_branch_osx.png</file>
|
||||||
<file>../images/expanded_branch_osx.png</file>
|
<file>../images/expanded_branch_osx.png</file>
|
||||||
<file>../images/folder_macosx.png</file>
|
<file>../images/folder_macosx.png</file>
|
||||||
@ -100,8 +100,18 @@
|
|||||||
<file>../images/comic_vine/downArrow.png</file>
|
<file>../images/comic_vine/downArrow.png</file>
|
||||||
<file>../images/comic_vine/upArrow.png</file>
|
<file>../images/comic_vine/upArrow.png</file>
|
||||||
<file>../images/find_folder.png</file>
|
<file>../images/find_folder.png</file>
|
||||||
|
<file>../images/clear_shortcut.png</file>
|
||||||
|
<file>../images/accept_shortcut.png</file>
|
||||||
<file>../images/f_overlayed.png</file>
|
<file>../images/f_overlayed.png</file>
|
||||||
<file>../images/f_overlayed_retina.png</file>
|
<file>../images/f_overlayed_retina.png</file>
|
||||||
|
<file>../images/shortcuts_group_comics.png</file>
|
||||||
|
<file>../images/shortcuts_group_folders.png</file>
|
||||||
|
<file>../images/shortcuts_group_general.png</file>
|
||||||
|
<file>../images/shortcuts_group_libraries.png</file>
|
||||||
|
<file>../images/shortcuts_group_mglass.png</file>
|
||||||
|
<file>../images/shortcuts_group_page.png</file>
|
||||||
|
<file>../images/shortcuts_group_reading.png</file>
|
||||||
|
<file>../images/shortcuts_group_visualization.png</file>
|
||||||
<!--<file>../images/busy_background.png</file>-->
|
<!--<file>../images/busy_background.png</file>-->
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -17,5 +17,8 @@
|
|||||||
<file alias="images/colapse.png">../images/colapse_osx.png</file>
|
<file alias="images/colapse.png">../images/colapse_osx.png</file>
|
||||||
<file alias="images/newLibraryIcon.png">../images/newLibraryIcon_osx.png</file>
|
<file alias="images/newLibraryIcon.png">../images/newLibraryIcon_osx.png</file>
|
||||||
<file alias="images/openLibraryIcon.png">../images/openLibraryIcon_osx.png</file>
|
<file alias="images/openLibraryIcon.png">../images/openLibraryIcon_osx.png</file>
|
||||||
|
<file alias="images/flow_to_grid.gif">../images/flow_to_grid.gif</file>
|
||||||
|
<file alias="images/grid_to_flow.gif">../images/grid_to_flow.gif</file>
|
||||||
|
<file alias="images/empty_folder.png">../images/empty_folder.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/" >
|
<qresource prefix="/">
|
||||||
<file>../images/main_toolbar/back.png</file>
|
<file>../images/main_toolbar/back.png</file>
|
||||||
<file>../images/main_toolbar/back_disabled.png</file>
|
<file>../images/main_toolbar/back_disabled.png</file>
|
||||||
<file>../images/main_toolbar/forward.png</file>
|
<file>../images/main_toolbar/forward.png</file>
|
||||||
<file>../images/main_toolbar/forward_disabled.png</file>
|
<file>../images/main_toolbar/forward_disabled.png</file>
|
||||||
<file>../images/main_toolbar/settings.png</file>
|
<file>../images/main_toolbar/settings.png</file>
|
||||||
<file>../images/main_toolbar/server.png</file>
|
<file>../images/main_toolbar/server.png</file>
|
||||||
<file>../images/main_toolbar/help.png</file>
|
<file>../images/main_toolbar/help.png</file>
|
||||||
<file>../images/main_toolbar/fullscreen.png</file>
|
<file>../images/main_toolbar/fullscreen.png</file>
|
||||||
|
<file>../images/libraryIcon.png</file>
|
||||||
<file>../images/libraryIcon.png</file>
|
<file>../images/setRoot.png</file>
|
||||||
<file>../images/setRoot.png</file>
|
<file>../images/expand.png</file>
|
||||||
<file>../images/expand.png</file>
|
<file>../images/colapse.png</file>
|
||||||
<file>../images/colapse.png</file>
|
<file>../images/newLibraryIcon.png</file>
|
||||||
<file>../images/newLibraryIcon.png</file>
|
<file>../images/openLibraryIcon.png</file>
|
||||||
<file>../images/openLibraryIcon.png</file>
|
<file>../images/main_toolbar/flow.png</file>
|
||||||
</qresource>
|
<file>../images/main_toolbar/grid.png</file>
|
||||||
|
<file>../images/flow_to_grid.gif</file>
|
||||||
|
<file>../images/grid_to_flow.gif</file>
|
||||||
|
<file>../images/empty_folder.png</file>
|
||||||
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -27,7 +27,6 @@ class HelpAboutDialog;
|
|||||||
class RenameLibraryDialog;
|
class RenameLibraryDialog;
|
||||||
class PropertiesDialog;
|
class PropertiesDialog;
|
||||||
class PackageManager;
|
class PackageManager;
|
||||||
class ComicFlowWidget;
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class TableModel;
|
class TableModel;
|
||||||
@ -50,6 +49,13 @@ class YACReaderLibraryListWidget;
|
|||||||
class YACReaderTreeView;
|
class YACReaderTreeView;
|
||||||
class YACReaderMainToolBar;
|
class YACReaderMainToolBar;
|
||||||
class ComicVineDialog;
|
class ComicVineDialog;
|
||||||
|
class ComicsView;
|
||||||
|
class ClassicComicsView;
|
||||||
|
class GridComicsView;
|
||||||
|
class ComicsViewTransition;
|
||||||
|
class EmptyFolderWidget;
|
||||||
|
class EditShortcutsDialog;
|
||||||
|
|
||||||
#include "comic_db.h"
|
#include "comic_db.h"
|
||||||
|
|
||||||
using namespace YACReader;
|
using namespace YACReader;
|
||||||
@ -59,7 +65,7 @@ class LibraryWindow : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
YACReaderSideBar * sideBar;
|
YACReaderSideBar * sideBar;
|
||||||
QSplitter * sVertical;
|
|
||||||
CreateLibraryDialog * createLibraryDialog;
|
CreateLibraryDialog * createLibraryDialog;
|
||||||
ExportLibraryDialog * exportLibraryDialog;
|
ExportLibraryDialog * exportLibraryDialog;
|
||||||
ImportLibraryDialog * importLibraryDialog;
|
ImportLibraryDialog * importLibraryDialog;
|
||||||
@ -71,6 +77,7 @@ private:
|
|||||||
RenameLibraryDialog * renameLibraryDialog;
|
RenameLibraryDialog * renameLibraryDialog;
|
||||||
PropertiesDialog * propertiesDialog;
|
PropertiesDialog * propertiesDialog;
|
||||||
ComicVineDialog * comicVineDialog;
|
ComicVineDialog * comicVineDialog;
|
||||||
|
EditShortcutsDialog * editShortcutsDialog;
|
||||||
//YACReaderSocialDialog * socialDialog;
|
//YACReaderSocialDialog * socialDialog;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
bool importedCovers; //if true, the library is read only (not updates,open comic or properties)
|
bool importedCovers; //if true, the library is read only (not updates,open comic or properties)
|
||||||
@ -80,7 +87,6 @@ private:
|
|||||||
//YACReaderSortComics * proxySort;
|
//YACReaderSortComics * proxySort;
|
||||||
PackageManager * packageManager;
|
PackageManager * packageManager;
|
||||||
|
|
||||||
ComicFlowWidget * comicFlow;
|
|
||||||
QSize slideSizeW;
|
QSize slideSizeW;
|
||||||
QSize slideSizeF;
|
QSize slideSizeF;
|
||||||
//search filter
|
//search filter
|
||||||
@ -91,15 +97,20 @@ private:
|
|||||||
QPushButton * clearFoldersFilter;
|
QPushButton * clearFoldersFilter;
|
||||||
QCheckBox * includeComicsCheckBox;
|
QCheckBox * includeComicsCheckBox;
|
||||||
//-------------
|
//-------------
|
||||||
QWidget *comics;
|
|
||||||
YACReaderTableView * comicView;
|
ComicsView * comicsView;
|
||||||
|
ClassicComicsView * classicComicsView;
|
||||||
|
GridComicsView * gridComicsView;
|
||||||
|
QStackedWidget * comicsViewStack;
|
||||||
|
ComicsViewTransition * comicsViewTransition;
|
||||||
|
EmptyFolderWidget * emptyFolderWidget;
|
||||||
|
|
||||||
YACReaderTreeView * foldersView;
|
YACReaderTreeView * foldersView;
|
||||||
YACReaderLibraryListWidget * selectedLibrary;
|
YACReaderLibraryListWidget * selectedLibrary;
|
||||||
TreeModel * dm;
|
TreeModel * dm;
|
||||||
TableModel * dmCV;
|
TableModel * dmCV;
|
||||||
//QStringList paths;
|
//QStringList paths;
|
||||||
YACReaderLibraries libraries;
|
YACReaderLibraries libraries;
|
||||||
QLabel * fullScreenToolTip;
|
|
||||||
|
|
||||||
QStackedWidget * mainWidget;
|
QStackedWidget * mainWidget;
|
||||||
NoLibrariesWidget * noLibrariesWidget;
|
NoLibrariesWidget * noLibrariesWidget;
|
||||||
@ -116,8 +127,8 @@ private:
|
|||||||
QAction * createLibraryAction;
|
QAction * createLibraryAction;
|
||||||
QAction * openLibraryAction;
|
QAction * openLibraryAction;
|
||||||
|
|
||||||
QAction * exportComicsInfo;
|
QAction * exportComicsInfoAction;
|
||||||
QAction * importComicsInfo;
|
QAction * importComicsInfoAction;
|
||||||
|
|
||||||
QAction * exportLibraryAction;
|
QAction * exportLibraryAction;
|
||||||
QAction * importLibraryAction;
|
QAction * importLibraryAction;
|
||||||
@ -129,6 +140,7 @@ private:
|
|||||||
QAction * toggleFullScreenAction;
|
QAction * toggleFullScreenAction;
|
||||||
QAction * optionsAction;
|
QAction * optionsAction;
|
||||||
QAction * serverConfigAction;
|
QAction * serverConfigAction;
|
||||||
|
QAction * toggleComicsViewAction;
|
||||||
//QAction * socialAction;
|
//QAction * socialAction;
|
||||||
|
|
||||||
//tree actions
|
//tree actions
|
||||||
@ -141,8 +153,8 @@ private:
|
|||||||
QAction * setFolderAsNotCompletedAction;
|
QAction * setFolderAsNotCompletedAction;
|
||||||
QAction * setFolderAsCompletedAction;
|
QAction * setFolderAsCompletedAction;
|
||||||
//--
|
//--
|
||||||
QAction * setFolderAsFinishedAction;
|
QAction * setFolderAsReadAction;
|
||||||
QAction * setFolderAsNotFinishedAction;
|
QAction * setFolderAsUnreadAction;
|
||||||
|
|
||||||
QAction * openContainingFolderComicAction;
|
QAction * openContainingFolderComicAction;
|
||||||
QAction * setAsReadAction;
|
QAction * setAsReadAction;
|
||||||
@ -156,11 +168,16 @@ private:
|
|||||||
//edit info actions
|
//edit info actions
|
||||||
QAction * selectAllComicsAction;
|
QAction * selectAllComicsAction;
|
||||||
QAction * editSelectedComicsAction;
|
QAction * editSelectedComicsAction;
|
||||||
QAction * asignOrderActions;
|
QAction * asignOrderAction;
|
||||||
QAction * forceConverExtractedAction;
|
QAction * forceCoverExtractedAction;
|
||||||
QAction * deleteComicsAction;
|
QAction * deleteComicsAction;
|
||||||
QAction * hideComicViewAction;
|
QAction * hideComicViewAction;
|
||||||
|
|
||||||
|
QAction *showEditShortcutsAction;
|
||||||
|
|
||||||
|
QList<QAction *> itemActions;
|
||||||
|
QList<QAction *> viewActions;
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QToolBar * libraryToolBar;
|
QToolBar * libraryToolBar;
|
||||||
#else
|
#else
|
||||||
@ -191,103 +208,113 @@ private:
|
|||||||
void createConnections();
|
void createConnections();
|
||||||
void doLayout();
|
void doLayout();
|
||||||
void doDialogs();
|
void doDialogs();
|
||||||
|
void setUpShortcutsManagement();
|
||||||
void doModels();
|
void doModels();
|
||||||
|
void disconnectComicsViewConnections(ComicsView * widget);
|
||||||
|
void doComicsViewConnections();
|
||||||
|
|
||||||
//ACTIONS MANAGEMENT
|
|
||||||
void disableComicsActions(bool disabled);
|
|
||||||
void disableLibrariesActions(bool disabled);
|
|
||||||
void disableNoUpdatedLibrariesActions(bool disabled);
|
|
||||||
void disableFoldersActions(bool disabled);
|
|
||||||
|
|
||||||
void disableAllActions();
|
//ACTIONS MANAGEMENT
|
||||||
//void disableActions();
|
void disableComicsActions(bool disabled);
|
||||||
//void enableActions();
|
void disableLibrariesActions(bool disabled);
|
||||||
//void enableLibraryActions();
|
void disableNoUpdatedLibrariesActions(bool disabled);
|
||||||
|
void disableFoldersActions(bool disabled);
|
||||||
|
|
||||||
QString currentPath();
|
void disableAllActions();
|
||||||
|
//void disableActions();
|
||||||
|
//void enableActions();
|
||||||
|
//void enableLibraryActions();
|
||||||
|
|
||||||
//settings
|
QString currentPath();
|
||||||
QSettings * settings;
|
|
||||||
|
|
||||||
//navigation backward and forward
|
//settings
|
||||||
int currentFolderNavigation;
|
QSettings * settings;
|
||||||
QList<QModelIndex> history;
|
|
||||||
|
|
||||||
bool removeError;
|
//navigation backward and forward
|
||||||
|
int currentFolderNavigation;
|
||||||
|
QList<QModelIndex> history;
|
||||||
|
|
||||||
|
bool removeError;
|
||||||
|
|
||||||
|
ComicsViewStatus comicsViewStatus;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent ( QCloseEvent * event );
|
virtual void closeEvent ( QCloseEvent * event );
|
||||||
public:
|
public:
|
||||||
LibraryWindow();
|
LibraryWindow();
|
||||||
public slots:
|
|
||||||
void loadLibrary(const QString & path);
|
public slots:
|
||||||
void loadCovers(const QModelIndex & mi);
|
void loadLibrary(const QString & path);
|
||||||
void checkEmptyFolder(QStringList * paths = 0);
|
void loadCovers(const QModelIndex & mi);
|
||||||
void reloadCovers();
|
void selectSubfolder(const QModelIndex & mi, int child);
|
||||||
void centerComicFlow(const QModelIndex & mi);
|
void checkEmptyFolder(QStringList * paths = 0);
|
||||||
void updateComicView(int i);
|
void reloadCovers();
|
||||||
void openComic();
|
void openComic();
|
||||||
void createLibrary();
|
void createLibrary();
|
||||||
void create(QString source,QString dest, QString name);
|
void create(QString source,QString dest, QString name);
|
||||||
void showAddLibrary();
|
void showAddLibrary();
|
||||||
void openLibrary(QString path, QString name);
|
void openLibrary(QString path, QString name);
|
||||||
void loadLibraries();
|
void loadLibraries();
|
||||||
void saveLibraries();
|
void saveLibraries();
|
||||||
void reloadCurrentLibrary();
|
void reloadCurrentLibrary();
|
||||||
void openLastCreated();
|
void openLastCreated();
|
||||||
void updateLibrary();
|
void updateLibrary();
|
||||||
//void deleteLibrary();
|
//void deleteLibrary();
|
||||||
void openContainingFolder();
|
void openContainingFolder();
|
||||||
void setFolderAsNotCompleted();
|
void setFolderAsNotCompleted();
|
||||||
void setFolderAsCompleted();
|
void setFolderAsCompleted();
|
||||||
void setFolderAsFinished();
|
void setFolderAsRead();
|
||||||
void setFolderAsNotFinished();
|
void setFolderAsUnread();
|
||||||
void openContainingFolderComic();
|
void openContainingFolderComic();
|
||||||
void deleteCurrentLibrary();
|
void deleteCurrentLibrary();
|
||||||
void removeLibrary();
|
void removeLibrary();
|
||||||
void renameLibrary();
|
void renameLibrary();
|
||||||
void rename(QString newName);
|
void rename(QString newName);
|
||||||
void cancelCreating();
|
void cancelCreating();
|
||||||
void stopLibraryCreator();
|
void stopLibraryCreator();
|
||||||
void setRootIndex();
|
void setRootIndex();
|
||||||
void toggleFullScreen();
|
void toggleFullScreen();
|
||||||
void toNormal();
|
void toNormal();
|
||||||
void toFullScreen();
|
void toFullScreen();
|
||||||
void setFoldersFilter(QString filter);
|
void setFoldersFilter(QString filter);
|
||||||
void showProperties();
|
void showProperties();
|
||||||
void exportLibrary(QString destPath);
|
void exportLibrary(QString destPath);
|
||||||
void importLibrary(QString clc,QString destPath,QString name);
|
void importLibrary(QString clc,QString destPath,QString name);
|
||||||
void reloadOptions();
|
void reloadOptions();
|
||||||
void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus);
|
void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus);
|
||||||
void setCurrentComicReaded();
|
void setCurrentComicReaded();
|
||||||
void setCurrentComicUnreaded();
|
void setCurrentComicUnreaded();
|
||||||
void setComicsReaded();
|
void hideComicFlow(bool hide);
|
||||||
void setComicsUnreaded();
|
void showExportComicsInfo();
|
||||||
void hideComicFlow(bool hide);
|
void showImportComicsInfo();
|
||||||
void showExportComicsInfo();
|
void asignNumbers();
|
||||||
void showImportComicsInfo();
|
void showNoLibrariesWidget();
|
||||||
void asignNumbers();
|
void showRootWidget();
|
||||||
void showNoLibrariesWidget();
|
void showImportingWidget();
|
||||||
void showRootWidget();
|
void manageCreatingError(const QString & error);
|
||||||
void showImportingWidget();
|
void manageUpdatingError(const QString & error);
|
||||||
void manageCreatingError(const QString & error);
|
void manageOpeningLibraryError(const QString & error);
|
||||||
void manageUpdatingError(const QString & error);
|
QModelIndexList getSelectedComics();
|
||||||
void manageOpeningLibraryError(const QString & error);
|
void deleteComics();
|
||||||
QModelIndexList getSelectedComics();
|
//void showSocial();
|
||||||
void deleteComics();
|
void backward();
|
||||||
//void showSocial();
|
void forward();
|
||||||
void backward();
|
void updateHistory(const QModelIndex & mi);
|
||||||
void forward();
|
void updateFoldersViewConextMenu(const QModelIndex & mi);
|
||||||
void updateHistory(const QModelIndex & mi);
|
void libraryAlreadyExists(const QString & name);
|
||||||
void updateFoldersViewConextMenu(const QModelIndex & mi);
|
void importLibraryPackage();
|
||||||
void libraryAlreadyExists(const QString & name);
|
void updateComicsView(quint64 libraryId, const ComicDB & comic);
|
||||||
void importLibraryPackage();
|
void setCurrentComicOpened();
|
||||||
void updateComicsView(quint64 libraryId, const ComicDB & comic);
|
void showComicVineScraper();
|
||||||
void setCurrentComicOpened();
|
void setRemoveError();
|
||||||
void showComicVineScraper();
|
void checkRemoveError();
|
||||||
void setRemoveError();
|
void resetComicRating();
|
||||||
void checkRemoveError();
|
void switchToComicsView(ComicsView *from, ComicsView *to);
|
||||||
void resetComicRating();
|
void showComicsViewTransition();
|
||||||
|
void toggleComicsView_delayed();//used in orther to avoid flickering;
|
||||||
|
void showComicsView();
|
||||||
|
void showEmptyFolderView();
|
||||||
|
void toggleComicsView();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -239,9 +239,12 @@ int main( int argc, char ** argv )
|
|||||||
|
|
||||||
YACReader::exitCheck(ret);
|
YACReader::exitCheck(ret);
|
||||||
|
|
||||||
//server shutdown
|
//shutdown
|
||||||
s->stop();
|
s->stop();
|
||||||
delete s;
|
delete s;
|
||||||
|
localServer->close();
|
||||||
|
delete localServer;
|
||||||
|
delete mw;
|
||||||
|
|
||||||
QsLogging::Logger::destroyInstance();
|
QsLogging::Logger::destroyInstance();
|
||||||
|
|
||||||
|
@ -20,33 +20,50 @@ FlowType flowType = Strip;
|
|||||||
OptionsDialog::OptionsDialog(QWidget * parent)
|
OptionsDialog::OptionsDialog(QWidget * parent)
|
||||||
:YACReaderOptionsDialog(parent)
|
:YACReaderOptionsDialog(parent)
|
||||||
{
|
{
|
||||||
QVBoxLayout * layout = new QVBoxLayout;
|
QTabWidget * tabWidget = new QTabWidget();
|
||||||
|
|
||||||
QHBoxLayout * switchFlowType = new QHBoxLayout;
|
QVBoxLayout * layout = new QVBoxLayout(this);
|
||||||
switchFlowType->addStretch();
|
|
||||||
switchFlowType->addWidget(useGL);
|
|
||||||
|
|
||||||
|
QVBoxLayout * flowLayout = new QVBoxLayout;
|
||||||
|
QVBoxLayout * generalLayout = new QVBoxLayout();
|
||||||
|
|
||||||
|
QHBoxLayout * switchFlowType = new QHBoxLayout;
|
||||||
|
switchFlowType->addStretch();
|
||||||
|
switchFlowType->addWidget(useGL);
|
||||||
|
|
||||||
QHBoxLayout * buttons = new QHBoxLayout();
|
QHBoxLayout * buttons = new QHBoxLayout();
|
||||||
buttons->addStretch();
|
buttons->addStretch();
|
||||||
buttons->addWidget(accept);
|
buttons->addWidget(accept);
|
||||||
buttons->addWidget(cancel);
|
buttons->addWidget(cancel);
|
||||||
|
|
||||||
layout->addWidget(sw);
|
flowLayout->addWidget(sw);
|
||||||
layout->addWidget(gl);
|
flowLayout->addWidget(gl);
|
||||||
layout->addLayout(switchFlowType);
|
flowLayout->addLayout(switchFlowType);
|
||||||
layout->addLayout(buttons);
|
|
||||||
|
|
||||||
sw->hide();
|
sw->hide();
|
||||||
|
|
||||||
setLayout(layout);
|
QWidget * comicFlowW = new QWidget;
|
||||||
//restoreOptions(settings); //load options
|
comicFlowW->setLayout(flowLayout);
|
||||||
//resize(200,0);
|
|
||||||
setModal (true);
|
QWidget * generalW = new QWidget;
|
||||||
setWindowTitle(tr("Options"));
|
generalW->setLayout(generalLayout);
|
||||||
|
generalLayout->addWidget(shortcutsBox);
|
||||||
|
generalLayout->addStretch();
|
||||||
|
|
||||||
|
tabWidget->addTab(comicFlowW,tr("Comic Flow"));
|
||||||
|
tabWidget->addTab(generalW,tr("General"));
|
||||||
|
|
||||||
|
layout->addWidget(tabWidget);
|
||||||
|
layout->addLayout(buttons);
|
||||||
|
setLayout(layout);
|
||||||
|
//restoreOptions(settings); //load options
|
||||||
|
//resize(200,0);
|
||||||
|
setModal (true);
|
||||||
|
setWindowTitle(tr("Options"));
|
||||||
|
|
||||||
|
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
|
||||||
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
8
YACReaderLibrary/qml.qrc
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>qml/GridComicsView.qml</file>
|
||||||
|
<file>qml/YACReaderScrollView.qml</file>
|
||||||
|
<file>qml/tick.png</file>
|
||||||
|
<file>qml/reading.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
295
YACReaderLibrary/qml/GridComicsView.qml
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
import QtQuick 2.3
|
||||||
|
import QtQuick.Controls 1.0
|
||||||
|
import QtQuick.Controls 1.1
|
||||||
|
import QtGraphicalEffects 1.0
|
||||||
|
import comicModel 1.0
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: main
|
||||||
|
color: backgroundColor
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
anchors.margins: 0
|
||||||
|
|
||||||
|
function selectAll(from,to)
|
||||||
|
{
|
||||||
|
for(var i = from+1;i<to;i++)
|
||||||
|
{
|
||||||
|
comicsSelectionHelper.selectIndex(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: appDelegate
|
||||||
|
Rectangle
|
||||||
|
{
|
||||||
|
id: cell
|
||||||
|
width: grid.cellWidth
|
||||||
|
height: grid.cellHeight
|
||||||
|
color: backgroundColor
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
comicsSelectionHelper.clear();
|
||||||
|
comicsSelectionHelper.selectIndex(grid.currentIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: realCell
|
||||||
|
|
||||||
|
width: 156; height: 287
|
||||||
|
color: ((dummyValue || !dummyValue) && comicsSelectionHelper.isSelectedIndex(index)) || grid.currentIndex === index?selectedColor:cellColor;
|
||||||
|
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
onDoubleClicked: {
|
||||||
|
|
||||||
|
comicsSelectionHelper.clear();
|
||||||
|
|
||||||
|
comicsSelectionHelper.selectIndex(index);
|
||||||
|
grid.currentIndex = index;
|
||||||
|
comicsSelectionHelper.selectedItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
//grid.currentIndex = index
|
||||||
|
//comicsSelection.setCurrentIndex(index,0x0002)
|
||||||
|
var ci = grid.currentIndex;
|
||||||
|
if(mouse.button == Qt.RightButton || !(mouse.modifiers & Qt.ControlModifier || mouse.modifiers & Qt.ShiftModifier))
|
||||||
|
{
|
||||||
|
comicsSelectionHelper.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mouse.button == Qt.RightButton)
|
||||||
|
myContextMenu.popup();
|
||||||
|
|
||||||
|
if(mouse.modifiers & Qt.ShiftModifier)
|
||||||
|
if(index < ci)
|
||||||
|
selectAll(index,ci);
|
||||||
|
else if (index > ci)
|
||||||
|
selectAll(ci,index);
|
||||||
|
|
||||||
|
mouse.accepted = true;
|
||||||
|
|
||||||
|
comicsSelectionHelper.selectIndex(index)
|
||||||
|
grid.currentIndex = index;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Menu emits the 'main' signals
|
||||||
|
Menu {
|
||||||
|
id: myContextMenu
|
||||||
|
MenuItem { text: "Open comic"; enabled: true; iconSource:"qrc:///images/openInYACReader.png"; onTriggered: openComicAction.trigger() }
|
||||||
|
MenuSeparator{}
|
||||||
|
MenuItem { text: "Open containing folder..."; enabled: true; iconSource: "qrc:///images/open.png"; onTriggered: openContainingFolderComicAction.trigger() }
|
||||||
|
MenuSeparator{}
|
||||||
|
MenuItem { text: "Reset comic rating"; onTriggered: resetComicRatingAction.trigger() }
|
||||||
|
MenuSeparator{}
|
||||||
|
MenuItem { text: "Edit"; enabled: true; iconSource:"qrc:///images/editComic.png"; onTriggered: editSelectedComicsAction.trigger() }
|
||||||
|
MenuItem { text: "Download tags from Comic Vine"; enabled: true; iconSource:"qrc:///images/getInfo.png"; onTriggered: getInfoAction.trigger() }
|
||||||
|
MenuItem { text: "Asign current order to comics"; enabled: true; iconSource:"qrc:///images/asignNumber.png"; onTriggered: asignOrderAction.trigger() }
|
||||||
|
MenuSeparator{}
|
||||||
|
MenuItem { text: "Select all comics"; enabled: true; iconSource:"qrc:///images/selectAll.png"; onTriggered: selectAllComicsAction.trigger() }
|
||||||
|
MenuSeparator{}
|
||||||
|
MenuItem { text: "Set as read"; enabled: true; iconSource:"qrc:///images/setReadButton.png"; onTriggered: setAsReadAction.trigger() }
|
||||||
|
MenuItem { text: "Set as unread"; enabled: true; iconSource:"qrc:///images/setUnread.png"; onTriggered: setAsNonReadAction.trigger() }
|
||||||
|
MenuItem { text: "Show or hide read marks"; enabled: true; iconSource:"qrc:///images/showMarks.png"; onTriggered: showHideMarksAction.trigger() }
|
||||||
|
MenuSeparator{}
|
||||||
|
MenuItem { text: "Delete selected comics"; enabled: true; iconSource:"qrc:///images/trash.png"; onTriggered: deleteComicsAction.trigger() }
|
||||||
|
MenuSeparator{}
|
||||||
|
MenuItem { text: "Fullscreen mode on/off"; onTriggered: toggleFullScreenAction.trigger() }
|
||||||
|
//MenuItem { text: "Show details"; onTriggered: cell.state = 'Details';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
DropShadow {
|
||||||
|
anchors.fill: source
|
||||||
|
horizontalOffset: 0
|
||||||
|
verticalOffset: 0
|
||||||
|
radius: 3
|
||||||
|
samples: 24
|
||||||
|
color: "#40000000"
|
||||||
|
transparentBorder: true;
|
||||||
|
source: realCell;
|
||||||
|
enabled: dropShadow;
|
||||||
|
visible: dropShadow;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**/
|
||||||
|
|
||||||
|
//cover
|
||||||
|
Image {
|
||||||
|
id: coverElement
|
||||||
|
width: 148
|
||||||
|
height: 224
|
||||||
|
anchors {horizontalCenter: parent.horizontalCenter; top: realCell.top; topMargin: 4}
|
||||||
|
source: cover_path
|
||||||
|
fillMode: Image.PreserveAspectCrop
|
||||||
|
//smooth: true
|
||||||
|
mipmap: true
|
||||||
|
//antialiasing: true
|
||||||
|
asynchronous : true
|
||||||
|
cache: false //TODO clear cache only when it is neede
|
||||||
|
}
|
||||||
|
//mark
|
||||||
|
Image {
|
||||||
|
id: mark
|
||||||
|
width: 23
|
||||||
|
height: 23
|
||||||
|
source: read_column&&show_marks?"tick.png":has_been_opened&&show_marks?"reading.png":""
|
||||||
|
anchors {right: coverElement.right; top: coverElement.top; topMargin: 11; rightMargin: 11}
|
||||||
|
asynchronous : true
|
||||||
|
}
|
||||||
|
|
||||||
|
//title
|
||||||
|
Text {
|
||||||
|
anchors { top: realCell.top; left: realCell.left; leftMargin: 4; rightMargin: 4; topMargin: 234; }
|
||||||
|
width: 148
|
||||||
|
maximumLineCount: 2
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
text: title
|
||||||
|
elide: Text.ElideRight
|
||||||
|
color: titleColor
|
||||||
|
clip: true
|
||||||
|
font.letterSpacing: 0.5
|
||||||
|
}
|
||||||
|
//number
|
||||||
|
Text {
|
||||||
|
anchors {bottom: realCell.bottom; left: realCell.left; margins: 4}
|
||||||
|
text: number?"<b>#</b>"+number:""
|
||||||
|
color: textColor
|
||||||
|
font.letterSpacing: 0.5
|
||||||
|
}
|
||||||
|
//page icon
|
||||||
|
Image {
|
||||||
|
id: pageImage
|
||||||
|
anchors {bottom: realCell.bottom; right: realCell.right; bottomMargin: 5; rightMargin: 4; leftMargin: 4}
|
||||||
|
source: "page.png"
|
||||||
|
}
|
||||||
|
//numPages
|
||||||
|
Text {
|
||||||
|
id: pages
|
||||||
|
anchors {bottom: realCell.bottom; right: pageImage.left; margins: 4}
|
||||||
|
text: has_been_opened?current_page+"/"+num_pages:num_pages
|
||||||
|
color: textColor
|
||||||
|
font.letterSpacing: 0.5
|
||||||
|
}
|
||||||
|
//rating icon
|
||||||
|
Image {
|
||||||
|
id: ratingImage
|
||||||
|
anchors {bottom: realCell.bottom; right: pageImage.left; bottomMargin: 5; rightMargin: Math.floor(pages.width)+12}
|
||||||
|
source: "star.png"
|
||||||
|
}
|
||||||
|
//comic rating
|
||||||
|
Text {
|
||||||
|
id: comicRating
|
||||||
|
anchors {bottom: realCell.bottom; right: ratingImage.left; margins: 4}
|
||||||
|
text: rating>0?rating:"-"
|
||||||
|
color: textColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
YACReaderScrollView{
|
||||||
|
id: scrollView
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: 0
|
||||||
|
|
||||||
|
|
||||||
|
GridView {
|
||||||
|
id:grid
|
||||||
|
anchors.fill: parent
|
||||||
|
cellHeight: 295
|
||||||
|
highlight: appHighlight
|
||||||
|
focus: true
|
||||||
|
model: comicsList
|
||||||
|
delegate: appDelegate
|
||||||
|
anchors.topMargin: 20
|
||||||
|
anchors.bottomMargin: 20
|
||||||
|
anchors.leftMargin: 10
|
||||||
|
anchors.rightMargin: 10
|
||||||
|
pixelAligned: true
|
||||||
|
//flickDeceleration: -2000
|
||||||
|
snapMode: GridView.SnapToRow
|
||||||
|
currentIndex: 0
|
||||||
|
cacheBuffer: 0
|
||||||
|
|
||||||
|
|
||||||
|
function numCellsPerRow() {
|
||||||
|
return Math.floor(width / 190);
|
||||||
|
}
|
||||||
|
|
||||||
|
onWidthChanged: {
|
||||||
|
var numCells = numCellsPerRow();
|
||||||
|
var rest = width % 190;
|
||||||
|
|
||||||
|
if(numCells > 0)
|
||||||
|
{
|
||||||
|
cellWidth = Math.floor(width / numCells) ;
|
||||||
|
//console.log("numCells=",numCells,"rest=",rest,"cellWidth=",cellWidth,"width=",width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
focus: true
|
||||||
|
Keys.onPressed: {
|
||||||
|
if (event.modifiers & Qt.ControlModifier || event.modifiers & Qt.ShiftModifier)
|
||||||
|
return;
|
||||||
|
var numCells = grid.numCellsPerRow();
|
||||||
|
var ci
|
||||||
|
if (event.key === Qt.Key_Right) {
|
||||||
|
ci = Math.min(grid.currentIndex+1,grid.count);
|
||||||
|
}
|
||||||
|
else if (event.key === Qt.Key_Left) {
|
||||||
|
ci = Math.max(0,grid.currentIndex-1);
|
||||||
|
}
|
||||||
|
else if (event.key === Qt.Key_Up) {
|
||||||
|
ci = Math.max(0,grid.currentIndex-numCells);
|
||||||
|
}
|
||||||
|
else if (event.key === Qt.Key_Down) {
|
||||||
|
ci = Math.min(grid.currentIndex+numCells,grid.count);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.accepted = true;
|
||||||
|
//var ci = grid.currentIndex;
|
||||||
|
grid.currentIndex = -1
|
||||||
|
comicsSelectionHelper.clear();
|
||||||
|
comicsSelectionHelper.selectIndex(ci);
|
||||||
|
grid.currentIndex = ci;
|
||||||
|
}
|
||||||
|
//}
|
||||||
|
|
||||||
|
/*MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
clicked.accepted = false;
|
||||||
|
console.log("xx");
|
||||||
|
}
|
||||||
|
|
||||||
|
onWheel: {
|
||||||
|
var newValue = Math.max(0,scrollView.flickableItem.contentY - wheel.angleDelta.y)
|
||||||
|
scrollView.flickableItem.contentY = newValue
|
||||||
|
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
/*ScrollBar {
|
||||||
|
flickable: grid;
|
||||||
|
}
|
||||||
|
|
||||||
|
PerformanceMeter {
|
||||||
|
anchors {top: parent.top; left: parent.left; margins: 4}
|
||||||
|
id: performanceMeter
|
||||||
|
width: 128
|
||||||
|
height: 64
|
||||||
|
enabled: (dummyValue || !dummyValue)
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
336
YACReaderLibrary/qml/YACReaderScrollView.qml
Normal file
@ -0,0 +1,336 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||||
|
** Contact: http://www.qt-project.org/legal
|
||||||
|
**
|
||||||
|
** This file is part of the Qt Quick Controls module of the Qt Toolkit.
|
||||||
|
**
|
||||||
|
** $QT_BEGIN_LICENSE:BSD$
|
||||||
|
** You may use this file under the terms of the BSD license as follows:
|
||||||
|
**
|
||||||
|
** "Redistribution and use in source and binary forms, with or without
|
||||||
|
** modification, are permitted provided that the following conditions are
|
||||||
|
** met:
|
||||||
|
** * Redistributions of source code must retain the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer.
|
||||||
|
** * Redistributions in binary form must reproduce the above copyright
|
||||||
|
** notice, this list of conditions and the following disclaimer in
|
||||||
|
** the documentation and/or other materials provided with the
|
||||||
|
** distribution.
|
||||||
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
||||||
|
** of its contributors may be used to endorse or promote products derived
|
||||||
|
** from this software without specific prior written permission.
|
||||||
|
**
|
||||||
|
**
|
||||||
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
||||||
|
**
|
||||||
|
** $QT_END_LICENSE$
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
import QtQuick 2.2
|
||||||
|
import QtQuick.Controls 1.2
|
||||||
|
import QtQuick.Controls.Private 1.0
|
||||||
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmltype ScrollView
|
||||||
|
\inqmlmodule QtQuick.Controls
|
||||||
|
\since 5.1
|
||||||
|
\ingroup views
|
||||||
|
\brief Provides a scrolling view within another Item.
|
||||||
|
|
||||||
|
A ScrollView can be used either to replace a \l Flickable or decorate an
|
||||||
|
existing \l Flickable. Depending on the platform, it will add scroll bars and
|
||||||
|
a content frame.
|
||||||
|
|
||||||
|
Only one Item can be a direct child of the ScrollView and the child is implicitly anchored
|
||||||
|
to fill the scroll view.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
\code
|
||||||
|
ScrollView {
|
||||||
|
Image { source: "largeImage.png" }
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
In the previous example the Image item will implicitly get scroll behavior as if it was
|
||||||
|
used within a \l Flickable. The width and height of the child item will be used to
|
||||||
|
define the size of the content area.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
\code
|
||||||
|
ScrollView {
|
||||||
|
ListView {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
\endcode
|
||||||
|
|
||||||
|
In this case the content size of the ScrollView will simply mirror that of its contained
|
||||||
|
\l flickableItem.
|
||||||
|
|
||||||
|
You can create a custom appearance for a ScrollView by
|
||||||
|
assigning a \l {QtQuick.Controls.Styles::ScrollViewStyle}{ScrollViewStyle}.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FocusScope {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
implicitWidth: 240
|
||||||
|
implicitHeight: 150
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This property tells the ScrollView if it should render
|
||||||
|
a frame around its content.
|
||||||
|
|
||||||
|
The default value is \c false.
|
||||||
|
*/
|
||||||
|
property bool frameVisible: false
|
||||||
|
|
||||||
|
/*!
|
||||||
|
This property controls if there should be a highlight
|
||||||
|
around the frame when the ScrollView has input focus.
|
||||||
|
|
||||||
|
The default value is \c false.
|
||||||
|
|
||||||
|
\note This property is only applicable on some platforms, such
|
||||||
|
as Mac OS.
|
||||||
|
*/
|
||||||
|
property bool highlightOnFocus: false
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlproperty Item ScrollView::viewport
|
||||||
|
|
||||||
|
The viewport determines the current "window" on the contentItem.
|
||||||
|
In other words, it clips it and the size of the viewport tells you
|
||||||
|
how much of the content area is visible.
|
||||||
|
*/
|
||||||
|
property alias viewport: viewportItem
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlproperty Item ScrollView::flickableItem
|
||||||
|
|
||||||
|
The flickableItem of the ScrollView. If the contentItem provided
|
||||||
|
to the ScrollView is a Flickable, it will be the \l contentItem.
|
||||||
|
*/
|
||||||
|
readonly property alias flickableItem: internal.flickableItem
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The contentItem of the ScrollView. This is set by the user.
|
||||||
|
|
||||||
|
Note that the definition of contentItem is somewhat different to that
|
||||||
|
of a Flickable, where the contentItem is implicitly created.
|
||||||
|
*/
|
||||||
|
default property Item contentItem
|
||||||
|
|
||||||
|
/*! \internal */
|
||||||
|
property Item __scroller: scroller
|
||||||
|
/*! \internal */
|
||||||
|
property alias __wheelAreaScrollSpeed: wheelArea.scrollSpeed
|
||||||
|
/*! \internal */
|
||||||
|
property int __scrollBarTopMargin: 0
|
||||||
|
/*! \internal */
|
||||||
|
property int __viewTopMargin: 0
|
||||||
|
/*! \internal */
|
||||||
|
property alias __horizontalScrollBar: scroller.horizontalScrollBar
|
||||||
|
/*! \internal */
|
||||||
|
property alias __verticalScrollBar: scroller.verticalScrollBar
|
||||||
|
/*! \qmlproperty Component ScrollView::style
|
||||||
|
|
||||||
|
The style Component for this control.
|
||||||
|
\sa {Qt Quick Controls Styles QML Types}
|
||||||
|
|
||||||
|
*/
|
||||||
|
property Component style: Qt.createComponent(Settings.style + "/ScrollViewStyle.qml", root)
|
||||||
|
|
||||||
|
/*! \internal */
|
||||||
|
property Style __style: styleLoader.item
|
||||||
|
|
||||||
|
activeFocusOnTab: true
|
||||||
|
|
||||||
|
onContentItemChanged: {
|
||||||
|
//console.log("onContentItemChanged");
|
||||||
|
if (contentItem.hasOwnProperty("contentY") && // Check if flickable
|
||||||
|
contentItem.hasOwnProperty("contentHeight")) {
|
||||||
|
internal.flickableItem = contentItem // "Use content if it is a flickable
|
||||||
|
internal.flickableItem.parent = viewportItem
|
||||||
|
} else {
|
||||||
|
internal.flickableItem = flickableComponent.createObject(viewportItem)
|
||||||
|
contentItem.parent = internal.flickableItem.contentItem
|
||||||
|
}
|
||||||
|
internal.flickableItem.anchors.fill = viewportItem
|
||||||
|
if (!Settings.hasTouchScreen)
|
||||||
|
internal.flickableItem.interactive = false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
children: Item {
|
||||||
|
id: internal
|
||||||
|
|
||||||
|
property Flickable flickableItem
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
id: styleLoader
|
||||||
|
sourceComponent: style
|
||||||
|
onStatusChanged: {
|
||||||
|
if (status === Loader.Error)
|
||||||
|
console.error("Failed to load Style for", root)
|
||||||
|
}
|
||||||
|
property alias __control: root
|
||||||
|
}
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
target: flickableItem
|
||||||
|
property: "contentHeight"
|
||||||
|
when: contentItem !== flickableItem
|
||||||
|
value: contentItem ? contentItem.height : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
target: flickableItem
|
||||||
|
when: contentItem !== flickableItem
|
||||||
|
property: "contentWidth"
|
||||||
|
value: contentItem ? contentItem.width : 0
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: flickableItem
|
||||||
|
|
||||||
|
onContentYChanged: {
|
||||||
|
//console.log("onContentYChanged2");
|
||||||
|
scroller.blockUpdates = true
|
||||||
|
scroller.verticalScrollBar.value = flickableItem.contentY
|
||||||
|
scroller.blockUpdates = false
|
||||||
|
}
|
||||||
|
|
||||||
|
onContentXChanged: {
|
||||||
|
//console.log("onContentXChanged2");
|
||||||
|
scroller.blockUpdates = true
|
||||||
|
scroller.horizontalScrollBar.value = flickableItem.contentX
|
||||||
|
scroller.blockUpdates = false
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
Component {
|
||||||
|
id: flickableComponent
|
||||||
|
Flickable {}
|
||||||
|
}
|
||||||
|
|
||||||
|
WheelArea {
|
||||||
|
id: wheelArea
|
||||||
|
parent: flickableItem
|
||||||
|
|
||||||
|
// ### Note this is needed due to broken mousewheel behavior in Flickable.
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
property int stepSize: 295
|
||||||
|
|
||||||
|
property int acceleration: 40
|
||||||
|
property int flickThreshold: Settings.dragThreshold
|
||||||
|
property real speedThreshold: 3
|
||||||
|
property real ignored: 0.001 // ## flick() does not work with 0 yVelocity
|
||||||
|
property int maxFlick: 400
|
||||||
|
|
||||||
|
property bool horizontalRecursionGuard: false
|
||||||
|
property bool verticalRecursionGuard: false
|
||||||
|
|
||||||
|
horizontalMinimumValue: flickableItem ? flickableItem.originX : 0
|
||||||
|
horizontalMaximumValue: flickableItem ? flickableItem.originX + flickableItem.contentWidth - viewport.width : 0
|
||||||
|
|
||||||
|
verticalMinimumValue: flickableItem ? flickableItem.originY : 0
|
||||||
|
verticalMaximumValue: flickableItem ? flickableItem.originY + flickableItem.contentHeight - viewport.height + __viewTopMargin : 0
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: flickableItem
|
||||||
|
|
||||||
|
onContentYChanged: {
|
||||||
|
//console.log("onContentYChanged");
|
||||||
|
wheelArea.verticalRecursionGuard = true
|
||||||
|
wheelArea.verticalValue = flickableItem.contentY
|
||||||
|
wheelArea.verticalRecursionGuard = false
|
||||||
|
}
|
||||||
|
onContentXChanged: {
|
||||||
|
//console.log("onContentXChanged");
|
||||||
|
wheelArea.horizontalRecursionGuard = true
|
||||||
|
wheelArea.horizontalValue = flickableItem.contentX
|
||||||
|
wheelArea.horizontalRecursionGuard = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onVerticalValueChanged: {
|
||||||
|
if (!verticalRecursionGuard) {
|
||||||
|
//console.log(verticalDelta);
|
||||||
|
|
||||||
|
if (flickableItem.contentY < flickThreshold && verticalDelta > speedThreshold) {
|
||||||
|
flickableItem.flick(ignored, Math.min(maxFlick, acceleration * verticalDelta))
|
||||||
|
} else if (flickableItem.contentY > flickableItem.contentHeight
|
||||||
|
- flickThreshold - viewport.height && verticalDelta < -speedThreshold) {
|
||||||
|
flickableItem.flick(ignored, Math.max(-maxFlick, acceleration * verticalDelta))
|
||||||
|
} else {
|
||||||
|
var absDelta = Math.abs(verticalDelta);
|
||||||
|
|
||||||
|
if(verticalDelta < 0)
|
||||||
|
flickableItem.contentY = verticalValue + Math.min(98,0.93*absDelta+4.5);
|
||||||
|
else
|
||||||
|
flickableItem.contentY = verticalValue - Math.min(98,0.93*absDelta+4.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: snap to row
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onHorizontalValueChanged: {
|
||||||
|
if (!horizontalRecursionGuard)
|
||||||
|
flickableItem.contentX = horizontalValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ScrollViewHelper {
|
||||||
|
id: scroller
|
||||||
|
anchors.fill: parent
|
||||||
|
active: wheelArea.active
|
||||||
|
property bool outerFrame: !frameVisible || !(__style ? __style.__externalScrollBars : 0)
|
||||||
|
property int scrollBarSpacing: outerFrame ? 0 : (__style ? __style.__scrollBarSpacing : 0)
|
||||||
|
property int verticalScrollbarOffset: verticalScrollBar.visible && !verticalScrollBar.isTransient ?
|
||||||
|
verticalScrollBar.width + scrollBarSpacing : 0
|
||||||
|
property int horizontalScrollbarOffset: horizontalScrollBar.visible && !horizontalScrollBar.isTransient ?
|
||||||
|
horizontalScrollBar.height + scrollBarSpacing : 0
|
||||||
|
Loader {
|
||||||
|
id: frameLoader
|
||||||
|
sourceComponent: __style ? __style.frame : null
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.rightMargin: scroller.outerFrame ? 0 : scroller.verticalScrollbarOffset
|
||||||
|
anchors.bottomMargin: scroller.outerFrame ? 0 : scroller.horizontalScrollbarOffset
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: viewportItem
|
||||||
|
anchors.fill: frameLoader
|
||||||
|
anchors.topMargin: frameVisible ? __style.padding.top : 0
|
||||||
|
anchors.leftMargin: frameVisible ? __style.padding.left : 0
|
||||||
|
anchors.rightMargin: (frameVisible ? __style.padding.right : 0) + (scroller.outerFrame ? scroller.verticalScrollbarOffset : 0)
|
||||||
|
anchors.bottomMargin: (frameVisible ? __style.padding.bottom : 0) + (scroller.outerFrame ? scroller.horizontalScrollbarOffset : 0)
|
||||||
|
clip: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FocusFrame { visible: highlightOnFocus && root.activeFocus }
|
||||||
|
}
|
||||||
|
}
|
BIN
YACReaderLibrary/qml/page-macosx.png
Normal file
After Width: | Height: | Size: 171 B |
BIN
YACReaderLibrary/qml/page.png
Normal file
After Width: | Height: | Size: 155 B |
BIN
YACReaderLibrary/qml/reading.png
Normal file
After Width: | Height: | Size: 374 B |
BIN
YACReaderLibrary/qml/star-macosx.png
Normal file
After Width: | Height: | Size: 288 B |
BIN
YACReaderLibrary/qml/star.png
Normal file
After Width: | Height: | Size: 242 B |
BIN
YACReaderLibrary/qml/tick.png
Normal file
After Width: | Height: | Size: 488 B |
6
YACReaderLibrary/qml_osx.qrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file alias="qml/page.png">qml/page-macosx.png</file>
|
||||||
|
<file alias="qml/star.png">qml/star-macosx.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
6
YACReaderLibrary/qml_win.qrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>qml/page.png</file>
|
||||||
|
<file>qml/star.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@ -37,7 +37,7 @@ void Startup::start() {
|
|||||||
//QSettings* debugLogSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
//QSettings* debugLogSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||||
//debugLogSettings->beginGroup("debugLogFile");
|
//debugLogSettings->beginGroup("debugLogFile");
|
||||||
Logger* logger=new FileLogger(mainLogSettings,10000,app);
|
Logger* logger=new FileLogger(mainLogSettings,10000,app);
|
||||||
logger->installMsgHandler();
|
logger->installMsgHandler();
|
||||||
|
|
||||||
// Configure template loader and cache
|
// Configure template loader and cache
|
||||||
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||||
@ -65,9 +65,14 @@ void Startup::start() {
|
|||||||
|
|
||||||
|
|
||||||
void Startup::stop() {
|
void Startup::stop() {
|
||||||
qDebug("ServiceHelper: Service has been stopped");
|
qDebug("ServiceHelper: Service has been stopped");
|
||||||
// QCoreApplication destroys all objects that have been created in start().
|
// QCoreApplication destroys all objects that have been created in start().
|
||||||
delete listener;
|
if(listener!=nullptr)
|
||||||
|
{
|
||||||
|
listener->close();
|
||||||
|
delete listener;
|
||||||
|
listener = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,12 @@ bool YACReaderLocalServer::isRunning()
|
|||||||
socket.connectToServer(YACREADERLIBRARY_GUID);
|
socket.connectToServer(YACREADERLIBRARY_GUID);
|
||||||
if (socket.waitForConnected(500))
|
if (socket.waitForConnected(500))
|
||||||
return true; // Server is running (another instance of YACReaderLibrary has been launched)
|
return true; // Server is running (another instance of YACReaderLibrary has been launched)
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderLocalServer::close()
|
||||||
|
{
|
||||||
|
localServer->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ public slots:
|
|||||||
bool isListening();
|
bool isListening();
|
||||||
void sendResponse();
|
void sendResponse();
|
||||||
static bool isRunning();
|
static bool isRunning();
|
||||||
|
void close();
|
||||||
private:
|
private:
|
||||||
//void run();
|
//void run();
|
||||||
QLocalServer * localServer;
|
QLocalServer * localServer;
|
||||||
|
@ -44,11 +44,14 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) :
|
|||||||
helpButton->setStyleSheet(qToolButtonStyleSheet);
|
helpButton->setStyleSheet(qToolButtonStyleSheet);
|
||||||
helpButton->setIconSize(QSize(14,25));
|
helpButton->setIconSize(QSize(14,25));
|
||||||
|
|
||||||
|
toggleComicsViewButton = new QToolButton;
|
||||||
|
toggleComicsViewButton->setStyleSheet(qToolButtonStyleSheet);
|
||||||
|
toggleComicsViewButton->setIconSize(QSize(24,24));
|
||||||
|
|
||||||
fullscreenButton = new QToolButton();
|
fullscreenButton = new QToolButton();
|
||||||
fullscreenButton->setStyleSheet(qToolButtonStyleSheet);
|
fullscreenButton->setStyleSheet(qToolButtonStyleSheet);
|
||||||
fullscreenButton->setIconSize(QSize(24,24));
|
fullscreenButton->setIconSize(QSize(24,24));
|
||||||
|
|
||||||
|
|
||||||
mainLayout->setMargin(0);
|
mainLayout->setMargin(0);
|
||||||
mainLayout->setSpacing(0);
|
mainLayout->setSpacing(0);
|
||||||
|
|
||||||
@ -66,6 +69,8 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) :
|
|||||||
|
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
|
mainLayout->addWidget(toggleComicsViewButton);
|
||||||
|
addWideDivider();
|
||||||
mainLayout->addWidget(fullscreenButton);
|
mainLayout->addWidget(fullscreenButton);
|
||||||
mainLayout->addSpacing(10);
|
mainLayout->addSpacing(10);
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ class QResizeEvent;
|
|||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
|
|
||||||
|
//TODO create methods for adding actions, separators and sctreches dynimically
|
||||||
class YACReaderMainToolBar : public QWidget
|
class YACReaderMainToolBar : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -21,8 +22,10 @@ public:
|
|||||||
QToolButton * settingsButton;
|
QToolButton * settingsButton;
|
||||||
QToolButton * serverButton;
|
QToolButton * serverButton;
|
||||||
QToolButton * helpButton;
|
QToolButton * helpButton;
|
||||||
|
QToolButton * toggleComicsViewButton;
|
||||||
QToolButton * fullscreenButton;
|
QToolButton * fullscreenButton;
|
||||||
|
|
||||||
|
|
||||||
void setCurrentFolderName(const QString & name);
|
void setCurrentFolderName(const QString & name);
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -1059,7 +1059,7 @@ void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
|
|||||||
|
|
||||||
if(event->key() == Qt::Key_Up)
|
if(event->key() == Qt::Key_Up)
|
||||||
{
|
{
|
||||||
emit selected(centerIndex());
|
//emit selected(centerIndex());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,3 +19,11 @@ void YACReader::addSperator(QWidget *w)
|
|||||||
separator->setSeparator(true);
|
separator->setSeparator(true);
|
||||||
w->addAction(separator);
|
w->addAction(separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QAction * YACReader::createSeparator()
|
||||||
|
{
|
||||||
|
QAction * a = new QAction(0);
|
||||||
|
a->setSeparator(true);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#define MAIN_WINDOW_STATE "MAIN_WINDOW_STATE"
|
#define MAIN_WINDOW_STATE "MAIN_WINDOW_STATE"
|
||||||
#define COMICS_VIEW_HEADERS "COMICS_VIEW_HEADERS"
|
#define COMICS_VIEW_HEADERS "COMICS_VIEW_HEADERS"
|
||||||
#define COMICS_VIEW_HEADERS_GEOMETRY "COMICS_VIEW_HEADERS_GEOMETRY"
|
#define COMICS_VIEW_HEADERS_GEOMETRY "COMICS_VIEW_HEADERS_GEOMETRY"
|
||||||
|
#define COMICS_VIEW_STATUS "COMICS_VIEW_STATUS"
|
||||||
|
|
||||||
#define NUM_DAYS_BETWEEN_VERSION_CHECKS "NUM_DAYS_BETWEEN_VERSION_CHECKS"
|
#define NUM_DAYS_BETWEEN_VERSION_CHECKS "NUM_DAYS_BETWEEN_VERSION_CHECKS"
|
||||||
#define LAST_VERSION_CHECK "LAST_VERSION_CHECK"
|
#define LAST_VERSION_CHECK "LAST_VERSION_CHECK"
|
||||||
@ -94,8 +95,15 @@ namespace YACReader
|
|||||||
SevenZNotFound = 700
|
SevenZNotFound = 700
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ComicsViewStatus
|
||||||
|
{
|
||||||
|
Flow,
|
||||||
|
Grid
|
||||||
|
};
|
||||||
|
|
||||||
QString getSettingsPath();
|
QString getSettingsPath();
|
||||||
void addSperator(QWidget * w);
|
void addSperator(QWidget * w);
|
||||||
|
QAction * createSeparator();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QGroupBox>
|
||||||
|
|
||||||
YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
|
YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
|
||||||
:QDialog(parent)
|
:QDialog(parent)
|
||||||
@ -23,6 +24,16 @@ YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
|
|||||||
|
|
||||||
cancel->setDefault(true);
|
cancel->setDefault(true);
|
||||||
|
|
||||||
|
|
||||||
|
QVBoxLayout * shortcutsLayout = new QVBoxLayout();
|
||||||
|
QPushButton * shortcutsButton = new QPushButton(tr("Edit shortcuts"));
|
||||||
|
shortcutsLayout->addWidget(shortcutsButton);
|
||||||
|
|
||||||
|
shortcutsBox = new QGroupBox(tr("Shortcuts"));
|
||||||
|
shortcutsBox->setLayout(shortcutsLayout);
|
||||||
|
|
||||||
|
connect(shortcutsButton,SIGNAL(clicked()),this,SIGNAL(editShortcuts()));
|
||||||
|
|
||||||
connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions()));
|
connect(accept,SIGNAL(clicked()),this,SLOT(saveOptions()));
|
||||||
connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); //TODO fix this
|
connect(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); //TODO fix this
|
||||||
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
||||||
|
@ -8,6 +8,7 @@ class YACReaderGLFlowConfigWidget;
|
|||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
class QGroupBox;
|
||||||
|
|
||||||
class YACReaderOptionsDialog : public QDialog
|
class YACReaderOptionsDialog : public QDialog
|
||||||
{
|
{
|
||||||
@ -20,6 +21,8 @@ protected:
|
|||||||
QPushButton * accept;
|
QPushButton * accept;
|
||||||
QPushButton * cancel;
|
QPushButton * cancel;
|
||||||
|
|
||||||
|
QGroupBox * shortcutsBox;
|
||||||
|
|
||||||
QSettings * settings;
|
QSettings * settings;
|
||||||
QSettings * previousSettings;
|
QSettings * previousSettings;
|
||||||
|
|
||||||
@ -56,6 +59,7 @@ protected slots:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void optionsChanged();
|
void optionsChanged();
|
||||||
|
void editShortcuts();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // YACREADER_OPTIONS_DIALOG_H
|
#endif // YACREADER_OPTIONS_DIALOG_H
|
||||||
|
@ -34,7 +34,7 @@ YACReaderSearchLineEdit::YACReaderSearchLineEdit(QWidget *parent)
|
|||||||
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
|
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
setMaximumWidth(300);
|
setMaximumWidth(212);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
images/accept_shortcut.png
Normal file
After Width: | Height: | Size: 204 B |
BIN
images/clear_shortcut.png
Normal file
After Width: | Height: | Size: 200 B |
BIN
images/empty_folder.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
images/flow_to_grid.gif
Normal file
After Width: | Height: | Size: 121 KiB |
BIN
images/grid_to_flow.gif
Normal file
After Width: | Height: | Size: 127 KiB |
BIN
images/shortcuts_group_comics.png
Normal file
After Width: | Height: | Size: 276 B |
BIN
images/shortcuts_group_folders.png
Normal file
After Width: | Height: | Size: 157 B |
BIN
images/shortcuts_group_general.png
Normal file
After Width: | Height: | Size: 319 B |
BIN
images/shortcuts_group_libraries.png
Normal file
After Width: | Height: | Size: 164 B |
BIN
images/shortcuts_group_mglass.png
Normal file
After Width: | Height: | Size: 351 B |
BIN
images/shortcuts_group_page.png
Normal file
After Width: | Height: | Size: 162 B |
BIN
images/shortcuts_group_reading.png
Normal file
After Width: | Height: | Size: 179 B |
BIN
images/shortcuts_group_visualization.png
Normal file
After Width: | Height: | Size: 320 B |
80
shortcuts_management/actions_groups_model.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#include "actions_groups_model.h"
|
||||||
|
|
||||||
|
ActionsGroupsModel::ActionsGroupsModel(QObject *parent) :
|
||||||
|
QAbstractItemModel(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int ActionsGroupsModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return groups.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ActionsGroupsModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex ActionsGroupsModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if (!hasIndex(row, column, parent))
|
||||||
|
return QModelIndex();
|
||||||
|
|
||||||
|
return createIndex(row, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ActionsGroupsModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if (role == Qt::DecorationRole)
|
||||||
|
return QVariant(groups.at(index.row()).getIcon());
|
||||||
|
|
||||||
|
if (role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
return QVariant(groups[index.row()].getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex ActionsGroupsModel::parent(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionsGroupsModel::addActionsGroup(const ActionsGroup &group)
|
||||||
|
{
|
||||||
|
beginInsertRows(QModelIndex(),groups.length()-1,groups.length());
|
||||||
|
groups.push_back(group);
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QAction *> ActionsGroupsModel::getActions(const QModelIndex &mi)
|
||||||
|
{
|
||||||
|
if(mi.isValid())
|
||||||
|
return groups[mi.row()].getActions();
|
||||||
|
return QList<QAction *>();
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------
|
||||||
|
|
||||||
|
ActionsGroup::ActionsGroup(const QString &name, const QIcon &icon, QList<QAction *> &actions)
|
||||||
|
:name(name), icon(icon), actions(actions)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ActionsGroup::getName() const
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon ActionsGroup::getIcon() const
|
||||||
|
{
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QAction *> ActionsGroup::getActions() const
|
||||||
|
{
|
||||||
|
return actions;
|
||||||
|
}
|
44
shortcuts_management/actions_groups_model.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#ifndef ACTIONS_GROUPS_MODEL_H
|
||||||
|
#define ACTIONS_GROUPS_MODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QIcon>
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
|
class ActionsGroup
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ActionsGroup(const QString & name, const QIcon & icon, QList<QAction *> & actions);
|
||||||
|
QString getName() const;
|
||||||
|
QIcon getIcon() const;
|
||||||
|
QList<QAction *> getActions() const;
|
||||||
|
protected:
|
||||||
|
QString name;
|
||||||
|
QIcon icon;
|
||||||
|
QList<QAction *> actions;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ActionsGroupsModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ActionsGroupsModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
void addActionsGroup(const ActionsGroup & group);
|
||||||
|
QList<QAction *> getActions(const QModelIndex & mi);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QList<ActionsGroup> groups;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ACTIONS_GROUPS_MODEL_H
|
106
shortcuts_management/actions_shortcuts_model.cpp
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
#include "actions_shortcuts_model.h"
|
||||||
|
#include "shortcuts_manager.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
ActionsShortcutsModel::ActionsShortcutsModel(QObject *parent) :
|
||||||
|
QAbstractItemModel(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int ActionsShortcutsModel::rowCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return actions.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ActionsShortcutsModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex ActionsShortcutsModel::index(int row, int column, const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
if (!hasIndex(row, column, parent))
|
||||||
|
return QModelIndex();
|
||||||
|
|
||||||
|
return createIndex(row, column, actions[row]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Qt::ItemFlags ActionsShortcutsModel::flags(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return 0;
|
||||||
|
if(index.column() == KEYS)
|
||||||
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
||||||
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ActionsShortcutsModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if (!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if (role == Qt::DecorationRole && index.column() == ICON)
|
||||||
|
return QVariant(actions[index.row()]->icon());
|
||||||
|
|
||||||
|
if (role == Qt::TextAlignmentRole)
|
||||||
|
{
|
||||||
|
switch(index.column())
|
||||||
|
{
|
||||||
|
case ICON:
|
||||||
|
return QVariant(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
|
case NAME:
|
||||||
|
return QVariant(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
case KEYS:
|
||||||
|
return QVariant(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(role == Qt::ForegroundRole && index.column() == KEYS && actions[index.row()]->shortcut().isEmpty())
|
||||||
|
return QBrush(QColor("#AAAAAA"));
|
||||||
|
|
||||||
|
if (role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if (index.column() == NAME)
|
||||||
|
return QVariant(actions[index.row()]->toolTip());
|
||||||
|
if (index.column() == KEYS)
|
||||||
|
{
|
||||||
|
QKeySequence ks = actions[index.row()]->shortcut();
|
||||||
|
if(ks.isEmpty())
|
||||||
|
return tr("None");
|
||||||
|
return QVariant(ks.toString(QKeySequence::NativeText));
|
||||||
|
}
|
||||||
|
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ActionsShortcutsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||||
|
{
|
||||||
|
if(index.column() == KEYS)
|
||||||
|
{
|
||||||
|
ShortcutsManager sm = ShortcutsManager::getShortcutsManager();
|
||||||
|
if(sm.checkConflicts(value.toString(), actions[index.row()]))
|
||||||
|
emit conflict(value.toString());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
actions[index.row()]->setShortcut(value.toString());
|
||||||
|
ShortcutsManager::getShortcutsManager().saveShortcut(actions[index.row()]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QModelIndex ActionsShortcutsModel::parent(const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionsShortcutsModel::addActions(const QList<QAction *> actions)
|
||||||
|
{
|
||||||
|
beginResetModel();
|
||||||
|
this->actions = actions;
|
||||||
|
endResetModel();
|
||||||
|
}
|
38
shortcuts_management/actions_shortcuts_model.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#ifndef ACTIONS_SHORTCUTS_MODEL_H
|
||||||
|
#define ACTIONS_SHORTCUTS_MODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
|
class ActionsShortcutsModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ActionsShortcutsModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
|
||||||
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||||
|
QModelIndex parent(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
void addActions(const QList<QAction *> actions);
|
||||||
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
|
||||||
|
|
||||||
|
enum Columns {
|
||||||
|
ICON = 0,
|
||||||
|
NAME,
|
||||||
|
KEYS
|
||||||
|
};
|
||||||
|
signals:
|
||||||
|
void conflict(QString);
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QList<QAction *> actions;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ACTIONS_SHORTCUTS_MODEL_H
|
145
shortcuts_management/edit_shortcut_item_delegate.cpp
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
#include "edit_shortcut_item_delegate.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
EditShortcutItemDelegate::EditShortcutItemDelegate(QObject *parent) :
|
||||||
|
QItemDelegate(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *EditShortcutItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
KeySequenceLineEdit * editor = new KeySequenceLineEdit(parent);
|
||||||
|
connect(editor,SIGNAL(editingFinished()),this,SLOT(closeShortcutEditor()));
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
QString value = index.model()->data(index, Qt::DisplayRole).toString();
|
||||||
|
|
||||||
|
KeySequenceLineEdit * lineEdit = static_cast<KeySequenceLineEdit*>(editor);
|
||||||
|
lineEdit->setText(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
KeySequenceLineEdit *lineEdit = static_cast<KeySequenceLineEdit*>(editor);
|
||||||
|
|
||||||
|
model->setData(index, lineEdit->text(), Qt::EditRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &mi) const
|
||||||
|
{
|
||||||
|
editor->setGeometry(option.rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EditShortcutItemDelegate::eventFilter(QObject* editor, QEvent* event)
|
||||||
|
{
|
||||||
|
if(event->type()==QEvent::KeyPress)
|
||||||
|
return false;
|
||||||
|
return QItemDelegate::eventFilter(editor, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutItemDelegate::closeShortcutEditor()
|
||||||
|
{
|
||||||
|
emit commitData(static_cast<QWidget *>(sender()));
|
||||||
|
emit closeEditor(static_cast<QWidget *>(sender()),QAbstractItemDelegate::NoHint);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO uncoment commented code for enabling concatenated shortcuts
|
||||||
|
KeySequenceLineEdit::KeySequenceLineEdit(QWidget *parent)
|
||||||
|
:QLineEdit(parent)//,numKeys(0)
|
||||||
|
{
|
||||||
|
//keys[0] = keys[1] = keys[2] = keys[3] = 0;
|
||||||
|
setAlignment(Qt::AlignRight);
|
||||||
|
|
||||||
|
QPixmap clearPixmap(":/images/clear_shortcut.png");
|
||||||
|
QPixmap acceptPixmap(":/images/accept_shortcut.png");
|
||||||
|
|
||||||
|
clearButton = new QToolButton(this);
|
||||||
|
acceptButton = new QToolButton(this);
|
||||||
|
QString buttonsStyle = "QToolButton { border: none; padding: 0px; }";
|
||||||
|
|
||||||
|
clearButton->setIcon(QIcon(clearPixmap));
|
||||||
|
clearButton->setIconSize(clearPixmap.size());
|
||||||
|
clearButton->setCursor(Qt::ArrowCursor);
|
||||||
|
clearButton->setStyleSheet(buttonsStyle);
|
||||||
|
|
||||||
|
acceptButton->setIcon(QIcon(acceptPixmap));
|
||||||
|
acceptButton->setIconSize(acceptPixmap.size());
|
||||||
|
acceptButton->setCursor(Qt::ArrowCursor);
|
||||||
|
acceptButton->setStyleSheet(buttonsStyle);
|
||||||
|
|
||||||
|
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
|
||||||
|
connect(acceptButton, SIGNAL(clicked()), this, SIGNAL(editingFinished()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeySequenceLineEdit::resizeEvent(QResizeEvent * e)
|
||||||
|
{
|
||||||
|
QSize szClear = clearButton->sizeHint();
|
||||||
|
//int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
|
int leftMargin = style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
|
||||||
|
int topMargin = style()->pixelMetric(QStyle::PM_LayoutTopMargin);
|
||||||
|
clearButton->move(0 + leftMargin,(e->size().height()-19)/2); //16 is the icon height+1blank pixel
|
||||||
|
|
||||||
|
acceptButton->move( leftMargin + szClear.width(),(e->size().height()-19)/2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeySequenceLineEdit::keyPressEvent(QKeyEvent * e)
|
||||||
|
{
|
||||||
|
int key = e->key();
|
||||||
|
|
||||||
|
|
||||||
|
//if ( numKeys > 3 ||
|
||||||
|
if ( key == Qt::Key_Control ||
|
||||||
|
key == Qt::Key_Shift ||
|
||||||
|
key == Qt::Key_Meta ||
|
||||||
|
key == Qt::Key_Alt )
|
||||||
|
return;
|
||||||
|
|
||||||
|
key |= translateModifiers(e->modifiers(), e->text());
|
||||||
|
|
||||||
|
/*switch (numKeys) {
|
||||||
|
case 0:
|
||||||
|
keys[0] = nextKey;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
keys[1] = nextKey;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
keys[2] = nextKey;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
keys[3] = nextKey;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}*/
|
||||||
|
//numKeys++;
|
||||||
|
QKeySequence keySequence = QKeySequence(key);
|
||||||
|
setText(keySequence.toString(QKeySequence::NativeText));
|
||||||
|
e->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
int KeySequenceLineEdit::translateModifiers(Qt::KeyboardModifiers state,
|
||||||
|
const QString &text)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
// The shift modifier only counts when it is not used to type a symbol
|
||||||
|
// that is only reachable using the shift key anyway
|
||||||
|
if ((state & Qt::ShiftModifier) && (text.size() == 0
|
||||||
|
|| !text.at(0).isPrint()
|
||||||
|
|| text.at(0).isLetterOrNumber()
|
||||||
|
|| text.at(0).isSpace()))
|
||||||
|
result |= Qt::SHIFT;
|
||||||
|
if (state & Qt::ControlModifier)
|
||||||
|
result |= Qt::CTRL;
|
||||||
|
if (state & Qt::MetaModifier)
|
||||||
|
result |= Qt::META;
|
||||||
|
if (state & Qt::AltModifier)
|
||||||
|
result |= Qt::ALT;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
48
shortcuts_management/edit_shortcut_item_delegate.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#ifndef EDIT_SHORTCUT_ITEM_DELEGATE_H
|
||||||
|
#define EDIT_SHORTCUT_ITEM_DELEGATE_H
|
||||||
|
|
||||||
|
#include <QItemDelegate>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
#include <QKeySequence>
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
class KeySequenceLineEdit : public QLineEdit
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit KeySequenceLineEdit(QWidget *parent = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//int numKeys;
|
||||||
|
//int keys[4];
|
||||||
|
void keyPressEvent(QKeyEvent *);
|
||||||
|
int translateModifiers(Qt::KeyboardModifiers state, const QString &text);
|
||||||
|
void resizeEvent(QResizeEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QToolButton *clearButton;
|
||||||
|
QToolButton *acceptButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
class EditShortcutItemDelegate : public QItemDelegate
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EditShortcutItemDelegate(QObject *parent = 0);
|
||||||
|
|
||||||
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||||
|
const QModelIndex &index) const;
|
||||||
|
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||||
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
|
const QModelIndex &index) const;
|
||||||
|
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex & mi) const;
|
||||||
|
bool eventFilter(QObject *editor, QEvent *event);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void closeShortcutEditor();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EDIT_SHORTCUT_ITEM_DELEGATE_H
|
95
shortcuts_management/edit_shortcuts_dialog.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
#include "edit_shortcuts_dialog.h"
|
||||||
|
|
||||||
|
#include "actions_groups_model.h"
|
||||||
|
#include "actions_shortcuts_model.h"
|
||||||
|
#include "edit_shortcut_item_delegate.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QTableView>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "QsLog.h"
|
||||||
|
|
||||||
|
EditShortcutsDialog::EditShortcutsDialog(QWidget *parent) :
|
||||||
|
QDialog(parent)
|
||||||
|
{
|
||||||
|
QPushButton * resetButton = new QPushButton(tr("Restore defaults"),this);
|
||||||
|
QLabel * infoLabel = new QLabel(tr("To change a shortcut, double click in the key combination and type the new keys."));
|
||||||
|
QVBoxLayout * layout = new QVBoxLayout(this);
|
||||||
|
QSplitter * splitter = new QSplitter(this);
|
||||||
|
actionsGroupsListView = new QListView(this);
|
||||||
|
|
||||||
|
actionsTableView = new QTableView(this);
|
||||||
|
actionsTableView->verticalHeader()->setHidden(true);
|
||||||
|
actionsTableView->horizontalHeader()->setHidden(true);
|
||||||
|
splitter->addWidget(actionsGroupsListView);
|
||||||
|
splitter->addWidget(actionsTableView);
|
||||||
|
splitter->setStretchFactor(1,1);
|
||||||
|
splitter->setSizes(QList<int>() << 200 << 400);
|
||||||
|
|
||||||
|
layout->addWidget(infoLabel,0);
|
||||||
|
layout->addWidget(splitter,1);
|
||||||
|
layout->addWidget(resetButton,0,Qt::AlignRight);
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
groupsModel = new ActionsGroupsModel();
|
||||||
|
actionsModel = new ActionsShortcutsModel();
|
||||||
|
actionsGroupsListView->setModel(groupsModel);
|
||||||
|
actionsGroupsListView->setFocus();
|
||||||
|
actionsTableView->setModel(actionsModel);
|
||||||
|
actionsTableView->setColumnWidth(0,30);
|
||||||
|
actionsTableView->setColumnWidth(1,360);
|
||||||
|
//actionsTableView->horizontalHeader()->sectionResizeMode(QHeaderView::Custom);
|
||||||
|
actionsTableView->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
actionsTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
actionsTableView->setShowGrid(false);
|
||||||
|
actionsTableView->setItemDelegateForColumn(ActionsShortcutsModel::KEYS,new EditShortcutItemDelegate(this));
|
||||||
|
actionsTableView->installEventFilter(this);
|
||||||
|
/*actionsTableView->setStyleSheet("QTableView {outline: 0px;}"
|
||||||
|
"QTableView::item {outline: 0px;}");
|
||||||
|
"QTableView {border:0px;}"
|
||||||
|
"QTableView::item:selected {outline: 0px; border: 0px;}"
|
||||||
|
"");*/
|
||||||
|
|
||||||
|
|
||||||
|
connect(resetButton,SIGNAL(clicked()),this,SLOT(resetToDefaults()));
|
||||||
|
connect(actionsGroupsListView->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(loadShortcuts(QModelIndex,QModelIndex))); //clicked(QModelIndex) doesn't work :S
|
||||||
|
connect(actionsModel,SIGNAL(conflict(QString)),this,SLOT(processConflict(QString)));
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
setFixedSize(760,500);
|
||||||
|
#else
|
||||||
|
setFixedSize(804,500); //extra width for modifiers
|
||||||
|
#endif
|
||||||
|
setWindowTitle(tr("Shortcuts settings"));
|
||||||
|
|
||||||
|
setModal(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutsDialog::addActionsGroup(const QString &name, const QIcon &ico, QList<QAction *> &group)
|
||||||
|
{
|
||||||
|
groupsModel->addActionsGroup(ActionsGroup(name,ico,group));
|
||||||
|
if(actionsTableView->model()->rowCount()==0)//first group added
|
||||||
|
actionsGroupsListView->selectionModel()->select(groupsModel->index(0,0),QItemSelectionModel::Select);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutsDialog::resetToDefaults()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutsDialog::loadShortcuts(const QModelIndex &mi,const QModelIndex &mi2)
|
||||||
|
{
|
||||||
|
actionsModel->addActions(groupsModel->getActions(mi));
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditShortcutsDialog::processConflict(const QString &shortcutInConflict)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this,tr("Shortcut in use"), QString(tr("The shortcut \"%1\" is already assigned to other function")).arg(shortcutInConflict));
|
||||||
|
}
|
33
shortcuts_management/edit_shortcuts_dialog.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef EDIT_SHORTCUTS_DIALOG_H
|
||||||
|
#define EDIT_SHORTCUTS_DIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
class QListView;
|
||||||
|
class QTableView;
|
||||||
|
|
||||||
|
class ActionsGroupsModel;
|
||||||
|
class ActionsShortcutsModel;
|
||||||
|
|
||||||
|
class EditShortcutsDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EditShortcutsDialog(QWidget * parent = 0);
|
||||||
|
void addActionsGroup(const QString & name, const QIcon & ico, QList<QAction *> & group);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void resetToDefaults();
|
||||||
|
void loadShortcuts(const QModelIndex & mi,const QModelIndex &mi2);
|
||||||
|
void processConflict(const QString & shortcutInConflict);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QListView * actionsGroupsListView;
|
||||||
|
QTableView * actionsTableView;
|
||||||
|
ActionsGroupsModel * groupsModel;
|
||||||
|
ActionsShortcutsModel * actionsModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EDIT_SHORTCUTS_DIALOG_H
|
16
shortcuts_management/shortcuts_management.pri
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
DEPENDPATH += $$PWD
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/edit_shortcuts_dialog.h \
|
||||||
|
$$PWD/actions_groups_model.h \
|
||||||
|
$$PWD/actions_shortcuts_model.h \
|
||||||
|
$$PWD/edit_shortcut_item_delegate.h \
|
||||||
|
$$PWD/shortcuts_manager.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/edit_shortcuts_dialog.cpp \
|
||||||
|
$$PWD/actions_groups_model.cpp \
|
||||||
|
$$PWD/actions_shortcuts_model.cpp \
|
||||||
|
$$PWD/edit_shortcut_item_delegate.cpp \
|
||||||
|
$$PWD/shortcuts_manager.cpp
|
112
shortcuts_management/shortcuts_manager.cpp
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#include "shortcuts_manager.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
#include <QAction>
|
||||||
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
|
ShortcutsManager::ShortcutsManager()
|
||||||
|
{
|
||||||
|
initDefaultShorcuts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsManager::initDefaultShorcuts()
|
||||||
|
{
|
||||||
|
#ifdef YACREADER_LIBRARY
|
||||||
|
//ACTIONS
|
||||||
|
defaultShorcuts.insert(CREATE_LIBRARY_ACTION_YL,Qt::Key_A);
|
||||||
|
defaultShorcuts.insert(OPEN_LIBRARY_ACTION_YL,Qt::Key_O);
|
||||||
|
defaultShorcuts.insert(UPDATE_LIBRARY_ACTION_YL,Qt::Key_U);
|
||||||
|
defaultShorcuts.insert(RENAME_LIBRARY_ACTION_YL,Qt::Key_R);
|
||||||
|
defaultShorcuts.insert(OPEN_COMIC_ACTION_YL,Qt::Key_Return);
|
||||||
|
defaultShorcuts.insert(SHOW_HIDE_MARKS_ACTION_YL,Qt::Key_M);
|
||||||
|
defaultShorcuts.insert(TOGGLE_FULL_SCREEN_ACTION_YL,Qt::Key_F);
|
||||||
|
defaultShorcuts.insert(HELP_ABOUT_ACTION_YL,Qt::Key_F1);
|
||||||
|
defaultShorcuts.insert(SET_ROOT_INDEX_ACTION_YL,Qt::Key_0);
|
||||||
|
defaultShorcuts.insert(EXPAND_ALL_NODES_ACTION_YL,Qt::Key_Plus);
|
||||||
|
defaultShorcuts.insert(COLAPSE_ALL_NODES_ACTION_YL,Qt::Key_Minus);
|
||||||
|
defaultShorcuts.insert(OPTIONS_ACTION_YL,Qt::Key_C);
|
||||||
|
defaultShorcuts.insert(SERVER_CONFIG_ACTION_YL,Qt::Key_S);
|
||||||
|
defaultShorcuts.insert(TOGGLE_COMICS_VIEW_ACTION_YL,Qt::Key_V);
|
||||||
|
|
||||||
|
//COMMANDS (used in keypressevent)
|
||||||
|
#else
|
||||||
|
defaultShorcuts.insert(OPEN_ACTION_Y, Qt::Key_O);
|
||||||
|
defaultShorcuts.insert(OPEN_FOLDER_ACTION_Y, Qt::CTRL | Qt::Key_O);
|
||||||
|
defaultShorcuts.insert(OPEN_PREVIOUS_COMIC_ACTION_Y, Qt::CTRL | Qt::Key_Left);
|
||||||
|
defaultShorcuts.insert(OPEN_NEXT_COMIC_ACTION_Y, Qt::CTRL | Qt::Key_Right);
|
||||||
|
defaultShorcuts.insert(PREV_ACTION_Y, Qt::Key_Left);
|
||||||
|
defaultShorcuts.insert(NEXT_ACTION_Y, Qt::Key_Right);
|
||||||
|
defaultShorcuts.insert(LEFT_ROTATION_ACTION_Y, Qt::Key_L);
|
||||||
|
defaultShorcuts.insert(RIGHT_ROTATION_ACTION_Y, Qt::Key_R);
|
||||||
|
defaultShorcuts.insert(DOUBLE_PAGE_ACTION_Y, Qt::Key_D);
|
||||||
|
defaultShorcuts.insert(GO_TO_PAGE_ACTION_Y, Qt::Key_G);
|
||||||
|
defaultShorcuts.insert(OPTIONS_ACTION_Y, Qt::Key_C);
|
||||||
|
defaultShorcuts.insert(HELP_ABOUT_ACTION_Y, Qt::Key_F1);
|
||||||
|
defaultShorcuts.insert(SHOW_MAGNIFYING_GLASS_ACTION_Y, Qt::Key_Z);
|
||||||
|
defaultShorcuts.insert(SET_BOOKMARK_ACTION_Y, Qt::CTRL | Qt::Key_M);
|
||||||
|
defaultShorcuts.insert(SHOW_BOOKMARKS_ACTION_Y, Qt::Key_M);
|
||||||
|
defaultShorcuts.insert(SHOW_INFO_ACTION_Y, Qt::Key_I);
|
||||||
|
defaultShorcuts.insert(CLOSE_ACTION_Y, Qt::Key_Escape);
|
||||||
|
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(SHOW_FLOW_ACTION_Y, Qt::Key_S);
|
||||||
|
|
||||||
|
//main_window_viewer
|
||||||
|
defaultShorcuts.insert(TOGGLE_FULL_SCREEN_ACTION_Y, Qt::Key_F);
|
||||||
|
defaultShorcuts.insert(TOGGLE_TOOL_BARS_ACTION_Y, Qt::Key_H);
|
||||||
|
defaultShorcuts.insert(CHANGE_FIT_ACTION_Y, Qt::Key_A);
|
||||||
|
//viewer
|
||||||
|
defaultShorcuts.insert(AUTO_SCROLL_FORWARD_ACTION_Y, Qt::Key_Space);
|
||||||
|
defaultShorcuts.insert(AUTO_SCROLL_BACKWARD_ACTION_Y, Qt::Key_B);
|
||||||
|
defaultShorcuts.insert(MOVE_DOWN_ACTION_Y, Qt::Key_Down);
|
||||||
|
defaultShorcuts.insert(MOVE_UP_ACTION_Y, Qt::Key_Up);
|
||||||
|
defaultShorcuts.insert(GO_TO_FIRST_PAGE_ACTION_Y, Qt::Key_Home);
|
||||||
|
defaultShorcuts.insert(GO_TO_LAST_PAGE_ACTION_Y, Qt::Key_End);
|
||||||
|
//mglass
|
||||||
|
defaultShorcuts.insert(SIZE_UP_MGLASS_ACTION_Y, Qt::Key_Plus);
|
||||||
|
defaultShorcuts.insert(SIZE_DOWN_MGLASS_ACTION_Y, Qt::Key_Minus);
|
||||||
|
defaultShorcuts.insert(ZOOM_IN_MGLASS_ACTION_Y, Qt::Key_Asterisk);
|
||||||
|
defaultShorcuts.insert(ZOOM_OUT_MGLASS_ACTION_Y, Qt::Key_Underscore);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsManager::resetToDefaults()
|
||||||
|
{
|
||||||
|
//TODO reset to defaults
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ShortcutsManager::getShortcut(const QString &name)
|
||||||
|
{
|
||||||
|
QSettings s(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
|
s.beginGroup("shortcuts");
|
||||||
|
|
||||||
|
return s.value(name,defaultShorcuts.value(name)).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsManager::saveShortcut(QAction *action)
|
||||||
|
{
|
||||||
|
QSettings s(YACReader::getSettingsPath()+"/YACReaderLibrary.ini",QSettings::IniFormat);
|
||||||
|
s.beginGroup("shortcuts");
|
||||||
|
|
||||||
|
return s.setValue(action->data().toString() , action->shortcut().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShortcutsManager::registerActions(const QList<QAction *> &a)
|
||||||
|
{
|
||||||
|
actions = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShortcutsManager::checkConflicts(const QKeySequence & shortcut, const QAction *dest)
|
||||||
|
{
|
||||||
|
foreach(QAction * action, actions)
|
||||||
|
{
|
||||||
|
if(action != dest) //if the same shortcut is setted there is no conflict
|
||||||
|
if(action->shortcut() == shortcut)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
127
shortcuts_management/shortcuts_manager.h
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
#ifndef SHORTCUTS_MANAGER_H
|
||||||
|
#define SHORTCUTS_MANAGER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QKeySequence>
|
||||||
|
#include <QString>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
|
class QAction;
|
||||||
|
|
||||||
|
//QAction: used setData() and data() for storing (userData) an identifier for each QAction. This value is ussed in QSettings
|
||||||
|
|
||||||
|
class ShortcutsManager
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
ShortcutsManager();
|
||||||
|
QMap<QString,QKeySequence> defaultShorcuts;
|
||||||
|
QList<QAction *> actions; //all actions registered, used for checking conflicts
|
||||||
|
|
||||||
|
void initDefaultShorcuts();
|
||||||
|
public:
|
||||||
|
static ShortcutsManager & getShortcutsManager()
|
||||||
|
{
|
||||||
|
static ShortcutsManager manager;
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetToDefaults();
|
||||||
|
QString getShortcut(const QString & name);
|
||||||
|
void saveShortcut(QAction * action);
|
||||||
|
void registerActions(const QList<QAction *> & actions);
|
||||||
|
bool checkConflicts(const QKeySequence &shortcut, const QAction *dest);
|
||||||
|
};
|
||||||
|
|
||||||
|
//ACTION NAMES YACReaderLibrary
|
||||||
|
#define BACK_ACTION_YL "BACK_ACTION_YL"
|
||||||
|
#define FORWARD_ACTION_YL "FORWARD_ACTION_YL"
|
||||||
|
#define CREATE_LIBRARY_ACTION_YL "CREATE_LIBRARY_ACTION_YL"
|
||||||
|
#define OPEN_LIBRARY_ACTION_YL "OPEN_LIBRARY_ACTION_YL"
|
||||||
|
#define EXPORT_COMICS_INFO_ACTION_YL "EXPORT_COMICS_INFO_ACTION_YL"
|
||||||
|
#define IMPORT_COMICS_INFO_ACTION_YL "IMPORT_COMICS_INFO_ACTION_YL"
|
||||||
|
#define EXPORT_LIBRARY_ACTION_YL "EXPORT_LIBRARY_ACTION_YL"
|
||||||
|
#define IMPORT_LIBRARY_ACTION_YL "IMPORT_LIBRARY_ACTION_YL"
|
||||||
|
#define UPDATE_LIBRARY_ACTION_YL "UPDATE_LIBRARY_ACTION_YL"
|
||||||
|
#define RENAME_LIBRARY_ACTION_YL "RENAME_LIBRARY_ACTION_YL"
|
||||||
|
#define REMOVE_LIBRARY_ACTION_YL "REMOVE_LIBRARY_ACTION_YL"
|
||||||
|
#define OPEN_COMIC_ACTION_YL "OPEN_COMIC_ACTION_YL"
|
||||||
|
#define SET_AS_READ_ACTION_YL "SET_AS_READ_ACTION_YL"
|
||||||
|
#define SET_AS_NON_READ_ACTION_YL "SET_AS_NON_READ_ACTION_YL"
|
||||||
|
#define SHOW_HIDE_MARKS_ACTION_YL "SHOW_HIDE_MARKS_ACTION_YL"
|
||||||
|
#define TOGGLE_FULL_SCREEN_ACTION_YL "TOGGLE_FULL_SCREEN_ACTION_YL"
|
||||||
|
#define HELP_ABOUT_ACTION_YL "HELP_ABOUT_ACTION_YL"
|
||||||
|
#define SET_ROOT_INDEX_ACTION_YL "SET_ROOT_INDEX_ACTION_YL"
|
||||||
|
#define EXPAND_ALL_NODES_ACTION_YL "EXPAND_ALL_NODES_ACTION_YL"
|
||||||
|
#define COLAPSE_ALL_NODES_ACTION_YL "COLAPSE_ALL_NODES_ACTION_YL"
|
||||||
|
#define OPTIONS_ACTION_YL "OPTIONS_ACTION_YL"
|
||||||
|
#define SERVER_CONFIG_ACTION_YL "SERVER_CONFIG_ACTION_YL"
|
||||||
|
#define TOGGLE_COMICS_VIEW_ACTION_YL "TOGGLE_COMICS_VIEW_ACTION_YL"
|
||||||
|
#define OPEN_CONTAINING_FOLDER_ACTION_YL "OPEN_CONTAINING_FOLDER_ACTION_YL"
|
||||||
|
#define SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL "SET_FOLDER_AS_NOT_COMPLETED_ACTION_YL"
|
||||||
|
#define SET_FOLDER_AS_COMPLETED_ACTION_YL "SET_FOLDER_AS_COMPLETED_ACTION_YL"
|
||||||
|
#define SET_FOLDER_AS_READ_ACTION_YL "SET_FOLDER_AS_READ_ACTION_YL"
|
||||||
|
#define SET_FOLDER_AS_UNREAD_ACTION_YL "SET_FOLDER_AS_UNREAD_ACTION_YL"
|
||||||
|
#define OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL "OPEN_CONTAINING_FOLDER_COMIC_ACTION_YL"
|
||||||
|
#define RESET_COMIC_RATING_ACTION_YL "RESET_COMIC_RATING_ACTION_YL"
|
||||||
|
#define SELECT_ALL_COMICS_ACTION_YL "SELECT_ALL_COMICS_ACTION_YL"
|
||||||
|
#define EDIT_SELECTED_COMICS_ACTION_YL "EDIT_SELECTED_COMICS_ACTION_YL"
|
||||||
|
#define ASIGN_ORDER_ACTION_YL "ASIGN_ORDER_ACTION_YL"
|
||||||
|
#define FORCE_COVER_EXTRACTED_ACTION_YL "FORCE_COVER_EXTRACTED_ACTION_YL"
|
||||||
|
#define DELETE_COMICS_ACTION_YL "DELETE_COMICS_ACTION_YL"
|
||||||
|
#define HIDE_COMIC_VIEW_ACTION_YL "HIDE_COMIC_VIEW_ACTION_YL"
|
||||||
|
#define GET_INFO_ACTION_YL "GET_INFO_ACTION_YL"
|
||||||
|
#define SHOW_EDIT_SHORTCUTS_ACTION_YL "SHOW_EDIT_SHORTCUTS_ACTION_YL"
|
||||||
|
|
||||||
|
//COMMANDS YACReaderLibrary
|
||||||
|
|
||||||
|
|
||||||
|
//ACTION NAMES YACReader
|
||||||
|
#define OPEN_ACTION_Y "OPEN_ACTION_Y"
|
||||||
|
#define OPEN_FOLDER_ACTION_Y "OPEN_FOLDER_ACTION_Y"
|
||||||
|
#define SAVE_IMAGE_ACTION_Y "SAVE_IMAGE_ACTION_Y"
|
||||||
|
#define OPEN_PREVIOUS_COMIC_ACTION_Y "OPEN_PREVIOUS_COMIC_ACTION_Y"
|
||||||
|
#define OPEN_NEXT_COMIC_ACTION_Y "OPEN_NEXT_COMIC_ACTION_Y"
|
||||||
|
#define PREV_ACTION_Y "PREV_ACTION_Y"
|
||||||
|
#define NEXT_ACTION_Y "NEXT_ACTION_Y"
|
||||||
|
#define ADJUST_HEIGHT_ACTION_Y "ADJUST_HEIGHT_Y"
|
||||||
|
#define ADJUST_WIDTH_ACTION_Y "ADJUST_WIDTH_Y"
|
||||||
|
#define LEFT_ROTATION_ACTION_Y "LEFT_ROTATION_ACTION_Y"
|
||||||
|
#define RIGHT_ROTATION_ACTION_Y "RIGHT_ROTATION_ACTION_Y"
|
||||||
|
#define DOUBLE_PAGE_ACTION_Y "DOUBLE_PAGE_ACTION_Y"
|
||||||
|
#define GO_TO_PAGE_ACTION_Y "GO_TO_PAGE_ACTION_Y"
|
||||||
|
#define OPTIONS_ACTION_Y "OPTIONS_ACTION_Y"
|
||||||
|
#define HELP_ABOUT_ACTION_Y "HELP_ABOUT_ACTION_Y"
|
||||||
|
#define SHOW_MAGNIFYING_GLASS_ACTION_Y "SHOW_MAGNIFYING_GLASS_ACTION_Y"
|
||||||
|
#define SET_BOOKMARK_ACTION_Y "SET_BOOKMARK_ACTION_Y"
|
||||||
|
#define SHOW_BOOKMARKS_ACTION_Y "SHOW_BOOKMARKS_ACTION_Y"
|
||||||
|
#define SHOW_SHORCUTS_ACTION_Y "SHOW_SHORCUTS_ACTION_Y"
|
||||||
|
#define SHOW_INFO_ACTION_Y "SHOW_INFO_ACTION_Y"
|
||||||
|
#define CLOSE_ACTION_Y "CLOSE_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 SHOW_FLOW_ACTION_Y "SHOW_FLOW_ACTION_Y"
|
||||||
|
#define SHOW_EDIT_SHORTCUTS_ACTION_Y "SHOW_EDIT_SHORTCUTS_ACTION_Y"
|
||||||
|
|
||||||
|
//COMMANDS YACReader
|
||||||
|
//main_viewer_window
|
||||||
|
#define TOGGLE_FULL_SCREEN_ACTION_Y "TOGGLE_FULL_SCREEN_ACTION_Y"
|
||||||
|
#define TOGGLE_TOOL_BARS_ACTION_Y "TOGGLE_TOOL_BARS_ACTION_Y"
|
||||||
|
#define CHANGE_FIT_ACTION_Y "CHANGE_FIT_ACTION_Y"
|
||||||
|
//viewer
|
||||||
|
#define AUTO_SCROLL_FORWARD_ACTION_Y "AUTO_SCROLL_FORWARD_ACTION_Y"
|
||||||
|
#define AUTO_SCROLL_BACKWARD_ACTION_Y "AUTO_SCROLL_BACKWARD_ACTION_Y"
|
||||||
|
#define MOVE_DOWN_ACTION_Y "MOVE_DOWN_ACTION_Y"
|
||||||
|
#define MOVE_UP_ACTION_Y "MOVE_UP_ACTION_Y"
|
||||||
|
#define MOVE_LEFT_ACTION_Y "MOVE_LEFT_ACTION_Y"
|
||||||
|
#define MOVE_RIGHT_ACTION_Y "MOVE_RIGHT_ACTION_Y"
|
||||||
|
#define GO_TO_FIRST_PAGE_ACTION_Y "GO_TO_FIRST_PAGE_ACTION_Y"
|
||||||
|
#define GO_TO_LAST_PAGE_ACTION_Y "GO_TO_LAST_PAGE_ACTION_Y"
|
||||||
|
//mglass
|
||||||
|
#define SIZE_UP_MGLASS_ACTION_Y "SIZE_UP_MGLASS_ACTION_Y"
|
||||||
|
#define SIZE_DOWN_MGLASS_ACTION_Y "SIZE_DOWN_MGLASS_ACTION_Y"
|
||||||
|
#define ZOOM_IN_MGLASS_ACTION_Y "ZOOM_IN_MGLASS_ACTION_Y"
|
||||||
|
#define ZOOM_OUT_MGLASS_ACTION_Y "ZOOM_OUT_MGLASS_ACTION_Y"
|
||||||
|
|
||||||
|
#endif // SHORTCUTS_MANAGER_H
|