mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
generic: remove appmenu support
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
5f76620386
commit
1fb5e67762
70 changed files with 93 additions and 4196 deletions
|
@ -337,7 +337,6 @@ endif(Q_WS_X11 AND X11_Xinput_FOUND)
|
|||
add_subdirectory(kcminit)
|
||||
add_subdirectory(khotkeys)
|
||||
add_subdirectory(ksystraycmd)
|
||||
add_subdirectory(appmenu)
|
||||
|
||||
if(X11_Xau_FOUND AND X11_Xdmcp_FOUND)
|
||||
add_subdirectory( kdm )
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
|
||||
|
||||
set(kded_appmenu_SRCS
|
||||
menubutton.cpp
|
||||
menuwidget.cpp
|
||||
menubar.cpp
|
||||
topmenubar.cpp
|
||||
glowbar.cpp
|
||||
verticalmenu.cpp
|
||||
shadows.cpp
|
||||
)
|
||||
|
||||
if(DBUSMENUEQT_FOUND)
|
||||
set(kded_appmenu_SRCS
|
||||
${kded_appmenu_SRCS}
|
||||
appmenu.cpp
|
||||
appmenu_dbus.cpp
|
||||
menuimporter.cpp
|
||||
)
|
||||
|
||||
qt4_add_dbus_adaptor(kded_appmenu_SRCS
|
||||
com.canonical.AppMenu.Registrar.xml
|
||||
menuimporter.h
|
||||
MenuImporter
|
||||
menuimporteradaptor
|
||||
MenuImporterAdaptor
|
||||
)
|
||||
|
||||
qt4_add_dbus_adaptor(kded_appmenu_SRCS
|
||||
org.kde.kded.appmenu.xml
|
||||
appmenu_dbus.h
|
||||
AppmenuDBus
|
||||
appmenuadaptor
|
||||
AppmenuAdaptor
|
||||
)
|
||||
endif()
|
||||
|
||||
kde4_add_plugin(kded_appmenu ${kded_appmenu_SRCS})
|
||||
|
||||
target_link_libraries(kded_appmenu
|
||||
${KDE4_KIO_LIBS}
|
||||
${X11_LIBRARIES}
|
||||
${KDE4_PLASMA_LIBS}
|
||||
)
|
||||
|
||||
if(DBUSMENUQT_FOUND)
|
||||
target_link_libraries(kded_appmenu ${DBUSMENUQT_LIBRARIES})
|
||||
include_directories(${DBUSMENUQT_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
install(
|
||||
TARGETS kded_appmenu
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install(
|
||||
FILES appmenu.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}/kded
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
com.canonical.AppMenu.Registrar.xml
|
||||
org.kde.kded.appmenu.xml
|
||||
DESTINATION ${KDE4_DBUS_INTERFACES_INSTALL_DIR}
|
||||
)
|
|
@ -1,399 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "appmenu.h"
|
||||
#include "kdbusimporter.h"
|
||||
#include "menuimporteradaptor.h"
|
||||
#include "appmenuadaptor.h"
|
||||
#include "appmenu_dbus.h"
|
||||
#include "topmenubar.h"
|
||||
#include "verticalmenu.h"
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusReply>
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QMenu>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#include <KDebug>
|
||||
#include <KWindowSystem>
|
||||
#include <KWindowInfo>
|
||||
#include <KConfig>
|
||||
#include <KConfigGroup>
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
#include <netwm.h>
|
||||
|
||||
K_PLUGIN_FACTORY(AppMenuFactory,
|
||||
registerPlugin<AppMenuModule>();
|
||||
)
|
||||
K_EXPORT_PLUGIN(AppMenuFactory("appmenu"))
|
||||
|
||||
AppMenuModule::AppMenuModule(QObject* parent, const QList<QVariant>&)
|
||||
: KDEDModule(parent),
|
||||
m_parent(parent),
|
||||
m_menuImporter(0),
|
||||
m_appmenuDBus(new AppmenuDBus(parent)),
|
||||
m_menubar(0),
|
||||
m_menu(0),
|
||||
m_screenTimer(new QTimer(this)),
|
||||
m_waitingAction(0),
|
||||
m_currentScreen(-1)
|
||||
{
|
||||
reconfigure();
|
||||
|
||||
m_appmenuDBus->connectToBus();
|
||||
|
||||
m_currentScreen = currentScreen();
|
||||
|
||||
connect(m_appmenuDBus, SIGNAL(appShowMenu(int, int, WId)), SLOT(slotShowMenu(int, int, WId)));
|
||||
connect(m_appmenuDBus, SIGNAL(moduleReconfigure()), SLOT(reconfigure()));
|
||||
|
||||
// transfer our signals to dbus
|
||||
connect(this, SIGNAL(showRequest(qulonglong)), m_appmenuDBus, SIGNAL(showRequest(qulonglong)));
|
||||
connect(this, SIGNAL(menuAvailable(qulonglong)), m_appmenuDBus, SIGNAL(menuAvailable(qulonglong)));
|
||||
connect(this, SIGNAL(clearMenus()), m_appmenuDBus, SIGNAL(clearMenus()));
|
||||
connect(this, SIGNAL(menuHidden(qulonglong)), m_appmenuDBus, SIGNAL(menuHidden(qulonglong)));
|
||||
connect(this, SIGNAL(WindowRegistered(qulonglong, const QString&, const QDBusObjectPath&)),
|
||||
m_appmenuDBus, SIGNAL(WindowRegistered(qulonglong, const QString&, const QDBusObjectPath&)));
|
||||
connect(this, SIGNAL(WindowUnregistered(qulonglong)), m_appmenuDBus, SIGNAL(WindowUnregistered(qulonglong)));
|
||||
}
|
||||
|
||||
AppMenuModule::~AppMenuModule()
|
||||
{
|
||||
emit clearMenus();
|
||||
hideMenubar();
|
||||
if (m_menubar) {
|
||||
delete m_menubar;
|
||||
}
|
||||
delete m_menuImporter;
|
||||
delete m_appmenuDBus;
|
||||
}
|
||||
|
||||
void AppMenuModule::slotShowMenu(int x, int y, WId id)
|
||||
{
|
||||
static KDBusMenuImporter *importer = 0;
|
||||
|
||||
if (!m_menuImporter) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If menu visible, hide it
|
||||
if (m_menu && m_menu->isVisible()) {
|
||||
m_menu->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
//dbus call by user (for khotkey shortcut)
|
||||
if (x == -1 || y == -1) {
|
||||
// We do not know kwin button position, so tell kwin to show menu
|
||||
emit showRequest(KWindowSystem::self()->activeWindow());
|
||||
return;
|
||||
}
|
||||
|
||||
importer = getImporter(id);
|
||||
|
||||
if (!importer) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu *menu = importer->menu();
|
||||
|
||||
// Window do not have menu
|
||||
if (!menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_menu = new VerticalMenu();
|
||||
m_menu->setParentWid(id);
|
||||
// Populate menu
|
||||
foreach (QAction *action, menu->actions()) {
|
||||
m_menu->addAction(action);
|
||||
}
|
||||
m_menu->popup(QPoint(x, y));
|
||||
// Activate waiting action if exist
|
||||
if (m_waitingAction) {
|
||||
m_menu->setActiveAction(m_waitingAction);
|
||||
m_waitingAction = 0;
|
||||
}
|
||||
connect(m_menu, SIGNAL(aboutToHide()), this, SLOT(slotAboutToHide()));
|
||||
}
|
||||
|
||||
void AppMenuModule::slotAboutToHide()
|
||||
{
|
||||
if (m_menu) {
|
||||
emit menuHidden(m_menu->parentWid());
|
||||
m_menu->deleteLater();
|
||||
m_menu = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// New window registered
|
||||
void AppMenuModule::slotWindowRegistered(WId id, const QString& service, const QDBusObjectPath& path)
|
||||
{
|
||||
KDBusMenuImporter* importer = m_importers.take(id);
|
||||
if (importer) {
|
||||
delete importer;
|
||||
}
|
||||
|
||||
// Application already active so check if we need create menubar
|
||||
if ( m_menuStyle == "TopMenuBar" && id == KWindowSystem::self()->activeWindow()) {
|
||||
slotActiveWindowChanged(id);
|
||||
} else if (m_menuStyle == "ButtonVertical") {
|
||||
KWindowInfo info = KWindowSystem::windowInfo(id, 0, NET::WM2WindowClass);
|
||||
// Tell Kwin menu is available
|
||||
emit menuAvailable(id);
|
||||
// FIXME: https://bugs.kde.org/show_bug.cgi?id=317926
|
||||
if (info.windowClassName() != "kmix") {
|
||||
getImporter(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Send a signal on bus for others dbus interface registrars
|
||||
emit WindowRegistered(id, service, path);
|
||||
}
|
||||
|
||||
// Window unregistered
|
||||
void AppMenuModule::slotWindowUnregistered(WId id)
|
||||
{
|
||||
KDBusMenuImporter* importer = m_importers.take(id);
|
||||
|
||||
// Send a signal on bus for others dbus interface registrars
|
||||
emit WindowUnregistered(id);
|
||||
|
||||
if (importer) {
|
||||
delete importer;
|
||||
}
|
||||
|
||||
if (m_menubar && m_menubar->parentWid() == id) {
|
||||
hideMenubar();
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard activation requested, transmit it to menu
|
||||
void AppMenuModule::slotActionActivationRequested(QAction* a)
|
||||
{
|
||||
// If we have a topmenubar, activate action
|
||||
if (m_menubar) {
|
||||
m_menubar->setActiveAction(a);
|
||||
m_menubar->show();
|
||||
} else { // else send request to kwin or others dbus interface registrars
|
||||
m_waitingAction = a;
|
||||
emit showRequest(KWindowSystem::self()->activeWindow());
|
||||
}
|
||||
}
|
||||
|
||||
// Current window change, update menubar
|
||||
// See comments in slotWindowRegistered() for why we get importers here
|
||||
void AppMenuModule::slotActiveWindowChanged(WId id)
|
||||
{
|
||||
KWindowInfo info = KWindowSystem::windowInfo(id, NET::WMWindowType);
|
||||
unsigned long mask = NET::AllTypesMask;
|
||||
|
||||
m_currentScreen = currentScreen();
|
||||
|
||||
if (id == 0) {// Ignore root window
|
||||
return;
|
||||
} else if (info.windowType(mask) & NET::Dock) { // Hide immediatly menubar for docks (krunner)
|
||||
hideMenubar();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_menuImporter->serviceExist(id)) { // No menu exist, check for another menu for application
|
||||
WId recursiveId = m_menuImporter->recursiveMenuId(id);
|
||||
if (recursiveId) {
|
||||
id = recursiveId;
|
||||
}
|
||||
}
|
||||
|
||||
KDBusMenuImporter *importer = getImporter(id);
|
||||
if (!importer) {
|
||||
hideMenubar();
|
||||
return;
|
||||
}
|
||||
|
||||
QMenu *menu = importer->menu();
|
||||
|
||||
if(menu) {
|
||||
showMenuBar(menu);
|
||||
m_menubar->setParentWid(id);
|
||||
} else {
|
||||
hideMenubar();
|
||||
}
|
||||
}
|
||||
|
||||
void AppMenuModule::slotShowCurrentWindowMenu()
|
||||
{
|
||||
slotActiveWindowChanged(KWindowSystem::self()->activeWindow());
|
||||
}
|
||||
|
||||
void AppMenuModule::slotCurrentScreenChanged()
|
||||
{
|
||||
if (m_currentScreen != currentScreen()) {
|
||||
if (m_menubar) {
|
||||
m_menubar->setParentWid(0);
|
||||
}
|
||||
slotActiveWindowChanged(KWindowSystem::self()->activeWindow());
|
||||
}
|
||||
}
|
||||
|
||||
void AppMenuModule::slotBarNeedResize()
|
||||
{
|
||||
if (m_menubar) {
|
||||
m_menubar->updateSize();
|
||||
m_menubar->move(centeredMenubarPos());
|
||||
}
|
||||
}
|
||||
|
||||
// reload settings
|
||||
void AppMenuModule::reconfigure()
|
||||
{
|
||||
KConfig config( "kdeglobals", KConfig::FullConfig );
|
||||
KConfigGroup configGroup = config.group("Appmenu Style");
|
||||
m_menuStyle = configGroup.readEntry("Style", "InApplication");
|
||||
|
||||
m_waitingAction = 0;
|
||||
|
||||
// hide menubar if exist
|
||||
hideMenubar();
|
||||
if (m_menubar) {
|
||||
delete m_menubar;
|
||||
m_menubar = 0;
|
||||
}
|
||||
|
||||
slotAboutToHide(); // hide vertical menu if exist
|
||||
|
||||
// Disconnect all options specifics signals
|
||||
disconnect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(slotActiveWindowChanged(WId)));
|
||||
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(slotShowCurrentWindowMenu()));
|
||||
disconnect(m_screenTimer, SIGNAL(timeout()), this, SLOT(slotCurrentScreenChanged()));
|
||||
|
||||
m_screenTimer->stop();
|
||||
|
||||
// Tell kwin to clean its titlebar
|
||||
emit clearMenus();
|
||||
|
||||
if (m_menuStyle == "InApplication") {
|
||||
if (m_menuImporter) {
|
||||
delete m_menuImporter;
|
||||
m_menuImporter = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup a menu importer if needed
|
||||
if (!m_menuImporter) {
|
||||
m_menuImporter = new MenuImporter(m_parent);
|
||||
connect(m_menuImporter, SIGNAL(WindowRegistered(WId, const QString&, const QDBusObjectPath&)),
|
||||
SLOT(slotWindowRegistered(WId, const QString&, const QDBusObjectPath&)));
|
||||
connect(m_menuImporter, SIGNAL(WindowUnregistered(WId)),
|
||||
SLOT(slotWindowUnregistered(WId)));
|
||||
m_menuImporter->connectToBus();
|
||||
}
|
||||
|
||||
if( m_menuStyle == "ButtonVertical" ) {
|
||||
foreach(WId id, m_menuImporter->ids()) {
|
||||
emit menuAvailable(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup top menubar if needed
|
||||
if (m_menuStyle == "TopMenuBar") {
|
||||
m_menubar = new TopMenuBar();
|
||||
connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(slotActiveWindowChanged(WId)));
|
||||
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(slotShowCurrentWindowMenu()));
|
||||
connect(m_screenTimer, SIGNAL(timeout()), this, SLOT(slotCurrentScreenChanged()));
|
||||
connect(m_menubar, SIGNAL(needResize()), SLOT(slotBarNeedResize()));
|
||||
m_screenTimer->start(1000);
|
||||
slotShowCurrentWindowMenu();
|
||||
}
|
||||
}
|
||||
|
||||
KDBusMenuImporter* AppMenuModule::getImporter(WId id)
|
||||
{
|
||||
KDBusMenuImporter* importer = 0;
|
||||
if (m_importers.contains(id)) { // importer already exist
|
||||
importer = m_importers.value(id);
|
||||
} else if (m_menuImporter->serviceExist(id)) { // get importer
|
||||
importer = new KDBusMenuImporter(id, m_menuImporter->serviceForWindow(id), &m_icons,
|
||||
m_menuImporter->pathForWindow(id), this);
|
||||
if (importer) {
|
||||
QMetaObject::invokeMethod(importer, "updateMenu", Qt::DirectConnection);
|
||||
connect(importer, SIGNAL(actionActivationRequested(QAction*)),
|
||||
SLOT(slotActionActivationRequested(QAction*)));
|
||||
m_importers.insert(id, importer);
|
||||
}
|
||||
}
|
||||
return importer;
|
||||
}
|
||||
|
||||
void AppMenuModule::showMenuBar(QMenu *menu)
|
||||
{
|
||||
if (!menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_menubar->setMenu(menu);
|
||||
if (menu->actions().length()) {
|
||||
m_menubar->enableMouseTracking();
|
||||
}
|
||||
}
|
||||
|
||||
void AppMenuModule::hideMenubar()
|
||||
{
|
||||
if (!m_menubar) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_menubar->enableMouseTracking(false);
|
||||
if (m_menubar->isVisible()) {
|
||||
m_menubar->hide();
|
||||
}
|
||||
}
|
||||
|
||||
int AppMenuModule::currentScreen()
|
||||
{
|
||||
KWindowInfo info = KWindowSystem::windowInfo(KWindowSystem::self()->activeWindow(),
|
||||
NET::WMGeometry);
|
||||
int x = info.geometry().x();
|
||||
int y = info.geometry().y();
|
||||
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
return desktop->screenNumber(QPoint(x,y));
|
||||
}
|
||||
|
||||
|
||||
QPoint AppMenuModule::centeredMenubarPos()
|
||||
{
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
m_currentScreen = currentScreen();
|
||||
QRect screen = desktop->availableGeometry(m_currentScreen);
|
||||
int x = screen.center().x() - m_menubar->sizeHint().width()/2;
|
||||
return QPoint(x, screen.topLeft().y());
|
||||
}
|
||||
|
||||
|
||||
#include "moc_appmenu.cpp"
|
|
@ -1,96 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
Name=Application menus daemon
|
||||
Name[bs]=Demon za aplikacijske menije
|
||||
Name[ca]=Dimoni de menús d'aplicació
|
||||
Name[ca@valencia]=Dimoni de menús d'aplicació
|
||||
Name[cs]=Démon nabídky aplikací
|
||||
Name[da]=Dæmon til programmenuer
|
||||
Name[de]=Dienst für Anwendungsmenüs
|
||||
Name[el]=Δαίμων για τα μενού των εφαρμογών
|
||||
Name[en_GB]=Application menus daemon
|
||||
Name[es]=Demonio de menús de aplicación
|
||||
Name[et]=Rakenduste menüü deemon
|
||||
Name[eu]=Aplikazio-menuen daimona
|
||||
Name[fi]=Sovellusvalikkopalvelu
|
||||
Name[fr]=Démon de menus des applications
|
||||
Name[gl]=Daemon de menús do programa
|
||||
Name[he]=תהליך רקע של תפריט היישומים
|
||||
Name[hu]=Alkalmazás menük démon
|
||||
Name[ia]=Demone de menus de application
|
||||
Name[it]=Demone dei menu delle applicazioni
|
||||
Name[kk]=Қолданба мәзірінің қызметі
|
||||
Name[ko]=프로그램 메뉴 데몬
|
||||
Name[lt]=Programos meniu tarnyba
|
||||
Name[mr]=अनुप्रयोग मेन्यू डीमन
|
||||
Name[nb]=Daemon for programmenyer
|
||||
Name[nds]=Programmmenü-Dämoon
|
||||
Name[nl]=Daemon voor menu van toepassingen
|
||||
Name[pa]=ਐਪਲੀਕੇਸ਼ਨ ਮੈਨੂ ਡੈਮਨ
|
||||
Name[pl]=Demon menu programów
|
||||
Name[pt]=Servidor dos menus da aplicação
|
||||
Name[pt_BR]=Servidor dos menus do aplicativo
|
||||
Name[ro]=Demon pentru meniurile aplicațiilor
|
||||
Name[ru]=Фоновая служба меню приложений
|
||||
Name[sk]=Démon ponúk aplikácie
|
||||
Name[sl]=Ozadnji program za programske menije
|
||||
Name[sr]=Демон програмских менија
|
||||
Name[sr@ijekavian]=Демон програмских менија
|
||||
Name[sr@ijekavianlatin]=Demon programskih menija
|
||||
Name[sr@latin]=Demon programskih menija
|
||||
Name[sv]=Demon för programmenyer
|
||||
Name[tr]=Uygulama menü araçları
|
||||
Name[uk]=Фонова служба меню програм
|
||||
Name[x-test]=xxApplication menus daemonxx
|
||||
Name[zh_CN]=应用程序菜单守护程序
|
||||
Name[zh_TW]=應用程式選單伺服程式應用程式選單伺服程式
|
||||
Comment=Transfers application's menu to the desktop
|
||||
Comment[bs]=Prebacuje aplikacijski meni na radnu površinu
|
||||
Comment[ca]=Transfereix els menús d'aplicació a l'escriptori
|
||||
Comment[ca@valencia]=Transfereix els menús d'aplicació a l'escriptori
|
||||
Comment[cs]=Přesouvá nabídku aplikací na plochu
|
||||
Comment[da]=Overfører programmets menu til skrivebordet
|
||||
Comment[de]=Überträgt Anwendungsmenüs auf die Arbeitsfläche
|
||||
Comment[el]=Μεταφέρει το μενού της εφαρμογής στην επιφάνεια εργασίας
|
||||
Comment[en_GB]=Transfers application's menu to the desktop
|
||||
Comment[es]=Transfiere el menú de aplicaciones al escritorio
|
||||
Comment[et]=Rakenduste menüü paigutamine töölauale
|
||||
Comment[eu]=Aplikazioen menua mahaigainera transferitzen du
|
||||
Comment[fi]=Siirtää sovelluksen valikon työpöydälle
|
||||
Comment[fr]=Transfère le menu des applications sur le bureau
|
||||
Comment[gl]=Transfire o menú do programa ao escritorio
|
||||
Comment[he]=מעביר את התפריטים של היישום אל שולחן העבודה
|
||||
Comment[hu]=Átviszi az alkalmazás menüjét az asztalra
|
||||
Comment[ia]=Il transfere menu de applicationes al scriptorio
|
||||
Comment[it]=Trasferisce al desktop i menu delle applicazioni
|
||||
Comment[kk]=Қолданбаның мәзірін үстел бетіне тапсыру
|
||||
Comment[ko]=프로그램 메뉴를 데스크톱으로 보내기
|
||||
Comment[lt]=Perkelia programos meniu į darbastalį
|
||||
Comment[mr]=अनुप्रयोग मेन्यूचे डेस्कटॉपवर स्थानान्तरण
|
||||
Comment[nb]=Overfører programmets meny til skrivebordet
|
||||
Comment[nds]=Dat Programmmenü na den Schriefdisch överdregen
|
||||
Comment[nl]=Brengt het menu van de toepassing over naar het bureaublad
|
||||
Comment[pa]=ਐਪਲੀਕੇਸ਼ਨ ਦੇ ਮੇਨੂ ਨੂੰ ਡੈਸਕਟਾਪ ਉੱਤੇ ਭੇਜੋ
|
||||
Comment[pl]=Przenosi menu aplikacji na pulpit
|
||||
Comment[pt]=Transfere o menu da aplicação para o ecrã
|
||||
Comment[pt_BR]=Transfere o menu do aplicativo para a área de trabalho
|
||||
Comment[ro]=Transferă meniul aplicațiilor către birou
|
||||
Comment[ru]=Перемещает меню приложения на рабочий стол
|
||||
Comment[sk]=Presunúť ponuky aplikácie na plochu
|
||||
Comment[sl]=Prenese programski meni na namizje
|
||||
Comment[sr]=Пребацује меније програма на површ
|
||||
Comment[sr@ijekavian]=Пребацује меније програма на површ
|
||||
Comment[sr@ijekavianlatin]=Prebacuje menije programa na površ
|
||||
Comment[sr@latin]=Prebacuje menije programa na površ
|
||||
Comment[sv]=Överför programmets meny till skrivbordet
|
||||
Comment[tr]=Uygulamanın menüsünü masaüstüne aktarır
|
||||
Comment[uk]=Передає меню програм на стільницю
|
||||
Comment[x-test]=xxTransfers application's menu to the desktopxx
|
||||
Comment[zh_CN]=将应用程序的菜单转移到桌面上
|
||||
Comment[zh_TW]=將應用程式選單傳送到桌面
|
||||
X-KDE-ServiceTypes=KDEDModule
|
||||
X-KDE-Library=appmenu
|
||||
X-KDE-DBus-ModuleName=appmenu
|
||||
X-KDE-Kded-autoload=true
|
||||
X-KDE-Kded-load-on-demand=false
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef APPMENUMODULE_H
|
||||
#define APPMENUMODULE_H
|
||||
|
||||
#include <kdedmodule.h>
|
||||
#include "menuimporter.h"
|
||||
#include "gtkicons.h"
|
||||
|
||||
#include <QDBusPendingCallWatcher>
|
||||
class KDBusMenuImporter;
|
||||
class AppmenuDBus;
|
||||
class TopMenuBar;
|
||||
class VerticalMenu;
|
||||
|
||||
class AppMenuModule : public KDEDModule,
|
||||
protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AppMenuModule(QObject* parent, const QList<QVariant>& list);
|
||||
virtual ~AppMenuModule();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* We do not know where is menu decoration button, so tell kwin to show menu
|
||||
*/
|
||||
void showRequest(qulonglong);
|
||||
/**
|
||||
* This signal is emitted whenever application menu becomes available
|
||||
*/
|
||||
void menuAvailable(qulonglong);
|
||||
/**
|
||||
* This signal is emitted whenever menus are unavailables
|
||||
*/
|
||||
void clearMenus();
|
||||
/**
|
||||
* This signal is emitted whenever popup menu/menubar is hidden
|
||||
* Useful for decorations to know if menu button should be release
|
||||
*/
|
||||
void menuHidden(qulonglong);
|
||||
/**
|
||||
* This signal is emitted whenever a window register to appmenu
|
||||
*/
|
||||
void WindowRegistered(qulonglong wid, const QString& service, const QDBusObjectPath&);
|
||||
/**
|
||||
* This signal is emitted whenever a window unregister from appmenu
|
||||
*/
|
||||
void WindowUnregistered(qulonglong wid);
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Show menu at QPoint(x,y) for id
|
||||
* if x or y == -1, show in application window
|
||||
*/
|
||||
void slotShowMenu(int x, int y, WId);
|
||||
/**
|
||||
* Send menuHidden signal over bus when menu is about to hide
|
||||
*/
|
||||
void slotAboutToHide();
|
||||
/**
|
||||
* New window registered to appmenu
|
||||
* Emit WindowRegistered signal over bus
|
||||
*/
|
||||
void slotWindowRegistered(WId id, const QString& service, const QDBusObjectPath& path);
|
||||
/**
|
||||
* Window unregistered from appmenu
|
||||
* Emit WindowUnregistered signal over bus
|
||||
*/
|
||||
void slotWindowUnregistered(WId id);
|
||||
/**
|
||||
* Open a action in current menu
|
||||
*/
|
||||
void slotActionActivationRequested(QAction* a);
|
||||
/**
|
||||
* Active window changed, show menubar for id
|
||||
*/
|
||||
void slotActiveWindowChanged(WId id);
|
||||
/**
|
||||
* Update menubar with current window menu
|
||||
*/
|
||||
void slotShowCurrentWindowMenu();
|
||||
/**
|
||||
* Current screen changed, update menubar
|
||||
*/
|
||||
void slotCurrentScreenChanged();
|
||||
/**
|
||||
* Resize menubar
|
||||
*/
|
||||
void slotBarNeedResize();
|
||||
/**
|
||||
* Reconfigure module
|
||||
*/
|
||||
void reconfigure();
|
||||
|
||||
private:
|
||||
/**
|
||||
* return an importer for window id
|
||||
*/
|
||||
KDBusMenuImporter* getImporter(WId id);
|
||||
/**
|
||||
* Show menubar and update it with menu
|
||||
*/
|
||||
void showMenuBar(QMenu *menu);
|
||||
/**
|
||||
* Hide menubar
|
||||
*/
|
||||
void hideMenubar();
|
||||
/**
|
||||
* Return current screen
|
||||
*/
|
||||
int currentScreen();
|
||||
/**
|
||||
* Return position of menubar for being centered on screen
|
||||
*/
|
||||
QPoint centeredMenubarPos();
|
||||
|
||||
QObject* m_parent;
|
||||
MenuImporter* m_menuImporter;
|
||||
AppmenuDBus* m_appmenuDBus;
|
||||
QHash<WId, KDBusMenuImporter*> m_importers;
|
||||
GtkIcons m_icons;
|
||||
QString m_menuStyle;
|
||||
TopMenuBar* m_menubar;
|
||||
VerticalMenu* m_menu;
|
||||
QTimer* m_screenTimer;
|
||||
QAction *m_waitingAction;
|
||||
int m_currentScreen;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "appmenu_dbus.h"
|
||||
#include "kdbusimporter.h"
|
||||
#include "appmenuadaptor.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDBusMessage>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QDBusServiceWatcher>
|
||||
|
||||
static const char* DBUS_SERVICE = "org.kde.kded";
|
||||
static const char* DBUS_OBJECT_PATH = "/modules/appmenu";
|
||||
|
||||
AppmenuDBus::AppmenuDBus(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
AppmenuDBus::~AppmenuDBus()
|
||||
{
|
||||
}
|
||||
|
||||
bool AppmenuDBus::connectToBus(const QString& service, const QString& path)
|
||||
{
|
||||
m_service = service.isEmpty() ? DBUS_SERVICE : service;
|
||||
QString newPath = path.isEmpty() ? DBUS_OBJECT_PATH : path;
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerService(m_service)) {
|
||||
return false;
|
||||
}
|
||||
new AppmenuAdaptor(this);
|
||||
QDBusConnection::sessionBus().registerObject(newPath, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AppmenuDBus::showMenu(int x, int y, WId id)
|
||||
{
|
||||
emit appShowMenu(x, y, id);
|
||||
}
|
||||
|
||||
void AppmenuDBus::reconfigure()
|
||||
{
|
||||
emit moduleReconfigure();
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef APPMENU_DBUS_H
|
||||
#define APPMENU_DBUS_H
|
||||
|
||||
// Qt
|
||||
#include <QDBusContext>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <qwindowdefs.h>
|
||||
|
||||
class KDBusMenuImporter;
|
||||
|
||||
class AppmenuDBus : public QObject, protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AppmenuDBus(QObject*);
|
||||
~AppmenuDBus();
|
||||
|
||||
bool connectToBus(const QString& service = QString(), const QString& path = QString());
|
||||
|
||||
/**
|
||||
* DBus method showing menu at QPoint(x,y) for id
|
||||
* if x or y == -1, show in application window
|
||||
*/
|
||||
void showMenu(int x, int y, WId id);
|
||||
/**
|
||||
* DBus method reconfiguring kded module
|
||||
*/
|
||||
void reconfigure();
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
* This signal is emitted on showMenu() request
|
||||
*/
|
||||
void appShowMenu(int x, int y, WId id);
|
||||
/**
|
||||
* This signal is emitted on reconfigure() request
|
||||
*/
|
||||
void moduleReconfigure();
|
||||
|
||||
// Dbus signals
|
||||
/**
|
||||
* This signal is emitted whenever kded want to show menu
|
||||
* We do not know where is menu decoration button, so tell kwin to show menu
|
||||
*/
|
||||
void showRequest(qulonglong);
|
||||
/**
|
||||
* This signal is emitted whenever application menu becomes available
|
||||
*/
|
||||
void menuAvailable(qulonglong);
|
||||
/**
|
||||
* This signal is emitted whenever menus are unavailables
|
||||
*/
|
||||
void clearMenus();
|
||||
/**
|
||||
* This signal is emitted whenever popup menu/menubar is hidden
|
||||
* Useful for decorations to know if menu button should be release
|
||||
*/
|
||||
void menuHidden(qulonglong);
|
||||
/**
|
||||
* This signal is emitted whenever a window register to appmenu
|
||||
*/
|
||||
void WindowRegistered(qulonglong wid, const QString& service, const QDBusObjectPath&);
|
||||
/**
|
||||
* This signal is emitted whenever a window unregister from appmenu
|
||||
*/
|
||||
void WindowUnregistered(qulonglong wid);
|
||||
|
||||
private:
|
||||
QString m_service;
|
||||
};
|
||||
|
||||
#endif // APPMENU_DBUS_H
|
|
@ -1,56 +0,0 @@
|
|||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
|
||||
<dox:d><![CDATA[
|
||||
@mainpage
|
||||
|
||||
An interface to register menus that are associated with a window in an application. The
|
||||
main interface is docuemented here: @ref com::canonical::AppMenu::Registrar.
|
||||
|
||||
The actual menus are transported using the dbusmenu protocol which is available
|
||||
here: @ref com::canonical::dbusmenu.
|
||||
]]></dox:d>
|
||||
<interface name="com.canonical.AppMenu.Registrar" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
|
||||
<dox:d>
|
||||
An interface to register a menu from an application's window to be displayed in another
|
||||
window. This manages that association between XWindow Window IDs and the dbus
|
||||
address and object that provides the menu using the dbusmenu dbus interface.
|
||||
</dox:d>
|
||||
<method name="RegisterWindow">
|
||||
<dox:d><![CDATA[
|
||||
Associates a dbusmenu with a window
|
||||
|
||||
/note this method assumes that the connection from the caller is the DBus connection
|
||||
to use for the object. Applications that use multiple DBus connections will need to
|
||||
ensure this method is called with the same connection that implmenets the object.
|
||||
]]></dox:d>
|
||||
<arg name="windowId" type="u" direction="in">
|
||||
<dox:d>The XWindow ID of the window</dox:d>
|
||||
</arg>
|
||||
<arg name="menuObjectPath" type="o" direction="in">
|
||||
<dox:d>The object on the dbus interface implementing the dbusmenu interface</dox:d>
|
||||
</arg>
|
||||
</method>
|
||||
<method name="UnregisterWindow">
|
||||
<dox:d>
|
||||
A method to allow removing a window from the database. Windows will also be removed
|
||||
when the client drops off DBus so this is not required. It is polite though. And
|
||||
important for testing.
|
||||
</dox:d>
|
||||
<arg name="windowId" type="u" direction="in">
|
||||
<dox:d>The XWindow ID of the window</dox:d>
|
||||
</arg>
|
||||
</method>
|
||||
<method name="GetMenuForWindow">
|
||||
<dox:d>Gets the registered menu for a given window ID.</dox:d>
|
||||
<arg name="windowId" type="u" direction="in">
|
||||
<dox:d>The XWindow ID of the window to get</dox:d>
|
||||
</arg>
|
||||
<arg name="service" type="s" direction="out">
|
||||
<dox:d>The address of the connection on DBus (e.g. :1.23 or org.example.service)</dox:d>
|
||||
</arg>
|
||||
<arg name="menuObjectPath" type="o" direction="out">
|
||||
<dox:d>The path to the object which implements the com.canonical.dbusmenu interface.</dox:d>
|
||||
</arg>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "glowbar.h"
|
||||
|
||||
#include <X11/extensions/shape.h>
|
||||
#include <fixx11h.h>
|
||||
|
||||
#include <Plasma/Svg>
|
||||
#include <KWindowSystem>
|
||||
#include <KDebug>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
|
||||
|
||||
GlowBar::GlowBar()
|
||||
: QWidget(0),
|
||||
m_svg(new Plasma::Svg(this))
|
||||
{
|
||||
m_svg->setImagePath("widgets/glowbar");
|
||||
|
||||
setWindowFlags(Qt::Tool | Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setAutoFillBackground(false);
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
|
||||
QPalette pal = palette();
|
||||
pal.setColor(backgroundRole(), Qt::transparent);
|
||||
setPalette(pal);
|
||||
|
||||
setInputMask();
|
||||
}
|
||||
|
||||
GlowBar::~GlowBar()
|
||||
{
|
||||
}
|
||||
|
||||
void GlowBar::paintEvent(QPaintEvent*)
|
||||
{
|
||||
QPixmap l, r, c;
|
||||
QPoint pixmapPosition(0, 0);
|
||||
|
||||
m_buffer.fill(QColor(0, 0, 0, int(qreal(255)*0.3)));
|
||||
QPainter p(&m_buffer);
|
||||
p.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
l = m_svg->pixmap("bottomleft");
|
||||
r = m_svg->pixmap("bottomright");
|
||||
c = m_svg->pixmap("bottom");
|
||||
p.drawPixmap(pixmapPosition, l);
|
||||
p.drawTiledPixmap(QRect(l.width(), pixmapPosition.y(), width() - l.width() - r.width(), c.height()), c);
|
||||
p.drawPixmap(QPoint(width() - r.width(), pixmapPosition.y()), r);
|
||||
p.end();
|
||||
p.begin(this);
|
||||
p.drawPixmap(QPoint(0, 0), m_buffer);
|
||||
}
|
||||
|
||||
void GlowBar::setPixmap(const QPoint pos, uint width)
|
||||
{
|
||||
QRect zone = QRect(pos, QSize(width, 10));
|
||||
setGeometry(zone);
|
||||
m_buffer = QPixmap(zone.size());
|
||||
}
|
||||
|
||||
void GlowBar::setInputMask()
|
||||
{
|
||||
// Create an empty input mask to achieve click-through effect
|
||||
// Thanks to MacSlow for this!
|
||||
Pixmap mask = XCreatePixmap(QX11Info::display(),
|
||||
winId(),
|
||||
1, /* width */
|
||||
1, /* height */
|
||||
1 /* depth */);
|
||||
XShapeCombineMask(QX11Info::display(),
|
||||
winId(),
|
||||
ShapeInput,
|
||||
0, /* x-offset */
|
||||
0, /* y-offset */
|
||||
mask,
|
||||
ShapeSet);
|
||||
XFreePixmap(QX11Info::display(), mask);
|
||||
}
|
||||
#include "moc_glowbar.cpp"
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GLOWBAR__H
|
||||
#define GLOWBAR__H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class Svg;
|
||||
}
|
||||
|
||||
class GlowBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
GlowBar();
|
||||
~GlowBar();
|
||||
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
void setPixmap(const QPoint pos, uint width);
|
||||
private:
|
||||
void setInputMask();
|
||||
Plasma::Svg *m_svg;
|
||||
QPixmap m_buffer;
|
||||
};
|
||||
#endif
|
|
@ -1,146 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef GTKICONS_H
|
||||
#define GTKICONS_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
|
||||
class GtkIcons : public QMap<QString, QString>
|
||||
{
|
||||
public:
|
||||
GtkIcons( void ) : QMap<QString, QString> ()
|
||||
{
|
||||
insert(QString("gnome-fs-directory"), QString("folder.png"));
|
||||
insert(QString("gnome-fs-regular.png"), QString("application-x-zerosize.png"));
|
||||
insert(QString("gtk-about"), QString("help-about.png"));
|
||||
insert(QString("gtk-add"), QString("list-add.png"));
|
||||
insert(QString("gtk-apply"), QString("dialog-ok-apply.png ok-apply.png apply.png"));
|
||||
insert(QString("gtk-bold"), QString("format-text-bold.png"));
|
||||
insert(QString("gtk-cancel"), QString("dialog-cancel.png cancel.png"));
|
||||
insert(QString("gtk-cdrom"), QString("media-optical.png"));
|
||||
insert(QString("gtk-clear"), QString("edit-clear.png"));
|
||||
insert(QString("gtk-close"), QString("window-close.png"));
|
||||
insert(QString("gtk-color-picker"), QString("color-picker.png"));
|
||||
insert(QString("gtk-connect"), QString("network-connect.png"));
|
||||
insert(QString("gtk-convert"), QString("document-export.png"));
|
||||
insert(QString("gtk-copy"), QString("edit-copy.png"));
|
||||
insert(QString("gtk-cut"), QString("edit-cut.png"));
|
||||
insert(QString("gtk-delete"), QString("edit-delete.png"));
|
||||
insert(QString("gtk-dialog-authentication"), QString("dialog-password.png document-encrypt.png object-locked.png"));
|
||||
insert(QString("gtk-dialog-error"), QString("dialog-error.png"));
|
||||
insert(QString("gtk-dialog-info"), QString("dialog-information.png"));
|
||||
insert(QString("gtk-dialog-question"), QString("dialog-information.png"));
|
||||
insert(QString("gtk-dialog-warning"), QString("dialog-warning.png"));
|
||||
insert(QString("gtk-directory"), QString("folder.png"));
|
||||
insert(QString("gtk-disconnect"), QString("network-disconnect.png"));
|
||||
insert(QString("gtk-dnd"), QString("application-x-zerosize.png"));
|
||||
insert(QString("gtk-dnd-multiple"), QString("document-multiple.png"));
|
||||
insert(QString("gtk-edit"), QString("document-properties.png"));
|
||||
insert(QString("gtk-execute"), QString("fork.png"));
|
||||
insert(QString("gtk-file"), QString("application-x-zerosize.png"));
|
||||
insert(QString("gtk-find"), QString("edit-find.png"));
|
||||
insert(QString("gtk-find-and-replace"), QString("edit-find-replace.png"));
|
||||
insert(QString("gtk-floppy"), QString("media-floppy.png"));
|
||||
insert(QString("gtk-fullscreen"), QString("view-fullscreen.png"));
|
||||
insert(QString("gtk-goto-bottom"), QString("go-bottom.png"));
|
||||
insert(QString("gtk-goto-first"), QString("go-first.png"));
|
||||
insert(QString("gtk-goto-last"), QString("go-last.png"));
|
||||
insert(QString("gtk-goto-top"), QString("go-top.png"));
|
||||
insert(QString("gtk-go-back"), QString("go-previous.png"));
|
||||
insert(QString("gtk-go-back-ltr"), QString("go-previous.png"));
|
||||
insert(QString("gtk-go-back-rtl"), QString("go-next.png"));
|
||||
insert(QString("gtk-go-down"), QString("go-down.png"));
|
||||
insert(QString("gtk-go-forward"), QString("go-next.png"));
|
||||
insert(QString("gtk-go-forward-ltr"), QString("go-next.png"));
|
||||
insert(QString("gtk-go-forward-rtl"), QString("go-previous.png"));
|
||||
insert(QString("gtk-go-up"), QString("go-up.png"));
|
||||
insert(QString("gtk-harddisk"), QString("drive-harddisk.png"));
|
||||
insert(QString("gtk-help"), QString("help-contents.png"));
|
||||
insert(QString("gtk-home"), QString("go-home.png"));
|
||||
insert(QString("gtk-indent"), QString("format-indent-more.png"));
|
||||
insert(QString("gtk-index"), QString("help-contents.png"));
|
||||
insert(QString("gtk-info"), QString("help-about.png"));
|
||||
insert(QString("gtk-italic"), QString("format-text-italic.png"));
|
||||
insert(QString("gtk-jump-to"), QString("go-jump.png"));
|
||||
insert(QString("gtk-justify-center"), QString("format-justify-center.png"));
|
||||
insert(QString("gtk-justify-fill"), QString("format-justify-fill.png"));
|
||||
insert(QString("gtk-justify-left"), QString("format-justify-left.png"));
|
||||
insert(QString("gtk-justify-right"), QString("format-justify-right.png"));
|
||||
insert(QString("gtk-leave-fullscreen"), QString("view-restore.png"));
|
||||
insert(QString("gtk-media-forward"), QString("media-seek-forward.png"));
|
||||
insert(QString("gtk-media-next"), QString("media-skip-forward.png"));
|
||||
insert(QString("gtk-media-pause"), QString("media-playback-pause.png"));
|
||||
insert(QString("gtk-media-play"), QString("media-playback-start.png"));
|
||||
insert(QString("gtk-media-previous"), QString("media-skip-backward.png"));
|
||||
insert(QString("gtk-media-record"), QString("media-record.png"));
|
||||
insert(QString("gtk-media-rewind"), QString("media-seek-backward.png"));
|
||||
insert(QString("gtk-media-stop"), QString("media-playback-stop.png"));
|
||||
insert(QString("gtk-missing-image"), QString("unknown.png"));
|
||||
insert(QString("gtk-network"), QString("network-server.png"));
|
||||
insert(QString("gtk-new"), QString("document-new.png"));
|
||||
insert(QString("gtk-no"), QString("edit-delete.png"));
|
||||
insert(QString("gtk-ok"), QString("dialog-ok.png ok.png"));
|
||||
insert(QString("gtk-open"), QString("document-open.png"));
|
||||
insert(QString("gtk-paste"), QString("edit-paste.png"));
|
||||
insert(QString("gtk-preferences"), QString("configure.png"));
|
||||
insert(QString("gtk-print"), QString("document-print.png"));
|
||||
insert(QString("gtk-print-preview"), QString("document-print-preview.png"));
|
||||
insert(QString("gtk-properties"), QString("document-properties.png"));
|
||||
insert(QString("gtk-quit"), QString("application-exit.png"));
|
||||
insert(QString("gtk-redo"), QString("edit-redo.png"));
|
||||
insert(QString("gtk-refresh"), QString("view-refresh.png"));
|
||||
insert(QString("gtk-remove"), QString("edit-delete.png"));
|
||||
insert(QString("gtk-revert-to-saved"), QString("document-revert.png"));
|
||||
insert(QString("gtk-save"), QString("document-save.png"));
|
||||
insert(QString("gtk-save-as"), QString("document-save-as.png"));
|
||||
insert(QString("gtk-select-all"), QString("edit-select-all.png"));
|
||||
insert(QString("gtk-select-color"), QString("color-picker.png"));
|
||||
insert(QString("gtk-select-font"), QString("preferences-desktop-font.png"));
|
||||
insert(QString("gtk-sort-ascending"), QString("view-sort-ascending.png"));
|
||||
insert(QString("gtk-sort-descending"), QString("view-sort-descending.png"));
|
||||
insert(QString("gtk-spell-check"), QString("tools-check-spelling.png"));
|
||||
insert(QString("gtk-stop"), QString("process-stop.png"));
|
||||
insert(QString("gtk-strikethrough"), QString("format-text-strikethrough.png"));
|
||||
insert(QString("gtk-undelete"), QString("edit-undo.png"));
|
||||
insert(QString("gtk-underline"), QString("format-text-underline.png"));
|
||||
insert(QString("gtk-undo"), QString("edit-undo.png"));
|
||||
insert(QString("gtk-unindent"), QString("format-indent-less.png"));
|
||||
insert(QString("gtk-yes"), QString("dialog-ok.png ok.png"));
|
||||
insert(QString("gtk-zoom-100"), QString("zoom-original.png"));
|
||||
insert(QString("gtk-zoom-fit"), QString("zoom-fit-best.png"));
|
||||
insert(QString("gtk-zoom-in"), QString("zoom-in.png"));
|
||||
insert(QString("gtk-zoom-out"), QString("zoom-out.png"));
|
||||
insert(QString("stock_edit-bookmark"), QString("bookmarks-organize.png"));
|
||||
insert(QString("gimp-edit"), QString("edit.png"));
|
||||
insert(QString("gimp-info"), QString("dialog-information.png"));
|
||||
insert(QString("gimp-reset"), QString("reload.png"));
|
||||
insert(QString("gimp-warning"), QString("dialog-warning.png"));
|
||||
insert(QString("gimp-tool-options"), QString("tool.png"));
|
||||
insert(QString("gimp-images"), QString("image.png"));
|
||||
}
|
||||
};
|
||||
|
||||
#endif // GTKICONS_H
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef KDBUSMENUIMPORTER_H
|
||||
#define KDBUSMENUIMPORTER_H
|
||||
|
||||
#include "gtkicons.h"
|
||||
|
||||
#include <KIcon>
|
||||
#include <KIconLoader>
|
||||
|
||||
#include <QDBusArgument>
|
||||
|
||||
#include <dbusmenuimporter.h>
|
||||
|
||||
class KDBusMenuImporter : public DBusMenuImporter
|
||||
{
|
||||
|
||||
public:
|
||||
KDBusMenuImporter(WId wid, const QString &service, GtkIcons *icons, const QString &path, QObject *parent)
|
||||
: DBusMenuImporter(service, path, parent)
|
||||
, m_service(service)
|
||||
, m_path(path)
|
||||
, m_WId(wid)
|
||||
{
|
||||
m_icons = icons;
|
||||
}
|
||||
|
||||
QString service() const { return m_service; }
|
||||
QString path() const { return m_path; }
|
||||
WId wid() const { return m_WId; }
|
||||
|
||||
protected:
|
||||
virtual QIcon iconForName(const QString &name)
|
||||
{
|
||||
KIcon icon;
|
||||
if(m_icons->contains(name)){
|
||||
icon = KIcon(m_icons->value(name));
|
||||
}
|
||||
else if(!KIconLoader::global()->iconPath(name, 1, true ).isNull()){
|
||||
icon = KIcon(name);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
private:
|
||||
GtkIcons *m_icons;
|
||||
QString m_service;
|
||||
QString m_path;
|
||||
WId m_WId;
|
||||
};
|
||||
|
||||
#endif //KDBUSMENUIMPORTER_H
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "menubar.h"
|
||||
#include "shadows.h"
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QDesktopWidget>
|
||||
#include <QtGui/qgraphicseffect.h>
|
||||
|
||||
#include <KWindowSystem>
|
||||
#include <Plasma/FrameSvg>
|
||||
#include <Plasma/Theme>
|
||||
#include <Plasma/WindowEffects>
|
||||
#include <KApplication>
|
||||
|
||||
MenuBar::MenuBar()
|
||||
: QGraphicsView(),
|
||||
m_hideTimer(new QTimer(this)),
|
||||
m_background(new Plasma::FrameSvg(this)),
|
||||
m_shadows(new Shadows(this)),
|
||||
m_scene(new QGraphicsScene(this)),
|
||||
m_container(new MenuWidget(this))
|
||||
{
|
||||
qreal left, top, right, bottom;
|
||||
|
||||
//Setup the window properties
|
||||
setWindowFlags(Qt::Tool|Qt::X11BypassWindowManagerHint|Qt::WindowStaysOnTopHint);
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
setFrameStyle(QFrame::NoFrame);
|
||||
viewport()->setAutoFillBackground(false);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
|
||||
//Setup the widgets
|
||||
m_background->setImagePath("widgets/tooltip");
|
||||
m_background->setEnabledBorders(Plasma::FrameSvg::BottomBorder|Plasma::FrameSvg::LeftBorder|Plasma::FrameSvg::RightBorder);
|
||||
|
||||
m_container->initLayout();
|
||||
|
||||
m_scene->addItem(m_container);
|
||||
|
||||
setScene(m_scene);
|
||||
|
||||
m_background->getMargins(left, top, right, bottom);
|
||||
m_container->layout()->setContentsMargins(left, top, right, bottom);
|
||||
|
||||
resize(sizeHint());
|
||||
|
||||
connect(m_container, SIGNAL(aboutToHide()), this, SLOT(slotAboutToHide()));
|
||||
connect(m_container, SIGNAL(needResize()), this, SIGNAL(needResize()));
|
||||
connect(m_hideTimer, SIGNAL(timeout()), this, SLOT(slotAboutToHide()));
|
||||
|
||||
connect(KWindowSystem::self(), SIGNAL(compositingChanged(bool)), this, SLOT(slotCompositingChanged(bool)));
|
||||
}
|
||||
|
||||
MenuBar::~MenuBar()
|
||||
{
|
||||
}
|
||||
|
||||
QSize MenuBar::sizeHint() const
|
||||
{
|
||||
QSizeF size = m_container->minimumSize();
|
||||
return QSize(size.width(), size.height() - m_container->contentBottomMargin());
|
||||
}
|
||||
|
||||
void MenuBar::show()
|
||||
{
|
||||
// Add shadow for better readability
|
||||
if (! Plasma::WindowEffects::isEffectAvailable(Plasma::WindowEffects::BlurBehind)) {
|
||||
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect();
|
||||
shadow->setBlurRadius(5);
|
||||
shadow->setOffset(QPointF(1, 1));
|
||||
shadow->setColor(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
|
||||
setGraphicsEffect(shadow);
|
||||
} else {
|
||||
setGraphicsEffect(0);
|
||||
}
|
||||
m_hideTimer->start(1000);
|
||||
QGraphicsView::show();
|
||||
|
||||
}
|
||||
|
||||
void MenuBar::hide()
|
||||
{
|
||||
emit aboutToHide();
|
||||
m_hideTimer->stop();
|
||||
QGraphicsView::hide();
|
||||
}
|
||||
|
||||
void MenuBar::slotAboutToHide()
|
||||
{
|
||||
if (m_container->aMenuIsVisible()) { // MenuBar::m_hideTimer
|
||||
m_hideTimer->stop(); // menu is visible, menubar will be hidden by another aboutToHide() signal
|
||||
}
|
||||
else if (!cursorInMenuBar()) { //MenuWidget::AboutToHide signal
|
||||
hide();
|
||||
} else if (!m_hideTimer->isActive()){ //use click on menubar button while a popup was shown
|
||||
m_hideTimer->start(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuBar::slotCompositingChanged(bool)
|
||||
{
|
||||
updateMask();
|
||||
}
|
||||
|
||||
bool MenuBar::cursorInMenuBar()
|
||||
{
|
||||
return QRect(pos(), size()).contains(QCursor::pos());
|
||||
}
|
||||
|
||||
void MenuBar::drawBackground(QPainter *painter, const QRectF &/*rectF*/)
|
||||
{
|
||||
painter->save();
|
||||
painter->setCompositionMode(QPainter::CompositionMode_Source);
|
||||
m_background->paintFrame(painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void MenuBar::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
m_background->resizeFrame(size());
|
||||
m_scene->setSceneRect(0, 0, width(), height());
|
||||
updateMask();
|
||||
}
|
||||
|
||||
void MenuBar::updateMask()
|
||||
{
|
||||
// Enable the mask only when compositing is disabled;
|
||||
// As this operation is quite slow, it would be nice to find some
|
||||
// way to workaround it for no-compositing users.
|
||||
if (KWindowSystem::compositingActive()) {
|
||||
clearMask();
|
||||
Plasma::WindowEffects::overrideShadow(winId(), true);
|
||||
Plasma::WindowEffects::enableBlurBehind(winId(), true, m_background->mask());
|
||||
m_shadows->addWindow(this, Plasma::FrameSvg::BottomBorder|Plasma::FrameSvg::LeftBorder|Plasma::FrameSvg::RightBorder);
|
||||
} else {
|
||||
setMask(m_background->mask());
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MENUBAR__H
|
||||
#define MENUBAR__H
|
||||
|
||||
#include "menuwidget.h"
|
||||
|
||||
#include <QGraphicsView>
|
||||
|
||||
#include <QMenu>
|
||||
class Shadows;
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class FrameSvg;
|
||||
}
|
||||
|
||||
class MenuBar : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MenuBar();
|
||||
~MenuBar();
|
||||
|
||||
/**
|
||||
* Set root menu
|
||||
*/
|
||||
void setMenu(QMenu *menu) { m_container->setMenu(menu); }
|
||||
/**
|
||||
* Auto open menu items on mouse over
|
||||
*/
|
||||
void autoOpen() { m_container->autoOpen(); }
|
||||
/**
|
||||
* Set action as active menubar action
|
||||
*/
|
||||
void setActiveAction(QAction *action) { m_container->setActiveAction(action); }
|
||||
|
||||
virtual QSize sizeHint() const;
|
||||
virtual void show();
|
||||
virtual void hide();
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotAboutToHide();
|
||||
void slotCompositingChanged(bool);
|
||||
Q_SIGNALS:
|
||||
void needResize();
|
||||
void aboutToHide();
|
||||
protected:
|
||||
/**
|
||||
* Return true if cursor in menubar
|
||||
*/
|
||||
virtual bool cursorInMenuBar();
|
||||
virtual void drawBackground(QPainter* painter, const QRectF &rectF);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
private:
|
||||
void updateMask();
|
||||
QTimer* m_hideTimer;
|
||||
Plasma::FrameSvg* m_background;
|
||||
Shadows *m_shadows;
|
||||
QGraphicsScene* m_scene;
|
||||
MenuWidget* m_container;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "menubutton.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QtGui/qgraphicseffect.h>
|
||||
|
||||
#include <Plasma/Theme>
|
||||
|
||||
MenuButton::MenuButton(QGraphicsWidget *parent):
|
||||
Plasma::ToolButton(parent),
|
||||
m_enterEvent(false),
|
||||
m_menu(0)
|
||||
{
|
||||
QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect();
|
||||
shadow->setBlurRadius(5);
|
||||
shadow->setOffset(QPointF(1, 1));
|
||||
shadow->setColor(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
|
||||
setGraphicsEffect(shadow);
|
||||
}
|
||||
|
||||
void MenuButton::setHovered(bool hovered)
|
||||
{
|
||||
if (hovered) {
|
||||
hoverEnterEvent(0);
|
||||
} else {
|
||||
hoverLeaveEvent(0);
|
||||
}
|
||||
}
|
||||
|
||||
QSizeF MenuButton::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const
|
||||
{
|
||||
QSizeF sh = Plasma::ToolButton::sizeHint(which, constraint);
|
||||
if (which == Qt::MinimumSize || which == Qt::PreferredSize) {
|
||||
sh.setHeight(nativeWidget()->fontMetrics().height() + bottomMargin());
|
||||
}
|
||||
return sh;
|
||||
}
|
||||
|
||||
qreal MenuButton::bottomMargin() const
|
||||
{
|
||||
qreal left, right, top, bottom;
|
||||
getContentsMargins(&left, &right, &top, &bottom);
|
||||
return bottom;
|
||||
}
|
||||
|
||||
void MenuButton::hoverEnterEvent(QGraphicsSceneHoverEvent *e)
|
||||
{
|
||||
m_enterEvent = true;
|
||||
Plasma::ToolButton::hoverEnterEvent(e);
|
||||
}
|
||||
|
||||
void MenuButton::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
|
||||
{
|
||||
if (m_enterEvent) {
|
||||
m_enterEvent = false;
|
||||
Plasma::ToolButton::hoverLeaveEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_menubutton.cpp"
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MENUBUTTON__H
|
||||
#define MENUBUTTON__H
|
||||
|
||||
#include <Plasma/ToolButton>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
class MenuButton : public Plasma::ToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MenuButton(QGraphicsWidget *parent);
|
||||
|
||||
void setHovered(bool hovered);
|
||||
|
||||
QSizeF sizeHint(Qt::SizeHint which, const QSizeF& constraint) const;
|
||||
qreal bottomMargin() const;
|
||||
|
||||
void setMenu(QMenu *menu) { m_menu = menu; }
|
||||
QMenu* menu() { return m_menu; }
|
||||
protected:
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *);
|
||||
private:
|
||||
bool m_enterEvent;
|
||||
QMenu *m_menu;
|
||||
};
|
||||
#endif
|
|
@ -1,224 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "menuimporter.h"
|
||||
#include "menuimporteradaptor.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDBusMessage>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QDBusServiceWatcher>
|
||||
|
||||
#include <KDebug>
|
||||
#include <KWindowSystem>
|
||||
#include <KWindowInfo>
|
||||
|
||||
static const char* DBUS_SERVICE = "com.canonical.AppMenu.Registrar";
|
||||
static const char* DBUS_OBJECT_PATH = "/com/canonical/AppMenu/Registrar";
|
||||
|
||||
// Marshalling code for DBusMenuLayoutItem
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const DBusMenuLayoutItem &obj)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << obj.id << obj.properties;
|
||||
argument.beginArray(qMetaTypeId<QDBusVariant>());
|
||||
Q_FOREACH(const DBusMenuLayoutItem& child, obj.children) {
|
||||
argument << QDBusVariant(QVariant::fromValue<DBusMenuLayoutItem>(child));
|
||||
}
|
||||
argument.endArray();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, DBusMenuLayoutItem &obj)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> obj.id >> obj.properties;
|
||||
argument.beginArray();
|
||||
while (!argument.atEnd()) {
|
||||
QDBusVariant dbusVariant;
|
||||
argument >> dbusVariant;
|
||||
QDBusArgument childArgument = dbusVariant.variant().value<QDBusArgument>();
|
||||
|
||||
DBusMenuLayoutItem child;
|
||||
childArgument >> child;
|
||||
obj.children.append(child);
|
||||
}
|
||||
argument.endArray();
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
MenuImporter::MenuImporter(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_serviceWatcher(new QDBusServiceWatcher(this))
|
||||
{
|
||||
qDBusRegisterMetaType<DBusMenuLayoutItem>();
|
||||
m_serviceWatcher->setConnection(QDBusConnection::sessionBus());
|
||||
m_serviceWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
|
||||
connect(m_serviceWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&)));
|
||||
|
||||
QDBusConnection::sessionBus().connect("", "", "com.canonical.dbusmenu", "LayoutUpdated",
|
||||
this, SLOT(slotLayoutUpdated(uint,int)));
|
||||
}
|
||||
|
||||
MenuImporter::~MenuImporter()
|
||||
{
|
||||
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
|
||||
QDBusConnection::sessionBus().disconnect("", "", "com.canonical.dbusmenu", "LayoutUpdated",
|
||||
this, SLOT(slotLayoutUpdated(uint,int)));
|
||||
}
|
||||
|
||||
bool MenuImporter::connectToBus()
|
||||
{
|
||||
if (!QDBusConnection::sessionBus().registerService(DBUS_SERVICE)) {
|
||||
return false;
|
||||
}
|
||||
new MenuImporterAdaptor(this);
|
||||
QDBusConnection::sessionBus().registerObject(DBUS_OBJECT_PATH, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
WId MenuImporter::recursiveMenuId(WId id)
|
||||
{
|
||||
KWindowInfo info = KWindowSystem::windowInfo(id, 0, NET::WM2WindowClass);
|
||||
QString classClass = info.windowClassClass();
|
||||
WId classId = 0;
|
||||
|
||||
// First look at transient windows
|
||||
WId tid = KWindowSystem::transientFor(id);
|
||||
while (tid) {
|
||||
if (serviceExist(tid)) {
|
||||
classId = tid;
|
||||
break;
|
||||
}
|
||||
tid = KWindowSystem::transientFor(tid);
|
||||
}
|
||||
|
||||
if (classId == 0) {
|
||||
// Look at friends windows
|
||||
QHashIterator<WId, QString> i(m_windowClasses);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if (i.value() == classClass) {
|
||||
classId = i.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return classId;
|
||||
}
|
||||
|
||||
void MenuImporter::RegisterWindow(WId id, const QDBusObjectPath& path)
|
||||
{
|
||||
KWindowInfo info = KWindowSystem::windowInfo(id, NET::WMWindowType);
|
||||
unsigned long mask = NET::AllTypesMask;
|
||||
|
||||
// Menu can try to register, right click in gimp for exemple
|
||||
if (info.windowType(mask) & (NET::Menu|NET::DropdownMenu||NET::PopupMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.path().isEmpty()) //prevent bad dbusmenu usage
|
||||
return;
|
||||
|
||||
QString service = message().service();
|
||||
|
||||
info = KWindowSystem::windowInfo(id, 0, NET::WM2WindowClass);
|
||||
QString classClass = info.windowClassClass();
|
||||
m_windowClasses.insert(id, classClass);
|
||||
m_menuServices.insert(id, service);
|
||||
m_menuPaths.insert(id, path);
|
||||
if (! m_serviceWatcher->watchedServices().contains(service)) {
|
||||
m_serviceWatcher->addWatchedService(service);
|
||||
}
|
||||
emit WindowRegistered(id, service, path);
|
||||
}
|
||||
|
||||
void MenuImporter::UnregisterWindow(WId id)
|
||||
{
|
||||
m_menuServices.remove(id);
|
||||
m_menuPaths.remove(id);
|
||||
m_windowClasses.remove(id);
|
||||
|
||||
emit WindowUnregistered(id);
|
||||
}
|
||||
|
||||
QString MenuImporter::GetMenuForWindow(WId id, QDBusObjectPath& path)
|
||||
{
|
||||
path = m_menuPaths.value(id);
|
||||
return m_menuServices.value(id);
|
||||
}
|
||||
|
||||
void MenuImporter::slotServiceUnregistered(const QString& service)
|
||||
{
|
||||
WId id = m_menuServices.key(service);
|
||||
m_menuServices.remove(id);
|
||||
m_menuPaths.remove(id);
|
||||
m_windowClasses.remove(id);
|
||||
emit WindowUnregistered(id);
|
||||
m_serviceWatcher->removeWatchedService(service);
|
||||
}
|
||||
|
||||
void MenuImporter::slotLayoutUpdated(uint /*revision*/, int parentId)
|
||||
{
|
||||
// Fake unity-panel-service weird behavior of calling aboutToShow on
|
||||
// startup. This is necessary for Firefox menubar to work correctly at
|
||||
// startup.
|
||||
// See: https://bugs.launchpad.net/plasma-idget-menubar/+bug/878165
|
||||
|
||||
if (parentId == 0) { //root menu
|
||||
fakeUnityAboutToShow();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuImporter::fakeUnityAboutToShow()
|
||||
{
|
||||
QDBusInterface iface(message().service(), message().path(), "com.canonical.dbusmenu");
|
||||
QDBusPendingCall call = iface.asyncCall("GetLayout", 0, 1, QStringList());
|
||||
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(call, this);
|
||||
watcher->setProperty("service", message().service());
|
||||
watcher->setProperty("path", message().path());
|
||||
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
||||
SLOT(finishFakeUnityAboutToShow(QDBusPendingCallWatcher*)));
|
||||
}
|
||||
|
||||
void MenuImporter::finishFakeUnityAboutToShow(QDBusPendingCallWatcher* watcher)
|
||||
{
|
||||
QDBusPendingReply<uint, DBusMenuLayoutItem> reply = *watcher;
|
||||
if (reply.isError()) {
|
||||
kWarning() << "Call to GetLayout failed:" << reply.error().message();
|
||||
return;
|
||||
}
|
||||
QString service = watcher->property("service").toString();
|
||||
QString path = watcher->property("path").toString();
|
||||
DBusMenuLayoutItem root = reply.argumentAt<1>();
|
||||
|
||||
QDBusInterface iface(service, path, "com.canonical.dbusmenu");
|
||||
Q_FOREACH(const DBusMenuLayoutItem& dbusMenuItem, root.children) {
|
||||
iface.asyncCall("AboutToShow", dbusMenuItem.id);
|
||||
}
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MENUIMPORTER_H
|
||||
#define MENUIMPORTER_H
|
||||
|
||||
// Qt
|
||||
#include <QDBusContext>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QObject>
|
||||
#include <QWidget> // For WId
|
||||
|
||||
#include <QDBusObjectPath>
|
||||
#include <QDBusPendingCallWatcher>
|
||||
#include <QDBusServiceWatcher>
|
||||
#include <QMenu>
|
||||
|
||||
/**
|
||||
* Represents an item with its children. GetLayout() returns a
|
||||
* DBusMenuLayoutItemList.
|
||||
*/
|
||||
struct DBusMenuLayoutItem
|
||||
{
|
||||
int id;
|
||||
QVariantMap properties;
|
||||
QList<DBusMenuLayoutItem> children;
|
||||
};
|
||||
Q_DECLARE_METATYPE(DBusMenuLayoutItem)
|
||||
|
||||
class MenuImporter : public QObject, protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MenuImporter(QObject*);
|
||||
~MenuImporter();
|
||||
|
||||
bool connectToBus();
|
||||
|
||||
bool serviceExist(WId id) { return m_menuServices.contains(id); }
|
||||
QString serviceForWindow(WId id) { return m_menuServices.value(id); }
|
||||
|
||||
bool pathExist(WId id) { return m_menuPaths.contains(id); }
|
||||
QString pathForWindow(WId id) { return m_menuPaths.value(id).path(); }
|
||||
|
||||
QList<WId> ids() { return m_menuServices.keys(); }
|
||||
|
||||
/**
|
||||
* Return id of first transient/friend window with a menu available
|
||||
*/
|
||||
WId recursiveMenuId(WId id);
|
||||
|
||||
Q_SIGNALS:
|
||||
void WindowRegistered(WId id, const QString& service, const QDBusObjectPath&);
|
||||
void WindowUnregistered(WId id);
|
||||
|
||||
public Q_SLOTS:
|
||||
void RegisterWindow(WId id, const QDBusObjectPath& path);
|
||||
void UnregisterWindow(WId id);
|
||||
QString GetMenuForWindow(WId id, QDBusObjectPath& path);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotServiceUnregistered(const QString& service);
|
||||
void slotLayoutUpdated(uint revision, int parentId);
|
||||
void finishFakeUnityAboutToShow(QDBusPendingCallWatcher*);
|
||||
|
||||
private:
|
||||
QDBusServiceWatcher* m_serviceWatcher;
|
||||
QHash<WId, QString> m_menuServices;
|
||||
QHash<WId, QDBusObjectPath> m_menuPaths;
|
||||
QHash<WId, QString> m_windowClasses;
|
||||
|
||||
void fakeUnityAboutToShow();
|
||||
};
|
||||
|
||||
#endif /* MENUIMPORTER_H */
|
|
@ -1,387 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "menuwidget.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGraphicsView>
|
||||
#include <QGraphicsLinearLayout>
|
||||
|
||||
#include <KWindowSystem>
|
||||
#include <KDebug>
|
||||
#include <KApplication>
|
||||
|
||||
MenuWidget::MenuWidget(QGraphicsView *view) :
|
||||
QGraphicsWidget(),
|
||||
m_mouseTimer(new QTimer(this)),
|
||||
m_actionTimer(new QTimer(this)),
|
||||
m_view(view),
|
||||
m_layout(new QGraphicsLinearLayout(this)),
|
||||
m_currentButton(0),
|
||||
m_contentBottomMargin(0),
|
||||
m_mousePosition(-1, -1),
|
||||
m_visibleMenu(0),
|
||||
m_menu(0)
|
||||
{
|
||||
connect(m_actionTimer, SIGNAL(timeout()), SLOT(slotUpdateActions()));
|
||||
connect(m_mouseTimer, SIGNAL(timeout()), SLOT(slotCheckActiveItem()));
|
||||
}
|
||||
|
||||
MenuWidget::~MenuWidget()
|
||||
{
|
||||
while (!m_buttons.isEmpty()) {
|
||||
delete m_buttons.front();
|
||||
m_buttons.pop_front();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuWidget::setMenu(QMenu *menu)
|
||||
{
|
||||
if (m_menu) {
|
||||
disconnect(m_menu, SIGNAL(destroyed()), this, SLOT(slotMenuDestroyed()));
|
||||
m_menu->removeEventFilter(this);
|
||||
}
|
||||
if (menu) {
|
||||
if (m_mouseTimer->isActive()) {
|
||||
m_mouseTimer->stop();
|
||||
}
|
||||
m_visibleMenu = 0;
|
||||
m_menu = menu;
|
||||
connect(m_menu, SIGNAL(destroyed()), SLOT(slotMenuDestroyed()), Qt::UniqueConnection);
|
||||
m_menu->installEventFilter(this);
|
||||
slotUpdateActions();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuWidget::initLayout()
|
||||
{
|
||||
MenuButton* button = 0;
|
||||
|
||||
if (!m_menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QAction* action, m_menu->actions())
|
||||
{
|
||||
button = createButton(action);
|
||||
if (button) {
|
||||
m_layout->addItem(button);
|
||||
button->setMenu(action->menu());
|
||||
m_buttons << button;
|
||||
}
|
||||
}
|
||||
|
||||
//Assume all buttons have same margins
|
||||
if (button) {
|
||||
m_contentBottomMargin = button->bottomMargin();
|
||||
}
|
||||
}
|
||||
|
||||
bool MenuWidget::eventFilter(QObject* object, QEvent* event)
|
||||
{
|
||||
bool filtered;
|
||||
if (object == m_menu) {
|
||||
filtered = menuEventFilter(event);
|
||||
} else {
|
||||
filtered = subMenuEventFilter(static_cast<QMenu*>(object), event);
|
||||
}
|
||||
return filtered ? true : QGraphicsWidget::eventFilter(object, event);
|
||||
}
|
||||
|
||||
bool MenuWidget::menuEventFilter(QEvent* event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::ActionAdded:
|
||||
case QEvent::ActionRemoved:
|
||||
case QEvent::ActionChanged:
|
||||
// Try to limit layout updates
|
||||
m_actionTimer->start(500);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MenuWidget::subMenuEventFilter(QObject* object, QEvent* event)
|
||||
{
|
||||
QMenu *menu = static_cast<QMenu*>(object);
|
||||
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
menu->removeEventFilter(this);
|
||||
QApplication::sendEvent(menu, event);
|
||||
menu->installEventFilter(this);
|
||||
if (!event->isAccepted()) {
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
switch (keyEvent->key()) {
|
||||
case Qt::Key_Left:
|
||||
showLeftRightMenu(false);
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
showLeftRightMenu(true);
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
menu->hide();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void MenuWidget::slotMenuDestroyed()
|
||||
{
|
||||
m_menu = 0;
|
||||
m_visibleMenu = 0;
|
||||
m_currentButton = 0;
|
||||
}
|
||||
|
||||
void MenuWidget::slotCheckActiveItem()
|
||||
{
|
||||
MenuButton* buttonBelow = 0;
|
||||
QPoint pos = m_view->mapFromGlobal(QCursor::pos());
|
||||
QGraphicsItem* item = m_view->itemAt(pos);
|
||||
|
||||
if (pos == m_mousePosition) {
|
||||
return;
|
||||
} else {
|
||||
m_mousePosition = pos;
|
||||
}
|
||||
|
||||
if (item) {
|
||||
buttonBelow = qobject_cast<MenuButton*>(item->toGraphicsObject());
|
||||
}
|
||||
|
||||
if (!buttonBelow) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (buttonBelow != m_currentButton) {
|
||||
if (m_currentButton && m_currentButton->nativeWidget()) {
|
||||
m_currentButton->nativeWidget()->setDown(false);
|
||||
m_currentButton->setHovered(false);
|
||||
}
|
||||
m_currentButton = buttonBelow;
|
||||
if (m_currentButton->nativeWidget()) {
|
||||
m_currentButton->nativeWidget()->setDown(true);
|
||||
}
|
||||
m_visibleMenu = showMenu();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuWidget::slotMenuAboutToHide()
|
||||
{
|
||||
if (m_currentButton && m_currentButton->nativeWidget()) {
|
||||
m_currentButton->nativeWidget()->setDown(false);
|
||||
}
|
||||
|
||||
if (m_mouseTimer->isActive()) {
|
||||
m_mouseTimer->stop();
|
||||
}
|
||||
m_visibleMenu = 0;
|
||||
emit aboutToHide();
|
||||
}
|
||||
|
||||
void MenuWidget::slotButtonClicked()
|
||||
{
|
||||
m_currentButton = qobject_cast<MenuButton*>(sender());
|
||||
|
||||
if (m_currentButton && m_currentButton->nativeWidget()) {
|
||||
m_currentButton->nativeWidget()->setDown(true);
|
||||
}
|
||||
m_visibleMenu = showMenu();
|
||||
// Start auto navigation after click
|
||||
if (!m_mouseTimer->isActive())
|
||||
m_mouseTimer->start(100);
|
||||
}
|
||||
|
||||
void MenuWidget::slotUpdateActions()
|
||||
{
|
||||
if (m_visibleMenu) {
|
||||
return; // Later
|
||||
}
|
||||
|
||||
m_actionTimer->stop();
|
||||
m_currentButton = 0;
|
||||
foreach (MenuButton *button, m_buttons) {
|
||||
disconnect(button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()));
|
||||
m_layout->removeItem(button);
|
||||
button->hide();
|
||||
m_buttons.removeOne(button);
|
||||
delete button;
|
||||
}
|
||||
initLayout();
|
||||
// Menu may be empty on application startup
|
||||
// slotUpdateActions will be called later by eventFilter()
|
||||
if (m_menu && m_menu->actions().length()) {
|
||||
emit needResize();
|
||||
}
|
||||
}
|
||||
|
||||
void MenuWidget::setActiveAction(QAction *action)
|
||||
{
|
||||
if (!m_menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentButton = m_buttons.first();
|
||||
|
||||
if (action) {
|
||||
QMenu *menu;
|
||||
int i = 0;
|
||||
foreach (MenuButton *button, m_buttons) {
|
||||
menu = m_menu->actions()[i]->menu();
|
||||
if (menu && menu == action->menu()) {
|
||||
m_currentButton = button;
|
||||
break;
|
||||
}
|
||||
if (++i >= m_menu->actions().length()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_currentButton->nativeWidget()->animateClick();
|
||||
}
|
||||
|
||||
void MenuWidget::hide()
|
||||
{
|
||||
if (m_mouseTimer->isActive()) {
|
||||
m_mouseTimer->stop();
|
||||
}
|
||||
QGraphicsWidget::hide();
|
||||
}
|
||||
|
||||
MenuButton* MenuWidget::createButton(QAction *action)
|
||||
{
|
||||
if( action->isSeparator() || !action->menu() || !action->isVisible()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
action->setShortcut(QKeySequence());
|
||||
MenuButton *button = new MenuButton(this);
|
||||
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
button->setText(action->text());
|
||||
connect(button, SIGNAL(clicked()), SLOT(slotButtonClicked()));
|
||||
return button;
|
||||
}
|
||||
|
||||
QMenu* MenuWidget::showMenu()
|
||||
{
|
||||
QMenu *menu = 0;
|
||||
|
||||
if (m_visibleMenu) {
|
||||
disconnect(m_visibleMenu, SIGNAL(aboutToHide()), this, SLOT(slotMenuAboutToHide()));
|
||||
m_visibleMenu->hide();
|
||||
}
|
||||
|
||||
if (m_currentButton && m_menu) {
|
||||
menu = m_currentButton->menu();
|
||||
}
|
||||
|
||||
// Last chance to get menu
|
||||
// Some applications like Firefox have empties menus on layout updates
|
||||
// They should populate this menu later but in fact, they use another object
|
||||
// So, we check here directly the button name, may fail with menubar with buttons with same name (test apps)
|
||||
if (menu && menu->actions().length() == 0) {
|
||||
foreach (QAction *action, m_menu->actions()) {
|
||||
if (action->text() == m_currentButton->text()) {
|
||||
menu = action->menu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (menu) {
|
||||
QPoint globalPos = m_view->mapToGlobal(QPoint(0,0));
|
||||
QPointF parentPos = m_currentButton->mapFromParent(QPoint(0,0));
|
||||
QRect screen = KApplication::desktop()->screenGeometry();
|
||||
int x = globalPos.x() - parentPos.x();
|
||||
int y = globalPos.y() + m_currentButton->size().height() - parentPos.y();
|
||||
|
||||
menu->popup(QPoint(x, y));
|
||||
|
||||
// Fix offscreen menu
|
||||
if (menu->size().height() + y > screen.height() + screen.y()) {
|
||||
y = globalPos.y() - parentPos.y() - menu->size().height();
|
||||
if (menu->size().width() + x > screen.width() + screen.x())
|
||||
x = screen.width() + screen.x() - menu->size().width();
|
||||
else if (menu->size().width() + x < screen.x())
|
||||
x = screen.x();
|
||||
menu->move(x, y);
|
||||
}
|
||||
|
||||
connect(menu, SIGNAL(aboutToHide()), this, SLOT(slotMenuAboutToHide()));
|
||||
|
||||
installEventFilterForAll(menu, this);
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
void MenuWidget::showLeftRightMenu(bool next)
|
||||
{
|
||||
if (!m_currentButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = m_buttons.indexOf(m_currentButton);
|
||||
if (index == -1) {
|
||||
kWarning() << "Couldn't find button!";
|
||||
return;
|
||||
}
|
||||
if (next) {
|
||||
index = (index + 1) % m_buttons.count();
|
||||
} else {
|
||||
index = (index == 0 ? m_buttons.count() : index) - 1;
|
||||
}
|
||||
|
||||
if (m_currentButton && m_currentButton->nativeWidget()) {
|
||||
m_currentButton->nativeWidget()->setDown(false);
|
||||
}
|
||||
m_currentButton = m_buttons.at(index);
|
||||
if (m_currentButton && m_currentButton->nativeWidget()) {
|
||||
m_currentButton->nativeWidget()->setDown(true);
|
||||
}
|
||||
m_visibleMenu = showMenu();
|
||||
}
|
||||
|
||||
void MenuWidget::installEventFilterForAll(QMenu *menu, QObject *object)
|
||||
{
|
||||
if (!menu) {
|
||||
return;
|
||||
}
|
||||
|
||||
menu->installEventFilter(this);
|
||||
|
||||
foreach (QAction *action, menu->actions()) {
|
||||
if (action->menu())
|
||||
installEventFilterForAll(action->menu(), object);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_menuwidget.cpp"
|
|
@ -1,143 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef MENUWIDGET__H
|
||||
#define MENUWIDGET__H
|
||||
|
||||
#include "menubutton.h"
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QGraphicsView>
|
||||
|
||||
class MenuWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MenuWidget(QGraphicsView *view = 0);
|
||||
~MenuWidget();
|
||||
|
||||
/**
|
||||
* Set root menu
|
||||
*/
|
||||
void setMenu(QMenu *menu);
|
||||
/**
|
||||
* Init layout with root menu
|
||||
*/
|
||||
void initLayout();
|
||||
/**
|
||||
* True if a menu is visible in menuwidget
|
||||
*/
|
||||
bool aMenuIsVisible() { return m_visibleMenu; }
|
||||
/**
|
||||
* Activate action, or first action if null
|
||||
*/
|
||||
void setActiveAction(QAction *action);
|
||||
|
||||
/**
|
||||
* Auto open menu items on mouse over
|
||||
*/
|
||||
void autoOpen() { m_mouseTimer->start(100); }
|
||||
|
||||
/**
|
||||
* Return content bottom margin
|
||||
*/
|
||||
qreal contentBottomMargin() { return m_contentBottomMargin; }
|
||||
|
||||
void hide();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Use to get keyboard events
|
||||
*/
|
||||
virtual bool eventFilter(QObject*, QEvent*);
|
||||
/**
|
||||
* Filter events on main menu
|
||||
*/
|
||||
bool menuEventFilter(QEvent* event);
|
||||
/**
|
||||
* Filter events on submenus
|
||||
*/
|
||||
bool subMenuEventFilter(QObject* object, QEvent* event);
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Clean menu if destroyed
|
||||
*/
|
||||
void slotMenuDestroyed();
|
||||
/**
|
||||
* Check hovered item and active it
|
||||
*/
|
||||
void slotCheckActiveItem();
|
||||
/**
|
||||
* A menu is hidding
|
||||
*/
|
||||
void slotMenuAboutToHide();
|
||||
/**
|
||||
* Menubar button clicked
|
||||
*/
|
||||
void slotButtonClicked();
|
||||
/**
|
||||
* Update pending actions
|
||||
*/
|
||||
void slotUpdateActions();
|
||||
Q_SIGNALS:
|
||||
void needResize();
|
||||
void aboutToHide();
|
||||
private:
|
||||
/**
|
||||
* Return a button based on action
|
||||
*/
|
||||
MenuButton* createButton(QAction *action);
|
||||
/**
|
||||
* Show current button menu
|
||||
* return showed menu
|
||||
*/
|
||||
QMenu* showMenu();
|
||||
/**
|
||||
* Show next menu if next, otherwise previous
|
||||
*/
|
||||
void showLeftRightMenu(bool next);
|
||||
/**
|
||||
* Install event filter for menu and it submenus
|
||||
*/
|
||||
void installEventFilterForAll(QMenu *menu, QObject *object);
|
||||
|
||||
//Follow mouse position
|
||||
QTimer *m_mouseTimer;
|
||||
//Update actions
|
||||
QTimer *m_actionTimer;
|
||||
QGraphicsView *m_view;
|
||||
QGraphicsLinearLayout *m_layout;
|
||||
QList<MenuButton*> m_buttons;
|
||||
MenuButton *m_currentButton;
|
||||
qreal m_contentBottomMargin;
|
||||
QPoint m_mousePosition;
|
||||
QMenu *m_visibleMenu;
|
||||
QMenu *m_menu;
|
||||
};
|
||||
|
||||
#endif //MENUWIDGET__H
|
|
@ -1,31 +0,0 @@
|
|||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.kde.kded">
|
||||
<method name="showMenu">
|
||||
<arg name="x" type="i" direction="in"/>
|
||||
<arg name="y" type="i" direction="in"/>
|
||||
<arg name="WId" type="t" direction="in"/>
|
||||
</method>
|
||||
<method name="reconfigure">
|
||||
</method>
|
||||
<signal name="showRequest">
|
||||
<arg name="WId" type="t"/>
|
||||
</signal>
|
||||
<signal name="menuAvailable">
|
||||
<arg name="WId" type="t"/>
|
||||
</signal>
|
||||
<signal name="clearMenus">
|
||||
</signal>
|
||||
<signal name="menuHidden">
|
||||
<arg name="WId" type="t"/>
|
||||
</signal>
|
||||
<signal name="WindowRegistered">
|
||||
<arg name="windowId" type="t" direction="out"/>
|
||||
<arg name="service" type="s" direction="out"/>
|
||||
<arg name="menuObjectPath" type="o" direction="out"/>
|
||||
</signal>
|
||||
<signal name="WindowUnregistered">
|
||||
<arg name="windowId" type="t" direction="out"/>
|
||||
</signal>
|
||||
</interface>
|
||||
</node>
|
|
@ -1,381 +0,0 @@
|
|||
/*
|
||||
* Copyright 2011 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "shadows.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <QtGui/qx11info_x11.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <fixx11h.h>
|
||||
#endif
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
|
||||
class Shadows::Private
|
||||
{
|
||||
public:
|
||||
Private(Shadows *shadows)
|
||||
: q(shadows),
|
||||
m_managePixmaps(false)
|
||||
{
|
||||
}
|
||||
|
||||
~Private()
|
||||
{
|
||||
clearPixmaps();
|
||||
}
|
||||
|
||||
void clearPixmaps();
|
||||
void setupPixmaps();
|
||||
void initPixmap(const QString &element);
|
||||
QPixmap initEmptyPixmap(const QSize &size);
|
||||
void updateShadow(const QWidget *window, Plasma::FrameSvg::EnabledBorders);
|
||||
void clearShadow(const QWidget *window);
|
||||
void updateShadows();
|
||||
void windowDestroyed(QObject *deletedObject);
|
||||
void setupData(Plasma::FrameSvg::EnabledBorders enabledBorders);
|
||||
|
||||
Shadows *q;
|
||||
QList<QPixmap> m_shadowPixmaps;
|
||||
|
||||
QPixmap m_emptyCornerPix;
|
||||
QPixmap m_emptyCornerLeftPix;
|
||||
QPixmap m_emptyCornerTopPix;
|
||||
QPixmap m_emptyCornerRightPix;
|
||||
QPixmap m_emptyCornerBottomPix;
|
||||
QPixmap m_emptyVerticalPix;
|
||||
QPixmap m_emptyHorizontalPix;
|
||||
|
||||
QHash<Plasma::FrameSvg::EnabledBorders, QVector<unsigned long> > data;
|
||||
QHash<const QWidget *, Plasma::FrameSvg::EnabledBorders> m_windows;
|
||||
bool m_managePixmaps;
|
||||
};
|
||||
|
||||
class ShadowsSingleton
|
||||
{
|
||||
public:
|
||||
ShadowsSingleton()
|
||||
{
|
||||
}
|
||||
|
||||
Shadows self;
|
||||
};
|
||||
|
||||
K_GLOBAL_STATIC(ShadowsSingleton, privateShadowsSelf)
|
||||
|
||||
Shadows::Shadows(QObject *parent, const QString &prefix)
|
||||
: Plasma::Svg(parent),
|
||||
d(new Private(this))
|
||||
{
|
||||
setImagePath(prefix);
|
||||
connect(this, SIGNAL(repaintNeeded()), this, SLOT(updateShadows()));
|
||||
}
|
||||
|
||||
Shadows *Shadows::self()
|
||||
{
|
||||
return &privateShadowsSelf->self;
|
||||
}
|
||||
|
||||
void Shadows::addWindow(const QWidget *window, Plasma::FrameSvg::EnabledBorders enabledBorders)
|
||||
{
|
||||
if (!window || !window->isWindow()) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->m_windows[window] = enabledBorders;
|
||||
d->updateShadow(window, enabledBorders);
|
||||
connect(window, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(windowDestroyed(QObject*)), Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void Shadows::removeWindow(const QWidget *window)
|
||||
{
|
||||
if (!d->m_windows.contains(window)) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->m_windows.remove(window);
|
||||
disconnect(window, 0, this, 0);
|
||||
d->clearShadow(window);
|
||||
|
||||
if (d->m_windows.isEmpty()) {
|
||||
d->clearPixmaps();
|
||||
}
|
||||
}
|
||||
|
||||
void Shadows::Private::windowDestroyed(QObject *deletedObject)
|
||||
{
|
||||
m_windows.remove(static_cast<QWidget *>(deletedObject));
|
||||
|
||||
if (m_windows.isEmpty()) {
|
||||
clearPixmaps();
|
||||
}
|
||||
}
|
||||
|
||||
void Shadows::Private::updateShadows()
|
||||
{
|
||||
setupPixmaps();
|
||||
QHash<const QWidget *, Plasma::FrameSvg::EnabledBorders>::const_iterator i;
|
||||
for (i = m_windows.constBegin(); i != m_windows.constEnd(); ++i) {
|
||||
updateShadow(i.key(), i.value());
|
||||
}
|
||||
}
|
||||
|
||||
void Shadows::Private::initPixmap(const QString &element)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
QPixmap pix = q->pixmap(element);
|
||||
if (!pix.isNull() && pix.handle() == 0) {
|
||||
Pixmap xPix = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), pix.width(), pix.height(), 32);
|
||||
QPixmap tempPix = QPixmap::fromX11Pixmap(xPix, QPixmap::ExplicitlyShared);
|
||||
tempPix.fill(Qt::transparent);
|
||||
QPainter p(&tempPix);
|
||||
p.drawPixmap(QPoint(0, 0), pix);
|
||||
m_shadowPixmaps << tempPix;
|
||||
m_managePixmaps = true;
|
||||
} else {
|
||||
m_shadowPixmaps << pix;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
QPixmap Shadows::Private::initEmptyPixmap(const QSize &size)
|
||||
{
|
||||
Pixmap emptyXPix = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), size.width(), size.height(), 32);
|
||||
QPixmap tempEmptyPix = QPixmap::fromX11Pixmap(emptyXPix, QPixmap::ExplicitlyShared);
|
||||
tempEmptyPix.fill(Qt::transparent);
|
||||
return tempEmptyPix;
|
||||
}
|
||||
|
||||
void Shadows::Private::setupPixmaps()
|
||||
{
|
||||
clearPixmaps();
|
||||
initPixmap("shadow-top");
|
||||
initPixmap("shadow-topright");
|
||||
initPixmap("shadow-right");
|
||||
initPixmap("shadow-bottomright");
|
||||
initPixmap("shadow-bottom");
|
||||
initPixmap("shadow-bottomleft");
|
||||
initPixmap("shadow-left");
|
||||
initPixmap("shadow-topleft");
|
||||
|
||||
m_emptyCornerPix = initEmptyPixmap(QSize(1,1));
|
||||
m_emptyCornerLeftPix = initEmptyPixmap(QSize(q->elementSize("shadow-topleft").width(), 1));
|
||||
m_emptyCornerTopPix = initEmptyPixmap(QSize(1, q->elementSize("shadow-topleft").height()));
|
||||
m_emptyCornerRightPix = initEmptyPixmap(QSize(q->elementSize("shadow-bottomright").width(), 1));
|
||||
m_emptyCornerBottomPix = initEmptyPixmap(QSize(1, q->elementSize("shadow-bottomright").height()));
|
||||
m_emptyVerticalPix = initEmptyPixmap(QSize(1, q->elementSize("shadow-left").height()));
|
||||
m_emptyHorizontalPix = initEmptyPixmap(QSize(q->elementSize("shadow-top").width(), 1));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Shadows::Private::setupData(Plasma::FrameSvg::EnabledBorders enabledBorders)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
//shadow-top
|
||||
if (enabledBorders & Plasma::FrameSvg::TopBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[0].handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyHorizontalPix.handle();
|
||||
}
|
||||
|
||||
//shadow-topright
|
||||
if (enabledBorders & Plasma::FrameSvg::TopBorder &&
|
||||
enabledBorders & Plasma::FrameSvg::RightBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[1].handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::TopBorder) {
|
||||
data[enabledBorders] << m_emptyCornerTopPix.handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::RightBorder) {
|
||||
data[enabledBorders] << m_emptyCornerRightPix.handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyCornerPix.handle();
|
||||
}
|
||||
|
||||
//shadow-right
|
||||
if (enabledBorders & Plasma::FrameSvg::RightBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[2].handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyVerticalPix.handle();
|
||||
}
|
||||
|
||||
//shadow-bottomright
|
||||
if (enabledBorders & Plasma::FrameSvg::BottomBorder &&
|
||||
enabledBorders & Plasma::FrameSvg::RightBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[3].handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::BottomBorder) {
|
||||
data[enabledBorders] << m_emptyCornerBottomPix.handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::RightBorder) {
|
||||
data[enabledBorders] << m_emptyCornerRightPix.handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyCornerPix.handle();
|
||||
}
|
||||
|
||||
//shadow-bottom
|
||||
if (enabledBorders & Plasma::FrameSvg::BottomBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[4].handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyHorizontalPix.handle();
|
||||
}
|
||||
|
||||
//shadow-bottomleft
|
||||
if (enabledBorders & Plasma::FrameSvg::BottomBorder &&
|
||||
enabledBorders & Plasma::FrameSvg::LeftBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[5].handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::BottomBorder) {
|
||||
data[enabledBorders] << m_emptyCornerBottomPix.handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::LeftBorder) {
|
||||
data[enabledBorders] << m_emptyCornerLeftPix.handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyCornerPix.handle();
|
||||
}
|
||||
|
||||
//shadow-left
|
||||
if (enabledBorders & Plasma::FrameSvg::LeftBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[6].handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyVerticalPix.handle();
|
||||
}
|
||||
|
||||
//shadow-topleft
|
||||
if (enabledBorders & Plasma::FrameSvg::TopBorder &&
|
||||
enabledBorders & Plasma::FrameSvg::LeftBorder) {
|
||||
data[enabledBorders] << m_shadowPixmaps[7].handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::TopBorder) {
|
||||
data[enabledBorders] << m_emptyCornerTopPix.handle();
|
||||
} else if (enabledBorders & Plasma::FrameSvg::LeftBorder) {
|
||||
data[enabledBorders] << m_emptyCornerLeftPix.handle();
|
||||
} else {
|
||||
data[enabledBorders] << m_emptyCornerPix.handle();
|
||||
}
|
||||
#endif
|
||||
|
||||
int left, top, right, bottom = 0;
|
||||
|
||||
QSize marginHint;
|
||||
if (enabledBorders & Plasma::FrameSvg::TopBorder) {
|
||||
marginHint = q->elementSize("shadow-hint-top-margin");
|
||||
if (marginHint.isValid()) {
|
||||
top = marginHint.height();
|
||||
} else {
|
||||
top = m_shadowPixmaps[0].height(); // top
|
||||
}
|
||||
} else {
|
||||
top = 1;
|
||||
}
|
||||
|
||||
if (enabledBorders & Plasma::FrameSvg::RightBorder) {
|
||||
marginHint = q->elementSize("shadow-hint-right-margin");
|
||||
if (marginHint.isValid()) {
|
||||
right = marginHint.width();
|
||||
} else {
|
||||
right = m_shadowPixmaps[2].width(); // right
|
||||
}
|
||||
} else {
|
||||
right = 1;
|
||||
}
|
||||
|
||||
if (enabledBorders & Plasma::FrameSvg::BottomBorder) {
|
||||
marginHint = q->elementSize("shadow-hint-bottom-margin");
|
||||
if (marginHint.isValid()) {
|
||||
bottom = marginHint.height();
|
||||
} else {
|
||||
bottom = m_shadowPixmaps[4].height(); // bottom
|
||||
}
|
||||
} else {
|
||||
bottom = 1;
|
||||
}
|
||||
|
||||
if (enabledBorders & Plasma::FrameSvg::LeftBorder) {
|
||||
marginHint = q->elementSize("shadow-hint-left-margin");
|
||||
if (marginHint.isValid()) {
|
||||
left = marginHint.width();
|
||||
} else {
|
||||
left = m_shadowPixmaps[6].width(); // left
|
||||
}
|
||||
} else {
|
||||
left = 1;
|
||||
}
|
||||
|
||||
data[enabledBorders] << top << right << bottom << left;
|
||||
}
|
||||
|
||||
void Shadows::Private::clearPixmaps()
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
if (m_managePixmaps) {
|
||||
foreach (const QPixmap &pixmap, m_shadowPixmaps) {
|
||||
XFreePixmap(QX11Info::display(), pixmap.handle());
|
||||
}
|
||||
|
||||
XFreePixmap(QX11Info::display(), m_emptyCornerPix.handle());
|
||||
XFreePixmap(QX11Info::display(), m_emptyCornerBottomPix.handle());
|
||||
XFreePixmap(QX11Info::display(), m_emptyCornerLeftPix.handle());
|
||||
XFreePixmap(QX11Info::display(), m_emptyCornerRightPix.handle());
|
||||
XFreePixmap(QX11Info::display(), m_emptyCornerTopPix.handle());
|
||||
XFreePixmap(QX11Info::display(), m_emptyVerticalPix.handle());
|
||||
XFreePixmap(QX11Info::display(), m_emptyHorizontalPix.handle());
|
||||
|
||||
m_managePixmaps = false;
|
||||
}
|
||||
#endif
|
||||
m_shadowPixmaps.clear();
|
||||
data.clear();
|
||||
}
|
||||
|
||||
void Shadows::Private::updateShadow(const QWidget *window, Plasma::FrameSvg::EnabledBorders enabledBorders)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
if (m_shadowPixmaps.isEmpty()) {
|
||||
setupPixmaps();
|
||||
}
|
||||
|
||||
if (!data.contains(enabledBorders)) {
|
||||
setupData(enabledBorders);
|
||||
}
|
||||
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False);
|
||||
|
||||
//kDebug() << "going to set the shadow of" << winId() << "to" << data;
|
||||
XChangeProperty(dpy, window->winId(), atom, XA_CARDINAL, 32, PropModeReplace,
|
||||
reinterpret_cast<const unsigned char *>(data[enabledBorders].constData()), data[enabledBorders].size());
|
||||
#endif
|
||||
}
|
||||
|
||||
void Shadows::Private::clearShadow(const QWidget *window)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom(dpy, "_KDE_NET_WM_SHADOW", False);
|
||||
XDeleteProperty(dpy, window->winId(), atom);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Shadows::enabled() const
|
||||
{
|
||||
return hasElement("shadow-left");
|
||||
}
|
||||
|
||||
#include "moc_shadows.cpp"
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Copyright 2011 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef SHADOWS_H
|
||||
#define SHADOWS_H
|
||||
|
||||
#include <QSet>
|
||||
|
||||
#include "plasma/framesvg.h"
|
||||
#include "plasma/svg.h"
|
||||
|
||||
|
||||
class Shadows : public Plasma::Svg
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Shadows(QObject *parent = 0, const QString &prefix = "widgets/panel-background");
|
||||
|
||||
static Shadows *self();
|
||||
|
||||
void addWindow(const QWidget *window, Plasma::FrameSvg::EnabledBorders enabledBorders = Plasma::FrameSvg::AllBorders);
|
||||
void removeWindow(const QWidget *window);
|
||||
|
||||
bool enabled() const;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private * const d;
|
||||
|
||||
Q_PRIVATE_SLOT(d, void updateShadows())
|
||||
Q_PRIVATE_SLOT(d, void windowDestroyed(QObject *deletedObject))
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "topmenubar.h"
|
||||
#include "glowbar.h"
|
||||
|
||||
//KDE
|
||||
#include <Plasma/Svg>
|
||||
#include <KWindowSystem>
|
||||
|
||||
// Qt
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
TopMenuBar::TopMenuBar()
|
||||
: MenuBar(),
|
||||
m_prevCursorPos(-1, -1),
|
||||
m_mouseTracker(new QTimer(this)),
|
||||
m_hideGlowTimer(new QTimer(this)),
|
||||
m_glowBar(new GlowBar())
|
||||
{
|
||||
connect(this, SIGNAL(aboutToHide()), this, SLOT(slotAboutToHide()));
|
||||
connect(m_mouseTracker, SIGNAL(timeout()), this, SLOT(slotMouseTracker()));
|
||||
connect(m_hideGlowTimer, SIGNAL(timeout()), this, SLOT(slotHideGlowBar()));
|
||||
}
|
||||
|
||||
TopMenuBar::~TopMenuBar()
|
||||
{
|
||||
delete m_mouseTracker;
|
||||
delete m_hideGlowTimer;
|
||||
hideGlowBar();
|
||||
delete m_glowBar;
|
||||
}
|
||||
|
||||
void TopMenuBar::enableMouseTracking(bool enable)
|
||||
{
|
||||
if (enable) {
|
||||
if (!cursorInMenuBar()) {
|
||||
showGlowBar();
|
||||
}
|
||||
m_mouseTracker->start(250);
|
||||
} else {
|
||||
hideGlowBar();
|
||||
m_mouseTracker->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void TopMenuBar::updateSize()
|
||||
{
|
||||
// Enable mouse tracking on resize if needed
|
||||
if (!m_mouseTracker->isActive() && !cursorInMenuBar()) {
|
||||
enableMouseTracking();
|
||||
}
|
||||
resize(sizeHint());
|
||||
}
|
||||
|
||||
void TopMenuBar::move(QPoint p)
|
||||
{
|
||||
MenuBar::move(p);
|
||||
if (m_glowBar) {
|
||||
m_glowBar->move(p);
|
||||
m_glowBar->setPixmap(triggerRect().topLeft(), triggerRect().width());
|
||||
}
|
||||
}
|
||||
|
||||
bool TopMenuBar::cursorInMenuBar()
|
||||
{
|
||||
if (m_mouseTracker->isActive()) {
|
||||
return triggerRect().contains(QCursor::pos());
|
||||
} else {
|
||||
return MenuBar::cursorInMenuBar();
|
||||
}
|
||||
}
|
||||
|
||||
void TopMenuBar::slotAboutToHide()
|
||||
{
|
||||
enableMouseTracking();
|
||||
}
|
||||
|
||||
void TopMenuBar::slotMouseTracker()
|
||||
{
|
||||
QPoint cursorPos = QCursor::pos();
|
||||
|
||||
// reset timer
|
||||
if (cursorPos != m_prevCursorPos && m_hideGlowTimer->isActive()) {
|
||||
m_hideGlowTimer->stop();
|
||||
m_hideGlowTimer->start(10000);
|
||||
}
|
||||
|
||||
if (cursorInMenuBar()) { // show menubar
|
||||
m_mouseTracker->stop();
|
||||
hideGlowBar();
|
||||
show();
|
||||
} else if(cursorPos != m_prevCursorPos) { // change glowbar opacity
|
||||
qreal opacity = glowBarOpacity();
|
||||
QPropertyAnimation *anim = new QPropertyAnimation(m_glowBar, "windowOpacity");
|
||||
anim->setStartValue(m_glowBar->windowOpacity());
|
||||
anim->setEndValue(opacity);
|
||||
anim->setDuration(200);
|
||||
anim->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
// Show menubar if auto hidden
|
||||
if (!m_glowBar->isVisible()) {
|
||||
m_glowBar->show();
|
||||
}
|
||||
}
|
||||
m_prevCursorPos = cursorPos;
|
||||
}
|
||||
|
||||
void TopMenuBar::slotHideGlowBar()
|
||||
{
|
||||
if (m_prevCursorPos == QCursor::pos()) {
|
||||
hideGlowBar();
|
||||
} else {
|
||||
m_hideGlowTimer->start(10000);
|
||||
}
|
||||
}
|
||||
|
||||
void TopMenuBar::showGlowBar()
|
||||
{
|
||||
if (m_glowBar) {
|
||||
m_hideGlowTimer->start(10000);
|
||||
m_glowBar->setWindowOpacity(glowBarOpacity());
|
||||
m_glowBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
void TopMenuBar::hideGlowBar()
|
||||
{
|
||||
if (m_glowBar) {
|
||||
m_glowBar->hide();
|
||||
}
|
||||
}
|
||||
|
||||
qreal TopMenuBar::glowBarOpacity()
|
||||
{
|
||||
QPoint cursorPos = QCursor::pos();
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
int screen = desktop->screenNumber(cursorPos);
|
||||
QRect desktopRect = desktop->availableGeometry(screen);
|
||||
return 1.0 - ((cursorPos.y() - desktopRect.y())/qreal(desktopRect.height())*2.0);
|
||||
}
|
||||
|
||||
QRect TopMenuBar::triggerRect()
|
||||
{
|
||||
QPoint triggerPoint = QPoint(x(), y());
|
||||
QSize triggerSize = QSize(sizeHint().width(), 5);
|
||||
return QRect(triggerPoint, triggerSize);
|
||||
}
|
||||
|
||||
#include "moc_topmenubar.cpp"
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef TOPMENUBAR__H
|
||||
#define TOPMENUBAR__H
|
||||
|
||||
#include "menubar.h"
|
||||
|
||||
#include <QTimer>
|
||||
class GlowBar;
|
||||
|
||||
class TopMenuBar : public MenuBar
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TopMenuBar();
|
||||
~TopMenuBar();
|
||||
|
||||
/**
|
||||
* Start mouse tracking (hide/show on mouse event)
|
||||
*/
|
||||
void enableMouseTracking(bool enable = true);
|
||||
|
||||
/**
|
||||
* Set menubar parent window id
|
||||
*/
|
||||
void setParentWid(WId id) { m_wid = id; }
|
||||
/**
|
||||
* Get menubar parent window id
|
||||
*/
|
||||
WId parentWid() { return m_wid; }
|
||||
/**
|
||||
* resize menu bar to feet content
|
||||
*/
|
||||
void updateSize();
|
||||
/**
|
||||
* Move menubar and glow bar at position
|
||||
*/
|
||||
void move(QPoint p);
|
||||
protected:
|
||||
bool cursorInMenuBar();
|
||||
private Q_SLOTS:
|
||||
void slotAboutToHide();
|
||||
void slotMouseTracker();
|
||||
void slotHideGlowBar();
|
||||
private:
|
||||
void showGlowBar();
|
||||
void hideGlowBar();
|
||||
qreal glowBarOpacity();
|
||||
QRect triggerRect();
|
||||
|
||||
WId m_wid;
|
||||
QPoint m_prevCursorPos;
|
||||
QTimer* m_mouseTracker;
|
||||
QTimer* m_hideGlowTimer;
|
||||
GlowBar* m_glowBar;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "verticalmenu.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QtGui/qevent.h>
|
||||
#include <QEvent>
|
||||
#include <QMenu>
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
VerticalMenu::VerticalMenu(QWidget* parent) : QMenu(parent)
|
||||
{
|
||||
}
|
||||
|
||||
VerticalMenu::~VerticalMenu()
|
||||
{
|
||||
}
|
||||
|
||||
QMenu *VerticalMenu::leafMenu()
|
||||
{
|
||||
QMenu *leaf = this;
|
||||
while (true) {
|
||||
QAction *act = leaf->activeAction();
|
||||
if (act && act->menu() && act->menu()->isVisible()) {
|
||||
leaf = act->menu();
|
||||
continue;
|
||||
}
|
||||
return leaf == this ? 0 : leaf;
|
||||
}
|
||||
return 0; // make gcc happy
|
||||
}
|
||||
|
||||
void VerticalMenu::paintEvent(QPaintEvent *pe)
|
||||
{
|
||||
QMenu::paintEvent(pe);
|
||||
if (QWidget::mouseGrabber() == this)
|
||||
return;
|
||||
if (QWidget::mouseGrabber())
|
||||
QWidget::mouseGrabber()->releaseMouse();
|
||||
grabMouse();
|
||||
grabKeyboard();
|
||||
}
|
||||
|
||||
#define FORWARD(_EVENT_, _TYPE_) \
|
||||
void VerticalMenu::_EVENT_##Event(Q##_TYPE_##Event *e) \
|
||||
{ \
|
||||
if (QMenu *leaf = leafMenu()) \
|
||||
QCoreApplication::sendEvent(leaf, e); \
|
||||
else \
|
||||
QMenu::_EVENT_##Event(e); \
|
||||
} \
|
||||
|
||||
FORWARD(keyPress, Key)
|
||||
FORWARD(keyRelease, Key)
|
||||
|
||||
#include "moc_verticalmenu.cpp"
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef VERTICALMENU_H
|
||||
#define VERTICALMENU_H
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
class VerticalMenu : public QMenu
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VerticalMenu(QWidget * parent = 0);
|
||||
~VerticalMenu();
|
||||
|
||||
/**
|
||||
* Set menu parent window id
|
||||
*/
|
||||
void setParentWid(WId id) { m_wid = id; }
|
||||
/**
|
||||
* Get menu parent window id
|
||||
*/
|
||||
WId parentWid() { return m_wid; }
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
void keyReleaseEvent(QKeyEvent*);
|
||||
void paintEvent(QPaintEvent*);
|
||||
private:
|
||||
QMenu *leafMenu();
|
||||
private:
|
||||
WId m_wid;
|
||||
};
|
||||
|
||||
#endif //VERTICALMENU_H
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="System"?>
|
||||
<ui version="4.0">
|
||||
<class>FineTuning</class>
|
||||
<widget class="QWidget" name="FineTuning">
|
||||
|
@ -7,23 +7,10 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>422</width>
|
||||
<height>358</height>
|
||||
<height>206</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Graphical effects:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboGraphicEffectsLevel"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
|
@ -37,25 +24,8 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Show icons on buttons:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>cbIconsOnButtons</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cbIconsOnButtons">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboGraphicEffectsLevel"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
|
@ -77,6 +47,26 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cbIconsOnButtons">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Show icons on buttons:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>cbIconsOnButtons</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
|
@ -173,66 +163,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="menubarBox">
|
||||
<property name="title">
|
||||
<string>Menubar</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout1">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelMenubarStyle">
|
||||
<property name="text">
|
||||
<string>Menubar style:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboMenubarStyle</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="KComboBox" name="comboMenubarStyle">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>In application</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Title bar button</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Top screen menubar</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Only export</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -245,6 +176,16 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Graphical effects:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
|
@ -259,7 +259,6 @@ KCMStyle::KCMStyle( QWidget* parent, const QVariantList& )
|
|||
connect(fineTuningUi.comboGraphicEffectsLevel, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
|
||||
connect(fineTuningUi.comboToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
|
||||
connect(fineTuningUi.comboSecondaryToolbarIcons, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
|
||||
connect(fineTuningUi.comboMenubarStyle, SIGNAL(activated(int)), this, SLOT(setEffectsDirty()));
|
||||
|
||||
// Page1
|
||||
cbStyle->setWhatsThis( i18n("Here you can choose from a list of"
|
||||
|
@ -284,10 +283,6 @@ KCMStyle::KCMStyle( QWidget* parent, const QVariantList& )
|
|||
fineTuningUi.comboGraphicEffectsLevel->setWhatsThis( i18n( "If you enable this option, KDE Applications will "
|
||||
"run internal animations.") );
|
||||
|
||||
if (!QFile::exists(QLibraryInfo::location(QLibraryInfo::PluginsPath) + "/menubar/libappmenu-qt.so")) {
|
||||
fineTuningUi.menubarBox->hide();
|
||||
}
|
||||
|
||||
// Insert the pages into the tabWidget
|
||||
tabWidget->addTab(page1, i18nc("@title:tab", "&Applications"));
|
||||
tabWidget->addTab(page2, i18nc("@title:tab", "&Fine Tuning"));
|
||||
|
@ -428,74 +423,8 @@ void KCMStyle::save()
|
|||
toolbarStyleGroup.writeEntry("ToolButtonStyleOtherToolbars",
|
||||
toolbarButtonText(fineTuningUi.comboSecondaryToolbarIcons->currentIndex()));
|
||||
|
||||
// menubar page
|
||||
KConfigGroup menuBarStyleGroup(&_config, "Appmenu Style");
|
||||
|
||||
// load kded module if needed
|
||||
bool load = false;
|
||||
QList<QVariant> args;
|
||||
|
||||
QString style = menuBarStyleText(fineTuningUi.comboMenubarStyle->currentIndex());
|
||||
|
||||
QString previous = menuBarStyleGroup.readEntry("Style", "InApplication");
|
||||
menuBarStyleGroup.writeEntry("Style", style);
|
||||
_config.sync();
|
||||
|
||||
QDBusMessage method = QDBusMessage::createMethodCall("org.kde.kded",
|
||||
"/modules/appmenu",
|
||||
"org.kde.kded",
|
||||
"reconfigure");
|
||||
QDBusConnection::sessionBus().asyncCall(method);
|
||||
|
||||
if (previous == "InApplication" && style != "InApplication") {
|
||||
load = true;
|
||||
KNotification *notification = new KNotification("reload", 0);
|
||||
notification->setComponentData(KComponentData("kcmstyle"));
|
||||
notification->setText(i18n("Settings changes will take effect only on application restart"));
|
||||
notification->sendEvent();
|
||||
}
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
// If user select ButtonVertical, we add (if needed) a button to titlebar
|
||||
if (style == "ButtonVertical") {
|
||||
KConfig _kwinConfig("kwinrc", KConfig::NoGlobals);
|
||||
KConfigGroup kwinConfig(&_kwinConfig, "Style");
|
||||
QString buttonsOnLeft = kwinConfig.readEntry("ButtonsOnLeft", KDecorationOptions::defaultTitleButtonsLeft());
|
||||
QString buttonsOnRight = kwinConfig.readEntry("ButtonsOnRight", KDecorationOptions::defaultTitleButtonsRight());
|
||||
qDebug() << buttonsOnLeft << buttonsOnRight;
|
||||
if (!buttonsOnLeft.contains("N") && !buttonsOnRight.contains("N")) {
|
||||
buttonsOnLeft = "N" + buttonsOnLeft;
|
||||
}
|
||||
kwinConfig.writeEntry("ButtonsOnLeft", buttonsOnLeft);
|
||||
kwinConfig.writeEntry("CustomButtonPositions", "true");
|
||||
}
|
||||
#endif
|
||||
|
||||
args = QList<QVariant>() << "appmenu" << (style != "InApplication");
|
||||
method = QDBusMessage::createMethodCall("org.kde.kded",
|
||||
"/kded",
|
||||
"org.kde.kded",
|
||||
"setModuleAutoloading");
|
||||
method.setArguments(args);
|
||||
QDBusConnection::sessionBus().asyncCall(method);
|
||||
|
||||
args = QList<QVariant>() << "appmenu";
|
||||
if (load) {
|
||||
method = QDBusMessage::createMethodCall("org.kde.kded",
|
||||
"/kded",
|
||||
"org.kde.kded",
|
||||
"loadModule");
|
||||
QDBusMessage method = QDBusMessage::createMethodCall("org.kde.kded", "/modules/appmenu", "org.kde.kded", "reconfigure");
|
||||
QDBusConnection::sessionBus().asyncCall(method);
|
||||
} else if (style == "InApplication") {
|
||||
method = QDBusMessage::createMethodCall("org.kde.kded",
|
||||
"/kded",
|
||||
"org.kde.kded",
|
||||
"unloadModule");
|
||||
}
|
||||
method.setArguments(args);
|
||||
QDBusConnection::sessionBus().asyncCall(method);
|
||||
|
||||
// Export the changes we made to qtrc, and update all qt-only
|
||||
// applications on the fly, ensuring that we still follow the user's
|
||||
// export fonts/colors settings.
|
||||
|
@ -581,7 +510,6 @@ void KCMStyle::defaults()
|
|||
// Effects
|
||||
fineTuningUi.comboToolbarIcons->setCurrentIndex(toolbarButtonIndex("TextBesideIcon"));
|
||||
fineTuningUi.comboSecondaryToolbarIcons->setCurrentIndex(toolbarButtonIndex("TextBesideIcon"));
|
||||
fineTuningUi.comboMenubarStyle->setCurrentIndex(menuBarStyleIndex("InApplication"));
|
||||
fineTuningUi.cbIconsOnButtons->setChecked(true);
|
||||
fineTuningUi.cbIconsInMenus->setChecked(true);
|
||||
fineTuningUi.comboGraphicEffectsLevel->setCurrentIndex(fineTuningUi.comboGraphicEffectsLevel->findData(((int) KGlobalSettings::graphicEffectsLevelDefault())));
|
||||
|
@ -803,33 +731,6 @@ int KCMStyle::toolbarButtonIndex(const QString &text)
|
|||
return 0;
|
||||
}
|
||||
|
||||
QString KCMStyle::menuBarStyleText(int index)
|
||||
{
|
||||
switch (index) {
|
||||
case 1:
|
||||
return "ButtonVertical";
|
||||
case 2:
|
||||
return "TopMenuBar";
|
||||
case 3:
|
||||
return "Others";
|
||||
}
|
||||
|
||||
return "InApplication";
|
||||
}
|
||||
|
||||
int KCMStyle::menuBarStyleIndex(const QString &text)
|
||||
{
|
||||
if (text == "ButtonVertical") {
|
||||
return 1;
|
||||
} else if (text == "TopMenuBar") {
|
||||
return 2;
|
||||
} else if (text == "Others") {
|
||||
return 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void KCMStyle::loadEffects( KConfig& config )
|
||||
{
|
||||
// KDE's Part via KConfig
|
||||
|
@ -840,10 +741,6 @@ void KCMStyle::loadEffects( KConfig& config )
|
|||
tbIcon = configGroup.readEntry("ToolButtonStyleOtherToolbars", "TextBesideIcon");
|
||||
fineTuningUi.comboSecondaryToolbarIcons->setCurrentIndex(toolbarButtonIndex(tbIcon));
|
||||
|
||||
configGroup = config.group("Appmenu Style");
|
||||
QString menuBarStyle = configGroup.readEntry("Style", "InApplication");
|
||||
fineTuningUi.comboMenubarStyle->setCurrentIndex(menuBarStyleIndex(menuBarStyle));
|
||||
|
||||
configGroup = config.group("KDE");
|
||||
fineTuningUi.cbIconsOnButtons->setChecked(configGroup.readEntry("ShowIconsOnPushButtons", true));
|
||||
fineTuningUi.cbIconsInMenus->setChecked(configGroup.readEntry("ShowIconsInMenuItems", true));
|
||||
|
|
|
@ -88,8 +88,6 @@ private:
|
|||
QString currentStyle();
|
||||
static QString toolbarButtonText(int index);
|
||||
static int toolbarButtonIndex(const QString &text);
|
||||
static QString menuBarStyleText(int index);
|
||||
static int menuBarStyleIndex(const QString &text);
|
||||
|
||||
bool m_bStyleDirty, m_bEffectsDirty;
|
||||
QHash <QString,StyleEntry*> styleEntries;
|
||||
|
|
|
@ -4,14 +4,8 @@ option(KWIN_BUILD_OXYGEN "Enable building of default decoration Oxygen" ON)
|
|||
option(KWIN_BUILD_KCMS "Enable building of KWin configuration modules." ON)
|
||||
option(KWIN_BUILD_TABBOX "Enable building of KWin Tabbox functionality" ON)
|
||||
option(KWIN_BUILD_SCREENEDGES "Enable building of KWin with screen edge support" ON)
|
||||
option(KWIN_BUILD_KAPPMENU "Enable building of KWin with application menu support" ON)
|
||||
option(KWIN_BUILD_COMPOSITE "Enable building of KWin with XRender Compositing support" ON)
|
||||
|
||||
# without dbusmenu-qt the functionality is useless
|
||||
if(NOT DBUSMENUQT_FOUND)
|
||||
set(KWIN_BUILD_KAPPMENU OFF)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${XCB_INCLUDE_DIR}
|
||||
# for kworkspace_export.h
|
||||
|
@ -145,13 +139,6 @@ if(KWIN_BUILD_SCREENEDGES)
|
|||
)
|
||||
endif()
|
||||
|
||||
if(KWIN_BUILD_KAPPMENU)
|
||||
set(kwin_SRCS
|
||||
${kwin_SRCS}
|
||||
appmenu.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
kde4_add_kcfg_files(kwin_SRCS settings.kcfgc)
|
||||
|
||||
qt4_add_dbus_adaptor(kwin_SRCS org.kde.KWin.xml dbusinterface.h KWin::DBusInterface)
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#include "appmenu.h"
|
||||
#include "client.h"
|
||||
#include "workspace.h"
|
||||
// Qt
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusPendingCall>
|
||||
|
||||
namespace KWin {
|
||||
|
||||
static const char *KDED_SERVICE = "org.kde.kded";
|
||||
static const char *KDED_APPMENU_PATH = "/modules/appmenu";
|
||||
static const char *KDED_INTERFACE = "org.kde.kded";
|
||||
|
||||
KWIN_SINGLETON_FACTORY(ApplicationMenu)
|
||||
|
||||
ApplicationMenu::ApplicationMenu(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
QDBusConnection dbus = QDBusConnection::sessionBus();
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "showRequest",
|
||||
this, SLOT(slotShowRequest(qulonglong)));
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "menuAvailable",
|
||||
this, SLOT(slotMenuAvailable(qulonglong)));
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "menuHidden",
|
||||
this, SLOT(slotMenuHidden(qulonglong)));
|
||||
dbus.connect(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "clearMenus",
|
||||
this, SLOT(slotClearMenus()));
|
||||
}
|
||||
|
||||
ApplicationMenu::~ApplicationMenu()
|
||||
{
|
||||
s_self = NULL;
|
||||
}
|
||||
|
||||
bool ApplicationMenu::hasMenu(xcb_window_t window)
|
||||
{
|
||||
return m_windowsMenu.removeOne(window);
|
||||
}
|
||||
|
||||
void ApplicationMenu::slotShowRequest(qulonglong wid)
|
||||
{
|
||||
if (Client *c = Workspace::self()->findClient(WindowMatchPredicate(wid)))
|
||||
c->emitShowRequest();
|
||||
}
|
||||
|
||||
void ApplicationMenu::slotMenuAvailable(qulonglong wid)
|
||||
{
|
||||
if (Client *c = Workspace::self()->findClient(WindowMatchPredicate(wid)))
|
||||
c->setAppMenuAvailable();
|
||||
else
|
||||
m_windowsMenu.append(wid);
|
||||
}
|
||||
|
||||
void ApplicationMenu::slotMenuHidden(qulonglong wid)
|
||||
{
|
||||
if (Client *c = Workspace::self()->findClient(WindowMatchPredicate(wid)))
|
||||
c->emitMenuHidden();
|
||||
}
|
||||
|
||||
void ApplicationMenu::slotClearMenus()
|
||||
{
|
||||
foreach (Client *c, Workspace::self()->clientList()) {
|
||||
c->setAppMenuUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationMenu::showApplicationMenu(const QPoint &p, const xcb_window_t id)
|
||||
{
|
||||
QList<QVariant> args = QList<QVariant>() << p.x() << p.y() << qulonglong(id);
|
||||
QDBusMessage method = QDBusMessage::createMethodCall(KDED_SERVICE, KDED_APPMENU_PATH, KDED_INTERFACE, "showMenu");
|
||||
method.setArguments(args);
|
||||
QDBusConnection::sessionBus().asyncCall(method);
|
||||
}
|
||||
|
||||
} // namespace
|
|
@ -1,60 +0,0 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (c) 2011 Lionel Chauvin <megabigbug@yahoo.fr>
|
||||
Copyright (c) 2011,2012 Cédric Bellegarde <gnumdk@gmail.com>
|
||||
Copyright (C) 2013 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
#ifndef KWIN_APPLICATIONMENU_H
|
||||
#define KWIN_APPLICATIONMENU_H
|
||||
// KWin
|
||||
#include <kwinglobals.h>
|
||||
// Qt
|
||||
#include <QObject>
|
||||
// xcb
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#include <QPoint>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
class ApplicationMenu : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~ApplicationMenu();
|
||||
|
||||
bool hasMenu(xcb_window_t window);
|
||||
void showApplicationMenu(const QPoint &pos, const xcb_window_t window);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotShowRequest(qulonglong wid);
|
||||
void slotMenuAvailable(qulonglong wid);
|
||||
void slotMenuHidden(qulonglong wid);
|
||||
void slotClearMenus();
|
||||
|
||||
private:
|
||||
QList<xcb_window_t> m_windowsMenu;
|
||||
|
||||
KWIN_SINGLETON(ApplicationMenu)
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // KWIN_APPLICATIONMENU_H
|
|
@ -115,22 +115,6 @@ void Bridge::showWindowMenu(const QRect &p)
|
|||
workspace()->showWindowMenu(p, c);
|
||||
}
|
||||
|
||||
void Bridge::showApplicationMenu(const QPoint &p)
|
||||
{
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
c->showApplicationMenu(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Bridge::menuAvailable() const
|
||||
{
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
return c->menuAvailable();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Bridge::performWindowOperation(WindowOperation op)
|
||||
{
|
||||
workspace()->performWindowOperation(c, op);
|
||||
|
|
|
@ -54,8 +54,6 @@ public:
|
|||
virtual void processMousePressEvent(QMouseEvent*);
|
||||
virtual void showWindowMenu(const QPoint &);
|
||||
virtual void showWindowMenu(const QRect &);
|
||||
virtual void showApplicationMenu(const QPoint &);
|
||||
virtual bool menuAvailable() const;
|
||||
virtual void performWindowOperation(WindowOperation);
|
||||
virtual void setMask(const QRegion&, int);
|
||||
virtual bool isPreview() const;
|
||||
|
|
|
@ -21,9 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// own
|
||||
#include "client.h"
|
||||
// kwin
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
#include "appmenu.h"
|
||||
#endif
|
||||
#include "atoms.h"
|
||||
#include "bridge.h"
|
||||
#include "client_machine.h"
|
||||
|
@ -126,9 +123,6 @@ Client::Client()
|
|||
, electricMaximizing(false)
|
||||
, needsSessionInteract(false)
|
||||
, needsXWindowMove(false)
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
, m_menuAvailable(false)
|
||||
#endif
|
||||
, m_decoInputExtent()
|
||||
{
|
||||
// TODO: Do all as initialization
|
||||
|
@ -448,12 +442,6 @@ void Client::createDecoration(const QRect& oldgeom)
|
|||
decoration, SLOT(maximizeChange()));
|
||||
connect(this, SIGNAL(keepAboveChanged(bool)), decoration, SIGNAL(keepAboveChanged(bool)));
|
||||
connect(this, SIGNAL(keepBelowChanged(bool)), decoration, SIGNAL(keepBelowChanged(bool)));
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
connect(this, SIGNAL(showRequest()), decoration, SIGNAL(showRequest()));
|
||||
connect(this, SIGNAL(appMenuAvailable()), decoration, SIGNAL(appMenuAvailable()));
|
||||
connect(this, SIGNAL(appMenuUnavailable()), decoration, SIGNAL(appMenuUnavailable()));
|
||||
connect(this, SIGNAL(menuHidden()), decoration, SIGNAL(menuHidden()));
|
||||
#endif
|
||||
// TODO: Check decoration's minimum size?
|
||||
decoration->init();
|
||||
decoration->widget()->installEventFilter(this);
|
||||
|
@ -2246,25 +2234,6 @@ bool Client::isClient() const
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
void Client::setAppMenuAvailable()
|
||||
{
|
||||
m_menuAvailable = true;
|
||||
emit appMenuAvailable();
|
||||
}
|
||||
|
||||
void Client::setAppMenuUnavailable()
|
||||
{
|
||||
m_menuAvailable = false;
|
||||
emit appMenuUnavailable();
|
||||
}
|
||||
|
||||
void Client::showApplicationMenu(const QPoint &p)
|
||||
{
|
||||
ApplicationMenu::self()->showApplicationMenu(p, window());
|
||||
}
|
||||
#endif
|
||||
|
||||
NET::WindowType Client::windowType(bool direct, int supportedTypes) const
|
||||
{
|
||||
// TODO: does it make sense to cache the returned window type for SUPPORTED_MANAGED_WINDOW_TYPES_MASK?
|
||||
|
|
|
@ -624,22 +624,6 @@ public:
|
|||
// a helper for the workspace window packing. tests for screen validity and updates since in maximization case as with normal moving
|
||||
void packTo(int left, int top);
|
||||
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
// Used by workspace
|
||||
void emitShowRequest() {
|
||||
emit showRequest();
|
||||
}
|
||||
void emitMenuHidden() {
|
||||
emit menuHidden();
|
||||
}
|
||||
void setAppMenuAvailable();
|
||||
void setAppMenuUnavailable();
|
||||
void showApplicationMenu(const QPoint&);
|
||||
bool menuAvailable() {
|
||||
return m_menuAvailable;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
void print(T &stream) const;
|
||||
|
||||
|
@ -734,23 +718,6 @@ signals:
|
|||
**/
|
||||
void tabGroupChanged();
|
||||
|
||||
/**
|
||||
* Emitted whenever the Client want to show it menu
|
||||
*/
|
||||
void showRequest();
|
||||
/**
|
||||
* Emitted whenever the Client's menu is closed
|
||||
*/
|
||||
void menuHidden();
|
||||
/**
|
||||
* Emitted whenever the Client's menu is available
|
||||
**/
|
||||
void appMenuAvailable();
|
||||
/**
|
||||
* Emitted whenever the Client's menu is unavailable
|
||||
*/
|
||||
void appMenuUnavailable();
|
||||
|
||||
/**
|
||||
* Emitted whenever the demands attention state changes.
|
||||
**/
|
||||
|
@ -977,9 +944,6 @@ private:
|
|||
bool needsSessionInteract;
|
||||
bool needsXWindowMove;
|
||||
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
bool m_menuAvailable;
|
||||
#endif
|
||||
Xcb::Window m_decoInputExtent;
|
||||
QPoint input_offset;
|
||||
};
|
||||
|
|
|
@ -38,13 +38,11 @@ install( FILES
|
|||
qml/Decoration.qml
|
||||
qml/DecorationButton.qml
|
||||
qml/MenuButton.qml
|
||||
qml/AppMenuButton.qml
|
||||
DESTINATION ${KDE4_DATA_INSTALL_DIR}/kwin/aurorae )
|
||||
install( FILES
|
||||
qml/Decoration.qml
|
||||
qml/DecorationButton.qml
|
||||
qml/MenuButton.qml
|
||||
qml/AppMenuButton.qml
|
||||
qml/ButtonGroup.qml
|
||||
qml/qmldir
|
||||
DESTINATION ${KDE4_IMPORTS_INSTALL_DIR}/org/kde/kwin/decoration )
|
||||
|
|
|
@ -198,7 +198,6 @@ bool AuroraeFactory::supports(Ability ability) const
|
|||
case AbilityButtonShade:
|
||||
case AbilityButtonOnAllDesktops:
|
||||
case AbilityButtonHelp:
|
||||
case AbilityButtonApplicationMenu:
|
||||
case AbilityProvidesShadow:
|
||||
return true; // TODO: correct value from theme
|
||||
case AbilityTabbing:
|
||||
|
@ -247,8 +246,6 @@ AuroraeClient::AuroraeClient(KDecorationBridge *bridge, KDecorationFactory *fact
|
|||
connect(AuroraeFactory::instance(), SIGNAL(configChanged()), SIGNAL(configChanged()));
|
||||
connect(AuroraeFactory::instance(), SIGNAL(titleFontChanged()), SIGNAL(fontChanged()));
|
||||
connect(m_item, SIGNAL(alphaChanged()), SLOT(slotAlphaChanged()));
|
||||
connect(this, SIGNAL(appMenuAvailable()), SIGNAL(appMenuAvailableChanged()));
|
||||
connect(this, SIGNAL(appMenuUnavailable()), SIGNAL(appMenuAvailableChanged()));
|
||||
}
|
||||
|
||||
AuroraeClient::~AuroraeClient()
|
||||
|
@ -450,11 +447,6 @@ void AuroraeClient::menuClicked()
|
|||
showWindowMenu(QCursor::pos());
|
||||
}
|
||||
|
||||
void AuroraeClient::appMenuClicked()
|
||||
{
|
||||
showApplicationMenu(QCursor::pos());
|
||||
}
|
||||
|
||||
void AuroraeClient::toggleShade()
|
||||
{
|
||||
setShade(!isShade());
|
||||
|
|
|
@ -106,7 +106,6 @@ class AuroraeClient : public KDecoration
|
|||
Q_PROPERTY(bool keepBelow READ keepBelow WRITE setKeepBelow NOTIFY keepBelowChangedWrapper)
|
||||
Q_PROPERTY(bool maximized READ isMaximized NOTIFY maximizeChanged)
|
||||
Q_PROPERTY(bool providesContextHelp READ providesContextHelp)
|
||||
Q_PROPERTY(bool appMenu READ menuAvailable NOTIFY appMenuAvailableChanged)
|
||||
Q_PROPERTY(QRect transparentRect READ transparentRect)
|
||||
Q_PROPERTY(int width READ width)
|
||||
Q_PROPERTY(qulonglong windowId READ windowId CONSTANT)
|
||||
|
@ -154,11 +153,9 @@ Q_SIGNALS:
|
|||
**/
|
||||
void configChanged();
|
||||
void fontChanged();
|
||||
void appMenuAvailableChanged();
|
||||
|
||||
public slots:
|
||||
void menuClicked();
|
||||
void appMenuClicked();
|
||||
void toggleShade();
|
||||
void toggleKeepAbove();
|
||||
void toggleKeepBelow();
|
||||
|
|
|
@ -167,8 +167,6 @@ QLatin1String AuroraeTheme::mapButtonToName(AuroraeButtonType type)
|
|||
return QLatin1String("help");
|
||||
case MenuButton:
|
||||
return QLatin1String("menu");
|
||||
case AppMenuButton:
|
||||
return QLatin1String("appmenu");
|
||||
default:
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
@ -365,7 +363,6 @@ THEME_CONFIG(buttonWidthKeepBelow)
|
|||
THEME_CONFIG(buttonWidthShade)
|
||||
THEME_CONFIG(buttonWidthHelp)
|
||||
THEME_CONFIG(buttonWidthMenu)
|
||||
THEME_CONFIG(buttonWidthAppMenu)
|
||||
THEME_CONFIG(buttonHeight)
|
||||
THEME_CONFIG(buttonSpacing)
|
||||
THEME_CONFIG(buttonMarginTop)
|
||||
|
|
|
@ -42,8 +42,7 @@ enum AuroraeButtonType {
|
|||
KeepBelowButton,
|
||||
ShadeButton,
|
||||
HelpButton,
|
||||
MenuButton,
|
||||
AppMenuButton
|
||||
MenuButton
|
||||
};
|
||||
|
||||
enum DecorationPosition {
|
||||
|
@ -80,7 +79,6 @@ class /*LIBAURORAE_EXPORT*/ AuroraeTheme : public QObject
|
|||
Q_PROPERTY(int buttonWidthShade READ buttonWidthShade NOTIFY themeChanged)
|
||||
Q_PROPERTY(int buttonWidthHelp READ buttonWidthHelp NOTIFY themeChanged)
|
||||
Q_PROPERTY(int buttonWidthMenu READ buttonWidthMenu NOTIFY themeChanged)
|
||||
Q_PROPERTY(int buttonWidthAppMenu READ buttonWidthAppMenu NOTIFY themeChanged)
|
||||
Q_PROPERTY(int buttonSpacing READ buttonSpacing NOTIFY themeChanged)
|
||||
Q_PROPERTY(int buttonMarginTop READ buttonMarginTop NOTIFY themeChanged)
|
||||
Q_PROPERTY(int explicitButtonSpacer READ explicitButtonSpacer NOTIFY themeChanged)
|
||||
|
@ -140,7 +138,6 @@ public:
|
|||
int buttonWidthShade() const;
|
||||
int buttonWidthHelp() const;
|
||||
int buttonWidthMenu() const;
|
||||
int buttonWidthAppMenu() const;
|
||||
int buttonHeight() const;
|
||||
int buttonSpacing() const;
|
||||
int buttonMarginTop() const;
|
||||
|
|
|
@ -67,7 +67,6 @@ ThemeConfig::ThemeConfig()
|
|||
, m_buttonWidthShade(defaultButtonWidthShade())
|
||||
, m_buttonWidthHelp(defaultButtonWidthHelp())
|
||||
, m_buttonWidthMenu(defaultButtonWidthMenu())
|
||||
, m_buttonWidthAppMenu(defaultButtonWidthAppMenu())
|
||||
, m_buttonHeight(defaultButtonHeight())
|
||||
, m_buttonSpacing(defaultButtonSpacing())
|
||||
, m_buttonMarginTop(defaultButtonMarginTop())
|
||||
|
@ -156,7 +155,6 @@ void ThemeConfig::load(const KConfig &conf)
|
|||
m_buttonWidthShade = border.readEntry("ButtonWidthShade", m_buttonWidth);
|
||||
m_buttonWidthHelp = border.readEntry("ButtonWidthHelp", m_buttonWidth);
|
||||
m_buttonWidthMenu = border.readEntry("ButtonWidthMenu", m_buttonWidth);
|
||||
m_buttonWidthAppMenu = border.readEntry("ButtonWidthAppMenu", m_buttonWidthMenu);
|
||||
m_buttonHeight = border.readEntry("ButtonHeight", defaultButtonHeight());
|
||||
m_buttonSpacing = border.readEntry("ButtonSpacing", defaultButtonSpacing());
|
||||
m_buttonMarginTop = border.readEntry("ButtonMarginTop", defaultButtonMarginTop());
|
||||
|
|
|
@ -145,9 +145,6 @@ public:
|
|||
int buttonWidthMenu() const {
|
||||
return m_buttonWidthMenu;
|
||||
}
|
||||
int buttonWidthAppMenu() const {
|
||||
return m_buttonWidthAppMenu;
|
||||
}
|
||||
int buttonHeight() const {
|
||||
return m_buttonHeight;
|
||||
}
|
||||
|
@ -311,9 +308,6 @@ public:
|
|||
static int defaultButtonWidthMenu() {
|
||||
return defaultButtonWidth();
|
||||
}
|
||||
static int defaultButtonWidthAppMenu() {
|
||||
return defaultButtonWidthMenu();
|
||||
}
|
||||
static int defaultButtonHeight() {
|
||||
return 20;
|
||||
}
|
||||
|
@ -395,7 +389,6 @@ private:
|
|||
int m_buttonWidthShade;
|
||||
int m_buttonWidthHelp;
|
||||
int m_buttonWidthMenu;
|
||||
int m_buttonWidthAppMenu;
|
||||
int m_buttonHeight;
|
||||
int m_buttonSpacing;
|
||||
int m_buttonMarginTop;
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
/********************************************************************
|
||||
Copyright (C) 2012 Martin Gräßlin <mgraesslin@kde.org>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
import QtQuick 1.1
|
||||
import org.kde.qtextracomponents 0.1 as QtExtra
|
||||
|
||||
DecorationButton {
|
||||
id: appMenuButton
|
||||
buttonType: "N"
|
||||
visible: decoration.appMenu
|
||||
QtExtra.QIconItem {
|
||||
icon: decoration.icon
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
|
@ -23,9 +23,6 @@ DecorationButton {
|
|||
case "M":
|
||||
// menu
|
||||
return auroraeTheme.buttonWidthMenu;
|
||||
case "N":
|
||||
// app menu
|
||||
return auroraeTheme.buttonWidthAppMenu;
|
||||
case "S":
|
||||
// all desktops
|
||||
return auroraeTheme.buttonWidthAllDesktops;
|
||||
|
|
|
@ -27,9 +27,6 @@ Item {
|
|||
} else if (buttons.charAt(i) == "M") {
|
||||
Qt.createQmlObject("import QtQuick 1.1; MenuButton { width: auroraeTheme.buttonWidthMenu * auroraeTheme.buttonSizeFactor; height: auroraeTheme.buttonHeight * auroraeTheme.buttonSizeFactor }",
|
||||
groupRow, "menuButton" + buttons + i);
|
||||
} else if (buttons.charAt(i) == "N") {
|
||||
Qt.createQmlObject("import QtQuick 1.1; AppMenuButton { width: auroraeTheme.buttonWidthAppMenu * auroraeTheme.buttonSizeFactor; height: auroraeTheme.buttonHeight * auroraeTheme.buttonSizeFactor }",
|
||||
groupRow, "appMenuButton" + buttons + i);
|
||||
} else if (buttons.charAt(i) == "A") {
|
||||
var maximizeComponent = Qt.createComponent("AuroraeMaximizeButton.qml");
|
||||
maximizeComponent.createObject(groupRow);
|
||||
|
|
|
@ -45,9 +45,6 @@ Item {
|
|||
case "M":
|
||||
component = group.menuButton;
|
||||
break;
|
||||
case "N":
|
||||
component = group.appMenuButton;
|
||||
break;
|
||||
case "S":
|
||||
component = group.allDesktopsButton;
|
||||
break;
|
||||
|
@ -73,7 +70,6 @@ Item {
|
|||
property variant keepBelowButton
|
||||
property variant maximizeButton
|
||||
property variant menuButton
|
||||
property variant appMenuButton
|
||||
property variant minimizeButton
|
||||
property variant allDesktopsButton
|
||||
property variant shadeButton
|
||||
|
|
|
@ -62,10 +62,6 @@ Item {
|
|||
// menu
|
||||
decoration.menuClicked();
|
||||
break;
|
||||
case "N":
|
||||
// app menu
|
||||
decoration.appMenuClicked();
|
||||
break;
|
||||
case "S":
|
||||
// all desktops
|
||||
decoration.toggleOnAllDesktops();
|
||||
|
|
|
@ -3,5 +3,4 @@ plugin decorationplugin
|
|||
Decoration 0.1 Decoration.qml
|
||||
DecorationButton 0.1 DecorationButton.qml
|
||||
MenuButton 0.1 MenuButton.qml
|
||||
AppMenuButton 0.1 AppMenuButton.qml
|
||||
ButtonGroup 0.1 ButtonGroup.qml
|
||||
|
|
|
@ -91,8 +91,6 @@ QPixmap PlastikButtonProvider::requestPixmap(const QString &id, QSize *size, con
|
|||
} else {
|
||||
button = ShadeIcon;
|
||||
}
|
||||
} else if (idParts[0] == "N") {
|
||||
button = AppMenuIcon;
|
||||
} else {
|
||||
// not recognized icon
|
||||
return QDeclarativeImageProvider::requestPixmap(id, size, requestedSize);
|
||||
|
@ -362,13 +360,6 @@ QPixmap PlastikButtonProvider::icon(ButtonIcon icon, int size, bool active, bool
|
|||
|
||||
break;
|
||||
}
|
||||
case AppMenuIcon:
|
||||
{
|
||||
drawObject(p, HorizontalLine, r.x(), r.top()+(lwTitleBar-1), r.width(), lwTitleBar);
|
||||
drawObject(p, HorizontalLine, r.x(), r.center().y(), r.width(), lwTitleBar);
|
||||
drawObject(p, HorizontalLine, r.x(), r.bottom()-(lwTitleBar-1), r.width(), lwTitleBar);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -44,7 +44,6 @@ private:
|
|||
NoKeepBelowIcon,
|
||||
ShadeIcon,
|
||||
UnShadeIcon,
|
||||
AppMenuIcon,
|
||||
NumButtonIcons
|
||||
};
|
||||
enum Object {
|
||||
|
|
|
@ -143,19 +143,11 @@ DecorationButton {
|
|||
if (buttonType == "H") {
|
||||
visible = decoration.providesContextHelp;
|
||||
}
|
||||
if (buttonType == "N") {
|
||||
visible = decoration.appMenu;
|
||||
}
|
||||
}
|
||||
onHoveredChanged: colorize()
|
||||
onPressedChanged: colorize()
|
||||
Connections {
|
||||
target: decoration
|
||||
onActiveChanged: button.colorize()
|
||||
onAppMenuChanged: {
|
||||
if (buttonType == "N") {
|
||||
visible = decoration.appMenu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,7 +254,6 @@ Decoration {
|
|||
spacing: 1
|
||||
explicitSpacer: root.buttonSize
|
||||
menuButton: menuButtonComponent
|
||||
appMenuButton: appMenuButtonComponent
|
||||
minimizeButton: minimizeButtonComponent
|
||||
maximizeButton: maximizeButtonComponent
|
||||
keepBelowButton: keepBelowButtonComponent
|
||||
|
@ -295,7 +294,6 @@ Decoration {
|
|||
spacing: 1
|
||||
explicitSpacer: root.buttonSize
|
||||
menuButton: menuButtonComponent
|
||||
appMenuButton: appMenuButtonComponent
|
||||
minimizeButton: minimizeButtonComponent
|
||||
maximizeButton: maximizeButtonComponent
|
||||
keepBelowButton: keepBelowButtonComponent
|
||||
|
@ -409,13 +407,6 @@ Decoration {
|
|||
height: root.buttonSize
|
||||
}
|
||||
}
|
||||
Component {
|
||||
id: appMenuButtonComponent
|
||||
PlastikButton {
|
||||
buttonType: "N"
|
||||
size: root.buttonSize
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
borders.setBorders(4);
|
||||
borders.setTitle(top.normalHeight);
|
||||
|
|
|
@ -205,11 +205,8 @@ namespace Oxygen
|
|||
//___________________________________________________
|
||||
void Button::mouseReleaseEvent( QMouseEvent* event )
|
||||
{
|
||||
if (_type != ButtonApplicationMenu)
|
||||
{
|
||||
_status &= ~Pressed;
|
||||
parentUpdate();
|
||||
}
|
||||
_status &= ~Pressed;
|
||||
parentUpdate();
|
||||
|
||||
KCommonDecorationButton::mouseReleaseEvent( event );
|
||||
}
|
||||
|
@ -307,68 +304,62 @@ namespace Oxygen
|
|||
{
|
||||
|
||||
case ButtonSticky:
|
||||
painter->drawPoint(QPointF(10.5,10.5));
|
||||
break;
|
||||
|
||||
case ButtonHelp:
|
||||
painter->translate(1.5, 1.5);
|
||||
painter->drawArc(7,5,4,4,135*16, -180*16);
|
||||
painter->drawArc(9,8,4,4,135*16,45*16);
|
||||
painter->drawPoint(9,12);
|
||||
painter->translate(-1.5, -1.5);
|
||||
break;
|
||||
|
||||
case ButtonApplicationMenu:
|
||||
painter->drawLine(QPointF(7.5, 7.5), QPointF(13.5, 7.5));
|
||||
painter->drawLine(QPointF(7.5, 10.5), QPointF(13.5, 10.5));
|
||||
painter->drawLine(QPointF(7.5, 13.5), QPointF(13.5, 13.5));
|
||||
break;
|
||||
|
||||
case ButtonMin:
|
||||
painter->drawLine(QPointF( 7.5, 9.5), QPointF(10.5,12.5));
|
||||
painter->drawLine(QPointF(10.5,12.5), QPointF(13.5, 9.5));
|
||||
break;
|
||||
|
||||
case ButtonMax:
|
||||
switch(_client.maximizeMode())
|
||||
{
|
||||
case Client::MaximizeRestore:
|
||||
case Client::MaximizeVertical:
|
||||
case Client::MaximizeHorizontal:
|
||||
painter->drawLine(QPointF( 7.5,11.5), QPointF(10.5, 8.5));
|
||||
painter->drawLine(QPointF(10.5, 8.5), QPointF(13.5,11.5));
|
||||
painter->drawPoint(QPointF(10.5,10.5));
|
||||
break;
|
||||
|
||||
case Client::MaximizeFull:
|
||||
case ButtonHelp:
|
||||
painter->translate(1.5, 1.5);
|
||||
painter->drawArc(7,5,4,4,135*16, -180*16);
|
||||
painter->drawArc(9,8,4,4,135*16,45*16);
|
||||
painter->drawPoint(9,12);
|
||||
painter->translate(-1.5, -1.5);
|
||||
break;
|
||||
|
||||
case ButtonMin:
|
||||
painter->drawLine(QPointF( 7.5, 9.5), QPointF(10.5,12.5));
|
||||
painter->drawLine(QPointF(10.5,12.5), QPointF(13.5, 9.5));
|
||||
break;
|
||||
|
||||
case ButtonMax:
|
||||
switch(_client.maximizeMode())
|
||||
{
|
||||
painter->translate(1.5, 1.5);
|
||||
QPoint points[4] = {QPoint(9, 6), QPoint(12, 9), QPoint(9, 12), QPoint(6, 9)};
|
||||
painter->drawPolygon(points, 4);
|
||||
painter->translate(-1.5, -1.5);
|
||||
break;
|
||||
case Client::MaximizeRestore:
|
||||
case Client::MaximizeVertical:
|
||||
case Client::MaximizeHorizontal:
|
||||
painter->drawLine(QPointF( 7.5,11.5), QPointF(10.5, 8.5));
|
||||
painter->drawLine(QPointF(10.5, 8.5), QPointF(13.5,11.5));
|
||||
break;
|
||||
|
||||
case Client::MaximizeFull:
|
||||
{
|
||||
painter->translate(1.5, 1.5);
|
||||
QPoint points[4] = {QPoint(9, 6), QPoint(12, 9), QPoint(9, 12), QPoint(6, 9)};
|
||||
painter->drawPolygon(points, 4);
|
||||
painter->translate(-1.5, -1.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ButtonItemClose:
|
||||
case ButtonClose:
|
||||
painter->drawLine(QPointF( 7.5,7.5), QPointF(13.5,13.5));
|
||||
painter->drawLine(QPointF(13.5,7.5), QPointF( 7.5,13.5));
|
||||
break;
|
||||
painter->drawLine(QPointF( 7.5,7.5), QPointF(13.5,13.5));
|
||||
painter->drawLine(QPointF(13.5,7.5), QPointF( 7.5,13.5));
|
||||
break;
|
||||
|
||||
case ButtonAbove:
|
||||
painter->drawLine(QPointF( 7.5,14), QPointF(10.5,11));
|
||||
painter->drawLine(QPointF(10.5,11), QPointF(13.5,14));
|
||||
painter->drawLine(QPointF( 7.5,10), QPointF(10.5, 7));
|
||||
painter->drawLine(QPointF(10.5, 7), QPointF(13.5,10));
|
||||
break;
|
||||
painter->drawLine(QPointF( 7.5,14), QPointF(10.5,11));
|
||||
painter->drawLine(QPointF(10.5,11), QPointF(13.5,14));
|
||||
painter->drawLine(QPointF( 7.5,10), QPointF(10.5, 7));
|
||||
painter->drawLine(QPointF(10.5, 7), QPointF(13.5,10));
|
||||
break;
|
||||
|
||||
case ButtonBelow:
|
||||
painter->drawLine(QPointF( 7.5,11), QPointF(10.5,14));
|
||||
painter->drawLine(QPointF(10.5,14), QPointF(13.5,11));
|
||||
painter->drawLine(QPointF( 7.5, 7), QPointF(10.5,10));
|
||||
painter->drawLine(QPointF(10.5,10), QPointF(13.5, 7));
|
||||
break;
|
||||
painter->drawLine(QPointF( 7.5,11), QPointF(10.5,14));
|
||||
painter->drawLine(QPointF(10.5,14), QPointF(13.5,11));
|
||||
painter->drawLine(QPointF( 7.5, 7), QPointF(10.5,10));
|
||||
painter->drawLine(QPointF(10.5,10), QPointF(13.5, 7));
|
||||
break;
|
||||
|
||||
case ButtonShade:
|
||||
if (!isChecked())
|
||||
|
@ -396,10 +387,4 @@ namespace Oxygen
|
|||
return;
|
||||
}
|
||||
|
||||
void Button::slotAppMenuHidden()
|
||||
{
|
||||
_status = Normal;
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -160,9 +160,6 @@ namespace Oxygen
|
|||
|
||||
//@}
|
||||
|
||||
private slots:
|
||||
void slotAppMenuHidden();
|
||||
|
||||
private:
|
||||
|
||||
//! parent client
|
||||
|
|
|
@ -187,9 +187,6 @@ namespace Oxygen
|
|||
case MenuButton:
|
||||
return new Button(*this, i18n("Window Actions Menu"), ButtonMenu);
|
||||
|
||||
case AppMenuButton:
|
||||
return new Button(*this, i18n("Application Menu"), ButtonApplicationMenu);
|
||||
|
||||
case HelpButton:
|
||||
return new Button(*this, i18n("Help"), ButtonHelp);
|
||||
|
||||
|
|
|
@ -49,7 +49,6 @@ namespace Oxygen
|
|||
ButtonAbove,
|
||||
ButtonBelow,
|
||||
ButtonShade,
|
||||
ButtonApplicationMenu,
|
||||
ButtonTypeCount,
|
||||
|
||||
// Close only one tab
|
||||
|
|
|
@ -117,7 +117,6 @@ namespace Oxygen
|
|||
{
|
||||
// buttons
|
||||
case AbilityButtonMenu:
|
||||
case AbilityButtonApplicationMenu:
|
||||
case AbilityButtonHelp:
|
||||
case AbilityButtonMinimize:
|
||||
case AbilityButtonMaximize:
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#cmakedefine KWIN_BUILD_TABBOX 1
|
||||
#cmakedefine KWIN_BUILD_SCREENEDGES 1
|
||||
#cmakedefine KWIN_BUILD_KAPPMENU 1
|
||||
#cmakedefine KWIN_BUILD_OXYGEN 1
|
||||
#cmakedefine KWIN_BUILD_COMPOSITE 1
|
||||
#define KWIN_VERSION_STRING "${KDE_VERSION_STRING}"
|
||||
|
|
|
@ -43,11 +43,6 @@
|
|||
#include <KLocalizedString>
|
||||
#include <kglobalsettings.h>
|
||||
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
#include <KConfigGroup>
|
||||
#include <KConfig>
|
||||
#endif
|
||||
|
||||
#include <kdecorationfactory.h>
|
||||
|
||||
|
||||
|
@ -688,16 +683,6 @@ ButtonPositionWidget::ButtonPositionWidget(QWidget *parent)
|
|||
bool dummy;
|
||||
|
||||
m_supportedButtons = "MSHIAX_FBLR";
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
KConfig config("kdeglobals", KConfig::FullConfig);
|
||||
KConfigGroup configGroup = config.group("Appmenu Style");
|
||||
QString style = configGroup.readEntry("Style", "InApplication");
|
||||
|
||||
if (style == "ButtonVertical") {
|
||||
m_supportedButtons = "MNSHIAX_FBLR"; // support all buttons
|
||||
new ButtonSourceItem(m_buttonSource, getButton('N', dummy));
|
||||
}
|
||||
#endif
|
||||
|
||||
new ButtonSourceItem(m_buttonSource, getButton('R', dummy));
|
||||
new ButtonSourceItem(m_buttonSource, getButton('L', dummy));
|
||||
|
@ -760,12 +745,6 @@ Button ButtonPositionWidget::getButton(QChar type, bool& success)
|
|||
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
|
||||
bmp.createMaskFromColor(Qt::white);
|
||||
return Button(i18nc("Button showing window actions menu", "Window Menu"), bmp, 'M', false, m_supportedButtons.contains('M'));
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
} else if (type == 'N') {
|
||||
QBitmap bmp = QBitmap::fromData(QSize(menu_width, menu_height), menu_bits);
|
||||
bmp.createMaskFromColor(Qt::white);
|
||||
return Button(i18nc("Button showing application menu imported from dbusmenu", "Application Menu"), bmp, 'N', false, m_supportedButtons.contains('N'));
|
||||
#endif
|
||||
} else if (type == '_') {
|
||||
QBitmap bmp = QBitmap::fromData(QSize(spacer_width, spacer_height), spacer_bits);
|
||||
bmp.createMaskFromColor(Qt::white);
|
||||
|
|
|
@ -299,15 +299,6 @@ void KDecorationPreviewBridge::showWindowMenu(const QPoint &)
|
|||
{
|
||||
}
|
||||
|
||||
void KDecorationPreviewBridge::showApplicationMenu(const QPoint &)
|
||||
{
|
||||
}
|
||||
|
||||
bool KDecorationPreviewBridge::menuAvailable() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void KDecorationPreviewBridge::performWindowOperation(WindowOperation)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -86,8 +86,6 @@ public:
|
|||
virtual void processMousePressEvent(QMouseEvent*);
|
||||
virtual void showWindowMenu(const QRect &);
|
||||
virtual void showWindowMenu(const QPoint &);
|
||||
virtual void showApplicationMenu(const QPoint &);
|
||||
virtual bool menuAvailable() const;
|
||||
virtual void performWindowOperation(WindowOperation);
|
||||
virtual void setMask(const QRegion&, int);
|
||||
virtual bool isPreview() const;
|
||||
|
|
|
@ -41,7 +41,6 @@ Item {
|
|||
property bool keepBelow: false
|
||||
property bool maximized: false
|
||||
property bool providesContextHelp: true
|
||||
property bool appMenu: true
|
||||
property string leftButtons: "MS"
|
||||
property string rightButtons: "HIA__X"
|
||||
function titleMouseMoved() {}
|
||||
|
|
|
@ -393,27 +393,6 @@ void KCommonDecoration::addButtons(ButtonContainer &btnContainer, const QString&
|
|||
m_button[MenuButton] = btn;
|
||||
}
|
||||
break;
|
||||
case 'N': // Application Menu button
|
||||
if (!m_button[AppMenuButton]) {
|
||||
btn = createButton(AppMenuButton);
|
||||
if (!btn) break;
|
||||
btn->setTipText(i18nc("Button showing application menu", "Application Menu"));
|
||||
btn->setRealizeButtons(Qt::LeftButton);
|
||||
connect(btn, SIGNAL(clicked()), SLOT(appMenuButtonPressed()), Qt::QueuedConnection);
|
||||
// Application want to show it menu
|
||||
connect(decoration(), SIGNAL(showRequest()), this, SLOT(appMenuButtonPressed()), Qt::UniqueConnection);
|
||||
// Wait for menu to become available before displaying any button
|
||||
connect(decoration(), SIGNAL(appMenuAvailable()), this, SLOT(slotAppMenuAvailable()), Qt::UniqueConnection);
|
||||
// On Kded module shutdown, hide application menu button
|
||||
connect(decoration(), SIGNAL(appMenuUnavailable()), this, SLOT(slotAppMenuUnavailable()), Qt::UniqueConnection);
|
||||
// Application menu button may need to be modified on this signal
|
||||
connect(decoration(), SIGNAL(menuHidden()), btn, SLOT(slotAppMenuHidden()), Qt::UniqueConnection);
|
||||
|
||||
// fix double deletion, see objDestroyed()
|
||||
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
|
||||
m_button[AppMenuButton] = btn;
|
||||
}
|
||||
break;
|
||||
case 'S': // OnAllDesktops button
|
||||
if (!m_button[OnAllDesktopsButton]) {
|
||||
btn = createButton(OnAllDesktopsButton);
|
||||
|
@ -542,12 +521,7 @@ void KCommonDecoration::addButtons(ButtonContainer &btnContainer, const QString&
|
|||
if (btn) {
|
||||
btn->setLeft(isLeft);
|
||||
btn->setSize(QSize(layoutMetric(LM_ButtonWidth, true, btn), layoutMetric(LM_ButtonHeight, true, btn)));
|
||||
// will be shown later on window registration
|
||||
if (btn->type() == AppMenuButton && !isPreview() && !wrapper->menuAvailable()) {
|
||||
btn->hide();
|
||||
} else {
|
||||
btn->show();
|
||||
}
|
||||
btn->show();
|
||||
|
||||
btnContainer.append(btn);
|
||||
}
|
||||
|
@ -564,7 +538,7 @@ void KCommonDecoration::calcHiddenButtons()
|
|||
btnHideLastWidth = width();
|
||||
|
||||
//Hide buttons in the following order:
|
||||
KCommonDecorationButton* btnArray[] = { m_button[HelpButton], m_button[AppMenuButton], m_button[ShadeButton], m_button[BelowButton],
|
||||
KCommonDecorationButton* btnArray[] = { m_button[HelpButton], m_button[ShadeButton], m_button[BelowButton],
|
||||
m_button[AboveButton], m_button[OnAllDesktopsButton], m_button[MaxButton],
|
||||
m_button[MinButton], m_button[MenuButton], m_button[CloseButton]
|
||||
};
|
||||
|
@ -589,8 +563,7 @@ void KCommonDecoration::calcHiddenButtons()
|
|||
if (! btnArray[i]->isHidden())
|
||||
break; // all buttons shown...
|
||||
|
||||
if (btnArray[i]->type() != AppMenuButton || wrapper->menuAvailable())
|
||||
btnArray[i]->show();
|
||||
btnArray[i]->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -788,34 +761,6 @@ void KCommonDecoration::doShowWindowMenu()
|
|||
showWindowMenu(QRect(menutop, menubottom));
|
||||
}
|
||||
|
||||
|
||||
void KCommonDecoration::appMenuButtonPressed()
|
||||
{
|
||||
QRect menuRect = m_button[AppMenuButton]->rect();
|
||||
wrapper->showApplicationMenu(m_button[AppMenuButton]->mapToGlobal(menuRect.bottomLeft()));
|
||||
|
||||
KDecorationFactory* f = factory();
|
||||
if (!f->exists(decoration())) // 'this' was deleted
|
||||
return;
|
||||
m_button[AppMenuButton]->setDown(false);
|
||||
}
|
||||
|
||||
void KCommonDecoration::slotAppMenuAvailable()
|
||||
{
|
||||
if (m_button[AppMenuButton]) {
|
||||
m_button[AppMenuButton]->show();
|
||||
updateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void KCommonDecoration::slotAppMenuUnavailable()
|
||||
{
|
||||
if (m_button[AppMenuButton]) {
|
||||
m_button[AppMenuButton]->hide();
|
||||
updateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
void KCommonDecoration::resizeEvent(QResizeEvent */*e*/)
|
||||
{
|
||||
if (decorationBehaviour(DB_ButtonHide))
|
||||
|
|
|
@ -46,7 +46,6 @@ enum ButtonType {
|
|||
AboveButton,
|
||||
BelowButton,
|
||||
ShadeButton,
|
||||
AppMenuButton,
|
||||
NumButtons,
|
||||
ItemCloseButton = 100, // Close only one tab
|
||||
ItemMenuButton // shows the window menu for one tab
|
||||
|
@ -270,9 +269,7 @@ public Q_SLOTS:
|
|||
void slotKeepBelow();
|
||||
void menuButtonPressed();
|
||||
void menuButtonReleased();
|
||||
void appMenuButtonPressed();
|
||||
void slotAppMenuAvailable();
|
||||
void slotAppMenuUnavailable();
|
||||
|
||||
public:
|
||||
virtual Position mousePosition(const QPoint &point) const;
|
||||
|
||||
|
|
|
@ -227,16 +227,6 @@ void KDecoration::showWindowMenu(QPoint pos)
|
|||
bridge_->showWindowMenu(pos);
|
||||
}
|
||||
|
||||
void KDecoration::showApplicationMenu(const QPoint &p)
|
||||
{
|
||||
bridge_->showApplicationMenu(p);
|
||||
}
|
||||
|
||||
bool KDecoration::menuAvailable() const
|
||||
{
|
||||
return bridge_->menuAvailable();
|
||||
}
|
||||
|
||||
void KDecoration::performWindowOperation(WindowOperation op)
|
||||
{
|
||||
bridge_->performWindowOperation(op);
|
||||
|
|
|
@ -204,22 +204,21 @@ public:
|
|||
AbilityButtonBelowOthers = 8, ///< decoration supports a below button
|
||||
AbilityButtonShade = 9, ///< decoration supports a shade button
|
||||
AbilityButtonResize = 10, ///< decoration supports a resize button
|
||||
AbilityButtonApplicationMenu = 11, ///< decoration supports the application menu button
|
||||
// compositing
|
||||
AbilityProvidesShadow = 12, ///< The decoration draws its own shadows.
|
||||
AbilityProvidesShadow = 11, ///< The decoration draws its own shadows.
|
||||
/// @since 4.3
|
||||
AbilityUsesAlphaChannel = 13, ///< The decoration isn't clipped to the mask when compositing is enabled.
|
||||
AbilityUsesAlphaChannel = 12, ///< The decoration isn't clipped to the mask when compositing is enabled.
|
||||
/// The mask is still used to define the input region and the blurred
|
||||
/// region, when the blur plugin is enabled.
|
||||
/// @since 4.3
|
||||
AbilityExtendIntoClientArea = 14, ///< The decoration respects transparentRect()
|
||||
AbilityExtendIntoClientArea = 13, ///< The decoration respects transparentRect()
|
||||
/// @since 4.4
|
||||
AbilityUsesBlurBehind = 15, ///< The decoration wants the background to be blurred, when the blur plugin is enabled.
|
||||
AbilityUsesBlurBehind = 14, ///< The decoration wants the background to be blurred, when the blur plugin is enabled.
|
||||
/// @since 4.6
|
||||
AbilityAnnounceAlphaChannel = 16, ///< The decoration can tell whether it currently uses an alpha channel or not. Requires AbilityUsesAlphaChannel.
|
||||
AbilityAnnounceAlphaChannel = 15, ///< The decoration can tell whether it currently uses an alpha channel or not. Requires AbilityUsesAlphaChannel.
|
||||
/// @since 4.10
|
||||
// Tabbing
|
||||
AbilityTabbing = 17, ///< The decoration supports tabbing
|
||||
AbilityTabbing = 16, ///< The decoration supports tabbing
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -309,7 +308,6 @@ public:
|
|||
* If customButtonPositions() returns true, titleButtonsLeft
|
||||
* returns which buttons should be on the left side of the titlebar from left
|
||||
* to right. Characters in the returned string have this meaning :
|
||||
* @li 'N' application menu button
|
||||
* @li 'M' window menu button
|
||||
* @li 'S' on_all_desktops button
|
||||
* @li 'H' quickhelp button
|
||||
|
@ -578,14 +576,6 @@ public:
|
|||
* Overloaded version of the above.
|
||||
*/
|
||||
void showWindowMenu(QPoint pos);
|
||||
/**
|
||||
* show application menu at p
|
||||
*/
|
||||
void showApplicationMenu(const QPoint& p);
|
||||
/**
|
||||
* Returns @a true if menu available for client
|
||||
*/
|
||||
bool menuAvailable() const;
|
||||
/**
|
||||
* This function performs the given window operation. This function may destroy
|
||||
* the current decoration object, just like showWindowMenu().
|
||||
|
@ -855,24 +845,6 @@ Q_SIGNALS:
|
|||
*/
|
||||
void keepBelowChanged(bool);
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever application menu is closed
|
||||
* Application menu button may need to be modified on this signal
|
||||
*/
|
||||
void menuHidden();
|
||||
/**
|
||||
* This signal is emitted whenever application want to show it menu
|
||||
*/
|
||||
void showRequest();
|
||||
/**
|
||||
* This signal is emitted whenever application menu becomes available
|
||||
*/
|
||||
void appMenuAvailable();
|
||||
/**
|
||||
* This signal is emitted whenever application menu becomes unavailable
|
||||
*/
|
||||
void appMenuUnavailable();
|
||||
|
||||
/**
|
||||
* This signal is emitted whenever the decoration changes it's alpha enabled
|
||||
* change. Only relevant in case the decoration provides AbilityAnnounceAlphaChannel.
|
||||
|
|
|
@ -60,8 +60,6 @@ public:
|
|||
virtual void processMousePressEvent(QMouseEvent*) = 0;
|
||||
virtual void showWindowMenu(const QRect &) = 0;
|
||||
virtual void showWindowMenu(const QPoint &) = 0;
|
||||
virtual void showApplicationMenu(const QPoint&) = 0;
|
||||
virtual bool menuAvailable() const = 0;
|
||||
virtual void performWindowOperation(WindowOperation) = 0;
|
||||
virtual void setMask(const QRegion&, int) = 0;
|
||||
virtual bool isPreview() const = 0;
|
||||
|
|
|
@ -23,9 +23,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// kwin libs
|
||||
#include <kdecorationfactory.h>
|
||||
// kwin
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
#include "appmenu.h"
|
||||
#endif
|
||||
#include "atoms.h"
|
||||
#include "client.h"
|
||||
#include "composite.h"
|
||||
|
@ -134,10 +131,6 @@ Workspace::Workspace(bool restore)
|
|||
// If KWin was already running it saved its configuration after loosing the selection -> Reread
|
||||
QFuture<void> reparseConfigFuture = QtConcurrent::run(options, &Options::reparseConfiguration);
|
||||
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
ApplicationMenu::create(this);
|
||||
#endif
|
||||
|
||||
_self = this;
|
||||
|
||||
// first initialize the extensions
|
||||
|
@ -518,10 +511,6 @@ void Workspace::addClient(Client* c)
|
|||
if (TabBox::TabBox::self()->isDisplayed())
|
||||
TabBox::TabBox::self()->reset(true);
|
||||
#endif
|
||||
#ifdef KWIN_BUILD_KAPPMENU
|
||||
if (ApplicationMenu::self()->hasMenu(c->window()))
|
||||
c->setAppMenuAvailable();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Workspace::addUnmanaged(Unmanaged* c)
|
||||
|
|
Loading…
Add table
Reference in a new issue