Gui: move options to use native or Qt dialogs to class DialogOptions
This commit is contained in:
@@ -50,8 +50,7 @@
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
namespace {
|
||||
bool dontUseNativeDialog()
|
||||
bool DialogOptions::dontUseNativeFileDialog()
|
||||
{
|
||||
#if defined(USE_QT_FILEDIALOG)
|
||||
bool notNativeDialog = true;
|
||||
@@ -64,6 +63,12 @@ bool dontUseNativeDialog()
|
||||
notNativeDialog = group->GetBool("DontUseNativeDialog", notNativeDialog);
|
||||
return notNativeDialog;
|
||||
}
|
||||
|
||||
bool DialogOptions::dontUseNativeColorDialog()
|
||||
{
|
||||
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Dialog");
|
||||
return group->GetBool("DontUseNativeColorDialog", true);
|
||||
}
|
||||
|
||||
/* TRANSLATOR Gui::FileDialog */
|
||||
@@ -177,7 +182,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption,
|
||||
// existing file. Hence we must extract the first matching suffix from the filter list and append it
|
||||
// before showing the file dialog.
|
||||
QString file;
|
||||
if (dontUseNativeDialog()) {
|
||||
if (DialogOptions::dontUseNativeFileDialog()) {
|
||||
QList<QUrl> urls;
|
||||
|
||||
options |= QFileDialog::DontUseNativeDialog;
|
||||
@@ -259,7 +264,7 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c
|
||||
windowTitle = FileDialog::tr("Open");
|
||||
|
||||
QString file;
|
||||
if (dontUseNativeDialog()) {
|
||||
if (DialogOptions::dontUseNativeFileDialog()) {
|
||||
QList<QUrl> urls;
|
||||
|
||||
options |= QFileDialog::DontUseNativeDialog;
|
||||
@@ -320,7 +325,7 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt
|
||||
windowTitle = FileDialog::tr("Open");
|
||||
|
||||
QStringList files;
|
||||
if (dontUseNativeDialog()) {
|
||||
if (DialogOptions::dontUseNativeFileDialog()) {
|
||||
QList<QUrl> urls;
|
||||
|
||||
options |= QFileDialog::DontUseNativeDialog;
|
||||
@@ -708,7 +713,7 @@ void FileChooser::chooseFile()
|
||||
}
|
||||
|
||||
QFileDialog::Options dlgOpt;
|
||||
if (dontUseNativeDialog()) {
|
||||
if (DialogOptions::dontUseNativeFileDialog()) {
|
||||
dlgOpt = QFileDialog::DontUseNativeDialog;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QFileSystemModel>
|
||||
#include <QCompleter>
|
||||
#include <QPointer>
|
||||
#include <FCGlobal.h>
|
||||
|
||||
class QButtonGroup;
|
||||
class QGridLayout;
|
||||
@@ -39,6 +40,17 @@ class QSpacerItem;
|
||||
|
||||
namespace Gui {
|
||||
|
||||
/*!
|
||||
* \brief The DialogOptions class
|
||||
* Helper class to control whether to use native or Qt dialogs.
|
||||
*/
|
||||
class GuiExport DialogOptions
|
||||
{
|
||||
public:
|
||||
static bool dontUseNativeFileDialog();
|
||||
static bool dontUseNativeColorDialog();
|
||||
};
|
||||
|
||||
/**
|
||||
* The FileDialog class provides dialogs that allow users to select files or directories.
|
||||
* \author Werner Mayer
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "Selection.h"
|
||||
#include "BitmapFactory.h"
|
||||
#include "Command.h"
|
||||
#include "FileDialog.h"
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
@@ -237,10 +238,7 @@ public:
|
||||
auto color = item->data(Qt::UserRole).value<QColor>();
|
||||
QColorDialog cd(color, parent);
|
||||
cd.setOption(QColorDialog::ShowAlphaChannel);
|
||||
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Dialog");
|
||||
bool notNativeColorDialog = group->GetBool("DontUseNativeColorDialog", true);
|
||||
if (notNativeColorDialog)
|
||||
if (DialogOptions::dontUseNativeColorDialog())
|
||||
cd.setOptions(QColorDialog::DontUseNativeDialog);
|
||||
if (cd.exec()!=QDialog::Accepted || color==cd.selectedColor())
|
||||
return;
|
||||
@@ -431,10 +429,7 @@ void ElementColors::on_addSelection_clicked()
|
||||
auto color = d->items.front()->data(Qt::UserRole).value<QColor>();
|
||||
QColorDialog cd(color, this);
|
||||
cd.setOption(QColorDialog::ShowAlphaChannel);
|
||||
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Dialog");
|
||||
bool notNativeColorDialog = group->GetBool("DontUseNativeColorDialog", true);
|
||||
if (notNativeColorDialog)
|
||||
if (DialogOptions::dontUseNativeColorDialog())
|
||||
cd.setOptions(QColorDialog::DontUseNativeDialog);
|
||||
if (cd.exec()!=QDialog::Accepted)
|
||||
return;
|
||||
|
||||
@@ -782,10 +782,7 @@ void ColorButton::onChooseColor()
|
||||
if (d->modal) {
|
||||
QColor currentColor = d->col;
|
||||
QColorDialog cd(d->col, this);
|
||||
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Dialog");
|
||||
bool notNativeColorDialog = group->GetBool("DontUseNativeColorDialog", true);
|
||||
if (notNativeColorDialog)
|
||||
if (DialogOptions::dontUseNativeColorDialog())
|
||||
cd.setOptions(QColorDialog::DontUseNativeDialog);
|
||||
cd.setOption(QColorDialog::ColorDialogOption::ShowAlphaChannel, d->allowTransparency);
|
||||
|
||||
@@ -812,10 +809,7 @@ void ColorButton::onChooseColor()
|
||||
if (d->cd.isNull()) {
|
||||
d->old = d->col;
|
||||
d->cd = new QColorDialog(d->col, this);
|
||||
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Dialog");
|
||||
bool notNativeColorDialog = group->GetBool("DontUseNativeColorDialog", true);
|
||||
if (notNativeColorDialog)
|
||||
if (DialogOptions::dontUseNativeColorDialog())
|
||||
d->cd->setOptions(QColorDialog::DontUseNativeDialog);
|
||||
d->cd->setOption(QColorDialog::ColorDialogOption::ShowAlphaChannel, d->allowTransparency);
|
||||
d->cd->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
Reference in New Issue
Block a user