mirror of
https://github.com/overte-org/overte.git
synced 2025-08-03 23:03:20 +02:00
Implement "go home" action
This commit is contained in:
parent
f74be226c8
commit
5e00a1ef49
3 changed files with 20 additions and 2 deletions
|
@ -29,6 +29,10 @@
|
|||
#include "Bookmarks.h"
|
||||
#include <QtQuick/QQuickWindow>
|
||||
|
||||
|
||||
const QString Bookmarks::HOME_BOOKMARK = "Home";
|
||||
|
||||
|
||||
Bookmarks::Bookmarks() {
|
||||
_bookmarksFilename = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + BOOKMARKS_FILENAME;
|
||||
readFromFile();
|
||||
|
@ -60,6 +64,10 @@ bool Bookmarks::contains(const QString& name) const {
|
|||
return _bookmarks.contains(name);
|
||||
}
|
||||
|
||||
QString Bookmarks::addressForBookmark(const QString& name) const {
|
||||
return _bookmarks.value(name).toString();
|
||||
}
|
||||
|
||||
void Bookmarks::readFromFile() {
|
||||
QFile loadFile(_bookmarksFilename);
|
||||
|
||||
|
@ -150,7 +158,7 @@ void Bookmarks::bookmarkLocation() {
|
|||
|
||||
void Bookmarks::setHomeLocation() {
|
||||
Menu* menubar = Menu::getInstance();
|
||||
QString bookmarkName = "Home";
|
||||
QString bookmarkName = HOME_BOOKMARK;
|
||||
auto addressManager = DependencyManager::get<AddressManager>();
|
||||
QString bookmarkAddress = addressManager->currentAddress().toString();
|
||||
|
||||
|
|
|
@ -29,6 +29,10 @@ public:
|
|||
|
||||
void setupMenus(Menu* menubar, MenuWrapper* menu);
|
||||
|
||||
QString addressForBookmark(const QString& name) const;
|
||||
|
||||
static const QString HOME_BOOKMARK;
|
||||
|
||||
private slots:
|
||||
void bookmarkLocation();
|
||||
void setHomeLocation();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
//
|
||||
|
||||
#include "AddressBarDialog.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -52,7 +53,12 @@ void AddressBarDialog::loadAddress(const QString& address) {
|
|||
|
||||
void AddressBarDialog::loadHome() {
|
||||
qDebug() << "Called LoadHome";
|
||||
// TODO
|
||||
QString homeLocation = qApp->getBookmarks()->addressForBookmark(Bookmarks::HOME_BOOKMARK);
|
||||
const QString DEFAULT_HOME_LOCATION = "localhost";
|
||||
if (homeLocation == "") {
|
||||
homeLocation = DEFAULT_HOME_LOCATION;
|
||||
}
|
||||
DependencyManager::get<AddressManager>()->handleLookupString(homeLocation);
|
||||
}
|
||||
|
||||
void AddressBarDialog::loadBack() {
|
||||
|
|
Loading…
Reference in a new issue