mirror of
https://github.com/YACReader/yacreader
synced 2025-07-19 21:44:43 -04:00
brough back to MacOSX the fit to width slider //ugly solution
This commit is contained in:
@ -488,13 +488,23 @@ void MainWindowViewer::createToolBars()
|
|||||||
|
|
||||||
//comicToolBar->addAction(adjustWidth);
|
//comicToolBar->addAction(adjustWidth);
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
|
||||||
|
sliderAction = new YACReaderSlider(this);
|
||||||
|
sliderAction->hide();
|
||||||
|
|
||||||
comicToolBar->addAction(adjustWidthAction);
|
comicToolBar->addAction(adjustWidthAction);
|
||||||
|
|
||||||
|
QAction * action = comicToolBar->addFitToWidthSlider(adjustWidthAction);
|
||||||
|
|
||||||
|
connect(action,SIGNAL(triggered()),this,SLOT(toggleFitToWidthSlider()));
|
||||||
|
|
||||||
#else
|
#else
|
||||||
QMenu * menu = new QMenu();
|
QMenu * menu = new QMenu();
|
||||||
sliderAction = new YACReaderSliderAction(this);
|
|
||||||
|
sliderAction = new YACReaderSliderAction(this);
|
||||||
|
|
||||||
menu->setAutoFillBackground(false);
|
menu->setAutoFillBackground(false);
|
||||||
menu->setStyleSheet(" QMenu {background:transparent; border: 0px;padding: 0px; }"
|
menu->setStyleSheet(" QMenu {background:transparent; border: 0px;padding: 0px; }"
|
||||||
);
|
);
|
||||||
@ -503,16 +513,15 @@ void MainWindowViewer::createToolBars()
|
|||||||
tb2->addAction(adjustWidthAction);
|
tb2->addAction(adjustWidthAction);
|
||||||
tb2->setMenu(menu);
|
tb2->setMenu(menu);
|
||||||
|
|
||||||
connect(sliderAction,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
|
||||||
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),sliderAction,SLOT(updateFitToWidthRatio(float)));
|
|
||||||
|
|
||||||
|
|
||||||
//tb2->addAction();
|
//tb2->addAction();
|
||||||
tb2->setPopupMode(QToolButton::MenuButtonPopup);
|
tb2->setPopupMode(QToolButton::MenuButtonPopup);
|
||||||
tb2->setDefaultAction(adjustWidthAction);
|
tb2->setDefaultAction(adjustWidthAction);
|
||||||
comicToolBar->addWidget(tb2);
|
comicToolBar->addWidget(tb2);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
connect(sliderAction,SIGNAL(fitToWidthRatioChanged(float)),viewer,SLOT(updateFitToWidthRatio(float)));
|
||||||
|
connect(optionsDialog,SIGNAL(fitToWidthRatioChanged(float)),sliderAction,SLOT(updateFitToWidthRatio(float)));
|
||||||
|
|
||||||
comicToolBar->addAction(adjustHeightAction);
|
comicToolBar->addAction(adjustHeightAction);
|
||||||
comicToolBar->addAction(adjustToFullSizeAction);
|
comicToolBar->addAction(adjustToFullSizeAction);
|
||||||
comicToolBar->addAction(leftRotationAction);
|
comicToolBar->addAction(leftRotationAction);
|
||||||
@ -1129,6 +1138,20 @@ void MainWindowViewer::setUpShortcutsManagement()
|
|||||||
|
|
||||||
ShortcutsManager::getShortcutsManager().registerActions(allActions);
|
ShortcutsManager::getShortcutsManager().registerActions(allActions);
|
||||||
|
|
||||||
|
}
|
||||||
|
#include "QsLog.h"
|
||||||
|
void MainWindowViewer::toggleFitToWidthSlider()
|
||||||
|
{
|
||||||
|
if(sliderAction->isVisible())
|
||||||
|
{
|
||||||
|
sliderAction->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sliderAction->move(250,0);
|
||||||
|
sliderAction->show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowViewer::changeFit()
|
void MainWindowViewer::changeFit()
|
||||||
|
@ -22,6 +22,7 @@ class HelpAboutDialog;
|
|||||||
class HttpVersionChecker;
|
class HttpVersionChecker;
|
||||||
class ShortcutsDialog;
|
class ShortcutsDialog;
|
||||||
class YACReaderSliderAction;
|
class YACReaderSliderAction;
|
||||||
|
class YACReaderSlider;
|
||||||
class EditShortcutsDialog;
|
class EditShortcutsDialog;
|
||||||
|
|
||||||
class MainWindowViewer : public QMainWindow
|
class MainWindowViewer : public QMainWindow
|
||||||
@ -58,6 +59,10 @@ class EditShortcutsDialog;
|
|||||||
void checkNewVersion();
|
void checkNewVersion();
|
||||||
void processReset();
|
void processReset();
|
||||||
void setUpShortcutsManagement();
|
void setUpShortcutsManagement();
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
void toggleFitToWidthSlider();
|
||||||
|
#endif
|
||||||
/*void viewComic();
|
/*void viewComic();
|
||||||
void prev();
|
void prev();
|
||||||
void next();
|
void next();
|
||||||
@ -73,7 +78,7 @@ class EditShortcutsDialog;
|
|||||||
QString currentDirectory;
|
QString currentDirectory;
|
||||||
QString currentDirectoryImgDest;
|
QString currentDirectoryImgDest;
|
||||||
//!Widgets
|
//!Widgets
|
||||||
Viewer * viewer;
|
Viewer * viewer;
|
||||||
//GoToDialog * goToDialog;
|
//GoToDialog * goToDialog;
|
||||||
OptionsDialog * optionsDialog;
|
OptionsDialog * optionsDialog;
|
||||||
HelpAboutDialog * had;
|
HelpAboutDialog * had;
|
||||||
@ -116,8 +121,11 @@ class EditShortcutsDialog;
|
|||||||
QAction *showFlowAction;
|
QAction *showFlowAction;
|
||||||
|
|
||||||
QAction *showEditShortcutsAction;
|
QAction *showEditShortcutsAction;
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
YACReaderSliderAction * sliderAction;
|
YACReaderSlider * sliderAction;
|
||||||
|
#else
|
||||||
|
YACReaderSliderAction * sliderAction;
|
||||||
|
#endif
|
||||||
|
|
||||||
HttpVersionChecker * versionChecker;
|
HttpVersionChecker * versionChecker;
|
||||||
QString previousComicPath;
|
QString previousComicPath;
|
||||||
|
@ -9,70 +9,86 @@
|
|||||||
YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
|
YACReaderSliderAction::YACReaderSliderAction (QWidget * parent)
|
||||||
:QWidgetAction (parent) {
|
:QWidgetAction (parent) {
|
||||||
|
|
||||||
QWidget* pWidget = new QWidget (NULL);
|
widget = new YACReaderSlider();
|
||||||
QHBoxLayout* pLayout = new QHBoxLayout();
|
setDefaultWidget(widget);
|
||||||
|
|
||||||
pLayout->addStretch();
|
connect(widget,SIGNAL(fitToWidthRatioChanged(float)),this,SIGNAL(fitToWidthRatioChanged(float)));
|
||||||
|
|
||||||
percentageLabel = new QLabel ("100%");
|
|
||||||
percentageLabel->setStyleSheet("QLabel { color : white; }");
|
|
||||||
percentageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
|
||||||
pLayout->addWidget (percentageLabel);
|
|
||||||
slider = new QSlider(NULL);
|
|
||||||
slider->setOrientation(Qt::Horizontal);
|
|
||||||
pLayout->addWidget (slider);
|
|
||||||
|
|
||||||
QString sliderCSS =
|
|
||||||
|
|
||||||
"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);
|
|
||||||
|
|
||||||
QLabel* imgLabel = new QLabel(pWidget);
|
|
||||||
QPixmap p(":/images/sliderBackground.png");
|
|
||||||
imgLabel->resize(p.size());
|
|
||||||
imgLabel->setPixmap(p);
|
|
||||||
|
|
||||||
pLayout->setMargin(0);
|
|
||||||
pLayout->setSpacing(0);
|
|
||||||
|
|
||||||
pLayout->setStretchFactor(percentageLabel,1);
|
|
||||||
pLayout->setStretchFactor(slider,0);
|
|
||||||
|
|
||||||
|
|
||||||
pWidget->setLayout (pLayout);
|
|
||||||
pWidget->setAutoFillBackground(false);
|
|
||||||
|
|
||||||
pWidget->setMinimumSize(276,45);
|
|
||||||
|
|
||||||
setDefaultWidget(pWidget);
|
|
||||||
|
|
||||||
slider->setMinimum(50);
|
|
||||||
slider->setMaximum(100);
|
|
||||||
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)));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderSliderAction::updateText(int value)
|
void YACReaderSliderAction::updateText(int value)
|
||||||
{
|
{
|
||||||
percentageLabel->setText(QString("%1 %").arg(value));
|
widget->updateText(value);
|
||||||
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
|
|
||||||
emit(fitToWidthRatioChanged(value / 100.0f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void YACReaderSliderAction::updateFitToWidthRatio(float v)
|
void YACReaderSliderAction::updateFitToWidthRatio(float v)
|
||||||
{
|
{
|
||||||
int value = v*100;
|
widget->updateFitToWidthRatio(v);
|
||||||
slider->setValue(value);
|
}
|
||||||
percentageLabel->setText(QString("%1 %").arg(value));
|
|
||||||
|
YACReaderSlider::YACReaderSlider(QWidget *parent)
|
||||||
|
:QWidget(parent)
|
||||||
|
{
|
||||||
|
QHBoxLayout* pLayout = new QHBoxLayout();
|
||||||
|
|
||||||
|
pLayout->addStretch();
|
||||||
|
|
||||||
|
percentageLabel = new QLabel ("100%");
|
||||||
|
percentageLabel->setStyleSheet("QLabel { color : white; }");
|
||||||
|
percentageLabel->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
|
||||||
|
pLayout->addWidget (percentageLabel);
|
||||||
|
slider = new QSlider(NULL);
|
||||||
|
slider->setOrientation(Qt::Horizontal);
|
||||||
|
pLayout->addWidget (slider);
|
||||||
|
|
||||||
|
QString sliderCSS =
|
||||||
|
|
||||||
|
"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);
|
||||||
|
|
||||||
|
QLabel* imgLabel = new QLabel(this);
|
||||||
|
QPixmap p(":/images/sliderBackground.png");
|
||||||
|
imgLabel->resize(p.size());
|
||||||
|
imgLabel->setPixmap(p);
|
||||||
|
|
||||||
|
pLayout->setMargin(0);
|
||||||
|
pLayout->setSpacing(0);
|
||||||
|
|
||||||
|
pLayout->setStretchFactor(percentageLabel,1);
|
||||||
|
pLayout->setStretchFactor(slider,0);
|
||||||
|
|
||||||
|
|
||||||
|
setLayout (pLayout);
|
||||||
|
setAutoFillBackground(false);
|
||||||
|
|
||||||
|
setMinimumSize(276,45);
|
||||||
|
|
||||||
|
slider->setMinimum(50);
|
||||||
|
slider->setMaximum(100);
|
||||||
|
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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderSlider::updateText(int value)
|
||||||
|
{
|
||||||
|
percentageLabel->setText(QString("%1 %").arg(value));
|
||||||
|
Configuration::getConfiguration().setFitToWidthRatio(value/100.0);
|
||||||
|
emit(fitToWidthRatioChanged(value / 100.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderSlider::updateFitToWidthRatio(float v)
|
||||||
|
{
|
||||||
|
int value = v*100;
|
||||||
|
slider->setValue(value);
|
||||||
|
percentageLabel->setText(QString("%1 %").arg(value));
|
||||||
}
|
}
|
@ -6,12 +6,31 @@
|
|||||||
class QLabel;
|
class QLabel;
|
||||||
class QSlider;
|
class QSlider;
|
||||||
|
|
||||||
|
class YACReaderSlider : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
QLabel * percentageLabel;
|
||||||
|
QSlider * slider;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
YACReaderSlider (QWidget * parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void updateText(int value);
|
||||||
|
void updateFitToWidthRatio(float v);
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void fitToWidthRatioChanged(float value);
|
||||||
|
};
|
||||||
|
|
||||||
class YACReaderSliderAction : public QWidgetAction
|
class YACReaderSliderAction : public QWidgetAction
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QLabel * percentageLabel;
|
YACReaderSlider * widget;
|
||||||
QSlider * slider;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -64,6 +64,10 @@ public:
|
|||||||
//hacks everywhere
|
//hacks everywhere
|
||||||
//convenience method for YACReaderLibrary search edit
|
//convenience method for YACReaderLibrary search edit
|
||||||
YACReaderMacOSXSearchLineEdit *addSearchEdit();
|
YACReaderMacOSXSearchLineEdit *addSearchEdit();
|
||||||
|
//convenience method for showing the fit to width slider in MacOSX
|
||||||
|
QAction * addFitToWidthSlider(QAction * attachToAction);
|
||||||
|
|
||||||
|
|
||||||
//convenience method for switching the icon of the view selector
|
//convenience method for switching the icon of the view selector
|
||||||
void updateViewSelectorIcon(const QIcon & icon);
|
void updateViewSelectorIcon(const QIcon & icon);
|
||||||
|
|
||||||
|
@ -280,6 +280,20 @@ YACReaderMacOSXSearchLineEdit * YACReaderMacOSXToolbar::addSearchEdit()
|
|||||||
return searchEdit;
|
return searchEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QAction *YACReaderMacOSXToolbar::addFitToWidthSlider(QAction *attachToAction)
|
||||||
|
{
|
||||||
|
QMacToolBarItem *toolBarItem = addItem(attachToAction->icon(),"fit to width slider");
|
||||||
|
|
||||||
|
NSToolbarItem * nativeItem = toolBarItem->nativeToolBarItem();
|
||||||
|
actions.insert(QString::fromNSString(nativeItem.itemIdentifier),attachToAction);
|
||||||
|
|
||||||
|
QAction * action = new QAction("",attachToAction->parent());
|
||||||
|
|
||||||
|
connect(toolBarItem,SIGNAL(activated()), action, SIGNAL(triggered()));
|
||||||
|
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
void YACReaderMacOSXToolbar::updateViewSelectorIcon(const QIcon &icon)
|
void YACReaderMacOSXToolbar::updateViewSelectorIcon(const QIcon &icon)
|
||||||
{
|
{
|
||||||
if(viewSelector)
|
if(viewSelector)
|
||||||
|
Reference in New Issue
Block a user