mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
refactor(videomode): Move implementation in cpp file
This commit is contained in:
parent
e6e666fa8c
commit
3edd84c4d8
3
qtox.pro
3
qtox.pro
|
@ -472,4 +472,5 @@ SOURCES += \
|
||||||
src/widget/about/aboutuser.cpp \
|
src/widget/about/aboutuser.cpp \
|
||||||
src/widget/form/groupinviteform.cpp \
|
src/widget/form/groupinviteform.cpp \
|
||||||
src/widget/tool/profileimporter.cpp \
|
src/widget/tool/profileimporter.cpp \
|
||||||
src/widget/passwordedit.cpp
|
src/widget/passwordedit.cpp \
|
||||||
|
src/video/videomode.cpp
|
||||||
|
|
75
src/video/videomode.cpp
Normal file
75
src/video/videomode.cpp
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
Copyright © 2015-2016 by The qTox Project
|
||||||
|
|
||||||
|
This file is part of qTox, a Qt-based graphical interface for Tox.
|
||||||
|
|
||||||
|
qTox is libre software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
qTox is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "videomode.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
@struct VideoMode
|
||||||
|
@brief Describes a video mode supported by a device.
|
||||||
|
|
||||||
|
@var unsigned short VideoMode::width, VideoMode::height
|
||||||
|
@brief Displayed video resolution (NOT frame resolution).
|
||||||
|
|
||||||
|
@var unsigned short VideoMode::x, VideoMode::y
|
||||||
|
@brief Coordinates of upper-left corner.
|
||||||
|
|
||||||
|
@var float VideoMode::FPS
|
||||||
|
@brief Frames per second supported by the device at this resolution
|
||||||
|
*/
|
||||||
|
|
||||||
|
VideoMode::VideoMode(int width, int height, int x, int y, int FPS, int format) :
|
||||||
|
width(width), height(height), x(x), y(y),
|
||||||
|
FPS(FPS), pixel_format(format)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoMode::VideoMode(QRect rect) :
|
||||||
|
width(rect.width()), height(rect.height()),
|
||||||
|
x(rect.x()), y(rect.y()),
|
||||||
|
FPS(0), pixel_format(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QRect VideoMode::toRect() const
|
||||||
|
{
|
||||||
|
return QRect(x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VideoMode::operator==(const VideoMode &other) const
|
||||||
|
{
|
||||||
|
return width == other.width
|
||||||
|
&& height == other.height
|
||||||
|
&& x == other.x
|
||||||
|
&& y == other.y
|
||||||
|
&& FPS == other.FPS
|
||||||
|
&& pixel_format == other.pixel_format;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t VideoMode::norm(const VideoMode &other) const
|
||||||
|
{
|
||||||
|
return abs(this->width-other.width) + abs(this->height-other.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief All zeros means a default/unspecified mode
|
||||||
|
*/
|
||||||
|
VideoMode::operator bool() const
|
||||||
|
{
|
||||||
|
return width || height || FPS;
|
||||||
|
}
|
|
@ -17,60 +17,29 @@
|
||||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef VIDEOMODE_H
|
#ifndef VIDEOMODE_H
|
||||||
#define VIDEOMODE_H
|
#define VIDEOMODE_H
|
||||||
|
|
||||||
#include <QRect>
|
#include <QRect>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
/// Describes a video mode supported by a device
|
|
||||||
struct VideoMode
|
struct VideoMode
|
||||||
{
|
{
|
||||||
unsigned short width, height; ///< Displayed video resolution (NOT frame resolution)
|
unsigned short width, height;
|
||||||
unsigned short x, y; ///< Coordinates of upper-left corner
|
unsigned short x, y;
|
||||||
float FPS; ///< Max frames per second supported by the device at this resolution
|
float FPS;
|
||||||
uint32_t pixel_format;
|
uint32_t pixel_format;
|
||||||
|
|
||||||
VideoMode(int width = 0, int height = 0, int x = 0, int y = 0,
|
VideoMode(int width = 0, int height = 0, int x = 0, int y = 0,
|
||||||
int FPS = 0, int format = 0) :
|
int FPS = 0, int format = 0);
|
||||||
width(width), height(height), x(x), y(y),
|
|
||||||
FPS(FPS), pixel_format(format)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoMode(QRect rect) :
|
VideoMode(QRect rect);
|
||||||
width(rect.width()), height(rect.height()),
|
|
||||||
x(rect.x()), y(rect.y()),
|
|
||||||
FPS(0), pixel_format(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect toRect() const
|
QRect toRect() const;
|
||||||
{
|
|
||||||
return QRect(x, y, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// All zeros means a default/unspecified mode
|
operator bool() const;
|
||||||
operator bool() const
|
bool operator==(const VideoMode& other) const;
|
||||||
{
|
uint32_t norm(const VideoMode& other) const;
|
||||||
return width || height || FPS;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const VideoMode& other) const
|
|
||||||
{
|
|
||||||
return width == other.width
|
|
||||||
&& height == other.height
|
|
||||||
&& x == other.x
|
|
||||||
&& y == other.y
|
|
||||||
&& FPS == other.FPS
|
|
||||||
&& pixel_format == other.pixel_format;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t norm(const VideoMode& other) const
|
|
||||||
{
|
|
||||||
return abs(this->width-other.width) + abs(this->height-other.height);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VIDEOMODE_H
|
#endif // VIDEOMODE_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user