61
62
WindowButton(const PanelStyle::WindowButtonType& buttonType, QWidget* parent = 0)
62
63
: QAbstractButton(parent)
63
, m_buttonType(buttonType)
64
, m_initialized(false)
66
setButtonType(buttonType);
66
67
if (buttonType == PanelStyle::MinimizeWindowButton) {
67
68
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
69
70
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
71
72
setAttribute(Qt::WA_Hover);
76
void setButtonType(const PanelStyle::WindowButtonType& buttonType)
78
if (m_initialized && m_buttonType == buttonType) return;
80
m_buttonType = buttonType;
74
85
QSize minimumSizeHint() const
169
185
m_windowButtonWidget->setFixedWidth(LauncherClient::MaximumWidth);
170
186
QObject::connect(m_closeButton, SIGNAL(clicked()), m_windowHelper, SLOT(close()));
171
187
QObject::connect(m_minimizeButton, SIGNAL(clicked()), m_windowHelper, SLOT(minimize()));
172
QObject::connect(m_maximizeButton, SIGNAL(clicked()), m_windowHelper, SLOT(unmaximize()));
188
QObject::connect(m_maximizeButton, SIGNAL(clicked()), m_windowHelper, SLOT(toggleMaximize()));
175
191
void setupWindowHelper()
243
259
|| d->m_menuBarWidget->isOpened()
245
261
bool showMenu = isOpened && !d->m_menuBarWidget->isEmpty() && isUserVisibleApp;
246
bool showWindowButtons = isOpened && isMaximized;
247
bool showLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen;
262
bool dashCanResize = d->m_windowHelper->dashCanResize();
263
bool dashIsVisible = d->m_windowHelper->dashIsVisible();
264
bool showWindowButtons = (isOpened && isMaximized) || dashIsVisible;
265
bool showAppLabel = !(isMaximized && showMenu) && isUserVisibleApp && isOnSameScreen;
266
bool showDesktopLabel = !app;
249
268
d->m_windowButtonWidget->setVisible(showWindowButtons);
269
d->m_maximizeButton->setButtonType(isMaximized ?
270
PanelStyle::UnmaximizeWindowButton :
271
PanelStyle::MaximizeWindowButton);
272
/* disable the minimize button for the dash */
273
d->m_minimizeButton->setEnabled(!dashIsVisible);
274
/* and the maximize button, if the dash is not resizeable */
275
d->m_maximizeButton->setEnabled(!dashIsVisible || dashCanResize);
251
d->m_label->setVisible(showLabel);
257
// When maximized, show window title
258
BamfWindow* bamfWindow = BamfMatcher::get_default().active_window();
260
text = bamfWindow->name();
277
if (showAppLabel || showDesktopLabel || dashIsVisible) {
278
d->m_label->setVisible(true);
284
// When maximized, show window title
285
BamfWindow* bamfWindow = BamfMatcher::get_default().active_window();
287
text = bamfWindow->name();
290
// When not maximized, show application name
263
// When not maximized, show application name
294
d->m_label->setText(text);
295
} else if (showDesktopLabel) {
296
d->m_label->setText(u2dTr("Ubuntu Desktop"));
298
d->m_label->setText("");
267
d->m_label->setText(text);
301
// Define label width
270
302
if (!isMaximized && showMenu) {
271
303
d->m_label->setMaximumWidth(LauncherClient::MaximumWidth);
273
305
d->m_label->setMaximumWidth(QWIDGETSIZE_MAX);
308
d->m_label->setVisible(false);
277
311
d->m_menuBarWidget->setVisible(showMenu);