代码拉取完成,页面将自动刷新
#include "ColorDesktop.h"
#include "ui_ColorDesktop.h"
ColorDesktop::ColorDesktop(QWidget *parent) : QWidget(parent), ui(new Ui::ColorDesktop) {
ui->setupUi(this);
this->setMouseTracking(true);
this->widget = new DetailWidget(this);
}
ColorDesktop::~ColorDesktop() {
delete widget;
delete ui;
}
const QImage &ColorDesktop::getImage() const {
return image;
}
void ColorDesktop::setImage(const QImage &image) {
ColorDesktop::image = image;
}
const QColor &ColorDesktop::getColor() const {
return color;
}
void ColorDesktop::setColor(const QColor &color) {
ColorDesktop::color = color;
}
int ColorDesktop::getHeight() const {
return height;
}
void ColorDesktop::setHeight(int height) {
ColorDesktop::height = height;
}
int ColorDesktop::getWidth() const {
return width;
}
void ColorDesktop::setWidth(int width) {
ColorDesktop::width = width;
}
void ColorDesktop::mousePressEvent(QMouseEvent *event) {
/* 隐藏当前全屏窗口 */
this->setVisible(false);
/* 保存颜色信息 */
this->color = this->image.pixelColor(event->globalX(),event->globalY());
/* 发送信号更新主窗口数据 */
emit this->clicked();
}
void ColorDesktop::mouseMoveEvent(QMouseEvent *event) {
/* 移动放大镜窗口以避开鼠标 */
if(event->globalY()<=this->width/2&&event->globalX()<=this->height/2){
this->widget->move(this->width-150,this->height-150);
}else{
this->widget->move(0,0);
}
/* 更新信息并重绘放大镜窗口 */
this->widget->setX(event->globalX());
this->widget->setY(event->globalY());
this->widget->setImage(&this->image);
this->widget->setWidth(this->width);
this->widget->setHeight(this->height);
this->widget->repaint();
}
void ColorDesktop::exit() {
this->widget->close();
this->close();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。