Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port to Qt 6.1.3 #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

#*.pro
#*.pri
build/
textserver/build/

# Application generated files
textedit/userLogin.dat
textserver/Documents/
Expand Down
12 changes: 12 additions & 0 deletions textedit.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ----------------------------------------------------
# This file is generated by the Qt Visual Studio Tools.
# ------------------------------------------------------

# This is a reminder that you are using a generated .pro file.
# Remove it when you are finished editing this file.
message("You are running qmake on a generated .pro file. This may not work!")

QT+=network widgets
TEMPLATE = subdirs
SUBDIRS += textedit/textedit.pro \
textserver/textserver.pro
8 changes: 5 additions & 3 deletions textedit/AboutWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#include "ui_aboutwindow.h"

#include "WidgetsManager.h"

#include <QDesktopWidget>
#include <QScreen>
#include <qguiapplication.h>
//#include <QDesktopWidget>

const QString rsrcPath = ":/images";

Expand All @@ -20,7 +21,8 @@ AboutWindow::AboutWindow(QWidget* parent)
//Center and resize window
WidgetsManager mngr(this);
//Center and resize
if (QApplication::desktop()->availableGeometry().size().width() <= 1366)
// if (QApplication::desktop()->availableGeometry().size().width() <= 1366)
if(QGuiApplication::primaryScreen()->availableGeometry().size().width()<=1366)
mngr.centerAndResize(0.4, 0.4);
else
mngr.centerAndResize(0.36, 0.38);
Expand Down
2 changes: 1 addition & 1 deletion textedit/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void Client::handleSslErrors(const QList<QSslError>& sslErrors)
}
else
{
qDebug() << "Encountered SSL errors: " << sslErrors << endl;
qDebug() << "Encountered SSL errors: " << sslErrors << Qt::endl;
}
}

Expand Down
3 changes: 3 additions & 0 deletions textedit/Client.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef _CLIENT_
#define _CLIENT_

#include <QObject>
#include <QtNetwork>
Expand Down Expand Up @@ -143,3 +145,4 @@ public slots:

};

#endif // _CLIENT_
2 changes: 1 addition & 1 deletion textedit/DocumentEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void DocumentEditor::charsDelete(QVector<Position> positions)
int position = -1;
int count = 0;

