mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 10:52:51 +00:00
libs: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
9e65f09172
commit
130edd507d
2 changed files with 114 additions and 95 deletions
|
@ -43,13 +43,15 @@ static bool compareKWinWindowInfo( KWindowInfo* firstInfo, KWindowInfo* secondIn
|
||||||
{
|
{
|
||||||
QString firstTitle, secondTitle;
|
QString firstTitle, secondTitle;
|
||||||
|
|
||||||
if ( firstInfo )
|
if (firstInfo) {
|
||||||
firstTitle = firstInfo->visibleNameWithState().toLower();
|
firstTitle = firstInfo->visibleNameWithState().toLower();
|
||||||
|
}
|
||||||
|
|
||||||
if ( secondInfo )
|
if (secondInfo) {
|
||||||
secondTitle = secondInfo->visibleNameWithState().toLower();
|
secondTitle = secondInfo->visibleNameWithState().toLower();
|
||||||
|
}
|
||||||
|
|
||||||
return firstTitle.compare( secondTitle ) >= 0;
|
return (firstTitle.compare(secondTitle) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
KWindowListMenu::KWindowListMenu(QWidget *parent)
|
KWindowListMenu::KWindowListMenu(QWidget *parent)
|
||||||
|
@ -62,12 +64,15 @@ static bool standaloneDialog( const KWindowInfo* info, const QList<KWindowInfo*>
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
WId group = info->groupLeader();
|
WId group = info->groupLeader();
|
||||||
|
|
||||||
if ( group == 0 )
|
if (group == 0) {
|
||||||
return info->transientFor() == QX11Info::appRootWindow();
|
return info->transientFor() == QX11Info::appRootWindow();
|
||||||
|
}
|
||||||
|
|
||||||
foreach ( KWindowInfo* info, list )
|
foreach (KWindowInfo *info, list) {
|
||||||
if ( info->groupLeader() == group )
|
if (info->groupLeader() == group) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -89,13 +94,15 @@ void KWindowListMenu::init()
|
||||||
QAction* cascade = addAction( i18nc("Action that reorganizes the windows so that they are in cascade", "Cascade Windows"),
|
QAction* cascade = addAction( i18nc("Action that reorganizes the windows so that they are in cascade", "Cascade Windows"),
|
||||||
this, SLOT(slotCascadeWindows()) );
|
this, SLOT(slotCascadeWindows()) );
|
||||||
|
|
||||||
// if we only have one desktop we won't be showing titles, so put a separator in
|
// if there is only one desktop showing titles would not be possible, so put a separator in
|
||||||
if ( numberOfDesktops == 1 )
|
if (numberOfDesktops == 1) {
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
QList<KWindowInfo> windows;
|
QList<KWindowInfo> windows;
|
||||||
foreach ( WId id, KWindowSystem::windows() )
|
foreach (WId id, KWindowSystem::windows() ) {
|
||||||
windows.append(KWindowSystem::windowInfo(id, NET::WMDesktop));
|
windows.append(KWindowSystem::windowInfo(id, NET::WMDesktop));
|
||||||
|
}
|
||||||
|
|
||||||
bool showAllDesktopsGroup = (numberOfDesktops > 1);
|
bool showAllDesktopsGroup = (numberOfDesktops > 1);
|
||||||
|
|
||||||
|
@ -112,10 +119,15 @@ void KWindowListMenu::init()
|
||||||
|
|
||||||
foreach (const KWindowInfo &wi, windows) {
|
foreach (const KWindowInfo &wi, windows) {
|
||||||
if ( (wi.desktop() == j) || (onAllDesktops && wi.onAllDesktops())
|
if ( (wi.desktop() == j) || (onAllDesktops && wi.onAllDesktops())
|
||||||
|| (!showAllDesktopsGroup && wi.onAllDesktops()) ) {
|
|| (!showAllDesktopsGroup && wi.onAllDesktops()))
|
||||||
list.append( new KWindowInfo( wi.win(),
|
{
|
||||||
|
list.append(
|
||||||
|
new KWindowInfo(
|
||||||
|
wi.win(),
|
||||||
NET::WMVisibleName | NET::WMState | NET::XAWMState | NET::WMWindowType,
|
NET::WMVisibleName | NET::WMState | NET::XAWMState | NET::WMWindowType,
|
||||||
NET::WM2GroupLeader | NET::WM2TransientFor ) );
|
NET::WM2GroupLeader | NET::WM2TransientFor
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,24 +137,27 @@ void KWindowListMenu::init()
|
||||||
++i;
|
++i;
|
||||||
QString itemText = fontMetrics().elidedText(info->visibleNameWithState(), Qt::ElideMiddle, maxwidth);
|
QString itemText = fontMetrics().elidedText(info->visibleNameWithState(), Qt::ElideMiddle, maxwidth);
|
||||||
|
|
||||||
NET::WindowType windowType = info->windowType( NET::NormalMask | NET::DesktopMask
|
NET::WindowType windowType = info->windowType(
|
||||||
|
NET::NormalMask | NET::DesktopMask
|
||||||
| NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
|
| NET::DockMask | NET::ToolbarMask | NET::MenuMask | NET::DialogMask
|
||||||
| NET::UtilityMask | NET::SplashMask );
|
| NET::UtilityMask | NET::SplashMask
|
||||||
|
);
|
||||||
|
|
||||||
if ((windowType == NET::Normal || windowType == NET::Unknown
|
if ((windowType == NET::Normal || windowType == NET::Unknown
|
||||||
|| (windowType == NET::Dialog && standaloneDialog(info, list)))
|
|| (windowType == NET::Dialog && standaloneDialog(info, list)))
|
||||||
&& !(info->state() & NET::SkipTaskbar) ) {
|
&& !(info->state() & NET::SkipTaskbar))
|
||||||
|
{
|
||||||
QPixmap pm = KWindowSystem::icon(info->win(), 16, 16, true);
|
QPixmap pm = KWindowSystem::icon(info->win(), 16, 16, true);
|
||||||
items++;
|
items++;
|
||||||
|
|
||||||
// ok, we have items on this desktop, let's show the title
|
// ok, we have items on this desktop, let's show the title
|
||||||
if (items == 1 && numberOfDesktops > 1) {
|
if (items == 1 && numberOfDesktops > 1) {
|
||||||
if( !onAllDesktops )
|
if (!onAllDesktops) {
|
||||||
addTitle(KWindowSystem::desktopName(j));
|
addTitle(KWindowSystem::desktopName(j));
|
||||||
else
|
} else {
|
||||||
addTitle(i18n("On All Desktops"));
|
addTitle(i18n("On All Desktops"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid creating unwanted accelerators.
|
// Avoid creating unwanted accelerators.
|
||||||
itemText.replace('&', QLatin1String("&&"));
|
itemText.replace('&', QLatin1String("&&"));
|
||||||
|
@ -150,10 +165,11 @@ void KWindowListMenu::init()
|
||||||
QAction* action = addAction(pm, itemText, this, SLOT(slotForceActiveWindow()));
|
QAction* action = addAction(pm, itemText, this, SLOT(slotForceActiveWindow()));
|
||||||
action->setData(qulonglong(quintptr(info->win())) );
|
action->setData(qulonglong(quintptr(info->win())) );
|
||||||
|
|
||||||
if ( info->win() == activeWindow )
|
if (info->win() == activeWindow) {
|
||||||
action->setChecked(true);
|
action->setChecked(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (j == currentDesktop) {
|
if (j == currentDesktop) {
|
||||||
unclutter->setEnabled(items > 0);
|
unclutter->setEnabled(items > 0);
|
||||||
|
@ -165,8 +181,10 @@ void KWindowListMenu::init()
|
||||||
|
|
||||||
// no windows?
|
// no windows?
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if ( numberOfDesktops > 1 )
|
if (numberOfDesktops > 1) {
|
||||||
addSeparator(); // because we don't have any titles, nor a separator
|
// because we don't have any titles, nor a separator
|
||||||
|
addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
addAction(i18n("No Windows"))->setEnabled(false);
|
addAction(i18n("No Windows"))->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
@ -184,28 +202,29 @@ bool KWindowListMenu::canChangePlacement()
|
||||||
// called after popup().
|
// called after popup().
|
||||||
void KWindowListMenu::selectActiveWindow()
|
void KWindowListMenu::selectActiveWindow()
|
||||||
{
|
{
|
||||||
foreach (QAction* action, actions())
|
foreach (QAction* action, actions()) {
|
||||||
if (action->isChecked()) {
|
if (action->isChecked()) {
|
||||||
setActiveAction(action);
|
setActiveAction(action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void KWindowListMenu::slotForceActiveWindow()
|
void KWindowListMenu::slotForceActiveWindow()
|
||||||
{
|
{
|
||||||
QAction* window = qobject_cast<QAction*>(sender());
|
QAction* window = qobject_cast<QAction*>(sender());
|
||||||
if (!window || !window->data().canConvert(QVariant::ULongLong))
|
if (!window || !window->data().canConvert(QVariant::ULongLong)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
KWindowSystem::forceActiveWindow((WId)window->data().toULongLong());
|
KWindowSystem::forceActiveWindow((WId)window->data().toULongLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
void KWindowListMenu::slotSetCurrentDesktop()
|
void KWindowListMenu::slotSetCurrentDesktop()
|
||||||
{
|
{
|
||||||
QAction* window = qobject_cast<QAction*>(sender());
|
QAction* window = qobject_cast<QAction*>(sender());
|
||||||
if (!window || !window->data().canConvert(QVariant::UInt))
|
if (!window || !window->data().canConvert(QVariant::UInt)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
KWindowSystem::setCurrentDesktop(window->data().toUInt());
|
KWindowSystem::setCurrentDesktop(window->data().toUInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,4 +239,3 @@ void KWindowListMenu::slotCascadeWindows()
|
||||||
org::kde::KWin kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
|
org::kde::KWin kwin("org.kde.kwin", "/KWin", QDBusConnection::sessionBus());
|
||||||
kwin.cascadeDesktop();
|
kwin.cascadeDesktop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#define KWINDOWLISTMENU_H
|
#define KWINDOWLISTMENU_H
|
||||||
|
|
||||||
#include "kworkspace_export.h"
|
#include "kworkspace_export.h"
|
||||||
|
|
||||||
#include <kmenu.h>
|
#include <kmenu.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,7 +45,7 @@ class KWORKSPACE_EXPORT KWindowListMenu : public KMenu
|
||||||
*
|
*
|
||||||
* @param parent The parent widget.
|
* @param parent The parent widget.
|
||||||
*/
|
*/
|
||||||
explicit KWindowListMenu( QWidget *parent = 0 );
|
explicit KWindowListMenu(QWidget *parent = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the menu by filling it with actions
|
* Initializes the menu by filling it with actions
|
||||||
|
@ -74,4 +75,4 @@ class KWORKSPACE_EXPORT KWindowListMenu : public KMenu
|
||||||
void slotCascadeWindows();
|
void slotCascadeWindows();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // KWINDOWLISTMENU_H
|
||||||
|
|
Loading…
Add table
Reference in a new issue