small code changes for qt5 compatibility

This commit is contained in:
Stephen Birarda 2013-07-24 12:06:55 -07:00
parent 9f2b2d09a9
commit f27eb5e1d8
4 changed files with 22 additions and 18 deletions

View file

@ -9,6 +9,10 @@ add_definitions(-DFV_GUI)
file(GLOB FERVOR_SOURCES *.cpp)
file(GLOB FERVOR_HEADERS *.h)
file(GLOB FERVOR_UI *.ui)
qt5_wrap_ui(FERVOR_WRAPPED_UI ${FERVOR_UI})
LIST(GET FERVOR_HEADERS 1 FIRST_HEADER)
GET_FILENAME_COMPONENT(HEADER_PATH ${FIRST_HEADER} PATH)
list(REMOVE_ITEM FERVOR_HEADERS ${HEADER_PATH}/fvversioncomparator.h)

View file

@ -166,9 +166,9 @@ void GLCanvas::wheelEvent(QWheelEvent* event) {
Application::getInstance()->wheelEvent(event);
}
void messageHandler(QtMsgType type, const char* message) {
fprintf(stdout, "%s", message);
LogDisplay::instance.addMessage(message);
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
fprintf(stdout, "%s", message.toLocal8Bit().constData());
LogDisplay::instance.addMessage(message.toLocal8Bit().constData());
}
Application::Application(int& argc, char** argv, timeval &startup_time) :
@ -223,7 +223,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_applicationStartupTime = startup_time;
_window->setWindowTitle("Interface");
qInstallMsgHandler(messageHandler);
qInstallMessageHandler(messageHandler);
unsigned int listenPort = 0; // bind to an ephemeral port by default
const char** constArgv = const_cast<const char**>(argv);
@ -1217,7 +1217,7 @@ void Application::editPreferences() {
if (domainServerHostname->text().size() > 0) {
// the user input a new hostname, use that
newHostname = domainServerHostname->text().toAscii();
newHostname = domainServerHostname->text().toLocal8Bit();
} else {
// the user left the field blank, use the default hostname
newHostname = QByteArray(DEFAULT_DOMAIN_HOSTNAME);
@ -1513,12 +1513,12 @@ bool Application::sendVoxelsOperation(VoxelNode* node, void* extraData) {
}
void Application::exportVoxels() {
QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString suggestedName = desktopLocation.append("/voxels.svo");
QString fileNameString = QFileDialog::getSaveFileName(_glWidget, tr("Export Voxels"), suggestedName,
tr("Sparse Voxel Octree Files (*.svo)"));
QByteArray fileNameAscii = fileNameString.toAscii();
QByteArray fileNameAscii = fileNameString.toLocal8Bit();
const char* fileName = fileNameAscii.data();
VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s);
if (selectedNode) {
@ -1533,11 +1533,11 @@ void Application::exportVoxels() {
const char* IMPORT_FILE_TYPES = "Sparse Voxel Octree Files, Square PNG, Schematic Files (*.svo *.png *.schematic)";
void Application::importVoxelsToClipboard() {
QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels to Clipboard"), desktopLocation,
tr(IMPORT_FILE_TYPES));
QByteArray fileNameAscii = fileNameString.toAscii();
QByteArray fileNameAscii = fileNameString.toLocal8Bit();
const char* fileName = fileNameAscii.data();
_clipboardTree.eraseAllVoxels();
@ -1567,11 +1567,11 @@ void Application::importVoxelsToClipboard() {
}
void Application::importVoxels() {
QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString fileNameString = QFileDialog::getOpenFileName(_glWidget, tr("Import Voxels"), desktopLocation,
tr(IMPORT_FILE_TYPES));
QByteArray fileNameAscii = fileNameString.toAscii();
QByteArray fileNameAscii = fileNameString.toLocal8Bit();
const char* fileName = fileNameAscii.data();
VoxelTree importVoxels;
@ -2005,7 +2005,7 @@ void Application::update(float deltaTime) {
// Set where I am looking based on my mouse ray (so that other people can see)
glm::vec3 eyePosition;
if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition)) {
if ((_isLookingAtOtherAvatar = isLookingAtOtherAvatar(mouseRayOrigin, mouseRayDirection, eyePosition))) {
// If the mouse is over another avatar's head...
glm::vec3 myLookAtFromMouse(eyePosition);
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
@ -2270,7 +2270,7 @@ void Application::updateAvatar(float deltaTime) {
_viewFrustum.computePickRay(MIDPOINT_OF_SCREEN, MIDPOINT_OF_SCREEN, screenCenterRayOrigin, screenCenterRayDirection);
glm::vec3 eyePosition;
if (_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition)) {
if ((_isLookingAtOtherAvatar = isLookingAtOtherAvatar(screenCenterRayOrigin, screenCenterRayDirection, eyePosition))) {
glm::vec3 myLookAtFromMouse(eyePosition);
_myAvatar.getHead().setLookAtPosition(myLookAtFromMouse);
}
@ -3584,7 +3584,7 @@ void Application::saveSettings(QSettings* settings) {
}
void Application::importSettings() {
QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation));
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
QString fileName = QFileDialog::getOpenFileName(_window,
tr("Open .ini config file"),
locationDir,
@ -3596,7 +3596,7 @@ void Application::importSettings() {
}
void Application::exportSettings() {
QString locationDir(QDesktopServices::displayName(QDesktopServices::DesktopLocation));
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
QString fileName = QFileDialog::getSaveFileName(_window,
tr("Save .ini config file"),
locationDir,

View file

@ -121,7 +121,7 @@ void AvatarVoxelSystem::setVoxelURL(const QUrl& url) {
// handle "file://" urls...
if (url.isLocalFile()) {
QString pathString = url.path();
QByteArray pathAsAscii = pathString.toAscii();
QByteArray pathAsAscii = pathString.toLocal8Bit();
const char* path = pathAsAscii.data();
readFromSVOFile(path);
return;
@ -255,7 +255,7 @@ void AvatarVoxelSystem::handleVoxelDownloadProgress(qint64 bytesReceived, qint64
}
void AvatarVoxelSystem::handleVoxelReplyError() {
qDebug("%s\n", _voxelReply->errorString().toAscii().constData());
qDebug("%s\n", _voxelReply->errorString().toLocal8Bit().constData());
_voxelReply->disconnect(this);
_voxelReply->deleteLater();

View file

@ -66,7 +66,7 @@ bool ChatEntry::keyPressEvent(QKeyEvent* event) {
return true;
}
if (_contents.size() < MAX_CONTENT_LENGTH) {
_contents.insert(_cursorPos, 1, text.at(0).toAscii());
_contents.insert(_cursorPos, 1, text.at(0).toLatin1());
_cursorPos++;
}
return true;