Merge pull request #1320 from hunbernd/feature/native-dialogs

Added switch to enable native dialogs at compile time
This commit is contained in:
csoler 2019-01-11 15:24:21 +01:00 committed by GitHub
commit 3c4d4e37e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 10 deletions

View File

@ -48,7 +48,7 @@ echo.
title Build - %SourceName%-%RsBuildConfig% [qmake]
set RS_QMAKE_CONFIG="CONFIG+=%RsBuildConfig%"
set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=%RsBuildConfig%"
if "%ParamAutologin%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=rs_autologin"
if "%ParamPlugins%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% "CONFIG+=retroshare_plugins"
@ -63,7 +63,7 @@ echo.
title Build - %SourceName%-%RsBuildConfig% [make]
%EnvMSYS2Cmd% "make -j 4"
%EnvMSYS2Cmd% "make -j %NUMBER_OF_PROCESSORS%"
:error
popd

View File

@ -6,6 +6,7 @@ set ParamDebug=0
set ParamAutologin=0
set ParamPlugins=0
set ParamTor=0
set RS_QMAKE_CONFIG=
:parameter_loop
if "%~1" NEQ "" (
@ -24,6 +25,8 @@ if "%~1" NEQ "" (
set ParamPlugins=1
) else if "%%~a"=="tor" (
set ParamTor=1
) else if "%%~a"=="CONFIG+" (
set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% %1
) else (
echo.
echo Unknown parameter %1

View File

@ -37,6 +37,7 @@
#include "gui/common/GroupDefs.h"
#include "gui/notifyqt.h"
#include "util/QtVersion.h"
#include "util/misc.h"
/* Images for context menu icons */
#define IMAGE_CANCEL ":/images/delete.png"
@ -123,7 +124,7 @@ void ShareManager::doubleClickedCell(int row,int column)
{
if(column == COLUMN_PATH)
{
QString dirname = QFileDialog::getExistingDirectory(NULL,tr("Choose directory"),QString(),QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly);
QString dirname = misc::getExistingDirectory(nullptr,tr("Choose directory"),QString());
if(!dirname.isNull())
{
@ -357,7 +358,7 @@ void ShareManager::showEvent(QShowEvent *event)
void ShareManager::addShare()
{
QString fname = QFileDialog::getExistingDirectory(NULL,tr("Choose a directory to share"),QString(),QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly);
QString fname = misc::getExistingDirectory(nullptr,tr("Choose a directory to share"),QString());
if(fname.isNull())
return;

View File

@ -22,7 +22,6 @@
#include <QApplication>
#include <QBuffer>
#include <QColorDialog>
#include <QFontDialog>
#include <QKeyEvent>
#include <QMenu>
#include <QMessageBox>
@ -1487,7 +1486,8 @@ void ChatWidget::chooseFont()
{
bool ok;
//Use NULL as parent as with this QFontDialog don't take care of title nether options.
QFont font = QFontDialog::getFont(&ok, currentFont, NULL, tr("Choose your font."),QFontDialog::DontUseNativeDialog);
QFont font = misc::getFont(&ok, currentFont, nullptr, tr("Choose your font."));
if (ok) {
currentFont = font;
setFont();

View File

@ -19,7 +19,6 @@
*******************************************************************************/
#include <QColorDialog>
#include <QFontDialog>
#include <QMenu>
#include <QMessageBox>
#include <time.h>
@ -415,7 +414,8 @@ ChatPage::load()
void ChatPage::on_pushButtonChangeChatFont_clicked()
{
bool ok;
QFont font = QFontDialog::getFont(&ok, fontTempChat, this, tr("Choose your default font for Chat."),QFontDialog::DontUseNativeDialog);
QFont font = misc::getFont(&ok, fontTempChat, this, tr("Choose your default font for Chat."));
if (ok) {
fontTempChat = font;
// using fontTempChat.rawname() does not always work!

View File

@ -25,6 +25,7 @@
#include <QByteArray>
#include <QBuffer>
#include <time.h>
#include <QFontDialog>
#include "misc.h"
@ -315,7 +316,11 @@ bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type
{
QString lastDir = Settings->getLastDir(type);
#ifdef RS_NATIVEDIALOGS
file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks | options);
#else
file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog | options);
#endif
if (file.isEmpty())
return false;
@ -338,7 +343,11 @@ bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type
{
QString lastDir = Settings->getLastDir(type);
#ifdef RS_NATIVEDIALOGS
files = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks | options);
#else
files = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog | options);
#endif
if (files.isEmpty())
return false;
@ -364,7 +373,11 @@ bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type
{
QString lastDir = Settings->getLastDir(type) + "/" + file;
#ifdef RS_NATIVEDIALOGS
file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter, selectedFilter, options);
#else
file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter, selectedFilter, QFileDialog::DontUseNativeDialog | options);
#endif
if (file.isEmpty())
return false;
@ -372,5 +385,23 @@ bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type
lastDir = QFileInfo(file).absoluteDir().absolutePath();
Settings->setLastDir(type, lastDir);
return true;
return true;
}
QFont misc::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title)
{
#ifdef RS_NATIVEDIALOGS
return QFontDialog::getFont(ok, initial, parent, title);
#else
return QFontDialog::getFont(ok, initial, parent, title, QFontDialog::DontUseNativeDialog);
#endif
}
QString misc::getExistingDirectory(QWidget *parent, const QString &caption, const QString &dir)
{
#ifdef RS_NATIVEDIALOGS
return QFileDialog::getExistingDirectory(parent, caption, dir, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
#else
return QFileDialog::getExistingDirectory(parent, caption, dir, QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
#endif
}

View File

@ -171,8 +171,17 @@ class misc : public QObject
static bool getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type
, const QString &caption , const QString &filter
, QString &file, QString *selectedFilter = NULL
, QString &file, QString *selectedFilter = NULL
, QFileDialog::Options options = 0);
static QFont getFont(bool *ok
, const QFont &initial
, QWidget *parent = nullptr
, const QString &title = QString());
static QString getExistingDirectory(QWidget *parent = nullptr
, const QString &caption = QString()
, const QString &dir = QString());
};
// Trick to get a portable sleep() function

View File

@ -186,6 +186,9 @@ rs_deep_search:CONFIG -= no_rs_deep_search
# assignation to qmake command line 'RS_EXTRA_VERSION=""'
#RS_EXTRA_VERSION=git
# To enable native dialogs append the following assignation to qmake command line
# "CONFIG+=rs_use_native_dialogs"
rs_use_native_dialogs:DEFINES *= RS_NATIVEDIALOGS
###########################################################################################################################################################
#