Permalink
Browse files

Total overhaul of actions handling, references #616, fixes #592

- use only numeric identifiers;
- do not rely on actions supplied by QtWebKit (they are often broken under Windows);
- decouple shortcuts from actions;
- create global actions on demand;
- always show keyboard shortcut of action, no matter if it is global or local instance;
- slightly reduced memory usage;
- hopefully no regressions other than keyboard shortcuts configuration being temporarily unavailable.
  • Loading branch information...
Emdek committed Dec 28, 2014
1 parent 3d1295d commit 30719aa16ff10dd69c3bf962f6ab7d8616b7387b
Showing with 1,743 additions and 2,016 deletions.
  1. +1 −2 CMakeLists.txt
  2. +0 −2 otter.pro
  3. +11 −11 resources/keyboard/default.ini
  4. +4 −4 resources/other/menuBar.json
  5. +2 −2 resources/other/menuButton.json
  6. +30 −21 src/core/Action.cpp
  7. +130 −112 src/core/Action.h
  8. +515 −306 src/core/ActionsManager.cpp
  9. +57 −24 src/core/ActionsManager.h
  10. +2 −2 src/core/GesturesManager.cpp
  11. +1 −1 src/core/GesturesManager.h
  12. +0 −221 src/core/ShortcutsManager.cpp
  13. +0 −64 src/core/ShortcutsManager.h
  14. +15 −42 src/core/WindowsManager.cpp
  15. +2 −2 src/core/WindowsManager.h
  16. +1 −1 src/modules/backends/web/qtwebkit/QtWebKitWebPage.cpp
  17. +355 −531 src/modules/backends/web/qtwebkit/QtWebKitWebWidget.cpp
  18. +4 −5 src/modules/backends/web/qtwebkit/QtWebKitWebWidget.h
  19. +14 −16 src/modules/windows/bookmarks/BookmarksContentsWidget.cpp
  20. +3 −3 src/modules/windows/bookmarks/BookmarksContentsWidget.h
  21. +16 −18 src/modules/windows/cache/CacheContentsWidget.cpp
  22. +3 −3 src/modules/windows/cache/CacheContentsWidget.h
  23. +0 −1 src/modules/windows/configuration/ConfigurationContentsWidget.h
  24. +20 −35 src/modules/windows/cookies/CookiesContentsWidget.cpp
  25. +3 −3 src/modules/windows/cookies/CookiesContentsWidget.h
  26. +1 −1 src/modules/windows/history/HistoryContentsWidget.cpp
  27. +0 −1 src/modules/windows/history/HistoryContentsWidget.h
  28. +20 −35 src/modules/windows/transfers/TransfersContentsWidget.cpp
  29. +3 −3 src/modules/windows/transfers/TransfersContentsWidget.h
  30. +13 −13 src/modules/windows/web/WebContentsWidget.cpp
  31. +2 −2 src/modules/windows/web/WebContentsWidget.h
  32. +18 −3 src/ui/ActionWidget.cpp
  33. +1 −1 src/ui/ActionWidget.h
  34. +8 −8 src/ui/AddressWidget.cpp
  35. +4 −4 src/ui/ContentsWidget.cpp
  36. +2 −2 src/ui/ContentsWidget.h
  37. +1 −1 src/ui/GoBackActionWidget.cpp
  38. +1 −1 src/ui/GoForwardActionWidget.cpp
  39. +270 −278 src/ui/MainWindow.cpp
  40. +2 −22 src/ui/MainWindow.h
  41. +2 −2 src/ui/MdiWidget.cpp
  42. +12 −11 src/ui/Menu.cpp
  43. +69 −69 src/ui/PreferencesDialog.cpp
  44. +1 −1 src/ui/TabBarToolBarWidget.cpp
  45. +7 −11 src/ui/TabBarWidget.cpp
  46. +67 −67 src/ui/WebWidget.cpp
  47. +2 −2 src/ui/WebWidget.h
  48. +14 −14 src/ui/Window.cpp
  49. +1 −1 src/ui/Window.h
  50. +32 −30 src/ui/preferences/ShortcutsProfileDialog.cpp
  51. +1 −1 src/ui/toolbars/MenuActionWidget.cpp
