Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
4321e01e
Commit
4321e01e
authored
Dec 16, 2010
by
con
Browse files
Some API beautification in action container.
Done-with: Daniel Molkentin
parent
83e82de6
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/actionmanager/actioncontainer.cpp
View file @
4321e01e
...
...
@@ -65,26 +65,37 @@ using namespace Core::Internal;
You can define if the menu represented by this action container should automatically disable
or hide whenever it only contains disabled items and submenus by setting the corresponding
\l{ActionContainer::setEmptyAction()}{EmptyAction}.
\l{ActionContainer::setOnAllDisabledBehavior()}{OnAllDisabledBehavior}. The default is
ActionContainer::Disable for menus, and ActionContainer::Show for menu bars.
*/
/*!
\enum ActionContainer::
EmptyAct
io
n
\enum ActionContainer::
OnAllDisabledBehav
io
r
Defines what happens when the represented menu is empty or contains only disabled/invisible items.
\omitvalue EA_Mask
\value EA_None
The menu will still be visible and active.
\value EA_Disable
\value Disable
The menu will be visible but disabled.
\value
EA_
Hide
\value Hide
The menu will not be visible until the state of the subitems change.
\value Show
The menu will still be visible and active.
*/
/*!
\fn ActionContainer::setOnAllDisabledBehavior(OnAllDisabledBehavior behavior)
Defines the \a behavior of the menu represented by this action container for the case
whenever it only contains disabled items and submenus.
The default is ActionContainer::Disable for menus, and ActionContainer::Show for menu bars.
\sa ActionContainer::OnAllDisabledBehavior
\sa ActionContainer::onAllDisabledBehavior()
*/
/*!
\fn ActionContainer::
setEmptyAction(EmptyAction disableOrHide)
Defines i
f the menu represented by this action container
should automatically \a disableOrHid
e
\fn ActionContainer::
onAllDisabledBehavior() const
Returns the \a behavior o
f the menu represented by this action container
for the cas
e
whenever it only contains disabled items and submenus.
\sa ActionContainer::EmptyAction
The default is ActionContainer::Disable for menus, and ActionContainer::Show for menu bars.
\sa ActionContainer::OnAllDisabledBehavior
\sa ActionContainer::setOnAllDisabledBehavior()
*/
/*!
...
...
@@ -148,19 +159,19 @@ using namespace Core::Internal;
*/
ActionContainerPrivate
::
ActionContainerPrivate
(
int
id
)
:
m_
data
(
0
),
m_id
(
id
),
m_updateRequested
(
false
)
:
m_
onAllDisabledBehavior
(
Disable
),
m_id
(
id
),
m_updateRequested
(
false
)
{
scheduleUpdate
();
}
void
ActionContainerPrivate
::
set
EmptyAction
(
EmptyAction
ea
)
void
ActionContainerPrivate
::
set
OnAllDisabledBehavior
(
OnAllDisabledBehavior
behavior
)
{
m_
data
=
((
m_data
&
~
EA_Mask
)
|
ea
)
;
m_
onAllDisabledBehavior
=
behavior
;
}
bool
ActionContainerPrivate
::
hasEmptyAction
(
EmptyAction
ea
)
const
ActionContainer
::
OnAllDisabledBehavior
ActionContainerPrivate
::
onAllDisabledBehavior
(
)
const
{
return
(
m_
data
&
EA_Mask
)
==
ea
;
return
m_
onAllDisabledBehavior
;
}
void
ActionContainerPrivate
::
appendGroup
(
const
QString
&
group
)
...
...
@@ -343,7 +354,7 @@ void ActionContainerPrivate::update()
MenuActionContainer
::
MenuActionContainer
(
int
id
)
:
ActionContainerPrivate
(
id
),
m_menu
(
0
)
{
set
EmptyAction
(
EA_
Disable
);
set
OnAllDisabledBehavior
(
Disable
);
}
void
MenuActionContainer
::
setMenu
(
QMenu
*
menu
)
...
...
@@ -383,7 +394,7 @@ CommandLocation MenuActionContainer::location() const
bool
MenuActionContainer
::
updateInternal
()
{
if
(
hasEmptyAction
(
EA_None
)
)
if
(
onAllDisabledBehavior
()
==
Show
)
return
true
;
bool
hasitems
=
false
;
...
...
@@ -419,9 +430,9 @@ bool MenuActionContainer::updateInternal()
}
}
if
(
hasEmptyAction
(
EA_
Hide
)
)
if
(
onAllDisabledBehavior
()
==
Hide
)
m_menu
->
menuAction
()
->
setVisible
(
hasitems
);
else
if
(
hasEmptyAction
(
EA_
Disable
)
)
else
if
(
onAllDisabledBehavior
()
==
Disable
)
m_menu
->
menuAction
()
->
setEnabled
(
hasitems
);
return
hasitems
;
...
...
@@ -443,7 +454,7 @@ bool MenuActionContainer::canBeAddedToMenu() const
MenuBarActionContainer
::
MenuBarActionContainer
(
int
id
)
:
ActionContainerPrivate
(
id
),
m_menuBar
(
0
)
{
set
EmptyAction
(
EA_None
);
set
OnAllDisabledBehavior
(
Show
);
}
void
MenuBarActionContainer
::
setMenuBar
(
QMenuBar
*
menuBar
)
...
...
@@ -468,7 +479,7 @@ void MenuBarActionContainer::insertMenu(QAction *before, QMenu *menu)
bool
MenuBarActionContainer
::
updateInternal
()
{
if
(
hasEmptyAction
(
EA_None
)
)
if
(
onAllDisabledBehavior
()
==
Show
)
return
true
;
bool
hasitems
=
false
;
...
...
@@ -480,9 +491,9 @@ bool MenuBarActionContainer::updateInternal()
}
}
if
(
hasEmptyAction
(
EA_
Hide
)
)
if
(
onAllDisabledBehavior
()
==
Hide
)
m_menuBar
->
setVisible
(
hasitems
);
else
if
(
hasEmptyAction
(
EA_
Disable
)
)
else
if
(
onAllDisabledBehavior
()
==
Disable
)
m_menuBar
->
setEnabled
(
hasitems
);
return
hasitems
;
...
...
src/plugins/coreplugin/actionmanager/actioncontainer.h
View file @
4321e01e
...
...
@@ -47,14 +47,14 @@ class ActionContainer : public QObject
Q_OBJECT
public:
enum
EmptyAction
{
EA_Mask
=
0xFF00
,
EA_None
=
0x0100
,
EA_Hide
=
0x0200
,
EA_Disable
=
0x0300
enum
OnAllDisabledBehavior
{
Disable
,
Hide
,
Show
};
virtual
void
setEmptyAction
(
EmptyAction
ea
)
=
0
;
virtual
void
setOnAllDisabledBehavior
(
OnAllDisabledBehavior
behavior
)
=
0
;
virtual
ActionContainer
::
OnAllDisabledBehavior
onAllDisabledBehavior
()
const
=
0
;
virtual
int
id
()
const
=
0
;
...
...
src/plugins/coreplugin/actionmanager/actioncontainer_p.h
View file @
4321e01e
...
...
@@ -46,8 +46,8 @@ public:
ActionContainerPrivate
(
int
id
);
virtual
~
ActionContainerPrivate
()
{}
void
set
EmptyAction
(
EmptyAction
ea
);
bool
hasEmptyAction
(
EmptyAction
ea
)
const
;
void
set
OnAllDisabledBehavior
(
OnAllDisabledBehavior
behavior
);
ActionContainer
::
OnAllDisabledBehavior
onAllDisabledBehavior
(
)
const
;
QAction
*
insertLocation
(
const
QString
&
group
)
const
;
void
appendGroup
(
const
QString
&
group
);
...
...
@@ -84,7 +84,7 @@ private:
int
calcPosition
(
int
pos
,
int
prevKey
)
const
;
QList
<
int
>
m_groups
;
int
m_data
;
OnAllDisabledBehavior
m_onAllDisabledBehavior
;
int
m_id
;
QMap
<
int
,
int
>
m_posmap
;
QList
<
ActionContainer
*>
m_subContainers
;
...
...
src/plugins/coreplugin/mainwindow.cpp
View file @
4321e01e
...
...
@@ -590,7 +590,7 @@ void MainWindow::registerDefaultActions()
ActionContainer
*
ac
=
am
->
createMenu
(
Constants
::
M_FILE_RECENTFILES
);
mfile
->
addMenu
(
ac
,
Constants
::
G_FILE_OPEN
);
ac
->
menu
()
->
setTitle
(
tr
(
"Recent &Files"
));
ac
->
set
EmptyAct
io
n
(
ActionContainer
::
EA_None
);
ac
->
set
OnAllDisabledBehav
io
r
(
ActionContainer
::
Show
);
// Save Action
icon
=
QIcon
::
fromTheme
(
QLatin1String
(
"document-save"
),
QIcon
(
Constants
::
ICON_SAVEFILE
));
...
...
src/plugins/glsleditor/glsleditorplugin.cpp
View file @
4321e01e
...
...
@@ -141,7 +141,7 @@ bool GLSLEditorPlugin::initialize(const QStringList & /*arguments*/, QString *er
Core
::
ActionManager
*
am
=
core
->
actionManager
();
Core
::
ActionContainer
*
contextMenu
=
am
->
createMenu
(
GLSLEditor
::
Constants
::
M_CONTEXT
);
Core
::
ActionContainer
*
glslToolsMenu
=
am
->
createMenu
(
Core
::
Id
(
Constants
::
M_TOOLS_GLSL
));
glslToolsMenu
->
set
EmptyAct
io
n
(
Core
::
ActionContainer
::
EA_
Hide
);
glslToolsMenu
->
set
OnAllDisabledBehav
io
r
(
Core
::
ActionContainer
::
Hide
);
QMenu
*
menu
=
glslToolsMenu
->
menu
();
//: GLSL sub-menu in the Tools menu
menu
->
setTitle
(
tr
(
"GLSL"
));
...
...
src/plugins/projectexplorer/projectexplorer.cpp
View file @
4321e01e
...
...
@@ -435,7 +435,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// "open with" submenu
Core
::
ActionContainer
*
const
openWith
=
am
->
createMenu
(
ProjectExplorer
::
Constants
::
M_OPENFILEWITHCONTEXT
);
openWith
->
set
EmptyAct
io
n
(
Core
::
ActionContainer
::
EA_None
);
openWith
->
set
OnAllDisabledBehav
io
r
(
Core
::
ActionContainer
::
Show
);
d
->
m_openWithMenu
=
openWith
->
menu
();
d
->
m_openWithMenu
->
setTitle
(
tr
(
"Open With"
));
...
...
@@ -540,7 +540,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
Core
::
ActionContainer
*
mrecent
=
am
->
createMenu
(
Constants
::
M_RECENTPROJECTS
);
mrecent
->
menu
()
->
setTitle
(
tr
(
"Recent P&rojects"
));
mrecent
->
set
EmptyAct
io
n
(
Core
::
ActionContainer
::
EA_None
);
mrecent
->
set
OnAllDisabledBehav
io
r
(
Core
::
ActionContainer
::
Show
);
mfile
->
addMenu
(
mrecent
,
Core
::
Constants
::
G_FILE_OPEN
);
connect
(
mfile
->
menu
(),
SIGNAL
(
aboutToShow
()),
this
,
SLOT
(
updateRecentProjectMenu
()));
...
...
@@ -563,7 +563,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// session menu
Core
::
ActionContainer
*
msession
=
am
->
createMenu
(
Constants
::
M_SESSION
);
msession
->
menu
()
->
setTitle
(
tr
(
"Session"
));
msession
->
set
EmptyAct
io
n
(
Core
::
ActionContainer
::
EA_None
);
msession
->
set
OnAllDisabledBehav
io
r
(
Core
::
ActionContainer
::
Show
);
mfile
->
addMenu
(
msession
,
Core
::
Constants
::
G_FILE_PROJECT
);
d
->
m_sessionMenu
=
msession
->
menu
();
connect
(
mfile
->
menu
(),
SIGNAL
(
aboutToShow
()),
...
...
src/plugins/qmljseditor/qmljseditorplugin.cpp
View file @
4321e01e
...
...
@@ -161,7 +161,7 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e
Core
::
ActionManager
*
am
=
core
->
actionManager
();
Core
::
ActionContainer
*
contextMenu
=
am
->
createMenu
(
QmlJSEditor
::
Constants
::
M_CONTEXT
);
Core
::
ActionContainer
*
qmlToolsMenu
=
am
->
createMenu
(
Core
::
Id
(
Constants
::
M_TOOLS_QML
));
qmlToolsMenu
->
set
EmptyAct
io
n
(
Core
::
ActionContainer
::
EA_
Hide
);
qmlToolsMenu
->
set
OnAllDisabledBehav
io
r
(
Core
::
ActionContainer
::
Hide
);
QMenu
*
menu
=
qmlToolsMenu
->
menu
();
//: QML sub-menu in the Tools menu
menu
->
setTitle
(
tr
(
"QML"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment