--- a/dirbrowser/cdbrowser.cpp
+++ b/dirbrowser/cdbrowser.cpp
@@ -48,8 +48,10 @@
#include <QApplication>
#include <QByteArray>
#include <QProgressDialog>
+#include <QClipboard>
#include "HelperStructs/Helper.h"
+#include "HelperStructs/Style.h"
#include "HelperStructs/CSettingsStorage.h"
#include "libupnpp/log.hxx"
@@ -72,27 +74,27 @@
static void msleep(int millis)
{
- struct timespec spec;
- spec.tv_sec = millis / 1000;
- spec.tv_nsec = (millis % 1000) * 1000000;
- nanosleep(&spec, 0);
+struct timespec spec;
+spec.tv_sec = millis / 1000;
+spec.tv_nsec = (millis % 1000) * 1000000;
+nanosleep(&spec, 0);
}
void CDWebPage::javaScriptConsoleMessage(
#ifdef USING_WEBENGINE
- JavaScriptConsoleMessageLevel,
+JavaScriptConsoleMessageLevel,
#endif
const QString& msg, int lineNum, const QString&)
{
- Q_UNUSED(msg);
- Q_UNUSED(lineNum);
- LOGDEB("JAVASCRIPT: "<< qs2utf8s(msg) << " at line " << lineNum << endl);
+Q_UNUSED(msg);
+Q_UNUSED(lineNum);
+LOGDEB("JAVASCRIPT: "<< qs2utf8s(msg) << " at line " << lineNum << endl);
}
static const QString html_top_orig = QString::fromUtf8(
- "<html><head>"
- "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">"
- );
+"<html><head>"
+"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">"
+);
// The const part + the js we need for webengine
static QString html_top_js;
@@ -103,47 +105,47 @@
: QWEBVIEW(parent), m_reader(0), m_reaper(0), m_progressD(0),
m_browsers(0), m_lastbutton(Qt::LeftButton), m_sysUpdId(0)
{
- setPage(new CDWebPage(this));
+setPage(new CDWebPage(this));
#ifdef USING_WEBENGINE
- if (html_top_js.isEmpty()) {
- QLoggingCategory("js").setEnabled(QtDebugMsg, true);
+if (html_top_js.isEmpty()) {
+QLoggingCategory("js").setEnabled(QtDebugMsg, true);
#if !defined(Q_OS_MACOS) && !defined(Q_OS_MAC)
- QString jsfn = Helper::getSharePath() + "/cdbrowser/containerscript.js";
+QString jsfn = Helper::getSharePath() + "/cdbrowser/containerscript.js";
#else
- QString jsfn = Helper::getSharePath() + "/Resources/containerscript.js";
+QString jsfn = Helper::getSharePath() + "/Resources/containerscript.js";
#endif
- QString js = "<script type=\"text/javascript\">\n";
- js += QString::fromUtf8(Helper::readFileToByteArray(jsfn));
- js += "</script>\n";
- html_top_js = html_top + js;
- }
+QString js = "<script type=\"text/javascript\">\n";
+js += QString::fromUtf8(Helper::readFileToByteArray(jsfn));
+js += "</script>\n";
+html_top_js = html_top + js;
+}
#else
- html_top_js = html_top;
- connect(this, SIGNAL(linkClicked(const QUrl &)),
+html_top_js = html_top;
+connect(this, SIGNAL(linkClicked(const QUrl &)),
this, SLOT(onLinkClicked(const QUrl &)));
- // Not available and not sure that this is needed with webengine ?
- connect(page()->mainFrame(), SIGNAL(contentsSizeChanged(const QSize&)),
+// Not available and not sure that this is needed with webengine ?
+connect(page()->mainFrame(), SIGNAL(contentsSizeChanged(const QSize&)),
this, SLOT(onContentsSizeChanged(const QSize&)));
- page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
+page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
#endif
- // This sets html_top
- setStyleSheet(CSettingsStorage::getInstance()->getPlayerStyle(), false);
+// This sets html_top
+setStyleSheet(CSettingsStorage::getInstance()->getPlayerStyle(), false);
- settings()->setAttribute(QWEBSETTINGS::JavascriptEnabled, true);
- if (parent) {
- settings()->setFontSize(QWEBSETTINGS::DefaultFontSize,
- parent->font().pointSize()+4);
- settings()->setFontFamily(QWEBSETTINGS::StandardFont,
- parent->font().family());
- }
- setContextMenuPolicy(Qt::CustomContextMenu);
- connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
- this, SLOT(createPopupMenu(const QPoint&)));
- m_timer.setSingleShot(1);
- connect(&m_timer, SIGNAL(timeout()), this, SLOT(initialPage()));
- m_timer.start(0);
+settings()->setAttribute(QWEBSETTINGS::JavascriptEnabled, true);
+if (parent) {
+settings()->setFontSize(QWEBSETTINGS::DefaultFontSize,
+ parent->font().pointSize()+4);
+settings()->setFontFamily(QWEBSETTINGS::StandardFont,
+ parent->font().family());
+}
+setContextMenuPolicy(Qt::CustomContextMenu);
+connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
+ this, SLOT(createPopupMenu(const QPoint&)));
+m_timer.setSingleShot(1);
+connect(&m_timer, SIGNAL(timeout()), this, SLOT(initialPage()));
+m_timer.start(0);
}
CDBrowser::~CDBrowser()
@@ -183,6 +185,11 @@
#endif
QString cssdata = QString::fromUtf8(Helper::readFileToByteArray(cssfn));
+ float multiplier = QSettings().value("wholeuiscale").toFloat();
+ if (multiplier == 0)
+ multiplier = 1.0;
+ cssdata = u8s2qs(Style::scale_fonts(qs2utf8s(cssdata), multiplier));
+
if (dark) {
#if defined(Q_OS_MACOS) || defined(Q_OS_MAC)
cssfn = Helper::getSharePath() + "/Resources/dark.css";
@@ -965,6 +972,7 @@
PUP_RAND_PLAY_GROUPS,
PUP_RAND_STOP,
PUP_SORT_ORDER,
+ PUP_COPY_URL,
};
void CDBrowser::onLoadFinished(bool)
@@ -1086,6 +1094,11 @@
v = QVariant(int(PUP_ADD_FROMHERE));
act->setData(v);
popup->addAction(act);
+
+ act = new QAction(tr("Copy URL"), this);
+ v = QVariant(int(PUP_COPY_URL));
+ act->setData(v);
+ popup->addAction(act);
}
// Connect to either recursive add or simpleAdd depending on entry type.
@@ -1175,6 +1188,17 @@
MetaDataList mdl;
unsigned int starti = 0;
switch (m_popupmode) {
+ case PUP_COPY_URL:
+ {
+ UPnPDirObject& e(m_entries[m_popupidx]);
+ if (e.m_resources.empty()) {
+
+ }
+ QString uri = QString::fromLocal8Bit(e.m_resources[0].m_uri.c_str());
+ QApplication::clipboard()->setText(uri, QClipboard::Selection);
+ QApplication::clipboard()->setText(uri, QClipboard::Clipboard);
+ return;
+ }
case PUP_ADD_FROMHERE:
starti = m_popupidx;
/* FALLTHROUGH */