mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
cleanup handleUrl call, add disabling of Menu items
This commit is contained in:
parent
ef62f7e9f0
commit
1af4b1c54c
3 changed files with 51 additions and 15 deletions
|
@ -94,17 +94,25 @@ Menu::Menu() {
|
|||
|
||||
addDisabledActionAndSeparator(fileMenu, "History");
|
||||
|
||||
addActionToQMenuAndActionHash(fileMenu,
|
||||
MenuOption::Back,
|
||||
0,
|
||||
addressManager.data(),
|
||||
SLOT(goBack()));
|
||||
QAction* backAction = addActionToQMenuAndActionHash(fileMenu,
|
||||
MenuOption::Back,
|
||||
0,
|
||||
addressManager.data(),
|
||||
SLOT(goBack()));
|
||||
|
||||
addActionToQMenuAndActionHash(fileMenu,
|
||||
MenuOption::Forward,
|
||||
0,
|
||||
addressManager.data(),
|
||||
SLOT(goForward()));
|
||||
QAction* forwardAction = addActionToQMenuAndActionHash(fileMenu,
|
||||
MenuOption::Forward,
|
||||
0,
|
||||
addressManager.data(),
|
||||
SLOT(goForward()));
|
||||
|
||||
// connect to the AddressManager signal to enable and disable the back and forward menu items
|
||||
connect(addressManager.data(), &AddressManager::goBackPossible, backAction, &QAction::setEnabled);
|
||||
connect(addressManager.data(), &AddressManager::goForwardPossible, forwardAction, &QAction::setEnabled);
|
||||
|
||||
// set the two actions to start disabled since the stacks are clear on startup
|
||||
backAction->setDisabled(true);
|
||||
forwardAction->setDisabled(true);
|
||||
|
||||
addDisabledActionAndSeparator(fileMenu, "Location");
|
||||
qApp->getBookmarks()->setupMenus(this, fileMenu);
|
||||
|
|
|
@ -62,11 +62,13 @@ void AddressManager::loadSettings(const QString& lookupString) {
|
|||
|
||||
void AddressManager::goBack() {
|
||||
if (_backStack.size() > 0) {
|
||||
// pop a URL from the backStack
|
||||
QUrl poppedURL = _backStack.pop();
|
||||
|
||||
// go to that address
|
||||
handleUrl(poppedURL, LookupTrigger::Back);
|
||||
handleUrl(_backStack.pop(), LookupTrigger::Back);
|
||||
|
||||
if (_backStack.size() == 0) {
|
||||
// the back stack is now empty so it is no longer possible to go back - emit that signal
|
||||
emit goBackPossible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,6 +76,11 @@ void AddressManager::goForward() {
|
|||
if (_forwardStack.size() > 0) {
|
||||
// pop a URL from the forwardStack and go to that address
|
||||
handleUrl(_forwardStack.pop(), LookupTrigger::Forward);
|
||||
|
||||
if (_forwardStack.size() == 0) {
|
||||
// the forward stack is empty so it is no longer possible to go forwards - emit that signal
|
||||
emit goForwardPossible(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -580,12 +587,27 @@ void AddressManager::addCurrentAddressToHistory(LookupTrigger trigger) {
|
|||
if (trigger == LookupTrigger::UserInput) {
|
||||
// anyime the user has manually looked up an address we know we should clear the forward stack
|
||||
_forwardStack.clear();
|
||||
|
||||
emit goForwardPossible(false);
|
||||
}
|
||||
|
||||
if (trigger == LookupTrigger::Back) {
|
||||
// when the user is going back, we move the current address to the forward stack and do not but it into the back stack
|
||||
// we're about to push to the forward stack
|
||||
// if it's currently empty emit our signal to say that going forward is now possible
|
||||
if (_forwardStack.size() == 0) {
|
||||
emit goForwardPossible(true);
|
||||
}
|
||||
|
||||
// when the user is going back, we move the current address to the forward stack
|
||||
// and do not but it into the back stack
|
||||
_forwardStack.push(currentAddress());
|
||||
} else {
|
||||
// we're about to push to the back stack
|
||||
// if it's currently empty emit our signal to say that going forward is now possible
|
||||
if (_forwardStack.size() == 0) {
|
||||
emit goBackPossible(true);
|
||||
}
|
||||
|
||||
// unless this was triggered from the result of a named path lookup, add the current address to the history
|
||||
_backStack.push(currentAddress());
|
||||
}
|
||||
|
|
|
@ -81,13 +81,19 @@ signals:
|
|||
void lookupResultsFinished();
|
||||
void lookupResultIsOffline();
|
||||
void lookupResultIsNotFound();
|
||||
|
||||
void possibleDomainChangeRequired(const QString& newHostname, quint16 newPort);
|
||||
void possibleDomainChangeRequiredViaICEForID(const QString& iceServerHostname, const QUuid& domainID);
|
||||
|
||||
void locationChangeRequired(const glm::vec3& newPosition,
|
||||
bool hasOrientationChange, const glm::quat& newOrientation,
|
||||
bool shouldFaceLocation);
|
||||
void pathChangeRequired(const QString& newPath);
|
||||
void hostChanged(const QString& newHost);
|
||||
|
||||
void goBackPossible(bool isPossible);
|
||||
void goForwardPossible(bool isPossible);
|
||||
|
||||
protected:
|
||||
AddressManager();
|
||||
private slots:
|
||||
|
|
Loading…
Reference in a new issue