54 #include <QApplication> 
   60 #include <QDirIterator> 
   62 #include <QGuiApplication> 
   64 #include <QLatin1Char> 
   67 #include <QMessageLogger> 
   70 #include <QPrinterInfo> 
   73 #include <QStaticStringData> 
   74 #include <QStringData> 
   75 #include <QStringDataPtr> 
   77 #include <QPixmapCache> 
   78 #include <QGraphicsItem> 
   79 #include <QDesktopServices> 
   87 const QString 
sin_F   = QStringLiteral(
"sin");
 
   88 const QString 
cos_F   = QStringLiteral(
"cos");
 
   89 const QString 
tan_F   = QStringLiteral(
"tan");
 
   90 const QString 
asin_F  = QStringLiteral(
"asin");
 
   91 const QString 
acos_F  = QStringLiteral(
"acos");
 
   92 const QString 
atan_F  = QStringLiteral(
"atan");
 
   93 const QString 
sinh_F  = QStringLiteral(
"sinh");
 
   94 const QString 
cosh_F  = QStringLiteral(
"cosh");
 
   95 const QString 
tanh_F  = QStringLiteral(
"tanh");
 
   96 const QString 
asinh_F = QStringLiteral(
"asinh");
 
   97 const QString 
acosh_F = QStringLiteral(
"acosh");
 
   98 const QString 
atanh_F = QStringLiteral(
"atanh");
 
   99 const QString 
sinD_F   = QStringLiteral(
"sinD");
 
  100 const QString 
cosD_F   = QStringLiteral(
"cosD");
 
  101 const QString 
tanD_F   = QStringLiteral(
"tanD");
 
  102 const QString 
asinD_F  = QStringLiteral(
"asinD");
 
  103 const QString 
acosD_F  = QStringLiteral(
"acosD");
 
  104 const QString 
atanD_F  = QStringLiteral(
"atanD");
 
  105 const QString 
log2_F  = QStringLiteral(
"log2");
 
  106 const QString 
log10_F = QStringLiteral(
"log10");
 
  107 const QString 
log_F   = QStringLiteral(
"log");
 
  108 const QString 
ln_F    = QStringLiteral(
"ln");
 
  109 const QString 
exp_F   = QStringLiteral(
"exp");
 
  110 const QString 
sqrt_F  = QStringLiteral(
"sqrt");
 
  111 const QString 
sign_F  = QStringLiteral(
"sign");
 
  112 const QString 
rint_F  = QStringLiteral(
"rint");
 
  113 const QString 
abs_F   = QStringLiteral(
"abs");
 
  114 const QString 
min_F   = QStringLiteral(
"min");
 
  115 const QString 
max_F   = QStringLiteral(
"max");
 
  116 const QString 
sum_F   = QStringLiteral(
"sum");
 
  117 const QString 
avg_F   = QStringLiteral(
"avg");
 
  118 const QString 
fmod_F  = QStringLiteral(
"fmod");
 
  137 const QString 
pl_size          = QStringLiteral(
"size");
 
  139 const QString 
pl_date          = QStringLiteral(
"date");
 
  140 const QString 
pl_time          = QStringLiteral(
"time");
 
  145 const QString 
pl_pExt          = QStringLiteral(
"pExt");
 
  148 const QString 
pl_mExt          = QStringLiteral(
"mExt");
 
  161 const QString 
pl_wCut          = QStringLiteral(
"wCut");
 
  197 const QString 
trueStr = QStringLiteral(
"true");
 
  200 const QString 
unitMM   = QStringLiteral(
"mm");
 
  201 const QString 
unitCM   = QStringLiteral(
"cm");
 
  203 const QString 
unitPX   = QStringLiteral(
"px");
 
  213     if (not QPixmapCache::find(pixmapPath, &pixmap))
 
  215         pixmap = QPixmap(pixmapPath);
 
  216         QPixmapCache::insert(pixmapPath, pixmap);
 
  219     item->setCursor(QCursor(pixmap, hotX, hotY));
 
  238             return ((val * 10.0) / 25.4) * 
PrintDPI;
 
  257             return ((pix / 
PrintDPI) * 25.4) / 10.0;
 
  298                     return ((value * 10.0) / 25.4) * 
PrintDPI;
 
  324                     return ((value / 
PrintDPI) * 25.4) / 10.0;
 
  354     const qreal bottom = 