@@ -93,7 +93,6 @@ set(otter_src
src/core/SearchSuggester.cpp
src/core/SessionsManager.cpp
src/core/SettingsManager.cpp
src/core/ShortcutsManager.cpp
src/core/TransfersManager.cpp
src/core/Utils.cpp
src/core/WebBackend.cpp
@@ -223,7 +222,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
qt5_use_modules(otter-browser WinExtras)
endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
qt5_use_modules(otter-browser Core Gui Multimedia Network PrintSupport Script Sql WebKit WebKitWidgets)
qt5_use_modules(otter-browser Core Gui Multimedia Network PrintSupport Script Sql WebKit WebKitWidgets Widgets)
set(OTTER_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(XDG_APPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/applications CACHE FILEPATH "Install path for .desktop files")
@@ -57,7 +57,6 @@ SOURCES += src/main.cpp \
src/core/SearchSuggester.cpp \
src/core/SessionsManager.cpp \
src/core/SettingsManager.cpp \
src/core/ShortcutsManager.cpp \
src/core/TransfersManager.cpp \
src/core/Utils.cpp \
src/core/WebBackend.cpp \
@@ -163,7 +162,6 @@ HEADERS += src/core/Action.h \
src/core/SearchSuggester.h \
src/core/SessionsManager.h \
src/core/SettingsManager.h \
src/core/ShortcutsManager.h \
src/core/TransfersManager.h \
src/core/Utils.h \
src/core/WebBackend.h \
@@ -2,7 +2,7 @@
; Description: Default configuration
; Type: keyboard-profile
; Author: Emdek <michal@emdek.pl>
; Version: 0.1
; Version: 0.2
[NewTab]
shortcuts=Ctrl+T
@@ -32,7 +32,7 @@ shortcuts=Ctrl+Shift+T
shortcuts=Alt+F11
[Exit]
shortcuts=native
shortcuts=Ctrl+Q
[Undo]
shortcuts=Ctrl+Z
@@ -53,37 +53,37 @@ shortcuts=Ctrl+Alt+C
shortcuts=Ctrl+V Shift+Ins
[Delete]
shortcuts=native
shortcuts=Delete
[SelectAll]
shortcuts=Ctrl+A
[Find]
shortcuts=native
shortcuts=Ctrl+F
[FindNext]
shortcuts=native Ctrl+G
shortcuts=Ctrl+G
[FindPrevious]
shortcuts=native Ctrl+Shift+G
shortcuts=Ctrl+Shift+G
[QuickFind]
shortcuts=/
[Reload]
shortcuts=native Ctrl+R
shortcuts=Ctrl+R
[ZoomIn]
shortcuts=native 0
shortcuts=0
[ZoomOut]
shortcuts=native 9
shortcuts=9
[GoBack]
shortcuts=native Z Backspace
shortcuts=Z Backspace
[GoForward]
shortcuts=native X Shift+Backspace
shortcuts=X Shift+Backspace
[GoToHomePage]
shortcuts=Ctrl+Space Alt+Home
@@ -118,7 +118,7 @@
]
},
"separator",
"ViewHistory",
"History",
"separator",
"ClearHistory"
]
@@ -130,7 +130,7 @@
"actions":
[
"AddBookmark",
"ManageBookmarks",
"Bookmarks",
"separator"
]
},
@@ -143,8 +143,8 @@
"Transfers",
"Cookies",
"ContentBlocking",
"ErrorConsole",
"Sidebar",
"ShowErrorConsole",
"ShowSidebar",
"separator",
"Preferences"
]
@@ -101,11 +101,11 @@
"actions":
[
"AddBookmark",
"ManageBookmarks",
"Bookmarks",
"separator"
]
},
"ViewHistory",
"History",
"Transfers",
"separator",
{
@@ -25,48 +25,57 @@
namespace Otter
{
Action::Action(const QIcon &icon, const QString &text, QObject *parent) : QAction(icon, text, parent),
m_identifier(UnknownAction),
m_scope(MainWindowScope)
Action::Action(int identifier, const QIcon &icon, const QString &text, QObject *parent) : QAction(icon, text, parent),
m_identifier(identifier)
{
setText(QCoreApplication::translate("actions", text.toUtf8().constData()));
update();
}
void Action::setName(const QString &name)
void Action::setup(Action *action)
{
setObjectName(name);
}
if (!action)
{
update();
setEnabled(false);
void Action::setIdentifier(ActionIdentifier identifier)
{
m_identifier = identifier;
}
return;
}
void Action::setScope(ActionScope scope)
{
m_scope = scope;
setEnabled(action->isEnabled());
setText(action->text());
setIcon(action->icon());
setCheckable(action->isCheckable());
setChecked(action->isChecked());
}
QString Action::getName() const
void Action::update()
{
return objectName();
const ActionDefinition action = ActionsManager::getActionDefinition(m_identifier);
QString text = QCoreApplication::translate("actions", action.text.toUtf8().constData());
if (!action.shortcuts.isEmpty())
{
text += QLatin1Char('\t') + action.shortcuts.first().toString(QKeySequence::NativeText);
}
setText(text);
}
ActionIdentifier Action::getIdentifier() const
QList<QKeySequence> Action::getShortcuts() const
{
return m_identifier;
return ActionsManager::getActionDefinition(m_identifier).shortcuts.toList();
}
ActionScope Action::getScope() const
int Action::getIdentifier() const
{
return m_scope;
return m_identifier;
}
bool Action::event(QEvent *event)
{
if (event->type() == QEvent::LanguageChange)
{
setText(QCoreApplication::translate("actions", ActionsManager::getActionDefinition(objectName()).text.toUtf8().constData()));
update();
}
return QAction::event(event);
Oops, something went wrong.

5 comments on commit 30719aa

@beastie1

This comment has been minimized.

Contributor

beastie1 replied Dec 28, 2014

F4 and F5 don't work anymore. F2, F9, F11, and the ctrl/alt/shift+something in general seem to be working fine.

@beastie1

This comment has been minimized.

Contributor

beastie1 replied Dec 28, 2014

F3 too doesn't work.

@Emdek

This comment has been minimized.

Member

Emdek replied Dec 28, 2014

Which ones where these exactly (except F5, obviously ;-))?
I've dropped support for native keyword as part of the cleanup, so there might be few missing shortcuts changes in default.ini).

@beastie1

This comment has been minimized.

Contributor

beastie1 replied Dec 28, 2014

You mean F3 for find next and F4 to open the sidebar?

Also F12 (quick preferences) seems to cause an instant total lock.

@Emdek

This comment has been minimized.

Member

Emdek replied Dec 28, 2014

@beastie1, it's all done now, thanks for report, that lock-up was pretty nasty one and hard to spot (apparently I've used all of my testing luck earlier today by finding out off by one issue happening for edge case by accidentally testing it as first one - of more than 100 :-D).

Please sign in to comment.