merged
@ -8,5 +8,5 @@ Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
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
|
||||
|
@ -134,6 +134,7 @@ SOURCES += $$PWD/../common/comic.cpp \
|
||||
|
||||
include($$PWD/../custom_widgets/custom_widgets_yacreader.pri)
|
||||
include($$PWD/../compressed_archive/wrapper.pri)
|
||||
include($$PWD/../shortcuts_management/shortcuts_management.pri)
|
||||
|
||||
RESOURCES += $$PWD/yacreader_images.qrc \
|
||||
$$PWD/yacreader_files.qrc
|
||||
|
@ -6,7 +6,7 @@ TARGET = YACReader
|
||||
DEPENDPATH += . \
|
||||
release
|
||||
|
||||
DEFINES += NOMINMAX
|
||||
DEFINES += NOMINMAX YACREADER
|
||||
|
||||
unix:!macx{
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "magnifying_glass.h"
|
||||
#include "viewer.h"
|
||||
#include "configuration.h"
|
||||
#include "shortcuts_manager.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
@ -244,26 +245,48 @@ void MagnifyingGlass::widthDown()
|
||||
void MagnifyingGlass::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
bool validKey = false;
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Plus:
|
||||
sizeUp();
|
||||
validKey = true;
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
sizeDown();
|
||||
validKey = true;
|
||||
break;
|
||||
case Qt::Key_Underscore:
|
||||
zoomOut();
|
||||
validKey = true;
|
||||
break;
|
||||
case Qt::Key_Asterisk:
|
||||
zoomIn();
|
||||
validKey = true;
|
||||
break;
|
||||
}
|
||||
updateImage();
|
||||
|
||||
int _key = event->key();
|
||||
Qt::KeyboardModifiers modifiers = event->modifiers();
|
||||
|
||||
if(modifiers & Qt::ShiftModifier)
|
||||
_key |= Qt::SHIFT;
|
||||
if (modifiers & Qt::ControlModifier)
|
||||
_key |= Qt::CTRL;
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
_key |= Qt::META;
|
||||
if (modifiers & Qt::AltModifier)
|
||||
_key |= Qt::ALT;
|
||||
|
||||
QKeySequence key(_key);
|
||||
|
||||
if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y))
|
||||
{
|
||||
sizeUp();
|
||||
validKey = true;
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y))
|
||||
{
|
||||
sizeDown();
|
||||
validKey = true;
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y))
|
||||
{
|
||||
zoomIn();
|
||||
validKey = true;
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y))
|
||||
{
|
||||
zoomOut();
|
||||
validKey = true;
|
||||
}
|
||||
|
||||
if(validKey)
|
||||
{
|
||||
updateImage();
|
||||
event->setAccepted(true);
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "yacreader_local_client.h"
|
||||
|
||||
#include "yacreader_global.h"
|
||||
#include "edit_shortcuts_dialog.h"
|
||||
#include "shortcuts_manager.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
@ -87,19 +89,19 @@ MainWindowViewer::~MainWindowViewer()
|
||||
delete openNextComicAction;
|
||||
delete prevAction;
|
||||
delete nextAction;
|
||||
delete adjustHeight;
|
||||
delete adjustWidth;
|
||||
delete adjustHeightAction;
|
||||
delete adjustWidthAction;
|
||||
delete leftRotationAction;
|
||||
delete rightRotationAction;
|
||||
delete doublePageAction;
|
||||
delete goToPage;
|
||||
delete goToPageAction;
|
||||
delete optionsAction;
|
||||
delete helpAboutAction;
|
||||
delete showMagnifyingGlass;
|
||||
delete setBookmark;
|
||||
delete showBookmarks;
|
||||
delete showMagnifyingGlassAction;
|
||||
delete setBookmarkAction;
|
||||
delete showBookmarksAction;
|
||||
delete showShorcutsAction;
|
||||
delete showInfo;
|
||||
delete showInfoAction;
|
||||
delete closeAction;
|
||||
delete showDictionaryAction;
|
||||
delete alwaysOnTopAction;
|
||||
@ -163,8 +165,12 @@ void MainWindowViewer::setupUI()
|
||||
|
||||
optionsDialog->restoreOptions(settings);
|
||||
shortcutsDialog = new ShortcutsDialog(this);
|
||||
editShortcutsDialog = new EditShortcutsDialog(this);
|
||||
connect(optionsDialog,SIGNAL(editShortcuts()),editShortcutsDialog,SLOT(show()));
|
||||
|
||||
createActions();
|
||||
setUpShortcutsManagement();
|
||||
|
||||
createToolBars();
|
||||
|
||||
setWindowTitle("YACReader");
|
||||
@ -194,181 +200,216 @@ void MainWindowViewer::setupUI()
|
||||
|
||||
void MainWindowViewer::createActions()
|
||||
{
|
||||
openAction = new QAction(tr("&Open"),this);
|
||||
openAction->setShortcut(tr("O"));
|
||||
openAction->setIcon(QIcon(":/images/viewer_toolbar/open.png"));
|
||||
openAction->setToolTip(tr("Open a comic"));
|
||||
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||
openAction = new QAction(tr("&Open"),this);
|
||||
openAction->setIcon(QIcon(":/images/viewer_toolbar/open.png"));
|
||||
openAction->setToolTip(tr("Open a comic"));
|
||||
openAction->setData(OPEN_ACTION_Y);
|
||||
openAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_ACTION_Y));
|
||||
connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
|
||||
|
||||
openFolderAction = new QAction(tr("Open Folder"),this);
|
||||
openFolderAction->setShortcut(tr("Ctrl+O"));
|
||||
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
|
||||
openFolderAction->setToolTip(tr("Open image folder"));
|
||||
connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openFolder()));
|
||||
openFolderAction = new QAction(tr("Open Folder"),this);
|
||||
openFolderAction->setIcon(QIcon(":/images/viewer_toolbar/openFolder.png"));
|
||||
openFolderAction->setToolTip(tr("Open image folder"));
|
||||
openFolderAction->setData(OPEN_FOLDER_ACTION_Y);
|
||||
openFolderAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_FOLDER_ACTION_Y));
|
||||
connect(openFolderAction, SIGNAL(triggered()), this, SLOT(openFolder()));
|
||||
|
||||
saveImageAction = new QAction(tr("Save"),this);
|
||||
saveImageAction->setIcon(QIcon(":/images/viewer_toolbar/save.png"));
|
||||
saveImageAction->setToolTip(tr("Save current page"));
|
||||
saveImageAction->setDisabled(true);
|
||||
connect(saveImageAction,SIGNAL(triggered()),this,SLOT(saveImage()));
|
||||
saveImageAction = new QAction(tr("Save"),this);
|
||||
saveImageAction->setIcon(QIcon(":/images/viewer_toolbar/save.png"));
|
||||
saveImageAction->setToolTip(tr("Save current page"));
|
||||
saveImageAction->setDisabled(true);
|
||||
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->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.png"));
|
||||
openPreviousComicAction->setShortcut(Qt::CTRL + Qt::Key_Left);
|
||||
openPreviousComicAction->setToolTip(tr("Open previous comic"));
|
||||
openPreviousComicAction->setDisabled(true);
|
||||
connect(openPreviousComicAction,SIGNAL(triggered()),this,SLOT(openPreviousComic()));
|
||||
openPreviousComicAction = new QAction(tr("Previous Comic"),this);
|
||||
openPreviousComicAction->setIcon(QIcon(":/images/viewer_toolbar/openPrevious.png"));
|
||||
openPreviousComicAction->setToolTip(tr("Open previous comic"));
|
||||
openPreviousComicAction->setDisabled(true);
|
||||
openPreviousComicAction->setData(OPEN_PREVIOUS_COMIC_ACTION_Y);
|
||||
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->setIcon(QIcon(":/images/viewer_toolbar/openNext.png"));
|
||||
openNextComicAction->setShortcut(Qt::CTRL + Qt::Key_Right);
|
||||
openNextComicAction->setToolTip(tr("Open next comic"));
|
||||
openNextComicAction->setDisabled(true);
|
||||
connect(openNextComicAction,SIGNAL(triggered()),this,SLOT(openNextComic()));
|
||||
openNextComicAction = new QAction(tr("Next Comic"),this);
|
||||
openNextComicAction->setIcon(QIcon(":/images/viewer_toolbar/openNext.png"));
|
||||
openNextComicAction->setToolTip(tr("Open next comic"));
|
||||
openNextComicAction->setDisabled(true);
|
||||
openNextComicAction->setData(OPEN_NEXT_COMIC_ACTION_Y);
|
||||
openNextComicAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(OPEN_NEXT_COMIC_ACTION_Y));
|
||||
connect(openNextComicAction,SIGNAL(triggered()),this,SLOT(openNextComic()));
|
||||
|
||||
prevAction = new QAction(tr("&Previous"),this);
|
||||
prevAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
|
||||
prevAction->setShortcut(Qt::Key_Left);
|
||||
prevAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
prevAction->setToolTip(tr("Go to previous page"));
|
||||
prevAction->setDisabled(true);
|
||||
connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev()));
|
||||
prevAction = new QAction(tr("&Previous"),this);
|
||||
prevAction->setIcon(QIcon(":/images/viewer_toolbar/previous.png"));
|
||||
prevAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
prevAction->setToolTip(tr("Go to previous page"));
|
||||
prevAction->setDisabled(true);
|
||||
prevAction->setData(PREV_ACTION_Y);
|
||||
prevAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(PREV_ACTION_Y));
|
||||
connect(prevAction, SIGNAL(triggered()),viewer,SLOT(prev()));
|
||||
|
||||
nextAction = new QAction(tr("&Next"),this);
|
||||
nextAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
|
||||
nextAction->setShortcut(Qt::Key_Right);
|
||||
nextAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
nextAction->setToolTip(tr("Go to next page"));
|
||||
nextAction = new QAction(tr("&Next"),this);
|
||||
nextAction->setIcon(QIcon(":/images/viewer_toolbar/next.png"));
|
||||
nextAction->setShortcutContext(Qt::WidgetShortcut);
|
||||
nextAction->setToolTip(tr("Go to next page"));
|
||||
nextAction->setDisabled(true);
|
||||
nextAction->setData(NEXT_ACTION_Y);
|
||||
nextAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(NEXT_ACTION_Y));
|
||||
connect(nextAction, SIGNAL(triggered()),viewer,SLOT(next()));
|
||||
|
||||
adjustHeight = new QAction(tr("Fit Height"),this);
|
||||
adjustHeight->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
|
||||
adjustHeightAction = new QAction(tr("Fit Height"),this);
|
||||
adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
|
||||
//adjustWidth->setCheckable(true);
|
||||
adjustHeight->setDisabled(true);
|
||||
adjustHeight->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustHeight->setToolTip(tr("Fit image to height"));
|
||||
adjustHeightAction->setDisabled(true);
|
||||
adjustHeightAction->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustHeightAction->setToolTip(tr("Fit image to height"));
|
||||
//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);
|
||||
adjustWidth->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
|
||||
adjustWidthAction = new QAction(tr("Fit Width"),this);
|
||||
adjustWidthAction->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
|
||||
//adjustWidth->setCheckable(true);
|
||||
adjustWidth->setDisabled(true);
|
||||
adjustWidth->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustWidth->setToolTip(tr("Fit image to width"));
|
||||
adjustWidthAction->setDisabled(true);
|
||||
adjustWidthAction->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustWidthAction->setToolTip(tr("Fit image to width"));
|
||||
//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->setShortcut(tr("L"));
|
||||
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
|
||||
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()));
|
||||
|
||||
rightRotationAction = new QAction(tr("Rotate image to the right"),this);
|
||||
rightRotationAction->setShortcut(tr("R"));
|
||||
rightRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateR.png"));
|
||||
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()));
|
||||
|
||||
doublePageAction = new QAction(tr("Double page mode"),this);
|
||||
doublePageAction->setToolTip(tr("Switch to double page mode"));
|
||||
doublePageAction->setShortcut(tr("D"));
|
||||
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
|
||||
doublePageAction->setDisabled(true);
|
||||
doublePageAction->setCheckable(true);
|
||||
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()));
|
||||
|
||||
goToPage = new QAction(tr("Go To"),this);
|
||||
goToPage->setShortcut(tr("G"));
|
||||
goToPage->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
||||
goToPage->setDisabled(true);
|
||||
goToPage->setToolTip(tr("Go to page ..."));
|
||||
connect(goToPage, SIGNAL(triggered()),viewer,SLOT(showGoToDialog()));
|
||||
goToPageAction = new QAction(tr("Go To"),this);
|
||||
goToPageAction->setIcon(QIcon(":/images/viewer_toolbar/goto.png"));
|
||||
goToPageAction->setDisabled(true);
|
||||
goToPageAction->setToolTip(tr("Go to page ..."));
|
||||
goToPageAction->setData(GO_TO_PAGE_ACTION_Y);
|
||||
goToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_PAGE_ACTION_Y));
|
||||
connect(goToPageAction, SIGNAL(triggered()),viewer,SLOT(showGoToDialog()));
|
||||
|
||||
optionsAction = new QAction(tr("Options"),this);
|
||||
optionsAction->setShortcut(tr("C"));
|
||||
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"));
|
||||
|
||||
connect(optionsAction, SIGNAL(triggered()),optionsDialog,SLOT(show()));
|
||||
|
||||
helpAboutAction = new QAction(tr("Help"),this);
|
||||
helpAboutAction->setToolTip(tr("Help, About YACReader"));
|
||||
helpAboutAction->setShortcut(Qt::Key_F1);
|
||||
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()));
|
||||
|
||||
showMagnifyingGlass = new QAction(tr("Magnifying glass"),this);
|
||||
showMagnifyingGlass->setToolTip(tr("Switch Magnifying glass"));
|
||||
showMagnifyingGlass->setShortcut(tr("Z"));
|
||||
showMagnifyingGlass->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.png"));
|
||||
showMagnifyingGlass->setDisabled(true);
|
||||
showMagnifyingGlass->setCheckable(true);
|
||||
connect(showMagnifyingGlass, SIGNAL(triggered()),viewer,SLOT(magnifyingGlassSwitch()));
|
||||
showMagnifyingGlassAction = new QAction(tr("Magnifying glass"),this);
|
||||
showMagnifyingGlassAction->setToolTip(tr("Switch Magnifying glass"));
|
||||
showMagnifyingGlassAction->setIcon(QIcon(":/images/viewer_toolbar/magnifyingGlass.png"));
|
||||
showMagnifyingGlassAction->setDisabled(true);
|
||||
showMagnifyingGlassAction->setCheckable(true);
|
||||
showMagnifyingGlassAction->setData(SHOW_MAGNIFYING_GLASS_ACTION_Y);
|
||||
showMagnifyingGlassAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_MAGNIFYING_GLASS_ACTION_Y));
|
||||
connect(showMagnifyingGlassAction, SIGNAL(triggered()),viewer,SLOT(magnifyingGlassSwitch()));
|
||||
|
||||
setBookmark = new QAction(tr("Set bookmark"),this);
|
||||
setBookmark->setToolTip(tr("Set a bookmark on the current page"));
|
||||
setBookmark->setShortcut(Qt::CTRL+Qt::Key_M);
|
||||
setBookmark->setIcon(QIcon(":/images/viewer_toolbar/bookmark.png"));
|
||||
setBookmark->setDisabled(true);
|
||||
setBookmark->setCheckable(true);
|
||||
connect(setBookmark,SIGNAL(triggered (bool)),viewer,SLOT(setBookmark(bool)));
|
||||
connect(viewer,SIGNAL(pageAvailable(bool)),setBookmark,SLOT(setEnabled(bool)));
|
||||
connect(viewer,SIGNAL(pageIsBookmark(bool)),setBookmark,SLOT(setChecked(bool)));
|
||||
setBookmarkAction = new QAction(tr("Set bookmark"),this);
|
||||
setBookmarkAction->setToolTip(tr("Set a bookmark on the current page"));
|
||||
setBookmarkAction->setIcon(QIcon(":/images/viewer_toolbar/bookmark.png"));
|
||||
setBookmarkAction->setDisabled(true);
|
||||
setBookmarkAction->setCheckable(true);
|
||||
setBookmarkAction->setData(SET_BOOKMARK_ACTION_Y);
|
||||
setBookmarkAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SET_BOOKMARK_ACTION_Y));
|
||||
connect(setBookmarkAction,SIGNAL(triggered (bool)),viewer,SLOT(setBookmarkAction(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);
|
||||
showBookmarks->setToolTip(tr("Show the bookmarks of the current comic"));
|
||||
showBookmarks->setShortcut(tr("M"));
|
||||
showBookmarks->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.png"));
|
||||
showBookmarks->setDisabled(true);
|
||||
connect(showBookmarks, SIGNAL(triggered()),viewer->getBookmarksDialog(),SLOT(show()));
|
||||
showBookmarksAction = new QAction(tr("Show bookmarks"),this);
|
||||
showBookmarksAction->setToolTip(tr("Show the bookmarks of the current comic"));
|
||||
showBookmarksAction->setIcon(QIcon(":/images/viewer_toolbar/showBookmarks.png"));
|
||||
showBookmarksAction->setDisabled(true);
|
||||
showBookmarksAction->setData(SHOW_BOOKMARKS_ACTION_Y);
|
||||
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->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()));
|
||||
|
||||
showInfo = new QAction(tr("Show Info"),this);
|
||||
showInfo->setShortcut(tr("I"));
|
||||
showInfo->setIcon(QIcon(":/images/viewer_toolbar/info.png"));
|
||||
showInfo->setDisabled(true);
|
||||
connect(showInfo, SIGNAL(triggered()),viewer,SLOT(informationSwitch()));
|
||||
showInfoAction = new QAction(tr("Show Info"),this);
|
||||
showInfoAction->setIcon(QIcon(":/images/viewer_toolbar/info.png"));
|
||||
showInfoAction->setDisabled(true);
|
||||
showInfoAction->setData(SHOW_INFO_ACTION_Y);
|
||||
showInfoAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(SHOW_INFO_ACTION_Y));
|
||||
connect(showInfoAction, SIGNAL(triggered()),viewer,SLOT(informationSwitch()));
|
||||
|
||||
closeAction = new QAction(tr("Close"),this);
|
||||
closeAction->setShortcut(Qt::Key_Escape);
|
||||
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()));
|
||||
|
||||
showDictionaryAction = new QAction(tr("Show Dictionary"),this);
|
||||
showDictionaryAction->setShortcut(Qt::Key_T);
|
||||
showDictionaryAction->setIcon(QIcon(":/images/viewer_toolbar/translator.png"));
|
||||
//showDictionaryAction->setCheckable(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()));
|
||||
|
||||
//deprecated
|
||||
alwaysOnTopAction = new QAction(tr("Always on top"),this);
|
||||
alwaysOnTopAction->setShortcut(Qt::Key_Q);
|
||||
alwaysOnTopAction->setIcon(QIcon(":/images/alwaysOnTop.png"));
|
||||
alwaysOnTopAction->setCheckable(true);
|
||||
alwaysOnTopAction->setDisabled(true);
|
||||
alwaysOnTopAction->setChecked(Configuration::getConfiguration().getAlwaysOnTop());
|
||||
alwaysOnTopAction->setData(ALWAYS_ON_TOP_ACTION_Y);
|
||||
alwaysOnTopAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ALWAYS_ON_TOP_ACTION_Y));
|
||||
connect(alwaysOnTopAction,SIGNAL(triggered()),this,SLOT(alwaysOnTopSwitch()));
|
||||
|
||||
adjustToFullSizeAction = new QAction(tr("Show full size"),this);
|
||||
adjustToFullSizeAction->setShortcut(Qt::Key_W);
|
||||
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
|
||||
adjustToFullSizeAction->setCheckable(true);
|
||||
adjustToFullSizeAction->setDisabled(true);
|
||||
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()));
|
||||
|
||||
showFlowAction = new QAction(tr("Show go to flow"),this);
|
||||
showFlowAction->setShortcut(Qt::Key_S);
|
||||
showFlowAction->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
||||
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()));
|
||||
|
||||
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()
|
||||
@ -399,7 +440,7 @@ void MainWindowViewer::createToolBars()
|
||||
#endif
|
||||
comicToolBar->addAction(prevAction);
|
||||
comicToolBar->addAction(nextAction);
|
||||
comicToolBar->addAction(goToPage);
|
||||
comicToolBar->addAction(goToPageAction);
|
||||
|
||||
//#ifndef Q_OS_MAC
|
||||
// comicToolBar->addSeparator();
|
||||
@ -440,7 +481,7 @@ void MainWindowViewer::createToolBars()
|
||||
);
|
||||
menu->addAction(sliderAction);
|
||||
QToolButton * tb2 = new QToolButton();
|
||||
tb2->addAction(adjustWidth);
|
||||
tb2->addAction(adjustWidthAction);
|
||||
tb2->setMenu(menu);
|
||||
|
||||
connect(sliderAction,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
||||
@ -449,9 +490,9 @@ void MainWindowViewer::createToolBars()
|
||||
|
||||
//tb2->addAction();
|
||||
tb2->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
tb2->setDefaultAction(adjustWidth);
|
||||
tb2->setDefaultAction(adjustWidthAction);
|
||||
comicToolBar->addWidget(tb2);
|
||||
comicToolBar->addAction(adjustHeight);
|
||||
comicToolBar->addAction(adjustHeightAction);
|
||||
comicToolBar->addAction(adjustToFullSizeAction);
|
||||
comicToolBar->addAction(leftRotationAction);
|
||||
comicToolBar->addAction(rightRotationAction);
|
||||
@ -462,15 +503,15 @@ void MainWindowViewer::createToolBars()
|
||||
#else
|
||||
comicToolBar->addSeparator();
|
||||
#endif
|
||||
comicToolBar->addAction(showMagnifyingGlass);
|
||||
comicToolBar->addAction(showMagnifyingGlassAction);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
#else
|
||||
comicToolBar->addSeparator();
|
||||
#endif
|
||||
comicToolBar->addAction(setBookmark);
|
||||
comicToolBar->addAction(showBookmarks);
|
||||
comicToolBar->addAction(setBookmarkAction);
|
||||
comicToolBar->addAction(showBookmarksAction);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
@ -479,7 +520,7 @@ void MainWindowViewer::createToolBars()
|
||||
#endif
|
||||
comicToolBar->addAction(showDictionaryAction);
|
||||
comicToolBar->addAction(showFlowAction);
|
||||
comicToolBar->addAction(showInfo);
|
||||
comicToolBar->addAction(showInfoAction);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
comicToolBar->addWidget(new MacToolBarSeparator);
|
||||
@ -505,28 +546,29 @@ void MainWindowViewer::createToolBars()
|
||||
|
||||
viewer->addAction(prevAction);
|
||||
viewer->addAction(nextAction);
|
||||
viewer->addAction(goToPage);
|
||||
viewer->addAction(adjustHeight);
|
||||
viewer->addAction(adjustWidth);
|
||||
viewer->addAction(goToPageAction);
|
||||
viewer->addAction(adjustHeightAction);
|
||||
viewer->addAction(adjustWidthAction);
|
||||
viewer->addAction(adjustToFullSizeAction);
|
||||
viewer->addAction(leftRotationAction);
|
||||
viewer->addAction(rightRotationAction);
|
||||
viewer->addAction(doublePageAction);
|
||||
YACReader::addSperator(viewer);
|
||||
|
||||
viewer->addAction(showMagnifyingGlass);
|
||||
viewer->addAction(showMagnifyingGlassAction);
|
||||
YACReader::addSperator(viewer);
|
||||
|
||||
viewer->addAction(setBookmark);
|
||||
viewer->addAction(showBookmarks);
|
||||
viewer->addAction(setBookmarkAction);
|
||||
viewer->addAction(showBookmarksAction);
|
||||
YACReader::addSperator(viewer);
|
||||
|
||||
viewer->addAction(showDictionaryAction);
|
||||
viewer->addAction(showFlowAction);
|
||||
viewer->addAction(showInfo);
|
||||
viewer->addAction(showInfoAction);
|
||||
YACReader::addSperator(viewer);
|
||||
|
||||
viewer->addAction(showShorcutsAction);
|
||||
viewer->addAction(showEditShortcutsAction);
|
||||
viewer->addAction(optionsAction);
|
||||
viewer->addAction(helpAboutAction);
|
||||
YACReader::addSperator(viewer);
|
||||
@ -728,18 +770,18 @@ void MainWindowViewer::enableActions()
|
||||
saveImageAction->setDisabled(false);
|
||||
prevAction->setDisabled(false);
|
||||
nextAction->setDisabled(false);
|
||||
adjustHeight->setDisabled(false);
|
||||
adjustWidth->setDisabled(false);
|
||||
goToPage->setDisabled(false);
|
||||
adjustHeightAction->setDisabled(false);
|
||||
adjustWidthAction->setDisabled(false);
|
||||
goToPageAction->setDisabled(false);
|
||||
//alwaysOnTopAction->setDisabled(false);
|
||||
leftRotationAction->setDisabled(false);
|
||||
rightRotationAction->setDisabled(false);
|
||||
showMagnifyingGlass->setDisabled(false);
|
||||
showMagnifyingGlassAction->setDisabled(false);
|
||||
doublePageAction->setDisabled(false);
|
||||
adjustToFullSizeAction->setDisabled(false);
|
||||
//setBookmark->setDisabled(false);
|
||||
showBookmarks->setDisabled(false);
|
||||
showInfo->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
showBookmarksAction->setDisabled(false);
|
||||
showInfoAction->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
showDictionaryAction->setDisabled(false);
|
||||
showFlowAction->setDisabled(false);
|
||||
}
|
||||
@ -748,18 +790,18 @@ void MainWindowViewer::disableActions()
|
||||
saveImageAction->setDisabled(true);
|
||||
prevAction->setDisabled(true);
|
||||
nextAction->setDisabled(true);
|
||||
adjustHeight->setDisabled(true);
|
||||
adjustWidth->setDisabled(true);
|
||||
goToPage->setDisabled(true);
|
||||
adjustHeightAction->setDisabled(true);
|
||||
adjustWidthAction->setDisabled(true);
|
||||
goToPageAction->setDisabled(true);
|
||||
//alwaysOnTopAction->setDisabled(true);
|
||||
leftRotationAction->setDisabled(true);
|
||||
rightRotationAction->setDisabled(true);
|
||||
showMagnifyingGlass->setDisabled(true);
|
||||
showMagnifyingGlassAction->setDisabled(true);
|
||||
doublePageAction->setDisabled(true);
|
||||
adjustToFullSizeAction->setDisabled(true);
|
||||
setBookmark->setDisabled(true);
|
||||
showBookmarks->setDisabled(true);
|
||||
showInfo->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
setBookmarkAction->setDisabled(true);
|
||||
showBookmarksAction->setDisabled(true);
|
||||
showInfoAction->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
openPreviousComicAction->setDisabled(true);
|
||||
openNextComicAction->setDisabled(true);
|
||||
showDictionaryAction->setDisabled(true);
|
||||
@ -768,28 +810,38 @@ void MainWindowViewer::disableActions()
|
||||
|
||||
void MainWindowViewer::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
//TODO remove unused keys
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Escape:
|
||||
this->close();
|
||||
break;
|
||||
case Qt::Key_F:
|
||||
toggleFullScreen();
|
||||
break;
|
||||
case Qt::Key_H:
|
||||
toggleToolBars();
|
||||
break;
|
||||
case Qt::Key_O:
|
||||
open();
|
||||
break;
|
||||
case Qt::Key_A:
|
||||
changeFit();
|
||||
break;
|
||||
default:
|
||||
QWidget::keyPressEvent(event);
|
||||
break;
|
||||
}
|
||||
//TODO remove unused keys
|
||||
int _key = event->key();
|
||||
Qt::KeyboardModifiers modifiers = event->modifiers();
|
||||
|
||||
if(modifiers & Qt::ShiftModifier)
|
||||
_key |= Qt::SHIFT;
|
||||
if (modifiers & Qt::ControlModifier)
|
||||
_key |= Qt::CTRL;
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
_key |= Qt::META;
|
||||
if (modifiers & Qt::AltModifier)
|
||||
_key |= Qt::ALT;
|
||||
|
||||
QKeySequence key(_key);
|
||||
|
||||
if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_FULL_SCREEN_ACTION_Y))
|
||||
{
|
||||
toggleFullScreen();
|
||||
event->accept();
|
||||
}
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(TOGGLE_TOOL_BARS_ACTION_Y))
|
||||
{
|
||||
toggleToolBars();
|
||||
event->accept();
|
||||
}
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y))
|
||||
{
|
||||
changeFit();
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void MainWindowViewer::mouseDoubleClickEvent ( QMouseEvent * event )
|
||||
@ -888,7 +940,7 @@ void MainWindowViewer::checkNewVersion()
|
||||
QTimer * tT = new QTimer;
|
||||
tT->setSingleShot(true);
|
||||
connect(tT, SIGNAL(timeout()), versionChecker, SLOT(get()));
|
||||
//versionChecker->get(); //TODÓ
|
||||
//versionChecker->get(); //TOD<EFBFBD>
|
||||
tT->start(100);
|
||||
|
||||
conf.setLastVersionCheck(current);
|
||||
@ -914,6 +966,147 @@ void MainWindowViewer::processReset()
|
||||
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()
|
||||
{
|
||||
Configuration & conf = Configuration::getConfiguration();
|
||||
|
@ -18,6 +18,7 @@ class HelpAboutDialog;
|
||||
class HttpVersionChecker;
|
||||
class ShortcutsDialog;
|
||||
class YACReaderSliderAction;
|
||||
class EditShortcutsDialog;
|
||||
|
||||
class MainWindowViewer : public QMainWindow
|
||||
{
|
||||
@ -52,6 +53,7 @@ class YACReaderSliderAction;
|
||||
void fitToHeight();
|
||||
void checkNewVersion();
|
||||
void processReset();
|
||||
void setUpShortcutsManagement();
|
||||
/*void viewComic();
|
||||
void prev();
|
||||
void next();
|
||||
@ -72,6 +74,7 @@ class YACReaderSliderAction;
|
||||
OptionsDialog * optionsDialog;
|
||||
HelpAboutDialog * had;
|
||||
ShortcutsDialog * shortcutsDialog;
|
||||
EditShortcutsDialog * editShortcutsDialog;
|
||||
|
||||
//! ToolBars
|
||||
QToolBar *comicToolBar;
|
||||
@ -84,17 +87,17 @@ class YACReaderSliderAction;
|
||||
QAction *openNextComicAction;
|
||||
QAction *nextAction;
|
||||
QAction *prevAction;
|
||||
QAction *adjustWidth;
|
||||
QAction *adjustHeight;
|
||||
QAction *goToPage;
|
||||
QAction *adjustWidthAction;
|
||||
QAction *adjustHeightAction;
|
||||
QAction *goToPageAction;
|
||||
QAction *optionsAction;
|
||||
QAction *helpAboutAction;
|
||||
QAction *showMagnifyingGlass;
|
||||
QAction *setBookmark;
|
||||
QAction *showBookmarks;
|
||||
QAction *showMagnifyingGlassAction;
|
||||
QAction *setBookmarkAction;
|
||||
QAction *showBookmarksAction;
|
||||
QAction *leftRotationAction;
|
||||
QAction *rightRotationAction;
|
||||
QAction *showInfo;
|
||||
QAction *showInfoAction;
|
||||
QAction *closeAction;
|
||||
QAction *doublePageAction;
|
||||
QAction *showShorcutsAction;
|
||||
@ -103,6 +106,8 @@ class YACReaderSliderAction;
|
||||
QAction *adjustToFullSizeAction;
|
||||
QAction *showFlowAction;
|
||||
|
||||
QAction *showEditShortcutsAction;
|
||||
|
||||
YACReaderSliderAction * sliderAction;
|
||||
|
||||
HttpVersionChecker * versionChecker;
|
||||
@ -115,8 +120,8 @@ class YACReaderSliderAction;
|
||||
void getSiblingComics(QString path,QString currentComic);
|
||||
|
||||
//! Manejadores de evento:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
//void resizeEvent(QResizeEvent * event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
//void resizeEvent(QResizeEvent * event);
|
||||
void mouseDoubleClickEvent ( QMouseEvent * event );
|
||||
void dropEvent(QDropEvent *event);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
|
@ -113,6 +113,7 @@ OptionsDialog::OptionsDialog(QWidget * parent)
|
||||
layoutGeneral->addWidget(slideSizeBox);
|
||||
layoutGeneral->addWidget(fitBox);
|
||||
layoutGeneral->addWidget(colorBox);
|
||||
layoutGeneral->addWidget(shortcutsBox);
|
||||
layoutGeneral->addStretch();
|
||||
layoutFlow->addWidget(sw);
|
||||
layoutFlow->addWidget(gl);
|
||||
|
@ -51,7 +51,7 @@ ShortcutsDialog::ShortcutsDialog(QWidget * parent)
|
||||
|
||||
setLayout(imgMainLayout);
|
||||
|
||||
setFixedSize(QSize(700,500));
|
||||
setFixedSize(QSize(700,500));
|
||||
|
||||
QFile f(":/files/shortcuts.html");
|
||||
f.open(QIODevice::ReadOnly);
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "page_label_widget.h"
|
||||
#include "notifications_label_widget.h"
|
||||
#include "comic_db.h"
|
||||
#include "shortcuts_manager.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
|
||||
@ -367,62 +369,72 @@ void Viewer::scrollUp()
|
||||
|
||||
void Viewer::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if(render->hasLoadedComic())
|
||||
{
|
||||
if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
|
||||
QCoreApplication::sendEvent(goToFlow,event);
|
||||
else
|
||||
switch (event->key())
|
||||
{
|
||||
case Qt::Key_Space:
|
||||
posByStep = height()/numScrollSteps;
|
||||
nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80));
|
||||
scrollDown();
|
||||
break;
|
||||
case Qt::Key_B:
|
||||
posByStep = height()/numScrollSteps;
|
||||
nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80));
|
||||
scrollUp();
|
||||
break;
|
||||
case Qt::Key_S:
|
||||
goToFlowSwitch();
|
||||
break;
|
||||
case Qt::Key_T:
|
||||
translatorSwitch();
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
/*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->maximum())
|
||||
next();
|
||||
else*/
|
||||
QAbstractScrollArea::keyPressEvent(event);
|
||||
emit backgroundChanges();
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
/*if(verticalScrollBar()->sliderPosition()==verticalScrollBar()->minimum())
|
||||
prev();
|
||||
else*/
|
||||
QAbstractScrollArea::keyPressEvent(event);
|
||||
emit backgroundChanges();
|
||||
break;
|
||||
case Qt::Key_Home:
|
||||
goTo(0);
|
||||
break;
|
||||
case Qt::Key_End:
|
||||
goTo(this->render->numPages()-1);
|
||||
break;
|
||||
default:
|
||||
QAbstractScrollArea::keyPressEvent(event);
|
||||
break;
|
||||
}
|
||||
if(mglass->isVisible())
|
||||
switch(event->key())
|
||||
{
|
||||
case Qt::Key_Plus: case Qt::Key_Minus: case Qt::Key_Underscore: case Qt::Key_Asterisk:
|
||||
QCoreApplication::sendEvent(mglass,event);
|
||||
}
|
||||
}
|
||||
else
|
||||
QAbstractScrollArea::keyPressEvent(event);
|
||||
if(render->hasLoadedComic())
|
||||
{
|
||||
int _key = event->key();
|
||||
Qt::KeyboardModifiers modifiers = event->modifiers();
|
||||
|
||||
if(modifiers & Qt::ShiftModifier)
|
||||
_key |= Qt::SHIFT;
|
||||
if (modifiers & Qt::ControlModifier)
|
||||
_key |= Qt::CTRL;
|
||||
if (modifiers & Qt::MetaModifier)
|
||||
_key |= Qt::META;
|
||||
if (modifiers & Qt::AltModifier)
|
||||
_key |= Qt::ALT;
|
||||
|
||||
QKeySequence key(_key);
|
||||
/*if(goToFlow->isVisible() && event->key()!=Qt::Key_S)
|
||||
QCoreApplication::sendEvent(goToFlow,event);
|
||||
else*/
|
||||
|
||||
if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_FORWARD_ACTION_Y))
|
||||
{
|
||||
posByStep = height()/numScrollSteps;
|
||||
nextPos=verticalScrollBar()->sliderPosition()+static_cast<int>((height()*0.80));
|
||||
scrollDown();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(AUTO_SCROLL_BACKWARD_ACTION_Y))
|
||||
{
|
||||
posByStep = height()/numScrollSteps;
|
||||
nextPos=verticalScrollBar()->sliderPosition()-static_cast<int>((height()*0.80));
|
||||
scrollUp();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_DOWN_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_UP_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_LEFT_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(MOVE_RIGHT_ACTION_Y))
|
||||
{
|
||||
QAbstractScrollArea::keyPressEvent(event);
|
||||
emit backgroundChanges();
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_FIRST_PAGE_ACTION_Y))
|
||||
{
|
||||
goTo(0);
|
||||
}
|
||||
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(GO_TO_LAST_PAGE_ACTION_Y))
|
||||
{
|
||||
goTo(this->render->numPages()-1);
|
||||
}
|
||||
|
||||
else
|
||||
QAbstractScrollArea::keyPressEvent(event);
|
||||
|
||||
if(mglass->isVisible() && (key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_UP_MGLASS_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(SIZE_DOWN_MGLASS_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_IN_MGLASS_ACTION_Y) ||
|
||||
key == ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_OUT_MGLASS_ACTION_Y)))
|
||||
{
|
||||
QCoreApplication::sendEvent(mglass,event);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
QAbstractScrollArea::keyPressEvent(event);
|
||||
}
|
||||
|
||||
void Viewer::wheelEvent(QWheelEvent * event)
|
||||
|
@ -73,5 +73,15 @@
|
||||
<file>../images/dropDownArrow.png</file>
|
||||
<file>../images/translatorSearch.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>
|
||||
</RCC>
|
||||
|
@ -8,5 +8,5 @@ Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
Categories=Graphics;Viewer;
|
||||
MimeType=application/x-cbz;application/x-cbr;application/x-cbt;application/x-cb7;
|
||||
MimeType=
|
||||
X-Desktop-File-Install-Version=0.22
|
||||
|
@ -13,7 +13,7 @@ INCLUDEPATH += ../common \
|
||||
./comic_vine \
|
||||
./comic_vine/model
|
||||
|
||||
DEFINES += SERVER_RELEASE NOMINMAX
|
||||
DEFINES += SERVER_RELEASE NOMINMAX YACREADER_LIBRARY
|
||||
|
||||
win32 {
|
||||
|
||||
@ -34,7 +34,6 @@ CONFIG -= embed_manifest_exe
|
||||
}
|
||||
|
||||
unix:!macx{
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
|
||||
isEqual(QT_MAJOR_VERSION, 5) {
|
||||
INCLUDEPATH += /usr/include/poppler/qt5
|
||||
@ -67,6 +66,10 @@ CONFIG += objective_c
|
||||
|
||||
}
|
||||
|
||||
unix{
|
||||
QMAKE_CXXFLAGS += -std=c++11
|
||||
}
|
||||
|
||||
#CONFIG += release
|
||||
CONFIG -= flat
|
||||
QT += sql network opengl script
|
||||
@ -113,6 +116,10 @@ HEADERS += comic_flow.h \
|
||||
../common/http_worker.h \
|
||||
yacreader_libraries.h \
|
||||
../common/exit_check.h \
|
||||
comics_view.h \
|
||||
classic_comics_view.h \
|
||||
empty_folder_widget.h
|
||||
|
||||
|
||||
SOURCES += comic_flow.cpp \
|
||||
create_library_dialog.cpp \
|
||||
@ -156,6 +163,10 @@ SOURCES += comic_flow.cpp \
|
||||
../common/yacreader_global.cpp \
|
||||
yacreader_libraries.cpp \
|
||||
../common/exit_check.cpp \
|
||||
comics_view.cpp \
|
||||
classic_comics_view.cpp \
|
||||
empty_folder_widget.cpp
|
||||
|
||||
|
||||
|
||||
include(./server/server.pri)
|
||||
@ -163,6 +174,7 @@ include(../custom_widgets/custom_widgets_yacreaderlibrary.pri)
|
||||
include(../compressed_archive/wrapper.pri)
|
||||
include(./comic_vine/comic_vine.pri)
|
||||
include(../QsLog/QsLog.pri)
|
||||
include(../shortcuts_management/shortcuts_management.pri)
|
||||
|
||||
RESOURCES += images.qrc files.qrc
|
||||
win32:RESOURCES += images_win.qrc
|
||||
@ -187,6 +199,21 @@ TRANSLATIONS = yacreaderlibrary_es.ts \
|
||||
isEqual(QT_MAJOR_VERSION, 5) {
|
||||
Release:DESTDIR = ../release5
|
||||
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 {
|
||||
Release:DESTDIR = ../release
|
||||
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();
|
||||
|
||||
QSqlQuery query("INSERT INTO db_info (version) "
|
||||
"VALUES ('"VERSION"')",database);
|
||||
"VALUES ('" VERSION "')",database);
|
||||
//query.finish();
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ void DataBaseManagement::exportComicsInfo(QString source, QString dest)
|
||||
queryComicsInfo.exec();*/
|
||||
|
||||
QSqlQuery query("INSERT INTO dest.db_info (version) "
|
||||
"VALUES ('"VERSION"')",destDB);
|
||||
"VALUES ('" VERSION "')",destDB);
|
||||
//query.finish();
|
||||
|
||||
QSqlQuery exportData(destDB);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
TableModel::TableModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
connect(this,SIGNAL(beforeReset()),this,SIGNAL(modelAboutToBeReset()));
|
||||
connect(this,SIGNAL(reset()),this,SIGNAL(modelReset()));
|
||||
@ -23,7 +23,7 @@ TableModel::TableModel(QObject *parent)
|
||||
|
||||
//! [0]
|
||||
TableModel::TableModel( QSqlQuery &sqlquery, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
setupModelData(sqlquery);
|
||||
}
|
||||
@ -46,6 +46,27 @@ int TableModel::columnCount(const QModelIndex &parent) const
|
||||
}
|
||||
//! [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]
|
||||
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
|
||||
//these roles will be used from QML/GridView
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
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)
|
||||
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)
|
||||
@ -265,7 +304,9 @@ void TableModel::setupModelData(unsigned long long int folderId,const QString &
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(_databasePath);
|
||||
endResetModel();
|
||||
//f.close();
|
||||
|
||||
if(_data.length()==0)
|
||||
emit isEmpty();
|
||||
}
|
||||
|
||||
QString TableModel::getComicPath(QModelIndex mi)
|
||||
@ -467,7 +508,7 @@ QVector<YACReaderComicReadStatus> TableModel::setComicsRead(QList<QModelIndex> l
|
||||
db.close();
|
||||
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();
|
||||
}
|
||||
@ -553,10 +594,10 @@ void TableModel::remove(ComicDB * comic, int row)
|
||||
endRemoveRows();
|
||||
}
|
||||
|
||||
ComicDB TableModel::getComic(int row)
|
||||
/*ComicDB TableModel::getComic(int row)
|
||||
{
|
||||
return getComic(index(row,0));
|
||||
}
|
||||
}*/
|
||||
|
||||
void TableModel::remove(int row)
|
||||
{
|
||||
@ -580,8 +621,8 @@ void TableModel::reload(const ComicDB & comic)
|
||||
}
|
||||
row++;
|
||||
}
|
||||
if(found)
|
||||
emit dataChanged(index(row,TableModel::CurrentPage),index(row,TableModel::CurrentPage));
|
||||
if(found)
|
||||
emit dataChanged(index(row,ReadColumn),index(row,HasBeenOpened), QVector<int>() << ReadColumnRole << CurrentPageRole << HasBeenOpenedRole);
|
||||
}
|
||||
|
||||
void TableModel::resetComicRating(const QModelIndex &mi)
|
||||
@ -600,27 +641,6 @@ void TableModel::resetComicRating(const QModelIndex &mi)
|
||||
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)
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
TableModel(QObject *parent = 0);
|
||||
TableModel( QSqlQuery &sqlquery, QObject *parent = 0);
|
||||
~TableModel();
|
||||
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
@ -39,8 +39,9 @@ public:
|
||||
//Métodos de conveniencia
|
||||
QStringList getPaths(const QString & _source);
|
||||
QString getComicPath(QModelIndex mi);
|
||||
QString getCurrentPath(){return QString(_databasePath).remove("/.yacreaderlibrary");};
|
||||
ComicDB getComic(const QModelIndex & mi); //--> para la edición
|
||||
ComicDB getComic(int row);
|
||||
//ComicDB getComic(int row);
|
||||
QVector<YACReaderComicReadStatus> getReadList();
|
||||
QVector<YACReaderComicReadStatus> setAllComicsRead(YACReaderComicReadStatus readStatus);
|
||||
QList<ComicDB> getComics(QList<QModelIndex> list); //--> recupera la información común a los comics seleccionados
|
||||
@ -56,7 +57,7 @@ public:
|
||||
void reload(const ComicDB & comic);
|
||||
void resetComicRating(const QModelIndex & mi);
|
||||
|
||||
QHash<int, QByteArray> roleNames();
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
enum Columns {
|
||||
Number = 0,
|
||||
@ -98,6 +99,8 @@ public slots:
|
||||
void finishTransaction();
|
||||
void updateRating(int rating, QModelIndex mi);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
void setupModelData( QSqlQuery &sqlquery);
|
||||
ComicDB _getComic(const QModelIndex & mi);
|
||||
@ -110,6 +113,7 @@ private:
|
||||
signals:
|
||||
void beforeReset();
|
||||
void reset();
|
||||
void isEmpty();
|
||||
};
|
||||
//! [0]
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "data_base_management.h"
|
||||
#include "folder.h"
|
||||
#include "db_helper.h"
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
#include <QFileIconProvider>
|
||||
@ -106,7 +107,7 @@ TreeModel::TreeModel(QObject *parent)
|
||||
TreeModel::TreeModel( QSqlQuery &sqlquery, QObject *parent)
|
||||
: QAbstractItemModel(parent),rootItem(0),rootBeforeFilter(0),filterEnabled(false),includeComics(false)
|
||||
{
|
||||
//lo más probable es que el nodo raíz no necesite tener información
|
||||
//lo m<EFBFBD>s probable es que el nodo ra<72>z no necesite tener informaci<63>n
|
||||
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)
|
||||
rootItem = new TreeItem(rootData);
|
||||
@ -265,7 +266,7 @@ void TreeModel::setupModelData(QString path)
|
||||
filterEnabled = false;
|
||||
rootItem = 0;
|
||||
rootBeforeFilter = 0;
|
||||
//inicializar el nodo raíz
|
||||
//inicializar el nodo ra<EFBFBD>z
|
||||
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)
|
||||
rootItem = new TreeItem(rootData);
|
||||
@ -291,10 +292,10 @@ void TreeModel::setupModelData(QString path)
|
||||
|
||||
void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
{
|
||||
//64 bits para la primary key, es decir la misma precisión que soporta sqlit 2^64
|
||||
//el diccionario permitirá encontrar cualquier nodo del árbol rápidamente, de forma que añadir un hijo a un padre sea O(1)
|
||||
//64 bits para la primary key, es decir la misma precisi<EFBFBD>n que soporta sqlit 2^64
|
||||
//el diccionario permitir<EFBFBD> encontrar cualquier nodo del <20>rbol r<>pidamente, de forma que a<>adir un hijo a un padre sea O(1)
|
||||
items.clear();
|
||||
//se añade el nodo 0
|
||||
//se a<EFBFBD>ade el nodo 0
|
||||
items.insert(parent->id,parent);
|
||||
|
||||
while (sqlquery.next()) {
|
||||
@ -308,11 +309,11 @@ void TreeModel::setupModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
TreeItem * item = new TreeItem(data);
|
||||
|
||||
item->id = record.value("id").toULongLong();
|
||||
//la inserción de hijos se hace de forma ordenada
|
||||
//la inserci<EFBFBD>n de hijos se hace de forma ordenada
|
||||
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.
|
||||
parent->appendChild(item);
|
||||
//se añade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||
//se a<EFBFBD>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||
items.insert(item->id,item);
|
||||
}
|
||||
}
|
||||
@ -323,12 +324,12 @@ void TreeModel::setupFilteredModelData()
|
||||
|
||||
//TODO hay que liberar memoria de anteriores filtrados
|
||||
|
||||
//inicializar el nodo raíz
|
||||
//inicializar el nodo ra<EFBFBD>z
|
||||
|
||||
if(rootBeforeFilter == 0)
|
||||
rootBeforeFilter = rootItem;
|
||||
else
|
||||
delete rootItem;//los resultados de la búsqueda anterior deben ser borrados
|
||||
delete rootItem;//los resultados de la b<EFBFBD>squeda anterior deben ser borrados
|
||||
|
||||
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)
|
||||
@ -365,10 +366,10 @@ void TreeModel::setupFilteredModelData()
|
||||
|
||||
void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
{
|
||||
//64 bits para la primary key, es decir la misma precisión que soporta sqlit 2^64
|
||||
//64 bits para la primary key, es decir la misma precisi<EFBFBD>n que soporta sqlit 2^64
|
||||
filteredItems.clear();
|
||||
|
||||
//se añade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro
|
||||
//se a<EFBFBD>ade el nodo 0 al modelo que representa el arbol de elementos que cumplen con el filtro
|
||||
filteredItems.insert(parent->id,parent);
|
||||
|
||||
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
|
||||
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<EFBFBD>ade el item al map, de forma que se pueda encontrar como padre en siguientes iteraciones
|
||||
if(!filteredItems.contains(item->id))
|
||||
filteredItems.insert(item->id,item);
|
||||
|
||||
//es necesario conocer las coordenadas de origen para poder realizar scroll automático en la vista
|
||||
//es necesario conocer las coordenadas de origen para poder realizar scroll autom<EFBFBD>tico en la vista
|
||||
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<EFBFBD>ade como hijo
|
||||
if(filteredItems.contains(parentId))
|
||||
filteredItems.value(parentId)->appendChild(item);
|
||||
else//si el padre aún no se ha añadido, hay que añadirlo a él y todos los padres hasta el nodo raíz
|
||||
else//si el padre a<EFBFBD>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 último de los padres (antes del nodo raíz) ya existía en el modelo
|
||||
//comprobamos con esta variable si el <EFBFBD>ltimo de los padres (antes del nodo ra<72>z) ya exist<73>a en el modelo
|
||||
bool parentPreviousInserted = false;
|
||||
|
||||
//mientras no se alcance el nodo raíz se procesan todos los padres (de abajo a arriba)
|
||||
//mientras no se alcance el nodo ra<EFBFBD>z se procesan todos los padres (de abajo a arriba)
|
||||
while(parentId != ROOT )
|
||||
{
|
||||
//el padre no estaba en el modelo filtrado, así que se rescata del modelo original
|
||||
//el padre no estaba en el modelo filtrado, as<EFBFBD> que se rescata del modelo original
|
||||
TreeItem * parentItem = items.value(parentId);
|
||||
//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á a la estructura de directorios filtrados
|
||||
TreeItem * newparentItem = new TreeItem(parentItem->getData()); //padre que se a<EFBFBD>adir<EFBFBD> a la estructura de directorios filtrados
|
||||
newparentItem->id = parentId;
|
||||
|
||||
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<EFBFBD>ade el item actual como hijo
|
||||
if(filteredItems.contains(parentId))
|
||||
{
|
||||
filteredItems.value(parentId)->appendChild(item);
|
||||
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<EFBFBD>ade el item actual como hijo
|
||||
else
|
||||
{
|
||||
newparentItem->appendChild(item);
|
||||
@ -432,7 +433,7 @@ void TreeModel::setupFilteredModelData(QSqlQuery &sqlquery, TreeItem *parent)
|
||||
parentId = parentItem->parentItem->id;
|
||||
}
|
||||
|
||||
//si el nodo es hijo de 1 y no había sido previamente insertado como hijo, se añade como tal
|
||||
//si el nodo es hijo de 1 y no hab<EFBFBD>a sido previamente insertado como hijo, se a<>ade como tal
|
||||
if(!parentPreviousInserted)
|
||||
filteredItems.value(ROOT)->appendChild(item);
|
||||
}
|
||||
@ -468,7 +469,7 @@ void TreeModel::resetFilter()
|
||||
//items.clear();
|
||||
filteredItems.clear();
|
||||
TreeItem * root = rootItem;
|
||||
rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidaría en modelo
|
||||
rootItem = rootBeforeFilter; //TODO si no se aplica el filtro previamente, esto invalidar<EFBFBD>a en modelo
|
||||
if(root !=0)
|
||||
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));
|
||||
}
|
||||
|
||||
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 updateFolderFinishedStatus(const QModelIndexList & list, bool status);
|
||||
|
||||
QStringList getSubfoldersNames(const QModelIndex & mi);
|
||||
|
||||
enum Columns {
|
||||
Name = 0,
|
||||
Path = 1,
|
||||
|
@ -31,9 +31,9 @@ YACReaderLibraries DBHelper::getLibraries()
|
||||
libraries.load();
|
||||
return libraries;
|
||||
}
|
||||
QList<LibraryItem *> DBHelper::getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId)
|
||||
QList<LibraryItem *> DBHelper::getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
QList<LibraryItem *> list = DBHelper::getFoldersFromParent(folderId,db,false);
|
||||
@ -42,9 +42,9 @@ QList<LibraryItem *> DBHelper::getFolderContentFromLibrary(const QString & libra
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
return list;
|
||||
}
|
||||
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId)
|
||||
QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
QList<LibraryItem *> list = DBHelper::getComicsFromParent(folderId,db,false);
|
||||
@ -53,9 +53,9 @@ QList<LibraryItem *> DBHelper::getFolderComicsFromLibrary(const QString & librar
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
return list;
|
||||
}
|
||||
qulonglong DBHelper::getParentFromComicFolderId(const QString & libraryName, qulonglong id)
|
||||
qulonglong DBHelper::getParentFromComicFolderId(qulonglong libraryId, qulonglong id)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
Folder f = DBHelper::loadFolder(id,db);
|
||||
@ -64,9 +64,9 @@ qulonglong DBHelper::getParentFromComicFolderId(const QString & libraryName, qul
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
return f.parentId;
|
||||
}
|
||||
ComicDB DBHelper::getComicInfo(const QString & libraryName, qulonglong id)
|
||||
ComicDB DBHelper::getComicInfo(qulonglong libraryId, qulonglong id)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
ComicDB comic = DBHelper::loadComic(id,db);
|
||||
@ -76,9 +76,9 @@ ComicDB DBHelper::getComicInfo(const QString & libraryName, qulonglong id)
|
||||
return comic;
|
||||
}
|
||||
|
||||
QList<ComicDB> DBHelper::getSiblings(const QString & libraryName, qulonglong parentId)
|
||||
QList<ComicDB> DBHelper::getSiblings(qulonglong libraryId, qulonglong parentId)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
QList<ComicDB> comics = DBHelper::getSortedComicsFromParent(parentId,db);
|
||||
@ -87,9 +87,9 @@ QList<ComicDB> DBHelper::getSiblings(const QString & libraryName, qulonglong par
|
||||
return comics;
|
||||
}
|
||||
|
||||
QString DBHelper::getFolderName(const QString & libraryName, qulonglong id)
|
||||
QString DBHelper::getFolderName(qulonglong libraryId, qulonglong id)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
QString name="";
|
||||
@ -153,9 +153,9 @@ void DBHelper::update(ComicDB * comic, QSqlDatabase & db)
|
||||
//do nothing
|
||||
}
|
||||
|
||||
void DBHelper::update(const QString & libraryName, ComicInfo & comicInfo)
|
||||
void DBHelper::update(qulonglong libraryId, ComicInfo & comicInfo)
|
||||
{
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryName);
|
||||
QString libraryPath = DBHelper::getLibraries().getPath(libraryId);
|
||||
QSqlDatabase db = DataBaseManagement::loadDatabase(libraryPath+"/.yacreaderlibrary");
|
||||
|
||||
DBHelper::update(&comicInfo,db);
|
||||
@ -254,6 +254,7 @@ void DBHelper::update(ComicInfo * comicInfo, QSqlDatabase & db)
|
||||
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)
|
||||
comicInfo->read = read;
|
||||
updateComicInfo.bindValue(":read", read?1:0);
|
||||
updateComicInfo.bindValue(":id", comicInfo->id);
|
||||
updateComicInfo.bindValue(":edited", comicInfo->edited?1:0);
|
||||
@ -312,6 +313,7 @@ void DBHelper::updateProgress(qulonglong libraryId, const ComicInfo &comicInfo)
|
||||
db.close();
|
||||
QSqlDatabase::removeDatabase(libraryPath);
|
||||
}
|
||||
|
||||
//inserts
|
||||
qulonglong DBHelper::insert(Folder * folder, QSqlDatabase & db)
|
||||
{
|
||||
@ -686,5 +688,18 @@ ComicInfo DBHelper::loadComicInfo(QString hash, QSqlDatabase & db)
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ class DBHelper
|
||||
public:
|
||||
//server
|
||||
static YACReaderLibraries getLibraries();
|
||||
static QList<LibraryItem *> getFolderContentFromLibrary(const QString & libraryName, qulonglong folderId);
|
||||
static QList<LibraryItem *> getFolderComicsFromLibrary(const QString & libraryName, qulonglong folderId);
|
||||
static qulonglong getParentFromComicFolderId(const QString & libraryName, qulonglong id);
|
||||
static ComicDB getComicInfo(const QString & libraryName, qulonglong id);
|
||||
static QList<ComicDB> getSiblings(const QString & libraryName, qulonglong parentId);
|
||||
static QString getFolderName(const QString & libraryName, qulonglong id);
|
||||
static QList<LibraryItem *> getFolderSubfoldersFromLibrary(qulonglong libraryId, qulonglong folderId);
|
||||
static QList<LibraryItem *> getFolderComicsFromLibrary(qulonglong libraryId, qulonglong folderId);
|
||||
static qulonglong getParentFromComicFolderId(qulonglong libraryId, qulonglong id);
|
||||
static ComicDB getComicInfo(qulonglong libraryId, qulonglong id);
|
||||
static QList<ComicDB> getSiblings(qulonglong libraryId, qulonglong parentId);
|
||||
static QString getFolderName(qulonglong libraryId, qulonglong id);
|
||||
static QList<QString> getLibrariesNames();
|
||||
static QString getLibraryName(int id);
|
||||
|
||||
@ -37,13 +37,13 @@ public:
|
||||
static qulonglong insert(Folder * folder, QSqlDatabase & db);
|
||||
static qulonglong insert(ComicDB * comic, QSqlDatabase & db);
|
||||
//updates
|
||||
static void update(const QString & libraryName, ComicInfo & comicInfo);
|
||||
static void update(qulonglong libraryId, ComicInfo & comicInfo);
|
||||
static void update(ComicDB * comics, QSqlDatabase & db);
|
||||
static void update(ComicInfo * comicInfo, QSqlDatabase & db);
|
||||
static void updateRead(ComicInfo * comicInfo, QSqlDatabase & db);
|
||||
static void update(const Folder & folder, QSqlDatabase & db);
|
||||
static void updateProgress(qulonglong libraryId,const ComicInfo & comicInfo); //TODO change libraryName by libraryId in all methods.
|
||||
//queries
|
||||
static void updateProgress(qulonglong libraryId,const ComicInfo & comicInfo);
|
||||
|
||||
static QList<LibraryItem *> getFoldersFromParent(qulonglong parentId, QSqlDatabase & db, bool sort = true);
|
||||
static QList<ComicDB> getSortedComicsFromParent(qulonglong parentId, QSqlDatabase & db);
|
||||
static QList<LibraryItem *> getComicsFromParent(qulonglong parentId, QSqlDatabase & db, bool sort = true);
|
||||
@ -52,6 +52,7 @@ public:
|
||||
static ComicDB loadComic(qulonglong id, QSqlDatabase & db);
|
||||
static ComicDB loadComic(QString cname, QString cpath, QString chash, QSqlDatabase & database);
|
||||
static ComicInfo loadComicInfo(QString hash, QSqlDatabase & db);
|
||||
static QList<QString> loadSubfoldersNames(qulonglong folderId, QSqlDatabase & db);
|
||||
};
|
||||
|
||||
#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/twitter.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/expanded_branch_osx.png</file>
|
||||
<file>../images/folder_macosx.png</file>
|
||||
@ -100,8 +100,18 @@
|
||||
<file>../images/comic_vine/downArrow.png</file>
|
||||
<file>../images/comic_vine/upArrow.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_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>-->
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -17,5 +17,8 @@
|
||||
<file alias="images/colapse.png">../images/colapse_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/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>
|
||||
</RCC>
|
||||
|
@ -1,19 +1,23 @@
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>../images/main_toolbar/back.png</file>
|
||||
<file>../images/main_toolbar/back_disabled.png</file>
|
||||
<file>../images/main_toolbar/forward.png</file>
|
||||
<file>../images/main_toolbar/forward_disabled.png</file>
|
||||
<file>../images/main_toolbar/settings.png</file>
|
||||
<file>../images/main_toolbar/server.png</file>
|
||||
<file>../images/main_toolbar/help.png</file>
|
||||
<file>../images/main_toolbar/fullscreen.png</file>
|
||||
|
||||
<file>../images/libraryIcon.png</file>
|
||||
<file>../images/setRoot.png</file>
|
||||
<file>../images/expand.png</file>
|
||||
<file>../images/colapse.png</file>
|
||||
<file>../images/newLibraryIcon.png</file>
|
||||
<file>../images/openLibraryIcon.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/">
|
||||
<file>../images/main_toolbar/back.png</file>
|
||||
<file>../images/main_toolbar/back_disabled.png</file>
|
||||
<file>../images/main_toolbar/forward.png</file>
|
||||
<file>../images/main_toolbar/forward_disabled.png</file>
|
||||
<file>../images/main_toolbar/settings.png</file>
|
||||
<file>../images/main_toolbar/server.png</file>
|
||||
<file>../images/main_toolbar/help.png</file>
|
||||
<file>../images/main_toolbar/fullscreen.png</file>
|
||||
<file>../images/libraryIcon.png</file>
|
||||
<file>../images/setRoot.png</file>
|
||||
<file>../images/expand.png</file>
|
||||
<file>../images/colapse.png</file>
|
||||
<file>../images/newLibraryIcon.png</file>
|
||||
<file>../images/openLibraryIcon.png</file>
|
||||
<file>../images/main_toolbar/flow.png</file>
|
||||
<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>
|
||||
|
@ -27,7 +27,6 @@ class HelpAboutDialog;
|
||||
class RenameLibraryDialog;
|
||||
class PropertiesDialog;
|
||||
class PackageManager;
|
||||
class ComicFlowWidget;
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
class TableModel;
|
||||
@ -50,6 +49,13 @@ class YACReaderLibraryListWidget;
|
||||
class YACReaderTreeView;
|
||||
class YACReaderMainToolBar;
|
||||
class ComicVineDialog;
|
||||
class ComicsView;
|
||||
class ClassicComicsView;
|
||||
class GridComicsView;
|
||||
class ComicsViewTransition;
|
||||
class EmptyFolderWidget;
|
||||
class EditShortcutsDialog;
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
using namespace YACReader;
|
||||
@ -59,7 +65,7 @@ class LibraryWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
private:
|
||||
YACReaderSideBar * sideBar;
|
||||
QSplitter * sVertical;
|
||||
|
||||
CreateLibraryDialog * createLibraryDialog;
|
||||
ExportLibraryDialog * exportLibraryDialog;
|
||||
ImportLibraryDialog * importLibraryDialog;
|
||||
@ -71,6 +77,7 @@ private:
|
||||
RenameLibraryDialog * renameLibraryDialog;
|
||||
PropertiesDialog * propertiesDialog;
|
||||
ComicVineDialog * comicVineDialog;
|
||||
EditShortcutsDialog * editShortcutsDialog;
|
||||
//YACReaderSocialDialog * socialDialog;
|
||||
bool fullscreen;
|
||||
bool importedCovers; //if true, the library is read only (not updates,open comic or properties)
|
||||
@ -80,7 +87,6 @@ private:
|
||||
//YACReaderSortComics * proxySort;
|
||||
PackageManager * packageManager;
|
||||
|
||||
ComicFlowWidget * comicFlow;
|
||||
QSize slideSizeW;
|
||||
QSize slideSizeF;
|
||||
//search filter
|
||||
@ -91,15 +97,20 @@ private:
|
||||
QPushButton * clearFoldersFilter;
|
||||
QCheckBox * includeComicsCheckBox;
|
||||
//-------------
|
||||
QWidget *comics;
|
||||
YACReaderTableView * comicView;
|
||||
|
||||
ComicsView * comicsView;
|
||||
ClassicComicsView * classicComicsView;
|
||||
GridComicsView * gridComicsView;
|
||||
QStackedWidget * comicsViewStack;
|
||||
ComicsViewTransition * comicsViewTransition;
|
||||
EmptyFolderWidget * emptyFolderWidget;
|
||||
|
||||
YACReaderTreeView * foldersView;
|
||||
YACReaderLibraryListWidget * selectedLibrary;
|
||||
TreeModel * dm;
|
||||
TableModel * dmCV;
|
||||
//QStringList paths;
|
||||
YACReaderLibraries libraries;
|
||||
QLabel * fullScreenToolTip;
|
||||
|
||||
QStackedWidget * mainWidget;
|
||||
NoLibrariesWidget * noLibrariesWidget;
|
||||
@ -116,8 +127,8 @@ private:
|
||||
QAction * createLibraryAction;
|
||||
QAction * openLibraryAction;
|
||||
|
||||
QAction * exportComicsInfo;
|
||||
QAction * importComicsInfo;
|
||||
QAction * exportComicsInfoAction;
|
||||
QAction * importComicsInfoAction;
|
||||
|
||||
QAction * exportLibraryAction;
|
||||
QAction * importLibraryAction;
|
||||
@ -129,6 +140,7 @@ private:
|
||||
QAction * toggleFullScreenAction;
|
||||
QAction * optionsAction;
|
||||
QAction * serverConfigAction;
|
||||
QAction * toggleComicsViewAction;
|
||||
//QAction * socialAction;
|
||||
|
||||
//tree actions
|
||||
@ -141,8 +153,8 @@ private:
|
||||
QAction * setFolderAsNotCompletedAction;
|
||||
QAction * setFolderAsCompletedAction;
|
||||
//--
|
||||
QAction * setFolderAsFinishedAction;
|
||||
QAction * setFolderAsNotFinishedAction;
|
||||
QAction * setFolderAsReadAction;
|
||||
QAction * setFolderAsUnreadAction;
|
||||
|
||||
QAction * openContainingFolderComicAction;
|
||||
QAction * setAsReadAction;
|
||||
@ -156,11 +168,16 @@ private:
|
||||
//edit info actions
|
||||
QAction * selectAllComicsAction;
|
||||
QAction * editSelectedComicsAction;
|
||||
QAction * asignOrderActions;
|
||||
QAction * forceConverExtractedAction;
|
||||
QAction * asignOrderAction;
|
||||
QAction * forceCoverExtractedAction;
|
||||
QAction * deleteComicsAction;
|
||||
QAction * hideComicViewAction;
|
||||
|
||||
QAction *showEditShortcutsAction;
|
||||
|
||||
QList<QAction *> itemActions;
|
||||
QList<QAction *> viewActions;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QToolBar * libraryToolBar;
|
||||
#else
|
||||
@ -191,103 +208,113 @@ private:
|
||||
void createConnections();
|
||||
void doLayout();
|
||||
void doDialogs();
|
||||
void setUpShortcutsManagement();
|
||||
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();
|
||||
//void disableActions();
|
||||
//void enableActions();
|
||||
//void enableLibraryActions();
|
||||
//ACTIONS MANAGEMENT
|
||||
void disableComicsActions(bool disabled);
|
||||
void disableLibrariesActions(bool disabled);
|
||||
void disableNoUpdatedLibrariesActions(bool disabled);
|
||||
void disableFoldersActions(bool disabled);
|
||||
|
||||
QString currentPath();
|
||||
void disableAllActions();
|
||||
//void disableActions();
|
||||
//void enableActions();
|
||||
//void enableLibraryActions();
|
||||
|
||||
//settings
|
||||
QSettings * settings;
|
||||
QString currentPath();
|
||||
|
||||
//navigation backward and forward
|
||||
int currentFolderNavigation;
|
||||
QList<QModelIndex> history;
|
||||
//settings
|
||||
QSettings * settings;
|
||||
|
||||
bool removeError;
|
||||
//navigation backward and forward
|
||||
int currentFolderNavigation;
|
||||
QList<QModelIndex> history;
|
||||
|
||||
bool removeError;
|
||||
|
||||
ComicsViewStatus comicsViewStatus;
|
||||
|
||||
protected:
|
||||
virtual void closeEvent ( QCloseEvent * event );
|
||||
virtual void closeEvent ( QCloseEvent * event );
|
||||
public:
|
||||
LibraryWindow();
|
||||
public slots:
|
||||
void loadLibrary(const QString & path);
|
||||
void loadCovers(const QModelIndex & mi);
|
||||
void checkEmptyFolder(QStringList * paths = 0);
|
||||
void reloadCovers();
|
||||
void centerComicFlow(const QModelIndex & mi);
|
||||
void updateComicView(int i);
|
||||
void openComic();
|
||||
void createLibrary();
|
||||
void create(QString source,QString dest, QString name);
|
||||
void showAddLibrary();
|
||||
void openLibrary(QString path, QString name);
|
||||
void loadLibraries();
|
||||
void saveLibraries();
|
||||
void reloadCurrentLibrary();
|
||||
void openLastCreated();
|
||||
void updateLibrary();
|
||||
//void deleteLibrary();
|
||||
void openContainingFolder();
|
||||
void setFolderAsNotCompleted();
|
||||
void setFolderAsCompleted();
|
||||
void setFolderAsFinished();
|
||||
void setFolderAsNotFinished();
|
||||
void openContainingFolderComic();
|
||||
void deleteCurrentLibrary();
|
||||
void removeLibrary();
|
||||
void renameLibrary();
|
||||
void rename(QString newName);
|
||||
void cancelCreating();
|
||||
void stopLibraryCreator();
|
||||
void setRootIndex();
|
||||
void toggleFullScreen();
|
||||
void toNormal();
|
||||
void toFullScreen();
|
||||
void setFoldersFilter(QString filter);
|
||||
void showProperties();
|
||||
void exportLibrary(QString destPath);
|
||||
void importLibrary(QString clc,QString destPath,QString name);
|
||||
void reloadOptions();
|
||||
void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus);
|
||||
void setCurrentComicReaded();
|
||||
void setCurrentComicUnreaded();
|
||||
void setComicsReaded();
|
||||
void setComicsUnreaded();
|
||||
void hideComicFlow(bool hide);
|
||||
void showExportComicsInfo();
|
||||
void showImportComicsInfo();
|
||||
void asignNumbers();
|
||||
void showNoLibrariesWidget();
|
||||
void showRootWidget();
|
||||
void showImportingWidget();
|
||||
void manageCreatingError(const QString & error);
|
||||
void manageUpdatingError(const QString & error);
|
||||
void manageOpeningLibraryError(const QString & error);
|
||||
QModelIndexList getSelectedComics();
|
||||
void deleteComics();
|
||||
//void showSocial();
|
||||
void backward();
|
||||
void forward();
|
||||
void updateHistory(const QModelIndex & mi);
|
||||
void updateFoldersViewConextMenu(const QModelIndex & mi);
|
||||
void libraryAlreadyExists(const QString & name);
|
||||
void importLibraryPackage();
|
||||
void updateComicsView(quint64 libraryId, const ComicDB & comic);
|
||||
void setCurrentComicOpened();
|
||||
void showComicVineScraper();
|
||||
void setRemoveError();
|
||||
void checkRemoveError();
|
||||
void resetComicRating();
|
||||
LibraryWindow();
|
||||
|
||||
public slots:
|
||||
void loadLibrary(const QString & path);
|
||||
void loadCovers(const QModelIndex & mi);
|
||||
void selectSubfolder(const QModelIndex & mi, int child);
|
||||
void checkEmptyFolder(QStringList * paths = 0);
|
||||
void reloadCovers();
|
||||
void openComic();
|
||||
void createLibrary();
|
||||
void create(QString source,QString dest, QString name);
|
||||
void showAddLibrary();
|
||||
void openLibrary(QString path, QString name);
|
||||
void loadLibraries();
|
||||
void saveLibraries();
|
||||
void reloadCurrentLibrary();
|
||||
void openLastCreated();
|
||||
void updateLibrary();
|
||||
//void deleteLibrary();
|
||||
void openContainingFolder();
|
||||
void setFolderAsNotCompleted();
|
||||
void setFolderAsCompleted();
|
||||
void setFolderAsRead();
|
||||
void setFolderAsUnread();
|
||||
void openContainingFolderComic();
|
||||
void deleteCurrentLibrary();
|
||||
void removeLibrary();
|
||||
void renameLibrary();
|
||||
void rename(QString newName);
|
||||
void cancelCreating();
|
||||
void stopLibraryCreator();
|
||||
void setRootIndex();
|
||||
void toggleFullScreen();
|
||||
void toNormal();
|
||||
void toFullScreen();
|
||||
void setFoldersFilter(QString filter);
|
||||
void showProperties();
|
||||
void exportLibrary(QString destPath);
|
||||
void importLibrary(QString clc,QString destPath,QString name);
|
||||
void reloadOptions();
|
||||
void setCurrentComicsStatusReaded(YACReaderComicReadStatus readStatus);
|
||||
void setCurrentComicReaded();
|
||||
void setCurrentComicUnreaded();
|
||||
void hideComicFlow(bool hide);
|
||||
void showExportComicsInfo();
|
||||
void showImportComicsInfo();
|
||||
void asignNumbers();
|
||||
void showNoLibrariesWidget();
|
||||
void showRootWidget();
|
||||
void showImportingWidget();
|
||||
void manageCreatingError(const QString & error);
|
||||
void manageUpdatingError(const QString & error);
|
||||
void manageOpeningLibraryError(const QString & error);
|
||||
QModelIndexList getSelectedComics();
|
||||
void deleteComics();
|
||||
//void showSocial();
|
||||
void backward();
|
||||
void forward();
|
||||
void updateHistory(const QModelIndex & mi);
|
||||
void updateFoldersViewConextMenu(const QModelIndex & mi);
|
||||
void libraryAlreadyExists(const QString & name);
|
||||
void importLibraryPackage();
|
||||
void updateComicsView(quint64 libraryId, const ComicDB & comic);
|
||||
void setCurrentComicOpened();
|
||||
void showComicVineScraper();
|
||||
void setRemoveError();
|
||||
void checkRemoveError();
|
||||
void resetComicRating();
|
||||
void switchToComicsView(ComicsView *from, ComicsView *to);
|
||||
void showComicsViewTransition();
|
||||
void toggleComicsView_delayed();//used in orther to avoid flickering;
|
||||
void showComicsView();
|
||||
void showEmptyFolderView();
|
||||
void toggleComicsView();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -239,9 +239,12 @@ int main( int argc, char ** argv )
|
||||
|
||||
YACReader::exitCheck(ret);
|
||||
|
||||
//server shutdown
|
||||
//shutdown
|
||||
s->stop();
|
||||
delete s;
|
||||
localServer->close();
|
||||
delete localServer;
|
||||
delete mw;
|
||||
|
||||
QsLogging::Logger::destroyInstance();
|
||||
|
||||
|
@ -20,33 +20,50 @@ FlowType flowType = Strip;
|
||||
OptionsDialog::OptionsDialog(QWidget * parent)
|
||||
:YACReaderOptionsDialog(parent)
|
||||
{
|
||||
QVBoxLayout * layout = new QVBoxLayout;
|
||||
QTabWidget * tabWidget = new QTabWidget();
|
||||
|
||||
QHBoxLayout * switchFlowType = new QHBoxLayout;
|
||||
switchFlowType->addStretch();
|
||||
switchFlowType->addWidget(useGL);
|
||||
QVBoxLayout * layout = new QVBoxLayout(this);
|
||||
|
||||
QVBoxLayout * flowLayout = new QVBoxLayout;
|
||||
QVBoxLayout * generalLayout = new QVBoxLayout();
|
||||
|
||||
QHBoxLayout * switchFlowType = new QHBoxLayout;
|
||||
switchFlowType->addStretch();
|
||||
switchFlowType->addWidget(useGL);
|
||||
|
||||
QHBoxLayout * buttons = new QHBoxLayout();
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(accept);
|
||||
buttons->addWidget(cancel);
|
||||
QHBoxLayout * buttons = new QHBoxLayout();
|
||||
buttons->addStretch();
|
||||
buttons->addWidget(accept);
|
||||
buttons->addWidget(cancel);
|
||||
|
||||
layout->addWidget(sw);
|
||||
layout->addWidget(gl);
|
||||
layout->addLayout(switchFlowType);
|
||||
layout->addLayout(buttons);
|
||||
flowLayout->addWidget(sw);
|
||||
flowLayout->addWidget(gl);
|
||||
flowLayout->addLayout(switchFlowType);
|
||||
|
||||
sw->hide();
|
||||
sw->hide();
|
||||
|
||||
setLayout(layout);
|
||||
//restoreOptions(settings); //load options
|
||||
//resize(200,0);
|
||||
setModal (true);
|
||||
setWindowTitle(tr("Options"));
|
||||
QWidget * comicFlowW = new QWidget;
|
||||
comicFlowW->setLayout(flowLayout);
|
||||
|
||||
QWidget * generalW = new QWidget;
|
||||
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>
|
@ -21,7 +21,8 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||
QStringList pathElements = path.split('/');
|
||||
QString libraryName = DBHelper::getLibraryName(pathElements.at(2).toInt());
|
||||
qulonglong libraryId = pathElements.at(2).toLongLong();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||
|
||||
bool remoteComic = path.endsWith("remote");
|
||||
@ -38,20 +39,14 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
// }
|
||||
//}
|
||||
|
||||
//Aplicar a todos los controladores
|
||||
//TODO usar LibraryWindow para acceder a información de las bases de datos está mal, hay
|
||||
//que crear una clase que se encargue de estas cosas
|
||||
//¿Se está accediendo a la UI desde un hilo?
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryName, comicId);
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
if(!remoteComic)
|
||||
session.setDownloadedComic(comic.info.hash);
|
||||
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryName)+comic.path);
|
||||
Comic * comicFile = FactoryComic::newComic(libraries.getPath(libraryId)+comic.path);
|
||||
|
||||
if(comicFile != NULL)
|
||||
{
|
||||
@ -64,7 +59,7 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
connect(thread, SIGNAL(started()), comicFile, SLOT(process()));
|
||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||
|
||||
comicFile->load(libraries.getPath(libraryName)+comic.path);
|
||||
comicFile->load(libraries.getPath(libraryId)+comic.path);
|
||||
|
||||
if(thread != NULL)
|
||||
thread->start();
|
||||
@ -84,10 +79,10 @@ void ComicController::service(HttpRequest& request, HttpResponse& response)
|
||||
response.setHeader("Content-Type", "plain/text; charset=ISO-8859-1");
|
||||
//TODO this field is not used by the client!
|
||||
response.writeText(QString("library:%1\r\n").arg(libraryName));
|
||||
response.writeText(QString("libraryId:%1\r\n").arg(pathElements.at(2)));
|
||||
response.writeText(QString("libraryId:%1\r\n").arg(libraryId));
|
||||
if(remoteComic) //send previous and next comics id
|
||||
{
|
||||
QList<LibraryItem *> siblings = DBHelper::getFolderComicsFromLibrary(libraryName, comic.parentId);
|
||||
QList<LibraryItem *> siblings = DBHelper::getFolderComicsFromLibrary(libraryId, comic.parentId);
|
||||
bool found = false;
|
||||
int i;
|
||||
for(i = 0; i < siblings.length(); i++)
|
||||
|
@ -0,0 +1,24 @@
|
||||
#include "comicdownloadinfocontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "comic_db.h"
|
||||
|
||||
ComicDownloadInfoController::ComicDownloadInfoController() {}
|
||||
|
||||
|
||||
void ComicDownloadInfoController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toLatin1();
|
||||
QStringList pathElements = path.split('/');
|
||||
|
||||
qulonglong libraryId = pathElements.at(2).toLongLong();
|
||||
qulonglong comicId = pathElements.at(4).toULongLong();
|
||||
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
//TODO: check if the comic wasn't found;
|
||||
response.writeText(QString("comicName:%1\r\n").arg(comic.getFileName()));
|
||||
response.writeText(QString("fileSize:%1\r\n").arg(comic.getFileSize()),true);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
#ifndef COMICDOWNLOADINFOCONTROLLER_H
|
||||
#define COMICDOWNLOADINFOCONTROLLER_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ComicDownloadInfoController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ComicDownloadInfoController);
|
||||
public:
|
||||
/** Constructor **/
|
||||
ComicDownloadInfoController();
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // COMICDOWNLOADINFOCONTROLLER_H
|
@ -43,7 +43,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
folderId = qMax<qulonglong>(1,folderId);
|
||||
|
||||
QString folderName = DBHelper::getFolderName(libraryName,folderId);
|
||||
QString folderName = DBHelper::getFolderName(libraryId,folderId);
|
||||
if(folderName.isEmpty())
|
||||
{
|
||||
ErrorController(300).service(request,response);
|
||||
@ -54,8 +54,8 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
||||
t.setVariable("folder.name",folderName);
|
||||
else
|
||||
t.setVariable("folder.name",libraryName);
|
||||
QList<LibraryItem *> folderContent = DBHelper::getFolderContentFromLibrary(libraryName,folderId);
|
||||
QList<LibraryItem *> folderComics = DBHelper::getFolderComicsFromLibrary(libraryName,folderId);
|
||||
QList<LibraryItem *> folderContent = DBHelper::getFolderSubfoldersFromLibrary(libraryId,folderId);
|
||||
QList<LibraryItem *> folderComics = DBHelper::getFolderComicsFromLibrary(libraryId,folderId);
|
||||
|
||||
//response.writeText(libraryName);
|
||||
|
||||
@ -152,7 +152,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
||||
t.loop("path",foldersPath.count()-1);
|
||||
for(int i = 1; i < foldersPath.count(); i++){
|
||||
t.setVariable(QString("path%1.url").arg(i-1),QString("/library/%1/folder/%2").arg(libraryId).arg(foldersPath[i].first));
|
||||
t.setVariable(QString("path%1.name").arg(i-1),DBHelper::getFolderName(libraryName,foldersPath[i].first));
|
||||
t.setVariable(QString("path%1.name").arg(i-1),DBHelper::getFolderName(libraryId,foldersPath[i].first));
|
||||
}
|
||||
|
||||
t.loop("element",numFoldersAtCurrentPage);
|
||||
@ -165,7 +165,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
t.setVariable(QString("element%1.class").arg(i),"folder");
|
||||
|
||||
QList<LibraryItem *> children = DBHelper::getFolderComicsFromLibrary(libraryName, item->id);
|
||||
QList<LibraryItem *> children = DBHelper::getFolderComicsFromLibrary(libraryId, item->id);
|
||||
if(children.length()>0)
|
||||
{
|
||||
const ComicDB * comic = static_cast<ComicDB*>(children.at(0));
|
||||
|
@ -19,21 +19,30 @@ void FolderInfoController::service(HttpRequest& request, HttpResponse& response)
|
||||
int libraryId = pathElements.at(2).toInt();
|
||||
QString libraryName = DBHelper::getLibraryName(libraryId);
|
||||
qulonglong parentId = pathElements.at(4).toULongLong();
|
||||
QList<LibraryItem *> folderContent = DBHelper::getFolderContentFromLibrary(libraryName,parentId);
|
||||
QList<LibraryItem *> folderComics = DBHelper::getFolderComicsFromLibrary(libraryName,parentId);
|
||||
|
||||
Folder * currentFolder;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderContent.constBegin();itr!=folderContent.constEnd();itr++)
|
||||
{
|
||||
currentFolder = (Folder *)(*itr);
|
||||
response.writeText(QString("/library/%1/folder/%2/info\n").arg(libraryId).arg(currentFolder->id));
|
||||
}
|
||||
serviceComics(libraryId, parentId, response);
|
||||
|
||||
ComicDB * currentComic;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderComics.constBegin();itr!=folderComics.constEnd();itr++)
|
||||
{
|
||||
currentComic = (ComicDB *)(*itr);
|
||||
response.writeText(QString("/library/%1/comic/%2\n").arg(libraryId).arg(currentComic->id));
|
||||
}
|
||||
response.writeText("",true);
|
||||
}
|
||||
|
||||
}
|
||||
void FolderInfoController::serviceComics(const int &library, const qulonglong &folderId, HttpResponse &response)
|
||||
{
|
||||
QList<LibraryItem *> folderContent = DBHelper::getFolderSubfoldersFromLibrary(library,folderId);
|
||||
QList<LibraryItem *> folderComics = DBHelper::getFolderComicsFromLibrary(library,folderId);
|
||||
|
||||
ComicDB * currentComic;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderComics.constBegin();itr!=folderComics.constEnd();itr++)
|
||||
{
|
||||
currentComic = (ComicDB *)(*itr);
|
||||
response.writeText(QString("/library/%1/comic/%2:%3:%4\r\n").arg(library).arg(currentComic->id).arg(currentComic->getFileName()).arg(currentComic->getFileSize()));
|
||||
delete currentComic;
|
||||
}
|
||||
|
||||
Folder * currentFolder;
|
||||
for(QList<LibraryItem *>::const_iterator itr = folderContent.constBegin();itr!=folderContent.constEnd();itr++)
|
||||
{
|
||||
currentFolder = (Folder *)(*itr);
|
||||
serviceComics(library, currentFolder->id, response);
|
||||
delete currentFolder;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ public:
|
||||
|
||||
/** Generates the response */
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceComics(const int &library, const qulonglong & folderId, HttpResponse& response);
|
||||
};
|
||||
|
||||
#endif // FOLDERINFOCONTROLLER_H
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "controllers/pagecontroller.h"
|
||||
#include "controllers/updatecomiccontroller.h"
|
||||
#include "controllers/errorcontroller.h"
|
||||
#include "controllers/comicdownloadinfocontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
@ -95,7 +96,8 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
|
||||
QRegExp folder("/library/.+/folder/[0-9]+/?");//get comic content
|
||||
QRegExp folderInfo("/library/.+/folder/[0-9]+/info/?"); //get folder info
|
||||
QRegExp comic("/library/.+/comic/[0-9]+/?"); //get comic info
|
||||
QRegExp comicDownloadInfo("/library/.+/comic/[0-9]+/?"); //get comic info (basic/download info)
|
||||
QRegExp comicFullInfo("/library/.+/comic/[0-9]+/info/?"); //get comic info (full info)
|
||||
QRegExp comicOpen("/library/.+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
||||
QRegExp comicUpdate("/library/.+/comic/[0-9]+/update/?"); //get comic info
|
||||
QRegExp comicClose("/library/.+/comic/[0-9]+/close/?"); //the server will close the comic and free memory
|
||||
@ -138,8 +140,12 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
else if(cover.exactMatch(path))
|
||||
{
|
||||
CoverController().service(request, response);
|
||||
}
|
||||
else if(comic.exactMatch(path) || comicOpen.exactMatch(path))
|
||||
}
|
||||
else if(comicDownloadInfo.exactMatch(path))
|
||||
{
|
||||
ComicDownloadInfoController().service(request, response);
|
||||
}
|
||||
else if(comicFullInfo.exactMatch(path) || comicOpen.exactMatch(path))//start download or start remote reading
|
||||
{
|
||||
ComicController().service(request, response);
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ HEADERS += \
|
||||
$$PWD/controllers/pagecontroller.h \
|
||||
$$PWD/controllers/sessionmanager.h \
|
||||
$$PWD/controllers/covercontroller.h \
|
||||
server/controllers/updatecomiccontroller.h
|
||||
server/controllers/updatecomiccontroller.h \
|
||||
server/controllers/comicdownloadinfocontroller.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/static.cpp \
|
||||
@ -27,7 +28,8 @@ SOURCES += \
|
||||
$$PWD/controllers/pagecontroller.cpp \
|
||||
$$PWD/controllers/sessionmanager.cpp \
|
||||
$$PWD/controllers/covercontroller.cpp \
|
||||
server/controllers/updatecomiccontroller.cpp
|
||||
server/controllers/updatecomiccontroller.cpp \
|
||||
server/controllers/comicdownloadinfocontroller.cpp
|
||||
|
||||
include(lib/bfLogging/bfLogging.pri)
|
||||
include(lib/bfHttpServer/bfHttpServer.pri)
|
||||
|
@ -37,7 +37,7 @@ void Startup::start() {
|
||||
//QSettings* debugLogSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
//debugLogSettings->beginGroup("debugLogFile");
|
||||
Logger* logger=new FileLogger(mainLogSettings,10000,app);
|
||||
logger->installMsgHandler();
|
||||
logger->installMsgHandler();
|
||||
|
||||
// Configure template loader and cache
|
||||
QSettings* templateSettings=new QSettings(configFileName,QSettings::IniFormat,app);
|
||||
@ -65,9 +65,14 @@ void Startup::start() {
|
||||
|
||||
|
||||
void Startup::stop() {
|
||||
qDebug("ServiceHelper: Service has been stopped");
|
||||
// QCoreApplication destroys all objects that have been created in start().
|
||||
delete listener;
|
||||
qDebug("ServiceHelper: Service has been stopped");
|
||||
// QCoreApplication destroys all objects that have been created in start().
|
||||
if(listener!=nullptr)
|
||||
{
|
||||
listener->close();
|
||||
delete listener;
|
||||
listener = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -64,7 +64,12 @@ bool YACReaderLocalServer::isRunning()
|
||||
socket.connectToServer(YACREADERLIBRARY_GUID);
|
||||
if (socket.waitForConnected(500))
|
||||
return true; // Server is running (another instance of YACReaderLibrary has been launched)
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
void YACReaderLocalServer::close()
|
||||
{
|
||||
localServer->close();
|
||||
}
|
||||
|
||||
|
||||
@ -201,13 +206,13 @@ void YACReaderClientConnectionWorker::run()
|
||||
void YACReaderClientConnectionWorker::getComicInfo(quint64 libraryId, ComicDB & comic, QList<ComicDB> & siblings)
|
||||
{
|
||||
QMutexLocker locker(&dbMutex);
|
||||
comic = DBHelper::getComicInfo(DBHelper::getLibrariesNames().at(libraryId), comic.id);
|
||||
siblings = DBHelper::getSiblings(DBHelper::getLibrariesNames().at(libraryId), comic.parentId);
|
||||
comic = DBHelper::getComicInfo(libraryId, comic.id);
|
||||
siblings = DBHelper::getSiblings(libraryId, comic.parentId);
|
||||
}
|
||||
|
||||
void YACReaderClientConnectionWorker::updateComic(quint64 libraryId, ComicDB & comic)
|
||||
{
|
||||
QMutexLocker locker(&dbMutex);
|
||||
DBHelper::update(DBHelper::getLibrariesNames().at(libraryId), comic.info);
|
||||
DBHelper::update(libraryId, comic.info);
|
||||
emit comicUpdated(libraryId, comic);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public slots:
|
||||
bool isListening();
|
||||
void sendResponse();
|
||||
static bool isRunning();
|
||||
void close();
|
||||
private:
|
||||
//void run();
|
||||
QLocalServer * localServer;
|
||||
|
@ -44,11 +44,14 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) :
|
||||
helpButton->setStyleSheet(qToolButtonStyleSheet);
|
||||
helpButton->setIconSize(QSize(14,25));
|
||||
|
||||
toggleComicsViewButton = new QToolButton;
|
||||
toggleComicsViewButton->setStyleSheet(qToolButtonStyleSheet);
|
||||
toggleComicsViewButton->setIconSize(QSize(24,24));
|
||||
|
||||
fullscreenButton = new QToolButton();
|
||||
fullscreenButton->setStyleSheet(qToolButtonStyleSheet);
|
||||
fullscreenButton->setIconSize(QSize(24,24));
|
||||
|
||||
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
@ -66,6 +69,8 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent) :
|
||||
|
||||
mainLayout->addStretch();
|
||||
|
||||
mainLayout->addWidget(toggleComicsViewButton);
|
||||
addWideDivider();
|
||||
mainLayout->addWidget(fullscreenButton);
|
||||
mainLayout->addSpacing(10);
|
||||
|
||||
|
@ -9,6 +9,7 @@ class QResizeEvent;
|
||||
class QPaintEvent;
|
||||
class QHBoxLayout;
|
||||
|
||||
//TODO create methods for adding actions, separators and sctreches dynimically
|
||||
class YACReaderMainToolBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -21,8 +22,10 @@ public:
|
||||
QToolButton * settingsButton;
|
||||
QToolButton * serverButton;
|
||||
QToolButton * helpButton;
|
||||
QToolButton * toggleComicsViewButton;
|
||||
QToolButton * fullscreenButton;
|
||||
|
||||
|
||||
void setCurrentFolderName(const QString & name);
|
||||
signals:
|
||||
|
||||
|
@ -31,7 +31,7 @@ QString ComicDB::toTXT()
|
||||
txt.append(QString("currentPage:%1\r\n").arg(info.currentPage));
|
||||
txt.append(QString("contrast:%1\r\n").arg(info.contrast));
|
||||
|
||||
//Información general
|
||||
//Informaci<EFBFBD>n general
|
||||
if(!info.coverPage.isNull())
|
||||
txt.append(QString("coverPage:%1\r\n").arg(info.coverPage.toString()));
|
||||
|
||||
@ -80,7 +80,7 @@ QString ComicDB::toTXT()
|
||||
|
||||
if(!info.coverArtist.isNull())
|
||||
txt.append(QString("coverArtist:%1\r\n").arg(info.coverArtist.toString()));
|
||||
//Publicación
|
||||
//Publicaci<EFBFBD>n
|
||||
if(!info.date.isNull())
|
||||
txt.append(QString("date:%1\r\n").arg(info.date.toString()));
|
||||
|
||||
@ -127,7 +127,13 @@ QString ComicDB::getParentFolderName() const
|
||||
if(paths.length()<2)
|
||||
return "";
|
||||
else
|
||||
return paths[paths.length()-2];
|
||||
return paths[paths.length()-2];
|
||||
}
|
||||
|
||||
qulonglong ComicDB::getFileSize() const
|
||||
{
|
||||
//the size is encoded in the hash after the SHA-1
|
||||
return info.hash.right(info.hash.length()-40).toLongLong();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -139,6 +139,9 @@ public:
|
||||
//returns parent folder name
|
||||
QString getParentFolderName() const;
|
||||
|
||||
//return the size of the file in bytes
|
||||
qulonglong getFileSize() const;
|
||||
|
||||
QString toTXT();
|
||||
|
||||
ComicInfo info;
|
||||
|
@ -1059,7 +1059,7 @@ void YACReaderFlowGL::keyPressEvent(QKeyEvent *event)
|
||||
|
||||
if(event->key() == Qt::Key_Up)
|
||||
{
|
||||
emit selected(centerIndex());
|
||||
//emit selected(centerIndex());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -19,3 +19,11 @@ void YACReader::addSperator(QWidget *w)
|
||||
separator->setSeparator(true);
|
||||
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 COMICS_VIEW_HEADERS "COMICS_VIEW_HEADERS"
|
||||
#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 LAST_VERSION_CHECK "LAST_VERSION_CHECK"
|
||||
@ -94,8 +95,15 @@ namespace YACReader
|
||||
SevenZNotFound = 700
|
||||
};
|
||||
|
||||
enum ComicsViewStatus
|
||||
{
|
||||
Flow,
|
||||
Grid
|
||||
};
|
||||
|
||||
QString getSettingsPath();
|
||||
void addSperator(QWidget * w);
|
||||
QAction * createSeparator();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QRadioButton>
|
||||
#include <QSlider>
|
||||
#include <QSettings>
|
||||
#include <QGroupBox>
|
||||
|
||||
YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
|
||||
:QDialog(parent)
|
||||
@ -23,6 +24,16 @@ YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
|
||||
|
||||
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(cancel,SIGNAL(clicked()),this,SLOT(restoreOptions())); //TODO fix this
|
||||
connect(cancel,SIGNAL(clicked()),this,SLOT(close()));
|
||||
|
@ -8,6 +8,7 @@ class YACReaderGLFlowConfigWidget;
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
class QSettings;
|
||||
class QGroupBox;
|
||||
|
||||
class YACReaderOptionsDialog : public QDialog
|
||||
{
|
||||
@ -20,6 +21,8 @@ protected:
|
||||
QPushButton * accept;
|
||||
QPushButton * cancel;
|
||||
|
||||
QGroupBox * shortcutsBox;
|
||||
|
||||
QSettings * settings;
|
||||
QSettings * previousSettings;
|
||||
|
||||
@ -56,6 +59,7 @@ protected slots:
|
||||
|
||||
signals:
|
||||
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));
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
setMaximumWidth(300);
|
||||
setMaximumWidth(212);
|
||||
#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
|