UnitConvertor(margins.bottom(),from, to);
 
  356     return QMarginsF(left, top, right, bottom);
 
  363     const QStringList locales = QStringList() << QStringLiteral(
"ru_RU")
 
  364                                               << QStringLiteral(
"uk_UA")
 
  365                                               << QStringLiteral(
"de_DE")
 
  366                                               << QStringLiteral(
"cs_CZ")
 
  367                                               << QStringLiteral(
"he_IL")
 
  368                                               << QStringLiteral(
"fr_FR")
 
  369                                               << QStringLiteral(
"it_IT")
 
  370                                               << QStringLiteral(
"nl_NL")
 
  371                                               << QStringLiteral(
"id_ID")
 
  372                                               << QStringLiteral(
"es_ES")
 
  373                                               << QStringLiteral(
"fi_FI")
 
  374                                               << QStringLiteral(
"en_US")
 
  375                                               << QStringLiteral(
"en_CA")
 
  376                                               << QStringLiteral(
"en_IN")
 
  377                                               << QStringLiteral(
"ro_RO")
 
  378                                               << QStringLiteral(
"zh_CN")
 
  379                                               << QStringLiteral(
"pt_BR")
 
  380                                               << QStringLiteral(
"el_GR");
 
  393     return QFileInfo(fullFileName).fileName();
 
  403     QString headerStr = QObject::tr(
"%1").arg(name);
 
  404     return headerStr.left(1).toUpper();
 
  408 QString 
RelativeMPath(
const QString &patternPath, 
const QString &absoluteMPath)
 
  410     if (patternPath.isEmpty() || absoluteMPath.isEmpty())
 
  412         return absoluteMPath;
 
  415     if (QFileInfo(absoluteMPath).isRelative())
 
  417         return absoluteMPath;
 
  420     return QFileInfo(patternPath).absoluteDir().relativeFilePath(absoluteMPath);
 
  424 QString 
AbsoluteMPath(
const QString &patternPath, 
const QString &relativeMPath)
 
  426     if (patternPath.isEmpty() || relativeMPath.isEmpty())
 
  428         return relativeMPath;
 
  431     if (QFileInfo(relativeMPath).isAbsolute())
 
  433         return relativeMPath;
 
  436     return QFileInfo(QFileInfo(patternPath).absoluteDir(), relativeMPath).absoluteFilePath();
 
  442     QPrinterInfo tmpInfo = info;
 
  443     if(tmpInfo.isNull() || tmpInfo.printerName().isEmpty())
 
  445         const QStringList list = QPrinterInfo::availablePrinterNames();
 
  453             tmpInfo = QPrinterInfo::printerInfo(list.first());
 
  458     printer->setResolution(
static_cast<int>(
PrintDPI));
 
  465     QPageLayout layout = printer->pageLayout();
 
  466     layout.setUnits(QPageLayout::Millimeter);
 
  467     const QMarginsF minMargins = layout.minimumMargins();
 
  479     if (printer.isNull())
 
  491     QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
 
  492     const int imgh = img.height();
 
  493     const int imgw = img.width();
 
  494     for (
int y = 0; y < imgh; ++y)
 
  496         for (
int x = 0; x < imgw; ++x)
 
  499             QRgb pixel = img.pixel(x, y);
 
  500             const int a = qAlpha(pixel);
 
  501             QColor hsvColor(pixel);
 
  502             hsvColor.getHsv(&h, &s, &v);
 
  503             s = qMin(100, s * 2);
 
  505             hsvColor.setHsv(h, s, v);
 
  506             pixel = hsvColor.rgb();
 
  507             img.setPixel(x, y, qRgba(qRed(pixel), qGreen(pixel), qBlue(pixel), a));
 
  510     return QPixmap::fromImage(img);
 
  519     args << 
"tell application \"Finder\"";
 
  523     args << 
"select POSIX file \""+filePath+
"\"";
 
  526     QProcess::startDetached(QStringLiteral(
"osascript"), args);
 
  527 #elif defined(Q_OS_WIN) 
  528     QProcess::startDetached(QStringLiteral(
"explorer"), QStringList{
"/select", QDir::toNativeSeparators(filePath)});
 
  530     QDesktopServices::openUrl(QUrl::fromLocalFile(QFileInfo(filePath).path()));
 
  540     for (
int i = 1; i < argc; ++i)
 
  542         if (!qstrcmp(argv[i], option))
 
  556         QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling);
 
  560         QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); 
 
  565 const QString 