for each (Position fPos in positions)
for(Position fPos : positions)
{
int index = _document.remove(fPos, position);

Expand Down
43 changes: 24 additions & 19 deletions textedit/LandingPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include "ui_landingpage.h"

#include <QApplication>
#include <QDesktopWidget>
#include <QScreen>
#include <QGuiApplication>

//#include <QDesktopWidget>
#include <QMessageBox>
#include <QFileDialog>
#include <QFileInfo>
Expand Down Expand Up @@ -37,7 +40,8 @@ LandingPage::LandingPage(QWidget* parent)
ui->setupUi(this);

//Center and resize
if (QApplication::desktop()->availableGeometry().size().width() <= 1366)
// if (QApplication::desktop()->availableGeometry().size().width() <= 1366)
if(QGuiApplication::primaryScreen()->availableGeometry().size().width()<=1366)
mngr.centerAndResize(0.68, 0.8);
else
mngr.centerAndResize(0.55, 0.65);
Expand Down Expand Up @@ -146,13 +150,13 @@ LandingPage::LandingPage(QWidget* parent)
//Validator for server port
ui->lineEdit_serverPort->setValidator(new QIntValidator(0, 65535, this));
//Validator for server IP
ui->lineEdit_serverIP->setValidator(new QRegExpValidator(
QRegExp("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])[\.]){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"),
ui->lineEdit_serverIP->setValidator(new QRegularExpressionValidator(
QRegularExpression("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])[\.]){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"),
this));
//Validator for username (no spaces and '_')
ui->lineEdit_regUsr->setValidator(new QRegExpValidator(QRegExp("^[^\\s" + QString(URI_FIELD_SEPARATOR) + "]+$"), this));
ui->lineEdit_regUsr->setValidator(new QRegularExpressionValidator(QRegularExpression("^[^\\s" + QString(URI_FIELD_SEPARATOR) + "]+$"), this));
//Validator for nickname (no spaces)
ui->lineEdit_regNick->setValidator(new QRegExpValidator(QRegExp("^[^\\s]+$"), this));
ui->lineEdit_regNick->setValidator(new QRegularExpressionValidator(QRegularExpression("^[^\\s]+$"), this));


//Loads user login infos
Expand Down Expand Up @@ -267,7 +271,7 @@ void LandingPage::Register()
QString username = ui->lineEdit_regUsr->text();
QString password = ui->lineEdit_regPsw->text();
QString passwordConf = ui->lineEdit_regPswConf->text();
QImage userIcon = ui->label_UsrIcon->pixmap()->toImage();
QImage userIcon = ui->label_UsrIcon->pixmap().toImage();

//Save login info to file
saveUserLoginInfo(username);
Expand All @@ -289,8 +293,8 @@ void LandingPage::radioButtonPressed()
ui->label_imageSize->setText("");

//Load default profile picture
QPixmap default(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
QPixmap default_pixmap(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default_pixmap.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
}
}

Expand Down Expand Up @@ -381,7 +385,8 @@ void LandingPage::setupFileList()
//Setting item style
noDocuments->setTextAlignment(Qt::AlignCenter);
noDocuments->setFont(QFont("Helvetica", 12));
noDocuments->setTextColor(Qt::darkGray);
//noDocuments->setTextColor(Qt::darkGray);
noDocuments->setForeground(Qt::darkGray);
noDocuments->setFlags(noDocuments->flags() & ~Qt::ItemIsSelectable);

//Set item in the table
Expand Down Expand Up @@ -459,7 +464,7 @@ void LandingPage::setupUserProfilePicture(QPixmap userPix)
//Initialize painter to create a rounded profile picture
QPainter painter(&base);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);

//Create a round shape to set label rounded
Expand Down Expand Up @@ -487,8 +492,8 @@ void LandingPage::resetFields()
ui->label_imageSize->setText("");

//Reset user avatar preview
QPixmap default(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
QPixmap default_pixmap(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default_pixmap.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));

//Check radio-button
ui->radioButton_defaultAvatar->setChecked(true);
Expand Down Expand Up @@ -605,8 +610,8 @@ void LandingPage::updateUserAvatarPreview(QString path)


//Load default profile picture
QPixmap default(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
QPixmap default_pixmap(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default_pixmap.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
}


Expand Down Expand Up @@ -781,12 +786,12 @@ void LandingPage::saveUserLoginInfo(QString username)
if (file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
if (ui->checkBox_saveCredential->isChecked()) {
stream << username << endl;
stream << ui->lineEdit_serverIP->text() << endl;
stream << ui->lineEdit_serverPort->text() << endl;
stream << username << Qt::endl;
stream << ui->lineEdit_serverIP->text() << Qt::endl;
stream << ui->lineEdit_serverPort->text() << Qt::endl;
}
else {
stream << "" << endl;
stream << "" << Qt::endl;
}
}

Expand Down
4 changes: 2 additions & 2 deletions textedit/NewDocumentWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "NewDocumentWindow.h"
#include "ui_newdocumentwindow.h"

#include <QRegExpValidator>
#include <QRegularExpressionValidator>

#include "WidgetsManager.h"
#include "Document.h"
Expand All @@ -25,7 +25,7 @@ NewDocumentWindow::NewDocumentWindow(QWidget* parent)
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &NewDocumentWindow::rejectClicked);

//Validator to prevent insertion of '_' character in filename
ui->lineEdit_fileName->setValidator(new QRegExpValidator(QRegExp(QString("^[^") + URI_FIELD_SEPARATOR + "]+$"), this));
ui->lineEdit_fileName->setValidator(new QRegularExpressionValidator(QRegularExpression(QString("^[^") + URI_FIELD_SEPARATOR + "]+$"), this));

//Set keyboard focus
ui->lineEdit_fileName->setFocus();
Expand Down
24 changes: 13 additions & 11 deletions textedit/ProfileEditWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#include "ui_profileeditwindow.h"

#include <QPixmap>
#include <QDesktopWidget>
//#include <QDesktopWidget>
#include <QScreen>
#include <QFileDialog>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>

const QString rsrcPath = ":/images";

Expand All @@ -17,7 +18,8 @@ ProfileEditWindow::ProfileEditWindow(User& user, bool fromEditor, QWidget* paren
ui->setupUi(this);

//Center and resize
if (QApplication::desktop()->availableGeometry().size().width() <= 1366)
// if (QApplication::desktop()->availableGeometry().size().width() <= 1366)
if(QGuiApplication::primaryScreen()->availableGeometry().size().width()<=1366)
mngr.centerAndResize(0.55, 0.62);
else
mngr.centerAndResize(0.5, 0.55);
Expand All @@ -38,7 +40,7 @@ ProfileEditWindow::ProfileEditWindow(User& user, bool fromEditor, QWidget* paren
connect(ui->radioButton_defaultAvatar, &QRadioButton::toggled, this, &ProfileEditWindow::radioButtonPressed);

//Validator for nickname (no spaces)
ui->lineEdit_editNick->setValidator(new QRegExpValidator(QRegExp("^[^\\s]+$"), this));
ui->lineEdit_editNick->setValidator(new QRegularExpressionValidator(QRegularExpression("^[^\\s]+$"), this));


//Update GUI according to user info
Expand Down Expand Up @@ -96,7 +98,7 @@ void ProfileEditWindow::pushButtonUpdateClicked()
QString newPassword = ui->lineEdit_editPsw->text();
QString newPasswordConf = ui->lineEdit_editPswConf->text();
//If the image was not changed, an empty one is sent
QImage userIcon = _iconChanged ? ui->label_UsrIcon->pixmap()->toImage() : QImage();
QImage userIcon = _iconChanged ? ui->label_UsrIcon->pixmap().toImage() : QImage();


//Check if all password are the same (if setted)
Expand Down Expand Up @@ -141,8 +143,8 @@ void ProfileEditWindow::radioButtonPressed()
ui->label_imageSize->setText("");

//Load default profile picture
QPixmap default(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
QPixmap default_pixmap{rsrcPath + "/misc/defaultProfile.png"};
ui->label_UsrIcon->setPixmap(default_pixmap.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
_iconChanged = true;
}
}
Expand Down Expand Up @@ -181,8 +183,8 @@ void ProfileEditWindow::updateSelectedAvatar(const QString& path)
}

//Load default profile picture
QPixmap default(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
QPixmap default_pixmap(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default_pixmap.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
}


Expand All @@ -195,8 +197,8 @@ void ProfileEditWindow::resetFields()
ui->lineEdit_editPswConf->setText("");

//Load default profile picture
QPixmap default(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
QPixmap default_pixmap(rsrcPath + "/misc/defaultProfile.png");
ui->label_UsrIcon->setPixmap(default_pixmap.scaled(ui->label_UsrIcon->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));

//Check radio-button
ui->radioButton_customAvatar->setChecked(true);
Expand Down
2 changes: 1 addition & 1 deletion textedit/QTextEditWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ QString QTextEditWrapper::correctFont(QString value)
value.remove("lighter");
value.remove("normal");

QStringList elements = value.split(QRegularExpression("\\s+"), QString::SkipEmptyParts);
QStringList elements = value.split(QRegularExpression("\\s+"), Qt::SkipEmptyParts);

while (!elements.isEmpty())
{
Expand Down
5 changes: 4 additions & 1 deletion textedit/QTextEditWrapper.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#pragma once
#ifndef _QTEXT_EDIT_WRAPPER_
#define _QTEXT_EDIT_WRAPPER_

#include <QObject>
#include <QSet>
Expand Down Expand Up @@ -106,4 +108,5 @@ class QTextEditWrapper : public QTextEdit
bool canInsertFromMimeData(const QMimeData* source) const override;
virtual void insertFromMimeData(const QMimeData* source) override;

};
};
#endif
2 changes: 1 addition & 1 deletion textedit/ShareUriWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ShareUriWindow::ShareUriWindow(QString uri, QWidget* parent)
ui->lineEdit_uri->setText(uri);

//Copy icon
ui->pushButton_copy->setIcon(QIcon::QIcon(rsrcPath + "/editor/editcopy.png"));
ui->pushButton_copy->setIcon(QIcon(rsrcPath + "/editor/editcopy.png"));

//Connect pushbutton
connect(ui->pushButton_copy, &QPushButton::clicked, this, &ShareUriWindow::copyAndClose);
Expand Down
19 changes: 12 additions & 7 deletions textedit/TextEdit.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "TextEdit.h"

#include <QApplication>
#include <QDesktopWidget>
//#include <QDesktopWidget>
#include <QActionGroup>
#include <QDesktopServices>
#include <QLabel>
#include <QMenu>
Expand All @@ -20,7 +21,7 @@
#include <QFontDatabase>
#include <QPainter>
#include <QBitmap>
#include <QTextCodec>
//#include <QTextCodec>
#include <QTextEdit>
#include <QTextList>
#include <QTextCursor>
Expand Down Expand Up @@ -174,7 +175,8 @@ void TextEdit::setupMainWindow()
setWindowIcon(QIcon(rsrcPath + "/misc/logo.png"));

//Center and resizes window
const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
// const QRect availableGeometry = QApplication::desktop()->availableGeometry(this);
const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry();

int screenWidth = availableGeometry.width() * 0.6;
resize(screenWidth + 100, availableGeometry.height() * 0.75);
Expand Down Expand Up @@ -578,7 +580,8 @@ void TextEdit::setupEditorActions()
//Combobox setup
comboFont = new QFontComboBox(toolbar);
toolbar->addWidget(comboFont);
connect(comboFont, QOverload<const QString&>::of(&QComboBox::activated), this, &TextEdit::textFamily);
//connect(comboFont, QOverload<const QString&>::of(&QComboBox::activated), this, &TextEdit::textFamily);
connect(comboFont,&QComboBox::textActivated, this, &TextEdit::textFamily);

//Size combobox
comboSize = new QComboBox(toolbar);
Expand All @@ -594,7 +597,8 @@ void TextEdit::setupEditorActions()
//Update current index according to format
comboSize->setCurrentIndex(standardSizes.indexOf(QApplication::font().pointSize()));

connect(comboSize, QOverload<const QString&>::of(&QComboBox::activated), this, &TextEdit::textSize);
// connect(comboSize, QOverload<const QString&>::of(&QComboBox::activated), this, &TextEdit::textSize);
connect(comboSize, &QComboBox::textActivated, this, &TextEdit::textSize);


toolbar->addAction(
Expand Down Expand Up @@ -743,7 +747,8 @@ void TextEdit::removePresence(qint32 userId)

void TextEdit::resizeEditor(const QSizeF& newSize)
{
int height = QApplication::desktop()->availableGeometry(this).height();
//int height = QApplication::desktop()->availableGeometry(this).height();
int height = QGuiApplication::primaryScreen()->availableGeometry().height();
if (newSize.height() > height) {
_textEdit->setFixedHeight(newSize.height());
}
Expand Down Expand Up @@ -1521,7 +1526,7 @@ void TextEdit::colorChanged(const QColor& c)

QPainter painter(&pix);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);

painter.drawPixmap(0, 0, QPixmap(rsrcPath + "/editor/textcolor_top.png"));
Expand Down
Loading