diff --git a/customScrollContainer.cpp b/customScrollContainer.cpp index 079609f..5650410 100644 --- a/customScrollContainer.cpp +++ b/customScrollContainer.cpp @@ -377,7 +377,11 @@ void ScrollIndicator::mousePressEvent(QMouseEvent *event){ pressed = true; //>note: globalPos -> globalPosition here due to deprecation //> may cause issues +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) lastY = event->globalPosition().y(); +#else + lastY = event->globalPos().y(); +#endif update(); } @@ -385,11 +389,19 @@ void ScrollIndicator::mouseMoveEvent(QMouseEvent *event){ if(pressed && !aniPause->isActive()){ //>note: globalPos -> globalPosition here due to deprecation //> may cause issues +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) int dp = event->globalPosition().y() - lastY; +#else + int dp = event->globalPos().y() - lastY; +#endif emit scrollPage(dp); //>note: globalPos -> globalPosition here due to deprecation //> may cause issues +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) lastY = event->globalPosition().y(); +#else + lastY = event->globalPos().y(); +#endif } } diff --git a/customScrollContainer.h b/customScrollContainer.h index 2349021..49cd703 100644 --- a/customScrollContainer.h +++ b/customScrollContainer.h @@ -13,6 +13,7 @@ #include #include #include +#include #define MAXSPEED 70 diff --git a/graph_view.cpp b/graph_view.cpp index 3ffd417..6b974af 100644 --- a/graph_view.cpp +++ b/graph_view.cpp @@ -1,5 +1,4 @@ #include "graph_view.h" -#include viewLog::viewLog(QString log, QWidget *parent) : QLabel(parent) @@ -147,7 +146,11 @@ void MyGraphicsView::mouseMoveEvent(QMouseEvent *event){ } void MyGraphicsView::wheelEvent(QWheelEvent *event){ +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) QPointF cursorPoint = event->position(); +#else + QPointF cursorPoint = event->posF(); +#endif QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y())); qreal viewWidth = this->viewport()->width(); diff --git a/graph_view.h b/graph_view.h index 23fe232..adf88ec 100644 --- a/graph_view.h +++ b/graph_view.h @@ -10,7 +10,6 @@ #include #include #include - #include //Header for MyVex class @@ -25,6 +24,10 @@ #include #include +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) +#include +#endif + class viewLog : public QLabel{ Q_OBJECT private: diff --git a/main.cpp b/main.cpp index cd83d19..fec4e8c 100644 --- a/main.cpp +++ b/main.cpp @@ -1,9 +1,17 @@ #include "mainwindow.h" #include +#include int main(int argc, char *argv[]) { + //int id = QFontDatabase::addApplicationFont(":/fonts/fonts/corbel.ttf"); + //qDebug() << id; + //QFontDatabase::addApplicationFont(":/fonts/fonts/corbell.ttf"); + //Qt::AA_EnableHighDpiScaling; +#ifdef Q_OS_LINUX + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif QApplication a(argc, argv); MainWindow w; w.setWindowFlag(Qt::FramelessWindowHint); diff --git a/mainwindow.cpp b/mainwindow.cpp index 63ec6e8..e1bdf26 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -11,6 +11,10 @@ MainWindow::MainWindow(QWidget *parent) { ui->setupUi(this); ui->centralwidget->setMouseTracking(true); +#ifdef Q_OS_LINUX + ui->verticalLayout->setContentsMargins(0, 0, 0, 0); + cornerRadius = 0; +#endif QTimer *t = new QTimer(this); connect(t, &QTimer::timeout, this, [=](){Init();}); t->setSingleShot(true); @@ -21,8 +25,13 @@ MainWindow::MainWindow(QWidget *parent) void MainWindow::Init(){ /* Create main widget and set mask, style sheet and shadow */ +#ifdef Q_OS_LINUX + QPainterPath path; + path.addRect(ui->mainWidget->rect()); +#else QPainterPath path; path.addRoundedRect(ui->mainWidget->rect(), cornerRadius - 1, cornerRadius - 1); +#endif QRegion mask(path.toFillPolygon().toPolygon()); ui->mainWidget->setMask(mask); @@ -30,15 +39,19 @@ void MainWindow::Init(){ ui->mainWidget->setObjectName("mainWidget"); mainStyle = "QWidget#mainWidget{background-color:" + mainBackGround.name() + QString::asprintf(";border-radius:%dpx", cornerRadius) + "}"; ui->mainWidget->setStyleSheet(mainStyle); - +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#ifdef Q_OS_WINDOWS windowShadow = new QGraphicsDropShadowEffect(this); windowShadow->setBlurRadius(30); windowShadow->setColor(QColor(0, 0, 0)); windowShadow->setOffset(0, 0); ui->mainWidget->setGraphicsEffect(windowShadow); +#endif +#endif /**********************************************************/ /* Create border in order to cover the zigzag edge of the region */ +#ifdef Q_OS_WINDOWS border = new QWidget(this); border->move(ui->mainWidget->pos() - QPoint(1, 1)); border->resize(ui->mainWidget->size() + QSize(2, 2)); @@ -47,6 +60,7 @@ void MainWindow::Init(){ border->setStyleSheet(borderStyle); border->setAttribute(Qt::WA_TransparentForMouseEvents); border->show(); +#endif /*****************************************************************/ /* Create about page */ @@ -329,7 +343,11 @@ MainWindow::~MainWindow() void MainWindow::mousePressEvent(QMouseEvent *event){ if(event->button() == Qt::LeftButton){ mousePressed = true; +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) lastPos = event->globalPosition().toPoint() - this->frameGeometry().topLeft(); +#else + lastPos = event->globalPos() - this->frameGeometry().topLeft(); +#endif } } @@ -362,14 +380,26 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event){ if(maximized){ qreal wRatio = (double)event->pos().x() / (double)ui->mainWidget->width(); controlWindowScale(); +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) this->move(QPoint(event->globalPosition().x() - ui->mainWidget->width() * wRatio, -30)); +#else + this->move(QPoint(event->globalPos().x() - ui->mainWidget->width() * wRatio, -30)); +#endif lastPos = QPoint(ui->mainWidget->width() * wRatio, event->pos().y()); } else +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) this->move(event->globalPosition().toPoint() - lastPos); +#else + this->move(event->globalPos() - lastPos); +#endif } else{ +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) QPoint d = event->globalPosition().toPoint() - frameGeometry().topLeft() - lastPos; +#else + QPoint d = event->globalPos() - frameGeometry().topLeft() - lastPos; +#endif if(mouseState & AT_LEFT){ this->move(this->frameGeometry().x() + d.x(), this->frameGeometry().y()); this->resize(this->width() - d.x(), this->height()); @@ -385,7 +415,11 @@ void MainWindow::mouseMoveEvent(QMouseEvent *event){ this->resize(this->width(), this->height() + d.y()); } } +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) lastPos = event->globalPosition().toPoint() - this->frameGeometry().topLeft(); +#else + lastPos = event->globalPos() - this->frameGeometry().topLeft(); +#endif } } @@ -396,18 +430,23 @@ void MainWindow::resizeEvent(QResizeEvent *event){ //Resize mask QPainterPath path; +#ifdef Q_OS_WINDOWS path.addRoundedRect(ui->mainWidget->rect(), cornerRadius - 1, cornerRadius - 1); +#else + path.addRect(ui->mainWidget->rect()); +#endif QRegion mask(path.toFillPolygon().toPolygon()); ui->mainWidget->setMask(mask); //Resize all pages for(int i = 0; i < pageList.size(); i++){ - pageList[i]->resize(ui->mainWidget->width() * 0.3 < pageList[i]->preferWidth ? pageList[i]->preferWidth - 1 : ui->mainWidget->width() * 0.3 - 1, ui->mainWidget->height()); + pageList[i]->resize(ui->mainWidget->width() * 0.4 < pageList[i]->preferWidth ? pageList[i]->preferWidth - 1 : ui->mainWidget->width() * 0.4 - 1, ui->mainWidget->height()); pageList[i]->resize(pageList[i]->width() + 1, pageList[i]->height()); } } void MainWindow::controlWindowScale(){ +#ifdef Q_OS_WINDOWS if(!maximized){ lastGeometry = this->frameGeometry(); windowShadow->setEnabled(false); @@ -437,6 +476,7 @@ void MainWindow::controlWindowScale(){ this->move(lastGeometry.x(), lastGeometry.y()); maximized = false; } +#endif } MyCanvas* MainWindow::loadCanvas(const QString &path){ diff --git a/mainwindow.h b/mainwindow.h index da435bc..8777c6f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -48,7 +48,16 @@ private: QPoint lastPos; void mouseMoveEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event){mousePressed = false;if(event->globalPosition().y() < 2) controlWindowScale();} + void mouseReleaseEvent(QMouseEvent *event){ + mousePressed = false; +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + if(event->globalPosition().y() < 2) + controlWindowScale(); +#else + if(event->globalPos().y() < 2) + controlWindowScale(); +#endif + } void resizeEvent(QResizeEvent *event); bool maximized = false; diff --git a/slidepage.cpp b/slidepage.cpp index 76fabf6..c722e2d 100644 --- a/slidepage.cpp +++ b/slidepage.cpp @@ -7,7 +7,7 @@ SlidePage::SlidePage(int radius, QString name, QWidget *parent) : { //if(parent) // resize(parent->width() * 0.8 <= preferWidth ? parent->width() * 0.8 : preferWidth, parent->height()); - resize(parent->width() * 0.3 <= preferWidth ? preferWidth : parent->width() * 0.3, parent->height()); + resize(parent->width() * 0.4 <= preferWidth ? preferWidth : parent->width() * 0.4, parent->height()); this->move(QPoint(-this->width() - 30, 0)); pageContentContainer = new ScrollAreaCustom(this);