Last active
August 29, 2015 13:58
-
-
Save danirod/10004530 to your computer and use it in GitHub Desktop.
Modificación hecha a appnameapplet.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a modification done to unity-2d v5.14.0 | |
* This source code is based on unity-2d. | |
* File: panel/applets/appname/appnameapplet.cpp | |
* | |
* Copyright 2010 Canonical Ltd. | |
* | |
* Authors: | |
* - Aurélien Gâteau <[email protected]> | |
* | |
* 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; version 3. | |
* | |
* 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/>. | |
*/ | |
void AppNameApplet::updateWidgets() | |
{ | |
BamfApplication* app = BamfMatcher::get_default().active_application(); | |
bool isMaximized = d->m_windowHelper->isMaximized(); | |
bool isUserVisibleApp = app ? app->user_visible() : false; | |
bool isOnSameScreen = d->m_windowHelper->isMostlyOnScreen(panel()->screen()); | |
bool isUnderMouse = rect().contains(mapFromGlobal(QCursor::pos())); | |
bool isOpened = isOnSameScreen && | |
(isUnderMouse | |
|| KeyMonitor::instance()->keyboardModifiers() == Qt::AltModifier | |
|| d->m_menuBarWidget->isOpened() | |
); | |
bool showDesktopLabel = !app; | |
bool showMenu = isOpened && !d->m_menuBarWidget->isEmpty() && (isUserVisibleApp || showDesktopLabel); | |
bool dashCanResize = !DashClient::instance()->alwaysFullScreen(); | |
bool dashIsVisible = DashClient::instance()->activeInScreen(panel()->screen()); | |
bool hudIsVisible = HUDClient::instance()->activeInScreen(panel()->screen()); | |
bool showWindowButtons = (isOpened && isMaximized) || dashIsVisible || hudIsVisible; | |
bool showAppLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen; | |
d->m_windowButtonWidget->setVisible(showWindowButtons); | |
d->m_windowButtonWidget->setEnabled(showWindowButtons); | |
d->m_maximizeButton->setIsDashButton(dashIsVisible); | |
d->m_maximizeButton->setButtonType(isMaximized ? | |
PanelStyle::UnmaximizeWindowButton : | |
PanelStyle::MaximizeWindowButton); | |
/* disable the minimize button for the dash & hud */ | |
d->m_minimizeButton->setEnabled(!dashIsVisible || !hudIsVisible); | |
d->m_minimizeButton->setIsDashButton(dashIsVisible || hudIsVisible); | |
/* disable the maximize button for the HUD, and when the dash is not resizeable */ | |
d->m_maximizeButton->setEnabled((dashIsVisible && dashCanResize) || !hudIsVisible); | |
d->m_maximizeButton->setIsDashButton(dashIsVisible || hudIsVisible); | |
/* make sure we use the right button for dash */ | |
d->m_closeButton->setIsDashButton(dashIsVisible || hudIsVisible); | |
if (showAppLabel || showDesktopLabel || dashIsVisible || hudIsVisible) { | |
d->m_label->setVisible(true); | |
if (showAppLabel) { | |
// Define text | |
QString text; | |
if (app) { | |
/* if (isMaximized) { | |
// When maximized, show window title | |
BamfWindow* bamfWindow = BamfMatcher::get_default().active_window(); | |
if (bamfWindow) { | |
text = bamfWindow->name(); | |
} | |
} else { | |
// When not maximized, show application name | |
text = app->name(); | |
} | |
*/ text = app->name(); | |
} | |
d->m_label->setText(text); | |
} else if (showDesktopLabel) { | |
d->m_label->setText(u2dTr("Ubuntu Desktop")); | |
} else { | |
d->m_label->setText(QString()); | |
} | |
// Define label width | |
/* if (!isMaximized && showMenu) { | |
// d->m_label->setMaximumWidth(LauncherClient::MaximumWidth); | |
} else { | |
d->m_label->setMaximumWidth(QWIDGETSIZE_MAX); | |
} | |
*/ QFontMetrics fm(d->m_label->font()); | |
int labelWidth = fm.width(d->m_label->text()) + 20; | |
if (labelWidth < LauncherClient::MaximumWidth) | |
labelWidth = LauncherClient::MaximumWidth; | |
d->m_label->setMaximumWidth(labelWidth); | |
} else { | |
// d->m_label->setVisible(false); | |
QFontMetrics fm(d->m_label->font()); | |
int labelWidth = fm.width(d->m_label->text()) + 20; | |
labelWidth -= LauncherClient::MaximumWidth; | |
d->m_label->setMaximumWidth(labelWidth); | |
} | |
// d->m_menuBarWidget->setVisible(showMenu); | |
d->m_menuBarWidget->setVisible(true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment