Skip to content

Commit

Permalink
fix: 折叠优化
Browse files Browse the repository at this point in the history
  • Loading branch information
mhduiy committed Jul 12, 2023
1 parent 2cf00a5 commit f8b1083
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/customComponents/MSidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ void MSidebar::addWidgetItem(const QString &text, const QIcon& icon) {

void MSidebar::foldPage() {
cutX = this->pos().x();
if(cutX != 0) { //当前是折叠状态
tarX = 0;
if(cutX == -1 * this->width() + foldBtn->width()) { //当前是折叠状态
tarX = 0; //设置为展开
}
else {
else if(cutX == 0){ // 当前是展开状态
tarX = -1 * this->width() + foldBtn->width();
}
else {
return;
}
animationTimer.start(1);
}

Expand Down Expand Up @@ -89,6 +92,7 @@ void MSidebar::showEvent(QShowEvent *event) {
setCurrentIndex(0); //设置默认选择项
connect(listWidget, &QListWidget::currentRowChanged, this, &MSidebar::currentIndexChanged);
foldPage();
isFirstShow = false;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/mainWidget/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ MainWindow::MainWindow(QWidget *parent)
this->stackedWidget->setCurrentIndex(index);
});

qDebug() << "show";

statusBar()->hide();
setCentralWidget(main);
this->centralWidget()->layout()->setMargin(10);
Expand Down
16 changes: 15 additions & 1 deletion src/simplyScreenShot/simpyScreenShot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include <QGroupBox>
#include <QFile>
#include <QDebug>
#include <QGuiApplication>
#include <QScreen>
#include <QThread>

SimpyScreenShot::SimpyScreenShot(QWidget *parent) : QWidget(parent){
initUI();
Expand Down Expand Up @@ -65,7 +68,18 @@ void SimpyScreenShot::initUI() {
}

void SimpyScreenShot::screenShotOperator() {

QObject *obj = this->parent()->parent()->parent();
if(QString(obj->metaObject()->className()) == "MainWindow") {
qobject_cast<QWidget*>(obj)->hide();
}
QScreen *screen = QGuiApplication::primaryScreen();
pixmap = screen->grabWindow(0);
imageDisPlay->setScaledContents(true); // 设置图片自动缩放
imageDisPlay->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // 设置大小策略
imageDisPlay->setPixmap(pixmap);
if(QString(obj->metaObject()->className()) == "MainWindow") {
qobject_cast<QWidget*>(obj)->show();
}
}

void SimpyScreenShot::colorPickerOperator() {
Expand Down
9 changes: 6 additions & 3 deletions src/simplyScreenShot/simpyScreenShot.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "customComponents/MButton.h"
#include <QLabel>
#include <QLineEdit>
#include <QPixmap>

class SimpyScreenShot : public QWidget{
Q_OBJECT
Expand All @@ -28,9 +29,11 @@ class SimpyScreenShot : public QWidget{
MButton *saveImageBtn = nullptr; // 保存图片
MButton *startScreenShotBtn = nullptr; // 屏幕截图
MButton *startColorPicker = nullptr; // 取色器
QLabel *colorDis{}; // 显示取到的颜色
QLineEdit *colorValue{}; // 显示颜色值
MButton *copyColorValueBtn{}; // 复制颜色值
QLabel *colorDis = nullptr; // 显示取到的颜色
QLineEdit *colorValue = nullptr; // 显示颜色值
MButton *copyColorValueBtn = nullptr; // 复制颜色值

QPixmap pixmap;
};


Expand Down

0 comments on commit f8b1083

Please sign in to comment.