separated global helpers depending on gui to a new source code file

This commit is contained in:
Luis Ángel San Martín 2015-12-12 12:09:47 +01:00
parent 92b0c1d9f4
commit c1e14aea1f
5 changed files with 153 additions and 144 deletions

View File

@ -118,6 +118,7 @@ HEADERS += comic_flow.h \
../common/custom_widgets.h \
../common/qnaturalsorting.h \
../common/yacreader_global.h \
../common/yacreader_global_gui.h \
../common/onstart_flow_selection_dialog.h \
no_libraries_widget.h \
import_widget.h \
@ -194,6 +195,7 @@ SOURCES += comic_flow.cpp \
comics_remover.cpp \
../common/http_worker.cpp \
../common/yacreader_global.cpp \
../common/yacreader_global_gui.cpp \
yacreader_libraries.cpp \
../common/exit_check.cpp \
comics_view.cpp \

View File

@ -1,5 +1,5 @@
#include "yacreader_global.h"
#include <QAction>
using namespace YACReader;
@ -13,22 +13,6 @@ QString YACReader::getSettingsPath()
}
void YACReader::addSperator(QWidget *w)
{
QAction * separator = new QAction(w);
separator->setSeparator(true);
w->addAction(separator);
}
QAction * YACReader::createSeparator()
{
QAction * a = new QAction(0);
a->setSeparator(true);
return a;
}
QString YACReader::colorToName(LabelColors colors)
{
switch(colors){
@ -59,31 +43,6 @@ QString YACReader::colorToName(LabelColors colors)
}
}
QIcon YACReader::noHighlightedIcon(const QString &path)
{
QPixmap p(path);
QIcon icon;//(path);
icon.addFile(path,p.size(),QIcon::Normal);
icon.addFile(path,p.size(),QIcon::Selected);
return icon;
}
void YACReader::colorize(QImage &img, QColor &col)
{
QRgb *data = (QRgb *)img.bits();
QRgb *end = data + img.width()*img.height();
int rcol = col.red(), gcol = col.green(), bcol = col.blue();
while(data != end) {
*data = qRgba(rcol,gcol,bcol,qAlpha(*data));
++data;
}
}
QString YACReader::labelColorToRGBString(LabelColors color)
{
switch (color) {
@ -129,13 +88,3 @@ QString YACReader::labelColorToRGBString(LabelColors color)
}
}
QList<qulonglong> YACReader::mimeDataToComicsIds(const QMimeData *data)
{
QList<qulonglong> comicIds;
QByteArray rawData = data->data(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
QDataStream in(&rawData,QIODevice::ReadOnly);
in >> comicIds; //deserialize the list of indentifiers
return comicIds;
}

View File

@ -7,66 +7,8 @@
#include <QDesktopServices>
#endif
#include <QWidget>
#include <QMimeData>
#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 FITMODE "FITMODE"
#define FLOW_TYPE "FLOW_TYPE"
#define FULLSCREEN "FULLSCREEN"
#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 BACKGROUND_COLOR "BACKGROUND_COLOR"
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
#define SHOW_TOOLBARS "SHOW_TOOLBARS"
#define BRIGHTNESS "BRIGHTNESS"
#define CONTRAST "CONTRAST"
#define GAMMA "GAMMA"
#define SHOW_INFO "SHOW_INFO"
#define FLOW_TYPE_GL "FLOW_TYPE_GL"
#define Y_POSITION "Y_POSITION"
#define COVER_DISTANCE "COVER_DISTANCE"
#define CENTRAL_DISTANCE "CENTRAL_DISTANCE"
#define ZOOM_LEVEL "ZOOM_LEVEL"
#define Z_COVER_OFFSET "Z_COVER_OFFSET"
#define COVER_ROTATION "COVER_ROTATION"
#define FADE_OUT_DIST "FADE_OUT_DIST"
#define LIGHT_STRENGTH "LIGHT_STRENGTH"
#define MAX_ANGLE "MAX_ANGLE"
#define PERFORMANCE "PERFORMANCE"
#define USE_OPEN_GL "USE_OPEN_GL"
#define X_ROTATION "X_ROTATION"
#define Y_COVER_OFFSET "Y_COVER_OFFSET"
#define V_SYNC "V_SYNC"
#define SERVER_ON "SERVER_ON"
#define MAIN_WINDOW_GEOMETRY "MAIN_WINDOW_GEOMETRY"
#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 COMICS_VIEW_FLOW_SPLITTER_STATUS "COMICS_VIEW_FLOW_SPLITTER_STATUS"
#define SIDEBAR_SPLITTER_STATUS "SIDEBAR_SPLITTER_STATUS"
#define COMICS_GRID_COVER_SIZES "COMICS_GRID_COVER_SIZES"
#define NUM_DAYS_BETWEEN_VERSION_CHECKS "NUM_DAYS_BETWEEN_VERSION_CHECKS"
#define LAST_VERSION_CHECK "LAST_VERSION_CHECK"
@ -74,24 +16,9 @@
#define LIBRARIES "LIBRARIES"
#define COMIC_VINE_API_KEY "COMIC_VINE_API_KEY"
namespace YACReader
{
static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids";
static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/yacreaderlibrary-sublist-rows";
enum FlowType
{
CoverFlowLike=0,
Strip,
StripOverlapped,
Modern,
Roulette,
Custom
};
enum YACReaderIPCMessages
{
RequestComicInfo = 0,
@ -110,12 +37,6 @@ static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/
SevenZNotFound = 700
};
enum ComicsViewStatus
{
Flow,
Grid
};
enum SearchModifiers{
NoModifiers = 0,
OnlyRead,
@ -138,22 +59,10 @@ static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/
YDark
};
enum FitMode{
ToWidth=0x01,
ToHeight=0x02,
FullRes=0x03,
FullPage=0x04//,
//Text=0x05
};
QString getSettingsPath();
void addSperator(QWidget * w);
QAction * createSeparator();
QString colorToName(LabelColors colors);
QIcon noHighlightedIcon(const QString & path);
void colorize(QImage &img, QColor &col);
QString labelColorToRGBString(LabelColors color);
QList<qulonglong> mimeDataToComicsIds(const QMimeData * data);
}
#endif

View File

@ -0,0 +1,51 @@
#include "yacreader_global_gui.h"
#include <QtCore>
#include <QAction>
using namespace YACReader;
void YACReader::addSperator(QWidget *w)
{
QAction * separator = new QAction(w);
separator->setSeparator(true);
w->addAction(separator);
}
QAction * YACReader::createSeparator()
{
QAction * a = new QAction(0);
a->setSeparator(true);
return a;
}
QIcon YACReader::noHighlightedIcon(const QString &path)
{
QPixmap p(path);
QIcon icon;//(path);
icon.addFile(path,p.size(),QIcon::Normal);
icon.addFile(path,p.size(),QIcon::Selected);
return icon;
}
void YACReader::colorize(QImage &img, QColor &col)
{
QRgb *data = (QRgb *)img.bits();
QRgb *end = data + img.width()*img.height();
int rcol = col.red(), gcol = col.green(), bcol = col.blue();
while(data != end) {
*data = qRgba(rcol,gcol,bcol,qAlpha(*data));
++data;
}
}
QList<qulonglong> YACReader::mimeDataToComicsIds(const QMimeData *data)
{
QList<qulonglong> comicIds;
QByteArray rawData = data->data(YACReader::YACReaderLibrarComiscSelectionMimeDataFormat);
QDataStream in(&rawData,QIODevice::ReadOnly);
in >> comicIds; //deserialize the list of indentifiers
return comicIds;
}

View File

@ -0,0 +1,98 @@
#ifndef __YACREADER_GLOBAL_GUI_H
#define __YACREADER_GLOBAL_GUI_H
#include "yacreader_global.h"
#include <QWidget>
#include <QMimeData>
#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 FITMODE "FITMODE"
#define FLOW_TYPE "FLOW_TYPE"
#define FULLSCREEN "FULLSCREEN"
#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 BACKGROUND_COLOR "BACKGROUND_COLOR"
#define ALWAYS_ON_TOP "ALWAYS_ON_TOP"
#define SHOW_TOOLBARS "SHOW_TOOLBARS"
#define BRIGHTNESS "BRIGHTNESS"
#define CONTRAST "CONTRAST"
#define GAMMA "GAMMA"
#define SHOW_INFO "SHOW_INFO"
#define FLOW_TYPE_GL "FLOW_TYPE_GL"
#define Y_POSITION "Y_POSITION"
#define COVER_DISTANCE "COVER_DISTANCE"
#define CENTRAL_DISTANCE "CENTRAL_DISTANCE"
#define ZOOM_LEVEL "ZOOM_LEVEL"
#define Z_COVER_OFFSET "Z_COVER_OFFSET"
#define COVER_ROTATION "COVER_ROTATION"
#define FADE_OUT_DIST "FADE_OUT_DIST"
#define LIGHT_STRENGTH "LIGHT_STRENGTH"
#define MAX_ANGLE "MAX_ANGLE"
#define PERFORMANCE "PERFORMANCE"
#define USE_OPEN_GL "USE_OPEN_GL"
#define X_ROTATION "X_ROTATION"
#define Y_COVER_OFFSET "Y_COVER_OFFSET"
#define V_SYNC "V_SYNC"
#define SERVER_ON "SERVER_ON"
#define MAIN_WINDOW_GEOMETRY "MAIN_WINDOW_GEOMETRY"
#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 COMICS_VIEW_FLOW_SPLITTER_STATUS "COMICS_VIEW_FLOW_SPLITTER_STATUS"
#define SIDEBAR_SPLITTER_STATUS "SIDEBAR_SPLITTER_STATUS"
#define COMICS_GRID_COVER_SIZES "COMICS_GRID_COVER_SIZES"
#define COMIC_VINE_API_KEY "COMIC_VINE_API_KEY"
namespace YACReader
{
static const QString YACReaderLibrarComiscSelectionMimeDataFormat = "application/yacreaderlibrary-comics-ids";
static const QString YACReaderLibrarSubReadingListMimeDataFormat = "application/yacreaderlibrary-sublist-rows";
enum FlowType
{
CoverFlowLike=0,
Strip,
StripOverlapped,
Modern,
Roulette,
Custom
};
enum ComicsViewStatus
{
Flow,
Grid
};
enum FitMode{
ToWidth=0x01,
ToHeight=0x02,
FullRes=0x03,
FullPage=0x04//,
//Text=0x05
};
void addSperator(QWidget * w);
QAction * createSeparator();
QIcon noHighlightedIcon(const QString & path);
void colorize(QImage &img, QColor &col);
QList<qulonglong> mimeDataToComicsIds(const QMimeData * data);
}
#endif