Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
UI|Client: Opening a web page (macOS); FileDialog in CVarNativePathWi…
…dget
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 0081a81 commit c320edc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
7 changes: 5 additions & 2 deletions doomsday/apps/client/src/clientapp.cpp
Expand Up @@ -173,7 +173,7 @@ DE_PIMPL(ClientApp)
InFineSystem infineSys; // instantiated at construction time
ServerLink * svLink = nullptr;
ClientServerWorld * world = nullptr;

/**
* Log entry sink that passes warning messages to the main window's alert
* notification dialog.
Expand Down Expand Up @@ -984,8 +984,11 @@ void ClientApp::openInBrowser(const String &url)
ClientWindow::main().changeAttributes(windowed);
#endif

// QDesktopServices::openUrl(url);
#if defined (MACOSX)
CommandLine({"/usr/bin/open", url}).execute();
#else
DE_ASSERT_FAIL("Open a browser");
#endif
}

void ClientApp::unloadGame(const GameProfile &upcomingGame)
Expand Down
Expand Up @@ -22,6 +22,7 @@

#include <doomsday/console/var.h>
#include <de/PopupMenuWidget>
#include <de/FileDialog>

using namespace de;

Expand Down
22 changes: 12 additions & 10 deletions doomsday/apps/client/src/ui/widgets/nativepathwidget.cpp
Expand Up @@ -115,23 +115,25 @@ void NativePathWidget::setPath(const NativePath &path)
void NativePathWidget::chooseUsingNativeFileDialog()
{
ClientApp::app().beginNativeUIMode();

// Use a native dialog to pick the path.
QDir dir(d->path);
if (d->path.isEmpty()) dir = QDir::home();
QFileDialog dlg(nullptr, d->prompt, dir.absolutePath());
NativePath dir = d->path;
if (d->path.isEmpty()) dir = NativePath::homePath();
FileDialog dlg;
dlg.setTitle(Stringf("Select File for \"%s\"", d->cvar));
dlg.setInitialLocation(NativePath::workPath() / dir);
if (!d->filters.isEmpty())
{
dlg.setNameFilters(d->filters);
dlg.setFileTypes(d->filters);
}
dlg.setFileMode(QFileDialog::ExistingFile);
dlg.setOption(QFileDialog::ReadOnly, true);
dlg.setLabelText(QFileDialog::Accept, tr("Select"));
dlg.setPrompt("Select");
if (dlg.exec())
{
setPath(dlg.selectedFiles().at(0));
d->path = dlg.selectedPath();
setCVarValueFromWidget();
setText(d->labelText());
}

ClientApp::app().endNativeUIMode();
}

Expand Down

0 comments on commit c320edc

Please sign in to comment.