strSlit      = QStringLiteral(
"slit");
 
  605     switch(values.indexOf(value))
 
  654     switch(values.indexOf(value))
 
  674     switch (units.indexOf(unit))
 
  730     QStringList fileNames;
 
  731     QDirIterator it(
qApp->translationsPath(), QStringList(
"seamly2d_*.qm"), QDir::Files, QDirIterator::Subdirectories);
 
  735         fileNames.append(it.fileName());
 
  738     bool englishUS = 
false;
 
  739     const QString en_US = QStringLiteral(
"en_US");
 
  741     for (
int i = 0; i < fileNames.size(); ++i)
 
  745         locale = fileNames.at(i);                  
 
  746         locale.truncate(locale.lastIndexOf(
'.'));  
 
  747         locale.remove(0, locale.indexOf(
'_') + 1); 
 
  751             englishUS = (en_US == locale);
 
  754         QLocale loc = QLocale(locale);
 
  755         QString lang = loc.nativeLanguageName();
 
  756         QIcon ico(QString(
"%1/%2.png").arg(
":/flags").arg(QLocale::countryToString(loc.country())));
 
  758         combobox->addItem(ico, lang, locale);
 
  761     if (combobox->count() == 0 || not englishUS)
 
  764         QIcon ico(QString(
":/flags/United States.png"));
 
  765         QString lang = QLocale(en_US).nativeLanguageName();
 
  766         combobox->addItem(ico, lang, en_US);
 
  770     qint32 index = combobox->findData(
qApp->Settings()->GetLocale());
 
  773         combobox->setCurrentIndex(index);
 
const QString pl_customer
 
Unit StrToUnits(const QString &unit)
 
QString makeHeaderName(const QString &name)
makeHeaderName make a 1 char tablewidgetitem header name based on a translated string.
 
const QString cursorArrowOpenHand
 
const QStringList builInFunctions
 
double ToPixel(double val, const Unit &unit)
 
QSharedPointer< QPrinter > PreparePrinter(const QPrinterInfo &info, QPrinter::PrinterMode mode)
 
void InitHighDpiScaling(int argc, char *argv[])
 
QPixmap darkenPixmap(const QPixmap &pixmap)
 
const QString pl_pFoldPosition
 
QMarginsF GetPrinterFields(const QSharedPointer< QPrinter > &printer)
 
QString notchSubTypeToString(NotchSubType type)
 
const QString pl_pQuantity
 
const QString LONG_OPTION_NO_HDPI_SCALING
 
const QString strIntersection
 
const QStringList labelTemplatePlaceholders
 
QString strippedName(const QString &fullFileName)
strippedName the function call around curFile to exclude the path to the file.
 
void SetItemOverrideCursor(QGraphicsItem *item, const QString &pixmapPath, int hotX, int hotY)
 
const QString strStraightforward
 
const QString pl_mFileName
 
const QString pl_patternName
 
const QString pl_pAnnotation
 
void ShowInGraphicalShell(const QString &filePath)
 
const QString cursorArrowCloseHand
 
const QStringList builInPostfixOperators
 
const QString pl_patternNumber
 
QString AbsoluteMPath(const QString &patternPath, const QString &relativeMPath)
 
bool IsOptionSet(int argc, char *argv[], const char *option)
 
const QString degreeSymbol
 
void InitLanguages(QComboBox *combobox)
 
const QString pl_pFileName
 
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.
 
const QString strVInternal
 
QStringList SupportedLocales()
 
const QString pl_mInterfacing
 
const QString pl_pOrientation
 
QString RelativeMPath(const QString &patternPath, const QString &absoluteMPath)
 
double FromPixel(double pix, const Unit &unit)
 
const QString pl_pRotation
 
const QString pl_mInterlining
 
QMarginsF GetMinPrinterFields(const QSharedPointer< QPrinter > &printer)
 
NotchType stringToNotchType(const QString &value)
 
const QString strBisector
 
const QString strVExternal
 
QString notchTypeToString(NotchType type)
 
qreal UnitConvertor(qreal value, const Unit &from, const Unit &to)
 
NotchSubType stringToNotchSubType(const QString &value)
 
#define translate(context, source)