Fixed issue #624. Icon resulotion issues with some display setups.
--HG-- branch : develop
This commit is contained in:
parent
0ff63c57e4
commit
9c27e7bfed
2
dist/OBS_debian/debian.tape.1
vendored
2
dist/OBS_debian/debian.tape.1
vendored
|
@ -28,6 +28,8 @@ Open with the base size. Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 4
|
|||
Set pattern file unit: cm, mm, inch.
|
||||
.IP "--test"
|
||||
Use for unit testing. Run the program and open a file without showing the main window.
|
||||
.IP "--no-scaling"
|
||||
Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable.
|
||||
.IP Arguments:
|
||||
.I filename
|
||||
\- the measurement file.
|
||||
|
|
2
dist/OBS_debian/debian.valentina.1
vendored
2
dist/OBS_debian/debian.valentina.1
vendored
|
@ -131,6 +131,8 @@ The path to output destination folder. By default the directory at which the app
|
|||
.RE
|
||||
.IP "-t, --test"
|
||||
Run the program in a test mode. The program in this mode loads a single pattern file and silently quit without showing the main window. The key have priority before key \*(lqbasename\*(rq.
|
||||
.IP "--no-scaling"
|
||||
.RB "Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable."
|
||||
.IP Arguments:
|
||||
.I filename
|
||||
\- a pattern file.
|
||||
|
|
2
dist/debian/tape.1
vendored
2
dist/debian/tape.1
vendored
|
@ -28,6 +28,8 @@ Open with the base size. Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 4
|
|||
Set pattern file unit: cm, mm, inch.
|
||||
.IP "--test"
|
||||
Use for unit testing. Run the program and open a file without showing the main window.
|
||||
.IP "--no-scaling"
|
||||
Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable.
|
||||
.IP Arguments:
|
||||
.I filename
|
||||
\- the measurement file.
|
||||
|
|
2
dist/debian/valentina.1
vendored
2
dist/debian/valentina.1
vendored
|
@ -131,6 +131,8 @@ The path to output destination folder. By default the directory at which the app
|
|||
.RE
|
||||
.IP "-t, --test"
|
||||
Run the program in a test mode. The program in this mode loads a single pattern file and silently quit without showing the main window. The key have priority before key \*(lqbasename\*(rq.
|
||||
.IP "--no-scaling"
|
||||
.RB "Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable."
|
||||
.IP Arguments:
|
||||
.I filename
|
||||
\- a pattern file.
|
||||
|
|
|
@ -49,9 +49,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
qt_qhash_seed.store(0); // Lock producing random attribute order in XML
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
|
||||
#endif
|
||||
#ifndef Q_OS_MAC // supports natively
|
||||
InitHighDpiScaling(argc, argv);
|
||||
#endif //Q_OS_MAC
|
||||
|
||||
MApplication app(argc, argv);
|
||||
app.InitOptions();
|
||||
|
|
|
@ -581,6 +581,11 @@ void MApplication::ParseCommandLine(const SocketConnection &connection, const QS
|
|||
tr("Use for unit testing. Run the program and open a file without showing the main window."));
|
||||
parser.addOption(testOption);
|
||||
//-----
|
||||
QCommandLineOption scalingOption(QStringList() << LONG_OPTION_NO_HDPI_SCALING,
|
||||
tr("Disable high dpi scaling. Call this option if has problem with scaling (by default scaling enabled). "
|
||||
"Alternatively you can use the QT_AUTO_SCREEN_SCALE_FACTOR=0 environment variable."));
|
||||
parser.addOption(scalingOption);
|
||||
//-----
|
||||
parser.process(arguments);
|
||||
|
||||
bool flagHeight = false;
|
||||
|
|
|
@ -249,6 +249,14 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
|
|||
"this mode loads a single pattern file and silently quit without "
|
||||
"showing the main window. The key have priority before key '%1'.")
|
||||
.arg(LONG_OPTION_BASENAME)));
|
||||
|
||||
optionsIndex.insert(LONG_OPTION_NO_HDPI_SCALING, index++);
|
||||
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_NO_HDPI_SCALING,
|
||||
translate("VCommandLine", "Disable high dpi scaling. Call this option if has "
|
||||
"problem with scaling (by default scaling "
|
||||
"enabled). Alternatively you can use the "
|
||||
"QT_AUTO_SCREEN_SCALE_FACTOR=0 environment "
|
||||
"variable.")));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
|
@ -500,7 +508,13 @@ bool VCommandLine::IsTestModeEnabled() const
|
|||
return r;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCommandLine::IsNoScalingEnabled() const
|
||||
{
|
||||
return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_NO_HDPI_SCALING)));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCommandLine::IsExportEnabled() const
|
||||
{
|
||||
const bool r = parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_BASENAME)));
|
||||
|
|
|
@ -56,10 +56,14 @@ public:
|
|||
|
||||
//@brief creates object and applies export related options to parser
|
||||
|
||||
//@brief tests if user enabled test mode from cmd, throws exception if not exactly 1 input VAL file supplied in case test mode enabled
|
||||
//@brief tests if user enabled test mode from cmd, throws exception if not exactly 1 input VAL file supplied in
|
||||
//case test mode enabled
|
||||
bool IsTestModeEnabled() const;
|
||||
|
||||
//@brief tests if user enabled export from cmd, throws exception if not exactly 1 input VAL file supplied in case export enabled
|
||||
bool IsNoScalingEnabled() const;
|
||||
|
||||
//@brief tests if user enabled export from cmd, throws exception if not exactly 1 input VAL file supplied in case
|
||||
//export enabled
|
||||
bool IsExportEnabled() const;
|
||||
|
||||
//@brief returns path to custom measure file or empty string
|
||||
|
@ -68,7 +72,8 @@ public:
|
|||
//@brief returns the base name of layout files or empty string if not set
|
||||
QString OptBaseName() const;
|
||||
|
||||
//@brief returns the absolute path to output destination directory or path to application's current directory if not set
|
||||
//@brief returns the absolute path to output destination directory or path to application's current directory if
|
||||
//not set
|
||||
QString OptDestinationPath() const;
|
||||
|
||||
//@brief returns export type set, defaults 0 - svg
|
||||
|
|
|
@ -56,9 +56,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
qRegisterMetaTypeStreamOperators<VPieceNode>("VPieceNode");
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
|
||||
#endif
|
||||
#ifndef Q_OS_MAC // supports natively
|
||||
InitHighDpiScaling(argc, argv);
|
||||
#endif //Q_OS_MAC
|
||||
|
||||
VApplication app(argc, argv);
|
||||
|
||||
|
|
|
@ -1506,6 +1506,12 @@ void MainWindow::ShowMeasurements()
|
|||
<< "-u"
|
||||
<< VDomDocument::UnitsToStr(qApp->patternUnit());
|
||||
}
|
||||
|
||||
if (isNoScaling)
|
||||
{
|
||||
arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING);
|
||||
}
|
||||
|
||||
const QString tape = qApp->TapeFilePath();
|
||||
const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath();
|
||||
QProcess::startDetached(tape, arguments, workingDirectory);
|
||||
|
@ -3779,7 +3785,14 @@ void MainWindow::CreateActions()
|
|||
{
|
||||
const QString tape = qApp->TapeFilePath();
|
||||
const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath();
|
||||
QProcess::startDetached(tape, QStringList(), workingDirectory);
|
||||
|
||||
QStringList arguments;
|
||||
if (isNoScaling)
|
||||
{
|
||||
arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING);
|
||||
}
|
||||
|
||||
QProcess::startDetached(tape, arguments, workingDirectory);
|
||||
});
|
||||
|
||||
connect(ui->actionShowM, &QAction::triggered, this, &MainWindow::ShowMeasurements);
|
||||
|
@ -3906,7 +3919,14 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
|||
{
|
||||
const QString tape = qApp->TapeFilePath();
|
||||
const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath();
|
||||
QProcess::startDetached(tape, QStringList(fileName), workingDirectory);
|
||||
|
||||
QStringList arguments = QStringList() << fileName;
|
||||
if (isNoScaling)
|
||||
{
|
||||
arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING);
|
||||
}
|
||||
|
||||
QProcess::startDetached(tape, arguments, workingDirectory);
|
||||
qApp->exit(V_EX_OK);
|
||||
return false; // stop continue processing
|
||||
}
|
||||
|
@ -4134,7 +4154,14 @@ void MainWindow::CreateMeasurements()
|
|||
{
|
||||
const QString tape = qApp->TapeFilePath();
|
||||
const QString workingDirectory = QFileInfo(tape).absoluteDir().absolutePath();
|
||||
QProcess::startDetached(tape, QStringList(), workingDirectory);
|
||||
|
||||
QStringList arguments;
|
||||
if (isNoScaling)
|
||||
{
|
||||
arguments.append(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING);
|
||||
}
|
||||
|
||||
QProcess::startDetached(tape, arguments, workingDirectory);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -4547,6 +4574,8 @@ void MainWindow::ProcessCMD()
|
|||
const VCommandLinePtr cmd = qApp->CommandLine();
|
||||
auto args = cmd->OptInputFileNames();
|
||||
|
||||
isNoScaling = cmd->IsNoScalingEnabled();
|
||||
|
||||
if (VApplication::IsGUIMode())
|
||||
{
|
||||
ReopenFilesAfterCrash(args);
|
||||
|
|
|
@ -61,11 +61,22 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||
: VAbstractMainWindow(parent), listDetails(QVector<VLayoutPiece>()), currentScene(nullptr), tempSceneLayout(nullptr),
|
||||
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList<QGraphicsItem *>()),
|
||||
shadows(QList<QGraphicsItem *>()), scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()),
|
||||
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr),
|
||||
curFile(QString()),
|
||||
: VAbstractMainWindow(parent),
|
||||
listDetails(),
|
||||
currentScene(nullptr),
|
||||
tempSceneLayout(nullptr),
|
||||
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())),
|
||||
doc(nullptr),
|
||||
papers(),
|
||||
shadows(),
|
||||
scenes(),
|
||||
details(),
|
||||
undoAction(nullptr),
|
||||
redoAction(nullptr),
|
||||
actionDockWidgetToolOptions(nullptr),
|
||||
actionDockWidgetGroups(nullptr),
|
||||
curFile(),
|
||||
isNoScaling(false),
|
||||
isLayoutStale(true),
|
||||
ignorePrinterFields(false),
|
||||
margins(),
|
||||
|
|
|
@ -84,6 +84,7 @@ protected:
|
|||
/** @brief fileName name current pattern file. */
|
||||
QString curFile;
|
||||
|
||||
bool isNoScaling;
|
||||
bool isLayoutStale;
|
||||
bool ignorePrinterFields;
|
||||
QMarginsF margins;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "commandoptions.h"
|
||||
#include "def.h"
|
||||
|
||||
#include <QStaticStringData>
|
||||
#include <QStringData>
|
||||
|
@ -132,7 +133,8 @@ QStringList AllKeys()
|
|||
<< LONG_OPTION_LEFT_MARGIN << SINGLE_OPTION_LEFT_MARGIN
|
||||
<< LONG_OPTION_RIGHT_MARGIN << SINGLE_OPTION_RIGHT_MARGIN
|
||||
<< LONG_OPTION_TOP_MARGIN << SINGLE_OPTION_TOP_MARGIN
|
||||
<< LONG_OPTION_BOTTOM_MARGIN << SINGLE_OPTION_BOTTOM_MARGIN;
|
||||
<< LONG_OPTION_BOTTOM_MARGIN << SINGLE_OPTION_BOTTOM_MARGIN
|
||||
<< LONG_OPTION_NO_HDPI_SCALING;
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -1919,7 +1919,6 @@ QPixmap darkenPixmap(const QPixmap &pixmap)
|
|||
return QPixmap::fromImage(img);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ShowInGraphicalShell(const QString &filePath)
|
||||
{
|
||||
|
@ -1968,3 +1967,41 @@ void ShowInGraphicalShell(const QString &filePath)
|
|||
#endif
|
||||
|
||||
}
|
||||
|
||||
const QString LONG_OPTION_NO_HDPI_SCALING = QStringLiteral("no-scaling");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool IsOptionSet(int argc, char *argv[], const char *option)
|
||||
{
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
if (!qstrcmp(argv[i], option))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// See issue #624. https://bitbucket.org/dismine/valentina/issues/624
|
||||
void InitHighDpiScaling(int argc, char *argv[])
|
||||
{
|
||||
/* For more info see: http://doc.qt.io/qt-5/highdpi.html */
|
||||
if (IsOptionSet(argc, argv, qPrintable(QLatin1String("--") + LONG_OPTION_NO_HDPI_SCALING)))
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
|
||||
#else
|
||||
qputenv("QT_DEVICE_PIXEL_RATIO", QByteArray("1"));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
||||
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // DPI support
|
||||
#else
|
||||
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", QByteArray("1"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,6 +255,10 @@ enum class GSizes : unsigned char { ALL,
|
|||
#define V_FALLTHROUGH
|
||||
#endif
|
||||
|
||||
extern const QString LONG_OPTION_NO_HDPI_SCALING;
|
||||
bool IsOptionSet(int argc, char *argv[], const char *option);
|
||||
void InitHighDpiScaling(int argc, char *argv[]);
|
||||
|
||||
// measurements
|
||||
// A
|
||||
extern const QString height_M; // A01
|
||||
|
|
Loading…
Reference in New Issue
Block a user