Merge pull request #2379 from kthchew/fix/blocked-desc
Improve blocked mods dialog (permissions prompt, misc. fixes) on macOS
This commit is contained in:
commit
c703babda9
@ -6,6 +6,8 @@
|
||||
<string>A Minecraft mod wants to access your camera.</string>
|
||||
<key>NSMicrophoneUsageDescription</key>
|
||||
<string>A Minecraft mod wants to access your microphone.</string>
|
||||
<key>NSDownloadsFolderUsageDescription</key>
|
||||
<string>Prism uses access to your Downloads folder to help you more quickly add mods that can't be automatically downloaded to your instance. You can change where Prism scans for downloaded mods in Settings or the prompt that appears.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSHighResolutionCapable</key>
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QPushButton>
|
||||
#include <QStandardPaths>
|
||||
#include <QTimer>
|
||||
|
||||
BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, const QString& text, QList<BlockedMod>& mods, QString hash_type)
|
||||
: QDialog(parent), ui(new Ui::BlockedModsDialog), m_mods(mods), m_hash_type(hash_type)
|
||||
@ -60,8 +61,13 @@ BlockedModsDialog::BlockedModsDialog(QWidget* parent, const QString& title, cons
|
||||
|
||||
qDebug() << "[Blocked Mods Dialog] Mods List: " << mods;
|
||||
|
||||
setupWatch();
|
||||
scanPaths();
|
||||
// defer setup of file system watchers until after the dialog is shown
|
||||
// this allows OS (namely macOS) permission prompts to show after the relevant dialog appears
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
setupWatch();
|
||||
scanPaths();
|
||||
update();
|
||||
});
|
||||
|
||||
this->setWindowTitle(title);
|
||||
ui->labelDescription->setText(text);
|
||||
@ -158,7 +164,8 @@ void BlockedModsDialog::update()
|
||||
|
||||
QString watching;
|
||||
for (auto& dir : m_watcher.directories()) {
|
||||
watching += QString("<a href=\"%1\">%1</a><br/>").arg(dir);
|
||||
QUrl fileURL = QUrl::fromLocalFile(dir);
|
||||
watching += QString("<a href=\"%1\">%2</a><br/>").arg(fileURL.toString(), dir);
|
||||
}
|
||||
|
||||
ui->textBrowserWatched->setText(watching);
|
||||
@ -194,6 +201,10 @@ void BlockedModsDialog::setupWatch()
|
||||
void BlockedModsDialog::watchPath(QString path, bool watch_recursive)
|
||||
{
|
||||
auto to_watch = QFileInfo(path);
|
||||
if (!to_watch.isReadable()) {
|
||||
qWarning() << "[Blocked Mods Dialog] Failed to add Watch Path (unable to read):" << path;
|
||||
return;
|
||||
}
|
||||
auto to_watch_path = to_watch.canonicalFilePath();
|
||||
if (m_watcher.directories().contains(to_watch_path))
|
||||
return; // don't watch the same path twice (no loops!)
|
||||
|
Loading…
Reference in New Issue
Block a user