diff --git a/ClockWidget.cxx b/ClockWidget.cxx
index 052209b..9b3ad96 100644
--- a/ClockWidget.cxx
+++ b/ClockWidget.cxx
@@ -1,244 +1,248 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
Copyright 2017,2018 Martin Koller, kollix@aon.at
This file is part of liquidshell.
liquidshell 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 3 of the License, or
(at your option) any later version.
liquidshell 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 liquidshell. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//--------------------------------------------------------------------------------
CalendarPopup::CalendarPopup(QWidget *parent)
: QFrame(parent)
{
setWindowFlags(windowFlags() | Qt::Popup);
setFrameShape(QFrame::StyledPanel);
QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setContentsMargins(QMargins());
cal = new QCalendarWidget;
vbox->addWidget(cal);
QPushButton *today = new QPushButton(QIcon::fromTheme("go-jump-today"), QString());
vbox->addWidget(today);
connect(today, &QPushButton::clicked, this, &CalendarPopup::goToday);
}
//--------------------------------------------------------------------------------
void CalendarPopup::goToday()
{
cal->showToday();
cal->setSelectedDate(QDate::currentDate());
}
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
ClockWidget::ClockWidget(DesktopPanel *parent)
: QFrame(parent), calendar(nullptr)
{
ensurePolished(); // make sure we already have the css applied
timer = new QTimer(this);
// if seconds are shown, update every second, else less often
if ( timeFormat.contains('s') )
timer->setInterval(1000);
else
timer->setInterval(5000);
timer->start();
connect(timer, &QTimer::timeout, this, &ClockWidget::tick);
connect(parent, &DesktopPanel::rowsChanged, this, &ClockWidget::fill);
timeLabel = new QLabel(this);
dayLabel = new QLabel(this);
dateLabel = new QLabel(this);
timeLabel->setObjectName("time");
dayLabel->setObjectName("day");
dateLabel->setObjectName("date");
- timeLabel->setContentsMargins(QMargins(0, -5, 0, -5));
- dayLabel->setContentsMargins(QMargins(0, -5, 0, -5));
- dateLabel->setContentsMargins(QMargins(0, -5, 0, -5));
+ timeLabel->setTextFormat(Qt::PlainText);
+ dayLabel->setTextFormat(Qt::PlainText);
+ dateLabel->setTextFormat(Qt::PlainText);
timeLabel->setAlignment(Qt::AlignCenter);
dayLabel->setAlignment(Qt::AlignCenter);
dateLabel->setAlignment(Qt::AlignCenter);
QFont f = font();
f.setPointSizeF(fontInfo().pointSizeF() * 1.5);
f.setBold(true);
timeLabel->setFont(f);
fill();
timeLabel->setVisible(!timeFormat.isEmpty());
dayLabel->setVisible(!dayFormat.isEmpty());
dateLabel->setVisible(!dateFormat.isEmpty());
// context menu
QAction *action = new QAction(this);
action->setIcon(QIcon::fromTheme("configure"));
action->setText(i18n("Select Timezones..."));
addAction(action);
connect(action, &QAction::triggered,
[this]()
{
ClockWidgetConfigureDialog dialog(parentWidget(), timeZoneIds);
dialog.setWindowTitle(i18n("Select Timezones"));
dialog.resize(600, 400);
if ( dialog.exec() == QDialog::Accepted )
{
timeZoneIds = dialog.getSelectedTimeZoneIds();
KConfig config;
KConfigGroup group = config.group("ClockWidget");
QStringList list;
for (const QByteArray &id : timeZoneIds)
list.append(id);
group.writeEntry("timeZoneIds", list);
tick(); // update tooltip
}
}
);
action = new QAction(this);
action->setIcon(QIcon::fromTheme("preferences-system-time"));
action->setText(i18n("Configure Date & Time..."));
addAction(action);
connect(action, &QAction::triggered,
[this]()
{
auto dialog = new KCMultiDialog(parentWidget());
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowTitle(i18n("Date & Time"));
dialog->addModule("clock");
dialog->adjustSize();
dialog->show();
}
);
setContextMenuPolicy(Qt::ActionsContextMenu);
// load config
KConfig config;
KConfigGroup group = config.group("ClockWidget");
QStringList list;
list = group.readEntry("timeZoneIds", QStringList());
for (const QString &id : list)
timeZoneIds.append(id.toLatin1());
tick();
+
+ timeLabel->setFixedHeight(timeLabel->fontMetrics().tightBoundingRect(timeLabel->text()).height() + 2);
+ dayLabel->setFixedHeight(dayLabel->fontMetrics().tightBoundingRect(dayLabel->text()).height() + 4);
+ dateLabel->setFixedHeight(dateLabel->fontMetrics().tightBoundingRect(dateLabel->text()).height() + 4);
}
//--------------------------------------------------------------------------------
void ClockWidget::fill()
{
delete layout();
const int MAX_ROWS = qobject_cast(parentWidget())->getRows();
QBoxLayout *box;
if ( MAX_ROWS >= 2 )
{
box = new QVBoxLayout(this);
box->setSpacing(0);
}
else
{
box = new QHBoxLayout(this);
}
box->setContentsMargins(QMargins());
box->addWidget(timeLabel);
box->addWidget(dayLabel);
box->addWidget(dateLabel);
}
//--------------------------------------------------------------------------------
void ClockWidget::tick()
{
QDateTime dateTimeUtc = QDateTime::currentDateTimeUtc();
QDateTime dateTime = dateTimeUtc.toLocalTime();
timeLabel->setText(dateTime.time().toString(timeFormat));
dayLabel->setText(dateTime.date().toString(dayFormat));
dateLabel->setText(dateTime.date().toString(dateFormat));
if ( !timeZoneIds.isEmpty() )
{
QString tip = "";
for (const QByteArray &id : timeZoneIds)
{
QTimeZone timeZone(id);
QDateTime dt = dateTimeUtc;
dateTime = dt.toTimeZone(timeZone);
tip += QString("%1 | %2 | %3 | %4 |
")
.arg(QLatin1String(id))
.arg(dateTime.time().toString(timeFormat))
.arg(dateTime.date().toString(dayFormat))
.arg(dateTime.date().toString(dateFormat));
}
tip += "
";
setToolTip(tip);
}
}
//--------------------------------------------------------------------------------
void ClockWidget::mousePressEvent(QMouseEvent *event)
{
if ( event->button() == Qt::LeftButton )
{
if ( !calendar )
calendar = new CalendarPopup(this);
calendar->goToday();
QPoint point = mapToGlobal(pos());
QRect screen = QApplication::desktop()->availableGeometry(this);
point.setX(std::min(point.x(), screen.x() + screen.width() - calendar->sizeHint().width()));
point.setY(point.y() - calendar->sizeHint().height());
calendar->move(point);
calendar->show();
}
}
//--------------------------------------------------------------------------------
diff --git a/PagerButton.cxx b/PagerButton.cxx
index d867cef..de14b4b 100644
--- a/PagerButton.cxx
+++ b/PagerButton.cxx
@@ -1,187 +1,187 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
Copyright 2017, 2018 Martin Koller, kollix@aon.at
This file is part of liquidshell.
liquidshell 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 3 of the License, or
(at your option) any later version.
liquidshell 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 liquidshell. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//--------------------------------------------------------------------------------
PagerButton::PagerButton(int num, DesktopPanel *p, bool doShowIcon)
: desktop(num), panel(p), showIcon(doShowIcon)
{
setText(KWindowSystem::desktopName(desktop).isEmpty() ?
QString::number(desktop) : KWindowSystem::desktopName(desktop));
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
setAcceptDrops(true);
dragDropTimer.setSingleShot(true);
dragDropTimer.setInterval(1000);
connect(&dragDropTimer, &QTimer::timeout, this, [this]() { emit clicked(true); });
if ( showIcon )
{
createPixmap();
connect(KWindowSystem::self(), &KWindowSystem::windowAdded,
this, &PagerButton::createPixmap);
connect(KWindowSystem::self(), &KWindowSystem::windowRemoved,
this, &PagerButton::createPixmap);
connect(KWindowSystem::self(), &KWindowSystem::stackingOrderChanged,
this, &PagerButton::createPixmap);
connect(KWindowSystem::self(), SIGNAL(windowChanged(WId, NET::Properties, NET::Properties2)),
this, SLOT(windowChanged(WId, NET::Properties, NET::Properties2)));
connect(KIconLoader::global(), &KIconLoader::iconLoaderSettingsChanged, this, [this]() { updateGeometry(); });
}
connect(KWindowSystem::self(), &KWindowSystem::desktopNamesChanged, this,
[this]()
{
setText(KWindowSystem::desktopName(desktop).isEmpty() ?
QString::number(desktop) : KWindowSystem::desktopName(desktop));
});
}
//--------------------------------------------------------------------------------
QSize PagerButton::sizeHint() const
{
QSize s = fontMetrics().size(0, text());
s.setWidth(std::max(45, s.width() + 10));
- s.setHeight(QPushButton::sizeHint().height());
+ s.setHeight(QPushButton::sizeHint().height() - 2);
if ( panel->getRows() == 1 )
s.setHeight(std::max(s.height(), KIconLoader::global()->currentSize(KIconLoader::Panel)));
return s;
}
//--------------------------------------------------------------------------------
void PagerButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
QStyleOptionButton option;
initStyleOption(&option);
style()->drawControl(QStyle::CE_PushButtonBevel, &option, &painter, this);
if ( !firstPixmap.isNull() )
painter.drawPixmap((width() - firstPixmap.width()) / 2, (height() - firstPixmap.height()) / 2, firstPixmap);
style()->drawControl(QStyle::CE_PushButtonLabel, &option, &painter, this);
}
//--------------------------------------------------------------------------------
void PagerButton::createPixmap()
{
firstPixmap = QPixmap();
QList windows = KWindowSystem::stackingOrder();
// from top to bottom
for (int i = windows.count() - 1; i >= 0; i--)
{
WId wid = windows[i];
KWindowInfo win(wid, NET::WMDesktop | NET::WMWindowType | NET::WMState | NET::WMIcon);
if ( win.valid(true) && win.isOnDesktop(desktop) &&
(win.windowType(NET::DesktopMask) != NET::Desktop) &&
(win.windowType(NET::DockMask) != NET::Dock) &&
!(win.state() & NET::SkipTaskbar) )
{
firstPixmap = KWindowSystem::icon(wid, 22, 22, true);
KIconEffect effect;
firstPixmap = effect.apply(firstPixmap, KIconEffect::DeSaturate, 0, QColor(), true);
break;
}
}
update();
}
//--------------------------------------------------------------------------------
void PagerButton::windowChanged(WId id, NET::Properties props, NET::Properties2 props2)
{
Q_UNUSED(id)
Q_UNUSED(props2)
if ( props & (NET::WMIcon | NET::WMDesktop) )
createPixmap();
}
//--------------------------------------------------------------------------------
void PagerButton::dragEnterEvent(QDragEnterEvent *event)
{
event->accept();
dragDropTimer.start();
}
//--------------------------------------------------------------------------------
void PagerButton::dragLeaveEvent(QDragLeaveEvent *event)
{
event->accept();
dragDropTimer.stop();
}
//--------------------------------------------------------------------------------
void PagerButton::dropEvent(QDropEvent *event)
{
dragDropTimer.stop();
if ( !event->mimeData()->hasFormat("application/x-winId") )
{
event->ignore();
return;
}
event->acceptProposedAction();
WId wid = static_cast(event->mimeData()->data("application/x-winId").toInt());
KWindowSystem::setOnDesktop(wid, desktop);
}
//--------------------------------------------------------------------------------
diff --git a/QuickLaunch.cxx b/QuickLaunch.cxx
index 3c1078d..29160b1 100644
--- a/QuickLaunch.cxx
+++ b/QuickLaunch.cxx
@@ -1,157 +1,161 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
- Copyright 2017 Martin Koller, kollix@aon.at
+ Copyright 2017 - 2019 Martin Koller, kollix@aon.at
This file is part of liquidshell.
liquidshell 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 3 of the License, or
(at your option) any later version.
liquidshell 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 liquidshell. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//--------------------------------------------------------------------------------
QuickLaunch::QuickLaunch(DesktopPanel *parent)
: Launcher(parent, "QuickLaunch")
{
QFrame *frame = new QFrame;
frame->setFrameShape(QFrame::StyledPanel);
grid = new QGridLayout(frame);
grid->setContentsMargins(QMargins());
grid->setSpacing(2);
layout()->addWidget(frame);
loadConfig();
connect(parent, &DesktopPanel::rowsChanged, this, &QuickLaunch::fill);
connect(KIconLoader::global(), &KIconLoader::iconLoaderSettingsChanged, this, &QuickLaunch::fill);
}
//--------------------------------------------------------------------------------
void QuickLaunch::fill()
{
const int MAX_ROWS = qobject_cast(parentWidget())->getRows();
QLayoutItem *child;
while ( (child = grid->takeAt(0)) )
{
delete child->widget();
delete child;
}
if ( !dirPath.isEmpty() )
{
QDir dir(dirPath);
QFileInfoList entries = dir.entryInfoList(QDir::Files);
int row = 0, col = 0;
for (const QFileInfo &info : entries)
{
QUrl url(QUrl::fromLocalFile(info.absoluteFilePath()));
QIcon icon;
QString name = info.fileName();
KFileItem item(url);
if ( item.isDesktopFile() )
{
KDesktopFile desktopFile(info.absoluteFilePath());
if ( desktopFile.noDisplay() )
continue;
name = desktopFile.readName();
if ( name.isEmpty() )
name = desktopFile.readGenericName();
QString iconName = desktopFile.readIcon();
icon = QIcon::fromTheme(iconName.isEmpty() ? name : iconName);
}
else
{
QMimeDatabase db;
icon = QIcon::fromTheme(db.mimeTypeForFile(info.absoluteFilePath()).iconName());
}
QToolButton *button = new QToolButton(this);
button->setAutoRaise(true);
button->setIcon(icon);
button->setToolTip(name);
if ( MAX_ROWS > 1 )
button->setIconSize(QSize(22, 22));
else
{
int size = KIconLoader::global()->currentSize(KIconLoader::Panel);
button->setIconSize(QSize(size, size));
}
+ button->setFixedHeight(button->sizeHint().height() - 2);
+
connect(button, &QToolButton::clicked, [url]() { new KRun(url, nullptr); });
grid->addWidget(button, row, col, Qt::AlignCenter);
row = (row + 1) % MAX_ROWS;
if ( row == 0 ) col++;
// limit width in case one selects a directory with too many items
const int MAX_COLS = 15;
if ( col > MAX_COLS )
break;
}
}
if ( grid->count() == 0 )
{
// add default entry
QToolButton *button = new QToolButton(this);
button->setAutoRaise(true);
button->setIcon(QIcon::fromTheme("user-home"));
button->setIconSize(QSize(22, 22));
+ button->setFixedHeight(button->sizeHint().height() - 2);
button->setToolTip(QStandardPaths::displayName(QStandardPaths::HomeLocation));
QUrl url = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation));
connect(button, &QToolButton::clicked, [url]() { new KRun(url, nullptr); });
grid->addWidget(button, 0, 0, Qt::AlignCenter);
button = new QToolButton(this);
button->setAutoRaise(true);
button->setIcon(QIcon::fromTheme("internet-web-browser"));
button->setIconSize(QSize(22, 22));
+ button->setFixedHeight(button->sizeHint().height() - 2);
button->setToolTip(i18n("Web Browser"));
connect(button, &QToolButton::clicked, []() { new KRun(QUrl("http://www.kde.org"), nullptr); });
if ( MAX_ROWS == 1 )
grid->addWidget(button, 0, 1, Qt::AlignCenter);
else
grid->addWidget(button, 1, 0, Qt::AlignCenter);
}
}
//--------------------------------------------------------------------------------
diff --git a/TaskBarButton.cxx b/TaskBarButton.cxx
index 2f29bcd..86d1065 100644
--- a/TaskBarButton.cxx
+++ b/TaskBarButton.cxx
@@ -1,262 +1,271 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
- Copyright 2017 Martin Koller, kollix@aon.at
+ Copyright 2017, 2018, 2019 Martin Koller, kollix@aon.at
This file is part of liquidshell.
liquidshell 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 3 of the License, or
(at your option) any later version.
liquidshell 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 liquidshell. If not, see .
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//--------------------------------------------------------------------------------
TaskBarButton::TaskBarButton(WId theWid)
: wid(theWid)
{
setAutoFillBackground(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
setAcceptDrops(true);
dragDropTimer.setSingleShot(true);
dragDropTimer.setInterval(1000);
connect(&dragDropTimer, &QTimer::timeout,
[this]() { KWindowSystem::raiseWindow(wid); KWindowSystem::forceActiveWindow(wid); });
QHBoxLayout *hbox = new QHBoxLayout(this);
hbox->setContentsMargins(QMargins(4, 2, 4, 2));
iconLabel = new QLabel;
iconLabel->setScaledContents(true);
iconLabel->setFixedSize(32, 32);
iconLabel->setContextMenuPolicy(Qt::PreventContextMenu);
hbox->addWidget(iconLabel);
textLabel = new KSqueezedTextLabel;
textLabel->setTextElideMode(Qt::ElideRight);
textLabel->setContextMenuPolicy(Qt::PreventContextMenu);
hbox->addWidget(textLabel);
fill();
setBackground();
connect(KWindowSystem::self(), SIGNAL(windowChanged(WId, NET::Properties, NET::Properties2)),
this, SLOT(windowChanged(WId, NET::Properties, NET::Properties2)));
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged,
this, &TaskBarButton::setBackground);
}
//--------------------------------------------------------------------------------
void TaskBarButton::setIconSize(int size)
{
iconLabel->setFixedSize(size, size);
}
//--------------------------------------------------------------------------------
void TaskBarButton::fill()
{
KWindowInfo win(wid, NET::WMName | NET::WMIcon);
iconLabel->setPixmap(KWindowSystem::icon(wid, 32, 32, true));
textLabel->setText(win.name());
setToolTip(win.name());
}
//--------------------------------------------------------------------------------
void TaskBarButton::mousePressEvent(QMouseEvent *event)
{
if ( event->button() == Qt::LeftButton )
{
KWindowSystem::setShowingDesktop(false);
if ( wid == KWindowSystem::activeWindow() )
KWindowSystem::minimizeWindow(wid);
else
KWindowSystem::forceActiveWindow(wid);
dragStartPos = event->pos();
event->accept();
}
else if ( event->button() == Qt::RightButton )
{
// context menu to close window etc.
QPointer menu(new QMenu(this));
if ( KWindowSystem::numberOfDesktops() > 1 )
{
QMenu *desktops = menu->addMenu(i18n("Move To Desktop"));
desktops->addAction(i18n("All Desktops"), [this]() { KWindowSystem::setOnAllDesktops(wid, true); });
desktops->addSeparator();
for (int i = 1; i <= KWindowSystem::numberOfDesktops(); i++)
desktops->addAction(KWindowSystem::desktopName(i), [this, i]() { KWindowSystem::setOnDesktop(wid, i); });
}
menu->addAction(QIcon::fromTheme("window-close"), i18n("Close"),
[this]()
{
NETRootInfo ri(QX11Info::connection(), NET::CloseWindow);
ri.closeWindowRequest(wid);
}
);
menu->exec(event->globalPos());
delete menu;
}
}
//--------------------------------------------------------------------------------
void TaskBarButton::mouseMoveEvent(QMouseEvent *event)
{
event->accept();
if ( (event->buttons() == Qt::LeftButton) &&
(event->pos() - dragStartPos).manhattanLength() > QGuiApplication::styleHints()->startDragDistance() )
{
QDrag *drag = new QDrag(parentWidget());
QMimeData *mimeData = new QMimeData;
mimeData->setData("application/x-winId", QByteArray::number(static_cast(wid)));
drag->setMimeData(mimeData);
drag->setPixmap(*(iconLabel->pixmap()));
drag->exec();
}
}
//--------------------------------------------------------------------------------
void TaskBarButton::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
QStyleOptionButton option;
initStyleOption(&option);
style()->drawControl(QStyle::CE_PushButtonBevel, &option, &painter, this);
}
//--------------------------------------------------------------------------------
void TaskBarButton::windowChanged(WId id, NET::Properties props, NET::Properties2 props2)
{
Q_UNUSED(id)
Q_UNUSED(props2)
//qDebug() << textLabel->text() << props << (props & (NET::WMVisibleName | NET::WMState | NET::WMName));
//qDebug() << this << id << props << "me" << (wid == id);
//if ( (id != wid) || (props == 0) )
//return;
if ( props & (NET::WMState | NET::ActiveWindow) )
setBackground();
// WMVisibleName alone is not enough. WMName needed
if ( (wid == id) && (props & (NET::WMIcon | NET::WMName)) )
fill();
}
//--------------------------------------------------------------------------------
void TaskBarButton::setBackground()
{
KColorScheme scheme(QPalette::Active, KColorScheme::Window);
QPalette pal = palette();
KWindowInfo win(wid, NET::WMState);
if ( win.state() & NET::Hidden )
pal.setBrush(foregroundRole(), scheme.foreground(KColorScheme::InactiveText));
else
pal.setBrush(foregroundRole(), scheme.foreground(KColorScheme::NormalText));
QBrush brush;
if ( win.state() & NET::DemandsAttention )
brush = scheme.background(KColorScheme::ActiveBackground);
else if ( wid == KWindowSystem::activeWindow() )
brush = scheme.shade(KColorScheme::MidShade);
else
brush = scheme.background();
pal.setBrush(backgroundRole(), brush);
setPalette(pal);
}
//--------------------------------------------------------------------------------
void TaskBarButton::dragEnterEvent(QDragEnterEvent *event)
{
event->accept();
dragDropTimer.start();
}
//--------------------------------------------------------------------------------
void TaskBarButton::dragLeaveEvent(QDragLeaveEvent *event)
{
event->accept();
dragDropTimer.stop();
}
//--------------------------------------------------------------------------------
void TaskBarButton::dropEvent(QDropEvent *event)
{
event->accept();
dragDropTimer.stop();
}
//--------------------------------------------------------------------------------
void TaskBarButton::updateWMGeometry()
{
NETWinInfo info(QX11Info::connection(), wid, QX11Info::appRootWindow(), 0, 0);
NETRect rect;
QPoint globalPos = mapToGlobal(QPoint(0, 0));
rect.pos.x = globalPos.x();
rect.pos.y = globalPos.y();
rect.size.width = width();
rect.size.height = height();
info.setIconGeometry(rect);
}
//--------------------------------------------------------------------------------
+
+QSize TaskBarButton::sizeHint() const
+{
+ QSize s = QPushButton::sizeHint();
+ s.setHeight(s.height() - 2);
+ return s;
+}
+
+//--------------------------------------------------------------------------------
diff --git a/TaskBarButton.hxx b/TaskBarButton.hxx
index 1079bf0..4430ab0 100644
--- a/TaskBarButton.hxx
+++ b/TaskBarButton.hxx
@@ -1,69 +1,71 @@
// SPDX-License-Identifier: GPL-3.0-or-later
/*
Copyright 2017 Martin Koller, kollix@aon.at
This file is part of liquidshell.
liquidshell 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 3 of the License, or
(at your option) any later version.
liquidshell 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 liquidshell. If not, see .
*/
#ifndef _TaskBarButton_H_
#define _TaskBarButton_H_
#include
#include
class QLabel;
class KSqueezedTextLabel;
#include
class TaskBarButton : public QPushButton
{
Q_OBJECT
public:
TaskBarButton(WId wid);
void setIconSize(int size);
+ QSize sizeHint() const override;
+
Q_SIGNALS:
void clicked();
protected:
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent *event) override;
void moveEvent(QMoveEvent *) override { updateWMGeometry(); }
void resizeEvent(QResizeEvent *) override { updateWMGeometry(); }
private Q_SLOTS:
void fill();
void setBackground();
void windowChanged(WId id, NET::Properties props, NET::Properties2 props2);
private:
void updateWMGeometry();
private:
WId wid;
QLabel *iconLabel;
KSqueezedTextLabel *textLabel;
QTimer dragDropTimer;
QPoint dragStartPos;
};
#endif