Move functions

This commit is contained in:
Luis Ángel San Martín 2022-10-22 11:40:16 +02:00
parent c8f8c5661f
commit 8f1c63fcf0
3 changed files with 41 additions and 31 deletions

View File

@ -36,37 +36,6 @@
#include <QDate>
#include <QMenuBar>
// TODO there are no SVG assets in macos yet
// we need two sets of icons, one for the toolbar and one for the context menu because of this bug (QTBUG-96553): https://bugreports.qt.io/browse/QTBUG-96553
QString addExtensionToIconPath(const QString &path)
{
return path + ".svg";
}
QString addExtensionToIconPathInToolbar(const QString &path)
{
return path + "_18x18.svg";
}
QAction *actionWithCustomIcon(const QIcon &icon, QAction *action)
{
auto a = new QAction(icon, action->text());
a->setEnabled(action->isEnabled());
a->setCheckable(action->isCheckable());
a->setChecked(action->isChecked());
QObject::connect(a, &QAction::triggered, action, &QAction::triggered);
QObject::connect(action, &QAction::enabledChanged, a, &QAction::setEnabled);
QObject::connect(a, &QAction::toggled, action, &QAction::setChecked);
QObject::connect(action, &QAction::toggled, a, &QAction::setChecked);
return a;
}
MainWindowViewer::MainWindowViewer()
: QMainWindow(), fullscreen(false), toolbars(true), currentDirectory("."), currentDirectoryImgDest("."), isClient(false)
{

View File

@ -49,3 +49,41 @@ QList<qulonglong> YACReader::mimeDataToComicsIds(const QMimeData *data)
in >> comicIds; // deserialize the list of indentifiers
return comicIds;
}
// TODO some SVG assets are missing in macos (WIP)
// we need two sets of icons, one for the toolbar and one for the context menu because of this bug (QTBUG-96553): https://bugreports.qt.io/browse/QTBUG-96553
QString YACReader::addExtensionToIconPath(const QString &path)
{
#ifdef YACREADER_LIBRARY
#ifdef Q_OS_MAC
return path + ".png";
#else
return path + ".svg";
#endif
#else
return path + ".svg";
#endif
}
QString YACReader::addExtensionToIconPathInToolbar(const QString &path)
{
return path + "_18x18.svg";
}
QAction *YACReader::actionWithCustomIcon(const QIcon &icon, QAction *action)
{
auto a = new QAction(icon, action->text());
a->setEnabled(action->isEnabled());
a->setCheckable(action->isCheckable());
a->setChecked(action->isChecked());
QObject::connect(a, &QAction::triggered, action, &QAction::triggered);
QObject::connect(action, &QAction::enabledChanged, a, &QAction::setEnabled);
QObject::connect(a, &QAction::toggled, action, &QAction::setChecked);
QObject::connect(action, &QAction::toggled, a, &QAction::setChecked);
return a;
}

View File

@ -110,6 +110,9 @@ QAction *createSeparator();
QIcon noHighlightedIcon(const QString &path);
void colorize(QImage &img, QColor &col);
QList<qulonglong> mimeDataToComicsIds(const QMimeData *data);
QString addExtensionToIconPath(const QString &path);
QString addExtensionToIconPathInToolbar(const QString &path);
QAction *actionWithCustomIcon(const QIcon &icon, QAction *action);
}
#endif