mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Stashed data file can be dropped to model view
* utility functions * style changes / renamings / slots -> normal functions * extra flag to enable file drop (and changed signatures) * split view load function into 2 parts, one can use passed file parameter
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "blackgui/enableforframelesswindow.h"
|
||||
#include "blackgui/guiutility.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackmisc/icon.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
#include <QApplication>
|
||||
@@ -225,6 +226,31 @@ namespace BlackGui
|
||||
return m;
|
||||
}
|
||||
|
||||
QFileInfo CGuiUtility::representedMimeFile(const QMimeData *mime)
|
||||
{
|
||||
if (!mime->hasText()) { return QFileInfo(); }
|
||||
const QString candidate = mime->text();
|
||||
if (candidate.isEmpty()) { return QFileInfo(); }
|
||||
if (!candidate.contains("://")) { return QFileInfo(candidate); }
|
||||
QUrl url(candidate);
|
||||
const QString localFile = url.toLocalFile();
|
||||
return QFileInfo(localFile);
|
||||
}
|
||||
|
||||
bool CGuiUtility::isMimeRepresentingReadableFile(const QMimeData *mime)
|
||||
{
|
||||
const QFileInfo fi = CGuiUtility::representedMimeFile(mime);
|
||||
return fi.isReadable();
|
||||
}
|
||||
|
||||
bool CGuiUtility::isMimeRepresentingReadableJsonFile(const QMimeData *mime)
|
||||
{
|
||||
const QFileInfo fi = CGuiUtility::representedMimeFile(mime);
|
||||
if (!fi.isReadable()) { return false; }
|
||||
const QString fn = fi.fileName();
|
||||
return fn.endsWith("json", Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void CGuiUtility::checkBoxReadOnly(QCheckBox *checkBox, bool readOnly)
|
||||
{
|
||||
static const QCheckBox defaultBox;
|
||||
@@ -519,4 +545,26 @@ namespace BlackGui
|
||||
w->setMinimumWidth(qMin(minW, w->minimumWidth()));
|
||||
w->setMinimumHeight(qMin(minH, w->minimumHeight()));
|
||||
}
|
||||
|
||||
QString CGuiUtility::asSimpleHtmlImageWidth(const CIcon &icon, int width)
|
||||
{
|
||||
if (!icon.hasFileResourcePath()) return QStringLiteral("");
|
||||
const QString p = icon.getFileResourcePath();
|
||||
|
||||
static const QString htmlNoWidth("<img src=\"%1\">");
|
||||
static const QString htmlWidth("<img src=\"%1\" width=%2>");
|
||||
|
||||
if (width < 0) { return htmlNoWidth.arg(p); }
|
||||
return htmlWidth.arg(p, QString::number(width));
|
||||
}
|
||||
|
||||
QString CGuiUtility::asSimpleHtmlImageHeight(const CIcon &icon, int height)
|
||||
{
|
||||
if (height < 0) { return CGuiUtility::asSimpleHtmlImageWidth(icon); }
|
||||
if (!icon.hasFileResourcePath()) return QStringLiteral("");
|
||||
const QString p = icon.getFileResourcePath();
|
||||
|
||||
static const QString htmlHeight("<img src=\"%1\" height=%2>");
|
||||
return htmlHeight.arg(p, QString::number(height));
|
||||
}
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user