Code maintenance for Qt 5:

- Changed qInstallMsgHandler to qInstallMessageHandler
- Changed qt_use_native_dialogs to filedialog_hook (Windows only)

Removed unused method Rshare::winEventFilter and signal Rshare::shutdown (Windows only)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6852 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2013-10-19 23:41:23 +00:00
parent f10f029d45
commit c8b8daf110
7 changed files with 62 additions and 34 deletions

View File

@ -19,7 +19,7 @@
* Boston, MA 02110-1301, USA.
****************************************************************/
#include <QFileDialog>
#include <QFileInfo>
#include "ULListDelegate.h"
#include "xprogressbar.h"

View File

@ -758,7 +758,7 @@ void SetForegroundWindowInternal(HWND hWnd)
_instance->raise();
#ifdef WINDOWS_SYS
SetForegroundWindowInternal(_instance->winId());
SetForegroundWindowInternal((HWND) _instance->winId());
#endif
}

View File

@ -24,7 +24,6 @@
#include <QUrl>
#include <QMimeData>
#include <QTimer>
#include <QFileDialog>
#include <retroshare-gui/RsAutoUpdatePage.h>
#include <gui/common/RsCollectionFile.h>

View File

@ -20,8 +20,6 @@
****************************************************************/
#include "EditChanDetails.h"
#include <QFileDialog>
#include <retroshare/rschannels.h>
#include "util/misc.h"

View File

@ -47,6 +47,12 @@
#include "lang/languagesupport.h"
#include "util/RsGxsUpdateBroadcast.h"
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
#ifdef WINDOWS_SYS
#include <QFileDialog>
#endif
#endif
/*** WINDOWS DON'T LIKE THIS - REDEFINES VER numbers.
#include <gui/qskinobject/qskinobject.h>
****/
@ -88,13 +94,54 @@ static void displayWarningAboutDSAKeys()
msgBox.exec();
}
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
#ifdef WINDOWS_SYS
QStringList filedialog_open_filenames_hook(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
{
return QFileDialog::getOpenFileNames(parent, caption, dir, filter, selectedFilter, options | QFileDialog::DontUseNativeDialog);
}
QString filedialog_open_filename_hook(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
{
return QFileDialog::getOpenFileName(parent, caption, dir, filter, selectedFilter, options | QFileDialog::DontUseNativeDialog);
}
QString filedialog_save_filename_hook(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
{
return QFileDialog::getSaveFileName(parent, caption, dir, filter, selectedFilter, options | QFileDialog::DontUseNativeDialog);
}
QString filedialog_existing_directory_hook(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
{
return QFileDialog::getExistingDirectory(parent, caption, dir, options | QFileDialog::DontUseNativeDialog);
}
#endif
#endif
int main(int argc, char *argv[])
{
#ifdef WINDOWS_SYS
// The current directory of the application is changed when using the native dialog on Windows
// This is a quick fix until libretroshare is using a absolute path in the portable Version
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
typedef QString (*_qt_filedialog_open_filename_hook) (QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
typedef QString (*_qt_filedialog_save_filename_hook) (QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
qt_filedialog_open_filename_hook = filedialog_open_filename_hook;
qt_filedialog_open_filenames_hook = filedialog_open_filenames_hook;
qt_filedialog_save_filename_hook = filedialog_save_filename_hook;
qt_filedialog_existing_directory_hook = filedialog_existing_directory_hook;
#else
extern bool Q_GUI_EXPORT qt_use_native_dialogs;
qt_use_native_dialogs = false;
#endif
{
/* Set the current directory to the application dir,

View File

@ -66,22 +66,24 @@ QDateTime Rshare::mStartupTime;
/** Catches debugging messages from Qt and sends them to RetroShare's logs. If Qt
* emits a QtFatalMsg, we will write the message to the log and then abort().
*/
void
Rshare::qt_msg_handler(QtMsgType type, const char *s)
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
void qt_msg_handler(QtMsgType type, const QMessageLogContext &, const QString &msg)
#else
void qt_msg_handler(QtMsgType type, const char *msg)
#endif
{
QString msg(s);
switch (type) {
case QtDebugMsg:
rDebug("QtDebugMsg: %1").arg(msg);
rDebug(QString("QtDebugMsg: %1").arg(msg));
break;
case QtWarningMsg:
rNotice("QtWarningMsg: %1").arg(msg);
rNotice(QString("QtWarningMsg: %1").arg(msg));
break;
case QtCriticalMsg:
rWarn("QtCriticalMsg: %1").arg(msg);
rWarn(QString("QtCriticalMsg: %1").arg(msg));
break;
case QtFatalMsg:
rError("QtFatalMsg: %1").arg(msg);
rError(QString("QtFatalMsg: %1").arg(msg));
break;
}
if (type == QtFatalMsg) {
@ -98,7 +100,11 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, const QString &dir)
{
mStartupTime = QDateTime::currentDateTime();
#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0)
qInstallMessageHandler(qt_msg_handler);
#else
qInstallMsgHandler(qt_msg_handler);
#endif
#ifndef __APPLE__
@ -179,19 +185,6 @@ Rshare::onEventLoopStarted()
emit running();
}
#if defined(Q_OS_WIN)
/** On Windows, we need to catch the WM_QUERYENDSESSION message
* so we know that it is time to shutdown. */
bool
Rshare::winEventFilter(MSG *msg, long *result)
{
if (msg->message == WM_QUERYENDSESSION) {
emit shutdown();
}
return QApplication::winEventFilter(msg, result);
}
#endif
/** Display usage information regarding command-line arguments. */
/*void
Rshare::printUsage(QString errmsg)

View File

@ -144,12 +144,6 @@ signals:
/** Global timer every second */
void secondTick();
protected:
#if defined(Q_OS_WIN)
/** Filters Windows events, looking for events of interest */
bool winEventFilter(MSG *msg, long *result);
#endif
private slots:
/** Called when the application's main event loop has started. This method
* will emit the running() signal to indicate that the application's event
@ -160,9 +154,6 @@ private slots:
private:
/** customize the date format (defaultlongformat) */
static void customizeDateFormat();
/** Catches debugging messages from Qt and sends them to
* RetroShare's logs. */
static void qt_msg_handler(QtMsgType type, const char *msg);
/** Parse the list of command-line arguments. */
void parseArguments(QStringList args);