mirror of
https://github.com/YACReader/yacreader
synced 2025-05-27 19:00:29 -04:00
QMacToolBar is not available in Qt6
This commit adds new qt pure versions of the mac toolbar to be used in qt6.
This commit is contained in:
parent
450d3c18b2
commit
e026f25617
@ -731,7 +731,7 @@ void MainWindowViewer::createToolBars()
|
|||||||
|
|
||||||
// attach toolbar
|
// attach toolbar
|
||||||
|
|
||||||
comicToolBar->attachToWindow(this->windowHandle());
|
comicToolBar->attachToWindow(this);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -922,9 +922,6 @@ void LibraryWindow::createToolBars()
|
|||||||
libraryToolBar->addSpace(10);
|
libraryToolBar->addSpace(10);
|
||||||
|
|
||||||
libraryToolBar->addAction(toggleComicsViewAction);
|
libraryToolBar->addAction(toggleComicsViewAction);
|
||||||
#ifndef Q_OS_MAC
|
|
||||||
libraryToolBar->addAction(toggleFullScreenAction);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
libraryToolBar->addStretch();
|
libraryToolBar->addStretch();
|
||||||
|
|
||||||
@ -935,7 +932,7 @@ void LibraryWindow::createToolBars()
|
|||||||
|
|
||||||
// libraryToolBar->setMovable(false);
|
// libraryToolBar->setMovable(false);
|
||||||
|
|
||||||
libraryToolBar->attachToWindow(this->windowHandle());
|
libraryToolBar->attachToWindow(this);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
libraryToolBar->backButton->setDefaultAction(backAction);
|
libraryToolBar->backButton->setDefaultAction(backAction);
|
||||||
|
@ -68,8 +68,10 @@ YACReaderMainToolBar::YACReaderMainToolBar(QWidget *parent)
|
|||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
mainLayout->addWidget(toggleComicsViewButton, 0, Qt::AlignVCenter);
|
mainLayout->addWidget(toggleComicsViewButton, 0, Qt::AlignVCenter);
|
||||||
|
#ifndef Q_OS_MAC
|
||||||
addWideDivider();
|
addWideDivider();
|
||||||
mainLayout->addWidget(fullscreenButton, 0, Qt::AlignVCenter);
|
mainLayout->addWidget(fullscreenButton, 0, Qt::AlignVCenter);
|
||||||
|
#endif
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
#ifndef YACREADER_MACOSX_TOOLBAR_H
|
#ifndef YACREADER_MACOSX_TOOLBAR_H
|
||||||
#define YACREADER_MACOSX_TOOLBAR_H
|
#define YACREADER_MACOSX_TOOLBAR_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
#include <QMacToolBar>
|
#include <QMacToolBar>
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
#include "yacreader_global.h"
|
#include "yacreader_global.h"
|
||||||
|
|
||||||
@ -70,6 +73,8 @@ public:
|
|||||||
// 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);
|
||||||
|
|
||||||
|
void attachToWindow(QMainWindow *window);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -80,5 +85,48 @@ protected:
|
|||||||
bool yosemite;
|
bool yosemite;
|
||||||
QMacToolBarItem *viewSelector;
|
QMacToolBarItem *viewSelector;
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifdef YACREADER_LIBRARY
|
||||||
|
|
||||||
|
#include "yacreader_main_toolbar.h"
|
||||||
|
#include "yacreader_search_line_edit.h"
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
class YACReaderMacOSXSearchLineEdit : public YACReaderSearchLineEdit
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
class YACReaderMacOSXToolbar : public YACReaderMainToolBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit YACReaderMacOSXToolbar(QWidget *parent = 0);
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
void addAction(QAction *action);
|
||||||
|
void addSpace(int size); // size in points
|
||||||
|
void addStretch();
|
||||||
|
YACReaderMacOSXSearchLineEdit *addSearchEdit();
|
||||||
|
void updateViewSelectorIcon(const QIcon &icon);
|
||||||
|
void attachToWindow(QMainWindow *window);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
class YACReaderMacOSXToolbar : public QToolBar
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit YACReaderMacOSXToolbar(QWidget *parent = 0);
|
||||||
|
void attachToWindow(QMainWindow *window);
|
||||||
|
void addStretch();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // YACREADER_MACOSX_TOOLBAR_H
|
#endif // YACREADER_MACOSX_TOOLBAR_H
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
#include "yacreader_macosx_toolbar.h"
|
#include "yacreader_macosx_toolbar.h"
|
||||||
|
#include "QtWidgets/qmainwindow.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
#include <QtWidgets>
|
||||||
|
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QMacNativeWidget>
|
#include <QMacNativeWidget>
|
||||||
#include <qmacfunctions.h>
|
#include <qmacfunctions.h>
|
||||||
@ -298,6 +303,11 @@ void YACReaderMacOSXToolbar::updateViewSelectorIcon(const QIcon &icon)
|
|||||||
viewSelector->setIcon(icon);
|
viewSelector->setIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::attachToWindow(QMainWindow *window)
|
||||||
|
{
|
||||||
|
QMacToolBar::attachToWindow(window->windowHandle());
|
||||||
|
}
|
||||||
|
|
||||||
YACReaderMacOSXSearchLineEdit::YACReaderMacOSXSearchLineEdit()
|
YACReaderMacOSXSearchLineEdit::YACReaderMacOSXSearchLineEdit()
|
||||||
: QObject()
|
: QObject()
|
||||||
{
|
{
|
||||||
@ -386,3 +396,108 @@ void MacToolBarItemWrapper::updateIcon(bool enabled)
|
|||||||
} else
|
} else
|
||||||
toolbaritem->setIcon(action->icon());
|
toolbaritem->setIcon(action->icon());
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
#ifdef YACREADER_LIBRARY
|
||||||
|
|
||||||
|
YACReaderMacOSXToolbar::YACReaderMacOSXToolbar(QWidget *parent)
|
||||||
|
: YACReaderMainToolBar(parent)
|
||||||
|
{
|
||||||
|
backButton->setIconSize(QSize(24, 24));
|
||||||
|
forwardButton->setIconSize(QSize(24, 24));
|
||||||
|
settingsButton->setIconSize(QSize(24, 24));
|
||||||
|
serverButton->setIconSize(QSize(24, 24));
|
||||||
|
helpButton->setIconSize(QSize(24, 24));
|
||||||
|
toggleComicsViewButton->setIconSize(QSize(24, 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize YACReaderMacOSXToolbar::sizeHint() const
|
||||||
|
{
|
||||||
|
return QSize(400, 36);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::addAction(QAction *action)
|
||||||
|
{
|
||||||
|
if (backButton->defaultAction() == nullptr) {
|
||||||
|
backButton->setDefaultAction(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (forwardButton->defaultAction() == nullptr) {
|
||||||
|
forwardButton->setDefaultAction(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (settingsButton->defaultAction() == nullptr) {
|
||||||
|
settingsButton->setDefaultAction(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (serverButton->defaultAction() == nullptr) {
|
||||||
|
serverButton->setDefaultAction(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (helpButton->defaultAction() == nullptr) {
|
||||||
|
helpButton->setDefaultAction(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (toggleComicsViewButton->defaultAction() == nullptr) {
|
||||||
|
toggleComicsViewButton->setDefaultAction(action);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::addSpace(int size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::addStretch()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
YACReaderMacOSXSearchLineEdit *YACReaderMacOSXToolbar::addSearchEdit()
|
||||||
|
{
|
||||||
|
auto search = new YACReaderMacOSXSearchLineEdit();
|
||||||
|
|
||||||
|
setSearchWidget(search);
|
||||||
|
|
||||||
|
return search;
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::updateViewSelectorIcon(const QIcon &icon)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::attachToWindow(QMainWindow *window)
|
||||||
|
{
|
||||||
|
auto toolbar = new QToolBar();
|
||||||
|
|
||||||
|
toolbar->addWidget(this);
|
||||||
|
toolbar->setMovable(false);
|
||||||
|
|
||||||
|
window->addToolBar(toolbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
YACReaderMacOSXToolbar::YACReaderMacOSXToolbar(QWidget *parent)
|
||||||
|
: QToolBar(parent)
|
||||||
|
{
|
||||||
|
setMovable(false);
|
||||||
|
setIconSize(QSize(24, 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::attachToWindow(QMainWindow *window)
|
||||||
|
{
|
||||||
|
window->setUnifiedTitleAndToolBarOnMac(true);
|
||||||
|
window->addToolBar(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void YACReaderMacOSXToolbar::addStretch()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user