merged fitmode_refactoring
@ -8,6 +8,8 @@ DEPENDPATH += . \
|
||||
|
||||
DEFINES += NOMINMAX YACREADER
|
||||
|
||||
QMAKE_MAC_SDK = macosx10.11
|
||||
|
||||
#load default build flags
|
||||
include (../config.pri)
|
||||
|
||||
|
@ -33,26 +33,28 @@ void Configuration::load(QSettings * settings)
|
||||
settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
|
||||
if(!settings->contains(ZOOM_LEVEL))
|
||||
settings->setValue(MAG_GLASS_SIZE,QSize(350,175));
|
||||
if(!settings->contains(FIT))
|
||||
settings->setValue(FIT,false);
|
||||
if(!settings->contains(FLOW_TYPE))
|
||||
settings->setValue(FLOW_TYPE,0);
|
||||
if(!settings->contains(FULLSCREEN))
|
||||
settings->setValue(FULLSCREEN,false);
|
||||
if(!settings->contains(FIT_TO_WIDTH_RATIO))
|
||||
settings->setValue(FIT_TO_WIDTH_RATIO,1);
|
||||
if(!settings->contains(Y_WINDOW_SIZE))
|
||||
settings->setValue(Y_WINDOW_SIZE,QSize(0,0));
|
||||
if(!settings->contains(MAXIMIZED))
|
||||
settings->setValue(MAXIMIZED,false);
|
||||
if(!settings->contains(DOUBLE_PAGE))
|
||||
settings->setValue(DOUBLE_PAGE,false);
|
||||
if(!settings->contains(ADJUST_TO_FULL_SIZE))
|
||||
settings->setValue(ADJUST_TO_FULL_SIZE,false);
|
||||
if(!settings->contains(BACKGROUND_COLOR))
|
||||
settings->setValue(BACKGROUND_COLOR,QColor(40,40,40));
|
||||
if(!settings->contains(ALWAYS_ON_TOP))
|
||||
settings->setValue(ALWAYS_ON_TOP,false);
|
||||
if(!settings->contains(SHOW_TOOLBARS))
|
||||
settings->setValue(SHOW_TOOLBARS, true);
|
||||
}
|
||||
//old fit stuff
|
||||
/*if(!settings->contains(FIT))
|
||||
settings->setValue(FIT,false);
|
||||
if(!settings->contains(FIT_TO_WIDTH_RATIO))
|
||||
settings->setValue(FIT_TO_WIDTH_RATIO,1);
|
||||
if(!settings->contains(ADJUST_TO_FULL_SIZE))
|
||||
settings->setValue(ADJUST_TO_FULL_SIZE,false);
|
||||
*/
|
||||
}
|
@ -58,16 +58,28 @@ using namespace YACReader;
|
||||
void setMagnifyingGlassSize(const QSize & mgs) { settings->setValue(MAG_GLASS_SIZE,mgs);}
|
||||
QSize getGotoSlideSize() { return settings->value(GO_TO_FLOW_SIZE).toSize();}
|
||||
void setGotoSlideSize(const QSize & gss) { settings->setValue(GO_TO_FLOW_SIZE,gss);}
|
||||
float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();}
|
||||
void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);}
|
||||
float getZoomLevel() { return settings->value(ZOOM_LEVEL).toFloat();}
|
||||
void setZoomLevel(float zl) { settings->setValue(ZOOM_LEVEL,zl);}
|
||||
|
||||
//Unified enum based fitmode
|
||||
YACReader::FitMode getFitMode() { return static_cast<YACReader::FitMode>(settings->value(FITMODE, YACReader::FitMode::FullPage).toInt()); }
|
||||
void setFitMode ( YACReader::FitMode fitMode ){ settings->setValue(FITMODE, static_cast<int>(fitMode)); }
|
||||
|
||||
//Old fitmodes
|
||||
/*
|
||||
bool getAdjustToWidth() {return settings->value(FIT).toBool();}
|
||||
void setAdjustToWidth(bool atw=true) {settings->setValue(FIT,atw);}
|
||||
float getFitToWidthRatio(){return settings->value(FIT_TO_WIDTH_RATIO).toFloat();}
|
||||
void setFitToWidthRatio(float r){settings->setValue(FIT_TO_WIDTH_RATIO,r);}
|
||||
bool getAdjustToFullSize(){return settings->value(ADJUST_TO_FULL_SIZE).toBool();}
|
||||
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);}
|
||||
*/
|
||||
|
||||
FlowType getFlowType(){return (FlowType)settings->value(FLOW_TYPE_SW).toInt();}
|
||||
void setFlowType(FlowType type){settings->setValue(FLOW_TYPE_SW,type);}
|
||||
bool getFullScreen(){return settings->value(FULLSCREEN).toBool();}
|
||||
void setFullScreen(bool f){settings->setValue(FULLSCREEN,f);}
|
||||
float getFitToWidthRatio(){return settings->value(FIT_TO_WIDTH_RATIO).toFloat();}
|
||||
void setFitToWidthRatio(float r){settings->setValue(FIT_TO_WIDTH_RATIO,r);}
|
||||
|
||||
QPoint getPos(){return settings->value(Y_WINDOW_POS).toPoint();}
|
||||
void setPos(QPoint p){settings->setValue(Y_WINDOW_POS,p);}
|
||||
QSize getSize(){return settings->value(Y_WINDOW_SIZE).toSize();}
|
||||
@ -78,8 +90,7 @@ using namespace YACReader;
|
||||
void setDoublePage(bool b){settings->setValue(DOUBLE_PAGE,b);}
|
||||
bool getDoubleMangaPage(){return settings->value(DOUBLE_MANGA_PAGE).toBool();}
|
||||
void setDoubleMangaPage(bool b){settings->setValue(DOUBLE_MANGA_PAGE,b);}
|
||||
bool getAdjustToFullSize(){return settings->value(ADJUST_TO_FULL_SIZE).toBool();}
|
||||
void setAdjustToFullSize(bool b){settings->setValue(ADJUST_TO_FULL_SIZE,b);}
|
||||
|
||||
QColor getBackgroundColor(){return settings->value(BACKGROUND_COLOR).value<QColor>();}
|
||||
void setBackgroundColor(const QColor& color){settings->value(BACKGROUND_COLOR,color);}
|
||||
bool getAlwaysOnTop(){return settings->value(ALWAYS_ON_TOP).toBool();}
|
||||
|
@ -81,7 +81,7 @@ MainWindowViewer::~MainWindowViewer()
|
||||
delete viewer;
|
||||
delete had;
|
||||
|
||||
delete sliderAction;
|
||||
//delete sliderAction;
|
||||
delete openAction;
|
||||
delete openFolderAction;
|
||||
delete saveImageAction;
|
||||
@ -95,6 +95,9 @@ MainWindowViewer::~MainWindowViewer()
|
||||
delete rightRotationAction;
|
||||
delete doublePageAction;
|
||||
delete doubleMangaPageAction;
|
||||
delete increasePageZoomAction;
|
||||
delete decreasePageZoomAction;
|
||||
delete resetZoomAction;
|
||||
delete goToPageAction;
|
||||
delete optionsAction;
|
||||
delete helpAboutAction;
|
||||
@ -107,6 +110,7 @@ MainWindowViewer::~MainWindowViewer()
|
||||
delete showDictionaryAction;
|
||||
delete alwaysOnTopAction;
|
||||
delete adjustToFullSizeAction;
|
||||
delete fitToPageAction;
|
||||
delete showFlowAction;
|
||||
|
||||
}
|
||||
@ -160,7 +164,6 @@ void MainWindowViewer::setupUI()
|
||||
|
||||
optionsDialog = new OptionsDialog(this);
|
||||
connect(optionsDialog,SIGNAL(accepted()),viewer,SLOT(updateOptions()));
|
||||
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
||||
connect(optionsDialog, SIGNAL(optionsChanged()),this,SLOT(reloadOptions()));
|
||||
connect(optionsDialog,SIGNAL(changedFilters(int,int,int)),viewer,SLOT(updateFilters(int,int,int)));
|
||||
|
||||
@ -261,24 +264,88 @@ void MainWindowViewer::createActions()
|
||||
adjustHeightAction->setIcon(QIcon(":/images/viewer_toolbar/toHeight.png"));
|
||||
//adjustWidth->setCheckable(true);
|
||||
adjustHeightAction->setDisabled(true);
|
||||
adjustHeightAction->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustHeightAction->setToolTip(tr("Fit image to height"));
|
||||
//adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
||||
adjustHeightAction->setData(ADJUST_HEIGHT_ACTION_Y);
|
||||
adjustHeightAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_HEIGHT_ACTION_Y));
|
||||
adjustHeightAction->setCheckable(true);
|
||||
connect(adjustHeightAction, SIGNAL(triggered()),this,SLOT(fitToHeight()));
|
||||
|
||||
adjustWidthAction = new QAction(tr("Fit Width"),this);
|
||||
adjustWidthAction->setIcon(QIcon(":/images/viewer_toolbar/toWidth.png"));
|
||||
//adjustWidth->setCheckable(true);
|
||||
adjustWidthAction->setDisabled(true);
|
||||
adjustWidthAction->setChecked(Configuration::getConfiguration().getAdjustToWidth());
|
||||
adjustWidthAction->setToolTip(tr("Fit image to width"));
|
||||
//adjustWidth->setIcon(QIcon(":/images/fitWidth.png"));
|
||||
adjustWidthAction->setData(ADJUST_WIDTH_ACTION_Y);
|
||||
adjustWidthAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_WIDTH_ACTION_Y));
|
||||
adjustWidthAction->setCheckable(true);
|
||||
connect(adjustWidthAction, SIGNAL(triggered()),this,SLOT(fitToWidth()));
|
||||
|
||||
adjustToFullSizeAction = new QAction(tr("Show full size"),this);
|
||||
adjustToFullSizeAction->setIcon(QIcon(":/images/viewer_toolbar/full.png"));
|
||||
adjustToFullSizeAction->setCheckable(false);
|
||||
adjustToFullSizeAction->setDisabled(true);
|
||||
adjustToFullSizeAction->setData(ADJUST_TO_FULL_SIZE_ACTION_Y);
|
||||
adjustToFullSizeAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ADJUST_TO_FULL_SIZE_ACTION_Y));
|
||||
adjustToFullSizeAction->setCheckable(true);
|
||||
connect(adjustToFullSizeAction,SIGNAL(triggered()),this,SLOT(adjustToFullSizeSwitch()));
|
||||
|
||||
fitToPageAction = new QAction(tr("Fit to page"),this);
|
||||
fitToPageAction->setIcon(QIcon(":/images/viewer_toolbar/fitToPage.png"));
|
||||
fitToPageAction->setDisabled(true);
|
||||
fitToPageAction->setData(FIT_TO_PAGE_ACTION_Y);
|
||||
fitToPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(FIT_TO_PAGE_ACTION_Y));
|
||||
fitToPageAction->setCheckable(true);
|
||||
connect(fitToPageAction,SIGNAL(triggered()),this,SLOT(fitToPageSwitch()));
|
||||
|
||||
//fit modes have to be exclusive and checkable
|
||||
QActionGroup *fitModes = new QActionGroup(this);
|
||||
fitModes->addAction(adjustHeightAction);
|
||||
fitModes->addAction(adjustWidthAction);
|
||||
fitModes->addAction(adjustToFullSizeAction);
|
||||
fitModes->addAction(fitToPageAction);
|
||||
|
||||
switch(Configuration::getConfiguration().getFitMode())
|
||||
{
|
||||
case YACReader::FitMode::ToWidth:
|
||||
adjustWidthAction->setChecked(true);
|
||||
break;
|
||||
case YACReader::FitMode::ToHeight:
|
||||
adjustHeightAction->setChecked(true);
|
||||
break;
|
||||
case YACReader::FitMode::FullRes:
|
||||
adjustToFullSizeAction->setChecked(true);
|
||||
break;
|
||||
case YACReader::FitMode::FullPage:
|
||||
fitToPageAction->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
fitToPageAction->setChecked(true);
|
||||
}
|
||||
|
||||
resetZoomAction = new QAction(tr("Reset zoom"), this);
|
||||
resetZoomAction->setDisabled(true);
|
||||
resetZoomAction->setData(RESET_ZOOM_ACTION_Y);
|
||||
resetZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(RESET_ZOOM_ACTION_Y));
|
||||
connect(resetZoomAction,SIGNAL(triggered()),this,SLOT(resetZoomLevel()));
|
||||
|
||||
showZoomSliderlAction = new QAction(tr("Show zoom slider"), this);
|
||||
showZoomSliderlAction->setIcon(QIcon(":/images/viewer_toolbar/zoom.png"));
|
||||
showZoomSliderlAction->setDisabled(true);
|
||||
|
||||
increasePageZoomAction = new QAction(tr("Zoom+"),this);
|
||||
increasePageZoomAction->setDisabled(true);
|
||||
increasePageZoomAction->setData(ZOOM_PLUS_ACTION_Y);
|
||||
increasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_PLUS_ACTION_Y));
|
||||
connect(increasePageZoomAction,SIGNAL(triggered()),this,SLOT(increasePageZoomLevel()));
|
||||
|
||||
decreasePageZoomAction = new QAction(tr("Zoom-"),this);
|
||||
decreasePageZoomAction->setDisabled(true);
|
||||
decreasePageZoomAction->setData(ZOOM_MINUS_ACTION_Y);
|
||||
decreasePageZoomAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(ZOOM_MINUS_ACTION_Y));
|
||||
connect(decreasePageZoomAction,SIGNAL(triggered()),this,SLOT(decreasePageZoomLevel()));
|
||||
|
||||
leftRotationAction = new QAction(tr("Rotate image to the left"),this);
|
||||
leftRotationAction->setIcon(QIcon(":/images/viewer_toolbar/rotateL.png"));
|
||||
leftRotationAction->setDisabled(true);
|
||||
@ -295,7 +362,7 @@ void MainWindowViewer::createActions()
|
||||
|
||||
doublePageAction = new QAction(tr("Double page mode"),this);
|
||||
doublePageAction->setToolTip(tr("Switch to double page mode"));
|
||||
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
|
||||
doublePageAction->setIcon(QIcon(":/images/viewer_toolbar/doublePage.png"));
|
||||
doublePageAction->setDisabled(true);
|
||||
doublePageAction->setCheckable(true);
|
||||
doublePageAction->setChecked(Configuration::getConfiguration().getDoublePage());
|
||||
@ -310,8 +377,8 @@ void MainWindowViewer::createActions()
|
||||
doubleMangaPageAction->setDisabled(true);
|
||||
doubleMangaPageAction->setCheckable(true);
|
||||
doubleMangaPageAction->setChecked(Configuration::getConfiguration().getDoubleMangaPage());
|
||||
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
|
||||
doubleMangaPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_MANGA_PAGE_ACTION_Y));
|
||||
doubleMangaPageAction->setData(DOUBLE_MANGA_PAGE_ACTION_Y);
|
||||
doubleMangaPageAction->setShortcut(ShortcutsManager::getShortcutsManager().getShortcut(DOUBLE_MANGA_PAGE_ACTION_Y));
|
||||
connect(doubleMangaPageAction, SIGNAL(triggered()),viewer,SLOT(doubleMangaPageSwitch()));
|
||||
|
||||
goToPageAction = new QAction(tr("Go To"),this);
|
||||
@ -403,15 +470,6 @@ void MainWindowViewer::createActions()
|
||||
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->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->setIcon(QIcon(":/images/viewer_toolbar/flow.png"));
|
||||
showFlowAction->setDisabled(true);
|
||||
@ -462,69 +520,22 @@ void MainWindowViewer::createToolBars()
|
||||
comicToolBar->addAction(nextAction);
|
||||
comicToolBar->addAction(goToPageAction);
|
||||
|
||||
//#ifndef Q_OS_MAC
|
||||
// comicToolBar->addSeparator();
|
||||
// comicToolBar->addAction(alwaysOnTopAction);
|
||||
//#else
|
||||
// alwaysOnTopAction->setEnabled(false);
|
||||
//#endif
|
||||
|
||||
|
||||
comicToolBar->addSeparator();
|
||||
|
||||
//QWidget * widget = new QWidget();
|
||||
|
||||
//QToolButton * tbW = new QToolButton(widget);
|
||||
//tbW->addAction(adjustWidth);
|
||||
//tbW->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
//tbW->setDefaultAction(adjustWidth);
|
||||
|
||||
//QHBoxLayout *layout = new QHBoxLayout;
|
||||
//layout->addWidget(tbW);
|
||||
//layout->setContentsMargins(0,0,0,0);
|
||||
//widget->setLayout(layout);
|
||||
//widget->setContentsMargins(0,0,0,0);
|
||||
|
||||
//comicToolBar->addWidget(widget);
|
||||
|
||||
//comicToolBar->addAction(adjustWidth);
|
||||
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
|
||||
sliderAction = new YACReaderSlider(this);
|
||||
sliderAction->hide();
|
||||
|
||||
comicToolBar->addAction(adjustWidthAction);
|
||||
|
||||
QAction * action = comicToolBar->addFitToWidthSlider(adjustWidthAction);
|
||||
|
||||
connect(action,SIGNAL(triggered()),this,SLOT(toggleFitToWidthSlider()));
|
||||
|
||||
#else
|
||||
QMenu * menu = new QMenu();
|
||||
|
||||
sliderAction = new YACReaderSliderAction(this);
|
||||
|
||||
menu->setAutoFillBackground(false);
|
||||
menu->setStyleSheet(" QMenu {background:transparent; border: 0px;padding: 0px; }"
|
||||
);
|
||||
menu->addAction(sliderAction);
|
||||
QToolButton * tb2 = new QToolButton();
|
||||
tb2->addAction(adjustWidthAction);
|
||||
tb2->setMenu(menu);
|
||||
|
||||
//tb2->addAction();
|
||||
tb2->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
tb2->setDefaultAction(adjustWidthAction);
|
||||
comicToolBar->addWidget(tb2);
|
||||
#endif
|
||||
|
||||
connect(sliderAction,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
||||
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),sliderAction,SLOT(updateFitToWidthRatio(float)));
|
||||
|
||||
comicToolBar->addAction(adjustHeightAction);
|
||||
comicToolBar->addAction(adjustWidthAction);
|
||||
comicToolBar->addAction(adjustHeightAction);
|
||||
comicToolBar->addAction(adjustToFullSizeAction);
|
||||
comicToolBar->addAction(fitToPageAction);
|
||||
|
||||
zoomSliderAction = new YACReaderSlider(this);
|
||||
zoomSliderAction->hide();
|
||||
|
||||
comicToolBar->addAction(showZoomSliderlAction);
|
||||
|
||||
connect(showZoomSliderlAction,SIGNAL(triggered()),this,SLOT(toggleFitToWidthSlider()));
|
||||
connect(zoomSliderAction, SIGNAL(zoomRatioChanged(int)),viewer,SLOT(updateZoomRatio(int)));
|
||||
connect(viewer,SIGNAL(zoomUpdated(int)),zoomSliderAction,SLOT(updateZoomRatio(int)));
|
||||
|
||||
comicToolBar->addAction(leftRotationAction);
|
||||
comicToolBar->addAction(rightRotationAction);
|
||||
comicToolBar->addAction(doublePageAction);
|
||||
@ -534,7 +545,6 @@ void MainWindowViewer::createToolBars()
|
||||
|
||||
comicToolBar->addAction(showMagnifyingGlassAction);
|
||||
|
||||
|
||||
comicToolBar->addSeparator();
|
||||
|
||||
comicToolBar->addAction(setBookmarkAction);
|
||||
@ -575,6 +585,7 @@ void MainWindowViewer::createToolBars()
|
||||
viewer->addAction(adjustHeightAction);
|
||||
viewer->addAction(adjustWidthAction);
|
||||
viewer->addAction(adjustToFullSizeAction);
|
||||
viewer->addAction(fitToPageAction);
|
||||
viewer->addAction(leftRotationAction);
|
||||
viewer->addAction(rightRotationAction);
|
||||
viewer->addAction(doublePageAction);
|
||||
@ -582,6 +593,9 @@ void MainWindowViewer::createToolBars()
|
||||
YACReader::addSperator(viewer);
|
||||
|
||||
viewer->addAction(showMagnifyingGlassAction);
|
||||
viewer->addAction(increasePageZoomAction);
|
||||
viewer->addAction(decreasePageZoomAction);
|
||||
viewer->addAction(resetZoomAction);
|
||||
YACReader::addSperator(viewer);
|
||||
|
||||
viewer->addAction(setBookmarkAction);
|
||||
@ -824,6 +838,12 @@ void MainWindowViewer::enableActions()
|
||||
doublePageAction->setDisabled(false);
|
||||
doubleMangaPageAction->setDisabled(false);
|
||||
adjustToFullSizeAction->setDisabled(false);
|
||||
adjustToFullSizeAction->setDisabled(false);
|
||||
fitToPageAction->setDisabled(false);
|
||||
showZoomSliderlAction->setDisabled(false);
|
||||
increasePageZoomAction->setDisabled(false);
|
||||
decreasePageZoomAction->setDisabled(false);
|
||||
resetZoomAction->setDisabled(false);
|
||||
//setBookmark->setDisabled(false);
|
||||
showBookmarksAction->setDisabled(false);
|
||||
showInfoAction->setDisabled(false); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
@ -845,6 +865,11 @@ void MainWindowViewer::disableActions()
|
||||
doublePageAction->setDisabled(true);
|
||||
doubleMangaPageAction->setDisabled(true);
|
||||
adjustToFullSizeAction->setDisabled(true);
|
||||
fitToPageAction->setDisabled(true);
|
||||
showZoomSliderlAction->setDisabled(true);
|
||||
increasePageZoomAction->setDisabled(true);
|
||||
decreasePageZoomAction->setDisabled(true);
|
||||
resetZoomAction->setDisabled(true);
|
||||
setBookmarkAction->setDisabled(true);
|
||||
showBookmarksAction->setDisabled(true);
|
||||
showInfoAction->setDisabled(true); //TODO enable goTo and showInfo (or update) when numPages emited
|
||||
@ -881,11 +906,6 @@ void MainWindowViewer::keyPressEvent(QKeyEvent *event)
|
||||
toggleToolBars();
|
||||
event->accept();
|
||||
}
|
||||
else if (key == ShortcutsManager::getShortcutsManager().getShortcut(CHANGE_FIT_ACTION_Y))
|
||||
{
|
||||
changeFit();
|
||||
event->accept();
|
||||
}
|
||||
else
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
@ -956,21 +976,15 @@ void MainWindowViewer::showToolBars()
|
||||
}
|
||||
void MainWindowViewer::fitToWidth()
|
||||
{
|
||||
Configuration & conf = Configuration::getConfiguration();
|
||||
if(!conf.getAdjustToWidth())
|
||||
{
|
||||
conf.setAdjustToWidth(true);
|
||||
viewer->updatePage();
|
||||
}
|
||||
Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToWidth);
|
||||
viewer->setZoomFactor(100);
|
||||
viewer->updatePage();
|
||||
}
|
||||
void MainWindowViewer::fitToHeight()
|
||||
{
|
||||
Configuration & conf = Configuration::getConfiguration();
|
||||
if(conf.getAdjustToWidth())
|
||||
{
|
||||
conf.setAdjustToWidth(false);
|
||||
viewer->updatePage();
|
||||
}
|
||||
Configuration::getConfiguration().setFitMode(YACReader::FitMode::ToHeight);
|
||||
viewer->setZoomFactor(100);
|
||||
viewer->updatePage();
|
||||
}
|
||||
|
||||
void MainWindowViewer::checkNewVersion()
|
||||
@ -1097,8 +1111,11 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
<< leftRotationAction
|
||||
<< rightRotationAction
|
||||
<< doublePageAction
|
||||
<< doubleMangaPageAction
|
||||
<< adjustToFullSizeAction);
|
||||
<< doubleMangaPageAction
|
||||
<< adjustToFullSizeAction
|
||||
<< increasePageZoomAction
|
||||
<< decreasePageZoomAction
|
||||
<< resetZoomAction);
|
||||
|
||||
allActions << tmpList;
|
||||
|
||||
@ -1156,27 +1173,26 @@ void MainWindowViewer::setUpShortcutsManagement()
|
||||
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void MainWindowViewer::toggleFitToWidthSlider()
|
||||
{
|
||||
if(sliderAction->isVisible())
|
||||
int y;
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
y = 0;
|
||||
#else
|
||||
y = this->comicToolBar->frameSize().height();
|
||||
#endif
|
||||
|
||||
if(zoomSliderAction->isVisible())
|
||||
{
|
||||
sliderAction->hide();
|
||||
zoomSliderAction->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
sliderAction->move(250,0);
|
||||
sliderAction->show();
|
||||
zoomSliderAction->move(250, y);
|
||||
zoomSliderAction->show();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindowViewer::changeFit()
|
||||
{
|
||||
Configuration & conf = Configuration::getConfiguration();
|
||||
conf.setAdjustToWidth(!conf.getAdjustToWidth());
|
||||
viewer->updatePage();
|
||||
}
|
||||
|
||||
void MainWindowViewer::newVersion()
|
||||
{
|
||||
@ -1383,10 +1399,34 @@ void MainWindowViewer::alwaysOnTopSwitch()
|
||||
|
||||
void MainWindowViewer::adjustToFullSizeSwitch()
|
||||
{
|
||||
Configuration::getConfiguration().setAdjustToFullSize(!Configuration::getConfiguration().getAdjustToFullSize());
|
||||
Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullRes);
|
||||
viewer->setZoomFactor(100);
|
||||
viewer->updatePage();
|
||||
}
|
||||
|
||||
void MainWindowViewer::fitToPageSwitch()
|
||||
{
|
||||
Configuration::getConfiguration().setFitMode(YACReader::FitMode::FullPage);
|
||||
viewer->setZoomFactor(100);
|
||||
viewer->updatePage();
|
||||
}
|
||||
|
||||
void MainWindowViewer::resetZoomLevel()
|
||||
{
|
||||
viewer->setZoomFactor(100);
|
||||
viewer->updatePage();
|
||||
}
|
||||
|
||||
void MainWindowViewer::increasePageZoomLevel()
|
||||
{
|
||||
viewer->increaseZoomFactor();
|
||||
}
|
||||
|
||||
void MainWindowViewer::decreasePageZoomLevel()
|
||||
{
|
||||
viewer->decreaseZoomFactor();
|
||||
}
|
||||
|
||||
void MainWindowViewer::sendComic()
|
||||
{
|
||||
YACReaderLocalClient * client = new YACReaderLocalClient;
|
||||
|
@ -38,7 +38,6 @@ class EditShortcutsDialog;
|
||||
void toggleToolBars();
|
||||
void hideToolBars();
|
||||
void showToolBars();
|
||||
void changeFit();
|
||||
void enableActions();
|
||||
void disableActions();
|
||||
void toggleFullScreen();
|
||||
@ -55,6 +54,10 @@ class EditShortcutsDialog;
|
||||
void openFolderFromPath(QString pathFile, QString atFileName);
|
||||
void alwaysOnTopSwitch();
|
||||
void adjustToFullSizeSwitch();
|
||||
void fitToPageSwitch();
|
||||
void resetZoomLevel();
|
||||
void increasePageZoomLevel();
|
||||
void decreasePageZoomLevel();
|
||||
void reloadOptions();
|
||||
void fitToWidth();
|
||||
void fitToHeight();
|
||||
@ -62,9 +65,8 @@ class EditShortcutsDialog;
|
||||
void processReset();
|
||||
void setUpShortcutsManagement();
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
void toggleFitToWidthSlider();
|
||||
#endif
|
||||
|
||||
/*void viewComic();
|
||||
void prev();
|
||||
void next();
|
||||
@ -125,14 +127,16 @@ class EditShortcutsDialog;
|
||||
QAction *showDictionaryAction;
|
||||
QAction *alwaysOnTopAction;
|
||||
QAction *adjustToFullSizeAction;
|
||||
QAction *fitToPageAction;
|
||||
QAction *resetZoomAction;
|
||||
QAction *showZoomSliderlAction;
|
||||
QAction *increasePageZoomAction;
|
||||
QAction *decreasePageZoomAction;
|
||||
QAction *showFlowAction;
|
||||
|
||||
QAction *showEditShortcutsAction;
|
||||
#ifdef Q_OS_MAC
|
||||
YACReaderSlider * sliderAction;
|
||||
#else
|
||||
YACReaderSliderAction * sliderAction;
|
||||
#endif
|
||||
|
||||
YACReaderSlider * zoomSliderAction;
|
||||
|
||||
HttpVersionChecker * versionChecker;
|
||||
QString previousComicPath;
|
||||
|
@ -55,7 +55,7 @@ OptionsDialog::OptionsDialog(QWidget * parent)
|
||||
connect(pathFindButton,SIGNAL(clicked()),this,SLOT(findFolder()));
|
||||
|
||||
//fitToWidthRatioLabel = new QLabel(tr("Page width stretch"),this);
|
||||
QGroupBox *fitBox = new QGroupBox(tr("Page width stretch"));
|
||||
/*QGroupBox *fitBox = new QGroupBox(tr("Page width stretch"));
|
||||
fitToWidthRatioS = new QSlider(this);
|
||||
fitToWidthRatioS->setMinimum(50);
|
||||
fitToWidthRatioS->setMaximum(100);
|
||||
@ -64,7 +64,7 @@ OptionsDialog::OptionsDialog(QWidget * parent)
|
||||
//connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
|
||||
QHBoxLayout * fitLayout = new QHBoxLayout;
|
||||
fitLayout->addWidget(fitToWidthRatioS);
|
||||
fitBox->setLayout(fitLayout);
|
||||
fitBox->setLayout(fitLayout);*/
|
||||
|
||||
QHBoxLayout * colorSelection = new QHBoxLayout;
|
||||
backgroundColor = new QLabel();
|
||||
@ -113,7 +113,7 @@ OptionsDialog::OptionsDialog(QWidget * parent)
|
||||
|
||||
layoutGeneral->addWidget(pathBox);
|
||||
layoutGeneral->addWidget(slideSizeBox);
|
||||
layoutGeneral->addWidget(fitBox);
|
||||
//layoutGeneral->addWidget(fitBox);
|
||||
layoutGeneral->addWidget(colorBox);
|
||||
layoutGeneral->addWidget(shortcutsBox);
|
||||
layoutGeneral->addStretch();
|
||||
@ -190,7 +190,7 @@ void OptionsDialog::saveOptions()
|
||||
settings->setValue(PATH,pathEdit->text());
|
||||
|
||||
settings->setValue(BACKGROUND_COLOR,colorDialog->currentColor());
|
||||
settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0);
|
||||
//settings->setValue(FIT_TO_WIDTH_RATIO,fitToWidthRatioS->sliderPosition()/100.0);
|
||||
|
||||
YACReaderOptionsDialog::saveOptions();
|
||||
}
|
||||
@ -219,7 +219,7 @@ void OptionsDialog::restoreOptions(QSettings * settings)
|
||||
pathEdit->setText(settings->value(PATH).toString());
|
||||
|
||||
updateColor(settings->value(BACKGROUND_COLOR).value<QColor>());
|
||||
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
||||
//fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
||||
|
||||
brightnessS->setValue(settings->value(BRIGHTNESS,0).toInt());
|
||||
contrastS->setValue(settings->value(CONTRAST,100).toInt());
|
||||
@ -240,11 +240,11 @@ void OptionsDialog::updateColor(const QColor & color)
|
||||
emit(changedOptions());
|
||||
}
|
||||
|
||||
void OptionsDialog::fitToWidthRatio(int value)
|
||||
/*void OptionsDialog::fitToWidthRatio(int value)
|
||||
{
|
||||
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
|
||||
emit(fitToWidthRatioChanged(value/100.0));
|
||||
}
|
||||
}*/
|
||||
|
||||
void OptionsDialog::brightnessChanged(int value)
|
||||
{
|
||||
@ -287,9 +287,9 @@ void OptionsDialog::show()
|
||||
{
|
||||
//TODO solucionar el tema de las settings, esto sólo debería aparecer en una única línea de código
|
||||
QSettings *s = new QSettings(YACReader::getSettingsPath()+"/YACReader.ini",QSettings::IniFormat);
|
||||
fitToWidthRatioS->disconnect();
|
||||
fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
||||
connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
|
||||
//fitToWidthRatioS->disconnect();
|
||||
//fitToWidthRatioS->setSliderPosition(settings->value(FIT_TO_WIDTH_RATIO).toFloat()*100);
|
||||
//connect(fitToWidthRatioS,SIGNAL(valueChanged(int)),this,SLOT(fitToWidthRatio(int)));
|
||||
QDialog::show();
|
||||
delete s;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ Q_OBJECT
|
||||
QSlider * slideSize;
|
||||
|
||||
//QLabel * fitToWidthRatioLabel;
|
||||
QSlider * fitToWidthRatioS;
|
||||
//QSlider * fitToWidthRatioS;
|
||||
|
||||
QLabel * backgroundColor;
|
||||
QPushButton * selectBackgroundColorButton;
|
||||
@ -50,7 +50,7 @@ Q_OBJECT
|
||||
void restoreOptions(QSettings * settings);
|
||||
void findFolder();
|
||||
void updateColor(const QColor & color);
|
||||
void fitToWidthRatio(int value);
|
||||
//void fitToWidthRatio(int value);
|
||||
void brightnessChanged(int value);
|
||||
void contrastChanged(int value);
|
||||
void gammaChanged(int value);
|
||||
@ -62,7 +62,7 @@ signals:
|
||||
void changedOptions();
|
||||
void changedImageOptions();
|
||||
void changedFilters(int brightness, int contrast, int gamma);
|
||||
void fitToWidthRatioChanged(float ratio);
|
||||
//void fitToWidthRatioChanged(float ratio);
|
||||
|
||||
};
|
||||
|
||||
|
@ -38,7 +38,8 @@ restoreMagnifyingGlass(false),
|
||||
drag(false),
|
||||
numScrollSteps(22),
|
||||
shouldOpenNext(false),
|
||||
shouldOpenPrevious(false)
|
||||
shouldOpenPrevious(false),
|
||||
zoom(100)
|
||||
{
|
||||
translator = new YACReaderTranslator(this);
|
||||
translator->hide();
|
||||
@ -328,47 +329,89 @@ void Viewer::updateContentSize()
|
||||
//there is an image to resize
|
||||
if(currentPage !=0 && !currentPage->isNull())
|
||||
{
|
||||
if(Configuration::getConfiguration().getAdjustToFullSize())
|
||||
QSize pagefit;
|
||||
YACReader::FitMode fitmode = Configuration::getConfiguration().getFitMode();
|
||||
switch (fitmode)
|
||||
{
|
||||
content->resize(currentPage->width(),currentPage->height());
|
||||
case YACReader::FitMode::FullRes:
|
||||
pagefit=currentPage->size();
|
||||
break;
|
||||
case YACReader::FitMode::ToWidth:
|
||||
pagefit=currentPage->size();
|
||||
pagefit.scale(width(), 0, Qt::KeepAspectRatioByExpanding);
|
||||
break;
|
||||
case YACReader::FitMode::ToHeight:
|
||||
pagefit=currentPage->size();
|
||||
pagefit.scale(0, height(), Qt::KeepAspectRatioByExpanding);
|
||||
break;
|
||||
//if everything fails showing the full page is a good idea
|
||||
case YACReader::FitMode::FullPage:
|
||||
default:
|
||||
pagefit=currentPage->size();
|
||||
pagefit.scale(size(), Qt::KeepAspectRatio);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
if(zoom != 100)
|
||||
{
|
||||
pagefit.scale(floor(pagefit.width()*zoom/100.0f), 0, Qt::KeepAspectRatioByExpanding);
|
||||
}
|
||||
//apply scaling
|
||||
content->resize(pagefit);
|
||||
|
||||
//TODO: updtateContentSize should only scale the pixmap once
|
||||
if(devicePixelRatio()>1)//only in retina display
|
||||
{
|
||||
float aspectRatio = (float)currentPage->width()/currentPage->height();
|
||||
//Fit to width
|
||||
if(Configuration::getConfiguration().getAdjustToWidth())
|
||||
{
|
||||
adjustToWidthRatio = Configuration::getConfiguration().getFitToWidthRatio();
|
||||
if(static_cast<int>(width()*adjustToWidthRatio/aspectRatio)<height())
|
||||
if(static_cast<int>(height()*aspectRatio)>width())
|
||||
content->resize(width(),static_cast<int>(width()/aspectRatio));
|
||||
else
|
||||
content->resize(static_cast<int>(height()*aspectRatio),height());
|
||||
else
|
||||
content->resize(width()*adjustToWidthRatio,static_cast<int>(width()*adjustToWidthRatio/aspectRatio));
|
||||
}
|
||||
//Fit to height or fullsize/custom size
|
||||
else
|
||||
{
|
||||
if(static_cast<int>(height()*aspectRatio)>width()) //page width exceeds window width
|
||||
content->resize(width(),static_cast<int>(width()/aspectRatio));
|
||||
else
|
||||
content->resize(static_cast<int>(height()*aspectRatio),height());
|
||||
}
|
||||
QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
page.setDevicePixelRatio(devicePixelRatio());
|
||||
content->setPixmap(page);
|
||||
}
|
||||
|
||||
if(devicePixelRatio()>1)//only in retina display
|
||||
{
|
||||
QPixmap page = currentPage->scaled(content->width()*devicePixelRatio(), content->height()*devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
page.setDevicePixelRatio(devicePixelRatio());
|
||||
content->setPixmap(page);
|
||||
}
|
||||
|
||||
emit backgroundChanges();
|
||||
}
|
||||
content->update(); //TODO, it shouldn't be neccesary
|
||||
}
|
||||
|
||||
void Viewer::increaseZoomFactor()
|
||||
{
|
||||
zoom = std::min(zoom + 10, 500);
|
||||
|
||||
updateContentSize();
|
||||
notificationsLabel->setText(QString::number(getZoomFactor())+"%");
|
||||
notificationsLabel->flash();
|
||||
|
||||
emit zoomUpdated(zoom);
|
||||
}
|
||||
void Viewer::decreaseZoomFactor()
|
||||
{
|
||||
zoom = std::max(zoom - 10, 30);
|
||||
|
||||
updateContentSize();
|
||||
notificationsLabel->setText(QString::number(getZoomFactor())+"%");
|
||||
notificationsLabel->flash();
|
||||
|
||||
emit zoomUpdated(zoom);
|
||||
}
|
||||
|
||||
int Viewer::getZoomFactor()
|
||||
{
|
||||
//this function is a placeholder for future refactoring work
|
||||
return zoom;
|
||||
}
|
||||
|
||||
void Viewer::setZoomFactor(int z)
|
||||
{
|
||||
//this function is mostly used to reset the zoom after a fitmode switch
|
||||
if (z > 500)
|
||||
zoom = 500;
|
||||
else if (z < 30)
|
||||
zoom = 30;
|
||||
else
|
||||
zoom = z;
|
||||
|
||||
emit zoomUpdated(zoom);
|
||||
}
|
||||
|
||||
void Viewer::updateVerticalScrollBar()
|
||||
{
|
||||
if(direction > 0)
|
||||
@ -888,11 +931,10 @@ void Viewer::mouseReleaseEvent ( QMouseEvent * event )
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void Viewer::updateFitToWidthRatio(float ratio)
|
||||
void Viewer::updateZoomRatio(int ratio)
|
||||
{
|
||||
Configuration::getConfiguration().setAdjustToWidth(true);
|
||||
adjustToWidthRatio = ratio;
|
||||
updateContentSize();
|
||||
zoom = ratio;
|
||||
updateContentSize();
|
||||
}
|
||||
|
||||
void Viewer::updateConfig(QSettings * settings)
|
||||
|
@ -37,6 +37,11 @@ class NotificationsLabelWidget;
|
||||
public:
|
||||
bool fullscreen; //TODO, change by the right use of windowState();
|
||||
public slots:
|
||||
void increaseZoomFactor();
|
||||
void decreaseZoomFactor();
|
||||
void setZoomFactor(int);
|
||||
int getZoomFactor();
|
||||
|
||||
void prepareForOpening();
|
||||
void open(QString pathFile, int atPage = -1);
|
||||
void open(QString pathFile, const ComicDB & comic);
|
||||
@ -80,7 +85,6 @@ class NotificationsLabelWidget;
|
||||
virtual void mousePressEvent ( QMouseEvent * event );
|
||||
virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
void updateBackgroundColor(const QColor & color);
|
||||
void updateFitToWidthRatio(float ratio);
|
||||
void updateConfig(QSettings * settings);
|
||||
void showMessageErrorOpening();
|
||||
void showMessageErrorOpening(QString);
|
||||
@ -92,11 +96,15 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
void showIsCoverMessage();
|
||||
void showIsLastMessage();
|
||||
int getCurrentPageNumber();
|
||||
void updateZoomRatio(int ratio);
|
||||
|
||||
private:
|
||||
bool information;
|
||||
bool doublePage;
|
||||
bool doubleMangaPage;
|
||||
|
||||
int zoom;
|
||||
|
||||
PageLabelWidget * informationLabel;
|
||||
//QTimer * scroller;
|
||||
QPropertyAnimation * verticalScroller;
|
||||
@ -163,6 +171,7 @@ virtual void mouseReleaseEvent ( QMouseEvent * event );
|
||||
void reset();
|
||||
void openNextComic();
|
||||
void openPreviousComic();
|
||||
void zoomUpdated(int);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,9 +1,7 @@
|
||||
#include "width_slider.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QtWidgets>
|
||||
|
||||
#include "configuration.h"
|
||||
|
||||
YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
|
||||
@ -12,9 +10,7 @@ YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
|
||||
widget = new YACReaderSlider();
|
||||
setDefaultWidget(widget);
|
||||
|
||||
connect(widget,SIGNAL(fitToWidthRatioChanged(float)),this,SIGNAL(fitToWidthRatioChanged(float)));
|
||||
|
||||
|
||||
connect(widget,SIGNAL(zoomRatioChanged(int)),this,SIGNAL(zoomRatioChanged(int)));
|
||||
}
|
||||
|
||||
void YACReaderSliderAction::updateText(int value)
|
||||
@ -22,73 +18,94 @@ void YACReaderSliderAction::updateText(int value)
|
||||
widget->updateText(value);
|
||||
}
|
||||
|
||||
void YACReaderSliderAction::updateFitToWidthRatio(float v)
|
||||
void YACReaderSliderAction::updateZoomRatio(int value)
|
||||
{
|
||||
widget->updateFitToWidthRatio(v);
|
||||
widget->updateZoomRatio(value);
|
||||
}
|
||||
|
||||
YACReaderSlider::YACReaderSlider(QWidget *parent)
|
||||
:QWidget(parent)
|
||||
{
|
||||
const int sliderWidth = 200;
|
||||
const int contentsMargin = 10;
|
||||
const int elementsSpacing = 10;
|
||||
const int percentageLabelWidth = 30;
|
||||
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
|
||||
QHBoxLayout* pLayout = new QHBoxLayout();
|
||||
|
||||
pLayout->addStretch();
|
||||
|
||||
percentageLabel = new QLabel ("100%");
|
||||
percentageLabel = new QLabel();
|
||||
percentageLabel->setStyleSheet("QLabel { color : white; }");
|
||||
percentageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||
pLayout->addWidget (percentageLabel);
|
||||
slider = new QSlider(NULL);
|
||||
percentageLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
slider = new QSlider();
|
||||
slider->setOrientation(Qt::Horizontal);
|
||||
pLayout->addWidget (slider);
|
||||
|
||||
QString sliderCSS =
|
||||
slider->setMinimumWidth(sliderWidth);
|
||||
|
||||
"QSlider::sub-page:horizontal {background-image: url(:/images/sliderSubPage.png); border: 0px; margin-left: 18px;}"
|
||||
"QSlider::add-page:horizontal {background-image: url(:/images/sliderAddPage.png); border: 0px; margin-right: 25px;}"
|
||||
"QSlider::handle:horizontal {image: url(:/images/sliderHandle.png); width: 31px;height:45px; }"
|
||||
"QSlider::groove:horizontal {border-image:url(:/images/sliderGround.png); border-left:-2px; border-right:0;}"
|
||||
;
|
||||
slider->setStyleSheet(sliderCSS);
|
||||
slider->setFixedSize(218,45);
|
||||
QPushButton *resetButton = new QPushButton(tr("Reset"));
|
||||
resetButton->setStyleSheet("QPushButton {border: 1px solid #BB242424; background: #BB2E2E2E; color:white; padding: 3px 5px 5px 5px; font-color: white}");
|
||||
connect(resetButton, &QPushButton::clicked, this, &YACReaderSlider::resetValueToDefault);
|
||||
|
||||
QLabel* imgLabel = new QLabel(this);
|
||||
QPixmap p(":/images/sliderBackground.png");
|
||||
imgLabel->resize(p.size());
|
||||
imgLabel->setPixmap(p);
|
||||
pLayout->addWidget(percentageLabel, 1, Qt::AlignHCenter);
|
||||
pLayout->addWidget(slider, 0, Qt::AlignHCenter | Qt::AlignBottom);
|
||||
pLayout->addWidget(resetButton, 1, Qt::AlignHCenter | Qt::AlignBottom);
|
||||
pLayout->setSpacing(elementsSpacing);
|
||||
|
||||
pLayout->setMargin(0);
|
||||
pLayout->setSpacing(0);
|
||||
|
||||
pLayout->setStretchFactor(percentageLabel,1);
|
||||
pLayout->setStretchFactor(slider,0);
|
||||
|
||||
|
||||
setLayout (pLayout);
|
||||
setAutoFillBackground(false);
|
||||
|
||||
setMinimumSize(276,45);
|
||||
setContentsMargins(contentsMargin,contentsMargin,contentsMargin,contentsMargin);
|
||||
setFixedSize(sliderWidth + 2 * contentsMargin + 2 * elementsSpacing + percentageLabelWidth + resetButton->sizeHint().width(), 45);
|
||||
|
||||
slider->setMinimum(50);
|
||||
slider->setMaximum(100);
|
||||
slider->setMinimum(30);
|
||||
slider->setMaximum(500);
|
||||
slider->setPageStep(5);
|
||||
|
||||
int value = Configuration::getConfiguration().getFitToWidthRatio()*100;
|
||||
slider->setValue(value);
|
||||
percentageLabel->setText(QString("%1 %").arg(value));
|
||||
connect(slider,SIGNAL(valueChanged(int)),this,SLOT(updateText(int)));
|
||||
slider->setFocusPolicy(Qt::NoFocus);
|
||||
resetButton->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
slider->setValue(100);
|
||||
percentageLabel->setText(QString("%1%").arg(100));
|
||||
connect(slider, &QSlider::valueChanged, this, &YACReaderSlider::updateText);
|
||||
}
|
||||
|
||||
void YACReaderSlider::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.fillRect(0,0,width(),height(),QColor("#BB000000"));
|
||||
}
|
||||
|
||||
void YACReaderSlider::show()
|
||||
{
|
||||
QWidget::show();
|
||||
setFocus();
|
||||
}
|
||||
|
||||
void YACReaderSlider::focusOutEvent(QFocusEvent * event)
|
||||
{
|
||||
QWidget::focusOutEvent(event);
|
||||
hide();
|
||||
}
|
||||
|
||||
void YACReaderSlider::updateText(int value)
|
||||
{
|
||||
percentageLabel->setText(QString("%1 %").arg(value));
|
||||
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
|
||||
emit(fitToWidthRatioChanged(value / 100.0f));
|
||||
percentageLabel->setText(QString("%1%").arg(value));
|
||||
emit zoomRatioChanged(value);
|
||||
}
|
||||
|
||||
void YACReaderSlider::updateFitToWidthRatio(float v)
|
||||
void YACReaderSlider::updateZoomRatio(int value)
|
||||
{
|
||||
int value = v*100;
|
||||
slider->setValue(value);
|
||||
percentageLabel->setText(QString("%1 %").arg(value));
|
||||
percentageLabel->setText(QString("%1%").arg(value));
|
||||
}
|
||||
|
||||
void YACReaderSlider::resetValueToDefault()
|
||||
{
|
||||
slider->setValue(100);
|
||||
}
|
||||
|
@ -14,16 +14,21 @@ private:
|
||||
QSlider * slider;
|
||||
|
||||
public:
|
||||
|
||||
YACReaderSlider (QWidget * parent = 0);
|
||||
void show();
|
||||
|
||||
protected:
|
||||
virtual void focusOutEvent(QFocusEvent * event);
|
||||
virtual void paintEvent(QPaintEvent *);
|
||||
|
||||
public slots:
|
||||
void updateText(int value);
|
||||
void updateFitToWidthRatio(float v);
|
||||
void updateZoomRatio(int value);
|
||||
void resetValueToDefault();
|
||||
|
||||
|
||||
signals:
|
||||
void fitToWidthRatioChanged(float value);
|
||||
void zoomRatioChanged(int value);
|
||||
};
|
||||
|
||||
class YACReaderSliderAction : public QWidgetAction
|
||||
@ -38,11 +43,11 @@ public:
|
||||
|
||||
public slots:
|
||||
void updateText(int value);
|
||||
void updateFitToWidthRatio(float v);
|
||||
void updateZoomRatio(int value);
|
||||
|
||||
|
||||
signals:
|
||||
void fitToWidthRatioChanged(float value);
|
||||
void zoomRatioChanged(int value);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -27,11 +27,6 @@
|
||||
<file>../images/imgGoToSlide.png</file>
|
||||
<file>../images/imgCenterSlidePressed.png</file>
|
||||
<file>../images/imgGoToSlidePressed.png</file>
|
||||
<file>../images/sliderBackground.png</file>
|
||||
<file>../images/sliderGround.png</file>
|
||||
<file>../images/sliderSubPage.png</file>
|
||||
<file>../images/sliderAddPage.png</file>
|
||||
<file>../images/sliderHandle.png</file>
|
||||
|
||||
<file>../images/helpImages/open.png</file>
|
||||
<file>../images/helpImages/openFolder.png</file>
|
||||
|
@ -8,6 +8,8 @@
|
||||
<file alias="images/viewer_toolbar/doubleMangaPage@2x.png">../images/viewer_toolbar/doubleMangaPage_osx@2x.png</file>
|
||||
<file alias="images/viewer_toolbar/doublePage.png">../images/viewer_toolbar/doublePage_osx.png</file>
|
||||
<file alias="images/viewer_toolbar/doublePage@2x.png">../images/viewer_toolbar/doublePage_osx@2x.png</file>
|
||||
<file alias="images/viewer_toolbar/fitToPage.png">../images/viewer_toolbar/fitToPage_osx.png</file>
|
||||
<file alias="images/viewer_toolbar/fitToPage@2x.png">../images/viewer_toolbar/fitToPage_osx@2x.png</file>
|
||||
<file alias="images/viewer_toolbar/flow.png">../images/viewer_toolbar/flow_osx.png</file>
|
||||
<file alias="images/viewer_toolbar/flow@2x.png">../images/viewer_toolbar/flow_osx@2x.png</file>
|
||||
<file alias="images/viewer_toolbar/full.png">../images/viewer_toolbar/full_osx.png</file>
|
||||
@ -52,6 +54,8 @@
|
||||
<file alias="images/viewer_toolbar/toWidthSlider@2x.png">../images/viewer_toolbar/toWidthSlider_osx@2x.png</file>
|
||||
<file alias="images/viewer_toolbar/translator.png">../images/viewer_toolbar/translator_osx.png</file>
|
||||
<file alias="images/viewer_toolbar/translator@2x.png">../images/viewer_toolbar/translator_osx@2x.png</file>
|
||||
<file alias="images/viewer_toolbar/zoom.png">../images/viewer_toolbar/zoom_osx.png</file>
|
||||
<file alias="images/viewer_toolbar/zoom@2x.png">../images/viewer_toolbar/zoom_osx@2x.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
<file>../images/viewer_toolbar/close.png</file>
|
||||
<file>../images/viewer_toolbar/doublePage.png</file>
|
||||
<file>../images/viewer_toolbar/doubleMangaPage.png</file>
|
||||
<file>../images/viewer_toolbar/fitToPage.png</file>
|
||||
<file>../images/viewer_toolbar/flow.png</file>
|
||||
<file>../images/viewer_toolbar/full.png</file>
|
||||
<file>../images/viewer_toolbar/goto.png</file>
|
||||
@ -25,5 +26,6 @@
|
||||
<file>../images/viewer_toolbar/toHeight.png</file>
|
||||
<file>../images/viewer_toolbar/toWidth.png</file>
|
||||
<file>../images/viewer_toolbar/translator.png</file>
|
||||
<file>../images/viewer_toolbar/zoom.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -12,22 +12,27 @@
|
||||
|
||||
#define VERSION "8.0.0"
|
||||
|
||||
//old fitmode defines
|
||||
/*
|
||||
#define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE"
|
||||
#define FIT "FIT"
|
||||
#define FIT_TO_WIDTH_RATIO "FIT_TO_WIDTH_RATIO"
|
||||
*/
|
||||
|
||||
#define PATH "PATH"
|
||||
#define MAG_GLASS_SIZE "MAG_GLASS_SIZE"
|
||||
#define ZOOM_LEVEL "ZOOM_LEVEL"
|
||||
#define SLIDE_SIZE "SLIDE_SIZE"
|
||||
#define GO_TO_FLOW_SIZE "GO_TO_FLOW_SIZE"
|
||||
#define FLOW_TYPE_SW "FLOW_TYPE_SW"
|
||||
#define FIT "FIT"
|
||||
#define FITMODE "FITMODE"
|
||||
#define FLOW_TYPE "FLOW_TYPE"
|
||||
#define FULLSCREEN "FULLSCREEN"
|
||||
#define FIT_TO_WIDTH_RATIO "FIT_TO_WIDTH_RATIO"
|
||||
#define Y_WINDOW_POS "POS"
|
||||
#define Y_WINDOW_SIZE "SIZE"
|
||||
#define MAXIMIZED "MAXIMIZED"
|
||||
#define DOUBLE_PAGE "DOUBLE_PAGE"
|
||||
#define DOUBLE_MANGA_PAGE "DOUBLE_MANGA_PAGE"
|
||||
#define ADJUST_TO_FULL_SIZE "ADJUST_TO_FULL_SIZE"
|
||||
#define BACKGROUND_COLOR "BACKGROUND_COLOR"
|
||||
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
|
||||
#define SHOW_TOOLBARS "SHOW_TOOLBARS"
|
||||
@ -132,6 +137,14 @@ static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/
|
||||
YLight,
|
||||
YDark
|
||||
};
|
||||
|
||||
enum FitMode{
|
||||
ToWidth=0x01,
|
||||
ToHeight=0x02,
|
||||
FullRes=0x03,
|
||||
FullPage=0x04//,
|
||||
//Text=0x05
|
||||
};
|
||||
|
||||
QString getSettingsPath();
|
||||
void addSperator(QWidget * w);
|
||||
|
@ -287,6 +287,7 @@ YACReaderMacOSXSearchLineEdit * YACReaderMacOSXToolbar::addSearchEdit()
|
||||
return searchEdit;
|
||||
}
|
||||
|
||||
//deprecated
|
||||
QAction *YACReaderMacOSXToolbar::addFitToWidthSlider(QAction *attachToAction)
|
||||
{
|
||||
QMacToolBarItem *toolBarItem = addItem(QIcon(":/images/viewer_toolbar/toWidthSlider.png"),"fit to width slider");
|
||||
|
Before Width: | Height: | Size: 186 B |
Before Width: | Height: | Size: 564 B |
Before Width: | Height: | Size: 951 B |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 185 B |
BIN
images/viewer_toolbar/fitToPage.png
Normal file
After Width: | Height: | Size: 205 B |
BIN
images/viewer_toolbar/fitToPage_osx.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
images/viewer_toolbar/fitToPage_osx@2x.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
images/viewer_toolbar/zoom.png
Normal file
After Width: | Height: | Size: 136 B |
BIN
images/viewer_toolbar/zoom_osx.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
images/viewer_toolbar/zoom_osx@2x.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
@ -52,6 +52,9 @@ void ShortcutsManager::initDefaultShorcuts()
|
||||
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);
|
||||
defaultShorcuts.insert(ZOOM_PLUS_ACTION_Y, Qt::Key_Plus);
|
||||
defaultShorcuts.insert(ZOOM_MINUS_ACTION_Y, Qt::Key_Minus);
|
||||
defaultShorcuts.insert(RESET_ZOOM_ACTION_Y, Qt::CTRL | Qt::Key_0);
|
||||
|
||||
//main_window_viewer
|
||||
defaultShorcuts.insert(TOGGLE_FULL_SCREEN_ACTION_Y, Qt::Key_F);
|
||||
|
@ -110,6 +110,7 @@ public:
|
||||
#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 FIT_TO_PAGE_ACTION_Y "FIT_TO_PAGE_ACTION_Y"
|
||||
#define SHOW_FLOW_ACTION_Y "SHOW_FLOW_ACTION_Y"
|
||||
#define SHOW_EDIT_SHORTCUTS_ACTION_Y "SHOW_EDIT_SHORTCUTS_ACTION_Y"
|
||||
|
||||
@ -118,6 +119,9 @@ public:
|
||||
#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"
|
||||
#define ZOOM_PLUS_ACTION_Y "ZOOM_PLUS_ACTION_Y"
|
||||
#define ZOOM_MINUS_ACTION_Y "ZOOM_MINUS_ACTION_Y"
|
||||
#define RESET_ZOOM_ACTION_Y "RESET_ZOOM_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"
|
||||
|